]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/QA/AddTaskCalorimeterQA.C
97580d504432ec2679fb9e1ffe3ecefac62db76f
[u/mrichter/AliRoot.git] / PWG4 / macros / QA / AddTaskCalorimeterQA.C
1 //
2 // Wagon contacts: EMCAL Gustavo.Conesa.Balbastre@cern.ch
3 //                 PHOS  Yuri.Kharlov@cern.ch
4 //
5 AliAnalysisTaskParticleCorrelation *AddTaskCalorimeterQA(TString data, Bool_t kPrintSettings = kFALSE,Bool_t kSimulation = kFALSE,TString outputFile = "", Bool_t oldAOD=kFALSE)
6 {
7   // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.
8   
9   // Get the pointer to the existing analysis manager via the static access method.
10   //==============================================================================
11   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
12   if (!mgr) {
13     ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
14     return NULL;
15   }  
16   
17   // Check the analysis type using the event handlers connected to the analysis manager.
18   //==============================================================================
19   if (!mgr->GetInputEventHandler()) {
20     ::Error("AddTaskPartCorr", "This task requires an input event handler");
21     return NULL;
22   }
23   TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
24   
25   Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
26         
27   cout<<"********* ACCESS KINE? "<<kUseKinematics<<endl;
28         
29   // Configure analysis
30   //===========================================================================
31   
32   //Reader
33   //For this particular analysis few things done by the reader.
34   //Nothing else needs to be set.
35   AliCaloTrackReader * reader = 0x0;
36   if     (data=="AOD") reader = new AliCaloTrackAODReader();
37   else if(data=="ESD") reader = new AliCaloTrackESDReader();
38   //reader->SetDebug(10);//10 for lots of messages
39   reader->SwitchOnEMCALCells(); 
40   reader->SwitchOnPHOSCells(); 
41   reader->SwitchOnEMCAL();
42   reader->SwitchOnPHOS();
43   reader->SwitchOffCTS();
44   reader->SetEMCALPtMin(0.); 
45   reader->SetPHOSPtMin (0.);
46   reader->SetCTSPtMin  (0.);
47   
48   if(kUseKinematics){
49                 if(inputDataType == "ESD"){
50                         reader->SwitchOnStack();          
51                         reader->SwitchOffAODMCParticles(); 
52                 }
53                 else if(inputDataType == "AOD"){
54                         reader->SwitchOffStack();          
55                         reader->SwitchOnAODMCParticles(); 
56                 }
57   }
58   //if(!kSimulation) reader->SetFiredTriggerClassName("CINT1B-ABCE-NOPF-ALL");
59   reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
60   reader->SwitchOffWriteDeltaAOD()  ;
61   if(oldAOD)         reader->SwitchOnOldAODs();
62   if(kPrintSettings) reader->Print("");
63         
64   // *** Calorimeters Utils     ***
65   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
66   // Remove clusters close to borders, at least max energy cell is 1 cell away 
67   cu->SetNumberOfCellsFromEMCALBorder(1);
68   cu->SetNumberOfCellsFromPHOSBorder(2);
69   cu->SwitchOnNoFiducialBorderInEMCALEta0();
70         
71   // Remove EMCAL hottest channels for first LHC10 periods      
72   cu->SwitchOnBadChannelsRemoval();
73   // SM0
74   cu->SetEMCALChannelStatus(0,3,13);  cu->SetEMCALChannelStatus(0,44,1); cu->SetEMCALChannelStatus(0,3,13); 
75   cu->SetEMCALChannelStatus(0,20,7);  cu->SetEMCALChannelStatus(0,38,2);   
76   // SM1
77   cu->SetEMCALChannelStatus(1,4,7);   cu->SetEMCALChannelStatus(1,4,13);  cu->SetEMCALChannelStatus(1,9,20); 
78   cu->SetEMCALChannelStatus(1,14,15); cu->SetEMCALChannelStatus(1,23,16); cu->SetEMCALChannelStatus(1,32,23); 
79   cu->SetEMCALChannelStatus(1,37,5);  cu->SetEMCALChannelStatus(1,40,1);  cu->SetEMCALChannelStatus(1,40,2);
80   cu->SetEMCALChannelStatus(1,40,5);  cu->SetEMCALChannelStatus(1,41,0);  cu->SetEMCALChannelStatus(1,41,1);
81   cu->SetEMCALChannelStatus(1,41,2);  cu->SetEMCALChannelStatus(1,41,4);
82   // SM2        
83   cu->SetEMCALChannelStatus(2,14,15); cu->SetEMCALChannelStatus(2,18,16); cu->SetEMCALChannelStatus(2,18,17); 
84   cu->SetEMCALChannelStatus(2,18,18); cu->SetEMCALChannelStatus(2,18,20); cu->SetEMCALChannelStatus(2,18,21); 
85   cu->SetEMCALChannelStatus(2,18,23); cu->SetEMCALChannelStatus(2,19,16); cu->SetEMCALChannelStatus(2,19,17); 
86   cu->SetEMCALChannelStatus(2,19,19); cu->SetEMCALChannelStatus(2,19,20); cu->SetEMCALChannelStatus(2,19,21); 
87   cu->SetEMCALChannelStatus(2,19,22);
88   //SM3
89   cu->SetEMCALChannelStatus(3,4,7);
90         
91   //Recalibration
92   //cu->SwitchOnRecalibration();
93   //TFile * f = new TFile("RecalibrationFactors.root","read");
94   //cu->SetEMCALChannelRecalibrationFactors(0,(TH2F*)f->Get("EMCALRecalFactors_SM0"));
95   //cu->SetEMCALChannelRecalibrationFactors(1,(TH2F*)f->Get("EMCALRecalFactors_SM1"));
96   //cu->SetEMCALChannelRecalibrationFactors(2,(TH2F*)f->Get("EMCALRecalFactors_SM2"));
97   //cu->SetEMCALChannelRecalibrationFactors(3,(TH2F*)f->Get("EMCALRecalFactors_SM3"));
98         
99   cu->SetDebug(-1);
100   if(kPrintSettings) cu->Print("");     
101         
102   // ##### Analysis algorithm settings ####
103   //AliFiducialCut * fidCut = new AliFiducialCut();
104   //fidCut->DoCTSFiducialCut(kFALSE) ;
105   //fidCut->DoEMCALFiducialCut(kTRUE) ;
106   //fidCut->DoPHOSFiducialCut(kTRUE) ;  
107         
108   AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
109   //emcalQA->SetDebug(2); //10 for lots of messages
110   emcalQA->SetCalorimeter("EMCAL");
111   if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
112   else  emcalQA->SwitchOffDataMC() ;
113   emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
114   //emcalQA->SetFiducialCut(fidCut);
115   emcalQA->SwitchOffFiducialCut();
116   emcalQA->SwitchOffPlotsMaking();
117   emcalQA->SwitchOnCalorimetersCorrelation();
118   if(!kUseKinematics)emcalQA->SetTimeCut(400,850);//Open for the moment
119   //Set Histrograms bins and ranges
120   emcalQA->SetHistoPtRangeAndNBins(0, 5, 50) ;
121   emcalQA->SetHistoFinePtRangeAndNBins(0, 5, 1000) ; // bining for fhAmpId
122   emcalQA->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 121*TMath::DegToRad(), 100) ;
123   emcalQA->SetHistoEtaRangeAndNBins(-0.71, 0.71, 200) ;
124   emcalQA->SetNumberOfModules(4); //EMCAL first year
125   emcalQA->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
126   emcalQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
127   emcalQA->SetHistoPOverERangeAndNBins(0,10.,100);
128   emcalQA->SetHistodEdxRangeAndNBins(0.,200.,200);
129   emcalQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
130   emcalQA->SetHistoTimeRangeAndNBins(300.,900,300);
131   emcalQA->SetHistoRatioRangeAndNBins(0.,2.,100);
132   emcalQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
133   emcalQA->SetHistoNClusterCellRangeAndNBins(0,50,50);
134   emcalQA->SetHistoXRangeAndNBins(-230,90,120);
135   emcalQA->SetHistoYRangeAndNBins(370,450,40);
136   emcalQA->SetHistoZRangeAndNBins(-400,400,200);
137   emcalQA->SetHistoRRangeAndNBins(400,450,25);
138   
139   //emcalQA->GetMCAnalysisUtils()->SetDebug(10);
140         
141   if(kPrintSettings) emcalQA->Print("");        
142   
143   AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
144   //phosQA->SetDebug(2); //10 for lots of messages
145   phosQA->SetCalorimeter("PHOS");
146   if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
147   else  phosQA->SwitchOffDataMC() ;  
148   phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
149   //phosQA->SetFiducialCut(fidCut);
150   phosQA->SwitchOffFiducialCut();
151   //phosQA->GetMCAnalysisUtils()->SetDebug(10);
152   phosQA->SwitchOffPlotsMaking();
153   //Set Histrograms bins and ranges
154   phosQA->SetHistoPtRangeAndNBins(0, 5, 50) ;
155   phosQA->SetHistoFinePtRangeAndNBins(0, 5, 1000) ; // bining for fhAmpId
156   phosQA->SetHistoPhiRangeAndNBins(259*TMath::DegToRad(), 321*TMath::DegToRad(), 130) ;
157   phosQA->SetHistoEtaRangeAndNBins(-0.125, 0.125, 57) ;
158   phosQA->SetNumberOfModules(3); //PHOS first year
159   phosQA->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
160   phosQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
161   phosQA->SetHistoPOverERangeAndNBins(0,10.,100);
162   phosQA->SetHistodEdxRangeAndNBins(0.,200.,200);
163   phosQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
164   phosQA->SetHistoTimeRangeAndNBins(0.,300,300);
165   phosQA->SetHistoRatioRangeAndNBins(0.,2.,100);
166   phosQA->SetHistoVertexDistRangeAndNBins(0.,500.,500);
167   phosQA->SetHistoNClusterCellRangeAndNBins(0,50,50);
168   phosQA->SetHistoXRangeAndNBins(-100,400,100);
169   phosQA->SetHistoYRangeAndNBins(-490,-290,100);
170   phosQA->SetHistoZRangeAndNBins(-80,80,100);
171   phosQA->SetHistoRRangeAndNBins(440,480,80);
172         
173   //if(kPrintSettings)phosQA->Print("");        
174         
175   // #### Configure Maker ####
176   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
177   maker->SetReader(reader);//pointer to reader
178   maker->SetCaloUtils(cu); //pointer to calorimeter utils
179   maker->AddAnalysis(emcalQA,0);
180   maker->AddAnalysis(phosQA,1);
181   maker->SetAnaDebug(-1)  ; // 0 to at least print the event number
182   maker->SwitchOnHistogramsMaker()  ;
183   maker->SwitchOffAODsMaker()  ;
184   if(kPrintSettings) maker->Print("");
185   
186   
187   printf("======================== \n");
188   printf(" End Configuration of Calorimeter QA \n");
189   printf("======================== \n");
190   
191   // Create task
192   //===========================================================================
193   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
194   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
195   //task->SetDebugLevel(-1);
196   task->SelectCollisionCandidates();
197   task->SetAnalysisMaker(maker);        
198   mgr->AddTask(task);
199   
200   //Create containers
201   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
202   //                                                       AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
203         
204   
205   if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName(); 
206   
207   
208   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer("CaloQA", TList::Class(), 
209                                                              AliAnalysisManager::kOutputContainer, 
210                                                              Form("%s:CaloQA",outputFile.Data()));
211   
212   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer("CaloQACuts", TList::Class(), 
213                                                              AliAnalysisManager::kParamContainer, 
214                                                              Form("%s:CaloQACuts",outputFile.Data()));
215         //Form("%s:PartCorrCuts",outputfile.Data()));   
216   // Create ONLY the output containers for the data produced by the task.
217   // Get and connect other common input/output containers via the manager as below
218   //==============================================================================
219   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
220   mgr->ConnectOutput (task, 1, cout_pc);
221   mgr->ConnectOutput (task, 2, cout_cuts);
222   
223   return task;
224 }
225
226