]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Reconstructor.cxx
Iontail object for OCDB
[u/mrichter/AliRoot.git] / T0 / AliT0Reconstructor.cxx
index 3664505b7bd353e151b8713b197c705005192253..aa10f8e208eac3f895edc30d516ea16dc272e784 100644 (file)
@@ -116,8 +116,7 @@ ClassImp(AliT0Reconstructor)
   AliDebug(2,Form(" LatencyL1 %f latencyL1A %f latencyL1C %f latencyHPTDC %f \n",fLatencyL1, fLatencyL1A, fLatencyL1C, fLatencyHPTDC));
  
   for (Int_t i=0; i<24; i++) {
-    if( fTime0vertex[i] < 500 || fTime0vertex[i] > 50000) fTime0vertex[i] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
-    //  printf(" calulated mean %i %f \n",i, fTime0vertex[i]);
+    if( fTime0vertex[i] < 500 || fTime0vertex[i] > 60000) fTime0vertex[i] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
   }
   //here real Z position
   fdZonC = TMath::Abs(fParam->GetZPosition("T0/C/PMT1"));
@@ -144,7 +143,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
  
   Float_t c = 29.9792458; // cm/ns
   Float_t channelWidth = fParam->GetChannelWidth() ;  
-  Double32_t vertex = 9999999, meanVertex = 9999999 ;
+  Double32_t vertex = 9999999, meanVertex = 0 ;
   Double32_t timeDiff=999999, meanTime=999999, timeclock=999999;
   
   
@@ -152,7 +151,13 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   
   Float_t lowAmpThreshold =  GetRecoParam()->GetAmpLowThreshold();  
   Float_t highAmpThreshold =  GetRecoParam()->GetAmpHighThreshold(); 
-  printf( "AliT0Reconstructor::Reconstruct::: RecoParam amplitude %f %f \n",lowAmpThreshold, highAmpThreshold);
+  printf("Reconstruct(TTree*digitsTree highAmpThreshold %f  lowAmpThreshold %f \n",lowAmpThreshold, highAmpThreshold);
+
+  //shift T0A, T0C , T0AC
+  Float_t shiftA = GetRecoParam() -> GetLow(310);  
+  Float_t shiftC = GetRecoParam() -> GetLow(311);  
+  Float_t shiftAC = GetRecoParam() -> GetLow(312);
+  printf("Reconstruct(TTree*digitsTree shiftA %f shiftC %f shiftAC %f \n",shiftA, shiftC, shiftAC);
  
   Double32_t besttimeA=9999999;  Double32_t besttimeA_best=9999999;
   Double32_t besttimeC=9999999;  Double32_t besttimeC_best=9999999;
@@ -193,16 +198,18 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   Float_t time[24], adc[24], adcmip[24];
   for (Int_t ipmt=0; ipmt<24; ipmt++) {
     if(timeCFD->At(ipmt)>0 ) {
+      Float_t timefull = 0.001*( timeCFD->At(ipmt) - 511 - timeDelayCFD[ipmt])  * channelWidth;
+      frecpoints.SetTimeFull(ipmt, 0 ,timefull) ;
       if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0)  
        adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt);
       else
        adc[ipmt] = 0;
       
       time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, Int_t(adc[ipmt]),  timeCFD->At(ipmt)) ;
-      
+      time[ipmt] =   time[ipmt] - 511;   
       Double_t sl = Double_t(timeLED->At(ipmt) - timeCFD->At(ipmt));
       //    time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl),  timeCFD->At(ipmt) ) ;
-      AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
+      AliDebug(5,Form(" ipmt %i QTC  %i , time in chann %i (led-cfd) %i ",
                      ipmt, Int_t(adc[ipmt]) ,Int_t(time[ipmt]),Int_t( sl)));
       
       Double_t ampMip = 0;
