/[PAMELA software]/DarthVader/ToFLevel2/src/ToFLevel2.cpp
ViewVC logotype

Diff of /DarthVader/ToFLevel2/src/ToFLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by carbone, Fri Nov 20 11:05:21 2009 UTC revision 1.48 by pam-fi, Wed May 20 10:57:02 2015 UTC
# Line 21  ToFPMT::ToFPMT(){ Line 21  ToFPMT::ToFPMT(){
21    adc = 0.;    adc = 0.;
22    tdc_tw = 0.;    tdc_tw = 0.;
23    tdc = 0.;    tdc = 0.;
24      l0flag_adc = 0.;
25      l0flag_tdc = 0.;
26  }  }
27    
28  ToFPMT::ToFPMT(const ToFPMT &t){  ToFPMT::ToFPMT(const ToFPMT &t){
# Line 111  void ToFLevel2::Set(){//ELENA Line 113  void ToFLevel2::Set(){//ELENA
113      if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA      if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA
114      if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA      if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
115  }//ELENA  }//ELENA
116    //--------------------------------------
117    //
118    //
119    //--------------------------------------
120    void ToFLevel2::SetTrackArray(TClonesArray *track){//ELENA
121        if(track && strcmp(track->GetClass()->GetName(),"ToFTrkVar")==0){
122            if(ToFTrk)ToFTrk->Clear("C");
123            ToFTrk = track;
124        }
125    }
126    
127  void ToFLevel2::Clear(Option_t *t){  void ToFLevel2::Clear(Option_t *t){
128    //    //
# Line 118  void ToFLevel2::Clear(Option_t *t){ Line 130  void ToFLevel2::Clear(Option_t *t){
130    if(PMT)PMT->Delete(); //ELENA    if(PMT)PMT->Delete(); //ELENA
131    memset(tof_j_flag, 0, 6*sizeof(Int_t));    memset(tof_j_flag, 0, 6*sizeof(Int_t));
132    unpackError = 0;    unpackError = 0;
133      unpackWarning = 0;
134    //    //
135  };  };
136    
# Line 134  void ToFLevel2::Delete(Option_t *t){ //E Line 147  void ToFLevel2::Delete(Option_t *t){ //E
147    //    //
148  }; //ELENA  }; //ELENA
149    
150    /**
151     * Retrieves the itrk-th tof track stored in the array
152     * @param itrk Array index (min 0, max ToFLevel2::ntrk())
153     *
154     */
155  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){
156    //        //    
157    if(itrk >= ntrk()){    if(itrk >= ntrk()){
# Line 148  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t Line 166  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t
166    return toftrack;    return toftrack;
167  }  }
168    
169    /**
170     * Retrieves the tof track matching the seqno-th tracker stored track.
171     * @param seqno Track sequential number
172     * (seqno = -1 for standalone tof track, seqno=0-TrkLevel2::ntrk() for tof tracks associated to a tracker track)
173     *
174     */
175    ToFTrkVar *ToFLevel2::GetToFStoredTrack(int seqno){
176    
177      if( ntrk()==0 ){
178        printf("ToFLevel2::GetToFStoredTrack(int) : requested tracker SeqNo %i but no ToFrimeter tracks are stored\n",seqno);
179        return NULL;
180      };
181      
182      ToFTrkVar *c = 0;
183      Int_t it_tof=0;
184        
185      do {
186        c = GetToFTrkVar(it_tof);
187        it_tof++;
188      } while( c && seqno != c->trkseqno && it_tof < ntrk());      
189      
190      if(!c || seqno != c->trkseqno){
191        c = 0;
192        if(seqno!=-1 ) printf("ToFLevel2::GetToFStoredTrack(int) : requested tracker SeqNo %i does not match ToFrimeter stored tracks\n",seqno);
193      };
194      return c;
195        
196    }
197    
198    
199  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit){  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit){
200    //        //    
201    if(ihit >= npmt()){    if(ihit >= npmt()){
# Line 211  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 259  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
259         false) return true;         false) return true;
260      else return false;      else return false;
261  };  };
262    
263  /**  /**
264   * Method to get the number of hit paddles on a ToF plane.   * Strict method to get the number of hit paddles on a ToF plane.
265     * The method uses "HitPaddle" which checks if there is a TDC signal
266     * from both PMTs.
267   * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).   * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).
268   */   */
269  Int_t ToFLevel2::GetNHitPaddles(Int_t plane){  Int_t ToFLevel2::GetNHitPaddles(Int_t plane){
# Line 221  Int_t ToFLevel2::GetNHitPaddles(Int_t pl Line 272  Int_t ToFLevel2::GetNHitPaddles(Int_t pl
272      return npad;      return npad;
273  };  };
274    
275    /**
276     * Optional method to get the number of hit paddles on a ToF plane.
277     * The method does NOT check if there is a signal from both PMTs, it only
278     * checks if there is some PMT signal in a paddle
279     * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).
280     */
281    Int_t ToFLevel2::GetTrueNHitPaddles(Int_t plane){
282        Int_t npad=0;
283        TClonesArray* Pmt = this->PMT;
284        int paddle[24];
285        memset(paddle,0, 24*sizeof(int));
286        for(int i=0; i<Pmt->GetEntries(); i++) {  //loop per vedere quale TOF è colpito
287          ToFPMT* pmthit = (ToFPMT*)Pmt->At(i);
288          int pplane = -1;
289          int ppaddle = -1;
290          GetPMTPaddle(pmthit->pmt_id,pplane,ppaddle);
291          if ( pplane == plane ) paddle[ppaddle]++;
292        }
293        for(int i=0;i<24;i++) if ( paddle[i]>0 ) npad++;
294    
295        return npad;
296    };
297    
298    //new, wm Feb 15
299  //wm Nov 08  //wm Nov 08
300  //gf Apr 07  //gf Apr 07
301  /**  /**
302   * Method to get the mean dEdx from a ToF layer - ATTENTION:   * Method to get the mean dEdx from a ToF layer
303   * It will sum up the dEdx of all the paddles, but since by definition   * By definition there should be PMTs with dEdx values only in one paddle of a layer
304   * only the paddle hitted by the track gets a dEdx value and the other   * (the paddle hitted by the track), this method looks for the hitted paddle
305   * paddles are set to zero, the output is just the dEdx of the hitted   * and gives the mean dEdx of that paddle as the output
306   * paddle in each layer!   * The method was modified for the "ToF-standalone" part in february 2015
307   * The "adcfl" option is not very useful (an artificial dEdx is per   * The "adcfl" option is not very useful (an artificial dEdx is per
308   * definition= 1 mip and not a real measurement), anyway left in the code   * definition= 1 mip and not a real measurement), anyway left in the code
309   * @param notrack Track Number   * @param notrack Track Number (array index, ranging from 0 to ntrk())
310   * @param plane Plane index (0,1,2,3,4,5)   * @param plane Plane index (0,1,2,3,4,5)
311   * @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )   * @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
312   */   */
313  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){
314        ToFTrkVar *trk = GetToFTrkVar(notrack);
315    //    ToFTrkVar *trk = GetToFStoredTrack(seqno);//Elena 2015
316      return this->GetdEdx(trk, plane, adcfl);
317    }
318    
319    //new, wm Feb 15
320    //wm Nov 08
321    //gf Apr 07
322    /**
323     * Method to get the mean dEdx from a ToF layer
324     * By definition there should be PMTs with dEdx values only in one paddle of a layer
325     * (the paddle hitted by the track), this method looks for the hitted paddle
326     * and gives the mean dEdx of that paddle as the output
327     * The method was modified for the "ToF-standalone" part in february 2015
328     * The "adcfl" option is not very useful (an artificial dEdx is per
329     * definition= 1 mip and not a real measurement), anyway left in the code
330     * @param trk Pointer to TofTrkVar object
331     * @param plane Plane index (0,1,2,3,4,5)
332     * @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
333     */
334    Float_t ToFLevel2::GetdEdx(ToFTrkVar *trk, Int_t plane, Int_t adcfl){
335      
336    Float_t dedx = 0.;    Float_t dedx = 0.;
337    Float_t PadEdx =0.;    Float_t PadEdx =0.;
338    Int_t SatWarning;    Int_t SatWarning;
339    Int_t pad=-1;    Int_t pad=-1;
340    //    //
341    ToFTrkVar *trk = GetToFTrkVar(notrack);    if(!trk) cout << "ToFLevel2::GetdEdx(...) ---> NULL ToFTrkVar obj "<<endl;
342    if(!trk) return 0; //ELENA    if(!trk) return 0; //ELENA
343    //    //
344    for (Int_t ii=0; ii<GetNPaddle(plane); ii++){    // ToF standalone part
     Int_t paddleid=ii;  
     pad = GetPaddleid(plane,paddleid);  
     GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning);  
     dedx += PadEdx;  
   };  
