]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/QA/AddTaskCalorimeterQA.C
Change binning of histograms, correct problem with delete of PHOS geometry pointer...
[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   // ##### Analysis algorithm settings ####
59    //Only needed now for MC data
60    //AliFiducialCut * fidCut = new AliFiducialCut();
61    //fidCut->DoCTSFiducialCut(kFALSE) ;
62    //fidCut->DoEMCALFiducialCut(kTRUE) ;
63    //fidCut->DoPHOSFiducialCut(kTRUE) ;
64                 
65   AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
66   //emcalQA->SetDebug(2); //10 for lots of messages
67   emcalQA->SetCalorimeter("EMCAL");
68   if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
69   else  emcalQA->SwitchOffDataMC() ;
70   emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
71   //emcalQA->SetFiducialCut(fidCut);
72   emcalQA->SwitchOffFiducialCut();
73   emcalQA->SwitchOffPlotsMaking();
74   emcalQA->SwitchOnCalorimetersCorrelation();
75   emcalQA->SetTimeCut(550,750);
76   //Set Histrograms bins and ranges
77   emcalQA->SetHistoPtRangeAndNBins(0, 10, 100) ;
78   emcalQA->SetHistoPhiRangeAndNBins(75*TMath::DegToRad(), 125*TMath::DegToRad(), 100) ;
79   emcalQA->SetHistoEtaRangeAndNBins(-0.8, 0.8, 80) ;
80   emcalQA->SetNumberOfModules(4); //EMCAL first year
81   emcalQA->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
82   emcalQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 10) ;
83   emcalQA->SetHistoPOverERangeAndNBins(0,10.,100);
84   emcalQA->SetHistodEdxRangeAndNBins(0.,400.,200);
85   emcalQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
86   emcalQA->SetHistoTimeRangeAndNBins(400.,800,200);
87   emcalQA->SetHistoRatioRangeAndNBins(0.,2.,100);
88   emcalQA->SetHistoVertexDistRangeAndNBins(0.,500.,100);
89   emcalQA->SetHistoNClusterCellRangeAndNBins(0,300,300);
90   emcalQA->SetHistoXRangeAndNBins(-230,90,160);
91   emcalQA->SetHistoYRangeAndNBins(370,450,35);
92   emcalQA->SetHistoZRangeAndNBins(-400,400,100);
93   emcalQA->SetHistoRRangeAndNBins(400,450,25);
94
95   //emcalQA->GetMCAnalysisUtils()->SetDebug(10);
96         
97   if(kPrintSettings) emcalQA->Print("");        
98
99    AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
100    //phosQA->SetDebug(2); //10 for lots of messages
101    phosQA->SetCalorimeter("PHOS");
102    if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
103    else  phosQA->SwitchOffDataMC() ;  
104    phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
105    //phosQA->SetFiducialCut(fidCut);
106    phosQA->SwitchOffFiducialCut();
107    //phosQA->GetMCAnalysisUtils()->SetDebug(10);
108    phosQA->SwitchOffPlotsMaking();
109    //Set Histrograms bins and ranges
110    phosQA->SetHistoPtRangeAndNBins(0, 10, 100) ;
111    phosQA->SetHistoPhiRangeAndNBins(255*TMath::DegToRad(), 325*TMath::DegToRad(), 100) ;
112    phosQA->SetHistoEtaRangeAndNBins(-0.13, 0.13, 80) ;
113    phosQA->SetNumberOfModules(3); //PHOS first year
114    phosQA->SetHistoMassRangeAndNBins(0., 0.6, 200) ;
115    phosQA->SetHistoAsymmetryRangeAndNBins(0., 1. , 25) ;
116    phosQA->SetHistoPOverERangeAndNBins(0,10.,100);
117    phosQA->SetHistodEdxRangeAndNBins(0.,400.,200);
118    phosQA->SetHistodRRangeAndNBins(0.,TMath::Pi(),150);
119    phosQA->SetHistoTimeRangeAndNBins(0.,400,200);
120    phosQA->SetHistoRatioRangeAndNBins(0.,2.,100);
121    phosQA->SetHistoVertexDistRangeAndNBins(0.,500.,100);
122    phosQA->SetHistoNClusterCellRangeAndNBins(0,300,300);
123    phosQA->SetHistoXRangeAndNBins(-100,400,150);
124    phosQA->SetHistoYRangeAndNBins(-490,-290,100);
125    phosQA->SetHistoZRangeAndNBins(-80,80,80);
126    phosQA->SetHistoRRangeAndNBins(440,480,40);
127         
128   //if(kPrintSettings)phosQA->Print("");        
129         
130   // #### Configure Maker ####
131   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
132   maker->SetReader(reader);//pointer to reader
133   maker->AddAnalysis(emcalQA,0);
134   maker->AddAnalysis(phosQA,1);
135   maker->SetAnaDebug(-1)  ; // 0 to at least print the event number
136   maker->SwitchOnHistogramsMaker()  ;
137   maker->SwitchOffAODsMaker()  ;
138   if(kPrintSettings) maker->Print("");
139  
140
141   printf("======================== \n");
142   printf(" End Configuration of Calorimeter QA \n");
143   printf("======================== \n");
144   
145    // Create task
146    //===========================================================================
147   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
148   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
149   //task->SetDebugLevel(-1);
150   task->SelectCollisionCandidates();
151   task->SetAnalysisMaker(maker);        
152   mgr->AddTask(task);
153   
154 //  AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
155 //                                                         AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
156         
157         
158   TString outputfile = AliAnalysisManager::GetCommonFileName(); 
159   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("CaloQA", TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:CaloQA",outputfile.Data()));
160         
161         
162   // Create ONLY the output containers for the data produced by the task.
163   // Get and connect other common input/output containers via the manager as below
164   //==============================================================================
165   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
166   mgr->ConnectOutput (task, 1, cout_pc);
167   
168   return task;
169 }
170
171