@@ -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
@@ -128,7 +129,9 @@ public final void initDecoder(){
128129
129130 scalerManager .init (Arrays .asList (new String []{"/runcontrol/fcup" ,"/runcontrol/slm" ,"/runcontrol/hwp" ,
130131 "/runcontrol/helicity" ,"/daq/config/scalers/dsc1" }));
131-
132+
133+ keysMicromega = Arrays .asList (new DetectorType []{DetectorType .BMT ,DetectorType .FMT ,DetectorType .FTTRK });
134+
132135 checkTables ();
133136 }
134137
@@ -175,70 +178,64 @@ public void fitPulses(List<DetectorDataDgtz> detectorData){
175178 }
176179
177180 for (DetectorDataDgtz data : detectorData ){
181+ if (data .getADCSize () == 0 ) continue ;
178182 int crate = data .getDescriptor ().getCrate ();
179183 int slot = data .getDescriptor ().getSlot ();
180184 int channel = data .getDescriptor ().getChannel ();
181185 long hash = IndexedTable .DEFAULT_GENERATOR .hashCode (crate ,slot ,channel );
182186 long hash0 = IndexedTable .DEFAULT_GENERATOR .hashCode (0 ,0 ,0 );
187+ boolean ismm = keysMicromega .contains (data .getDescriptor ().getType ());
188+
183189 for (int j =0 ; j <keysFitter .size (); ++j ) {
184190 IndexedTable daq = tables .get (j );
185191 DetectorType type = keysFitter .get (j );
186192 //custom MM fitter
187- if ( ( (type == DetectorType .BMT )&&(data .getDescriptor ().getType ().getName ().equals ("BMT" )) )
188- || ( (type == DetectorType .FMT )&&(data .getDescriptor ().getType ().getName ().equals ("FMT" )) )
189- //|| ( (type == DetectorType.AHDC)&&(data.getDescriptor().getType().getName().equals("AHDC")) )
190- || ( (type == DetectorType .FTTRK )&&(data .getDescriptor ().getType ().getName ().equals ("FTTRK" )) ) ){
193+ if (ismm && data .getDescriptor ().getType () == type ) {
191194 short adcOffset = (short ) daq .getDoubleValueByHash ("adc_offset" , hash0 );
192195 double fineTimeStampResolution = (byte ) daq .getDoubleValueByHash ("dream_clock" , hash0 );
193196 double samplingTime = (byte ) daq .getDoubleValueByHash ("sampling_time" , hash0 );
194197 int sparseSample = daq .getIntValueByHash ("sparse" , hash0 );
195- if (data .getADCSize () > 0 ) {
196- ADCData adc = data .getADCData (0 );
197- mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
198- adc .setHeight ((short ) (mvtFitter .adcMax ));
199- adc .setTime ((int ) (mvtFitter .timeMax ));
200- adc .setIntegral ((int ) (mvtFitter .integral ));
201- adc .setTimeStamp (mvtFitter .timestamp );
198+ ADCData adc = data .getADCData (0 );
199+ mvtFitter .fit (adcOffset , fineTimeStampResolution , samplingTime , adc .getPulseArray (), adc .getTimeStamp (), sparseSample );
200+ adc .setHeight ((short ) (mvtFitter .adcMax ));
201+ adc .setTime ((int ) (mvtFitter .timeMax ));
202+ adc .setIntegral ((int ) (mvtFitter .integral ));
203+ adc .setTimeStamp (mvtFitter .timestamp );
204+ // first one wins:
205+ break ;
206+ }
207+ else if (daq .hasEntryByHash (hash )==true ){
208+ int nsa = daq .getIntValueByHash ("nsa" , hash );
209+ int nsb = daq .getIntValueByHash ("nsb" , hash );
210+ int tet = daq .getIntValueByHash ("tet" , hash );
211+ int ped = 0 ;
212+ if (data .getDescriptor ().getType () == DetectorType .RF && type == DetectorType .RF ) {
213+ ped = daq .getIntValueByHash ("pedestal" , hash );
202214 }
203- } else {
204- if (daq .hasEntryByHash (hash )==true ){
205- int nsa = daq .getIntValueByHash ("nsa" , hash );
206- int nsb = daq .getIntValueByHash ("nsb" , hash );
207- int tet = daq .getIntValueByHash ("tet" , hash );
208- int ped = 0 ;
209- if (type == DetectorType .RF &&data .getDescriptor ().getType ().getName ().equals ("RF" )) {
210- ped = daq .getIntValueByHash ("pedestal" , hash );
211- }
212- if (data .getADCSize ()>0 ){
213- for (int i = 0 ; i < data .getADCSize (); i ++){
214- ADCData adc = data .getADCData (i );
215- if (adc .getPulseSize ()>0 ){
216- try {
217- extendedFitter .fit (nsa , nsb , tet , ped , adc .getPulseArray ());
218- } catch (Exception e ) {
219- System .out .println (">>>> error : fitting pulse "
220- + crate + " / " + slot + " / " + channel );
221- }
222- int adc_corrected = extendedFitter .adc + extendedFitter .ped *(nsa +nsb );
223- adc .setHeight ((short ) this .extendedFitter .pulsePeakValue );
224- adc .setIntegral (adc_corrected );
225- adc .setTimeWord (this .extendedFitter .t0 );
226- adc .setPedestal ((short ) this .extendedFitter .ped );
227- }
228- }
229- }
230- if (data .getADCSize ()>0 ){
231- for (int i = 0 ; i < data .getADCSize (); i ++){
232- data .getADCData (i ).setADC (nsa , nsb );
215+ for (int i = 0 ; i < data .getADCSize (); i ++){
216+ ADCData adc = data .getADCData (i );
217+ if (adc .getPulseSize ()>0 ){
218+ try {
219+ extendedFitter .fit (nsa , nsb , tet , ped , adc .getPulseArray ());
220+ } catch (Exception e ) {
221+ System .out .println (">>>> error : fitting pulse "
222+ + crate + " / " + slot + " / " + channel );
233223 }
224+ int adc_corrected = extendedFitter .adc + extendedFitter .ped *(nsa +nsb );
225+ adc .setHeight ((short ) this .extendedFitter .pulsePeakValue );
226+ adc .setIntegral (adc_corrected );
227+ adc .setTimeWord (this .extendedFitter .t0 );
228+ adc .setPedestal ((short ) this .extendedFitter .ped );
234229 }
230+ data .getADCData (i ).setADC (nsa , nsb );
235231 }
232+ // first one wins:
233+ break ;
236234 }
237235 }
238236 }
239237 }
240238
241-
242239 public void filterTDCs (List <DetectorDataDgtz > detectorData ){
243240 int maxMultiplicity = 1 ;
244241 for (DetectorType type : keysFilter ){
0 commit comments