]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Reconstructor.cxx
coverity fixed
[u/mrichter/AliRoot.git] / T0 / AliT0Reconstructor.cxx
index 47320a763617c18675b6142dee1d283aef944362..27a4ef60341e9a15104d458c81f07af65c8f7448 100644 (file)
@@ -1,5 +1,3 @@
-
-
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -40,6 +38,7 @@
 #include "AliCTPTimeParams.h"
 #include "AliLHCClockPhase.h"
 #include "AliT0CalibSeasonTimeShift.h"
+#include "AliESDRun.h"
 
 #include <TArrayI.h>
 #include <TGraph.h>
@@ -67,6 +66,8 @@ ClassImp(AliT0Reconstructor)
                                              fESDTZEROfriend(NULL)
 
 {
+
+
   //constructor
   AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
   if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
@@ -89,8 +90,7 @@ ClassImp(AliT0Reconstructor)
     AliT0CalibSeasonTimeShift *timeshift = (AliT0CalibSeasonTimeShift*)entry5->GetObject();
     fTimeMeanShift = timeshift->GetT0Means();
     fTimeSigmaShift  = timeshift->GetT0Sigmas();
-     timeshift->Print();
-  }
+   }
   else
     AliWarning("Time Adjust is not found in OCDB !");
 
@@ -125,7 +125,6 @@ ClassImp(AliT0Reconstructor)
 
 //_____________________________________________________________________________
 void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
-  
 {
   // T0 digits reconstruction
   Int_t refAmp = Int_t (GetRecoParam()->GetRefAmp());
@@ -145,6 +144,9 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   
   AliDebug(1,Form("Start DIGITS reconstruction "));
   
+  Float_t lowAmpThreshold =  GetRecoParam()->GetLow(200);  
+  Float_t highAmpThreshold =  GetRecoParam()->GetHigh(200);  
+  Int_t badpmt = GetRecoParam()->GetRefPoint();
 
   TBranch *brDigits=digitsTree->GetBranch("T0");
   AliT0digit *fDigits = new AliT0digit() ;
@@ -175,9 +177,9 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
   clustersTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints);
   
