]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDcalibration.cxx
- Macro to create the "raw" data file with selected events
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDcalibration.cxx
index 82a7907511183c5b55fe7509dcd50ad0ee1d0f59..aa5cafc572f41f329bdb0b30aea4e60d7191be6a 100644 (file)
@@ -59,9 +59,6 @@
 #include "AliTRDCalibraVector.h"
 #include "./Cal/AliTRDCalPad.h"
 #include "./Cal/AliTRDCalDet.h"
-#include "AliCDBMetaData.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
 
 #include "AliLog.h"
 
@@ -72,7 +69,7 @@ ClassImp(AliTRDcalibration)
 
 //________________________________________________________________________
 AliTRDcalibration::AliTRDcalibration() 
-  :AliTRDrecoTask("Calibration", "Calibration on tracks")
+  :AliTRDrecoTask()
   ,fTrackInfo(0)
   ,ftrdTrack(0)
   ,fcl(0)
@@ -89,6 +86,8 @@ AliTRDcalibration::AliTRDcalibration()
   ,fNbClusters(0)
   ,fNbClustersOffline(0)
   ,fNbClustersStandalone(0)
+  ,fPHSM(0)
+  ,fCHSM(0)
   ,fPHSum(0)
   ,fCHSum(0)
   ,fDetSum(0)
@@ -98,16 +97,15 @@ AliTRDcalibration::AliTRDcalibration()
   ,fVdriftLinear(kTRUE)
   ,flow(0)
   ,fhigh(30)
-  ,fNbTimeBins(30)
+  ,fNbTimeBins(0)
   ,ffillZero(kFALSE)
   ,fnormalizeNbOfCluster(kFALSE)
   ,fmaxCluster(0)
   ,fOfflineTracks(kFALSE)
   ,fStandaloneTracks(kFALSE)
   ,fCompressPerDetector(kFALSE)
-  ,fRunNumber(0)
-  ,fkNameDirectory("local://.")
   ,fGraph(0x0)
+  ,fArrayCalib(0x0)
   ,fPostProcess(kFALSE)
 {
   // Constructor
@@ -121,6 +119,59 @@ AliTRDcalibration::AliTRDcalibration()
     }
 
 }  
+
+AliTRDcalibration::AliTRDcalibration(char* name) 
+  :AliTRDrecoTask(name, "Calibration on tracks")
+  ,fTrackInfo(0)
+  ,ftrdTrack(0)
+  ,fcl(0)
+  ,fTRDCalibraFillHisto(0)
+  ,fNbTRDTrack(0)
+  ,fNbTRDTrackOffline(0)
+  ,fNbTRDTrackStandalone(0)
+  ,fNbTRDTracklet(0)
+  ,fNbTRDTrackletOffline(0)
+  ,fNbTRDTrackletStandalone(0)
+  ,fNbTimeBin(0x0)
+  ,fNbTimeBinOffline(0x0)
+  ,fNbTimeBinStandalone(0x0)
+  ,fNbClusters(0)
+  ,fNbClustersOffline(0)
+  ,fNbClustersStandalone(0)
+  ,fPHSM(0)
+  ,fCHSM(0)
+  ,fPHSum(0)
+  ,fCHSum(0)
+  ,fDetSum(0)
+  ,fDetSumVector(0)
+  ,fHisto2d(kTRUE)
+  ,fVector2d(kFALSE)
+  ,fVdriftLinear(kTRUE)
+  ,flow(0)
+  ,fhigh(30)
+  ,fNbTimeBins(0)
+  ,ffillZero(kFALSE)
+  ,fnormalizeNbOfCluster(kFALSE)
+  ,fmaxCluster(0)
+  ,fOfflineTracks(kFALSE)
+  ,fStandaloneTracks(kFALSE)
+  ,fCompressPerDetector(kFALSE)
+  ,fGraph(0x0)
+  ,fArrayCalib(0x0)
+  ,fPostProcess(kFALSE)
+{
+  // Constructor
+  
+  fNRefFigures = 17;
+
+  for(Int_t k = 0; k < 3; k++)
+    {
+      fNz[k]=0;
+      fNrphi[k]=0;
+    }
+
+}  
+
 //________________________________________________________________________
 AliTRDcalibration::~AliTRDcalibration() 
 {
@@ -138,24 +189,30 @@ AliTRDcalibration::~AliTRDcalibration()
   if(fNbClusters) delete fNbClusters;
   if(fNbClustersOffline) delete fNbClustersOffline;
   if(fNbClustersStandalone) delete fNbClustersStandalone;
+  if(fPHSM) delete fPHSM;
+  if(fCHSM) delete fCHSM;
   if(fPHSum) delete fPHSum;
   if(fCHSum) delete fCHSum;
   if(fDetSum) delete fDetSum;
   if(fDetSumVector) delete fDetSumVector;
-  if(fkNameDirectory) delete fkNameDirectory;
   if(fGraph){fGraph->Delete(); delete fGraph;}
-
+  if(fArrayCalib){fArrayCalib->Delete(); delete fArrayCalib;}
+   
 }
 //________________________________________________________________________
