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