@@ -219,7 +226,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
       
     }
     else {
-      time[ipmt] = 0;
+      time[ipmt] = -99999;
       adc[ipmt] = 0;
       adcmip[ipmt] = 0;
       
@@ -247,14 +254,14 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
     }
   
   if( besttimeA < 999999 && besttimeA!=0) {
-    frecpoints.SetTimeBestA((besttimeA_best * channelWidth  - fdZonA/c)  - 12500.);
-    frecpoints.SetTime1stA((besttimeA * channelWidth  - fdZonA/c)  - 12500.);
+    frecpoints.SetTimeBestA((besttimeA_best * channelWidth  - fdZonA/c)  );
+    frecpoints.SetTime1stA((besttimeA * channelWidth  - fdZonA/c - shiftA) );
     tr[1]=true;
   }
   
   if( besttimeC < 999999 && besttimeC!=0) {
-    frecpoints.SetTimeBestC((besttimeC_best * channelWidth  - fdZonC/c)  - 12500.);
-    frecpoints.SetTime1stC((besttimeC * channelWidth  - fdZonC/c)  - 12500.);
+    frecpoints.SetTimeBestC((besttimeC_best * channelWidth  - fdZonC/c) );
+    frecpoints.SetTime1stC((besttimeC * channelWidth  - fdZonC/c - shiftC) );
     tr[2]=true;
   }
   
@@ -266,19 +273,19 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
     //    timeDiff = (besttimeC - besttimeA)*channelWidth;
     timeDiff = (besttimeA - besttimeC)*channelWidth;
     meanTime = channelWidth * (besttimeA_best + besttimeC_best)/2. ; 
-    timeclock = channelWidth * (besttimeA + besttimeC)/2. ;
-    vertex = meanVertex - c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2;
+    timeclock = channelWidth * (besttimeA + besttimeC)/2. - shiftAC ;
+    vertex = meanVertex - 0.001* c*(timeDiff)/2.;// + (fdZonA - fdZonC)/2;
     tr[0]=true; 
   }
   frecpoints.SetVertex(vertex);
-  frecpoints.SetMeanTime(meanTime - 12500.);
-  frecpoints.SetT0clock(timeclock - 12500.);
+  frecpoints.SetMeanTime(meanTime );
+  frecpoints.SetT0clock(timeclock );
   frecpoints.SetT0Trig(tr);
   
- AliDebug(5,Form("fRecPoints:::  1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f shiftA %f shiftC %f ",
+ AliDebug(5,Form("fRecPoints:::  1stimeA %f , besttimeA %f 1sttimeC %f besttimeC %f vertex %f",
                  frecpoints.Get1stTimeA(),  frecpoints.GetBestTimeA(),
                  frecpoints.Get1stTimeC(),  frecpoints.GetBestTimeC(), 
-                 fTimeMeanShift[1],fTimeMeanShift[2] ) );
+                 vertex ) );
   
   AliDebug(5,Form("T0 triggers %d %d %d %d %d",tr[0],tr[1],tr[2],tr[3],tr[4]));
   
@@ -306,8 +313,8 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   Float_t meanOrC = fTime0vertex[0] + 678;
   Float_t meanTVDC = fTime0vertex[0] + 2564;
   Int_t timeDelayCFD[24]; 
-  
-
+  Int_t corridor = GetRecoParam() -> GetCorridor();  
+  //  printf("!!!! corridor %i \n",corridor);
   Int_t badpmt[24];
   //Bad channel
   for (Int_t i=0; i<24; i++) {
@@ -315,11 +322,11 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
     timeDelayCFD[i] =  Int_t (fParam->GetTimeDelayCFD(i));
   }
   Int_t equalize = GetRecoParam() -> GetEq();
-  //  printf( "AliT0Reconstructor::Reconstruct::: RecoParam %i \n",equalize);
+  printf( "AliT0Reconstructor::Reconstruct::: RecoParam %i \n",equalize);
   fCalib->SetEq(equalize);
   Int_t low[500], high[500];
-  Float_t timefull=-9999;;
-  Float_t tvdc  = -9999; Float_t ora = -9999; Float_t orc = -9999;
+  Float_t timefull=-99999;;
+  Float_t tvdc  = -99999; Float_t ora = -99999; Float_t orc = -99999;
 
   Int_t allData[110][5];
   
@@ -331,10 +338,12 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   Double32_t vertex = 9999999;
   Int_t onlineMean=0;
   Float_t meanVertex = 0;