-void AliTRDcalibration::CreateOutputObjects() 
+void AliTRDcalibration::UserCreateOutputObjects() 
 {
   // Create output objects
 
-  OpenFile(0, "RECREATE");
-  
   // Number of time bins
-  AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
-  fNbTimeBins = cal->GetNumberOfTimeBins();
+  if(fNbTimeBins==0) {
+    AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
+    fNbTimeBins = cal->GetNumberOfTimeBinsDCS();
+    if(fNbTimeBins <= 0){ 
+      AliWarning(Form("No of TimeBins from DB [%d] use default [30]", fNbTimeBins));
+      fNbTimeBins = 30;
+    }
+  }
   
   // instance calibration: what to calibrate
   fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
@@ -189,7 +246,7 @@ void AliTRDcalibration::CreateOutputObjects()
   fTRDCalibraFillHisto->SetDebugLevel(DebugLevel()); //debug stuff
 
   // Init the stuff
-  fTRDCalibraFillHisto->Init2Dhistos(); // initialise the histos
+  fTRDCalibraFillHisto->Init2Dhistos(fNbTimeBins); // initialise the histos
 
   // cuts
   fTRDCalibraFillHisto->SetNumberClusters(flow); // At least flow clusters
@@ -238,15 +295,30 @@ void AliTRDcalibration::CreateOutputObjects()
     fNbClustersStandalone = new TH1F("NbClustersStandalone","",35,0,35);
     fNbClustersStandalone->Sumw2();
     //
-    fPHSum = new TProfile2D("PH2dSum","Nz0Nrphi0"
-                           ,fNbTimeBins,-0.05,(Double_t)(fNbTimeBins/10.0)-0.05
-                           ,540,0,540);
+    fPHSM = new TProfile2D("PH2dSM","Nz10Nrphi10"
+                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
+                           ,18,0,18);
+    fPHSM->SetYTitle("Det/pad groups");
+    fPHSM->SetXTitle("time [#mus]");
+    fPHSM->SetZTitle("<PH> [a.u.]");
+    fPHSM->SetStats(0);
+    //
+    fCHSM = new TH2I("CH2dSM","Nz10Nrphi10",50,0,300,18,0,18);
+    fCHSM->SetYTitle("Det/pad groups");
+    fCHSM->SetXTitle("charge deposit [a.u]");
+    fCHSM->SetZTitle("counts");
+    fCHSM->SetStats(0);
+    fCHSM->Sumw2();
+    //
+    fPHSum = new TProfile2D("PH2dSum","Nz100Nrphi100"
+                           ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
+                           ,1,0,1);
     fPHSum->SetYTitle("Det/pad groups");
     fPHSum->SetXTitle("time [#mus]");
     fPHSum->SetZTitle("<PH> [a.u.]");
     fPHSum->SetStats(0);
     //
-    fCHSum = new TH2I("CH2dSum","Nz0Nrphi0",100,0,300,540,0,540);
+    fCHSum = new TH2I("CH2dSum","Nz100Nrphi100",50,0,300,1,0,1);
     fCHSum->SetYTitle("Det/pad groups");
     fCHSum->SetXTitle("charge deposit [a.u]");
     fCHSum->SetZTitle("counts");
@@ -266,15 +338,18 @@ void AliTRDcalibration::CreateOutputObjects()
     fContainer->Add(fNbClusters);
     fContainer->Add(fNbClustersOffline);
     fContainer->Add(fNbClustersStandalone);
+    fContainer->Add(fPHSM);
+    fContainer->Add(fCHSM);
     fContainer->Add(fPHSum);
     fContainer->Add(fCHSum);
 
   }
-
+  // Post output data
+  PostData(1, fContainer);
 }
 
 //________________________________________________________________________
-void AliTRDcalibration::Exec(Option_t *) 
+void AliTRDcalibration::UserExec(Option_t *) 
 {
   //
   // Execute function where the reference data are filled
@@ -328,12 +403,14 @@ void AliTRDcalibration::Exec(Option_t *)
        // normalisation
        Float_t normalisation = 6.67;
        Int_t detector = 0;
+       Int_t sector = 0;
        Int_t crossrow = 0;
+       // Check no shared clusters
+       for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
+         if((fcl = tracklet->GetClusters(icc)))  crossrow = 1;
+       }
+       // Loop on clusters
        for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
-         // Check no shared clusters
-         for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
-           if((fcl = tracklet->GetClusters(icc)))  crossrow = 1;
-         }
          if(!(fcl = tracklet->GetClusters(ic))) continue;
          nbclusters++;
          Int_t time = fcl->GetPadTime();
