new reconstruction with pass0 calibration
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Apr 2011 11:01:36 +0000 (11:01 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Apr 2011 11:01:36 +0000 (11:01 +0000)
T0/AliT0CalibOffsetChannelsTask.cxx
T0/AliT0CalibSeasonTimeShift.cxx
T0/AliT0CalibTimeEq.cxx
T0/AliT0CalibTimeEq.h
T0/AliT0CalibWalk.cxx
T0/AliT0Calibrator.cxx
T0/AliT0PreprocessorOffline.cxx
T0/AliT0RecoParam.h
T0/AliT0Reconstructor.cxx
T0/T0Physda.cxx

index 981158e..67977fb 100644 (file)
@@ -73,10 +73,9 @@ AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask()
   delete fTzeroORC;\r
   delete fResolution;\r
   delete fTzeroORAplusORC;\r
-  for (Int_t i=0; i<24; i++) {\r
-    delete  fTimeDiff[i];\r
-    delete  fCFD[i];\r
-  }\r
+  delete [] fTimeDiff;\r
+  delete [] fCFD;\r
+\r
   delete fTzeroObject;\r
 }\r
 \r
@@ -107,7 +106,8 @@ void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()
   // Create histograms\r
   for (Int_t i=0; i<24; i++) {\r
     fTimeDiff[i]   = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",300, -300, 300);\r
-    fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",500, 2000, 3000);//6000, 7000);\r
+    //   fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",500, 2000, 3000);//6000, 7000);\r
+    fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",500, -1000, 1000);//6000, 7000);\r
   }\r
 \r
   fTzeroORAplusORC = new TH1F("fTzeroORAplusORC","ORA+ORC /2",400,-2000,2000);   //or A plus or C \r
@@ -151,23 +151,24 @@ void AliT0CalibOffsetChannelsTask::UserExec(Option_t *)
 \r
   const Double32_t* time = fESD->GetT0time();\r
   for (Int_t i=0; i<12; i++) {\r
-    if( time[i]>1 ){\r
-      fCFD[i]->Fill( time[i]);\r
-      if(  time[0]>1 ) \r
+     if( time[i] != 0 ){\r
+     printf(" %i time %f \n", i, time[i] );\r
+    fCFD[i]->Fill( time[i]);\r
+      if(  time[0] != 0 ) \r
        fTimeDiff[i]->Fill( time[i]-time[0]);\r
     }\r
   }\r
   for (Int_t i=12; i<24; i++) {\r
-    if( time[i]>1) {\r
+    if( time[i] != 0) {\r
       fCFD[i]->Fill( time[i]);\r
-      if( time[12]>1 ) \r
+      if( time[12] != 0 ) \r
        fTimeDiff[i]->Fill( time[i]-time[12]);\r
     }\r
   }\r
   const Double32_t* mean = fESD->GetT0TOF();\r
-  Double32_t meanTOF = mean[0] + 100000. ;\r
-  Double32_t orA = mean[1] + 100000.;\r
-  Double32_t orC = mean[2] + 100000.;\r
+  Double32_t meanTOF = mean[0] ;\r
+  Double32_t orA = mean[1] ;\r
+  Double32_t orC = mean[2];\r
  \r
   if(orA<9999) fTzeroORA->Fill(orA);\r
   if(orC<9999) fTzeroORC->Fill(orC);\r
index 7c688c3..828c4da 100644 (file)
@@ -118,8 +118,15 @@ Bool_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys)
     {
       gFile->ls();
     TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
-    // dr->Dump();
+      if (!dr) {
+      AliWarning(Form("no Tzero Directory in file collected "));
+      return ok;
+    }
     TObjArray * TzeroObj = (TObjArray*) dr->Get("fTzeroObject");
+    if(!TzeroObj) { 
+      AliWarning(Form("no Tzero Object in file collected "));
+      return ok;
+    }
     TString histname[4]={"fTzeroORAplusORC", "fTzeroORA", "fTzeroORC",  "fResolution"};
     for (Int_t i=0; i<4; i++)
        {
@@ -127,12 +134,14 @@ Bool_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys)
          gFile->Get(histname[i].Data());
          if(!cfd) AliWarning(Form("no histograms collected for %s", histname[i].Data()));
          if(cfd) {
+           //      printf(" T0s: %i %s mean %f  rms %f  \n", i, histname[i].Data(),cfd->GetMean , cfd ->GetRMS() ); 
            GetMeanAndSigma(cfd, mean, sigma);
            if (sigma == 0 || sigma > 500) ok = false;
            else
              { 
-               fMeanPar[i] = mean;
+               fMeanPar[i] =  mean;
                fSigmaPar[i] = sigma;
+               printf(" T0s: %i %s %f %f  \n", i, histname[i].Data(), fMeanPar[i],fSigmaPar[i] ); 
                ok=true;
              }
          }
index 7aabf7d..30bd757 100644 (file)
@@ -127,22 +127,18 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
          TH1F *cfd = (TH1F*) gFile->Get(Form("CFD1minCFD%d",i+1));
          TH1F *cfdtime = (TH1F*) gFile->Get(Form("CFD%d",i+1));
          if(!cfd) AliWarning(Form("no Diff histograms collected by PHYS DA for channel %i", i));
+         if(!cfdtime) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i));
          if(cfd) {
            nent = Int_t(cfd->GetEntries());
-           if(nent>500 )  {
-             if(cfd->GetRMS()>1.5 &&  cfd->GetRMS()<20)
+           if(nent>500)  { 
+             if(cfd->GetRMS()>1.5 )
                GetMeanAndSigma(cfd, meandiff, sigmadiff);
              if(cfd->GetRMS()<=1.5) 
                {
                  meandiff = cfd->GetMean();
                  sigmadiff=cfd->GetRMS();
                }
-             
-             if(cfd->GetRMS()>20) 
-               {
-                 ok=false;
-                 AliWarning(Form("Data is not good  in PMT %i - mean %f rsm %f nentries %i", i,meandiff,sigmadiff , nent));
-               }
+             if(TMath::Abs(cfd->GetMean() - meandiff) >10 ) meandiff = cfd->GetMean(); 
            }
            else 
              {
@@ -151,10 +147,10 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
              }
            if(!cfd) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i));
          }