345    //    //
346      if ( trk->trkseqno == -1 ){
347        
348        //    ToFTrkVar *t_tof = trk;
349        
350        // Find the hitted paddle  (two good TDC values) using the tof_j_flag (from tofl2com.for)
351        
352        Int_t Ipaddle=-1;
353        // if tof_j_flag == 0: no paddle was hitted. Otherwise decode tof_j_flag to get the paddle
354        if (this->tof_j_flag[plane] > 0)  Ipaddle = (Int_t)log2(this->tof_j_flag[plane]) ;
355        
356        Ipaddle =  (Int_t)log2(this->tof_j_flag[plane]) ;
357        
358        // Get the dEdx of this paddle using "GetdEdxPaddle"
359        if (Ipaddle>-1) {
360          Int_t pad = GetPaddleid(plane,Ipaddle);
361          GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning);
362          dedx = PadEdx;
363        }
364        
365        // If there was no correct hitted paddle, but there was one (and only one) paddle with some
366        // PMT entries in the PMT-class (found with "GetTrueNHitPaddles", use the dEdx of this paddle
367        
368        if ((Ipaddle<0) && (GetTrueNHitPaddles(plane)==1)) {
369          // find the paddle by looping over the paddles in each layer
370          // since GetTrueNHitPaddles==1 this is OK
371          for (Int_t ii=0; ii<GetNPaddle(plane); ii++){
372            Int_t paddleid=ii;
373            Int_t pad = GetPaddleid(plane,paddleid);
374            GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning);
375            dedx += PadEdx;
376          }
377        }
378      } else {
379        // track dependent dEdx: simple, there will be only one paddle hitted in    each layer
380        // so just loop over the paddles in each layer
381        for (Int_t ii=0; ii<GetNPaddle(plane); ii++){
382          Int_t paddleid=ii;
383          pad = GetPaddleid(plane,paddleid);
384          GetdEdxPaddle(trk, pad, adcfl, PadEdx, SatWarning);
385          dedx += PadEdx;
386        }
387      }
388      //
389    return(dedx);    return(dedx);
390  };  }
391    
392  /**  /**
393   * Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix   * Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix
394   * with the time-walk corrected TDC values.   * with the time-walk corrected TDC values.
395   * @param notrack Track Number   * @param notrack Track Number (arry index, ranging from 0 to ntrk())
396   * @param adc  ADC_C matrix with dEdx values   * @param adc  ADC_C matrix with dEdx values
397   * @param tdc  TDC matrix   * @param tdc  TDC matrix
398   */   */
# Line 328  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt Line 462  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt
462   */   */
463  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){
464    //    //
465    short tof[4][24] = {    static const short tof[4][24] = {
466      {4, 4,  4,  4,  1,  1, 2, 2,  3,  3, 3, 3,  3,  3, 1, 1,  1,  1, 2, 3,  3, 3, 3,  4},      {4, 4,  4,  4,  1,  1, 2, 2,  3,  3, 3, 3,  3,  3, 1, 1,  1,  1, 2, 3,  3, 3, 3,  4},
467      {1, 3,  5,  7, 10, 12, 2, 4,  2,  4, 6, 8, 10, 12, 1, 5,  3,  9, 7, 9, 11, 1, 5,  9},      {1, 3,  5,  7, 10, 12, 2, 4,  2,  4, 6, 8, 10, 12, 1, 5,  3,  9, 7, 9, 11, 1, 5,  9},
468      {2, 2,  2,  2,  1,  1, 1, 1,  4,  4, 4, 4,  4,  4, 2, 1,  2,  1, 2, 2,  2, 3, 3,  4},      {2, 2,  2,  2,  1,  1, 1, 1,  4,  4, 4, 4,  4,  4, 2, 1,  2,  1, 2, 2,  2, 3, 3,  4},
# Line 364  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_ Line 498  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_
498   */   */
499  void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){  void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){
500    //    //
501    short tof[4][24] = {    static const short tof[4][24] = {
502      {4, 4,  4,  4,  1,  1, 2, 2,  3,  3, 3, 3,  3,  3, 1, 1,  1,  1, 2, 3,  3, 3, 3,  4},      {4, 4,  4,  4,  1,  1, 2, 2,  3,  3, 3, 3,  3,  3, 1, 1,  1,  1, 2, 3,  3, 3, 3,  4},
503      {1, 3,  5,  7, 10, 12, 2, 4,  2,  4, 6, 8, 10, 12, 1, 5,  3,  9, 7, 9, 11, 1, 5,  9},      {1, 3,  5,  7, 10, 12, 2, 4,  2,  4, 6, 8, 10, 12, 1, 5,  3,  9, 7, 9, 11, 1, 5,  9},
504      {2, 2,  2,  2,  1,  1, 1, 1,  4,  4, 4, 4,  4,  4, 2, 1,  2,  1, 2, 2,  2, 3, 3,  4},      {2, 2,  2,  2,  1,  1, 1, 1,  4,  4, 4, 4,  4,  4, 2, 1,  2,  1, 2, 2,  2, 3, 3,  4},
# Line 396  void ToFLevel2::GetPMTIndex(Int_t ind, I Line 530  void ToFLevel2::GetPMTIndex(Int_t ind, I
530   * Method to get the dEdx from a given ToF paddle.   * Method to get the dEdx from a given ToF paddle.
531   * If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise   * If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise
532   * just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000   * just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000
533   * @param notrack Track Number   * @param notrack Track Number (-1 for standalone info)
534   * @param Paddle index (0,1,...,23).   * @param Paddle index (0,1,...,23).
535   * @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )   * @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
536   * @param PadEdx dEdx from a given ToF paddle   * @param PadEdx dEdx from a given ToF paddle
# Line 404  void ToFLevel2::GetPMTIndex(Int_t ind, I Line 538  void ToFLevel2::GetPMTIndex(Int_t ind, I
538   */   */
539  void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){  void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){
540    
541  /*    ToFTrkVar *trk = GetToFTrkVar(notrack);
542  Float_t  PMTsat[48] = {  //    ToFTrkVar *trk = GetToFStoredTrack(seqno); //Elena 2015
543  3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37,    this->GetdEdxPaddle(trk, paddleid, adcfl, PadEdx, SatWarning);
544  3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03,    
545  3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53,  };
546  3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98,  
547  3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66,  //
548  3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ;  //  wm Nov 08 revision - saturation values included
549  */  /// gf Apr 07
550    /**
551  // new values from Napoli dec 2008   * Method to get the dEdx from a given ToF paddle.
552  Float_t  PMTsat[48] = {   * If two PMTs are good, the mean dEdx of both PMTs is taken, otherwise
553  3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27,   * just the dEdx of the "good" PMT. If both PMTs are above saturation => dEdx=1000
554  3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14,   * @param notrack Track Number
555  3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62,   * @param Paddle index (0,1,...,23).
556  3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26,   * @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
557  3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18,   * @param PadEdx dEdx from a given ToF paddle
558  3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 };   * @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000)
559     */
560    void ToFLevel2::GetdEdxPaddle(ToFTrkVar *trk, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){
561    
562      /*
563        Float_t  PMTsat[48] = {
564        3162.14, 3165.48, 3153.85, 3085.73, 3089.65, 3107.64, 3097.52, 3078.37,
565        3130.05, 3087.07, 3112.22, 3102.92, 3080.58, 3092.55, 3087.94, 3125.03,
566        3094.09, 3143.16, 3125.51, 3181.27, 3092.09, 3124.98, 3069.3, 3095.53,
567        3097.11, 3133.53, 3114.73, 3113.01, 3091.19, 3097.99, 3033.84, 3134.98,
568        3081.37, 3111.04, 3066.77, 3108.17, 3133, 3111.06, 3052.52, 3140.66,
569        3106.33, 3094.85, 3150.85, 3118.8, 3096.24, 3118.47,3111.36, 3117.11 } ;
570      */
571    
572      // new values from Napoli dec 2008
573      Float_t  PMTsat[48] = {
574        3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27,
575        3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14,
576        3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62,
577        3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26,
578        3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18,
579        3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 };
580    
581  for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.;  // safety margin    for (Int_t i=0; i<48;i++) PMTsat[i] = PMTsat[i] - 5.;  // safety margin
582    
583    
584    PadEdx = 0.;    PadEdx = 0.;
585  //  SatWarning = 1000;    //  SatWarning = 1000;
586    SatWarning = 0;   // 0=good, increase for each bad PMT    SatWarning = 0;   // 0=good, increase for each bad PMT
587    
588    Float_t dEdx[48] = {0};    Float_t dEdx[48] = {0};
589    Int_t pmt_id = -1;    Int_t pmt_id = -1;
590    Float_t adcraw[48];    Float_t adcraw[48];
591    //    //
592    ToFTrkVar *trk = GetToFTrkVar(notrack);    if(!trk)cout << "ToFLevel2::GetdEdxPaddle(...) ---> NULL ToFTrkVar obj "<<endl;
593    if(!trk) return; //ELENA    if(!trk) return; //ELENA
594    //    //
595    
# Line 474  for (Int_t i=0; i<48;i++) PMTsat[i] = PM Line 629  for (Int_t i=0; i<48;i++) PMTsat[i] = PM
629    }    }
630    
631    
632  //  if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1;  //old version    //  if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1;  //old version
633    
634  // Increase SatWarning Counter for each PMT>Sat    // Increase SatWarning Counter for each PMT>Sat
635    if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++;      if( adcraw[pmtleft] > PMTsat[pmtleft])SatWarning++;  
636    if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++;    if( adcraw[pmtright] > PMTsat[pmtright])SatWarning++;
637    
638  // if ADC  > sat set dEdx=1000    // if ADC  > sat set dEdx=1000
639    if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.;    if( adcraw[pmtleft] > PMTsat[pmtleft]) dEdx[pmtleft] = 1000.;
640    if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ;    if( adcraw[pmtright] > PMTsat[pmtright]) dEdx[pmtright] = 1000. ;
641    
642  // if two PMT are good, take mean dEdx, otherwise only the good dEdx    // if two PMT are good, take mean dEdx, otherwise only the good dEdx
643    if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5;    if(dEdx[pmtleft]<1000 && dEdx[pmtright]<1000) PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5;
644    if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright];      if(dEdx[pmtleft]==1000 && dEdx[pmtright]<1000) PadEdx = dEdx[pmtright];  
645    if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft];    if(dEdx[pmtleft]<1000 && dEdx[pmtright]==1000) PadEdx = dEdx[pmtleft];
646        
647  };  };
 //  
   
