35 #include <TClonesArray.h> 37 #include <THashList.h> 40 #include <TLorentzVector.h> 41 #include <TObjArray.h> 42 #include <TParameter.h> 45 #include "AliAnalysisManager.h" 46 #include "AliAnalysisUtils.h" 49 #include "AliEMCALGeometry.h" 51 #include "AliEMCALTriggerPatchInfo.h" 56 #include "AliESDEvent.h" 57 #include "AliInputEventHandler.h" 59 #include "AliMultSelection.h" 60 #include "AliMultEstimator.h" 61 #include "AliVCluster.h" 62 #include "AliVEvent.h" 63 #include "AliVEventHandler.h" 64 #include "AliVVertex.h" 74 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
76 fCentralityRange(-999., 999.),
77 fRequestCentrality(false),
79 fCentralityEstimator(
"V0M"),
80 fBunchCrossingIndex(-1),
81 fEnergyDefinition(kDefaultEnergy),
83 fDoFillMultiplicityHistograms(false),
84 fUseExclusiveTriggers(true),
85 fClusterTimeRange(-50e-6, 50e-6)
111 TLinearBinning smbinning(21, -0.5, 20.5), etabinning(100, -0.7, 0.7), timebinning(1000, -500e-9, 500e-9), ncellbinning(101, -0.5, 100.5);
120 std::array<Double_t, 5> encuts = {1., 2., 5., 10., 20.};
121 Int_t sectorsWithEMCAL[10] = {4, 5, 6, 7, 8, 9, 13, 14, 15, 16};
124 TLinearBinning v0abinning(1000, 0., 1000.), trackletbinning(500, 0., 500.), itsclustbinning(500, 0., 500.), emcclustbinning(100, 0., 100.), emccellbinning(3000, 0., 3000.), adcbinning(2000, 0., 2000.);
125 const TBinning *multbinning[6] = {&v0abinning, &trackletbinning, &trackletbinning, &itsclustbinning, &emcclustbinning, &emccellbinning};
127 fHistos->
CreateTH1(
"hEventCount" + trg,
"Event count for trigger class " + trg, 1, 0.5, 1.5, optionstring);
128 fHistos->
CreateTH1(
"hEventCentrality" + trg,
"Event centrality for trigger class " + trg, 103, -2., 101., optionstring);
129 fHistos->
CreateTH1(
"hVertexZ" + trg,
"z-position of the primary vertex for trigger class " + trg, 200, -40., 40., optionstring);
131 fHistos->
CreateTH1(
"hClusterEnergy" + trg,
"Cluster energy for trigger class " + trg, energybinning, optionstring);
132 fHistos->
CreateTH1(
"hClusterET" + trg,
"Cluster transverse energy for trigger class " + trg, energybinning, optionstring);
133 fHistos->
CreateTH1(
"hClusterEnergyFired" + trg,
"Cluster energy for trigger class " + trg +
", firing the trigger", energybinning, optionstring);
134 fHistos->
CreateTH1(
"hClusterETFired" + trg,
"Cluster transverse energy for trigger class " + trg +
", firing the trigger" , energybinning, optionstring);
135 fHistos->
CreateTH2(
"hClusterEnergySM" + trg,
"Cluster energy versus supermodule for trigger class " + trg, smbinning, energybinning, optionstring);
136 fHistos->
CreateTH2(
"hClusterETSM" + trg,
"Cluster transverse energy versus supermodule for trigger class " + trg, smbinning, energybinning, optionstring);
137 fHistos->
CreateTH2(
"hClusterEnergyFiredSM" + trg,
"Cluster energy versus supermodule for trigger class " + trg +
", firing the trigger" , smbinning, energybinning, optionstring);
138 fHistos->
CreateTH2(
"hClusterETFiredSM" + trg,
"Cluster transverse energy versus supermodule for trigger class " + trg +
", firing the trigger" , smbinning, energybinning, optionstring);
139 fHistos->
CreateTH2(
"hEtaEnergy" + trg,
"Cluster energy vs. eta for trigger class " + trg, etabinning, energybinning, optionstring);
140 fHistos->
CreateTH2(
"hEtaET" + trg,
"Cluster transverse energy vs. eta for trigger class " + trg, etabinning, energybinning, optionstring);
141 fHistos->
CreateTH2(
"hTimeEnergy" + trg,
"Cluster time vs. energy for trigger class " + trg, timebinning, energybinning, optionstring);
142 fHistos->
CreateTH2(
"hNCellEnergy" + trg,
"Cluster number of cells vs energy for trigger class " + trg, ncellbinning, energybinning, optionstring);
143 fHistos->
CreateTH2(
"hNCellET" + trg,
"Cluster number of cells vs transverse energy for trigger class " + trg, ncellbinning, energybinning, optionstring);
144 fHistos->
CreateTH2(
"hEtaEnergyFired" + trg,
"Cluster energy vs. eta for trigger class " + trg +
", firing the trigger", etabinning, energybinning, optionstring);
145 fHistos->
CreateTH2(
"hEtaETFired" + trg,
"Cluster transverse energy vs. eta for trigger class " + trg +
", firing the trigger", etabinning, energybinning, optionstring);
146 fHistos->
CreateTH2(
"hCorrClusterEPatchADC" + trg,
"Correlation between cluster E and patch ADC for trigger " + trg, energybinning, adcbinning);
147 fHistos->
CreateTH2(
"hCorrClusterEPatchE" + trg,
"Correlation between cluster E and patch E for trigger " + trg, energybinning, energybinning);
148 for(
int ism = 0; ism < 20; ism++){
149 fHistos->
CreateTH2(TString::Format(
"hEtaEnergySM%d", ism) + trg, TString::Format(
"Cluster energy vs. eta in Supermodule %d for trigger ", ism) + trg, etabinning, energybinning, optionstring);
150 fHistos->
CreateTH2(TString::Format(
"hEtaETSM%d", ism) + trg, TString::Format(
"Cluster transverse energy vs. eta in Supermodule %d for trigger ", ism) + trg, etabinning, energybinning, optionstring);
151 fHistos->
CreateTH2(TString::Format(
"hEtaEnergyFiredSM%d", ism) + trg, TString::Format(
"Cluster energy vs. eta in Supermodule %d for trigger ", ism) + trg +
", firing the trigger", etabinning, energybinning, optionstring);
152 fHistos->
CreateTH2(TString::Format(
"hEtaETFiredSM%d", ism) + trg, TString::Format(
"Cluster transverse energy vs. eta in Supermodule %d for trigger ", ism) + trg +
", firing the trigger", etabinning, energybinning, optionstring);
154 for(
int isec = 0; isec < 10; isec++){
155 fHistos->
CreateTH2(TString::Format(
"hEtaEnergySec%d", sectorsWithEMCAL[isec]) + trg, TString::Format(
"Cluster energy vs.eta in tracking sector %d for trigger ", sectorsWithEMCAL[isec]) + trg, etabinning, energybinning, optionstring);
156 fHistos->
CreateTH2(TString::Format(
"hEtaETSec%d", sectorsWithEMCAL[isec]) + trg, TString::Format(
"Cluster transverse energy vs.eta in tracking sector %d for trigger ", sectorsWithEMCAL[isec]) + trg, etabinning, energybinning, optionstring);
157 fHistos->
CreateTH2(TString::Format(
"hEtaEnergyFiredSec%d", sectorsWithEMCAL[isec]) + trg, TString::Format(
"Cluster energy vs.eta in tracking sector %d for trigger ", sectorsWithEMCAL[isec]) + trg +
", firing the trigger", etabinning, energybinning, optionstring);
158 fHistos->
CreateTH2(TString::Format(
"hEtaETFiredSec%d", sectorsWithEMCAL[isec]) + trg, TString::Format(
"Cluster transverse energy vs.eta in tracking sector %d for trigger ", sectorsWithEMCAL[isec]) + trg +
", firing the trigger", etabinning, energybinning, optionstring);
160 for(
auto ien : encuts){
161 fHistos->
CreateTH2(TString::Format(
"hEtaPhi%dG", static_cast<int>(ien)) + trg, TString::Format(
"cluster #eta-#phi map for clusters with energy larger than %f GeV/c for trigger class ", ien) + trg, 100, -0.7, 0.7, 200, 0, 2*TMath::Pi(), optionstring);
162 fHistos->
CreateTH2(TString::Format(
"hEtaPhiFired%dG", static_cast<int>(ien)) + trg, TString::Format(
"cluster #eta-#phi map for clusters fired the trigger with energy larger than %f GeV/c for trigger class", ien) + trg +
", firing the trigger", 200, -0.7, 0.7, 200, 0, 2*TMath::Pi(), optionstring);
170 AliMultSelection *mult =
dynamic_cast<AliMultSelection *
>(InputEvent()->FindListObject(
"MultSelection"));
172 AliErrorStream() << GetName() <<
": Centrality selection enabled but no centrality estimator found" << std::endl;
175 if(mult->IsEventSelected())
return false;
177 AliDebugStream(1) << GetName() <<
": Centrality " <<
fEventCentrality << std::endl;
179 AliDebugStream(1) << GetName() <<
": reject centrality: " <<
fEventCentrality << std::endl;
182 AliDebugStream(1) << GetName() <<
": select centrality " <<
fEventCentrality << std::endl;
185 AliDebugStream(1) << GetName() <<
": No centrality selection applied" << std::endl;
189 int bcindex = fInputEvent->GetHeader()->GetBunchCrossNumber() % 4;
196 AliDebugStream(1) << GetName() <<
": UserExec start" << std::endl;
198 std::map<TString, const TList *> patchhandlers;
199 const std::vector<TString> l1triggers = {
"EJ1",
"EJ2",
"EG1",
"EG2",
"DJ1",
"DJ2",
"DG1",
"DG2"};
202 if(
auto trgsel = static_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject(
"EmcalTriggerDecision"))){
209 for(
auto t : l1triggers){
210 auto decision = trgsel->FindTriggerDecision(t.Data());
212 patchhandlers[t] = decision->GetAcceptedPatches();
214 switch(decision->GetSelectionCuts()->GetSelectionMethod()){
226 const TList *selpatches(
nullptr);
229 if(!clust->IsEMCAL())
continue;
230 if(clust->GetIsExotic())
continue;
236 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: default" << std::endl;
240 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for non-linearity" << std::endl;
241 energy = clust->GetNonLinCorrEnergy();
244 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for hadronic contribution" << std::endl;
245 energy = clust->GetHadCorrEnergy();
249 AliDebugStream(2) << GetName() <<
": Using energy " << energy <<
" (def: " << clust->E()
250 <<
" | NL: " << clust->GetNonLinCorrEnergy()
251 <<
" | HD: " << clust->GetHadCorrEnergy()
254 TLorentzVector posvec;
255 clust->GetMomentum(posvec,
fVertex);
263 if(std::find(supportedTriggers.begin(), supportedTriggers.end(), trg) == supportedTriggers.end())
continue;
264 selpatches =
nullptr;
265 for(
auto t : l1triggers) {
266 if(trg.Contains(t)) {
267 auto patchdata = patchhandlers.find(t);
268 if(patchdata != patchhandlers.end()){
269 selpatches = patchdata->second;
280 std::vector<AliEMCALTriggerPatchInfo *> matchedPatches;
284 auto hasTriggerPatch = matchedPatches.size() > 0;
285 Int_t supermoduleID = -1, sector = -1;
287 AliDebugStream(1) << GetName() <<
": Using weight " << weight <<
" for trigger " << triggerclass << std::endl;
289 fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
290 fHistos->
FillTH1(
"hClusterEnergy" + triggerclass, energy, weight);
291 fHistos->
FillTH1(
"hClusterET" + triggerclass, transverseenergy, weight);
292 fHistos->
FillTH2(
"hEtaEnergy" + triggerclass, eta, energy, weight);
293 fHistos->
FillTH2(
"hEtaET" + triggerclass, eta, transverseenergy, weight);
294 fHistos->
FillTH2(
"hTimeEnergy" + triggerclass, clustertime, energy, weight);
295 fHistos->
FillTH2(
"hNCellEnergy" + triggerclass, ncell, energy, weight);
296 fHistos->
FillTH2(
"hNCellET" + triggerclass, ncell, transverseenergy, weight);
297 if(supermoduleID >= 0){
298 fHistos->
FillTH2(
"hClusterEnergySM" + triggerclass, supermoduleID, energy, weight);
299 fHistos->
FillTH2(
"hClusterETSM" + triggerclass, supermoduleID, transverseenergy, weight);
300 fHistos->
FillTH2(TString::Format(
"hEtaEnergySM%d", supermoduleID) + triggerclass, eta, energy, weight);
301 fHistos->
FillTH2(TString::Format(
"hEtaETSM%d", supermoduleID) + triggerclass, eta, transverseenergy, weight);
302 if(supermoduleID < 12)
303 sector = 4 + int(supermoduleID/2);
305 sector = 13 + int((supermoduleID-12)/2);
306 fHistos->
FillTH2(TString::Format(
"hEtaEnergySec%d", sector) + triggerclass, eta, energy, weight);
307 fHistos->
FillTH2(TString::Format(
"hEtaETSec%d", sector) + triggerclass, eta, transverseenergy, weight);
311 AliEMCALTriggerPatchInfo *maxpatch(
nullptr);
312 double maxenergy = 0;
313 for(
auto patch : matchedPatches) {
316 case 0: patche = patch->GetADCAmp();
break;
317 case 1: patche = patch->GetPatchE();
break;
318 case 2: patche = patch->GetSmearedEnergy();
break;
320 if(patche > maxenergy) {
325 fHistos->
FillTH2(
"hCorrClusterEPatchADC" + triggerclass, energy, maxpatch->GetADCAmp());
326 fHistos->
FillTH2(
"hCorrClusterEPatchE" + triggerclass, energy, maxpatch->GetPatchE());
327 fHistos->
FillTH1(
"hClusterEnergyFired" + triggerclass, energy, weight);
328 fHistos->
FillTH1(
"hClusterETFired" + triggerclass, energy, weight);
329 fHistos->
FillTH2(
"hEtaEnergyFired" + triggerclass, eta, energy, weight);
330 fHistos->
FillTH2(
"hEtaETFired" + triggerclass, eta, energy, weight);
331 if(supermoduleID >= 0){
332 fHistos->
FillTH2(
"hClusterEnergyFiredSM" + triggerclass, supermoduleID, energy, weight);
333 fHistos->
FillTH2(
"hClusterETFiredSM" + triggerclass, supermoduleID, transverseenergy, weight);
334 fHistos->
FillTH2(TString::Format(
"hEtaEnergyFiredSM%d", supermoduleID) + triggerclass, eta, energy,weight);
335 fHistos->
FillTH2(TString::Format(
"hEtaETFiredSM%d", supermoduleID) + triggerclass, eta, transverseenergy, weight);
336 fHistos->
FillTH2(TString::Format(
"hEtaEnergyFiredSec%d", sector) + triggerclass, eta, energy, weight);
337 fHistos->
FillTH2(TString::Format(
"hEtaETFiredSec%d", sector) + triggerclass, eta, transverseenergy, weight);
340 Double_t encuts[5] = {1., 2., 5., 10., 20.};
341 for(
int ien = 0; ien < 5; ien++){
342 if(energy > encuts[ien]){
343 fHistos->
FillTH2(TString::Format(
"hEtaPhi%dG", static_cast<int>(encuts[ien])) + triggerclass, eta, phi, weight);
345 fHistos->
FillTH2(TString::Format(
"hEtaPhiFired%dG", static_cast<int>(encuts[ien])) + triggerclass, eta, phi, weight);
352 double v0amult = fInputEvent->GetVZEROData()->GetMTotV0A(),
353 trackletmult =
static_cast<double>(
CountTracklets(-0.8, 0.8, 0., TMath::TwoPi())),
354 emctrackletmult = static_cast<double>(
CountTracklets(-0.8, 0.8, 1.4, TMath::Pi())),
355 itsclustermult = fInputEvent->GetMultiplicity()->GetNumberOfSPDClusters(),
366 double data[6] = {v0amult, trackletmult, emctrackletmult, itsclustermult, emcclustermult, emccellocc};
373 std::vector<AliEMCALTriggerPatchInfo *> foundpatches;
374 for(
auto patchIter : triggerPatches){
376 auto testpatch =
static_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
379 etamax = TMath::Max(boundaries[0], boundaries[1]),
380 phimin = TMath::Min(boundaries[2], boundaries[3]),
381 phimax = TMath::Max(boundaries[2], boundaries[3]);
382 if(etaclust > etamin && etaclust < etamax && phiclust >
phimin && phiclust < phimax){
383 foundpatches.push_back(testpatch);
391 boundaries[0] = patch.GetEtaMin();
392 boundaries[1] = patch.GetEtaMax();
393 boundaries[2] = patch.GetPhiMin();
394 boundaries[3] = patch.GetPhiMax();
400 if(!clust->IsEMCAL())
continue;
401 if(clust->GetIsExotic())
continue;
402 if(clust->E() > ecut) nclusters++;
410 AliVMultiplicity *mult = fInputEvent->GetMultiplicity();
411 for(
int itl = 0; itl < mult->GetNumberOfTracklets(); itl++){
412 double eta = mult->GetEta(itl), phi = mult->GetPhi(itl);
413 if(!(eta > etamin && eta < etamax))
continue;
414 if(!(phi > phimin && phi < phimax))
continue;
421 std::set<int> cellIDs;
422 AliVCaloCells *emccells = fInputEvent->GetEMCALCells();
423 for(
short icell = 0; icell < emccells->GetNumberOfCells(); icell++){
424 if(emccells->GetAmplitude(icell) > ecut){
425 int cellID = emccells->GetCellNumber(icell);
426 if(cellIDs.find(cellID) == cellIDs.end()) cellIDs.insert(cellID);
429 return cellIDs.size();
448 TString outfile(mgr->GetCommonFileName());
449 outfile +=
":ClusterQA_" +
TString(suffix);
451 printf(
"Outfile: %s, container: %s\n", outfile.Data(), containername.Data());
453 task->ConnectInput(0, mgr->GetCommonInputContainer());
454 mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
482 TString outfile(mgr->GetCommonFileName());
483 outfile +=
":ClusterQA";
485 task->ConnectInput(0, mgr->GetCommonInputContainer());
486 mgr->ConnectOutput(task, 1, mgr->CreateContainer(
"ClusterResults", AliEmcalList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
AliCutValueRange< double > fClusterTimeRange
Selected range on cluster time.
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
Class creating a linear binning, used in the histogram manager.
Double_t fEventCentrality
! Current event centrality
THistManager * fHistos
Task Histogram container.
int CountEmcalClusters(double ecut)
Double_t GetTriggerWeight(const TString &triggerclass) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
virtual bool IsUserEventSelected()
User event selection: Select event in maching centrality range (if requested)
Energy corrected for the hadronic contribution.
Simple monitoring task for cluster-related quantities in EMCAL-triggered events.
Char_t fBunchCrossingIndex
Bunch Crossing index.
Bool_t fRequestCentrality
Switch on request for centrality range.
void AddStep(Double_t max, Double_t binwidth)
Interface for binnings used by the histogram handler.
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set an offline trigger selection.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
Bool_t fDoFillMultiplicityHistograms
Swich for multiplcity histograms.
std::vector< AliEMCALTriggerPatchInfo * > CorrelateToTrigger(Double_t etaclust, Double_t phiclust, const TList &triggerpatches) const
Check whether cluster is inside a trigger patch which has fired the trigger.
Base class for analyses using EMCAL triggers.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
AliAnalysisTaskEmcalClustersRef()
Dummy (I/O) constructor.
TString fNameClusterContainer
Name of the cluster container in the event.
virtual void UserFillHistosAfterEventSelection()
AliEMCALGeometry * fGeom
!emcal geometry
Bool_t fEnableSumw2
Enable sumw2 when creating histograms.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
void FillClusterHistograms(const TString &triggerclass, double energy, double transversenergy, double eta, double phi, double clustertime, int ncell, const TList *triggerpatches, int energycomp)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
Helper class creating user defined custom binning.
static AliAnalysisTaskEmcalClustersRef * AddTaskEmcalClustersRef(const TString &nClusters="usedefault", const TString &suffix="")
Preconfigure task so that it can be used in subwagons.
int CountTracklets(double etamin, double etamax, double phimin, double phimax)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
int GetEMCALCellOccupancy(double ecut)
TString fCentralityEstimator
Centrality estimator (default: V0M for PbPb)
Bool_t fUseExclusiveTriggers
Include exclusive triggers (without lower threshold triggers)
void SetClusterContainer(TString clustercontname)
static AliAnalysisTaskEmcalClustersRef * AddTaskEmcalClustersRefDefault(const TString &nClusters="usedefault")
Preconfigure task and add it to the analysis manager.
Analysis of high- tracks in triggered events.
Double_t fVertex[3]
!event vertex
AliCutValueRange< double > fCentralityRange
Selected centrality range.
Uncorrected energy measurement.
EnergyDefinition_t fEnergyDefinition
Energy definition used for a given cluster.
Energy corrected for non-linearity.
virtual void CreateUserHistos()
Creating histograms for the distributions monitored by the task.
virtual ~AliAnalysisTaskEmcalClustersRef()
Destructor.
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
std::vector< TString > GetSupportedTriggers(Bool_t useExclusiveTriggers=true) const
void GetPatchBoundaries(AliEMCALTriggerPatchInfo &o, Double_t *boundaries) const
Get the boundaries of the trigger patch.
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef=AliEmcalTriggerOfflineSelection::kFEEEnergy)
Configures EMCAL trigger offline selection used to restrict EMCAL triggered sample.
bool IsInRange(t value) const
void SetMinimum(Double_t min)
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.