/[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.15 by pam-de, Wed Apr 4 07:23:27 2007 UTC revision 1.22 by pamela, Fri Jun 20 12:23:26 2008 UTC
# Line 3  Line 3 
3   * \author Gianfranca DeRosa, Wolfgang Menn   * \author Gianfranca DeRosa, Wolfgang Menn
4   */   */
5    
 #include <TObject.h>  
6  #include <ToFLevel2.h>  #include <ToFLevel2.h>
7  #include <iostream>  
8  using namespace std;  using namespace std;
9    
10  ClassImp(ToFPMT);  ClassImp(ToFPMT);
11  ClassImp(ToFTrkVar);  ClassImp(ToFTrkVar);
12  ClassImp(ToFLevel2);  ClassImp(ToFLevel2);
# Line 15  ToFPMT::ToFPMT(){ Line 15  ToFPMT::ToFPMT(){
15    pmt_id = 0;    pmt_id = 0;
16    adc = 0.;    adc = 0.;
17    tdc_tw = 0.;    tdc_tw = 0.;
18      tdc = 0.;
19  }  }
20    
21  ToFPMT::ToFPMT(const ToFPMT &t){  ToFPMT::ToFPMT(const ToFPMT &t){
22    pmt_id = t.pmt_id;    pmt_id = t.pmt_id;
23    adc = t.adc;    adc = t.adc;
24    tdc_tw = t.tdc_tw;    tdc_tw = t.tdc_tw;
25      tdc = t.tdc;
26  }  }
27    
28  void ToFPMT::Clear(){  void ToFPMT::Clear(Option_t *t){
29    pmt_id = 0;    pmt_id = 0;
30    adc = 0.;    adc = 0.;
31    tdc_tw = 0.;    tdc_tw = 0.;
32      tdc = 0.;
33  }  }
34    
35    
# Line 45  ToFTrkVar::ToFTrkVar() { Line 48  ToFTrkVar::ToFTrkVar() {
48    memset(beta,  0, 13*sizeof(Float_t));    memset(beta,  0, 13*sizeof(Float_t));
49    memset(xtofpos,  0, 3*sizeof(Float_t));    memset(xtofpos,  0, 3*sizeof(Float_t));
50    memset(ytofpos,  0, 3*sizeof(Float_t));    memset(ytofpos,  0, 3*sizeof(Float_t));
51      memset(xtr_tof,  0, 6*sizeof(Float_t));
52      memset(ytr_tof,  0, 6*sizeof(Float_t));
53    //    //
54  };  };
55    
56  void ToFTrkVar::Clear() {  void ToFTrkVar::Clear(Option_t *t) {
57    trkseqno = 0;    trkseqno = 0;
58    npmttdc = 0;    npmttdc = 0;
59    npmtadc = 0;    npmtadc = 0;
# Line 61  void ToFTrkVar::Clear() { Line 66  void ToFTrkVar::Clear() {
66    memset(beta,  0, 13*sizeof(Float_t));    memset(beta,  0, 13*sizeof(Float_t));
67    memset(xtofpos,  0, 3*sizeof(Float_t));    memset(xtofpos,  0, 3*sizeof(Float_t));
68    memset(ytofpos,  0, 3*sizeof(Float_t));    memset(ytofpos,  0, 3*sizeof(Float_t));
69      memset(xtr_tof,  0, 6*sizeof(Float_t));
70      memset(ytr_tof,  0, 6*sizeof(Float_t));
71    //    //
72  };  };
73    
# Line 79  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t) Line 86  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t)
86    memcpy(beta,t.beta,sizeof(beta));    memcpy(beta,t.beta,sizeof(beta));
87    memcpy(xtofpos,t.xtofpos,sizeof(xtofpos));    memcpy(xtofpos,t.xtofpos,sizeof(xtofpos));
88    memcpy(ytofpos,t.ytofpos,sizeof(ytofpos));    memcpy(ytofpos,t.ytofpos,sizeof(ytofpos));
89      memcpy(xtr_tof,t.xtr_tof,sizeof(xtr_tof));
90      memcpy(ytr_tof,t.ytr_tof,sizeof(ytr_tof));
91    //    //
92  };  };
93    
# Line 98  void ToFLevel2::Set(){//ELENA Line 107  void ToFLevel2::Set(){//ELENA
107      if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA      if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
108  }//ELENA  }//ELENA
109    
110  void ToFLevel2::Clear(){  void ToFLevel2::Clear(Option_t *t){
111    //    //
112    if(ToFTrk)ToFTrk->Delete(); //ELENA    if(ToFTrk)ToFTrk->Delete(); //ELENA
113    if(PMT)PMT->Delete(); //ELENA    if(PMT)PMT->Delete(); //ELENA
# Line 107  void ToFLevel2::Clear(){ Line 116  void ToFLevel2::Clear(){
116    //    //
117  };  };
118    
119  void ToFLevel2::Delete(){ //ELENA  void ToFLevel2::Delete(Option_t *t){ //ELENA
120    //    //
121    if(ToFTrk){    if(ToFTrk){
122        ToFTrk->Delete(); //ELENA        ToFTrk->Delete(); //ELENA
# Line 153  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 162  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
162  //--------------------------------------  //--------------------------------------
163  /**  /**
164   * Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5)   * Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5)
165   * @param Plane index (0,1,2,3,4,5)   * @param Plane index (0,1,2,3,4,5).
166   */   */
167    Int_t  ToFLevel2::GetToFPlaneID(Int_t ip){    Int_t  ToFLevel2::GetToFPlaneID(Int_t ip){
168        if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1;        if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1;
# Line 208  Int_t ToFLevel2::GetNHitPaddles(Int_t pl Line 217  Int_t ToFLevel2::GetNHitPaddles(Int_t pl
217  };  };
218    
219    
220    //gf Apr 07
221  /**  /**
222   * Method to get the mean dEdx from a given ToF plane. This current version   * Method to get the mean dEdx from a given ToF plane. This current version
223   * is just summing up all PMT signals, which will not give proper results,   * is just summing up all PMT signals, which will not give proper results,
224   * and needs a revision.   *  and needs a revision.
225   * @param notrack Track Number   * @param notrack Track Number
226   * @param plane Plane index (0,1,2,3,4,5).   * @param plane Plane index (0,1,2,3,4,5)
227     * @param adcflag in the plane (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
228   */   */
229  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane, Int_t adcfl){
230    
231    Float_t dedx = 0.;    Float_t dedx = 0.;
232    Int_t ip = 0;    Float_t PadEdx =0.;
233    Int_t pmt_id = 0;    Int_t SatWarning;
234    Int_t pl = 0;    Int_t pad=-1;
   if ( plane >= 6 ){  
     ip = GetToFPlaneIndex(plane);  
   } else {  
     ip = plane;  
   };  
235    //    //
236    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = GetToFTrkVar(notrack);
237    if(!trk) return 0; //ELENA    if(!trk) return 0; //ELENA
238    //    //
239    for (Int_t i=0; i<trk->npmtadc; i++){    for (Int_t ii=0; ii<GetNPaddle(plane); ii++){
240      //      Int_t paddleid=ii;
241      pmt_id = (trk->pmtadc).At(i);      pad = GetPaddleid(plane,paddleid);
242      //      GetdEdxPaddle(notrack, pad, adcfl, PadEdx, SatWarning);
243      pl = GetPlaneIndex(pmt_id);      dedx += PadEdx;
     //  
     if ( pl == ip ) dedx += (trk->dedx).At(i);  
     //  
244    };    };
245    //    //
246    return(dedx);    return(dedx);
247  };  };
248    
   
249  /**  /**
250   * 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
251   * with the time-walk corrected TDC values.   * with the time-walk corrected TDC values.
# Line 307  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt Line 309  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt
309    return(-1);    return(-1);
310  };  };
311    
312    
313  /**  /**
314   * Method to get the PMT_ID if the index (4,12) is given. We have 4 channels on   * Method to get the PMT_ID if the index (4,12) is given. We have 4 channels on
315   * each of the 12 half-boards, this method decodes which PMT is cables to which   * each of the 12 half-boards, this method decodes which PMT is cables to which
# Line 342  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_ Line 345  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_
345    return ind;    return ind;
346  };  };
347    
 /**  
  * Method to get the PMT name (like "S11_1A") if the PMT_ID is given. The first  
  * PMT=0 is S11_1A, then S11_1B, then S11_2A, and so on, up to S32_3B which is PMT=47  
  * @param ind  PMT_ID (0 - 47)  
  */  
 TString ToFLevel2::GetPMTName(Int_t ind){  
     
   TString pmtname = " ";  
     
   TString photoS[48] = {  
     "S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", "S11_4B",  
     "S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", "S11_8B",  
     "S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", "S12_4B", "S12_5A",  "S12_5B", "S12_6A", "S12_6B",  
     "S21_1A", "S21_1B", "S21_2A", "S21_2B",  
     "S22_1A", "S22_1B", "S22_2A", "S22_2B",  
     "S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B",  
     "S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B"  
   };  
     
   
   pmtname = photoS[ind].Data();  
   
   return pmtname;  
 };  
348    
349  /**  /**
350   * Method to get the PMT index if the PMT ID is given. This method is the   * Method to get the PMT index if the PMT ID is given. This method is the
# Line 400  void ToFLevel2::GetPMTIndex(Int_t ind, I Line 379  void ToFLevel2::GetPMTIndex(Int_t ind, I
379    return;    return;
380  };  };
381    
382    
383    
384    
385    /// gf Apr 07
386    
387    /**
388     * Method to get the dEdx from a given ToF paddle.
389     * @param notrack Track Number
390     * @param Paddle index (0,1,...,23).
391     * @param adcflag in the paddle (100<-> independent of the adcflag; !=0&&!=100 <-> at least one PMT with adcflag!=0; )
392     * @param PadEdx dEdx from a given ToF paddle
393     * @param SatWarning 1 if the PMT ios near saturation region (adcraw ~3000)
394     */
395    void ToFLevel2::GetdEdxPaddle(Int_t notrack, Int_t paddleid, Int_t adcfl, Float_t &PadEdx, Int_t &SatWarning){
396    
397      PadEdx = 0.;
398      SatWarning = 1000;
399    
400      Float_t dEdx[48] = {0};
401      Int_t pmt_id = -1;
402      Float_t adcraw[48];
403      //
404      ToFTrkVar *trk = GetToFTrkVar(notrack);
405      if(!trk) return; //ELENA
406      //
407    
408      Int_t pmtleft=-1;
409      Int_t pmtright=-1;
410      GetPaddlePMT(paddleid, pmtleft, pmtright);
411    
412      adcraw[pmtleft] = 4095;
413      adcraw[pmtright] = 4095;
414    
415      
416      for (Int_t jj=0; jj<npmt(); jj++){
417        
418        ToFPMT *pmt = GetToFPMT(jj);
419        if(!pmt)break; //ELENA
420        
421        pmt_id = pmt->pmt_id;
422        if(pmt_id==pmtleft){
423          adcraw[pmtleft] = pmt->adc;
424        }
425        
426        if(pmt_id==pmtright){
427          adcraw[pmtright] = pmt->adc;
428        }
429      }
430      
431      for (Int_t i=0; i<trk->npmtadc; i++){
432    
433        if((trk->adcflag).At(i)==0 || adcfl==100){
434          if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = (trk->dedx).At(i);
435          if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = (trk->dedx).At(i);
436        }else{
437          if((trk->pmtadc).At(i) == pmtleft)dEdx[pmtleft] = 0.;
438          if((trk->pmtadc).At(i) == pmtright)dEdx[pmtright] = 0.;
439        }
440      }
441    
442      if( adcraw[pmtleft] >3000 || adcraw[pmtright] >3000)SatWarning=1;
443        
444      if(dEdx[pmtleft]!=0 && dEdx[pmtright]!=0){
445        PadEdx = (dEdx[pmtleft]+dEdx[pmtright])*0.5;
446      }
447      if(dEdx[pmtleft]==0 && dEdx[pmtright]!=0){
448        PadEdx = dEdx[pmtright];
449      }
450      if(dEdx[pmtleft]!=0 && dEdx[pmtright]==0){
451        PadEdx = dEdx[pmtleft];
452      }
453      
454      return;
455    };
456    //
457    
458    
459    // gf Apr 07
460    
461    /**
462     * Method to get the PMT name (like "S11_1A") if the PMT_ID is given.
463     * Indexes of corresponding  plane, paddle and  pmt are also given as output.
464     * @param ind  PMT_ID (0 - 47)
465     * @param iplane plane index (0 - 5)
466     * @param ipaddle paddle index (relative to the plane)
467     * @param ipmt pmt index (0(A), 1(B))
468     */
469    TString ToFLevel2::GetPMTName(Int_t ind, Int_t &iplane, Int_t &ipaddle,Int_t &ipmt){
470      
471      TString pmtname = " ";
472      
473      TString photoS[48] = {
474        "S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A",
475        "S11_4B",
476        "S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A",
477        "S11_8B",
478        "S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A",
479        "S12_4B", "S12_5A",  "S12_5B", "S12_6A", "S12_6B",
480        "S21_1A", "S21_1B", "S21_2A", "S21_2B",
481        "S22_1A", "S22_1B", "S22_2A", "S22_2B",
482        "S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B",
483        "S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B"
484      };
485      
486      
487      pmtname = photoS[ind].Data();
488      
489      TString ss = pmtname(1,2);
490      iplane  = (int)(atoi(ss.Data())/10)*2-3+atoi(ss.Data())%10;
491      ss = pmtname(4);
492      ipaddle = atoi(ss.Data())-1 ;
493      if( pmtname.Contains("A") )ipmt=0;
494      if( pmtname.Contains("B") )ipmt=1;
495      
496      return pmtname;
497    };
498    /**
499     * Method to get the PMT name (like "S11_1A") if the PMT_ID is given
500     * @param ind  PMT_ID (0 - 47)
501     */
502    TString ToFLevel2::GetPMTName(Int_t ind){
503    
504      Int_t iplane  = -1;
505      Int_t ipaddle = -1;
506      Int_t ipmt    = -1;
507      return GetPMTName(ind,iplane,ipaddle,ipmt);
508      
509    };
510    
511    // wm jun 08
512    Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane){
513    return GetPaddleIdOfTrack(xtr ,ytr ,plane, 0.4);
514    }
515    
516    // gf Apr 07
517    // wm jun 08  introduced a margin as input parameter
518    Int_t ToFLevel2::GetPaddleIdOfTrack(Float_t xtr, Float_t ytr, Int_t plane, Float_t margin){
519    
520      Double_t xt,yt,xl,xh,yl,yh;
521      
522      Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85};
523      Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75};
524      Float_t tof21_y[2] = { 3.75,-3.75};
525      Float_t tof22_x[2] = { -4.5,4.5};
526      Float_t tof31_x[3] = { -6.0,0.,6.0};
527      Float_t tof32_y[3] = { -5.0,0.0,5.0};
528      
529      //  S11 8 paddles  33.0 x 5.1 cm
530      //  S12 6 paddles  40.8 x 5.5 cm
531      //  S21 2 paddles  18.0 x 7.5 cm
532      //  S22 2 paddles  15.0 x 9.0 cm
533      //  S31 3 paddles  15.0 x 6.0 cm
534      //  S32 3 paddles  18.0 x 5.0 cm
535      
536      Int_t paddleidoftrack=-1;
537      //
538      
539      //--- S11 ------
540      
541      if(plane==0){
542        xt = xtr;
543        yt = ytr;
544        paddleidoftrack=-1;
545        yl = -33.0/2. ;
546        yh =  33.0/2. ;
547        if ((yt>yl)&&(yt<yh)) {
548          for (Int_t i1=0; i1<8;i1++){
549            xl = tof11_x[i1] - (5.1-margin)/2. ;
550            xh = tof11_x[i1] + (5.1-margin)/2. ;
551            if ((xt>xl)&&(xt<xh))  paddleidoftrack=i1;
552          }
553        }
554      }
555      //      cout<<"S11  "<<paddleidoftrack[0]<<"\n";
556      
557      //--- S12 -------
558      if(plane==1){
559        xt = xtr;
560        yt = ytr;
561        paddleidoftrack=-1;
562        xl = -40.8/2. ;
563        xh =  40.8/2. ;
564        
565        if ((xt>xl)&&(xt<xh)) {
566          for (Int_t i1=0; i1<6;i1++){
567            yl = tof12_y[i1] - (5.5-margin)/2. ;
568            yh = tof12_y[i1] + (5.5-margin)/2. ;
569            if ((yt>yl)&&(yt<yh))  paddleidoftrack=i1;
570          }
571        }
572      }
573      
574      //--- S21 ------
575    
576      if(plane==2){
577        xt = xtr;
578        yt = ytr;
579        paddleidoftrack=-1;
580        xl = -18./2. ;
581        xh =  18./2. ;
582        
583        if ((xt>xl)&&(xt<xh)) {
584          for (Int_t i1=0; i1<2;i1++){
585            yl = tof21_y[i1] - (7.5-margin)/2. ;
586            yh = tof21_y[i1] + (7.5-margin)/2. ;
587            if ((yt>yl)&&(yt<yh))  paddleidoftrack=i1;
588          }
589        }
590      }
591      
592      //--- S22 ------
593      if(plane==3){
594        xt = xtr;
595        yt = ytr;
596        paddleidoftrack=-1;
597        yl = -15./2. ;
598        yh =  15./2. ;
599        
600        if ((yt>yl)&&(yt<yh)) {
601          for (Int_t i1=0; i1<2;i1++){
602            xl = tof22_x[i1] - (9.0-margin)/2. ;
603            xh = tof22_x[i1] + (9.0-margin)/2. ;
604            if ((xt>xl)&&(xt<xh))  paddleidoftrack=i1;
605          }
606        }
607      }  
608      
609      //--- S31 ------
610      if(plane==4){
611        xt = xtr;
612        yt = ytr;
613        paddleidoftrack=-1;
614        yl = -15.0/2. ;
615        yh =  15.0/2. ;
616        
617        if ((yt>yl)&&(yt<yh)) {
618          for (Int_t i1=0; i1<3;i1++){
619            xl = tof31_x[i1] - (6.0-margin)/2. ;
620            xh = tof31_x[i1] + (6.0-margin)/2. ;
621            if ((xt>xl)&&(xt<xh))  paddleidoftrack=i1;
622          }
623        }
624      }  
625      
626      //---  S32 ------
627      if(plane==5){
628        xt = xtr;
629        yt = ytr;
630        paddleidoftrack=-1;
631        xl = -18.0/2. ;
632        xh =  18.0/2. ;
633        
634        if ((xt>xl)&&(xt<xh)) {
635          for (Int_t i1=0; i1<3;i1++){
636            yl = tof32_y[i1] - (5.0-margin)/2. ;
637            yh = tof32_y[i1] + (5.0-margin)/2. ;
638            if ((yt>yl)&&(yt<yh)) paddleidoftrack=i1;
639          }
640        }
641      }
642      
643      return paddleidoftrack;
644    
645    }  
646    
647    //
648    
649    // gf Apr 07
650    
651    void ToFLevel2::GetPMTPaddle(Int_t pmt_id, Int_t &plane, Int_t &paddle){
652      
653      plane = GetPlaneIndex(pmt_id);
654    
655      if(plane == 0){
656        if(pmt_id==0 || pmt_id==1)paddle=0;
657        if(pmt_id==2 || pmt_id==3)paddle=1;
658        if(pmt_id==4 || pmt_id==5)paddle=2;
659        if(pmt_id==6 || pmt_id==7)paddle=3;
660        if(pmt_id==8 || pmt_id==9)paddle=4;
661        if(pmt_id==10 || pmt_id==11)paddle=5;
662        if(pmt_id==12 || pmt_id==13)paddle=6;
663        if(pmt_id==14 || pmt_id==15)paddle=7;
664      }
665      
666      if(plane == 1){
667        if(pmt_id==16 || pmt_id==17)paddle=0;
668        if(pmt_id==18 || pmt_id==19)paddle=1;
669        if(pmt_id==20 || pmt_id==21)paddle=2;
670        if(pmt_id==22 || pmt_id==23)paddle=3;
671        if(pmt_id==24 || pmt_id==25)paddle=4;
672        if(pmt_id==26 || pmt_id==27)paddle=5;
673      }
674      
675      if(plane == 2){
676        if(pmt_id==28 || pmt_id==29)paddle=0;
677        if(pmt_id==30 || pmt_id==31)paddle=1;
678      }
679      
680      if(plane == 3){
681        if(pmt_id==32 || pmt_id==33)paddle=0;
682        if(pmt_id==34 || pmt_id==35)paddle=1;
683      }
684      
685      if(plane == 4){
686        if(pmt_id==36 || pmt_id==37)paddle=0;
687        if(pmt_id==38 || pmt_id==39)paddle=1;
688        if(pmt_id==40 || pmt_id==41)paddle=2;
689      }
690      
691      if(plane == 5){
692        if(pmt_id==42 || pmt_id==43)paddle=0;
693        if(pmt_id==44 || pmt_id==45)paddle=1;
694        if(pmt_id==46 || pmt_id==47)paddle=2;
695      }
696      return;
697    }
698    
699    //
700    
701    // gf Apr 07
702    
703    void ToFLevel2::GetPaddlePMT(Int_t paddle, Int_t &pmtleft, Int_t &pmtright){
704      pmtleft=paddle*2;
705      pmtright= pmtleft+1;
706      return;
707    }
708    
709    //
710    
711    
712    
713    // // gf Apr 07
714    
715    void ToFLevel2::GetPaddleGeometry(Int_t plane, Int_t paddle, Float_t &xleft, Float_t &xright, Float_t &yleft, Float_t &yright){
716      
717      Int_t i1;
718    
719      Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85};
720      Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75};
721      Float_t tof21_y[2] = { 3.75,-3.75};
722      Float_t tof22_x[2] = { -4.5,4.5};
723      Float_t tof31_x[3] = { -6.0,0.,6.0};
724      Float_t tof32_y[3] = { -5.0,0.0,5.0};
725            
726      //  S11 8 paddles  33.0 x 5.1 cm
727      //  S12 6 paddles  40.8 x 5.5 cm
728      //  S21 2 paddles  18.0 x 7.5 cm
729      //  S22 2 paddles  15.0 x 9.0 cm
730      //  S31 3 paddles  15.0 x 6.0 cm
731      //  S32 3 paddles  18.0 x 5.0 cm
732    
733      if(plane==0)
734        {
735          for (i1=0; i1<8;i1++){
736            if(i1 == paddle){
737              xleft = tof11_x[i1] - 5.1/2.;
738              xright = tof11_x[i1] + 5.1/2.;
739              yleft = -33.0/2.;
740              yright = 33.0/2.;
741            }
742          }
743        }
744      
745      if(plane==1)
746        {
747          for (i1=0; i1<6;i1++){
748            if(i1 == paddle){
749              xleft = -40.8/2.;
750              xright = 40.8/2.;
751              yleft = tof12_y[i1] - 5.5/2.;
752              yright = tof12_y[i1] + 5.5/2.;
753            }
754          }
755        }
756    
757      if(plane==2)
758        {
759          for (i1=0; i1<2;i1++){
760            if(i1 == paddle){
761              xleft =  -18./2.;
762              xright = 18./2.;
763              yleft = tof21_y[i1] - 7.5/2.;
764              yright = tof21_y[i1] + 7.5/2.;
765            }
766          }
767        }
768      
769      if(plane==3)
770        {
771          for (i1=0; i1<2;i1++){
772            if(i1 == paddle){
773              xleft = tof22_x[i1] - 9.0/2.;
774              xright = tof22_x[i1] + 9.0/2.;
775              yleft = -15./2.;
776              yright = 15./2.;
777            }
778          }
779        }
780    
781    
782      if(plane==4)
783        {
784          for (i1=0; i1<3;i1++){
785            if(i1 == paddle){
786              xleft = tof31_x[i1] - 6.0/2.;
787              xright = tof31_x[i1] + 6.0/2.;
788              yleft = -15./2.;
789              yright = 15./2.;
790            }
791          }
792        }
793    
794      if(plane==5)
795        {
796          for (i1=0; i1<3;i1++){
797            if(i1 == paddle){
798              xleft = -18.0/2.;
799              xright = 18.0/2.;
800              yleft = tof32_y[i1] - 5.0/2.;
801              yright = tof32_y[i1] + 5.0/2.;
802            }
803          }
804        }
805      return;
806    }
807    
808    // gf Apr 07
809    /**
810     * Method to get the paddle index (0,...23) if the plane ID and the paddle id in the plane is given.
811     * This method is the
812     * "reverse" of method "GetPaddlePlane"
813     * @param plane    (0 - 5)
814     * @param paddle   (plane=0, paddle = 0,...5)
815     * @param padid    (0 - 23)
816     */
817    Int_t ToFLevel2::GetPaddleid(Int_t plane, Int_t paddle)
818    {
819      Int_t padid=-1;
820      Int_t pads[6]={8,6,2,2,3,3};
821    
822      int somma=0;
823      int np=plane;
824      for(Int_t j=0; j<np; j++){
825        somma+=pads[j];
826      }
827      padid=paddle+somma;
828      return padid;
829    }
830    
831    
832    // gf Apr 07
833    /**
834     * Method to get the plane ID and the paddle id in the plane if the paddle index (0,...23) is given.
835     * This method is the
836     * "reverse" of method "GetPaddleid"
837     * @param pad      (0 - 23)
838     * @param plane    (0 - 5)
839     * @param paddle   (plane=0, paddle = 0,...5)
840     */
841    void ToFLevel2::GetPaddlePlane(Int_t pad, Int_t &plane, Int_t &paddle)
842    {
843    
844      Int_t pads11=8;
845      Int_t pads12=6;
846      Int_t pads21=2;
847      Int_t pads22=2;
848      Int_t pads31=3;
849      // Int_t pads32=3;
850    
851      if(pad<8){
852        plane=0;
853        paddle=pad;
854        return;
855      }
856    
857      if(7<pad<14){
858        plane=1;
859        paddle=pad-pads11;
860        return;
861      }
862      
863      if(13<pad<16){
864        plane=2;
865        paddle=pad-pads11-pads12;
866        return;
867      }
868    
869      if(15<pad<18){
870        plane=3;
871        paddle=pad-pads11-pads12-pads21;
872        return;
873      }
874    
875      if(17<pad<21){
876        plane=4;
877        paddle=pad-pads11-pads12-pads21-pads22;
878        return;
879      }
880    
881      if(20<pad<24){
882        plane=5;
883        paddle=pad-pads11-pads12-pads21-pads22-pads31;
884        return;
885      }  
886    
887    }
888    
889    
890    Int_t ToFLevel2::GetNPaddle(Int_t plane){
891    
892      Int_t npaddle=-1;
893    
894      Int_t pads11=8;
895      Int_t pads12=6;
896      Int_t pads21=2;
897      Int_t pads22=2;
898      Int_t pads31=3;
899      Int_t pads32=3;
900    
901      if(plane==0)npaddle=pads11;
902      if(plane==1)npaddle=pads12;
903      if(plane==2)npaddle=pads21;
904      if(plane==3)npaddle=pads22;
905      if(plane==4)npaddle=pads31;
906      if(plane==5)npaddle=pads32;
907    
908      return npaddle;
909    
910    }
911    
912    /// wm feb 08
913    
914    /**
915     * Method to calculate Beta from the 12 single measurements
916     * we check the individual weights for artificial TDC values, then calculate
917     * am mean beta for the first time. In a second step we loop again through
918     * the single measurements, checking for the residual from the mean
919     * The cut on the residual reject measurements > "x"-sigma. A chi2 value is
920     * calculated, furthermore a "quality" value by adding the weights which
921     * are finally used. If all measurements are taken, "quality" will be = 22.47.
922     * A chi2 cut around 3-4 and a quality-cut > 20 is needed for clean beta
923     * measurements like antiprotons etc.
924     * The Level2 output is derived in the fortran routines using: 10.,10.,20.
925     * @param notrack Track Number
926     * @param cut on residual: difference between single measurement and mean
927     * @param cut on "quality"
928     * @param cut on chi2
929     */
930    
931    Float_t ToFLevel2::CalcBeta(Int_t notrack, Float_t resmax, Float_t qualitycut, Float_t chi2cut){
932    
933    //  cout<<" in CalcBeta "<<resmax<<" "<<chi2cut<<" "<<qualitycut<<endl;
934    
935      Float_t bxx = 100.;
936      //
937      ToFTrkVar *trk = GetToFTrkVar(notrack);
938      if(!trk) return 0; //ELENA
939    
940    
941      Float_t chi2,xhelp,beta_mean;
942      Float_t w_i[12],quality,sw,sxw,res,betachi,beta_mean_inv;
943      Float_t b[12],tdcfl;
944      Int_t  pmt_id,pmt_plane;
945    
946      for (Int_t i=0; i<12; i++){
947        b[i] = trk->beta[i];
948                                  }
949          
950    
951    //========================================================================
952    //---  Find out ToF layers with artificial TDC values & fill vector    ---
953    //========================================================================
954    
955    Float_t  w_il[6];
956    
957         for (Int_t jj=0; jj<6;jj++) {
958             w_il[jj] = 1000.;
959                                     }
960    
961    
962      for (Int_t i=0; i<trk->npmttdc; i++){
963        //
964        pmt_id = (trk->pmttdc).At(i);
965        pmt_plane = GetPlaneIndex(pmt_id);
966        tdcfl = (trk->tdcflag).At(i);
967        if (w_il[pmt_plane] != 1.) w_il[pmt_plane] = tdcfl; //tdcflag
968                                         };
969      
970    //========================================================================
971    //---  Set weights for the 12 measurements using information for top and bottom:
972    //---  if no measurements: weight = set to very high value=> not used
973    //---  top or bottom artificial: weight*sqrt(2)
974    //---  top and bottom artificial: weight*sqrt(2)*sqrt(2)
975    //========================================================================
976    
977    Int_t itop[12] = {0,0,1,1,2,2,3,3,0,0,1,1};
978    Int_t ibot[12] = {4,5,4,5,4,5,4,5,2,3,2,3};
979    
980         xhelp= 1E09;
981      
982         for (Int_t jj=0; jj<12;jj++) {
983         if (jj<4)           xhelp = 0.11;    // S1-S3
984         if ((jj>3)&&(jj<8)) xhelp = 0.18;    // S2-S3
985         if (jj>7)           xhelp = 0.28;    // S1-S2
986         if ((w_il[itop[jj]] == 1000.) && (w_il[ibot[jj]] == 1000.)) xhelp = 1E09;
987         if ((w_il[itop[jj]] == 1) || (w_il[ibot[jj]] == 1.)) xhelp = xhelp*1.414 ;
988         if ((w_il[itop[jj]] == 1) && (w_il[ibot[jj]] == 1.)) xhelp = xhelp*2. ;
989    
990         w_i[jj] = 1./xhelp;
991                                      }
992    
993    
994    //========================================================================
995    //--- Calculate mean beta for the first time -----------------------------
996    //--- We are using "1/beta" since its error is gaussian ------------------
997    //========================================================================
998    
999          Int_t icount=0;
1000          sw=0.;
1001          sxw=0.;
1002          beta_mean=100.;
1003    
1004              for (Int_t jj=0; jj<12;jj++){
1005            if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.))
1006             {
1007                icount= icount+1;
1008                sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ;
1009                sw =sw + w_i[jj]*w_i[jj] ;
1010    
1011             }
1012             }
1013    
1014          if (icount>0) beta_mean=1./(sxw/sw);
1015          beta_mean_inv = 1./beta_mean;
1016    
1017    //========================================================================
1018    //--- Calculate beta for the second time, use residuals of the single
1019    //--- measurements to get a chi2 value
1020    //========================================================================
1021    
1022          icount=0;
1023          sw=0.;
1024          sxw=0.;
1025          betachi = 100.;
1026          chi2 = 0.;
1027          quality=0.;
1028    
1029    
1030              for (Int_t jj=0; jj<12;jj++){
1031           if ((fabs(1./b[jj])>0.1)&&(fabs(1./b[jj])<15.)&&(w_i[jj]>0.01)) {
1032                res = beta_mean_inv - (1./b[jj]) ;
1033                if (fabs(res*w_i[jj])<resmax)          {;
1034                chi2 = chi2 + pow((res*w_i[jj]),2) ;
1035                icount= icount+1;
1036                sxw=sxw + (1./b[jj])*w_i[jj]*w_i[jj] ;
1037                sw =sw + w_i[jj]*w_i[jj] ;
1038                                                   }
1039                                                                            }
1040                                          }
1041          quality = sqrt(sw) ;
1042    
1043          if (icount==0) chi2 = 1000.;
1044          if (icount>0) chi2 = chi2/(icount) ;
1045          if (icount>0) betachi=1./(sxw/sw);
1046    
1047       bxx = 100.;
1048       if ((chi2 < chi2cut)&&(quality>qualitycut)) bxx = betachi;
1049      //
1050      return(bxx);
1051    };
1052    
1053    
1054    ////////////////////////////////////////////////////
1055    ////////////////////////////////////////////////////
1056    
1057    
1058    
1059  /**  /**
1060   * Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common).   * Fills a struct cToFLevel2 with values from a ToFLevel2 object (to put data into a F77 common).
1061   */   */
# Line 430  void ToFLevel2::GetLevel2Struct(cToFLeve Line 1086  void ToFLevel2::GetLevel2Struct(cToFLeve
1086                l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];                l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];
1087                l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];                l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];
1088            }            }
1089              for(Int_t i=0;i<6;i++){
1090                  l2->xtr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtr_tof[i];
1091                  l2->ytr_tof[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytr_tof[i];
1092              }
1093        }        }
1094    } //ELENA    } //ELENA
1095            
# Line 442  void ToFLevel2::GetLevel2Struct(cToFLeve Line 1102  void ToFLevel2::GetLevel2Struct(cToFLeve
1102        }        }
1103    } //ELENA    } //ELENA
1104  }  }
1105    
1106    
1107    //
1108    // Reprocessing tool // Emiliano 08/04/07
1109    //
1110    Int_t ToFLevel2::Process(TrkLevel2 *trk, TrigLevel2 *trg, GL_RUN *run, OrbitalInfo *orb, Bool_t force){
1111      //
1112      // Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto
1113      //
1114    
1115    
1116    
1117    
1118      //
1119      // structures to communicate with F77
1120      //
1121      extern struct ToFInput  tofinput_;
1122      extern struct ToFOutput tofoutput_;
1123      //
1124      // DB connection
1125      //
1126      TString host;
1127      TString user;
1128      TString psw;
1129      const char *pamdbhost=gSystem->Getenv("PAM_DBHOST");
1130      const char *pamdbuser=gSystem->Getenv("PAM_DBUSER");
1131      const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW");
1132      if ( !pamdbhost ) pamdbhost = "";
1133      if ( !pamdbuser ) pamdbuser = "";
1134      if ( !pamdbpsw ) pamdbpsw = "";
1135      if ( strcmp(pamdbhost,"") ) host = pamdbhost;
1136      if ( strcmp(pamdbuser,"") ) user = pamdbuser;
1137      if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw;
1138      //
1139      //
1140      TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
1141      if ( !dbc->IsConnected() ) return 1;
1142      stringstream myquery;
1143      myquery.str("");
1144      myquery << "SET time_zone='+0:00'";
1145      dbc->Query(myquery.str().c_str());
1146      GL_PARAM *glparam = new GL_PARAM();
1147      glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table
1148      trk->LoadField(glparam->PATH+glparam->NAME);
1149      //
1150      Bool_t defcal = true;
1151      Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table
1152      if ( error<0 ) {
1153        return(1);
1154      };
1155      printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data());
1156      if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false;
1157      //
1158      Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length();
1159      rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen);
1160      //
1161      Int_t adc[4][12];
1162      Int_t tdc[4][12];
1163      Float_t tdcc[4][12];
1164      //
1165      // process tof data
1166      //
1167      for (Int_t hh=0; hh<12;hh++){
1168        for (Int_t kk=0; kk<4;kk++){
1169               adc[kk][hh] = 4095;
1170               tdc[kk][hh] = 4095;
1171               tdcc[kk][hh] = 4095.;
1172               tofinput_.adc[hh][kk] = 4095;
1173               tofinput_.tdc[hh][kk] = 4095;
1174        };
1175      };
1176      Int_t ntrkentry = 0;
1177      Int_t npmtentry = 0;
1178      Int_t gg = 0;
1179      Int_t hh = 0;
1180      Int_t adcf[48];
1181      memset(adcf, 0, 48*sizeof(Int_t));
1182      Int_t tdcf[48];
1183      memset(tdcf, 0, 48*sizeof(Int_t));
1184      for (Int_t pm=0; pm < this->ntrk() ; pm++){
1185         ToFTrkVar *ttf = this->GetToFTrkVar(pm);
1186         for ( Int_t nc=0; nc < ttf->npmttdc; nc++){
1187                if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1;
1188         };
1189         for ( Int_t nc=0; nc < ttf->npmtadc; nc++){
1190                if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1;
1191         };
1192      };
1193      //
1194      for (Int_t pm=0; pm < this->npmt() ; pm++){
1195         ToFPMT *pmt = this->GetToFPMT(pm);
1196         this->GetPMTIndex(pmt->pmt_id, gg, hh);
1197         if ( adcf[pmt->pmt_id] == 0 ){
1198                 tofinput_.adc[gg][hh] = (int)pmt->adc;
1199                 adc[hh][gg] = (int)pmt->adc;
1200         };
1201         if ( tdcf[pmt->pmt_id] == 0 ){
1202                 tofinput_.tdc[gg][hh] = (int)pmt->tdc;
1203                 tdc[hh][gg] = (int)pmt->tdc;
1204         };
1205         tdcc[hh][gg] = (float)pmt->tdc_tw;
1206         // Int_t pppid = this->GetPMTid(hh,gg);
1207         //      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);
1208      };
1209      //
1210      Int_t unpackError = this->unpackError;
1211      //
1212      for (Int_t hh=0; hh<5;hh++){
1213         tofinput_.patterntrig[hh]=trg->patterntrig[hh];
1214      };
1215      //
1216      this->Clear();
1217      //
1218          Int_t pmt_id = 0;
1219          ToFPMT *t_pmt = new ToFPMT();
1220          if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA
1221          TClonesArray &tpmt = *this->PMT;
1222          ToFTrkVar *t_tof = new ToFTrkVar();
1223          if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
1224          TClonesArray &t = *this->ToFTrk;
1225          //
1226          //
1227          // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related  variables.
1228          //
1229          npmtentry = 0;
1230          //
1231          ntrkentry = 0;
1232          //
1233          // Calculate tracks informations from ToF alone
1234          //
1235          tofl2com();
1236          //
1237          memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t));
1238          //
1239          t_tof->trkseqno = -1;
1240          //
1241          // and now we must copy from the output structure to the level2 class:
1242          //
1243          t_tof->npmttdc = 0;
1244          //
1245          for (Int_t hh=0; hh<12;hh++){
1246            for (Int_t kk=0; kk<4;kk++){
1247              if ( tofoutput_.tofmask[hh][kk] != 0 ){
1248                pmt_id = this->GetPMTid(kk,hh);
1249                t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
1250                t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
1251                t_tof->npmttdc++;
1252              };
1253            };
1254          };
1255          for (Int_t kk=0; kk<13;kk++){
1256            t_tof->beta[kk] = tofoutput_.betatof_a[kk];
1257          }
1258          //
1259          t_tof->npmtadc = 0;
1260          for (Int_t hh=0; hh<12;hh++){
1261            for (Int_t kk=0; kk<4;kk++){
1262              if ( tofoutput_.adctof_c[hh][kk] < 1000 ){
1263                t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc);
1264                pmt_id = this->GetPMTid(kk,hh);
1265                t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
1266                t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
1267                t_tof->npmtadc++;
1268              };
1269            };
1270          };
1271          //
1272          memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
1273          memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
1274          memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
1275          memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
1276          //
1277          new(t[ntrkentry]) ToFTrkVar(*t_tof);
1278          ntrkentry++;
1279          t_tof->Clear();
1280          //
1281          //
1282          //
1283          t_pmt->Clear();
1284          //
1285          for (Int_t hh=0; hh<12;hh++){
1286            for (Int_t kk=0; kk<4;kk++){
1287             // new WM
1288              if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){
1289    //          if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095  || tdc[kk][hh] < 4095 ){
1290                //
1291                t_pmt->pmt_id = this->GetPMTid(kk,hh);
1292                t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk];
1293                t_pmt->adc = (Float_t)adc[kk][hh];
1294                t_pmt->tdc = (Float_t)tdc[kk][hh];
1295                //
1296                new(tpmt[npmtentry]) ToFPMT(*t_pmt);
1297                npmtentry++;
1298                t_pmt->Clear();
1299              };
1300            };
1301          };
1302          //
1303          // Calculate track-related variables
1304          //
1305          if ( trk->ntrk() > 0 ){
1306            //
1307            // We have at least one track
1308            //
1309            //
1310            // Run over tracks
1311            //
1312            for(Int_t nt=0; nt < trk->ntrk(); nt++){
1313              //
1314              TrkTrack *ptt = trk->GetStoredTrack(nt);
1315              //
1316              // Copy the alpha vector in the input structure
1317              //
1318              for (Int_t e = 0; e < 5 ; e++){
1319                tofinput_.al_pp[e] = ptt->al[e];
1320              };
1321              //
1322              // Get tracker related variables for this track
1323              //
1324              toftrk();
1325              //
1326              // Copy values in the class from the structure (we need to use a temporary class to store variables).
1327              //
1328              t_tof->npmttdc = 0;
1329              for (Int_t hh=0; hh<12;hh++){
1330                for (Int_t kk=0; kk<4;kk++){
1331                  if ( tofoutput_.tofmask[hh][kk] != 0 ){
1332                    pmt_id = this->GetPMTid(kk,hh);
1333                    t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc);
1334                    t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07
1335                    t_tof->npmttdc++;
1336                  };
1337                };
1338              };
1339              for (Int_t kk=0; kk<13;kk++){
1340                t_tof->beta[kk] = tofoutput_.beta_a[kk];
1341              };
1342              //
1343              t_tof->npmtadc = 0;
1344              for (Int_t hh=0; hh<12;hh++){
1345                for (Int_t kk=0; kk<4;kk++){
1346                  if ( tofoutput_.adc_c[hh][kk] < 1000 ){
1347                    t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc);
1348                    pmt_id = this->GetPMTid(kk,hh);
1349                    t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc);
1350                    t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07
1351                    t_tof->npmtadc++;
1352                  };
1353                };
1354              };
1355              //
1356              memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos));
1357              memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos));
1358              memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof));
1359              memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof));
1360              //
1361              // Store the tracker track number in order to be sure to have shyncronized data during analysis
1362              //
1363              t_tof->trkseqno = nt;
1364              //
1365              // create a new object for this event with track-related variables
1366              //
1367              new(t[ntrkentry]) ToFTrkVar(*t_tof);
1368              ntrkentry++;
1369              t_tof->Clear();
1370              //
1371            }; // loop on all the tracks
1372          //
1373          this->unpackError = unpackError;
1374          if ( defcal ){
1375            this->default_calib = 1;
1376          } else {
1377            this->default_calib = 0;
1378          };
1379     };
1380    
1381    
1382    
1383      return(0);
1384    }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.23