@@ -346,6 +423,7 @@ void AliTRDcalibration::Exec(Option_t *)
          if(tracklet->IsStandAlone()) fNbTimeBinStandalone->Fill(time);
          else fNbTimeBinOffline->Fill(time);
        }
+       sector = AliTRDgeometry::GetSector(detector);
 
        fNbTRDTracklet->Fill(detector);
        if(tracklet->IsStandAlone()) fNbTRDTrackletStandalone->Fill(detector);
@@ -356,12 +434,18 @@ void AliTRDcalibration::Exec(Option_t *)
        else  fNbClustersOffline->Fill(nbclusters);
        
        if((nbclusters > flow) && (nbclusters < fhigh)){
-         fCHSum->Fill(sum/20.0,0.0);
+         fCHSM->Fill(sum/20.0,sector+0.5);
+         fCHSum->Fill(sum/20.0,0.5);
          for(int ic=0; ic<fNbTimeBins; ic++){
-           //printf("ic %d and time %f and cluster %f \n",ic,(Double_t)(ic/10.0),(Double_t)phtb[ic]);
-           if(ffillZero) fPHSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
+           if(ffillZero) {
+             fPHSum->Fill((Double_t)(ic/10.0),0.5,(Double_t)phtb[ic]);
+             fPHSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
+           }
            else {
-             if(phtb[ic] > 0.0) fPHSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
+             if(phtb[ic] > 0.0) {
+               fPHSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
+               fPHSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
+             }
            }
          }
        }
@@ -382,19 +466,8 @@ void AliTRDcalibration::Exec(Option_t *)
     fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
     
   }