648    
649  // gf Apr 07  // gf Apr 07
650    
# Line 507  TString ToFLevel2::GetPMTName(Int_t ind, Line 660  TString ToFLevel2::GetPMTName(Int_t ind,
660        
661    TString pmtname = " ";    TString pmtname = " ";
662        
663    TString photoS[48] = {    static const TString photoS[48] = {
664      "S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A",      "S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A",
665      "S11_4B",      "S11_4B",
666      "S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A",      "S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A",
# Line 967  Int_t ToFLevel2::GetNPaddle(Int_t plane) Line 1120  Int_t ToFLevel2::GetNPaddle(Int_t plane)
1120   * @param cut on chi2   * @param cut on chi2
1121   */   */
1122    
 Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){  
1123    
1124  //  cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl;  Float_t ToFTrkVar::CalcBeta( Float_t resmax, Float_t qualitycut, Float_t chi2cut){
1125    
1126    
1127    Float_t bxx = 100.;    Float_t bxx = 100.;
1128    //    //
1129    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = this;
   if(!trk) return 0; //ELENA  
1130    
1131    
1132    Float_t chi2,xhelp,beta_mean;    Float_t chi2,xhelp,beta_mean;
# Line 1001  Float_t  w_il[6]; Line 1153  Float_t  w_il[6];
1153    for (Int_t i=0; i<trk->npmttdc; i++){    for (Int_t i=0; i<trk->npmttdc; i++){
1154      //      //
1155      pmt_id = (trk->pmttdc).At(i);      pmt_id = (trk->pmttdc).At(i);
1156      pmt_plane = GetPlaneIndex(pmt_id);      pmt_plane = ToFLevel2::GetPlaneIndex(pmt_id);
1157      tdcfl = (trk->tdcflag).At(i);      tdcfl = (trk->tdcflag).At(i);
1158      if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag      if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag
1159                                       };                                       };
# Line 1088  Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2, Line 1240  Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,
1240    //    //
1241    return(bxx);    return(bxx);
1242  };  };
1243    ////////////////////////////////////////////////////
1244    ////////////////////////////////////////////////////
1245    /**
1246     * See ToFTrkVar::CalcBeta(Float_t,Float_t, Float_t).
1247     * @param notrack Track Number (arry index, ranging from 0 to ntrk())
1248     */
1249    Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){
1250    
1251    //  cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl;
1252    
1253      ToFTrkVar *trk = GetToFTrkVar(notrack);
1254    //    ToFTrkVar *trk = GetToFStoredTrack(seqno);//Elena Apr 2015
1255      if(!trk) return 0; //ELENA
1256    
1257      return trk->CalcBeta(resmax,qualitycut,chi2cut);
1258    
1259    };
1260    
1261    
1262  ////////////////////////////////////////////////////  ////////////////////////////////////////////////////
# Line 1149  Int_t ToFLevel2::Process(TrkLevel2 *trk, Line 1318  Int_t ToFLevel2::Process(TrkLevel2 *trk,
1318    //    //
1319    // Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto    // Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto
1320    //    //
1321      printf("\n\n\n ERROR: NOT IMPLEMENTED ANYMORE, write Emiliano if you need this method (Emiliano.Mocchiutti@ts.infn.it) \n\n\n");
1322      return(-1);
1323      //   //
1324      //   // structures to communicate with F77
1325    //    //   //
1326    // structures to communicate with F77    //   extern struct ToFInput  tofinput_;
1327    //  //   extern struct ToFOutput tofoutput_;
1328    extern struct ToFInput  tofinput_;  //   //
1329    extern struct ToFOutput tofoutput_;  //   // DB connection
1330    //  //   //
1331    // DB connection  //   TString host;
1332    //  //   TString user;
1333    TString host;  //   TString psw;
1334    TString user;  //   const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
1335    TString psw;  //   const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
1336    const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");  //   const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
1337    const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");  //   if ( !pamdbhost ) pamdbhost = "";
1338    const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");  //   if ( !pamdbuser ) pamdbuser = "";
1339    if ( !pamdbhost ) pamdbhost = "";  //   if ( !pamdbpsw ) pamdbpsw = "";
1340    if ( !pamdbuser ) pamdbuser = "";  //   if ( strcmp(pamdbhost,"") ) host = pamdbhost;
1341    if ( !pamdbpsw ) pamdbpsw = "";  //   if ( strcmp(pamdbuser,"") ) user = pamdbuser;
1342    if ( strcmp(pamdbhost,"") ) host = pamdbhost;  //   if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
1343    if ( strcmp(pamdbuser,"") ) user = pamdbuser;  //   //
1344    if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;  //   //
1345    //  //   TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
1346    //  //   if ( !dbc->IsConnected() ) return 1;
1347    TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());  //   stringstream myquery;
1348    if ( !dbc->IsConnected() ) return 1;  //   myquery.str("");
1349    stringstream myquery;  //   myquery << "SET time_zone='+0:00';";
1350    myquery.str("");  //   dbc->Query(myquery.str().c_str());
1351    myquery << "SET time_zone='+0:00'";  //   delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';");
1352    dbc->Query(myquery.str().c_str());  //   GL_PARAM *glparam = new GL_PARAM();
1353    GL_PARAM *glparam = new GL_PARAM();  //   glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table
1354    glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table  //   trk->LoadField(glparam->PATH+glparam->NAME);
1355    trk->LoadField(glparam->PATH+glparam->NAME);  //   //
1356    //  //   Bool_t defcal = true;
1357    Bool_t defcal = true;  //   Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table
1358    Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table  //   if ( error<0 ) {
1359    if ( error<0 ) {  //     return(1);
1360      return(1);  //   };
1361    };  //   printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
1362    printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());  //   if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false;
1363    if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false;  //   //
1364    //  //   Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length();
1365    Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length();  //   rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen);
1366    rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen);  //   //
1367    //  //   Int_t adc[4][12];
1368    Int_t adc[4][12];  //   Int_t tdc[4][12];
1369    Int_t tdc[4][12];  //   Float_t tdcc[4][12];
1370    Float_t tdcc[4][12];  //   //
1371    //  //   // process tof data
1372    // process tof data  //   //
1373    //  //   for (Int_t hh=0; hh<12;hh++){
1374    for (Int_t hh=0; hh<12;hh++){  //     for (Int_t kk=0; kk<4;kk++){
1375      for (Int_t kk=0; kk<4;kk++){  //            adc[kk][hh] = 4095;
1376             adc[kk][hh] = 4095;  //            tdc[kk][hh] = 4095;
1377             tdc[kk][hh] = 4095;  //            tdcc[kk][hh] = 4095.;
1378             tdcc[kk][hh] = 4095.;  //            tofinput_.adc[hh][kk] = 4095;
1379             tofinput_.adc[hh][kk] = 4095;  //            tofinput_.tdc[hh][kk] = 4095;
1380             tofinput_.tdc[hh][kk] = 4095;  //     };
1381      };  //   };
1382    };  //   Int_t ntrkentry = 0;
1383    Int_t ntrkentry = 0;  //   Int_t npmtentry = 0;
1384    Int_t npmtentry = 0;  //   Int_t gg = 0;
1385    Int_t gg = 0;  //   Int_t hh = 0;
1386    Int_t hh = 0;  //   Int_t adcf[48];
1387    Int_t adcf[48];  //   memset(adcf, 0, 48*sizeof(Int_t));
1388    memset(adcf, 0, 48*sizeof(Int_t));  //   Int_t tdcf[48];
1389    Int_t tdcf[48];  //   memset(tdcf, 0, 48*sizeof(Int_t));
1390    memset(tdcf, 0, 48*sizeof(Int_t));  //   for (Int_t pm=0; pm < this->ntrk() ; pm++){
1391    for (Int_t pm=0; pm < this->ntrk() ; pm++){  //      ToFTrkVar *ttf = this->GetToFTrkVar(pm);
1392       ToFTrkVar *ttf = this->GetToFTrkVar(pm);  //      for ( Int_t nc=0; nc < ttf->npmttdc; nc++){
1393       for ( Int_t nc=0; nc < ttf->npmttdc; nc++){  //             if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1;
1394              if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1;  //      };
1395       };  //      for ( Int_t nc=0; nc < ttf->npmtadc; nc++){
1396       for ( Int_t nc=0; nc < ttf->npmtadc; nc++){  //             if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1;
1397              if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1;  //      };
1398       };  //   };
1399    };  //   //
1400    //  //   for (Int_t pm=0; pm < this->npmt() ; pm++){
1401    for (Int_t pm=0; pm < this->npmt() ; pm++){  //      ToFPMT *pmt = this->GetToFPMT(pm);
1402       ToFPMT *pmt = this->GetToFPMT(pm);  //      this->GetPMTIndex(pmt->pmt_id, gg, hh);
1403       this->GetPMTIndex(pmt->pmt_id, gg, hh);  //      if ( adcf[pmt->pmt_id] == 0 ){
1404       if ( adcf[pmt->pmt_id] == 0 ){  //              tofinput_.adc[gg][hh] = (int)pmt->adc;
1405               tofinput_.adc[gg][hh] = (int)pmt->adc;  //              adc[hh][gg] = (int)pmt->adc;
1406               adc[hh][gg] = (int)pmt->adc;  //      };
1407       };  //      if ( tdcf[pmt->pmt_id] == 0 ){
1408       if ( tdcf[pmt->pmt_id] == 0 ){  //              tofinput_.tdc[gg][hh] = (int)pmt->tdc;
1409               tofinput_.tdc[gg][hh] = (int)pmt->tdc;  //              tdc[hh][gg] = (int)pmt->tdc;
1410               tdc[hh][gg] = (int)pmt->tdc;  //      };
1411       };  //      tdcc[hh][gg] = (float)pmt->tdc_tw;
1412       tdcc[hh][gg] = (float)pmt->tdc_tw;  //      // Int_t pppid = this->GetPMTid(hh,gg);
1413       // Int_t pppid = this->GetPMTid(hh,gg);  //      //      printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc);
1414       //      printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc);  //   };
1415    };  //   //
1416    //  //   Int_t unpackError = this->unpackError;
1417    Int_t unpackError = this->unpackError;  //   //
1418    //  //   for (Int_t hh=0; hh<5;hh++){
1419    for (Int_t hh=0; hh<5;hh++){  //      tofinput_.patterntrig[hh]=trg->patterntrig[hh];
1420       tofinput_.patterntrig[hh]=trg->patterntrig[hh];  //   };
1421    };  //   //
1422    //  //   this->Clear();
1423    this->Clear();  //   //
1424    //  //       Int_t pmt_id = 0;
1425        Int_t pmt_id = 0;  //       ToFPMT *t_pmt = new ToFPMT();
1426        ToFPMT *t_pmt = new ToFPMT();  //       if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA
1427        if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA  //       TClonesArray &tpmt = *this->PMT;
1428        TClonesArray &tpmt = *this->PMT;  //       ToFTrkVar *t_tof = new ToFTrkVar();
1429        ToFTrkVar *t_tof = new ToFTrkVar();  //       if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
1430        if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA  //       TClonesArray &t = *this->ToFTrk;
1431        TClonesArray &t = *this->ToFTrk;  //       //
1432        //  //       //
1433        //  //       // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related  variables.
1434        // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related  variables.  //       //
1435        //  //       npmtentry = 0;
1436        npmtentry = 0;  //       //
1437        //  //       ntrkentry = 0;
1438        ntrkentry = 0;  //       //
1439        //  //       // Calculate tracks informations from ToF alone
1440        // Calculate tracks informations from ToF alone  //       //
1441        //  //       tofl2com();
1442        tofl2com();  //       //
1443        //  //       memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t));
1444        memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t));  //       //
1445        //  //       t_tof->trkseqno = -1;
1446        t_tof->trkseqno = -1;  //       //
1447        //  //       // and now we must copy from the output structure to the level2 class:
1448        // and now we must copy from the output structure to the level2 class:  //       //
1449        //  //       t_tof->npmttdc = 0;
1450        t_tof->npmttdc = 0;  //       //
1451        //  //       for (Int_t hh=0; hh<12;hh++){
1452        for (Int_t hh=0; hh<12;hh++){  //         for (Int_t kk=0; kk<4;kk++){
1453          for (Int_t kk=0; kk<4;kk++){  //           if ( tofoutput_.tofmask[hh][kk] != 0 ){
1454            if ( tofoutput_.tofmask[hh][kk] != 0 ){  //             pmt_id = this->GetPMTid(kk,hh);
1455              pmt_id = this->GetPMTid(kk,hh);  //             t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
1456              t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);  //             t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
1457              t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07  //             t_tof->npmttdc++;
1458              t_tof->npmttdc++;  //           };
1459            };  //         };
1460          };  //       };
1461        };  //       for (Int_t kk=0; kk<13;kk++){
1462        for (Int_t kk=0; kk<13;kk++){  //         t_tof->beta[kk] = tofoutput_.betatof_a[kk];
1463          t_tof->beta[kk] = tofoutput_.betatof_a[kk];  //       }
1464        }  //       //
1465        //  //       t_tof->npmtadc = 0;
1466        t_tof->npmtadc = 0;  //       for (Int_t hh=0; hh<12;hh++){
1467        for (Int_t hh=0; hh<12;hh++){  //         for (Int_t kk=0; kk<4;kk++){
1468          for (Int_t kk=0; kk<4;kk++){  //           if ( tofoutput_.adctof_c[hh][kk] < 1000 ){
1469            if ( tofoutput_.adctof_c[hh][kk] < 1000 ){  //             t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc);
1470              t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc);  //             pmt_id = this->GetPMTid(kk,hh);
1471              pmt_id = this->GetPMTid(kk,hh);  //             t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
1472              t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);  //             t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
1473              t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07  //             t_tof->npmtadc++;
1474              t_tof->npmtadc++;  //           };
1475            };  //         };
1476          };  //       };
1477        };  //       //
1478        //  //       memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
1479        memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));  //       memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
1480        memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));  //       memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
1481        memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));  //       memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
1482        memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));  //       //
1483        //  //       new(t[ntrkentry]) ToFTrkVar(*t_tof);
1484        new(t[ntrkentry]) ToFTrkVar(*t_tof);  //       ntrkentry++;
1485        ntrkentry++;  //       t_tof->Clear();
1486        t_tof->Clear();  //       //
1487        //  //       //
1488        //  //       //
1489        //  //       t_pmt->Clear();
1490        t_pmt->Clear();  //       //
1491        //  //       for (Int_t hh=0; hh<12;hh++){
1492        for (Int_t hh=0; hh<12;hh++){  //         for (Int_t kk=0; kk<4;kk++){
1493          for (Int_t kk=0; kk<4;kk++){  //          // new WM
1494           // new WM  //           if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){
1495            if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){  // //          if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){
1496  //          if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){  //             //
1497              //  //             t_pmt->pmt_id = this->GetPMTid(kk,hh);
1498              t_pmt->pmt_id = this->GetPMTid(kk,hh);  //             t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk];
1499              t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk];  //             t_pmt->adc = (Float_t)adc[kk][hh];
1500              t_pmt->adc = (Float_t)adc[kk][hh];  //             t_pmt->tdc = (Float_t)tdc[kk][hh];
1501              t_pmt->tdc = (Float_t)tdc[kk][hh];  //             //
1502              //  //             new(tpmt[npmtentry]) ToFPMT(*t_pmt);
1503              new(tpmt[npmtentry]) ToFPMT(*t_pmt);  //             npmtentry++;
1504              npmtentry++;  //             t_pmt->Clear();
1505              t_pmt->Clear();  //           };
1506            };  //         };
1507          };  //       };
1508        };  //       //
1509        //  //       // Calculate track-related variables
1510        // Calculate track-related variables  //       //
1511        //  //       if ( trk->ntrk() > 0 ){
1512        if ( trk->ntrk() > 0 ){  //         //
1513          //  //         // We have at least one track
1514          // We have at least one track  //         //
1515          //  //         //
1516          //  //         // Run over tracks
1517          // Run over tracks  //         //
1518          //  //         for(Int_t nt=0; nt < trk->ntrk(); nt++){
1519          for(Int_t nt=0; nt < trk->ntrk(); nt++){  //           //
1520            //  //           TrkTrack *ptt = trk->GetStoredTrack(nt);
1521            TrkTrack *ptt = trk->GetStoredTrack(nt);  //           //
1522            //  //           // Copy the alpha vector in the input structure
1523            // Copy the alpha vector in the input structure  //           //
1524            //  //           for (Int_t e = 0; e < 5 ; e++){
1525            for (Int_t e = 0; e < 5 ; e++){  //             tofinput_.al_pp[e] = ptt->al[e];
1526              tofinput_.al_pp[e] = ptt->al[e];  //           };
1527            };  //           //
1528            //  //           // Get tracker related variables for this track
1529            // Get tracker related variables for this track  //           //
1530            //  //           toftrk();
1531            toftrk();  //           //
1532            //  //           // Copy values in the class from the structure (we need to use a temporary class to store variables).
1533            // Copy values in the class from the structure (we need to use a temporary class to store variables).  //           //
1534            //  //           t_tof->npmttdc = 0;
1535            t_tof->npmttdc = 0;  //           for (Int_t hh=0; hh<12;hh++){
1536            for (Int_t hh=0; hh<12;hh++){  //             for (Int_t kk=0; kk<4;kk++){
1537              for (Int_t kk=0; kk<4;kk++){  //               if ( tofoutput_.tofmask[hh][kk] != 0 ){
1538                if ( tofoutput_.tofmask[hh][kk] != 0 ){  //                 pmt_id = this->GetPMTid(kk,hh);
1539                  pmt_id = this->GetPMTid(kk,hh);  //                 t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
1540                  t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);  //                 t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
1541                  t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07  //                 t_tof->npmttdc++;
1542                  t_tof->npmttdc++;  //               };
1543                };  //             };
1544              };  //           };
1545            };  //           for (Int_t kk=0; kk<13;kk++){
1546            for (Int_t kk=0; kk<13;kk++){  //             t_tof->beta[kk] = tofoutput_.beta_a[kk];
1547              t_tof->beta[kk] = tofoutput_.beta_a[kk];  //           };
1548            };  //           //
1549            //  //           t_tof->npmtadc = 0;
1550            t_tof->npmtadc = 0;  //           for (Int_t hh=0; hh<12;hh++){
1551            for (Int_t hh=0; hh<12;hh++){  //             for (Int_t kk=0; kk<4;kk++){
1552              for (Int_t kk=0; kk<4;kk++){  //               if ( tofoutput_.adc_c[hh][kk] < 1000 ){
1553                if ( tofoutput_.adc_c[hh][kk] < 1000 ){  //                 t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc);
1554                  t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc);  //                 pmt_id = this->GetPMTid(kk,hh);
1555                  pmt_id = this->GetPMTid(kk,hh);  //                 t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
1556                  t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);  //                 t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
1557                  t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07  //                 t_tof->npmtadc++;
1558                  t_tof->npmtadc++;  //               };
1559                };  //             };
1560              };  //           };
1561            };  //           //
1562            //  //           memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
1563            memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));  //           memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
1564            memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));  //           memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
1565            memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));  //           memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
1566            memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));  //           //
1567            //  //           // Store the tracker track number in order to be sure to have shyncronized data during analysis
1568            // Store the tracker track number in order to be sure to have shyncronized data during analysis  //           //
1569            //  //           t_tof->trkseqno = nt;
1570            t_tof->trkseqno = nt;  //           //
1571            //  //           // create a new object for this event with track-related variables
1572            // create a new object for this event with track-related variables  //           //
1573            //  //           new(t[ntrkentry]) ToFTrkVar(*t_tof);
1574            new(t[ntrkentry]) ToFTrkVar(*t_tof);  //           ntrkentry++;
1575            ntrkentry++;  //           t_tof->Clear();
1576            t_tof->Clear();  //           //
1577            //  //         }; // loop on all the tracks
1578          }; // loop on all the tracks  //       //
1579        //  //       this->unpackError = unpackError;
1580        this->unpackError = unpackError;  //       if ( defcal ){
1581        if ( defcal ){  //         this->default_calib = 1;
1582          this->default_calib = 1;  //       } else {
1583        } else {  //         this->default_calib = 0;
1584          this->default_calib = 0;  //       };
1585        };  //};
1586   };  //  return(0);
1587    }
1588    
1589    bool ToFLevel2::bit(int decimal, char pos){
1590    return(0);    return( (decimal>>pos)%2 );
1591    }
1592    
1593    bool ToFLevel2::checkPMT(TString givenpmt){
1594      TClonesArray* Pmt = this->PMT;
1595      //  printf(" ou %s entries %i \n",givenpmt.Data(),Pmt->GetEntries());
1596      for(int i=0; i<Pmt->GetEntries(); i++) {  
1597        ToFPMT* pmthit = (ToFPMT*)Pmt->At(i);
1598        TString pmtname = this->GetPMTName(pmthit->pmt_id);
1599        //    printf(" name %s \n",pmtname.Data());
1600        if ( !strcmp(pmtname.Data(),givenpmt.Data()) )
1601          return true;
1602      }
1603      //  printf(" PMT %s missing \n",givenpmt.Data());
1604      return false;
1605    }
1606    
1607    bool ToFLevel2::checkPMTpatternPMThit(TrigLevel2 *trg, int &pmtpattern, int &pmtnosignal){
1608      UInt_t *patterntrig = trg->patterntrig;
1609      pmtpattern = 0;
1610      pmtnosignal = 0;
1611      bool good = true;
1612      //S3
1613      if ( this->bit(patterntrig[2],0) ){ pmtpattern++;  if ( !this->checkPMT("S31_1A")){ pmtnosignal++; good = false;}}
1614      if ( this->bit(patterntrig[2],1) ){ pmtpattern++;  if ( !this->checkPMT("S31_2A")){ pmtnosignal++; good = false;}}
1615      if ( this->bit(patterntrig[2],2) ){ pmtpattern++;  if ( !this->checkPMT("S31_3A")){ pmtnosignal++; good = false;}}
1616      if ( this->bit(patterntrig[2],3) ){ pmtpattern++;  if ( !this->checkPMT("S31_1B")){ pmtnosignal++; good = false;}}
1617      if ( this->bit(patterntrig[2],4) ){ pmtpattern++;  if ( !this->checkPMT("S31_2B")){ pmtnosignal++; good = false;}}
1618      if ( this->bit(patterntrig[2],5) ){ pmtpattern++;  if ( !this->checkPMT("S31_3B")){ pmtnosignal++; good = false;}}      
1619      if ( this->bit(patterntrig[2],6) ){ pmtpattern++;  if ( !this->checkPMT("S32_1A")){ pmtnosignal++; good = false;}}
1620      if ( this->bit(patterntrig[2],7) ){ pmtpattern++;  if ( !this->checkPMT("S32_2A")){ pmtnosignal++; good = false;}}
1621      if ( this->bit(patterntrig[2],8) ){ pmtpattern++;  if ( !this->checkPMT("S32_3A")){ pmtnosignal++; good = false;}}
1622      if ( this->bit(patterntrig[2],9) ){ pmtpattern++;  if ( !this->checkPMT("S32_1B")){ pmtnosignal++; good = false;}}
1623      if ( this->bit(patterntrig[2],10) ){ pmtpattern++;  if ( !this->checkPMT("S32_2B")){ pmtnosignal++; good = false;}}
1624      if ( this->bit(patterntrig[2],11) ){ pmtpattern++;  if ( !this->checkPMT("S32_3B")){ pmtnosignal++; good = false;}}      
1625      //S2
1626      if ( this->bit(patterntrig[3],0) ){ pmtpattern++;  if ( !this->checkPMT("S21_1A")){ pmtnosignal++; good = false;}}
1627      if ( this->bit(patterntrig[3],1) ){ pmtpattern++;  if ( !this->checkPMT("S21_2A")){ pmtnosignal++; good = false;}}
1628      if ( this->bit(patterntrig[3],2) ){ pmtpattern++;  if ( !this->checkPMT("S21_1B")){ pmtnosignal++; good = false;}}
1629      if ( this->bit(patterntrig[3],3) ){ pmtpattern++;  if ( !this->checkPMT("S21_2B")){ pmtnosignal++; good = false;}}      
1630      if ( this->bit(patterntrig[3],4) ){ pmtpattern++;  if ( !this->checkPMT("S22_1A")){ pmtnosignal++; good = false;}}
1631      if ( this->bit(patterntrig[3],5) ){ pmtpattern++;  if ( !this->checkPMT("S22_2A")){ pmtnosignal++; good = false;}}
1632      if ( this->bit(patterntrig[3],6) ){ pmtpattern++;  if ( !this->checkPMT("S22_1B")){ pmtnosignal++; good = false;}}
1633      if ( this->bit(patterntrig[3],7) ){ pmtpattern++;  if ( !this->checkPMT("S22_2B")){ pmtnosignal++; good = false;}}      
1634      //S12
1635      if ( this->bit(patterntrig[4],0) ){ pmtpattern++;  if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}}
1636      if ( this->bit(patterntrig[4],1) ){ pmtpattern++;  if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}}
1637      if ( this->bit(patterntrig[4],2) ){ pmtpattern++;  if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}}
1638      if ( this->bit(patterntrig[4],3) ){ pmtpattern++;  if ( !this->checkPMT("S12_4A")){ pmtnosignal++; good = false;}}
1639      if ( this->bit(patterntrig[4],4) ){ pmtpattern++;  if ( !this->checkPMT("S12_5A")){ pmtnosignal++; good = false;}}
1640      if ( this->bit(patterntrig[4],5) ){ pmtpattern++;  if ( !this->checkPMT("S12_6A")){ pmtnosignal++; good = false;}}      
1641      if ( this->bit(patterntrig[4],6) ){ pmtpattern++;  if ( !this->checkPMT("S12_1A")){ pmtnosignal++; good = false;}}
1642      if ( this->bit(patterntrig[4],7) ){ pmtpattern++;  if ( !this->checkPMT("S12_2A")){ pmtnosignal++; good = false;}}
1643      if ( this->bit(patterntrig[4],8) ){ pmtpattern++;  if ( !this->checkPMT("S12_3A")){ pmtnosignal++; good = false;}}
1644      if ( this->bit(patterntrig[4],9) ){ pmtpattern++;  if ( !this->checkPMT("S12_4B")){ pmtnosignal++; good = false;}}
1645      if ( this->bit(patterntrig[4],10) ){ pmtpattern++; if ( !this->checkPMT("S12_5B")){ pmtnosignal++; good = false;}}
1646      if ( this->bit(patterntrig[4],11) ){ pmtpattern++; if ( !this->checkPMT("S12_6B")){ pmtnosignal++; good = false;}}      
1647      //S11
1648      if ( this->bit(patterntrig[5],0) ){ pmtpattern++;  if ( !this->checkPMT("S11_1A")){ pmtnosignal++; good = false;}}
1649      if ( this->bit(patterntrig[5],1) ){ pmtpattern++;  if ( !this->checkPMT("S11_2A")){ pmtnosignal++; good = false;}}
1650      if ( this->bit(patterntrig[5],2) ){ pmtpattern++;  if ( !this->checkPMT("S11_3A")){ pmtnosignal++; good = false;}}
1651      if ( this->bit(patterntrig[5],3) ){ pmtpattern++;  if ( !this->checkPMT("S11_4A")){ pmtnosignal++; good = false;}}
1652      if ( this->bit(patterntrig[5],4) ){ pmtpattern++;  if ( !this->checkPMT("S11_5A")){ pmtnosignal++; good = false;}}
1653      if ( this->bit(patterntrig[5],5) ){ pmtpattern++;  if ( !this->checkPMT("S11_6A")){ pmtnosignal++; good = false;}}
1654      if ( this->bit(patterntrig[5],6) ){ pmtpattern++;  if ( !this->checkPMT("S11_7A")){ pmtnosignal++; good = false;}}
1655      if ( this->bit(patterntrig[5],7) ){ pmtpattern++;  if ( !this->checkPMT("S11_8A")){ pmtnosignal++; good = false;}}      
1656      if ( this->bit(patterntrig[5],8) ){ pmtpattern++;  if ( !this->checkPMT("S11_1B")){ pmtnosignal++; good = false;}}
1657      if ( this->bit(patterntrig[5],9) ){ pmtpattern++;  if ( !this->checkPMT("S11_2B")){ pmtnosignal++; good = false;}}
1658      if ( this->bit(patterntrig[5],10) ){ pmtpattern++; if ( !this->checkPMT("S11_3B")){ pmtnosignal++; good = false;}}
1659      if ( this->bit(patterntrig[5],11) ){ pmtpattern++; if ( !this->checkPMT("S11_4B")){ pmtnosignal++; good = false;}}
1660      if ( this->bit(patterntrig[5],12) ){ pmtpattern++; if ( !this->checkPMT("S11_5B")){ pmtnosignal++; good = false;}}
1661      if ( this->bit(patterntrig[5],13) ){ pmtpattern++; if ( !this->checkPMT("S11_6B")){ pmtnosignal++; good = false;}}
1662      if ( this->bit(patterntrig[5],14) ){ pmtpattern++; if ( !this->checkPMT("S11_7B")){ pmtnosignal++; good = false;}}
1663      if ( this->bit(patterntrig[5],15) ){ pmtpattern++; if ( !this->checkPMT("S11_8B")){ pmtnosignal++; good = false;}}
1664    
1665      return good;
1666    }
1667    
1668    bool ToFLevel2::checkPMTpmttrig(TrigLevel2 *trg){
1669      //  UInt_t *patterntrig = trg->patterntrig;
1670      int rS11 = 0;
1671      int rS12 = 0;
1672      int rS21 = 0;
1673      int rS22 = 0;
1674      int rS31 = 0;
1675      int rS32 = 0;
1676    
1677      // trigger configuration for the event from saved pmts
1678      TClonesArray* Pmt = this->PMT;
1679      for(int i=0; i<Pmt->GetEntries(); i++) {  
1680        ToFPMT* pmthit = (ToFPMT*)Pmt->At(i);
1681        TString pmtname = this->GetPMTName(pmthit->pmt_id);
1682        if ( pmtname.Contains("S11") ) rS11++;
1683        if ( pmtname.Contains("S12") ) rS12++;
1684        if ( pmtname.Contains("S21") ) rS21++;
1685        if ( pmtname.Contains("S22") ) rS22++;
1686        if ( pmtname.Contains("S31") ) rS31++;
1687        if ( pmtname.Contains("S32") ) rS32++;
1688      }
1689      int rTOF1 = (rS11 + rS12) * (rS21 + rS22) * (rS31 + rS32);
1690      int rTOF2 = (rS11 * rS12) * (rS21 * rS22) * (rS31 * rS32);
1691    
1692      int rTOF3 = (rS21 + rS22) * (rS31 + rS32);
1693      int rTOF4 = (rS21 * rS22) * (rS31 * rS32);
1694    
1695      int rTOF5 = rS12 * (rS21 * rS22);
1696    
1697      int rTOF6 = (rS11 + rS12) * (rS31 + rS32);
1698      int rTOF7 = (rS11 * rS12) * (rS31 * rS32);
1699    
1700    
1701      // trigger configuration of the run
1702      bool TCTOF1 = false;
1703      bool TCTOF2 = false;
1704      bool TCTOF3 = false;
1705      bool TCTOF4 = false;
1706      bool TCTOF5 = false;
1707      bool TCTOF6 = false;
1708      bool TCTOF7 = false;
1709      if ( trg->trigconf & (1<<0) ) TCTOF1 = true;
1710      if ( trg->trigconf & (1<<1) ) TCTOF2 = true;
1711      if ( trg->trigconf & (1<<2) ) TCTOF3 = true;
1712      if ( trg->trigconf & (1<<3) ) TCTOF4 = true;
1713      if ( trg->trigconf & (1<<4) ) TCTOF5 = true;
1714      if ( trg->trigconf & (1<<5) ) TCTOF6 = true;
1715      if ( trg->trigconf & (1<<6) ) TCTOF7 = true;
1716    
1717      // do patterntrig pmts match the trigger configuration?
1718      bool pmtsconf_trigconf_match = true;
1719      if ( rTOF1 == 0 && TCTOF1 ) pmtsconf_trigconf_match = false;
1720      if ( rTOF2 == 0 && TCTOF2 ) pmtsconf_trigconf_match = false;
1721      if ( rTOF3 == 0 && TCTOF3 ) pmtsconf_trigconf_match = false;
1722      if ( rTOF4 == 0 && TCTOF4 ) pmtsconf_trigconf_match = false;
1723      if ( rTOF5 == 0 && TCTOF5 ) pmtsconf_trigconf_match = false;
1724      if ( rTOF6 == 0 && TCTOF6 ) pmtsconf_trigconf_match = false;
1725      if ( rTOF7 == 0 && TCTOF7 ) pmtsconf_trigconf_match = false;
1726    
1727      return pmtsconf_trigconf_match;
1728    }
1729    
1730    void ToFLevel2::printPMT(){
1731      TClonesArray* Pmt = this->PMT;
1732      for(int i=0; i<Pmt->GetEntries(); i++) {  
1733        ToFPMT* pmthit = (ToFPMT*)Pmt->At(i);
1734        TString pmtname = this->GetPMTName(pmthit->pmt_id);
1735        printf(" PMT hit: %s \n",pmtname.Data());
1736      }
1737  }  }
1738    
1739    
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
1740  ToFdEdx::ToFdEdx()  ToFdEdx::ToFdEdx()
1741  {  {
1742    memset(conn,0,12*sizeof(Bool_t));    memset(conn,0,12*sizeof(Bool_t));
1743    memset(ts,0,12*sizeof(UInt_t));    memset(ts,0,12*sizeof(UInt_t));
1744    memset(te,0,12*sizeof(UInt_t));    memset(te,0,12*sizeof(UInt_t));
1745      eDEDXpmt = new TArrayF(48);
1746    Define_PMTsat();    Define_PMTsat();
1747    Clear();    Clear();
1748  }  }
1749    
1750    ToFdEdx::~ToFdEdx(){
1751      Clear();
1752      Delete();
1753    }
1754    
1755    void ToFdEdx::Delete(Option_t *option){
1756      if ( eDEDXpmt ){
1757        eDEDXpmt->Set(0);
1758        if ( eDEDXpmt) delete eDEDXpmt;
1759      }
1760    }
1761    
1762  //------------------------------------------------------------------------  //------------------------------------------------------------------------
1763  void ToFdEdx::CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc)  void ToFdEdx::CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc)
1764  {  {
# Line 1493  void ToFdEdx::Clear(Option_t *option) Line 1800  void ToFdEdx::Clear(Option_t *option)
1800  {  {
1801    //    //
1802    // Set arrays and initialize structure    // Set arrays and initialize structure
1803      //  eDEDXpmt.Set(48);    eDEDXpmt.Reset(-1);   // Set array size  and reset structure
1804    eDEDXpmt.Set(48);    eDEDXpmt.Reset(-1);   // Set array size  and reset structure    eDEDXpmt->Set(48);    eDEDXpmt->Reset(-1);   // Set array size  and reset structure
   eZpmt.Set(48);       eZpmt.Reset(-1);  
   eDEDXpad.Set(24);    eDEDXpad.Reset(-1);  
   eZpad.Set(24);       eZpad.Reset(-1);  
   eDEDXlayer.Set(6);   eDEDXlayer.Reset(-1);  
   eZlayer.Set(6);      eZlayer.Reset(-1);  
   eDEDXplane.Set(3);   eDEDXplane.Reset(-1);  
   eZplane.Set(3);      eZplane.Reset(-1);  
   INFOpmt.Set(48);     INFOpmt.Reset(0);  
   INFOlayer.Set(6);    INFOlayer.Reset(0);  
1805    //    //
1806  };  };
1807    
# Line 1515  void ToFdEdx::Print(Option_t *option) Line 1813  void ToFdEdx::Print(Option_t *option)
1813    
1814  };  };
1815    
   