+  Int_t pedestal[24];
   for (Int_t i0=0; i0<24; i0++) {
-    low[i0] = Int_t(fTime0vertex[i0]) - 200;
-    high[i0] = Int_t(fTime0vertex[i0]) + 200;
+    low[i0] = Int_t(fTime0vertex[i0]) - corridor;
+    high[i0] = Int_t(fTime0vertex[i0]) + corridor;
     time2zero[i0] = 99999;
+    pedestal[i0]=Int_t (GetRecoParam()->GetLow(100+i0) );
   }
   
   for (Int_t i0=0; i0<110; i0++)
@@ -367,10 +376,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
     {
       timeCFD[i]=0; timeLED[i]=0; chargeQT0[i]=0; chargeQT1[i]=0;
     }
-     Int_t fBCID=Int_t (rawReader->GetBCID());
-      Int_t trmbunch= myrawreader.GetTRMBunchID();
-      AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch ));
+  
       if(type == 7  ) {  //only physics 
        for (Int_t i=0; i<107; i++) {
        for (Int_t iHit=0; iHit<5; iHit++) 
@@ -379,6 +385,13 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          }
        }
        
+       Int_t fBCID=Int_t (rawReader->GetBCID());
+       Int_t trmbunch= myrawreader.GetTRMBunchID();
+       AliDebug(10,Form(" CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch ));
+       if( (trmbunch-fBCID)!=37  ) {
+         AliDebug(0,Form("wrong :::: CDH BC ID %i, TRM BC ID %i \n", fBCID, trmbunch ));
+         //    type = -1;
+       }
        for (Int_t in=0; in<12; in++)  
          {
            for (Int_t iHit=0; iHit<5; iHit++) 
@@ -387,13 +400,13 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
                   allData[in+1][iHit] < high[in])
                  {
                    timeCFD[in] = allData[in+1][iHit] ; 
-                   break;
+                   break;
                  }
              }
            for (Int_t iHit=0; iHit<5; iHit++) 
              {
-               if(allData[in+1+56][iHit] > low[in] && 
-                  allData[in+1+56][iHit] < high[in])
+               if(allData[in+1+56][iHit] > low[in+12] && 
+                  allData[in+1+56][iHit] < high[in+12])
                  {
                    timeCFD[in+12] = allData[in+56+1][iHit] ;
                    break;
@@ -407,30 +420,36 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
            
          }
        
-       
        for (Int_t in=0; in<12;  in++)
          {
-           chargeQT0[in]=allData[2*in+25][0];
-           chargeQT1[in]=allData[2*in+26][0];
-           AliDebug(25, Form(" readed Raw %i %i %i",
-                             in, chargeQT0[in],chargeQT1[in]));
+           if(allData[2*in+26][0] > low[in] + 1000)
+                 {
+                   chargeQT0[in]=allData[2*in+25][0];
+                   chargeQT1[in]=allData[2*in+26][0];
+                   AliDebug(25, Form(" readed Raw %i %i %i",
+                                     in, chargeQT0[in],chargeQT1[in]));
+                 }
          }     
        for (Int_t in=12; in<24;  in++)
          {
-           chargeQT0[in]=allData[2*in+57][0];
-           chargeQT1[in]=allData[2*in+58][0];
-           AliDebug(25, Form(" readed Raw %i %i %i",
-                             in, chargeQT0[in],chargeQT1[in]));
+           if(allData[2*in+58][0] > low[in] + 1000)
+           {
+             chargeQT0[in]=allData[2*in+57][0];
+             chargeQT1[in]=allData[2*in+58][0];
+             AliDebug(25, Form(" readed Raw %i %i %i",
+                               in, chargeQT0[in],chargeQT1[in]));
+           }
          }
        
        onlineMean = allData[49][0];
        
        Double32_t time[24], adc[24], adcmip[24], noncalibtime[24];
        for (Int_t ipmt=0; ipmt<24; ipmt++) {
-         if(timeCFD[ipmt] >  0 /* && badpmt[ipmt]==0*/ ){
+         //      if(timeCFD[ipmt] >  0 && (chargeQT0[ipmt] - chargeQT1[ipmt])>pedestal[ipmt]  ){
+         if(timeCFD[ipmt] >  0 && (chargeQT0[ipmt] - chargeQT1[ipmt])> 0 ){
           //for simulated data
             //for physics  data
-          if(( chargeQT0[ipmt] - chargeQT1[ipmt])>0)  {
+           if(( chargeQT0[ipmt] - chargeQT1[ipmt])>pedestal[ipmt])  {
             adc[ipmt] = chargeQT0[ipmt] - chargeQT1[ipmt];
           }
           else
@@ -449,32 +468,29 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
           TGraph * qtGraph = (TGraph*)fQTC.At(ipmt);
           if (qtGraph) qtMip = qtGraph->Eval(adc[ipmt]);
           AliDebug(10,Form("  Amlitude in MIPS LED %f ; QTC %f;  in channels %f\n ",ampMip,qtMip, adc[ipmt]));
-          if( qtMip>lowAmpThreshold && qtMip<highAmpThreshold )
-            {
-              if( equalize  ==0 ) 
-                frecpoints.SetTime(ipmt, Float_t(time[ipmt]) );
+          if( equalize  ==0 ) 
+            frecpoints.SetTime(ipmt, Float_t(time[ipmt]) );
           else 
             frecpoints.SetTime(ipmt, Float_t(time[ipmt] + fTime0vertex[ipmt]) );
-              // frecpoints.SetTime(ipmt, Float_t(time[ipmt] ) );
-            }
+          // frecpoints.SetTime(ipmt, Float_t(time[ipmt] ) );
           frecpoints.SetAmp(ipmt, Double32_t( qtMip)); 
           adcmip[ipmt]=qtMip;
           frecpoints.SetAmpLED(ipmt, Double32_t(ampMip));           
           noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]);
-        }
-        else {
+         }
+         else {
           time[ipmt] = -9999;
           adc[ipmt] = 0;
           adcmip[ipmt] = 0;
           noncalibtime[ipmt] = -9999;
-        }
+         }
        }
        fESDTZEROfriend->SetT0timeCorr(noncalibtime) ; 
     
        for (Int_t ipmt=0; ipmt<12; ipmt++){
         if(time[ipmt] !=0 &&  time[ipmt] > -9000 
            /*&& badpmt[ipmt]==0 */
-           &&  adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold )
+           &&  adcmip[ipmt]>lowAmpThreshold )
           {
             if(time[ipmt]<besttimeC) besttimeC=time[ipmt]; //timeC
             if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeC_best)) 
