20 #include <TClonesArray.h>
23 #include <THashList.h>
26 #include "AliAnalysisUtils.h"
27 #include "AliESDEvent.h"
28 #include "AliEMCALTriggerPatchInfo.h"
30 #include "AliInputEventHandler.h"
32 #include "AliMultSelection.h"
33 #include "AliMultEstimator.h"
39 namespace EMCalTriggerPtAnalysis {
44 AliAnalysisTaskEmcalPatchesRef::AliAnalysisTaskEmcalPatchesRef() :
47 fTriggerSelection(NULL),
49 fRequestAnalysisUtil(kTRUE),
50 fTriggerStringFromPatches(kFALSE),
51 fCentralityRange(-999., 999.),
52 fVertexRange(-999., 999.),
53 fRequestCentrality(
false)
61 AliAnalysisTaskEmcalPatchesRef::AliAnalysisTaskEmcalPatchesRef(
const char *name):
62 AliAnalysisTaskSE(name),
64 fTriggerSelection(NULL),
66 fRequestAnalysisUtil(kTRUE),
67 fTriggerStringFromPatches(kFALSE),
68 fCentralityRange(-999., 999.),
69 fVertexRange(-999., 999.),
70 fRequestCentrality(
false)
72 DefineOutput(1, TList::Class());
78 AliAnalysisTaskEmcalPatchesRef::~AliAnalysisTaskEmcalPatchesRef() {
86 void AliAnalysisTaskEmcalPatchesRef::UserCreateOutputObjects(){
87 AliInfoStream() <<
"Creating histograms for task " << GetName() << std::endl;
88 fAnalysisUtil =
new AliAnalysisUtils;
90 EnergyBinning energybinning;
93 TString triggers[18] = {
"MB",
"EMC7",
"DMC7",
94 "EJ1",
"EJ2",
"EG1",
"EG2",
"DJ1",
"DJ2",
"DG1",
"DG2",
95 "MBexcl",
"EMC7excl",
"DMC7excl",
"EG2excl",
"EJ2excl",
"DG2excl",
"DJ2excl"
97 TString patchtype[10] = {
"EG1",
"EG2",
"EJ1",
"EJ2",
"EMC7",
"DG1",
"DG2",
"DJ1",
"DJ2",
"DMC7"};
98 Double_t encuts[5] = {1., 2., 5., 10., 20.};
99 for(TString *trg = triggers; trg < triggers+18; trg++){
100 fHistos->CreateTH1(Form(
"hEventCount%s", trg->Data()), Form(
"Event count for trigger class %s", trg->Data()), 1, 0.5, 1.5);
101 fHistos->CreateTH1(Form(
"hEventCentrality%s", trg->Data()), Form(
"Event centrality for trigger class %s", trg->Data()), 103, -2., 101.);
102 for(
int ipatch = 0; ipatch < 10; ipatch++){
103 fHistos->CreateTH1(Form(
"h%sPatchEnergy%s", patchtype[ipatch].
Data(), trg->Data()), Form(
"%s-patch energy for trigger class %s", patchtype[ipatch].
Data(), trg->Data()), energybinning);
104 fHistos->CreateTH1(Form(
"h%sPatchET%s", patchtype[ipatch].
Data(), trg->Data()), Form(
"%s-patch transverse energy for trigger class %s", patchtype[ipatch].
Data(), trg->Data()), energybinning);
105 fHistos->CreateTH2(Form(
"h%sPatchEnergyEta%s", patchtype[ipatch].
Data(), trg->Data()), Form(
"%s-patch energy for trigger class %s", patchtype[ipatch].
Data(), trg->Data()), energybinning, etabinning);
106 fHistos->CreateTH2(Form(
"h%sPatchETEta%s", patchtype[ipatch].
Data(), trg->Data()), Form(
"%s-patch transverse energy for trigger class %s", patchtype[ipatch].
Data(), trg->Data()), energybinning, etabinning);
107 for(
int ien = 0; ien < 5; ien++){
108 fHistos->CreateTH2(Form(
"h%sEtaPhi%dG%s", patchtype[ipatch].
Data(), static_cast<int>(encuts[ien]), trg->Data()), Form(
"%s-patch #eta-#phi map for patches with energy larger than %f GeV/c for trigger class %s", patchtype[ipatch].
Data(), encuts[ien], trg->Data()), 100, -0.7, 0.7, 200, 0, TMath::TwoPi());
109 fHistos->CreateTH2(Form(
"h%sColRow%dG%s", patchtype[ipatch].
Data(), static_cast<int>(encuts[ien]), trg->Data()), Form(
"%s-patch col-row map for patches with energy larger than %f GeV/c for trigger class %s", patchtype[ipatch].
Data(), encuts[ien], trg->Data()), 48, -0.5, 47.5, 104, -0.5, 103.5);
113 PostData(1, fHistos->GetListOfHistograms());
114 AliDebugStream(1) <<
"Histograms done" << std::endl;
121 void AliAnalysisTaskEmcalPatchesRef::UserExec(Option_t *){
122 AliDebugStream(1) << GetName() <<
": Start function" << std::endl;
123 TClonesArray *patches =
dynamic_cast<TClonesArray *
>(fInputEvent->FindListObject(
"EmcalTriggers"));
124 TString triggerstring =
"";
125 if(fTriggerStringFromPatches){
126 triggerstring = GetFiredTriggerClassesFromPatches(patches);
128 triggerstring = fInputEvent->GetFiredTriggerClasses();
130 UInt_t selectionstatus = fInputHandler->IsEventSelected();
131 Bool_t isMinBias = selectionstatus & AliVEvent::kINT7,
132 isEMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains(
"EMC7"),
133 isEJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains(
"EJ1"),
134 isEJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains(
"EJ2"),
135 isEG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains(
"EG1"),
136 isEG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains(
"EG2"),
137 isDMC7 = (selectionstatus & AliVEvent::kEMC7) && triggerstring.Contains(
"DMC7"),
138 isDJ1 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains(
"DJ1"),
139 isDJ2 = (selectionstatus & AliVEvent::kEMCEJE) && triggerstring.Contains(
"DJ2"),
140 isDG1 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains(
"DG1"),
141 isDG2 = (selectionstatus & AliVEvent::kEMCEGA) && triggerstring.Contains(
"DG2");
142 if(patches && fTriggerSelection){
143 isEMC7 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEL0, patches);
144 isEJ1 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ1, patches);
145 isEJ2 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEJ2, patches);
146 isEG1 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG1, patches);
147 isEG2 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgEG2, patches);
148 isDMC7 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgDL0, patches);
149 isDJ1 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgDJ1, patches);
150 isDJ2 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgDJ2, patches);
151 isDG1 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgDG1, patches);
152 isDG2 &= fTriggerSelection->IsOfflineSelected(AliEmcalTriggerOfflineSelection::kTrgDG2, patches);
155 if(!(isMinBias || isEMC7 || isEG1 || isEG2 || isEJ1 || isEJ2 || isDMC7 || isDG1 || isDG2 || isDJ1 || isDJ2)){
156 AliDebugStream(1) << GetName() <<
": Reject trigger" << std::endl;
159 AliDebugStream(1) <<
"Event selected" << std::endl;
160 AliMultSelection *mult =
dynamic_cast<AliMultSelection *
>(InputEvent()->FindListObject(
"MultSelection"));
163 if(fRequestCentrality){
164 if(mult && !mult->IsEventSelected())
return;
166 double centrality = mult ? mult->GetEstimator(
"V0M")->GetPercentile() : -1;
167 AliDebugStream(1) << GetName() <<
": Centrality " << centrality << std::endl;
168 if(!fCentralityRange.IsInRange(centrality)){
169 AliDebugStream(1) << GetName() <<
": reject centrality: " << centrality << std::endl;
172 AliDebugStream(1) << GetName() <<
": select centrality " << centrality << std::endl;
174 const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
175 if(!vtx) vtx = fInputEvent->GetPrimaryVertexSPD();
177 if(vtx->GetNContributors() < 1){
178 AliDebug(1, Form(
"%s: Reject contributor\n", GetName()));
182 if(fRequestAnalysisUtil){
183 AliDebugStream(1) << GetName() <<
": Reject analysis util" << std::endl;
184 if(fInputEvent->IsA() == AliESDEvent::Class() && fAnalysisUtil->IsFirstEventInChunk(fInputEvent))
return;
185 if(!fAnalysisUtil->IsVertexSelected2013pA(fInputEvent))
return;
186 if(fAnalysisUtil->IsPileUpEvent(fInputEvent))
return;
189 if(!fVertexRange.IsInRange(vtx->GetZ())){
190 AliDebugStream(1) << GetName() <<
": Reject Z(" << vtx->GetZ() <<
")" << std::endl;
193 AliDebugStream(1) << GetName() <<
": Event Selected" << std::endl;
197 fHistos->FillTH1(
"hEventCountMB", 1);
198 fHistos->FillTH1(
"hEventCentralityMB", centrality);
200 if(!(isEMC7 || isDMC7 || isEJ1 || isEJ2 || isEG1 || isEG2 || isDJ1 || isDJ2 || isDG1 || isDG2)){
201 fHistos->FillTH1(
"hEventCountMBexcl", 1);
202 fHistos->FillTH1(
"hEventCentralityMBexcl", centrality);
208 fHistos->FillTH1(
"hEventCountEMC7", 1);
209 fHistos->FillTH1(
"hEventCentralityEMC7", centrality);
210 if(!(isEJ1 || isEJ2 || isEG1 || isEG2)){
211 fHistos->FillTH1(
"hEventCountEMC7excl", 1);
212 fHistos->FillTH1(
"hEventCentralityEMC7excl", centrality);
216 fHistos->FillTH1(
"hEventCountDMC7", 1);
217 fHistos->FillTH1(
"hEventCentralityDMC7", centrality);
218 if(!(isDJ1 || isDJ2 || isDG1 || isDG2)){
219 fHistos->FillTH1(
"hEventCountDMC7excl", 1);
220 fHistos->FillTH1(
"hEventCentralityDMC7excl", centrality);
226 fHistos->FillTH1(
"hEventCountEJ1", 1);
227 fHistos->FillTH1(
"hEventCentralityEJ1", centrality);
230 fHistos->FillTH1(
"hEventCountEJ1", 1);
231 fHistos->FillTH1(
"hEventCentralityDJ1", centrality);
235 fHistos->FillTH1(
"hEventCountEJ2", 1);
236 fHistos->FillTH1(
"hEventCentralityEJ2", centrality);
239 fHistos->FillTH1(
"hEventCountEJ2excl", 1);
240 fHistos->FillTH1(
"hEventCentralityEJ2excl", centrality);
244 fHistos->FillTH1(
"hEventCountDJ2", 1);
245 fHistos->FillTH1(
"hEventCentralityDJ2", centrality);
248 fHistos->FillTH1(
"hEventCountDJ2excl", 1);
249 fHistos->FillTH1(
"hEventCentralityDJ2excl", centrality);
255 fHistos->FillTH1(
"hEventCountEG1", 1);
256 fHistos->FillTH1(
"hEventCentralityEG1", centrality);
259 fHistos->FillTH1(
"hEventCountDG1", 1);
260 fHistos->FillTH1(
"hEventCentralityDG1", centrality);
263 fHistos->FillTH1(
"hEventCountEG2", 1);
264 fHistos->FillTH1(
"hEventCentralityEG2", centrality);
267 fHistos->FillTH1(
"hEventCountEG2excl", 1);
268 fHistos->FillTH1(
"hEventCentralityEG2excl", centrality);
272 fHistos->FillTH1(
"hEventCountDG2", 1);
273 fHistos->FillTH1(
"hEventCentralityDG2", centrality);
276 fHistos->FillTH1(
"hEventCountDG2excl", 1);
277 fHistos->FillTH1(
"hEventCentralityDG2excl", centrality);
282 AliErrorStream() << GetName() <<
": Trigger patch container not available" << std::endl;
286 AliDebugStream(1) << GetName() <<
": Number of trigger patches " << patches->GetEntries() << std::endl;
288 Double_t vertexpos[3];
289 fInputEvent->GetPrimaryVertex()->GetXYZ(vertexpos);
291 Double_t
energy, eta, phi, et;
293 for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
294 if(!IsOfflineSimplePatch(*patchIter))
continue;
295 AliEMCALTriggerPatchInfo *patch =
static_cast<AliEMCALTriggerPatchInfo *
>(*patchIter);
297 bool isDCAL = SelectDCALPatch(*patchIter),
298 isSingleShower = SelectSingleShowerPatch(*patchIter),
299 isJetPatch = SelectJetPatch(*patchIter);
301 std::vector<TString> patchnames;
304 patchnames.push_back(
"DJ1");
305 patchnames.push_back(
"DJ2");
307 patchnames.push_back(
"EJ1");
308 patchnames.push_back(
"EJ2");
313 patchnames.push_back(
"DMC7");
314 patchnames.push_back(
"DG1");
315 patchnames.push_back(
"DG2");
317 patchnames.push_back(
"EMC7");
318 patchnames.push_back(
"EG1");
319 patchnames.push_back(
"EG2");
322 if(!patchnames.size()){
327 TLorentzVector posvec;
328 energy = patch->GetPatchE();
329 eta = patch->GetEtaGeo();
330 phi = patch->GetPhiGeo();
331 col = patch->GetColStart();
332 row = patch->GetRowStart();
333 et = patch->GetLorentzVectorCenterGeo().Et();
336 for(std::vector<TString>::iterator nameit = patchnames.begin(); nameit != patchnames.end(); ++nameit){
338 FillPatchHistograms(
"MB", *nameit, energy, et, eta, phi, col, row);
340 if(!(isEMC7 || isDMC7 || isEJ1 || isEJ2 || isEG1 || isEG2 || isDJ1 || isDJ2 || isDG1 || isDG2)){
341 FillPatchHistograms(
"MBexcl", *nameit, energy, et, eta, phi, col, row);
346 FillPatchHistograms(
"EMC7", *nameit, energy, et, eta, phi, col, row);
347 if(!(isEJ1 || isEJ2 || isEG1 || isEG2)){
348 FillPatchHistograms(
"EMC7excl", *nameit, energy, et, eta, phi, col, row);
352 FillPatchHistograms(
"DMC7", *nameit, energy, et, eta, phi, col, row);
353 if(!(isDJ1 || isDJ2 || isDG1 || isDG2)){
354 FillPatchHistograms(
"DMC7excl", *nameit, energy, et, eta, phi, col, row);
359 FillPatchHistograms(
"EJ1", *nameit, energy, et, eta, phi, col, row);
362 FillPatchHistograms(
"DJ1", *nameit, energy, et, eta, phi, col, row);
367 FillPatchHistograms(
"EJ2", *nameit, energy, et, eta, phi, col, row);
370 FillPatchHistograms(
"EJ2excl", *nameit, energy, et, eta, phi, col, row);
374 FillPatchHistograms(
"DJ2", *nameit, energy, et, eta, phi, col, row);
377 FillPatchHistograms(
"DJ2excl", *nameit, energy, et, eta, phi, col, row);
382 FillPatchHistograms(
"EG1", *nameit, energy, et, eta, phi, col, row);
385 FillPatchHistograms(
"DG1", *nameit, energy, et, eta, phi, col, row);
389 FillPatchHistograms(
"EG2", *nameit, energy, et, eta, phi, col, row);
392 FillPatchHistograms(
"EG2excl", *nameit, energy, et, eta, phi, col, row);
396 FillPatchHistograms(
"DG2", *nameit, energy, et, eta, phi, col, row);
399 FillPatchHistograms(
"DG2excl", *nameit, energy, et, eta, phi, col, row);
404 PostData(1, fHistos->GetListOfHistograms());
415 void AliAnalysisTaskEmcalPatchesRef::FillPatchHistograms(TString triggerclass, TString patchname,
double energy,
double transverseenergy,
double eta,
double phi,
int col,
int row){
416 fHistos->FillTH1(Form(
"h%sPatchEnergy%s", patchname.Data(), triggerclass.Data()), energy);
417 fHistos->FillTH1(Form(
"h%sPatchET%s", patchname.Data(), triggerclass.Data()), transverseenergy);
418 fHistos->FillTH2(Form(
"h%sPatchEnergyEta%s", patchname.Data(), triggerclass.Data()), energy, eta);
419 fHistos->FillTH2(Form(
"h%sPatchETEta%s", patchname.Data(), triggerclass.Data()), transverseenergy, eta);
420 Double_t encuts[5] = {1., 2., 5., 10., 20.};
421 for(
int ien = 0; ien < 5; ien++){
422 if(energy > encuts[ien]){
423 fHistos->FillTH2(Form(
"h%sEtaPhi%dG%s", patchname.Data(),
static_cast<int>(encuts[ien]), triggerclass.Data()), eta, phi);
424 fHistos->FillTH2(Form(
"h%sColRow%dG%s", patchname.Data(),
static_cast<int>(encuts[ien]), triggerclass.Data()), col, row);
434 TString AliAnalysisTaskEmcalPatchesRef::GetFiredTriggerClassesFromPatches(
const TClonesArray* triggerpatches)
const {
435 TString triggerstring =
"";
436 if(!triggerpatches)
return triggerstring;
437 Int_t nEJ1 = 0, nEJ2 = 0, nEG1 = 0, nEG2 = 0, nDJ1 = 0, nDJ2 = 0, nDG1 = 0, nDG2 = 0;
438 double minADC_J1 = 260.,
442 for(TIter patchIter = TIter(triggerpatches).Begin(); patchIter != TIter::End(); ++patchIter){
443 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(*patchIter);
444 if(!patch->IsOfflineSimple())
continue;
445 if(patch->IsJetHighSimple() && patch->GetADCOfflineAmp() > minADC_J1){
446 if(patch->IsDCalPHOS()) nDJ1++;
449 if(patch->IsJetLowSimple() && patch->GetADCOfflineAmp() > minADC_J2){
450 if(patch->IsDCalPHOS()) nDJ2++;
453 if(patch->IsGammaHighSimple() && patch->GetADCOfflineAmp() > minADC_G1){
454 if(patch->IsDCalPHOS()) nDG1++;
457 if(patch->IsGammaLowSimple() && patch->GetADCOfflineAmp() > minADC_G2){
458 if(patch->IsDCalPHOS()) nDG2++;
462 if(nEJ1) triggerstring +=
"EJ1";
464 if(triggerstring.Length()) triggerstring +=
",";
465 triggerstring +=
"EJ2";
468 if(triggerstring.Length()) triggerstring +=
",";
469 triggerstring +=
"EG1";
472 if(triggerstring.Length()) triggerstring +=
",";
473 triggerstring +=
"EG2";
476 if(triggerstring.Length()) triggerstring +=
",";
477 triggerstring +=
"DJ1";
480 if(triggerstring.Length()) triggerstring +=
",";
481 triggerstring +=
"DJ2";
484 if(triggerstring.Length()) triggerstring +=
",";
485 triggerstring +=
"DG1";
488 if(triggerstring.Length()) triggerstring +=
",";
489 triggerstring +=
"DG2";
491 return triggerstring;
494 void AliAnalysisTaskEmcalPatchesRef::GetPatchBoundaries(TObject *o, Double_t *boundaries)
const {
495 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
496 boundaries[0] = patch->GetEtaMin();
497 boundaries[1] = patch->GetEtaMax();
498 boundaries[2] = patch->GetPhiMin();
499 boundaries[3] = patch->GetPhiMax();
502 bool AliAnalysisTaskEmcalPatchesRef::IsOfflineSimplePatch(TObject *o)
const {
503 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
504 return patch->IsOfflineSimple();
507 bool AliAnalysisTaskEmcalPatchesRef::SelectDCALPatch(TObject *o)
const {
508 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
509 return patch->GetRowStart() >= 64;
512 bool AliAnalysisTaskEmcalPatchesRef::SelectSingleShowerPatch(TObject *o)
const{
513 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
514 if(!patch->IsOfflineSimple())
return false;
515 return patch->IsGammaLowSimple();
518 bool AliAnalysisTaskEmcalPatchesRef::SelectJetPatch(TObject *o)
const{
519 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
520 if(!patch->IsOfflineSimple())
return false;
521 return patch->IsJetLowSimple();
524 double AliAnalysisTaskEmcalPatchesRef::GetPatchEnergy(TObject *o)
const {
526 AliEMCALTriggerPatchInfo *patch =
dynamic_cast<AliEMCALTriggerPatchInfo *
>(o);
527 energy = patch->GetPatchE();
531 AliAnalysisTaskEmcalPatchesRef::EnergyBinning::EnergyBinning():
534 this->SetMinimum(0.);
535 this->AddStep(1., 0.05);
536 this->AddStep(2., 0.1);
537 this->AddStep(4, 0.2);
538 this->AddStep(7, 0.5);
539 this->AddStep(16, 1);
540 this->AddStep(32, 2);
541 this->AddStep(40, 4);
542 this->AddStep(50, 5);
543 this->AddStep(100, 10);
544 this->AddStep(200, 20);
Class creating a linear binning, used in the histogram manager.
ClassImp(EMCalTriggerPtAnalysis::AliAnalysisTaskEmcalPatchesRef) namespace EMCalTriggerPtAnalysis
Helper class creating user defined custom binning.
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Container class for histograms for the high- charged particle analysis.