/[PAMELA software]/PamVMC/tof/src/PamVMCTofDig.cxx
ViewVC logotype

Diff of /PamVMC/tof/src/PamVMCTofDig.cxx

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

revision 1.1 by nikolas, Thu Feb 19 16:00:17 2009 UTC revision 1.6 by pizzolot, Tue Feb 23 12:09:40 2010 UTC
# Line 27  void PamVMCTofDig::LoadCalib(){ Line 27  void PamVMCTofDig::LoadCalib(){
27    ThrowCalFileUsage("TOF",fquery.str().c_str());    ThrowCalFileUsage("TOF",fquery.str().c_str());
28        
29    fcfile.open(fquery.str().c_str());    fcfile.open(fquery.str().c_str());
   // fcfile.open("/opt/pamela-5.21/calib/tof-param/ToFCalibParam.txt");  
30    
31    if(!fcfile) ThrowCalFileWarning("TOF"); else {    if(!fcfile) ThrowCalFileWarning("TOF"); else {
32    
# Line 70  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 69  void PamVMCTofDig::DigitizeTOF(Int_t Eve
69    const Int_t ADCsat=3100;       // saturation value for the ADCs    const Int_t ADCsat=3100;       // saturation value for the ADCs
70    const Int_t TDClast=4095;    const Int_t TDClast=4095;
71    
72    
73    for(Int_t i =0; i<NP; i++){    for(Int_t i =0; i<NP; i++){
74      fQevePmt_pC[i]=ftdc[i]=ftdc1[i]=0.;      fQevePmt_pC[i]=ftdc[i]=ftdc1[i]=0.;
75      ftdcpmt[i]=1000.;      ftdcpmt[i]=1000.;
# Line 85  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 85  void PamVMCTofDig::DigitizeTOF(Int_t Eve
85      hc = 0;      hc = 0;
86    }    }
87    
88      if(fDEBUG){
89        cout<<"Summarized values for ADC in PC:"<<endl;
90        for(Int_t i=0; i<NP; i++){
91          cout<<"PMT #"<<i<<" fQevePmt_pC="<<fQevePmt_pC[i]<<endl;
92        }
93      }
94    //+++++ ADC +++++    //+++++ ADC +++++
95    
96    for(Int_t i=0; i<NP; i++){    for(Int_t i=0; i<NP; i++){
97      if (fQevePmt_pC[i] < 800.)        if (fQevePmt_pC[i] <= 800.)  
98        fADCtof[i]= (Int_t)(ADC_pC0A + ADC_pC1A*fQevePmt_pC[i]        fADCtof[i]= (Int_t)(ADC_pC0A + ADC_pC1A*fQevePmt_pC[i]
99                            + ADC_pC2A*Power(fQevePmt_pC[i],2)                            + ADC_pC2A*Power(fQevePmt_pC[i],2)
100                            + ADC_pC3A*Power(fQevePmt_pC[i],3));                            + ADC_pC3A*Power(fQevePmt_pC[i],3));
# Line 106  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 112  void PamVMCTofDig::DigitizeTOF(Int_t Eve
112    
113    // ======  TDC coincidence  ======    // ======  TDC coincidence  ======
114    
115    Float_t t_coinc = 0;  
116      for(Int_t i=0; i<NP; i++) {
117        if((ftdcpmt[i] - fc1_S[i]) > 1e-7) {
118          ftdcpmt[i] = 0.;
119          ftdc[i] = 0.;
120        }
121      }// cycle to introduce a window for tdc
122    
123      Double_t t_coinc = 0;
124    Int_t ilast = 100;    Int_t ilast = 100;
125    for (Int_t ii=0; ii<NP;ii++)    for (Int_t ii=0; ii<NP;ii++)
126      if (ftdc[ii] > t_coinc) {      if (ftdc[ii] > t_coinc) {
# Line 147  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 161  void PamVMCTofDig::DigitizeTOF(Int_t Eve
161      fTDCint[i]= TDChelp[i];      fTDCint[i]= TDChelp[i];
162    }    }
163    
164      if (fDEBUG){
165        cout<<"====== TOF coincidence after... ======"<<endl;
166        for(Int_t i=0; i<NP; i++){
167          cout<<"PMT: "<<i<<" ADC: "<<fADCtof[i]<<" TDC: "
168              <<fTDCint[i]<<endl;
169        }
170        cout<<"============================="<<endl;
171      }
172    // ======  write DataTof  =======    // ======  write DataTof  =======
173    
174    UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192};  // DC (msb in 8 bit word )    UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192};  // DC (msb in 8 bit word )
# Line 174  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 195  void PamVMCTofDig::DigitizeTOF(Int_t Eve
195        /* control bits inserted here, after the bin to gray conv - DC*/        /* control bits inserted here, after the bin to gray conv - DC*/
196        DataTof[jk12+6] = Ctrl3bit[2*k+1] | DataTof[jk12+6];        DataTof[jk12+6] = Ctrl3bit[2*k+1] | DataTof[jk12+6];
197        tofBin=(UChar_t)(fTDCint[k+4*j]%256);   // TDC# (lsb)        tofBin=(UChar_t)(fTDCint[k+4*j]%256);   // TDC# (lsb)
198          //if(fDEBUG) cout<<" digit TDC: "<<jk12<<" TDC:"<<(Int_t)tofBin<<endl;
199        DataTof[jk12+7]=Bin2GrayTof(tofBin,DataTof[jk12+7]);        DataTof[jk12+7]=Bin2GrayTof(tofBin,DataTof[jk12+7]);
200      }      }
201      DataTof[j12+20]=0x00;   // TEMP1      DataTof[j12+20]=0x00;   // TEMP1
# Line 251  void PamVMCTofDig::DigitizeTOF(Int_t Eve Line 273  void PamVMCTofDig::DigitizeTOF(Int_t Eve
273    
274  Float_t PamVMCTofDig::TimeRes(Int_t PrimaryPDG){  Float_t PamVMCTofDig::TimeRes(Int_t PrimaryPDG){
275    
276    Float_t time_res[8] = {425.,210.,170.,130.,120.,120.,120.,120.};    Float_t time_res[8] = {425.,210.,170.,130.,120.,120.,120.,120.};
277      for(Int_t i=0;i<8;i++) time_res[i]/=1.4;//1.17;1.5;1.3*/
278    Int_t Z = Int_t((TDatabasePDG::Instance()->GetParticle(PrimaryPDG))->Charge()/3.);    Int_t Z = Int_t((TDatabasePDG::Instance()->GetParticle(PrimaryPDG))->Charge()/3.);
279            
280    Float_t dt1 = 1.e-12*time_res[0];  // single PMT resolution for Z=1  (WM, Nov'07)    Float_t dt1 = 1.e-12*time_res[0];  // single PMT resolution for Z=1  (WM, Nov'07)
# Line 300  void PamVMCTofDig::DigitizeTofPlane(Int_ Line 323  void PamVMCTofDig::DigitizeTofPlane(Int_
323      t1=t2 = hit->GetTOF();      t1=t2 = hit->GetTOF();
324      padNo = hit->GetPOS()-1;      padNo = hit->GetPOS()-1;
325      pmtleft=pmtright=0;      pmtleft=pmtright=0;
326      if(planeNo==2)      if(planeNo==2){
327        if(padNo==0)        if(padNo==0)
328          padNo=1;          padNo=1;
329        else        else
330          padNo=0;          padNo=0;
331        }
332    
333      Paddle2Pmt(planeNo,padNo, &pmtleft, &pmtright);      Paddle2Pmt(planeNo,padNo, &pmtleft, &pmtright);
334            
# Line 363  void PamVMCTofDig::DigitizeTofPlane(Int_ Line 387  void PamVMCTofDig::DigitizeTofPlane(Int_
387      // WM right and left <->          // WM right and left <->    
388      t1 += Abs(path[0]/veff0) + s_l_g[planeNo]/veff1;      t1 += Abs(path[0]/veff0) + s_l_g[planeNo]/veff1;
389      t2 += Abs(path[1]/veff0) + s_l_g[planeNo]/veff1;  // Signal reaches PMT      t2 += Abs(path[1]/veff0) + s_l_g[planeNo]/veff1;  // Signal reaches PMT
390      t1 = gRandom->Gaus(t1,TimeRes(PrimaryPDG)); //apply gaussian error  dt      t1 = frandom->Gaus(t1,TimeRes(PrimaryPDG)); //apply gaussian error  dt
391      t2 = gRandom->Gaus(t2,TimeRes(PrimaryPDG)); //apply gaussian error  dt      t2 = frandom->Gaus(t2,TimeRes(PrimaryPDG)); //apply gaussian error  dt
392      t1 += fc1_S[pmtleft] ;  // Signal reaches Discriminator ,TDC starts  to run      t1 += fc1_S[pmtleft] ;  // Signal reaches Discriminator ,TDC starts  to run
393      t2 += fc1_S[pmtright] ;      t2 += fc1_S[pmtright] ;
394    
# Line 391  void PamVMCTofDig::DigitizeTofPlane(Int_ Line 415  void PamVMCTofDig::DigitizeTofPlane(Int_
415        if (ftdcpmt[pmtright] < 1000.)  // is already filled!        if (ftdcpmt[pmtright] < 1000.)  // is already filled!
416          if (t2 <  ftdcpmt[pmtright]) {          if (t2 <  ftdcpmt[pmtright]) {
417            ftdcpmt[pmtright] = t2;            ftdcpmt[pmtright] = t2;
418            t2+= fc2_S[pmtright] ;            t2 += fc2_S[pmtright] ;
419            ftdc[pmtright] = t2;            ftdc[pmtright] = t2;
420          }          }
421      }      }
422      if(fDEBUG)cout<<"Time(s):"<<hit->GetTOF()<<" t1:"<<t1<<" t2:"<<t2<<endl      if(fDEBUG)cout<<"Time(s):"<<hit->GetTOF()<<" t1:"<<t1<<" t2:"<<t2<<endl
423                   <<"+++++  END OF TOF HIT +++++"<<endl;                   <<"+++++  END OF TOF HIT +++++"<<endl;
424          };
425    };    //END OF HIT COLLECTION LOOP
   //END OF HIT COLLECTION LOOP  
   
426  }  }
427    
428  void PamVMCTofDig::Paddle2Pmt(Int_t planeNo, Int_t padNo, Int_t *pl, Int_t *pr){  void PamVMCTofDig::Paddle2Pmt(Int_t planeNo, Int_t padNo, Int_t *pl, Int_t *pr){

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23