@@ -485,7 +501,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
         {
           if(time[ipmt] != 0 &&  time[ipmt] > -9000 
              /* && badpmt[ipmt]==0*/ 
-             && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold)
+             && adcmip[ipmt]>lowAmpThreshold )
             {
               if(time[ipmt]<besttimeA) besttimeA=time[ipmt]; 
               if(TMath::Abs(time[ipmt] ) < TMath::Abs(besttimeA_best)) 
@@ -520,7 +536,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
                       fTimeMeanShift[1],fTimeMeanShift[2] ) );
        if( besttimeC < 999999 &&  besttimeA < 999999) { 
         if(equalize  ==0 )
-          timeclock = ((besttimeC * channelWidth)- 1000.*fLatencyHPTDC +1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0]);
+          timeclock = (channelWidth*(besttimeC + besttimeA)/2.- 1000.*fLatencyHPTDC +1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0]);
         else
           {
             timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - fTimeMeanShift[0];
@@ -793,16 +809,18 @@ Bool_t AliT0Reconstructor::PileupFlag() const
   
 Bool_t AliT0Reconstructor::BackgroundFlag() const
 {
   Bool_t background = false;
-
-  Float_t orA = fESDTZERO->GetOrA(0);
-  Float_t orC = fESDTZERO->GetOrC(0);
-  Float_t tvdc =  fESDTZERO->GetTVDC(0);
-
-  if ( (orA > -5 && orA <5) && (orC > -5 && orC <5) && (tvdc < -5 || tvdc > 5)) {
-    background = true;
-    //   printf(" orA %f orC %f tvdc %f\n", orA, orC, tvdc);
-  } 
+  /*  
+      Float_t orA = fESDTZERO->GetOrA(0);
+      Float_t orC = fESDTZERO->GetOrC(0);
+      Float_t tvdc =  fESDTZERO->GetTVDC(ih);
+      
+      if ( (orA > -5 && orA <5) && (orC > -5 && orC <5) && (tvdc < -5 || tvdc > 5)) {
+      background = true;
+      //   printf(" orA %f orC %f tvdc %f\n", orA, orC, tvdc);
+      } 
+  */ 
   return background;