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