@@ -169,7 +169,7 @@ public void translate(List<DetectorDataDgtz> detectorData){
169169 }
170170 }
171171
172- public void fitPulses (List <DetectorDataDgtz > detectorData ){
172+ public void fitPulses (List <DetectorDataDgtz > detectorData ) {
173173
174174 // preload CCDB tables once:
175175 ArrayList <IndexedTable > tables = new ArrayList <>();
@@ -179,41 +179,41 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
179179
180180 final long hash0 = IndexedTable .DEFAULT_GENERATOR .hashCode (0 ,0 ,0 );
181181
182- for (DetectorDataDgtz data : detectorData ){
182+ for (DetectorDataDgtz data : detectorData ) {
183+
183184 if (data .getADCSize () == 0 ) continue ;
184185 int crate = data .getDescriptor ().getCrate ();
185186 int slot = data .getDescriptor ().getSlot ();
186187 int channel = data .getDescriptor ().getChannel ();
187- long hash = IndexedTable .DEFAULT_GENERATOR .hashCode (crate ,slot ,channel );
188- boolean ismm = keysMicromega .contains (data .getDescriptor ().getType ());
189-
190- for (int j =0 ; j <keysFitter .size (); ++j ) {
191- IndexedTable daqTable = tables .get (j );
192- DetectorType tableType = keysFitter .get (j );
193- //custom MM fitter
194- if (ismm && data .getDescriptor ().getType () == tableType ) {
195- short adcOffset = (short ) daqTable .getDoubleValueByHash ("adc_offset" , hash0 );
196- double fineTimeStampResolution = (byte ) daqTable .getDoubleValueByHash ("dream_clock" , hash0 );
197- double samplingTime = (byte ) daqTable .getDoubleValueByHash ("sampling_time" , hash0 );
198- int sparseSample = daqTable .getIntValueByHash ("sparse" , hash0 );
199- ADCData adc = data .getADCData (0 );
200- mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
201- adc .setHeight ((short ) (mvtFitter .adcMax ));
202- adc .setTime ((int ) (mvtFitter .timeMax ));
203- adc .setIntegral ((int ) (mvtFitter .integral ));
204- adc .setTimeStamp (mvtFitter .timestamp );
205- // first one wins:
206- break ;
207- }
208- else if (daqTable .hasEntryByHash (hash )==true ){
188+ DetectorType type = data .getDescriptor ().getType ();
189+
190+ int idx = keysFitter .indexOf (type );
191+ if (idx < 0 ) continue ;
192+ IndexedTable daqTable = tables .get (idx );
193+
194+ if (keysMicromega .contains (data .getDescriptor ().getType ())) {
195+ short adcOffset = (short ) daqTable .getDoubleValueByHash ("adc_offset" , hash0 );
196+ double fineTimeStampResolution = (byte ) daqTable .getDoubleValueByHash ("dream_clock" , hash0 );
197+ double samplingTime = (byte ) daqTable .getDoubleValueByHash ("sampling_time" , hash0 );
198+ int sparseSample = daqTable .getIntValueByHash ("sparse" , hash0 );
199+ ADCData adc = data .getADCData (0 );
200+ mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
201+ adc .setHeight ((short ) (mvtFitter .adcMax ));
202+ adc .setTime ((int ) (mvtFitter .timeMax ));
203+ adc .setIntegral ((int ) (mvtFitter .integral ));
204+ adc .setTimeStamp (mvtFitter .timestamp );
205+ }
206+ else {
207+ long hash = IndexedTable .DEFAULT_GENERATOR .hashCode (crate ,slot ,channel );
208+ if (daqTable .hasEntryByHash (hash )==true ){
209209 int nsa = daqTable .getIntValueByHash ("nsa" , hash );
210210 int nsb = daqTable .getIntValueByHash ("nsb" , hash );
211211 int tet = daqTable .getIntValueByHash ("tet" , hash );
212212 int ped = 0 ;
213- if (data .getDescriptor ().getType () == DetectorType .RF && tableType == DetectorType .RF ) {
213+ if (data .getDescriptor ().getType () == DetectorType .RF && type == DetectorType .RF ) {
214214 ped = daqTable .getIntValueByHash ("pedestal" , hash );
215215 }
216- for (int i = 0 ; i < data .getADCSize (); i ++){
216+ for (int i = 0 ; i < data .getADCSize (); i ++) {
217217 ADCData adc = data .getADCData (i );
218218 if (adc .getPulseSize ()>0 ){
219219 try {
@@ -230,8 +230,6 @@ else if(daqTable.hasEntryByHash(hash)==true){
230230 }
231231 data .getADCData (i ).setADC (nsa , nsb );
232232 }
233- // first one wins:
234- break ;
235233 }
236234 }
237235 }
0 commit comments