]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/Macros/AliTRDFindTheCoef.C
Add calibration macros by Raphaelle
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDFindTheCoef.C
1 #if !defined( __CINT__) || defined(__MAKECINT__)
2
3 #include <TFile.h>
4 #include <TProfile2D.h>
5 #include <TTree.h>
6 #include <Riostream.h>
7 #include <TSystem.h>
8 #include "AliReconstruction.h"
9 #include "AliTRDCalibra.h"
10 #include "AliCDBManager.h"
11
12 #endif
13
14
15
16 void AliTRDFindTheCoef() 
17 {
18   //
19   // This macro takes a 2D histo or vector in the file TRD.calibration.root
20   // tries to find the coeffficients
21   // writes the result in the form of a tree in the file coeftest.root
22  
23   TStopwatch timer;
24   timer.Start();
25   
26
27   ////Set the CDBManager(You have to use the same as during the reconstruction)*************************
28   AliCDBManager *man = AliCDBManager::Instance();
29   man->GetStorage("local://$ALICE_ROOT"); 
30   man->SetRun(0);
31
32   ////Set the parameters of AliTRDCalibra***************
33   AliTRDCalibra *calibra = AliTRDCalibra::Instance();
34
35   ////Wich mode did you use in the reconstruction?
36   calibra->SetNz(0,2);//here for the gain
37   calibra->SetNrphi(0,2);//here for the gain 
38
39   ////How many bins did you have?
40   //calibra->SetNumberBinCharge(100);
41   //calibra->SetNumberBinPRF(20);
42
43
44   ////Which method do you want to use (It is always the default method that will be put in the database)
45   //calibra->SetMeanChargeOn();
46   calibra->SetFitChargeBisOn();
47   //calibra->SetFitPHOn();
48   //calibra->SetPeriodeFitPH(10);
49
50   //Some details?
51   //calibra->SetRangeFitPRF(0.5);//fit from -0.5 and 0.5 with a gaussian the PRF
52   //calibra->SetT0Shift(0.1433);//will always abstract 0.1433 mus to the result of the method for time 0
53
54   ////What do you want to see?
55   calibra->SetDebug(1);//0 (nothing to see), 1, 2, 3, or 4
56   //calibra->SetDet(0,1,14);//in case of fDebug = 3 and 4
57   //calibra->SetFitVoir(2);//in case of fDebug = 2
58
59   ////How many statistics do you want to accept?
60   calibra->SetMinEntries(1);// 1 entry at least to fit
61
62   ////Do you want to write the result?
63   calibra->SetWriteCoef(1);
64
65   ////Do you want to change the name of the file (TRD.coefficient.root)?
66   calibra->SetWriteNameCoef("coeftest.root");
67
68   ////Take the Histo2d or tree in the TRD.calibration.root file 
69   TFile *file = TFile::Open("TRD.calibration.root","READ");
70   //TH2I *h = (TH2I *) file->Get("CH2d");
71   TTree *h = (TTree *) file->Get("treeCH2d");
72   //h->SetDirectory(0);
73
74   ////Fit
75   calibra->FitCHOnline(h);  
76
77   
78   timer.Stop();
79   timer.Print();
80
81 }