-
-  //printf("Nbof tracks %d\n",nbTrdTracks);
-  
-  TFile *file = TFile::Open("test.root","RECREATE");
-  fContainer->Write();
-  file->Close();
-
-  // Post output data
-  PostData(0, fContainer);
-
-  //printf("post container\n");
-  
-}      
+}  
+    
 //________________________________________________________________________
 void AliTRDcalibration::Terminate(Option_t *) 
 {
@@ -635,7 +708,7 @@ case kCH2DVector:{
     hdetector = 0x0;
     if((TMath::Abs(max) <= 0.001) || (detectormax <0.0) || (detectormax >=540.0)) break;
     if(!(hdetector = (TH2S *)h->GetLinearFitterHisto((Int_t)detectormax,kFALSE))) break;
-    AliInfo(Form("The detector with the maximum of entries is %d",detectormax));
+    AliInfo(Form("The detector with the maximum of entries is %f",detectormax));
     hdetector->Draw();
     return kTRUE;
   }
@@ -707,8 +780,24 @@ Bool_t AliTRDcalibration::PostProcess()
 {
   // 
   // Fit the filled histos
+  // Put the calibration object in fArrayCalib
+  // 0 and 1 AliTRDCalDet and AliTRDCalPad gain
+  // 2 and 3 AliTRDCalDet and AliTRDCalPad vdrift PH
+  // 4 and 5 AliTRDCalDet and AliTRDCalPad timeoffset PH
+  // 6 AliTRDCalPad PRF
+  // 7 and 8 AliTRDCalDet and AliTRDCalPad vdrift second
+  // 9 and 10 AliTRDCalDet and AliTRDCalPad lorentz angle second
   //
 
+  if(!fArrayCalib){
+    fArrayCalib = new TObjArray(11);
+    fArrayCalib->SetOwner();
+  }
+  else {
+    delete fArrayCalib;
+    PostProcess();
+  }
+  
   if(!fGraph){
     fGraph = new TObjArray(6);
     fGraph->SetOwner();
@@ -720,20 +809,6 @@ Bool_t AliTRDcalibration::PostProcess()
 
   Bool_t storage[3] = {kFALSE,kFALSE,kFALSE};
 
-  // storage element
-  AliCDBManager *man = AliCDBManager::Instance();
-  man->SetDefaultStorage("local://$ALICE_ROOT");
-  AliCDBStorage* storLoc = man->GetStorage(fkNameDirectory);
-  if (!storLoc)
-    return kFALSE;
-  man->SetRun(fRunNumber);
-
-  // MetaData
-  AliCDBMetaData mdDet; 
-  mdDet.SetObjectClassName("AliTRDCalDet");
-  AliCDBMetaData mdPad; 
-  mdPad.SetObjectClassName("AliTRDCalPad");
-  
   // Objects for fitting
   AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
   calibra->SetDebugLevel(2); // 0 rien, 1 fitvoir, 2 debug files, 3 one detector  
@@ -790,10 +865,8 @@ Bool_t AliTRDcalibration::PostProcess()
          AliTRDCalDet *objgaindet   = calibra->CreateDetObjectGain(&object);
          TObject *objgainpad        = calibra->CreatePadObjectGain();
          // store
-         AliCDBId id1("TRD/Calib/ChamberGainFactor",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objgaindet, id1, &mdDet); 
-         AliCDBId id2("TRD/Calib/LocalGainFactor",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objgainpad, id2, &mdPad);
+         fArrayCalib->AddAt(objgaindet,0);
+         fArrayCalib->AddAt(objgainpad,1);
          storage[0] = kTRUE;
          // Make graph
          TGraph *graph = 0x0;
@@ -852,15 +925,11 @@ Bool_t AliTRDcalibration::PostProcess()
        AliTRDCalDet *objtime0det  = calibra->CreateDetObjectT0(&object,kTRUE);
        TObject *objtime0pad       = calibra->CreatePadObjectT0();
        // store
-       AliCDBId id1("TRD/Calib/ChamberVdrift",fRunNumber, AliCDBRunRange::Infinity()); 
-       storLoc->Put((TObject *)objdriftvelocitydet, id1, &mdDet); 
-       AliCDBId id2("TRD/Calib/LocalVdrift",fRunNumber, AliCDBRunRange::Infinity()); 
-       storLoc->Put((TObject *)objdriftvelocitypad, id2, &mdPad); 
+       fArrayCalib->AddAt(objdriftvelocitydet,2);
+       fArrayCalib->AddAt(objdriftvelocitypad,3);
        //
-       AliCDBId idd1("TRD/Calib/ChamberT0",fRunNumber, AliCDBRunRange::Infinity()); 
-       storLoc->Put((TObject *)objtime0det, idd1, &mdDet); 
-       AliCDBId idd2("TRD/Calib/LocalT0",fRunNumber, AliCDBRunRange::Infinity()); 
-       storLoc->Put((TObject *)objtime0pad, idd2, &mdPad); 
+       fArrayCalib->AddAt(objtime0det,4);
+       fArrayCalib->AddAt(objtime0pad,5);
        // Make graph
        TGraph *graph = 0x0;
        if(FillGraphIndex(&object,graph)){ 
@@ -912,8 +981,7 @@ Bool_t AliTRDcalibration::PostProcess()
       TObjArray object            = calibra->GetVectorFit();
       TObject *objPRFpad          = calibra->CreatePadObjectPRF(&object);
       // store
-      AliCDBId id2("TRD/Calib/PRFWidth",fRunNumber, AliCDBRunRange::Infinity()); 
-      storLoc->Put((TObject *)objPRFpad, id2, &mdPad); 
+      fArrayCalib->AddAt(objPRFpad,6);
       // Make graph
       TGraph *graph = 0x0;
       if(FillGraphIndex(&object,graph)){ 
@@ -950,15 +1018,11 @@ Bool_t AliTRDcalibration::PostProcess()
          AliTRDCalDet *objtime0det  = calibra->CreateDetObjectT0(&object,kTRUE);
          TObject *objtime0pad       = calibra->CreatePadObjectT0();
          // store dummy
-         AliCDBId id1("TRD/Calib/ChamberVdriftLinear",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objdriftvelocitydet, id1, &mdDet); 
-         AliCDBId id2("TRD/Calib/LocalVdriftLinear",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objdriftvelocitypad, id2, &mdPad); 
+         fArrayCalib->AddAt(objdriftvelocitydet,7);
+         fArrayCalib->AddAt(objdriftvelocitypad,8);
          //
-         AliCDBId idd1("TRD/Calib/ChamberLorentzAngle",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objtime0det, idd1, &mdDet); 
-         AliCDBId idd2("TRD/Calib/LocalLorentzAngle",fRunNumber, AliCDBRunRange::Infinity()); 
-         storLoc->Put((TObject *)objtime0pad, idd2, &mdPad); 
+         fArrayCalib->AddAt(objtime0det,9);
+         fArrayCalib->AddAt(objtime0pad,10);
          // Make graph
          TGraph *graph = 0x0;
          if(FillGraphIndex(&object,graph)){ 
@@ -1005,8 +1069,10 @@ Bool_t AliTRDcalibration::FillGraphIndex(const TObjArray *vectora,TGraph *graph)
     y[k]  = ((Float_t *)((AliTRDCalibraFit::AliTRDFitInfo *) vectora->At(k))->GetCoef())[0];
   }
 
-  if(!graph) graph = new TGraph(540,&x[0],&y[0]);
-  else{ 
+  if(!graph){
+    graph = new TGraph(540,&x[0],&y[0]);
+    graph->SetMarkerStyle(20);
+  } else{ 
     graph->~TGraph();
     new(graph) TGraph(540,&x[0],&y[0]);
   }
@@ -1368,6 +1434,4 @@ Int_t AliTRDcalibration::GetNumberOfGroupsPRF(const char* nametitle) const
     return 6;
   }
   else return -1;
-
 }