-           //      printf(" i = %d buf1 = %s\n", i, buf1);
+         //      printf(" i = %d buf1 = %s\n", i, buf1);
          if(cfdtime) {
            nent = Int_t(cfdtime->GetEntries());
-           if(nent>500 )  {
+           if(nent > 500 )  { //!!!!!!!!!!
              if(cfdtime->GetRMS()>1.5 )
                GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime);
              if(cfdtime->GetRMS()<=1.5) 
@@ -162,11 +158,7 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
                  meancfdtime = cfdtime->GetMean();
                  sigmacfdtime = cfdtime->GetRMS();
                }
-             if(sigmacfdtime>50 ) 
-               {
-                 ok=false;
-                 AliWarning(Form("Data is not good enouph in PMT %i  - meancfdtime %f rsm %f nentries %i", i,meancfdtime, sigmacfdtime, nent));
-               }
+             if(TMath::Abs(cfdtime->GetMean() - meancfdtime) >20 ) meancfdtime = cfdtime->GetMean(); 
            }
          }
          else 
@@ -174,11 +166,10 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
              ok=false;
              AliWarning(Form(" Not  enouph data in PMT in CFD peak %i - %i ", i, nent));
            }
-         //      printf(" %i %f %f %f %f \n",i, meandiff, sigmadiff, meancfdtime, sigmacfdtime);
+         printf(" %i %f %f %f %f \n",i, meandiff, sigmadiff, meancfdtime, sigmacfdtime);
          SetTimeEq(i,meandiff);
          SetTimeEqRms(i,sigmadiff);
          SetCFDvalue(i,0,meancfdtime);
-         SetCFDvalue(i,0,sigmacfdtime);
          if (cfd) delete cfd;
          if (cfdtime) delete cfdtime;
 
@@ -200,7 +191,7 @@ Bool_t AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
 }
 
 //________________________________________________________________
-Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *timecdb, Int_t badpmt)
+Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *timecdb, Float_t *cfdvalue, Int_t badpmt)
 {
   // compute online equalized time
   Float_t meandiff, sigmadiff, meanver, meancfdtime, sigmacfdtime;
@@ -211,38 +202,39 @@ Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *tim
   gFile = TFile::Open(filePhys);
   if(!gFile) {
     AliError("No input PHYS data found ");
+    return ok;
   }
   else
     {
+
       meandiff = sigmadiff =  meanver = meancfdtime = sigmacfdtime =0;
       ok=true;
-    TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
-    TObjArray * TzeroObj = (TObjArray*) dr->Get("fTzeroObject");
-       for (Int_t i=0; i<24; i++)
+      TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
+      if (!dr ) { AliError("No input T0calib found "); 
+       return ok;
+      }
+      TObjArray * TzeroObj = (TObjArray*) dr->Get("fTzeroObject");
+      for (Int_t i=0; i<24; i++)
        {
+         printf("@@@ were in OCDB before %f \n", timecdb[i]);
          if (i != badpmt) {
          TH1F *cfddiff = (TH1F*)TzeroObj->At(i);
          TH1F *cfdtime = (TH1F*)TzeroObj->At(i+24);
          if(!cfddiff) AliWarning(Form("no Diff histograms collected by PHYS DA for channel %i", i));
          //      printf(" i = %d buf1 = %s\n", i, buf1);
+         if(!cfdtime) AliWarning(Form("no CFD histograms collected by PHYS DA for channel %i", i));
          if(cfddiff) {
            nent = Int_t(cfddiff->GetEntries());
-           if(nent>10 )  {
-             if(cfddiff->GetRMS()>1.5 &&  cfddiff->GetRMS()<30)
+           if(nent>500 )  { //!!!!!
+             if(cfddiff->GetRMS()>1.5 )
                GetMeanAndSigma(cfddiff, meandiff, sigmadiff);
              if(cfddiff->GetRMS()<=1.5) 
                {
                  meandiff = cfddiff->GetMean();
                  sigmadiff = cfddiff->GetRMS();
                }
-             //   printf(" ipmt %i meandiff %f sigmadiff %f mean %f rms %f\n", i, meandiff,sigmadiff,cfddiff->GetMean(),  cfddiff->GetRMS() );
+             if(TMath::Abs(cfddiff->GetMean() - meandiff) >10 ) meandiff = cfddiff->GetMean(); 
              
-             if(sigmadiff > 30) 
-               {
-                 ok=false;
-                 AliWarning(Form("Data is not good  in PMT %i - mean %f rsm %f nentries %i", i,meandiff,sigmadiff , nent));
-               }
-
            }
            else 
              {
@@ -252,7 +244,7 @@ Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *tim
          }         
          if(cfdtime) {
            nent = Int_t(cfdtime->GetEntries());
-           if(nent>10 )  {
+           if(nent>500 )  { //!!!!!
              if(cfdtime->GetRMS()>1.5 )
                GetMeanAndSigma(cfdtime,meancfdtime, sigmacfdtime);
              if(cfdtime->GetRMS()<=1.5) 
@@ -260,11 +252,7 @@ Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *tim
                  meancfdtime = cfdtime->GetMean();
                  sigmacfdtime=cfdtime->GetRMS();
                }
-             if(sigmacfdtime>50) 
-               {
-                 ok=false;
-                 AliWarning(Form("Data is not good enouph in PMT %i  - meancfdtime %f rsm %f nentries %i", i,meancfdtime, sigmacfdtime, nent));
-               }
+             if(TMath::Abs(cfdtime->GetMean() - meancfdtime) >20 ) meancfdtime = cfdtime->GetMean(); 
            }
            else 
              {
@@ -274,8 +262,8 @@ Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *tim
          }
          SetTimeEq(i,timecdb[i] + meandiff);
          SetTimeEqRms(i,sigmadiff);
-         SetCFDvalue(i,0,meancfdtime);
-         SetCFDvalue(i,0,sigmacfdtime);
+         SetCFDvalue(i,0,cfdvalue[i] + meancfdtime );
+         //SetCFDvalue(i,0,cfdvalue[i] );
          if (cfddiff) delete cfddiff;
          if (cfdtime) delete cfdtime;
          } //bad pmt
@@ -298,9 +286,9 @@ Bool_t AliT0CalibTimeEq::ComputeOfflineParams(const char* filePhys, Float_t *tim
 
 //________________________________________________________________________
 void AliT0CalibTimeEq::GetMeanAndSigma(TH1F* hist,  Float_t &mean, Float_t &sigma) {
-
-  const double window = 5.;  //fit window 
+  
+  const double window = 2.;  //fit window 
+  
   double meanEstimate, sigmaEstimate; 
   int maxBin;
   maxBin        =  hist->GetMaximumBin(); //position of maximum
index 9e1542d..6adbf41 100644 (file)
@@ -24,7 +24,7 @@ class AliT0CalibTimeEq: public TNamed {
   virtual void  Print(Option_t* option= "") const; 
   
   Bool_t ComputeOnlineParams(const char* filePhys);
-  Bool_t ComputeOfflineParams(const char* filePhys, Float_t *timecdb, Int_t badpmt);
+  Bool_t ComputeOfflineParams(const char* filePhys, Float_t *timecdb,Float_t *cfdcdb, Int_t badpmt);
   Float_t  GetCFDvalue(Int_t channel,Int_t number)  const {return fCFDvalue[channel][number];}
   Float_t* GetCFDvalue()          const {return (float*)fCFDvalue;}
   Float_t  GetTimeEq(Int_t channel)        const {return fTimeEq[channel];}
index fb1b3d7..8cc973f 100644 (file)
@@ -128,15 +128,15 @@ Bool_t AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
       Float_t x2[50], xx2[50],y2[50];
       Float_t xx1[50],yy1[50], xx[50];
       
-      Float_t cfd0[24];
-      Int_t startim = 0;
+      Float_t cfd0 = 0;
       
       for (Int_t ii=0; ii<nmips; ii++)
        x1[ii] = y1[ii] = x2[ii] = y2[ii] = 0; 
       
       for (Int_t i=0; i<24; i++)
        {
-         for (Int_t im=startim; im<nmips; im++)
+         cfd0 = 0;
+         for (Int_t im=0; im<nmips; im++)
            {         
              TString cfd = Form("hCFD%i_%i",i+1,im+1);
              TString qtc = Form("hQTC%i_%i",i+1,im+1);
@@ -166,8 +166,9 @@ Bool_t AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
                else
                  cfdmean = hCFD->GetMean();
                
-               if (im == 0) cfd0[i] = cfdmean;
-               y1[im] =  cfdmean - cfd0[i];
+             if(TMath::Abs(hCFD->GetMean() - cfdmean) >10 ) cfdmean = hCFD->GetMean(); 
+               if (im == 0) cfd0 = cfdmean;
+               y1[im] =  cfdmean - cfd0;
              } 
              if(hQTC && hQTC->GetEntries()>500) {
                GetMeanAndSigma(hQTC, qtmean, sigma);
index 8a8cbef..86bdd7c 100644 (file)
@@ -106,15 +106,17 @@ Int_t  AliT0Calibrator::WalkCorrection(Int_t refAmp,  Int_t ipmt, Int_t qt, Int_
   Int_t timeEq=0, timeWalk=0;  
   TGraph *fu1=(TGraph*) fWalk.At(ipmt);
   if(fu1 && fu1->GetN()>0) {
-    grY = fu1->GetY();
-    fMaxValue[ipmt]=grY[refAmp-1];
+     grY = fu1->GetY();
+     //   fMaxValue[ipmt]=grY[refAmp-1];
     // TGraph* fu  = param ->GetAmpLEDRec(i);
     // walk = Int_t (fMaxValue[ipmt]) + Int_t(fu1->Eval(Double_t(qt)));
     walk = Int_t(fu1->Eval(Double_t(qt)));
   }
   
   timeWalk = time - walk   ;
-  timeEq= timeWalk - fTimeDelayCFD[ipmt];
+  timeEq =timeWalk - refAmp ; //- fTimeDelayCFD[ipmt]; //in refAmp - mean CFD position
+ //  timeEq= timeWalk - fTimeDelayCFD[ipmt];
   //   printf(" ipmt %i time before %i timeWalk %i , walk %i  qt %i fTimeDelayCFD[ipmt] %i timeEq %i \n ",
   //    ipmt, time,timeWalk, walk, qt,fTimeDelayCFD[ipmt], timeEq );
      AliDebug(10,Form(" ipmt %i time before %i timeWalk %i , walk %i  qt %i timeEq %i \n ",
index 907a8e2..b88345c 100644 (file)
 #include "AliCDBStorage.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBManager.h"
+#include "AliCTPTimeParams.h"
+#include "AliLHCClockPhase.h"
 #include "AliT0CalibSeasonTimeShift.h"
-
+#include "AliT0CalibLatency.h"
 #include "AliCDBEntry.h"
 #include "AliLog.h"
 
@@ -71,8 +73,8 @@ void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, In
 void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
 {
 
-  Float_t *timecdb = 0x0;
-  for (Int_t i=0; i<24; i++)  timecdb[i]=999;
+  Float_t *timecdb, *cfdvalue;
+  for (Int_t i=0; i<24; i++) {  timecdb[i]=999; cfdvalue=0; }
   Int_t badpmt=0;
   //Processing data from DAQ Physics run
   AliInfo("Processing Time Offset between channels");
@@ -80,21 +82,44 @@ void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t u
   if (filePhysName)
     {
    if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
-  else
-  ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+   else
+     ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
    //      AliCDBManager* man = AliCDBManager::Instance();
-      // man->SetDefaultStorage("raw://");
+   // man->SetDefaultStorage("raw://");
    //   man->SetDefaultStorage("ocdbStorage");
    //     man->SetRun(ustartRun);
-      AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
-      if(!entryCalib) {
-       AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
-      }
-      else
-       {
-         AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
-         timecdb = clb->GetTimeEq();
-       }
+   AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
+   if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
+   AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
+   Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
+   
+   AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
+   if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !");
+   AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject();
+   l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0);
+   
+   AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
+   if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !");
+   AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject();
+   Float_t fGRPdelays = l1Delay - phase->GetMeanPhase();
+   AliCDBEntry *entryL = AliCDBManager::Instance()->Get("T0/Calib/Latency");
+   AliT0CalibLatency *lat = (AliT0CalibLatency*)entryL->GetObject();
+   Float_t fLatencyHPTDC = lat->GetLatencyHPTDC();
+   Float_t fLatencyL1 = lat->GetLatencyL1();
+   AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
+   if(!entryCalib) {
+     AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
+   }
+   else
+     {
+       AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
+       timecdb = clb->GetTimeEq();
+       cfdvalue = clb->GetCFDvalue();
+       for (Int_t i=0; i<24; i++) {
+        if( cfdvalue[i] < 500 ) cfdvalue[i] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
+        printf("Calc  mean CFD time %i %f \n",i,cfdvalue[i]);
+       }
+     }
       AliCDBEntry *entryCalibreco = AliCDBManager::Instance()->Get("T0/Calib/RecoParam");
       if(entryCalibreco) {
        AliT0RecoParam *rpr = (AliT0RecoParam*) entryCalibreco->GetObject();
@@ -103,7 +128,7 @@ void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t u
       }
       AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
       offline->Reset();
-      Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, badpmt);
+      Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, cfdvalue, badpmt);
       AliCDBMetaData metaData;
       metaData.SetBeamPeriod(1);
       metaData.SetResponsible("Alla Maevskaya");
@@ -128,7 +153,7 @@ void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t u
 //-------------------------------------------------------------------------------------
 void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
 {
- if (filePhysName)
+  if (filePhysName)
     {
       if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
       else
index d42c89c..4c6f241 100644 (file)
@@ -19,26 +19,26 @@ class AliT0RecoParam : public AliDetectorRecoParam
   AliT0RecoParam(const AliT0RecoParam &p); //copy constructor
   AliT0RecoParam& operator=(const AliT0RecoParam &p);
   virtual ~AliT0RecoParam();
-   
- static   AliT0RecoParam *GetLowFluxParam();        // make reco parameters for low  flux env
+  
+  static   AliT0RecoParam *GetLowFluxParam();        // make reco parameters for low  flux env
   static   AliT0RecoParam *GetHighFluxParam();       // make reco parameters for high flux env 
   static   AliT0RecoParam *GetLaserTestParam();  // special setting for laser SetLaserTestParam 
   //for monitoring
   //  static   AliT0RecoParam *GetHistRange();  //  limit of monitoring histograms
-
+  
+  //old staff  
   Float_t GetRefAmp()  const  {return fRefAmp;}
   void    SetRefAmp(Float_t amp)   { fRefAmp = amp;}
   Int_t   GetRefPoint() const {return fRefPoint;}
   void    SetRefPoint(Int_t ref) {fRefPoint = ref;}
-
+  
   Float_t   GetLow(Int_t numhist) const {return fLow[numhist];}
   //  Float_t   GetLow() {return *fLow;}
   void      SetLow(Int_t numhist, Float_t low) {fLow[numhist] = low;}
-
+  
   Float_t   GetHigh(Int_t numhist) const  {return fHigh[numhist];}
   //  Float_t   GetHigh()  {return *fHigh;}
   void      SetHigh(Int_t numhist, Float_t high) {fHigh[numhist] = high;}
-  
   Float_t   GetLatencyL1() const {return fLatencyL1;}
   void      SetLatencyL1(Float_t lat) {fLatencyL1 = lat;}
   Float_t   GetLatencyL1A() const {return fLatencyL1A;}
@@ -49,7 +49,14 @@ class AliT0RecoParam : public AliDetectorRecoParam
   void      SetLatencyHPTDC(Float_t lat) {fLatencyHPTDC = lat;}
   Float_t   GetVertexShift() const {return fVertexShift;}
   void      SetVertexShift(Float_t sh) {fVertexShift = sh;}
-
+  
+  //new staff
+  Int_t  GetBadChannels(Int_t i) const {return fBadChannels[i];}
+  void SetBadChannels(Int_t i, Int_t value) {fBadChannels[i] = value;}
+  Float_t GetAmpLowThreshold() const {return fLow[200];}
+  Float_t GetAmpHighThreshold() const {return fHigh[200];}
+  
+  
   void PrintParameters() const;
   
  protected:
@@ -62,8 +69,9 @@ class AliT0RecoParam : public AliDetectorRecoParam
   Float_t   fLatencyL1C;         //Latency L1 for orC
   Float_t   fLatencyHPTDC;      //Latency HPTDC
   Float_t   fVertexShift;       // for slewing correcton
-
-  ClassDef(AliT0RecoParam, 4);
+  Int_t  fBadChannels[24];   // bad channels map
+  
+  ClassDef(AliT0RecoParam, 5);
  
 };
 #endif
index 27a4ef6..337f0ee 100644 (file)
@@ -66,7 +66,7 @@ ClassImp(AliT0Reconstructor)
                                              fESDTZEROfriend(NULL)
 
 {
-
+  for (Int_t i=0; i<24; i++)  fTime0vertex[i] =0;
 
   //constructor
   AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
@@ -93,7 +93,7 @@ ClassImp(AliT0Reconstructor)
    }
   else
     AliWarning("Time Adjust is not found in OCDB !");
-
   fParam = AliT0Parameters::Instance();
   fParam->Init();
  
@@ -104,13 +104,19 @@ ClassImp(AliT0Reconstructor)
          if (gr1) fAmpLED.AddAtAndExpand(gr1,i) ; 
          TGraph* gr2 = fParam ->GetQTC(i);
          if (gr2) fQTC.AddAtAndExpand(gr2,i) ;         
-  }
-
+         fTime0vertex[i] = fParam->GetCFD(i);
+         printf("OCDB mean CFD time %i %f \n",i, fTime0vertex[i]);
+ }
   fLatencyL1 = fParam->GetLatencyL1();
-  fLatencyL1A = fParam->GetLatencyL1A();
+  fLatencyL1A = fParam->GetLatencyL1A(); 
   fLatencyL1C = fParam->GetLatencyL1C();
   fLatencyHPTDC = fParam->GetLatencyHPTDC();
   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] =( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
+  }
   
   // fdZonC = TMath::Abs(fParam->GetZPositionShift("T0/C/PMT1"));
   //fdZonA = TMath::Abs(fParam->GetZPositionShift("T0/A/PMT15"));
@@ -197,7 +203,7 @@ void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
       AliDebug(5,Form("  Amlitude in MIPS LED %f ,  QTC %f in channels %f\n ",ampMip,qtMip, adc[ipmt]));
       
       frecpoints->SetTime(ipmt, Float_t(time[ipmt]) );
-      frecpoints->SetAmpLED(ipmt, Float_t( ampMip)); //for cosmic &pp beam 
+      frecpoints->SetAmpLED(ipmt, Float_t( ampMip)); 
       frecpoints->SetAmp(ipmt, Float_t(qtMip));
       adcmip[ipmt]=qtMip;
       
@@ -272,33 +278,40 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   //
   // reference amplitude and time ref. point from reco param
 
-  Float_t refAmp = GetRecoParam()->GetRefAmp();
+  // Float_t refAmp = GetRecoParam()->GetRefAmp();
 
   //  Int_t refPoint = 0;
-
+  Int_t badpmt[24];
   //Bad channel
-  Int_t badpmt = GetRecoParam()->GetRefPoint();
+  for (Int_t i=0; i<24; i++) 
+  badpmt[i] = GetRecoParam() -> GetBadChannels(i);
  
   Int_t low[500], high[500];
 
   Int_t allData[110][5];
   
   Int_t timeCFD[24], timeLED[24], chargeQT0[24], chargeQT1[24];
-  Double32_t timeDiff=999999, meanTime=999999, timeclock=9999999;
+  Double32_t timeDiff, meanTime, timeclock;
+  timeDiff =  meanTime = timeclock = 9999999;
   Float_t c = 29.9792458; // cm/ns
   Double32_t vertex = 9999999;
   Int_t onlineMean=0;
   // Float_t meanVertex = fParam->GetMeanVertex();
   Float_t meanVertex = 0;
+  for (Int_t i0=0; i0<24; i0++) {
+    low[i0] = Int_t(fTime0vertex[i0]) - 200;
+    high[i0] = Int_t(fTime0vertex[i0]) + 200;
+  }
+  
   for (Int_t i0=0; i0<110; i0++)
     {
       for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; 
-      low[i0] = Int_t (GetRecoParam()->GetLow(i0));    
-      high[i0] = Int_t (GetRecoParam()->GetHigh(i0));
+      //    low[i0] = Int_t (GetRecoParam()->GetLow(i0));      
+      // high[i0] = Int_t (GetRecoParam()->GetHigh(i0));
       }
-  Float_t lowAmpThreshold =  GetRecoParam()->GetLow(200);  
-  Float_t highAmpThreshold =  GetRecoParam()->GetHigh(200); 
-  printf(" lowAmpThreshold %f  highAmpThreshold %f \n",lowAmpThreshold, highAmpThreshold);
+  
+  Float_t lowAmpThreshold =  GetRecoParam()->GetAmpLowThreshold();  
+  Float_t highAmpThreshold =  GetRecoParam()->GetAmpHighThreshold(); 
   
   Double32_t besttimeA=9999999;
   Double32_t besttimeC=9999999;
@@ -347,8 +360,8 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          {
            for (Int_t iHit=0; iHit<5; iHit++) 
              {
-               if(allData[in+1][iHit] > low[in+1] && 
-                  allData[in+1][iHit] < high[in+1])
+               if(allData[in+1][iHit] > low[in] && 
+                  allData[in+1][iHit] < high[in])
                  {
                    timeCFD[in] = allData[in+1][iHit] ; 
                    break;
@@ -356,36 +369,18 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
              }
            for (Int_t iHit=0; iHit<5; iHit++) 
              {
-               if(allData[in+12+1][iHit] > low[in+12+1] && 
-                  allData[in+1+12][iHit] < high[in+12+1])
-                 {
-                       timeLED[in] = allData[in+12+1][iHit] ;
-                       break;
-                 }
-             }
-           for (Int_t iHit=0; iHit<5; iHit++) 
-             {
-               if(allData[in+1+56][iHit] > low[in+1+56] && 
-                  allData[in+1+56][iHit] < high[in+1+56])
+               if(allData[in+1+56][iHit] > low[in] && 
+                  allData[in+1+56][iHit] < high[in])
                  {
                    timeCFD[in+12] = allData[in+56+1][iHit] ;
                    break;
                  }
              }
-           
-           for (Int_t iHit=0; iHit<5; iHit++) 
-             {
-               if(allData[in+1+68][iHit] > low[in+1+68] && 
-                  allData[in+1+68][iHit] < high[in+1+68])
-                 {
-
-                   timeLED[in+12] = allData[in+68+1][iHit] ;
-                   break;
-                 }
-             }
+           timeLED[in+12] = allData[in+68+1][0] ;
+           timeLED[in] = allData[in+12+1][0] ;
            AliDebug(5, Form(" readed i %i cfdC %i cfdA %i ledC %i ledA%i ",
                              in, timeCFD[in],timeCFD[in+12],timeLED[in], 
-                             timeLED[in+12]));   
+                            timeLED[in+12]));   
            
          }
        
@@ -394,14 +389,14 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          {
            chargeQT0[in]=allData[2*in+25][0];
            chargeQT1[in]=allData[2*in+26][0];
-           AliDebug(10, Form(" readed Raw %i %i %i",
+           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(10, Form(" readed Raw %i %i %i",
+           AliDebug(25, Form(" readed Raw %i %i %i",
                              in, chargeQT0[in],chargeQT1[in]));
            
          }
@@ -416,7 +411,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
          }
        Double32_t time[24], adc[24], adcmip[24], noncalibtime[24];
        for (Int_t ipmt=0; ipmt<24; ipmt++) {
-         if(timeCFD[ipmt]>0 && ipmt != badpmt ){
+         if(timeCFD[ipmt] >  0  && badpmt[ipmt]==0 ){
           //for simulated data
             //for physics  data
           if(( chargeQT0[ipmt] - chargeQT1[ipmt])>0)  {
@@ -424,8 +419,9 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
           }
           else
             adc[ipmt] = 0;
-          time[ipmt] = fCalib-> WalkCorrection(Int_t (refAmp), ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ;
+          //      time[ipmt] = fCalib-> WalkCorrection(refAmp, ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ;
           
+          time[ipmt] = fCalib-> WalkCorrection(Int_t (fTime0vertex[ipmt]), ipmt, Int_t(adc[ipmt]), timeCFD[ipmt] ) ;
           Double_t sl = timeLED[ipmt] - timeCFD[ipmt];
           // time[ipmt] = fCalib-> WalkCorrection( refAmp,ipmt, Int_t(sl), timeCFD[ipmt] ) ;
           AliDebug(5,Form(" ipmt %i QTC %i , time in chann %i (led-cfd) %i ",
@@ -449,37 +445,40 @@ 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 &&  adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold )
+        if(time[ipmt] !=0 && badpmt[ipmt]==0 &&  adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold )
           {
-            if(time[ipmt]<besttimeC){
-                 besttimeC=time[ipmt]; //timeC
+            if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeC)){
+              besttimeC=time[ipmt]; //timeC
                  pmtBestC=ipmt;
             }
           }
        }
        for ( Int_t ipmt=12; ipmt<24; ipmt++)
         {
-          if(time[ipmt] > 1 && ipmt != badpmt && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold)
+          if(time[ipmt] != 0  && badpmt[ipmt]==0 && adcmip[ipmt]>lowAmpThreshold && adcmip[ipmt]<highAmpThreshold)
             {
-              if(time[ipmt]<besttimeA) {
+              if(TMath::Abs(time[ipmt])<TMath::Abs(besttimeA)) {
                 besttimeA=time[ipmt]; //timeA
                 pmtBestA=ipmt;
               }
             }
         }
        if(besttimeA < 999999) 
-        frecpoints->SetTimeBestA(besttimeA * channelWidth - 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays - fTimeMeanShift[1]);
+        //      frecpoints->SetTimeBestA((besttimeA * channelWidth)- 1000.*fLatencyHPTDC + 1000.*fLatencyL1A - 1000.*fGRPdelays - fTimeMeanShift[1] ); 
+        frecpoints->SetTimeBestA((besttimeA * channelWidth- fTimeMeanShift[1])); 
 
        if( besttimeC < 999999 ) 
-        frecpoints->SetTimeBestC(besttimeC * channelWidth - 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays - fTimeMeanShift[2]);
+        //      frecpoints->SetTimeBestC((besttimeC * channelWidth)- 1000.*fLatencyHPTDC +1000.*fLatencyL1C - 1000.*fGRPdelays - fTimeMeanShift[2]);
+        frecpoints->SetTimeBestC((besttimeC * channelWidth - fTimeMeanShift[2]));
        AliDebug(5,Form(" pmtA %i besttimeA %f shift A %f ps, pmtC %i besttimeC %f shiftC %f ps",
                       pmtBestA,besttimeA, fTimeMeanShift[1],
-
                       pmtBestC,  besttimeC,fTimeMeanShift[2]));
         if(besttimeA <999999 && besttimeC < 999999 ){
-        timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth + fLatencyL1A - fLatencyL1C;
-        timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - 1000.*fLatencyHPTDC + 1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0];  
+         //     timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth + fLatencyL1A - fLatencyL1C;
+         // timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - 1000.*fLatencyHPTDC + 1000.*fLatencyL1 - 1000.*fGRPdelays - fTimeMeanShift[0] ;  
         meanTime = (besttimeA+besttimeC-2.*Float_t(ref))/2.;
+        timeDiff = ( besttimeA - besttimeC)* 0.001* channelWidth ;
+        timeclock = channelWidth * Float_t( besttimeA+besttimeC)/2. - fTimeMeanShift[0] ;  
         vertex =  meanVertex - c*(timeDiff)/2. ; //+ (fdZonA - fdZonC)/2; 
        }
       }  //if phys event       
@@ -578,12 +577,14 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   timeClock[0] = frecpoints -> GetT0clock() ;
   timeClock[1] = frecpoints -> GetBestTimeA() + shift;
   timeClock[2] = frecpoints -> GetBestTimeC() - shift;
+
   for ( Int_t i=0; i<24; i++) {
     time[i] =  frecpoints -> GetTime(i); // ps to ns
-    if ( time[i] >1) {
+    //    if ( time[i] >1) {
+    if ( time[i] != 0) {
       ampQTC[i] = frecpoints -> GetAmp(i);
       amp[i] = frecpoints -> AmpLED(i);
-      AliDebug(1,Form("T0: time %f  ampQTC %f ampLED %f \n", time[i], ampQTC[i], amp[i]));
+      AliDebug(1,Form("T0: %i  time %f  ampQTC %f ampLED %f \n", i, time[i], ampQTC[i], amp[i]));
    }
   }
   Int_t trig= frecpoints ->GetT0Trig();
@@ -603,7 +604,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   pESD->SetT0time(time);         // best TOF on each PMT 
   pESD->SetT0amplitude(ampQTC);     // number of particles(MIPs) on each PMT
   
-  AliDebug(1,Form("T0: Vertex %f (T0A+T0C)/2 %f #channels T0signal %f ns OrA %f ns OrC %f T0trig %i\n",zPosition, timeStart, timeClock[0], timeClock[1], timeClock[2], trig));
+  AliDebug(1,Form("T0: SPDshift %f Vertex %f (T0A+T0C)/2 %f #channels T0signal %f ns OrA %f ns OrC %f T0trig %i\n",shift, zPosition, timeStart, timeClock[0], timeClock[1], timeClock[2], trig));
   
   if (pESD) {
     
@@ -616,7 +617,7 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        for ( Int_t i=0; i<24; i++) {
          if(i<12 && time[i]>1) timecorr[i] = tcorr[i] -  shift/channelWidth;
          if(i>11 && time[i]>1) timecorr[i] = tcorr[i] +  shift/channelWidth;
-         if(time[i]>1)   AliDebug(10,Form("T0 friend : time %f  ampQTC %f ampLED %f \n", timecorr[i], ampQTC[i], amp[i]));
+         if(time[i]>1)   AliDebug(10,Form("T0 friend : %i time %f  ampQTC %f ampLED %f \n", i, timecorr[i], ampQTC[i], amp[i]));
        }
        fESDTZEROfriend->SetT0timeCorr( timecorr) ;
        fESDTZEROfriend->SetT0ampLEDminCFD(amp);
index 22e9f67..9cee0c8 100644 (file)
@@ -207,13 +207,13 @@ int main(int argc, char **argv) {
         { 
           if(ik<12 && allData[ik+1][0]>0 && allData[knpmtC][0]>0 ){
             hCFD1minCFD[ik]->Fill(allData[ik+1][0]-allData[knpmtC][0]);
-            if(allData[ik+1][0]>0 ) hCFD[ik]->Fill(allData[ik+1][0]);
+            hCFD[ik]->Fill(allData[ik+1][0]);
           }
           
           if(ik>11 && allData[ik+45][0]>0 && allData[56+knpmtA][0]>0 )
             {
             hCFD1minCFD[ik]->Fill(allData[ik+45][0]-allData[56+knpmtA][0]);
-            if(allData[ik+1][0]>0 ) hCFD[ik]->Fill(allData[ik+45][0]);
+            hCFD[ik]->Fill(allData[ik+45][0]);
             }
           if(iev == 10000) {   
             meanShift[ik] =  hCFD1minCFD[ik]->GetMean();