@@ -28,6 +28,7 @@ public class DetectorEventDecoder {
2828 List <DetectorType > keysTrans = null ;
2929 List <DetectorType > keysFitter = null ;
3030 List <DetectorType > keysFilter = null ;
31+ List <DetectorType > keysMicromega = null ;
3132
3233 private int runNumber = 10 ;
3334
@@ -121,7 +122,9 @@ public final void initDecoder(){
121122
122123 scalerManager .init (Arrays .asList (new String []{"/runcontrol/fcup" ,"/runcontrol/slm" ,"/runcontrol/hwp" ,
123124 "/runcontrol/helicity" ,"/daq/config/scalers/dsc1" }));
124-
125+
126+ keysMicromega = Arrays .asList (new DetectorType []{DetectorType .BMT ,DetectorType .FMT ,DetectorType .FTTRK });
127+
125128 checkTables ();
126129 }
127130
@@ -191,70 +194,64 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
191194 }
192195
193196 for (DetectorDataDgtz data : detectorData ){
197+ if (data .getADCSize () == 0 ) continue ;
194198 int crate = data .getDescriptor ().getCrate ();
195199 int slot = data .getDescriptor ().getSlot ();
196200 int channel = data .getDescriptor ().getChannel ();
197201 long hash = IndexedTable .DEFAULT_GENERATOR .hashCode (crate ,slot ,channel );
198202 long hash0 = IndexedTable .DEFAULT_GENERATOR .hashCode (0 ,0 ,0 );
203+ boolean ismm = keysMicromega .contains (data .getDescriptor ().getType ());
204+
199205 for (int j =0 ; j <keysFitter .size (); ++j ) {
200206 IndexedTable daq = tables .get (j );
201207 DetectorType type = keysFitter .get (j );
202208 //custom MM fitter
203- if ( ( (type == DetectorType .BMT )&&(data .getDescriptor ().getType ().getName ().equals ("BMT" )) )
204- || ( (type == DetectorType .FMT )&&(data .getDescriptor ().getType ().getName ().equals ("FMT" )) )
205- //|| ( (type == DetectorType.AHDC)&&(data.getDescriptor().getType().getName().equals("AHDC")) )
206- || ( (type == DetectorType .FTTRK )&&(data .getDescriptor ().getType ().getName ().equals ("FTTRK" )) ) ){
209+ if (ismm && data .getDescriptor ().getType () == type ) {
207210 short adcOffset = (short ) daq .getDoubleValueByHash ("adc_offset" , hash0 );
208211 double fineTimeStampResolution = (byte ) daq .getDoubleValueByHash ("dream_clock" , hash0 );
209212 double samplingTime = (byte ) daq .getDoubleValueByHash ("sampling_time" , hash0 );
210213 int sparseSample = daq .getIntValueByHash ("sparse" , hash0 );
211- if (data .getADCSize () > 0 ) {
212- ADCData adc = data .getADCData (0 );
213- mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
214- adc .setHeight ((short ) (mvtFitter .adcMax ));
215- adc .setTime ((int ) (mvtFitter .timeMax ));
216- adc .setIntegral ((int ) (mvtFitter .integral ));
217- adc .setTimeStamp (mvtFitter .timestamp );
214+ ADCData adc = data .getADCData (0 );
215+ mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
216+ adc .setHeight ((short ) (mvtFitter .adcMax ));
217+ adc .setTime ((int ) (mvtFitter .timeMax ));
218+ adc .setIntegral ((int ) (mvtFitter .integral ));
219+ adc .setTimeStamp (mvtFitter .timestamp );
220+ // first one wins:
221+ break ;
222+ }
223+ else if (daq .hasEntryByHash (hash )==true ){
224+ int nsa = daq .getIntValueByHash ("nsa" , hash );
225+ int nsb = daq .getIntValueByHash ("nsb" , hash );
226+ int tet = daq .getIntValueByHash ("tet" , hash );
227+ int ped = 0 ;
228+ if (data .getDescriptor ().getType () == DetectorType .RF && type == DetectorType .RF ) {
229+ ped = daq .getIntValueByHash ("pedestal" , hash );
218230 }
219- } else {
220- if (daq .hasEntryByHash (hash )==true ){
221- int nsa = daq .getIntValueByHash ("nsa" , hash );
222- int nsb = daq .getIntValueByHash ("nsb" , hash );
223- int tet = daq .getIntValueByHash ("tet" , hash );
224- int ped = 0 ;
225- if (type == DetectorType .RF &&data .getDescriptor ().getType ().getName ().equals ("RF" )) {
226- ped = daq .getIntValueByHash ("pedestal" , hash );
227- }
228- if (data .getADCSize ()>0 ){
229- for (int i = 0 ; i < data .getADCSize (); i ++){
230- ADCData adc = data .getADCData (i );
231- if (adc .getPulseSize ()>0 ){
232- try {
233- extendedFitter .fit (nsa , nsb , tet , ped , adc .getPulseArray ());
234- } catch (Exception e ) {
235- System .out .println (">>>> error : fitting pulse "
236- + crate + " / " + slot + " / " + channel );
237- }
238- int adc_corrected = extendedFitter .adc + extendedFitter .ped *(nsa +nsb );
239- adc .setHeight ((short ) this .extendedFitter .pulsePeakValue );
240- adc .setIntegral (adc_corrected );
241- adc .setTimeWord (this .extendedFitter .t0 );
242- adc .setPedestal ((short ) this .extendedFitter .ped );
243- }
244- }
245- }
246- if (data .getADCSize ()>0 ){
247- for (int i = 0 ; i < data .getADCSize (); i ++){
248- data .getADCData (i ).setADC (nsa , nsb );
231+ for (int i = 0 ; i < data .getADCSize (); i ++){
232+ ADCData adc = data .getADCData (i );
233+ if (adc .getPulseSize ()>0 ){
234+ try {
235+ extendedFitter .fit (nsa , nsb , tet , ped , adc .getPulseArray ());
236+ } catch (Exception e ) {
237+ System .out .println (">>>> error : fitting pulse "
238+ + crate + " / " + slot + " / " + channel );
249239 }
240+ int adc_corrected = extendedFitter .adc + extendedFitter .ped *(nsa +nsb );
241+ adc .setHeight ((short ) this .extendedFitter .pulsePeakValue );
242+ adc .setIntegral (adc_corrected );
243+ adc .setTimeWord (this .extendedFitter .t0 );
244+ adc .setPedestal ((short ) this .extendedFitter .ped );
250245 }
246+ data .getADCData (i ).setADC (nsa , nsb );
251247 }
248+ // first one wins:
249+ break ;
252250 }
253251 }
254252 }
255253 }
256254
257-
258255 public void filterTDCs (List <DetectorDataDgtz > detectorData ){
259256 int maxMultiplicity = 1 ;
260257 for (DetectorType type : keysFilter ){
0 commit comments