Protection added in case no ESD files have been chained.
[u/mrichter/AliRoot.git] / PWG4 / macros / QA / AddTaskCalorimeterQA.C
CommitLineData
a0bb4dc0 1AliAnalysisTaskParticleCorrelation *AddTaskCalorimeterQA(TString data, Bool_t kUseKinematics = kFALSE, Bool_t kPrintSettings = kFALSE)
2{
3 // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.
4
5 // Get the pointer to the existing analysis manager via the static access method.
6 //==============================================================================
7 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
8 if (!mgr) {
9 ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
10 return NULL;
11 }
12
13 // Check the analysis type using the event handlers connected to the analysis manager.
14 //==============================================================================
15 if (!mgr->GetInputEventHandler()) {
16 ::Error("AddTaskPartCorr", "This task requires an input event handler");
17 return NULL;
18 }
19 TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20
21 // Configure analysis
22 //===========================================================================
23
24 //Reader
25 //For this particular analysis few things done by the reader.
26 //Nothing else needs to be set.
27 AliCaloTrackReader * reader = 0x0;
28 if(data=="AOD") reader = new AliCaloTrackAODReader();
29 else if(data=="ESD") reader = new AliCaloTrackESDReader();
30 //reader->SetDebug(10);//10 for lots of messages
31 if(kPrintSettings) reader->Print("");
32
33 if(kUseKinematics){
34 if(inputDataType == "ESD"){
35 reader->SwitchOnStack();
36 reader->SwitchOffAODMCParticles();
37 }
38 else if(inputDataType == "AOD"){
39 reader->SwitchOffStack();
40 reader->SwitchOnAODMCParticles();
41 }
42 }
43
44 reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
45
46
47 // ##### Analysis algorithm settings ####
48 //Only needed now for MC data
49 //AliFiducialCut * fidCut = new AliFiducialCut();
50 //fidCut->DoCTSFiducialCut(kFALSE) ;
51 //fidCut->DoEMCALFiducialCut(kTRUE) ;
52 //fidCut->DoPHOSFiducialCut(kTRUE) ;
53
54 AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
55 //emcalQA->SetDebug(2); //10 for lots of messages
56 emcalQA->SetCalorimeter("EMCAL");
57 if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
58 else emcalQA->SwitchOffDataMC() ;
59 emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
60 //emcalQA->SetFiducialCut(fidCut);
61 emcalQA->SwitchOffFiducialCut();
62 if(kPrintSettings) emcalQA->Print("");
63 emcalQA->SwitchOnPlotsMaking();
64 emcalQA->SwitchOnCalorimetersCorrelation();
a348c43e 65 //Set Histrograms bins and ranges
66 emcalQA->SetHistoPtRangeAndNBins(0, 10, 100) ;
67 emcalQA->SetHistoPhiRangeAndNBins(75*TMath::DegToRad(), 125*TMath::DegToRad(), 100) ;
68 emcalQA->SetHistoEtaRangeAndNBins(-0.8, 0.8, 160) ;
a5fafd85 69 emcalQA->SetNumberOfModules(4); //EMCAL first year
a0bb4dc0 70 //emcalQA->GetMCAnalysisUtils()->SetDebug(10);
71
72 AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
73 //phosQA->SetDebug(2); //10 for lots of messages
74 phosQA->SetCalorimeter("PHOS");
75 if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
76 else phosQA->SwitchOffDataMC() ;
77 phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
78 //phosQA->SetFiducialCut(fidCut);
79 phosQA->SwitchOffFiducialCut();
80 if(kPrintSettings)phosQA->Print("");
81 //phosQA->GetMCAnalysisUtils()->SetDebug(10);
82 phosQA->SwitchOnPlotsMaking();
a348c43e 83 //Set Histrograms bins and ranges
84 phosQA->SetHistoPtRangeAndNBins(0, 10, 100) ;
85 phosQA->SetHistoPhiRangeAndNBins(215*TMath::DegToRad(), 325*TMath::DegToRad(), 100) ;
86 phosQA->SetHistoEtaRangeAndNBins(-0.13, 0.13, 100) ;
a5fafd85 87 phosQA->SetNumberOfModules(3); //PHOS first year
a348c43e 88
89
a0bb4dc0 90 // #### Configure Maker ####
91 AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
92 maker->SetReader(reader);//pointer to reader
93 maker->AddAnalysis(emcalQA,0);
94 maker->AddAnalysis(phosQA,1);
491e4f8b 95 maker->SetAnaDebug(-1) ;
a0bb4dc0 96 maker->SwitchOnHistogramsMaker() ;
97 maker->SwitchOffAODsMaker() ;
98 if(kPrintSettings) maker->Print("");
99
100
101 printf("======================== \n");
102 printf(" End Configuration of Calorimeter QA \n");
103 printf("======================== \n");
104
105 // Create task
106 //===========================================================================
107 AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
108 task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
109 task->SetDebugLevel(0);
110 task->SetAnalysisMaker(maker);
111 mgr->AddTask(task);
112
113 AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
114 AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
115
116 // Create ONLY the output containers for the data produced by the task.
117 // Get and connect other common input/output containers via the manager as below
118 //==============================================================================
119 mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer());
120 // AOD output slot will be used in a different way in future
121 //mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
122 mgr->ConnectOutput (task, 1, cout_pc);
123
124 return task;
125}
126
127