1816  //------------------------------------------------------------------------  //------------------------------------------------------------------------
1817  // void ToFdEdx::InitPar(TString parname, TString parfile)  void ToFdEdx::Init(pamela::tof::TofEvent *tofl0)
1818  // {  {
1819  //   // expensive function - call it once/run    //
1820      ToFLevel2 tf;
1821      for (Int_t gg=0; gg<4;gg++){
1822        for (Int_t hh=0; hh<12;hh++){
1823  //   ReadParAtt(            Form("%s/attenuation.txt"              , pardir) );        //          tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh];          
1824  //   ReadParPos(            Form("%s/desaturation_position.txt"    , pardir) );        int mm = tf.GetPMTid(gg,hh);        
1825  //   ReadParBBneg(          Form("%s/BetheBloch.txt"               , pardir) );        adc[mm]= (0xFFF & tofl0->adc[gg][hh]); // EM, exclude warning bits
1826  //   ReadParBBpos(          Form("%s/BetheBloch_betagt1.txt"       , pardir) );      };      
1827  //   ReadParDesatBB(        Form("%s/desaturation_beta.txt"        , pardir) );    };
1828      
1829  // };  };
   
1830    
1831  //------------------------------------------------------------------------  //------------------------------------------------------------------------
1832  void ToFdEdx::Process(UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, pamela::tof::TofEvent *tofl0 )  void ToFdEdx::Init(Int_t gg, Int_t hh, Float_t adce)
1833    {
1834      //
1835      ToFLevel2 tf;
1836      //  for (Int_t gg=0; gg<4;gg++){
1837      //    for (Int_t hh=0; hh<12;hh++){
1838      int mm = tf.GetPMTid(gg,hh);    
1839      adc[mm]=adce;
1840      
1841    };
1842    //------------------------------------------------------------------------
1843    void ToFdEdx::Process(UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, Int_t exitat)
1844  {  {
1845      bool debug = false;
1846      if ( debug ) printf(" INSIDE TOFDEDX PROCESS \n");
1847    // the parameters should be already initialised by InitPar()    // the parameters should be already initialised by InitPar()
1848      //  printf(" in process \n");
   
1849    Clear();    Clear();
1850    
   
   
   //  Float_t betamean = fabs(trackTRK->GetToFTrack()->beta[12]);  
   
   if(betamean<0.05 || betamean>2){  
     for(int i=0;i<48;i++)INFOpmt[i]=1;  
   }  
   
1851   // define angle:     // define angle:  
1852    double dx   = xtr_tof[1] - xtr_tof[5];    double dx   = xtr_tof[1] - xtr_tof[5];
1853    double dy   = ytr_tof[0] - ytr_tof[4];    double dy   = ytr_tof[0] - ytr_tof[4];
1854    double dr   = sqrt(dx*dx+dy*dy);    double dr   = sqrt(dx*dx+dy*dy);
1855    double theta=atan(dr/76.81);    double theta=atan(dr/76.81);
1856      //
1857      if ( xtr_tof[1] > 99. ||  xtr_tof[5] > 99. || ytr_tof[0] > 99. ||  ytr_tof[4] > 99. ) theta = 0.;
1858      for (Int_t ii=0; ii<6; ii++){
1859    //  TArrayF adc;      if ( xtr_tof[ii] > 99. ) xtr_tof[ii] = 0.;
1860    Float_t adc[48];      if ( ytr_tof[ii] > 99. ) ytr_tof[ii] = 0.;
   
   ToFLevel2 tf;  
   
   for (Int_t gg=0; gg<4;gg++){  
     for (Int_t hh=0; hh<12;hh++){  
       //          tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh];            
       int mm = tf.GetPMTid(gg,hh);          
       adc[mm]=tofl0->adc[gg][hh];  
     };        
1861    };    };
1862        //
1863        if ( debug ) printf(" theta %f \n",theta);
1864        if ( debug ) printf(" xtr_tof %.1f %.1f %.1f %.1f %.1f %.1f \n",xtr_tof[0],xtr_tof[1],xtr_tof[2],xtr_tof[3],xtr_tof[4],xtr_tof[5]);
1865        if ( debug ) printf(" ytr_tof %.1f %.1f %.1f %.1f %.1f %.1f \n",ytr_tof[0],ytr_tof[1],ytr_tof[2],ytr_tof[3],ytr_tof[4],ytr_tof[5]);
1866      //--------------------- TABLE OF PERIODS WITH HV PROBLEMS ----------------------------
1867      
1868      int Aconn=conn[0];    // PMT 0,20,22,24
1869      int Bconn=conn[1];    // PMT 6,12,26,34
1870      int Cconn=conn[2];    // PMT 4,14,28,32
1871      int Dconn=conn[3];    // PMT 2,8,10,30
1872      int Econn=conn[4];    // PMT 42,43,44,47
1873      int Fconn=conn[5];    // PMT 7,19,23,27
1874      int Gconn=conn[6];    // PMT 3,11,25,33
1875      int Hconn=conn[7];    // PMT 1,9,13,21
1876      int Iconn=conn[8];    // PMT 5,29,31,35
1877      int Lconn=conn[9];    // PMT 37,40,45,46
1878      int Mconn=conn[10];    // PMT 15,16,17,18
1879      int Nconn=conn[11];    // PMT 36,38,39,41
1880      if( false ) cout << Gconn << Iconn << Lconn <<endl; // to avoid compilation warnings
1881        
1882      //  printf(" size %i \n",eDEDXpmt.GetSize());
1883    for( int ii=0; ii<48; ii++ ) {    for( int ii=0; ii<48; ii++ ) {
1884      if( adc[ii] >= PMTsat[ii]-5 )  continue;      //
1885      if( adc[ii] <= 0. )            continue;      //    eDEDXpmt.SetAt(-1.,ii);
1886          //    printf(" ii %i beta %f atime %u xtr 1 %f ytr 1 %f adc %f \n",ii,betamean,atime,xtr_tof[0],ytr_tof[0],adc[ii]);
1887      double adcpC   = f_adcPC( adc[ii] );    // - adc conversion in pC      if ( debug ) printf("II %i adc %f \n",ii,adc[ii]);
1888      double adccorr = adcpC*fabs(cos(theta));  
1889        if( adc[ii] >= 4095. ){
1890           if(adccorr<=0.)           continue;        //      eDEDXpmt[ii] = 0.;
1891          eDEDXpmt->AddAt(0.,ii);
1892          if ( debug ) printf(" %i adc>4095 \n",ii);
1893          continue; // EMILIANO
1894        };
1895    
1896      //--------------------- TABLE OF PERIODS WITH HV PROBLEMS ----------------------------      if( adc[ii] >= (PMTsat[ii]-5.) && adc[ii] < 4095. ){
1897          eDEDXpmt->AddAt(1000.,ii);
1898          if ( debug ) printf(" %i adc> pmtsat && adc<4095 \n",ii);
1899          continue; // EMILIANO
1900        };
1901    
1902      int Aconn=conn[0];    // PMT 0,20,22,24      if( adc[ii] <= 0. ) {
1903      int Bconn=conn[1];    // PMT 6,12,26,34        eDEDXpmt->AddAt(1500.,ii);
1904      int Cconn=conn[2];    // PMT 4,14,28,32        if ( debug ) printf(" %i adc<=0 \n",ii);
1905      int Dconn=conn[3];    // PMT 2,8,10,30        continue;
1906      int Econn=conn[4];    // PMT 42,43,44,47      };
1907      int Fconn=conn[5];    // PMT 7,19,23,27      //
1908      int Gconn=conn[6];    // PMT 3,11,25,33      double adcpC   = f_adcPC( adc[ii] );    // - adc conversion in pC
1909      int Hconn=conn[7];    // PMT 1,9,13,21      if ( exitat == 0 ){
1910      int Iconn=conn[8];    // PMT 5,29,31,35        eDEDXpmt->AddAt((Float_t)adcpC,ii);
1911      int Lconn=conn[9];    // PMT 37,40,45,46        continue;
1912      int Mconn=conn[10];    // PMT 15,16,17,18      }
1913      int Nconn=conn[11];    // PMT 36,38,39,41      //    printf(" e qua? \n");
1914    
1915        double adccorr = adcpC*fabs(cos(theta));    
1916        if ( debug ) printf(" adccorr %f \n",adccorr);
1917        if(adccorr<=0.){
1918          if ( debug ) printf(" %i adccorr<=0 \n",ii);
1919          //      eDEDXpmt->AddAt((Float_t)adcpC,ii);//?
1920          continue;
1921        }
1922        if ( exitat == 1 ){
1923          eDEDXpmt->AddAt((Float_t)adccorr,ii);
1924          continue;
1925        }
1926        //    printf(" e quo? \n");
1927    
1928      //    int standard=0;      //    int standard=0;
     if( false ) cout << Gconn << Iconn << Lconn <<endl;  
1929      int S115B_ok=0;      int S115B_ok=0;
1930      int S115B_break=0;      int S115B_break=0;
1931    
 //   if(atime>=1153660001 && atime<=1154375000)Dconn=1;  
 //     else if(atime>=1155850001 && atime<=1156280000){  
 //       Hconn=1;  
 //       Nconn=1;  
 //     }  
   
 //  else if(atime>=1168490001 && atime<=1168940000)Dconn=1;  
 //     else if(atime>=1168940001 && atime<=1169580000){  
 //       Fconn=1;  
 //       Mconn=1;  
 //     }  
   
 //  else if(atime>=1174665001 && atime<=1175000000)Bconn=1;  
 //     else if(atime>=1176120001 && atime<=1176800000)Hconn=1;  
 //     else if(atime>=1176800001 && atime<=1178330000)Econn=1;  
 //     else if(atime>=1178330001 && atime<=1181322000)Hconn=1;  
 //     else if(atime>=1182100001 && atime<=1183030000)Aconn=1;  
 //     else if(atime>=1184000001 && atime<=1184570000)Hconn=1;  
 //     else if(atime>=1185090001 && atime<=1185212000)Dconn=1;  
 //     else if(atime>=1191100001 && atime<=1191940000)Dconn=1;  
 //     else if(atime>=1196230001 && atime<=1196280000)Hconn=1;  
 //     else if(atime>=1206100001 && atime<=1206375600)Cconn=1;  
 //     else if(atime>=1217989201 && atime<=1218547800)Econn=1;  
 //     else if(atime>=1225789201 && atime<=1226566800)Econn=1;  
 //     else if(atime>=1229400901 && atime<=1229700000)Econn=1;  
 //     else if(atime>=1230318001 && atime<=1230415200)Econn=1;  
 //     else {  
 //       standard=1;  
 //     }  
1932      if(atime<1158720000)S115B_ok=1;      if(atime<1158720000)S115B_ok=1;
1933      else S115B_break=1;      else S115B_break=1;
1934    
1935    
1936   //------------------------------------------------------------------------      //------------------------------------------------------------------------
1937        //    printf(" e qui? \n");
1938  //---------------------------------------------------- Z reconstruction      //---------------------------------------------------- Z reconstruction
1939    
1940  double adcHe, adcnorm, adclin, dEdx, Zeta;      double adcHe, adcnorm, adclin, dEdx;//, Zeta; // EM GCC4.7
1941    
1942   adcHe=-2;      adcHe=-2;
1943   adcnorm=-2;      adcnorm=-2;
1944   adclin=-2;      adclin=-2;
1945   dEdx=-2;      dEdx=-2;
1946   Zeta=-2;      //    Zeta=-2;//EM GCC4.7
1947        Double_t correction = 1.;
   
 //  float ZetaH=-2;  
 //  float dEdxH=-2;  
   
 //  double day = (atime-1150000000)/84600;  
1948    
1949      if(Aconn==1 && (ii==0 || ii==20 || ii==22 || ii==24)){      if(Aconn==1 && (ii==0 || ii==20 || ii==22 || ii==24)){
1950         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.675;        correction = 1.675;
1951      }      }
1952      else if(Bconn==1 && (ii==6 || ii==12 || ii==26 || ii==34)){      else if(Bconn==1 && (ii==6 || ii==12 || ii==26 || ii==34)){
1953         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/2.482;        correction = 2.482;
1954      }      }
1955      else if(Cconn==1 && (ii==4 || ii==14 || ii==28 || ii==32)){      else if(Cconn==1 && (ii==4 || ii==14 || ii==28 || ii==32)){
1956        adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.464;        correction = 1.464;
1957      }      }
1958      else if(Dconn==1 && (ii==2 || ii==8 || ii==10 || ii==30)){      else if(Dconn==1 && (ii==2 || ii==8 || ii==10 || ii==30)){
1959         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.995;        correction = 1.995;
1960      }      }
1961      else if(Econn==1 && (ii==42 || ii==43 || ii==44 || ii==47)){      else if(Econn==1 && (ii==42 || ii==43 || ii==44 || ii==47)){
1962         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.273;        correction = 1.273;
1963      }      }
1964      else if(Fconn==1 && (ii==7 || ii==19 || ii==23 || ii==27)){      else if(Fconn==1 && (ii==7 || ii==19 || ii==23 || ii==27)){
1965         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.565;        correction = 1.565;
1966      }      }
1967      else if(Mconn==1 && (ii==15 || ii==16 || ii==17 || ii==18)){      else if(Mconn==1 && (ii==15 || ii==16 || ii==17 || ii==18)){
1968         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.565;        correction = 1.565;
1969      }      }
1970      else if(Nconn==1 && (ii==36 || ii==38 || ii==39 || ii==41)){      else if(Nconn==1 && (ii==36 || ii==38 || ii==39 || ii==41)){
1971         adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.018;        correction = 1.018;
1972      }      }
1973      else if(Hconn==1 && (ii==1 || ii==13 || ii==21 || (ii==9&&S115B_ok==1))){      else if(Hconn==1 && (ii==1 || ii==13 || ii==21 || (ii==9&&S115B_ok==1))){
1974        adcHe   = (Get_adc_he(ii, xtr_tof, ytr_tof))/1.84;        correction = 1.84;
     }  
     else if(S115B_break==1 && ii==9 && Hconn==0){  
        adcHe   = f_att5B( ytr_tof[0] );   //N.B.: this function refers to the Carbon!!!  
1975      }      }
1976      else if(S115B_break==1 && ii==9 && Hconn==1){      else if(S115B_break==1 && ii==9 && Hconn==1){
1977         adcHe   = (f_att5B( ytr_tof[0] ))/1.64;        correction = 1.64;
1978        }
1979        else correction = 1.;
1980        
1981        if( ii==9 && S115B_break==1 ){
1982          adcHe   = f_att5B( ytr_tof[0] )/correction;
1983        } else {
1984          adcHe   = Get_adc_he(ii, xtr_tof, ytr_tof)/correction;
1985        };
1986        if(adcHe<=0){
1987          if ( debug ) printf(" %i adcHe<=0 \n",ii);
1988          //      eDEDXpmt->AddAt((Float_t)adccorr,ii); //?
1989          continue;
1990        }
1991        if ( exitat == 2 ){
1992          if(ii==9 && S115B_break==1)  eDEDXpmt->AddAt(36.*(Float_t)adccorr/adcHe,ii);
1993          else  adclin  = 4.*(Float_t)adccorr/adcHe;
1994          continue;
1995      }      }
     else  adcHe   = Get_adc_he(ii, xtr_tof, ytr_tof);  
   
     if(adcHe<=0)   continue;  
1996    
1997      if(ii==9 && S115B_break==1)  adcnorm = f_pos5B(adccorr);      if(ii==9 && S115B_break==1)  adcnorm = f_pos5B(adccorr);
1998      else adcnorm = f_pos( (parPos[ii]), adccorr);      else adcnorm = f_pos( (parPos[ii]), adccorr);
1999        if(adcnorm<=0){
2000      if(adcnorm<=0) continue;        if ( debug ) printf(" %i adcnorm<=0 \n",ii);
2001          //      eDEDXpmt->AddAt((Float_t)adccorr,ii);//?
2002          continue;
2003        }
2004        if ( debug ) printf(" adcnorm %f \n",adcnorm);
2005    
2006      if(ii==9 && S115B_break==1)  adclin  = 36.*adcnorm/adcHe;      if(ii==9 && S115B_break==1)  adclin  = 36.*adcnorm/adcHe;
2007      else  adclin  = 4.*adcnorm/adcHe;      else  adclin  = 4.*adcnorm/adcHe;
2008        if ( debug ) printf(" adclin %f \n",adclin);
2009      if(adclin<=0)  continue;      if(adclin<=0){
2010          if ( debug ) printf(" %i adclin<=0 \n",ii);
2011          //      eDEDXpmt->AddAt((Float_t)adccorr,ii);//?
2012          continue;
2013        }
2014        if ( exitat == 3 ){
2015          if(ii==9 && S115B_break==1)  eDEDXpmt->AddAt((Float_t)adclin,ii);
2016          else  eDEDXpmt->AddAt((Float_t)adclin,ii);
2017          continue;
2018        }
2019        //
2020        if ( betamean > 99. ){
2021          //      eDEDXpmt.AddAt((Float_t)adclin,ii);
2022          eDEDXpmt->AddAt((Float_t)adclin,ii);
2023          //      printf(" AAPMT IS %i dedx is %f vector is %f \n",ii,adclin,eDEDXpmt[ii]);
2024          if ( debug ) printf(" %i betamean > 99 \n",ii);
2025          continue;
2026        };
2027        //
2028      double dEdxHe=-2;      double dEdxHe=-2;
2029      if(ii==9 && S115B_break==1){      if(ii==9 && S115B_break==1){
2030        if( betamean <1. ) dEdxHe = f_BB5B( betamean );        if( betamean <1. ) dEdxHe = f_BB5B( betamean );
# Line 1709  double adcHe, adcnorm, adclin, dEdx, Zet Line 2033  double adcHe, adcnorm, adclin, dEdx, Zet
2033        if( betamean <1. ) dEdxHe = f_BB( (parBBneg[ii]), betamean );        if( betamean <1. ) dEdxHe = f_BB( (parBBneg[ii]), betamean );
2034        else                       dEdxHe = parBBpos[ii];        else                       dEdxHe = parBBpos[ii];
2035      }      }
   
     if(dEdxHe<=0)  continue;  
   
     if(ii==9 && S115B_break==1)  dEdx = f_desatBB5B( adclin );  
     else  dEdx = f_desatBB((parDesatBB[ii]), adclin );  
   
     if(dEdx<=0)    continue;  
   
     if(ii==9 && S115B_break==1)  Zeta = sqrt(36.*(dEdx/dEdxHe));  
     else  Zeta = sqrt(4.*(dEdx/dEdxHe));  
   
     if(Zeta<=0)    continue;  
   
 //--------------------- TIME DEPENDENCE ----------------------------------  
   
   
 //      TArrayF &binx = TDx[ii];  
 //      TArrayF &biny = TDy[ii];  
 //      for(int k=0; k<200; k++) {  
 //        if (day > binx[k]-2.5 && day<=binx[k]+2.5 && biny[k]>0)  {  
 //       ZetaH=Zeta/biny[k]*6;  
 //       dEdxH=dEdx/(pow(biny[k],2))*36;  
 //        }  
 //      }  
   
 //      if(ZetaH!=-2)eZpmt[ii]=(Float_t)ZetaH;  
 //      else eZpmt[ii]=(Float_t)Zeta;  
   
 //      if(dEdxH!=-2)eDEDXpmt[ii]=(Float_t)dEdxH;  
 //      else eDEDXpmt[ii]=(Float_t)dEdx;  
   
 //      printf("%5d %8.2f %8.2f %8.2f  %8.2f %8.2f  %8.2f %5.4f \n",               ii, adcpC,  adccorr, adcHe, dEdxHe, dEdx, Zeta, betamean );  
   
     eZpmt[ii]=(Float_t)Zeta;  
     eDEDXpmt[ii]=(Float_t)dEdx;  
   
   
  }  //end loop on 48 PMT  
   
 //---------------------------------------------------  paddle + layer --------------------  
   
   for(int j=0;j<48;j++){  
     int k=100;  
     if(j%2==0 || j==0)k=j/2;  
       
     double zpdl=-1;  
       
     if((j%2==0 || j==0) && eZpmt[j]!=-1 && eZpmt[j+1]!=-1){  
       zpdl=0.5*(eZpmt[j]+eZpmt[j+1]);  
     }else if((j%2==0 || j==0) && eZpmt[j]!=-1 && eZpmt[j+1]==-1){  
       zpdl=eZpmt[j];  
     }else if((j%2==0 || j==0) && eZpmt[j]==-1 && eZpmt[j+1]!=-1){  
       zpdl=eZpmt[j+1];  
     }  
2036            
2037      if(j%2==0 || j==0)eZpad[k]= (Float_t)zpdl;      if ( debug ) printf(" dEdxHe %f \n",dEdxHe);
2038            
2039      if((j%2==0 || j==0)&&eZpad[k]!=-1){      if(dEdxHe<=0){
2040        if(k>=0&&k<8)eZlayer[0]=eZpad[k];        eDEDXpmt->AddAt((Float_t)adclin,ii);
2041        if(k>=8&&k<14)eZlayer[1]=eZpad[k];        if ( debug ) printf(" %i dEdxHe<=0 \n",ii);
2042        if(k>=14&&k<16)eZlayer[2]=eZpad[k];        continue;
2043        if(k>=16&&k<18)eZlayer[3]=eZpad[k];      };
       if(k>=18&&k<21)eZlayer[4]=eZpad[k];  
       if(k>=21)eZlayer[5]=eZpad[k];  
     }  
   
     if(eZlayer[0]!=-1&&eZlayer[1]!=-1&&fabs(eZlayer[0]-eZlayer[1])<1.5)eZplane[0]=0.5*(eZlayer[0]+eZlayer[1]);  
     else if(eZlayer[0]!=-1&&eZlayer[1]==-1)eZplane[0]=eZlayer[0];  
     else if(eZlayer[1]!=-1&&eZlayer[0]==-1)eZplane[0]=eZlayer[1];  
   
     if(eZlayer[2]!=-1&&eZlayer[3]!=-1&&fabs(eZlayer[2]-eZlayer[3])<1.5)eZplane[1]=0.5*(eZlayer[2]+eZlayer[3]);  
     else if(eZlayer[2]!=-1&&eZlayer[3]==-1)eZplane[1]=eZlayer[2];  
     else if(eZlayer[3]!=-1&&eZlayer[2]==-1)eZplane[1]=eZlayer[3];  
2044    
2045      if(eZlayer[4]!=-1&&eZlayer[5]!=-1&&fabs(eZlayer[4]-eZlayer[5])<1.5)eZplane[2]=0.5*(eZlayer[4]+eZlayer[5]);      if(ii==9 && S115B_break==1)  dEdx = f_desatBB5B( adclin );
2046      else if(eZlayer[4]!=-1&&eZlayer[5]==-1)eZplane[2]=eZlayer[4];      else  dEdx = f_desatBB((parDesatBB[ii]), adclin );
     else if(eZlayer[5]!=-1&&eZlayer[4]==-1)eZplane[2]=eZlayer[5];  
2047    
2048    }      if(dEdx<=0){
2049          eDEDXpmt->AddAt((Float_t)adclin,ii);
2050          if ( debug ) printf(" %i dEdx<=0 \n",ii);
2051          continue;
2052        };
2053    
2054    for(int jj=0;jj<48;jj++){      if ( debug ) printf(" dEdx %f \n",dEdx);
2055      int k=100;      eDEDXpmt->AddAt((Float_t)dEdx,ii);
2056      if(jj%2==0 || jj==0)k=jj/2;      //    eDEDXpmt.AddAt((Float_t)dEdx,ii);
       
     double dedxpdl=-1;  
       
     if((jj%2==0 || jj==0) && eDEDXpmt[jj]!=-1 && eDEDXpmt[jj+1]!=-1){  
       dedxpdl=0.5*(eDEDXpmt[jj]+eDEDXpmt[jj+1]);  
     }else if((jj%2==0 || jj==0) && eDEDXpmt[jj]!=-1 && eDEDXpmt[jj+1]==-1){  
       dedxpdl=eDEDXpmt[jj];  
     }else if((jj%2==0 || jj==0) && eDEDXpmt[jj]==-1 && eDEDXpmt[jj+1]!=-1){  
       dedxpdl=eDEDXpmt[jj+1];  
     }  
       
     if(jj%2==0 || jj==0)eDEDXpad[k]= (Float_t)dedxpdl;  
       
     if((jj%2==0 || jj==0)&&eDEDXpad[k]!=-1){  
       if(k>=0&&k<8)eDEDXlayer[0]=eDEDXpad[k];  
       if(k>=8&&k<14)eDEDXlayer[1]=eDEDXpad[k];  
       if(k>=14&&k<16)eDEDXlayer[2]=eDEDXpad[k];  
       if(k>=16&&k<18)eDEDXlayer[3]=eDEDXpad[k];  
       if(k>=18&&k<21)eDEDXlayer[4]=eDEDXpad[k];  
       if(k>=21)eDEDXlayer[5]=eDEDXpad[k];  
     }  
   
     if(eDEDXlayer[0]!=-1&&eDEDXlayer[1]!=-1&&fabs(eDEDXlayer[0]-eDEDXlayer[1])<10)eDEDXplane[0]=0.5*(eDEDXlayer[0]+eDEDXlayer[1]);  
     else if(eDEDXlayer[0]!=-1&&eDEDXlayer[1]==-1)eDEDXplane[0]=eDEDXlayer[0];  
     else if(eDEDXlayer[1]!=-1&&eDEDXlayer[0]==-1)eDEDXplane[0]=eDEDXlayer[1];  
   
     if(eDEDXlayer[2]!=-1&&eDEDXlayer[3]!=-1&&fabs(eDEDXlayer[2]-eDEDXlayer[3])<10)eDEDXplane[1]=0.5*(eDEDXlayer[2]+eDEDXlayer[3]);  
     else if(eDEDXlayer[2]!=-1&&eDEDXlayer[3]==-1)eDEDXplane[1]=eDEDXlayer[2];  
     else if(eDEDXlayer[3]!=-1&&eDEDXlayer[2]==-1)eDEDXplane[1]=eDEDXlayer[3];  
   
     if(eDEDXlayer[4]!=-1&&eDEDXlayer[5]!=-1&&fabs(eDEDXlayer[4]-eDEDXlayer[5])<10)eDEDXplane[2]=0.5*(eDEDXlayer[4]+eDEDXlayer[5]);  
     else if(eDEDXlayer[4]!=-1&&eDEDXlayer[5]==-1)eDEDXplane[2]=eDEDXlayer[4];  
     else if(eDEDXlayer[5]!=-1&&eDEDXlayer[4]==-1)eDEDXplane[2]=eDEDXlayer[5];  
2057    
2058    }      //    printf(" PMT IS %i dedx is %f vector is %f \n",ii,dEdx,eDEDXpmt[ii]);
     
2059    
2060      }  //end loop on 48 PMT
2061    
2062  };  };
2063    
2064    
2065  //------------------------------------------------------------------------  //------------------------------------------------------------------------
 void ToFdEdx::PrintTD()  
 {  
   for(int i=0; i<48; i++) {    
     TArrayF &binx = TDx[i];  
     TArrayF &biny = TDy[i];  
     for(int k=0; k<200; k++) {  // bin temporali  
       printf("%d %d %f %f", i,k, binx[k], biny[k]);  
         
     }  
   }  
 }  
   
   
 //------------------------------------------------------------------------  
2066  void ToFdEdx::Define_PMTsat()  void ToFdEdx::Define_PMTsat()
2067  {  {
2068    Float_t  sat[48] = {    Float_t  sat[48] = {
# Line 1861  void ToFdEdx::Define_PMTsat() Line 2076  void ToFdEdx::Define_PMTsat()
2076  }  }
2077    
2078  //------------------------------------------------------------------------  //------------------------------------------------------------------------
 // void ToFdEdx::ReadParTD( Int_t ipmt, const char *fname )  
 // {  
 //   printf("read %s\n",fname);  
 //   if(ipmt<0)  return;  
 //   if(ipmt>47) return;  
 //   FILE *fattin = fopen( fname , "r" );  
 //   Float_t yTD[200],xTD[200];  
 //   for(int j=0;j<200;j++){  
 //     float x,y,ym,e;  
 //     if(fscanf(fattin,"%f %f %f %f",  
 //            &x, &y, &ym, &e )!=4) break;  
 //     xTD[j]=x;  
 //     if(ym>0&&fabs(y-ym)>1)  yTD[j]=ym;  
 //     else                    yTD[j]=y;  
 //   }  
 //   TDx[ipmt].Set(200,xTD);  
 //   TDy[ipmt].Set(200,yTD);  
 //   fclose(fattin);  
 // }  
   
 //------------------------------------------------------------------------  
2079  void ToFdEdx::ReadParBBpos( const char *fname )  void ToFdEdx::ReadParBBpos( const char *fname )
2080  {  {
2081    printf("read %s\n",fname);    //  printf("read %s\n",fname);
2082    parBBpos.Set(48);    parBBpos.Set(48);
2083    FILE *fattin = fopen( fname , "r" );    FILE *fattin = fopen( fname , "r" );
2084    for (int i=0; i<48; i++) {    for (int i=0; i<48; i++) {
# Line 1900  void ToFdEdx::ReadParBBpos( const char * Line 2094  void ToFdEdx::ReadParBBpos( const char *
2094  //------------------------------------------------------------------------  //------------------------------------------------------------------------
2095  void ToFdEdx::ReadParDesatBB( const char *fname )  void ToFdEdx::ReadParDesatBB( const char *fname )
2096  {  {
2097    printf("read %s\n",fname);    //  printf("read %s\n",fname);
2098    FILE *fattin = fopen( fname , "r" );    FILE *fattin = fopen( fname , "r" );
2099    for (int i=0; i<48; i++) {    for (int i=0; i<48; i++) {
2100      int   tid=0;      int   tid=0;
# Line 1917  void ToFdEdx::ReadParDesatBB( const char Line 2111  void ToFdEdx::ReadParDesatBB( const char
2111  void ToFdEdx::ReadParBBneg( const char *fname )  void ToFdEdx::ReadParBBneg( const char *fname )
2112    
2113  {  {
2114    printf("read %s\n",fname);    //  printf("read %s\n",fname);
2115    FILE *fattin = fopen( fname , "r" );    FILE *fattin = fopen( fname , "r" );
2116    for (int i=0; i<48; i++) {    for (int i=0; i<48; i++) {
2117      int   tid=0;      int   tid=0;
# Line 1932  void ToFdEdx::ReadParBBneg( const char * Line 2126  void ToFdEdx::ReadParBBneg( const char *
2126  //------------------------------------------------------------------------  //------------------------------------------------------------------------
2127  void ToFdEdx::ReadParPos( const char *fname )  void ToFdEdx::ReadParPos( const char *fname )
2128  {  {
2129    printf("read %s\n",fname);    //  printf("read %s\n",fname);
2130    FILE *fattin = fopen( fname , "r" );    FILE *fattin = fopen( fname , "r" );
2131    for (int i=0; i<48; i++) {    for (int i=0; i<48; i++) {
2132      int   tid=0;      int   tid=0;
# Line 1947  void ToFdEdx::ReadParPos( const char *fn Line 2141  void ToFdEdx::ReadParPos( const char *fn
2141  //------------------------------------------------------------------------  //------------------------------------------------------------------------
2142  void ToFdEdx::ReadParAtt( const char *fname )  void ToFdEdx::ReadParAtt( const char *fname )
2143  {  {
2144    printf("read %s\n",fname);    //  printf("read %s\n",fname);
2145    FILE *fattin = fopen( fname , "r" );    FILE *fattin = fopen( fname , "r" );
2146    for (int i=0; i<48; i++) {    for (int i=0; i<48; i++) {
2147      int   tid=0;      int   tid=0;
# Line 2020  float ToFdEdx::Get_adc_he( int id, float Line 2214  float ToFdEdx::Get_adc_he( int id, float
2214    //             pl_x - coord x of the tof plane    //             pl_x - coord x of the tof plane
2215    //             pl_y - coord y    //             pl_y - coord y
2216    
2217     adc_he = 0;    adc_he = 0;
2218    if( eGeom.GetXY(id)==1 )  adc_he = f_att( (parAtt[id]), pl_x[eGeom.GetPlane(id)] );    if( eGeom.GetXY(id)==1 )  adc_he = f_att( (parAtt[id]), pl_x[eGeom.GetPlane(id)] );
2219    if( eGeom.GetXY(id)==2 )  adc_he = f_att( (parAtt[id]), pl_y[eGeom.GetPlane(id)] );    if( eGeom.GetXY(id)==2 )  adc_he = f_att( (parAtt[id]), pl_y[eGeom.GetPlane(id)] );
2220    return adc_he;    return adc_he;
# Line 2055  double ToFdEdx::f_desatBB5B( float x ) Line 2249  double ToFdEdx::f_desatBB5B( float x )
2249      0.009*x*x;      0.009*x*x;
2250  }  }
2251    
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.48

  ViewVC Help
Powered by ViewVC 1.1.23