]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/CaloTrackCorrelations/macros/QA/AddTaskCalorimeterQA.C
4a47f21324e01b6f834595a8689f06a94f8b11e5
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / macros / QA / AddTaskCalorimeterQA.C
1 //
2 // Wagon contacts: EMCAL Gustavo.Conesa.Balbastre@cern.ch
3 //                
4 //
5 AliAnalysisTaskCaloTrackCorrelation *AddTaskCalorimeterQA(TString data, 
6                                                           Int_t year = 2011, 
7                                                           Bool_t kPrintSettings = kFALSE,
8                                                           Bool_t kSimulation = kFALSE,
9                                                           TString outputFile = "", 
10                                                           const char *suffix="default")
11 {
12   // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.
13   
14   // Get the pointer to the existing analysis manager via the static access method.
15   //==============================================================================
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr) {
18     ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
19     return NULL;
20   }  
21   
22   // Check the analysis type using the event handlers connected to the analysis manager.
23   //==============================================================================
24   if (!mgr->GetInputEventHandler()) {
25     ::Error("AddTaskPartCorr", "This task requires an input event handler");
26     return NULL;
27   }
28   TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
29   
30   Bool_t kUseKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
31   
32   // Configure analysis
33   //===========================================================================
34   
35   //Reader
36   //For this particular analysis few things done by the reader.
37   //Nothing else needs to be set.
38   
39   AliCaloTrackReader * reader = 0x0;
40   if     (data.Contains("AOD")) reader = new AliCaloTrackAODReader();
41   else if(data.Contains("ESD")) reader = new AliCaloTrackESDReader();
42   //reader->SetDebug(10);//10 for lots of messages
43   
44   reader->SwitchOnEMCALCells(); 
45   reader->SwitchOnEMCAL();
46   reader->SwitchOnPHOSCells(); // For correlation plots
47   reader->SwitchOnPHOS();      // For correlation plots
48   reader->SetEMCALPtMin(0.); 
49   reader->SwitchOnCTS();
50   reader->SetCTSPtMin  (0.);
51   reader->SetZvertexCut(10.);
52   
53   if(kUseKinematics){
54     if(inputDataType == "ESD"){
55       reader->SwitchOnStack();          
56       reader->SwitchOffAODMCParticles(); 
57     }
58     else if(inputDataType == "AOD"){
59       reader->SwitchOffStack();          
60       reader->SwitchOnAODMCParticles(); 
61     }
62   }
63   
64   reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
65   reader->SwitchOffWriteDeltaAOD()  ;
66   if(kPrintSettings) reader->Print("");
67   
68   // *** Calorimeters Utils     ***
69   AliCalorimeterUtils *cu = new AliCalorimeterUtils;
70   // Remove clusters close to borders, at least max energy cell is 1 cell away 
71   cu->SetNumberOfCellsFromEMCALBorder(1);
72   if     (year==2010) cu->SetEMCALGeometryName("EMCAL_FIRSTYEARV1");
73   else if(year==2011) cu->SetEMCALGeometryName("EMCAL_COMPLETEV1"); 
74   else                cu->SetEMCALGeometryName("EMCAL_COMPLETE12SMV1"); 
75   
76   AliEMCALRecoUtils* reco = cu->GetEMCALRecoUtils();
77   reco->SwitchOnRejectExoticCell() ; // reject exotic cells, fill different histograms for exotic clusters and good clusters
78   reco->SetExoticCellDiffTimeCut(10000); // Open  
79   reco->SetExoticCellFractionCut(0.95);  // 1-Ecross/Ecell > 0.95 -> out
80   reco->SetExoticCellMinAmplitudeCut(0.75); // 750 MeV    
81   
82   cu->SetDebug(-1);
83   if(kPrintSettings) cu->Print("");     
84   
85   // ##### Analysis algorithm settings ####
86   
87   AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
88   //emcalQA->SetDebug(10); //10 for lots of messages
89   emcalQA->SetCalorimeter("EMCAL");
90   if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
91   else               emcalQA->SwitchOffDataMC() ;
92   emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
93   emcalQA->SwitchOffFiducialCut();
94   emcalQA->SwitchOnCorrelation();
95   emcalQA->SwitchOffFillAllTH3Histogram();
96   emcalQA->SwitchOffFillAllPositionHistogram();
97   emcalQA->SwitchOffFillAllPositionHistogram2();
98   emcalQA->SwitchOnStudyBadClusters();
99
100   //Set Histrograms bins and ranges
101   emcalQA->GetHistogramRanges()->SetHistoPtRangeAndNBins(0, 100, 200) ;
102   emcalQA->GetHistogramRanges()->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
103   emcalQA->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-0.71, 0.71, 200) ;
104   
105   if     (year==2010)
106   {  
107     emcalQA->SetNumberOfModules(4); 
108     emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 121*TMath::DegToRad(), 200) ;
109     emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-230,90,120);
110     emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(370,450,40);
111   }
112   else if(year==2011)
113   {            
114     emcalQA->SetNumberOfModules(10); 
115     emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 191*TMath::DegToRad(), 200) ;
116     emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-600,90,200);
117     emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(100,450,100);
118   }
119   else 
120   {
121     emcalQA->SetNumberOfModules(12); 
122     emcalQA->GetHistogramRanges()->SetHistoPhiRangeAndNBins(79*TMath::DegToRad(), 181*TMath::DegToRad(), 200) ; // revise
123     emcalQA->GetHistogramRanges()->SetHistoXRangeAndNBins(-700,90,200); // revise
124     emcalQA->GetHistogramRanges()->SetHistoYRangeAndNBins(50,450,100);  // revise     
125   }
126   
127   emcalQA->GetHistogramRanges()->SetHistoMassRangeAndNBins(0., 1, 400) ;
128   emcalQA->GetHistogramRanges()->SetHistoAsymmetryRangeAndNBins(0., 1. , 10 );
129   emcalQA->GetHistogramRanges()->SetHistoPOverERangeAndNBins(0,10.,100);
130   emcalQA->GetHistogramRanges()->SetHistodEdxRangeAndNBins(0.,200.,200);
131   emcalQA->GetHistogramRanges()->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
132   emcalQA->GetHistogramRanges()->SetHistoTimeRangeAndNBins(300.,900,300);
133   emcalQA->GetHistogramRanges()->SetHistoRatioRangeAndNBins(0.,2.,100);
134   emcalQA->GetHistogramRanges()->SetHistoVertexDistRangeAndNBins(0.,500.,500);
135   emcalQA->GetHistogramRanges()->SetHistoNClusterCellRangeAndNBins(0,500,500);
136   emcalQA->GetHistogramRanges()->SetHistoZRangeAndNBins(-400,400,200);
137   emcalQA->GetHistogramRanges()->SetHistoRRangeAndNBins(400,450,25);
138   emcalQA->GetHistogramRanges()->SetHistoV0SignalRangeAndNBins(0,5000,500);
139   emcalQA->GetHistogramRanges()->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
140   emcalQA->GetHistogramRanges()->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
141         
142   if(kPrintSettings) emcalQA->Print("");        
143   
144   // #### Configure Maker ####
145   AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
146   maker->SetReader(reader);//pointer to reader
147   maker->SetCaloUtils(cu); //pointer to calorimeter utils
148   maker->AddAnalysis(emcalQA,0);
149   maker->SetAnaDebug(-1)  ; // 0 to at least print the event number
150   maker->SwitchOnHistogramsMaker()  ;
151   maker->SwitchOffAODsMaker()  ;
152   if(kPrintSettings) maker->Print("");
153   
154   printf("======================== \n");
155   printf(" End Configuration of Calorimeter QA \n");
156   printf("======================== \n");
157   
158   // Create task
159   //===========================================================================
160   AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CalorimeterPerformance_%s",suffix));
161   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
162   //task->SetDebugLevel(-1);
163   task->SetAnalysisMaker(maker);        
164   task->SetBranches("ESD:AliESDRun.,AliESDHeader"); //just a trick to get Constantin's analysis to work
165   mgr->AddTask(task);
166   
167   //Create containers
168   //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
169   //                                                       AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
170         
171   TString cname;
172   if(outputFile.Length()==0)outputFile = AliAnalysisManager::GetCommonFileName(); 
173   
174   
175   cname = Form("CaloQA_%s", suffix);
176   AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(cname, TList::Class(), 
177                                                              AliAnalysisManager::kOutputContainer, 
178                                                              Form("%s:%s",outputFile.Data(),cname.Data()));
179   
180   cname = Form("CaloQACuts_%s", suffix);
181   AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(cname, TList::Class(), 
182                                                              AliAnalysisManager::kParamContainer, 
183                                                              Form("%s:%s",outputFile.Data(),cname.Data()));
184         //Form("%s:PartCorrCuts",outputfile.Data()));   
185   // Create ONLY the output containers for the data produced by the task.
186   // Get and connect other common input/output containers via the manager as below
187   //==============================================================================
188   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
189   mgr->ConnectOutput (task, 1, cout_pc);
190   mgr->ConnectOutput (task, 2, cout_cuts);
191   
192   return task;
193 }
194
195