-  Float_t time[24], adc[24];
+  Float_t time[24], adc[24], adcmip[24];
   for (Int_t ipmt=0; ipmt<24; ipmt++) {
-    if(timeCFD->At(ipmt)>0 ){
+    if(timeCFD->At(ipmt)>0 && ipmt != badpmt) {
      if(( chargeQT1->At(ipmt) - chargeQT0->At(ipmt))>0)  
        adc[ipmt] = chargeQT1->At(ipmt) - chargeQT0->At(ipmt);
       else
@@ -197,6 +199,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
       frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
       frecpoints->SetAmpLED(ipmt, Float_t( ampMip)); //for cosmic &pp beam 
       frecpoints->SetAmp(ipmt, Float_t(qtMip));
+      adcmip[ipmt]=qtMip;
       
     }
     else {
@@ -206,7 +209,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
   }
   
   for (Int_t ipmt=0; ipmt<12; ipmt++){
-    if(time[ipmt] > 1 ) {
+    if(time[ipmt] > 1 && ipmt != badpmt && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold) {
       if(time[ipmt]<besttimeC){
        besttimeC=time[ipmt]; //timeC
        pmtBestC=ipmt;
@@ -214,7 +217,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
     }
   }
   for ( Int_t ipmt=12; ipmt<24; ipmt++){
-    if(time[ipmt] > 1) {
+    if(time[ipmt] > 1 &&  ipmt != badpmt && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold) {
       if(time[ipmt]<besttimeA) {
        besttimeA=time[ipmt]; //timeA
         pmtBestA=ipmt;}
@@ -270,10 +273,13 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   // reference amplitude and time ref. point from reco param
 
   Float_t refAmp = GetRecoParam()->GetRefAmp();
-  Int_t refPoint = 0;
+
+  //  Int_t refPoint = 0;
+
   //Bad channel
   Int_t badpmt = GetRecoParam()->GetRefPoint();
-  Int_t low[110], high[110];
+  Int_t low[500], high[500];
 
   Int_t allData[110][5];
   
@@ -291,7 +297,9 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
       high[i0] = Int_t (GetRecoParam()->GetHigh(i0));
       }
   Float_t lowAmpThreshold =  GetRecoParam()->GetLow(200);  
-  Float_t highAmpThreshold =  GetRecoParam()->GetHigh(200);  
+  Float_t highAmpThreshold =  GetRecoParam()->GetHigh(200); 
+  printf(" lowAmpThreshold %f  highAmpThreshold %f \n",lowAmpThreshold, highAmpThreshold);
+  
   Double32_t besttimeA=9999999;
   Double32_t besttimeC=9999999;
   Int_t pmtBestA=99999;
@@ -326,8 +334,10 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          }
        }
        Int_t ref=0;
-       if (refPoint>0) 
-         ref = allData[refPoint][0]-5000;
+
+       //      if (refPoint>0) 
+       //  ref = allData[refPoint][0]-5000;
+
        
        Float_t channelWidth = fParam->GetChannelWidth() ;  
        
@@ -404,9 +414,9 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
                break;
              }
          }
-       Double32_t time[24], adc[24],  noncalibtime[24];
+       Double32_t time[24], adc[24], adcmip[24], noncalibtime[24];
        for (Int_t ipmt=0; ipmt<24; ipmt++) {
-         if(timeCFD[ipmt]>0 ){
+         if(timeCFD[ipmt]>0 && ipmt != badpmt ){
           //for simulated data
             //for physics  data
           if(( chargeQT0[ipmt] - chargeQT1[ipmt])>0)  {
@@ -426,7 +436,8 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
           //bad peak removing
             frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
             // frecpoints->SetTime(ipmt,Double32_t(timeCFD[ipmt]));
-            frecpoints->SetAmp(ipmt, Double32_t( qtMip)); //for cosmic &pp beam 
+            frecpoints->SetAmp(ipmt, Double32_t( qtMip)); 
+            adcmip[ipmt]=qtMip;
             frecpoints->SetAmpLED(ipmt, Double32_t(ampMip));        
             noncalibtime[ipmt]= Double32_t (timeCFD[ipmt]);
         }
@@ -438,7 +449,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        }
        fESDTZEROfriend->SetT0timeCorr(noncalibtime) ;     
        for (Int_t ipmt=0; ipmt<12; ipmt++){
-        if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>lowAmpThreshold  && adc[ipmt]<highAmpThreshold)
+        if(time[ipmt] > 1 && ipmt != badpmt &&  adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold )
           {
             if(time[ipmt]<besttimeC){
                  besttimeC=time[ipmt]; //timeC
@@ -448,7 +459,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        }
        for ( Int_t ipmt=12; ipmt<24; ipmt++)
         {
-          if(time[ipmt] > 1 && ipmt != badpmt && adc[ipmt]>lowAmpThreshold && adc[ipmt]<highAmpThreshold)
+          if(time[ipmt] > 1 && ipmt != badpmt && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold)
             {
               if(time[ipmt]<besttimeA) {
                 besttimeA=time[ipmt]; //timeA
@@ -490,7 +501,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          }
       }
       frecpoints->SetT0Trig(tr);
-
+   
       //Set MPD
       if(allData[53][0]>0 && allData[54][0]) 
        frecpoints->SetMultA(allData[53][0]-allData[54][0]);
@@ -514,6 +525,9 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   ****************************************************/
   
   AliDebug(1,Form("Start FillESD T0"));
+  pESD ->SetT0spread(fTimeSigmaShift);
+
   Float_t channelWidth = fParam->GetChannelWidth() ;  
   Float_t c = 0.0299792458; // cm/ps
   Float_t currentVertex=0, shift=0;