]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C
Changes for 2012 data analysis
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / macros / ConfigureEMCALRecoUtils.C
1
2 void ConfigureEMCALRecoUtils(
3                              AliEMCALRecoUtils* reco,
4                              Bool_t  bMC   = kFALSE,
5                              TGeoHMatrix* matrix[12],
6                              TString path  = "",
7                              Int_t   run   = 0, 
8                              TString pass  = "pass2",
9                              Bool_t bRecalE= kTRUE,
10                              Bool_t bBad   = kTRUE,
11                              Bool_t bRecalT= kFALSE
12                              )
13 {  
14
15   // Configure RecoUtils with OADB objects
16   
17   printf("**** Configure AliEMCALRecoUtils, LOAD AODB ***\n");
18   printf("\t run %d, pass %s\n",run,pass.Data());
19   
20   
21   // Exotic cells removal
22   
23   reco->SwitchOnRejectExoticCell() ;
24   reco->SetExoticCellDiffTimeCut(10000); // Open  
25   reco->SetExoticCellFractionCut(0.95);  // 1-Ecross/Ecell > 0.95 -> out
26   reco->SetExoticCellMinAmplitudeCut(0.75); // 750 MeV    
27   
28   gSystem->Load("libOADB");
29   
30   // Geometry settings, matrices
31   
32   // Instantiate EMCAL geometry for the first time
33   
34   AliEMCALGeometry*   geom = 0; 
35   if     (run < 140000) geom = AliEMCALGeometry::GetInstance("EMCAL_FIRSTYEARV1");
36   else if(run < 171000) geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
37   else                  geom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETE12SMV1");
38
39   Int_t nSM = geom->GetNumberOfSuperModules();
40
41   // Alignment matrices
42
43   TString fileName="$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root";
44   if(path!="") fileName=path+"EMCALlocal2master.root";
45
46   AliOADBContainer EMCALgeoCont("AliEMCALgeo");
47   EMCALgeoCont.InitFromFile((char*)fileName.Data(),"AliEMCALgeo");
48   TObjArray *mobj=(TObjArray*)EMCALgeoCont.GetObject(run,"EmcalMatrices");
49   for (Int_t mod=0;mod<nSM;mod++)
50     {
51       matrix[mod] = (TGeoHMatrix*) mobj->At(mod);
52       //matrix[mod]->Print();
53     }
54       
55   reco->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal);   
56   
57   
58   // *** Energy recalibration settings ***
59   
60   if(pass == "pass3"){
61     bRecalE = kFALSE;
62     bBad   = kFALSE;
63   }
64   
65   if(bMC){
66     bRecalE = kFALSE;
67   }
68   
69   //Recalibration factors
70   if(bRecalE){
71     
72     fileName="$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root";
73     if(path!="") fileName=path+"EMCALRecalib.root";
74     
75     AliOADBContainer *contRF=new AliOADBContainer("");
76     contRF->InitFromFile((char*)fileName.Data(),"AliEMCALRecalib");
77     
78     TObjArray *recal=(TObjArray*)contRF->GetObject(run); 
79     if(recal){
80       TObjArray *recalpass=(TObjArray*)recal->FindObject(pass);
81       if(recalpass){
82         TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib");
83         if(recalib){
84           reco->SwitchOnRecalibration();
85           printf("AliEMCALRecoUtils - RECALIBRATE \n");
86           for (Int_t i=0; i<nSM; ++i) {
87             TH2F *h = reco->GetEMCALChannelRecalibrationFactors(i);
88             if (h)
89               delete h;
90             h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i));
91             if (!h) {
92               AliError(Form("Could not load EMCALRecalFactors_SM%d",i));
93               continue;
94             }
95             h->SetDirectory(0);
96             reco->SetEMCALChannelRecalibrationFactors(i,h);
97           } 
98         }else printf("AliEMCALRecoUtils ---Do NOT recalibrate 1\n");
99       }else printf("AliEMCALRecoUtils ---Do NOT recalibrate 2\n");
100     }else printf("AliEMCALRecoUtils ---Do NOT recalibrate 3\n");
101     
102     //TFile * f = new TFile("RecalibrationFactors.root","read");
103     //for(Int_t i =0; i< 12; i++)  reco->SetEMCALChannelRecalibrationFactors( i, (TH2F*) f->Get(Form("EMCALRecalFactors_SM%d",i)));                                                                      
104     // //  reco->SwitchOnTimeDepCorrection();
105     // //  //char cmd[200] ; 
106     // //  //sprintf(cmd, ".!tar xvfz CorrectionFiles.tgz") ; 
107     // //  //gROOT->ProcessLine(cmd) ; 
108     // //       
109     
110   } else printf("AliEMCALRecoUtils ---Do NOT recalibrate\n");
111
112   // *** Remove EMCAL hot channels *** 
113   
114   if(bBad){
115     
116     fileName="$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root";
117     if(path!="") fileName=path+"EMCALBadChannels.root";
118     
119     AliOADBContainer *contBC=new AliOADBContainer("");
120     contBC->InitFromFile((char*)fileName.Data(),"AliEMCALBadChannels"); 
121     TObjArray *arrayBC=(TObjArray*)contBC->GetObject(run);
122     if(arrayBC){
123       TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(pass);
124       if(arrayBCpass){
125         
126         reco->SwitchOnBadChannelsRemoval();
127         reco->SwitchOnDistToBadChannelRecalculation();
128         printf("AliEMCALRecoUtils - REMOVE bad cells \n");
129
130         for (Int_t i=0; i<nSM; ++i) {
131           TH2I *hbm = reco->GetEMCALChannelStatusMap(i);
132           if (hbm)
133             delete hbm;
134           hbm=(TH2I*)arrayBCpass->FindObject(Form("EMCALBadChannelMap_Mod%d",i));
135           
136           if (!hbm) {
137             AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i));
138             continue;
139           }
140           
141           hbm->SetDirectory(0);
142           reco->SetEMCALChannelStatusMap(i,hbm);
143         }
144       } else printf("AliEMCALRecoUtils ---Do NOT remove bad channels 1\n");
145     }  else printf("AliEMCALRecoUtils ---Do NOT remove bad channels 2\n");
146   } else printf("AliEMCALRecoUtils ---Do NOT remove bad channels 3 \n");
147
148   /*  
149     Int_t iCol = -1, iRow = -1, iSM =-1, iMod = -1,iIphi =-1,iIeta = -1;
150     Int_t badAbsID[]={74, 103};
151     
152     for(Int_t i=0;i < sizeof(badAbsID)/sizeof(Int_t); i++){
153       geom->GetCellIndex(badAbsID[i],iSM,iMod,iIphi,iIeta); 
154       // Gives SuperModule and Tower numbers
155       geom->GetCellPhiEtaIndexInSModule(iSM,iMod,
156                                         iIphi, iIeta,iRow,iCol);
157       //printf("bad ID %d, col %d, row %d, sm %d\n",badAbsID[i],iCol,iRow,iSM);
158       reco->SetEMCALChannelStatus(iSM , iCol, iRow,1);
159     }
160
161     }
162    */
163  
164   // *** Time recalibration settings ***
165   
166   if(bRecalT){
167     
168     reco->SwitchOnTimeRecalibration();
169     
170     //Waiting for OADB, meanwhile
171     
172     TFile * ftime = 0;
173     TString path ="./"; 
174     //TString path = "alien:///alice/cern.ch/user/g/germain/RecalDB/Time";
175     //TGrid::Connect("alien://");
176     
177     if     (run > 140000 && run < 146500 )
178       ftime = TFile::Open(Form("%s/RefLHC11apass1-7TeV.root",path.Data()));
179     else if(run > 146500 && run <= 146860 )
180       ftime = TFile::Open(Form("%s/RefLHC11apass3-2.76TeV.root",path.Data()));
181     else if(run > 146860 && run < 156477 )
182       ftime = TFile::Open(Form("%s/RefLHC11cpass1-7TeV.root",path.Data()));
183     else if(run >= 156477)
184       ftime = TFile::Open(Form("%s/RefLHC11dpass1-7TeV.root",path.Data()));
185     else if(run <  140000 && run > 136850)
186       ftime = TFile::Open(Form("%s/RefLHC10hpass2PbPb2.76TeV.root",path.Data()));
187     else if(run < 136850)
188       ftime = TFile::Open(Form("%s/RefLHC10dpass2-7TeV.root",path.Data()));
189     else printf("Run %d, not considered for time calibration\n",run);
190     
191     if(ftime){
192       printf("AliEMCALRecoUtils - Time recalibration ON\n");
193       
194       for(Int_t i =0; i< 4; i++)  reco->SetEMCALChannelTimeRecalibrationFactors( i, (TH1F*) ftime->Get(Form("hAllTimeAvBC%d",i)));      
195     }
196     else printf("AliEMCALRecoUtils --- Time recalibration OFF\n");
197     
198   }    else printf("AliEMCALRecoUtils --- Time recalibration OFF 2\n");
199
200     
201 }
202
203