35 #include <TClonesArray.h> 37 #include <THashList.h> 40 #include <TLorentzVector.h> 42 #include <TObjArray.h> 43 #include <TObjString.h> 44 #include <TParameter.h> 46 #include "AliAnalysisManager.h" 47 #include "AliAnalysisUtils.h" 50 #include "AliEMCALGeometry.h" 52 #include "AliEMCALTriggerPatchInfo.h" 58 #include "AliESDEvent.h" 59 #include "AliInputEventHandler.h" 61 #include "AliMultSelection.h" 62 #include "AliMultEstimator.h" 63 #include "AliVCluster.h" 64 #include "AliVEvent.h" 65 #include "AliVEventHandler.h" 66 #include "AliVVertex.h" 76 AliAnalysisTaskEmcalClustersRef::AliAnalysisTaskEmcalClustersRef() :
78 fCentralityRange(-999., 999.),
79 fRequestCentrality(false),
81 fCentralityEstimator(
"V0M"),
82 fBunchCrossingIndex(-1),
83 fEnergyDefinition(kDefaultEnergy),
85 fDoFillMultiplicityHistograms(false),
86 fUseFiredTriggers(false),
87 fUseExclusiveTriggers(true),
88 fFillTriggerClusters(true),
89 fClusterTimeRange(-50e-6, 50e-6),
123 TLinearBinning smbinning(21, -0.5, 20.5), etabinning(100, -0.7, 0.7), phibinning(200, 0., TMath::TwoPi()), timebinning(1000, -500e-9, 500e-9), ncellbinning(101, -0.5, 100.5);
135 TLinearBinning v0abinning(1000, 0., 1000.), centralitybinning(100, 0., 100.), trackletbinning(500, 0., 500.), itsclustbinning(500, 0., 500.),
136 emcclustbinning(100, 0., 100.), emccellbinning(3000, 0., 3000.), adcbinning(2000, 0., 2000.);
137 const TBinning *multbinning[6] = {&v0abinning, &trackletbinning, &trackletbinning, &itsclustbinning, &emcclustbinning, &emccellbinning};
138 const TBinning *clustallbinning[6] = {&smbinning, ¢ralitybinning, &energybinning, &etabinning, &phibinning, &trgclustbinning};
139 AliDebugStream(1) <<
"Using exclusive triggers: " << (
fUseExclusiveTriggers ?
"yes" :
"no") << std::endl;
141 AliDebugStream(1) <<
"Creating histograms for trigger " << trg << std::endl;
142 fHistos->
CreateTH1(
"hTrgClustCounter" + trg,
"Event counter in trigger cluster " + trg, trgclustbinning);
143 fHistos->
CreateTH1(
"hEventCentrality" + trg,
"Event centrality for trigger class " + trg, 103, -2., 101., optionstring);
144 fHistos->
CreateTH1(
"hVertexZ" + trg,
"z-position of the primary vertex for trigger class " + trg, 200, -40., 40., optionstring);
146 fHistos->
CreateTHnSparse(
"hClusterTHnSparseAll" + trg,
"Cluster THnSparse (all) for trigger" + trg, 6, clustallbinning);
147 fHistos->
CreateTHnSparse(
"hClusterTHnSparseMax" + trg,
"Cluster THnSparse (max) for trigger" + trg, 6, clustallbinning);
149 fHistos->
CreateTH2(
"hTimeEnergy" + trg,
"Cluster time vs. energy for trigger class " + trg, timebinning, energybinning, optionstring);
150 fHistos->
CreateTH2(
"hNCellEnergy" + trg,
"Cluster number of cells vs energy for trigger class " + trg, ncellbinning, energybinning, optionstring);
152 fHistos->
CreateTH2(
"hCorrClusterEPatchADC" + trg,
"Correlation between cluster E and patch ADC for trigger " + trg, energybinning, adcbinning);
153 fHistos->
CreateTH2(
"hCorrClusterEPatchE" + trg,
"Correlation between cluster E and patch E for trigger " + trg, energybinning, energybinning);
161 AliMultSelection *mult =
dynamic_cast<AliMultSelection *
>(InputEvent()->FindListObject(
"MultSelection"));
163 AliErrorStream() << GetName() <<
": Centrality selection enabled but no centrality estimator found" << std::endl;
166 if(mult->IsEventSelected())
return false;
168 AliDebugStream(1) << GetName() <<
": Centrality " <<
fEventCentrality << std::endl;
170 AliDebugStream(1) << GetName() <<
": reject centrality: " <<
fEventCentrality << std::endl;
173 AliDebugStream(1) << GetName() <<
": select centrality " <<
fEventCentrality << std::endl;
176 AliDebugStream(1) << GetName() <<
": No centrality selection applied" << std::endl;
180 int bcindex = fInputEvent->GetHeader()->GetBunchCrossNumber() % 4;
189 auto trgstr =
static_cast<TObjString *
>(t)->String();
195 if(!allFound)
return false;
201 auto trgstr =
static_cast<TObjString *
>(t)->String();
207 if(oneFound)
return false;
216 Bool_t isCENT(
false), isCENTNOTRD(
false), isCALO(
false), isCALOFAST(
false);
218 auto trgclust = trg.Triggercluster();
219 if(trgclust ==
"CENT" && !isCENT){
223 if(trgclust ==
"CENTNOTRD" && ! isCENTNOTRD){
227 if(trgclust ==
"CALO" && !isCALO){
231 if(trgclust ==
"CALOFAST" && ! isCALOFAST) {
237 if(isCENT || isCENTNOTRD) {
243 if(isCALO || isCALOFAST){
255 AliDebugStream(1) << GetName() <<
": UserExec start" << std::endl;
257 std::map<TString, const TList *> patchhandlers;
258 const std::vector<TString> l1triggers = {
"EJ1",
"EJ2",
"EG1",
"EG2",
"DJ1",
"DJ2",
"DG1",
"DG2"};
261 if(
auto trgsel = static_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject(
"EmcalTriggerDecision"))){
268 for(
auto t : l1triggers){
269 auto decision = trgsel->FindTriggerDecision(t.Data());
271 patchhandlers[t] = decision->GetAcceptedPatches();
273 switch(decision->GetSelectionCuts()->GetSelectionMethod()){
285 const TList *selpatches(
nullptr);
286 AliVCluster *maxcluster =
nullptr;
289 if(!clust->IsEMCAL())
continue;
290 if(clust->GetIsExotic())
continue;
292 if(!maxcluster || clust->E() > maxcluster->E()) maxcluster = clust;
297 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: default" << std::endl;
301 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for non-linearity" << std::endl;
302 energy = clust->GetNonLinCorrEnergy();
305 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for hadronic contribution" << std::endl;
306 energy = clust->GetHadCorrEnergy();
310 AliDebugStream(2) << GetName() <<
": Using energy " << energy <<
" (def: " << clust->E()
311 <<
" | NL: " << clust->GetNonLinCorrEnergy()
312 <<
" | HD: " << clust->GetHadCorrEnergy()
315 TLorentzVector posvec;
316 clust->GetMomentum(posvec,
fVertex);
320 if(phi < 0) phi += TMath::TwoPi();
324 if(std::find(supportedTriggers.begin(), supportedTriggers.end(), trg) == supportedTriggers.end())
continue;
325 selpatches =
nullptr;
326 for(
auto t : l1triggers) {
327 if(trg.Contains(t)) {
328 auto patchdata = patchhandlers.find(t);
329 if(patchdata != patchhandlers.end()){
330 selpatches = patchdata->second;
344 maxpoint[2] = maxcluster->E();
345 TLorentzVector maxvector;
346 maxcluster->GetMomentum(maxvector,
fVertex);
347 maxpoint[3] = maxvector.Eta();
348 maxpoint[4] = maxvector.Phi();
349 if(maxpoint[4] < 0) maxpoint[4] += TMath::TwoPi();
350 Int_t supermoduleID = -1;
351 fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
352 maxpoint[0] = supermoduleID;
357 maxpoint[5] = trgclust;
365 std::vector<AliEMCALTriggerPatchInfo *> matchedPatches;
369 auto hasTriggerPatch = matchedPatches.size() > 0;
370 Int_t supermoduleID = -1;
372 AliDebugStream(1) << GetName() <<
": Using weight " << weight <<
" for trigger " << triggerclass << std::endl;
374 fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
375 double point[6] = {
static_cast<double>(supermoduleID),
fEventCentrality, energy, eta, phi, static_cast<double>(trgcluster)};
378 fHistos->
FillTH2(
"hTimeEnergy" + triggerclass, clustertime, energy, weight);
379 fHistos->
FillTH2(
"hNCellEnergy" + triggerclass, ncell, energy, weight);
382 AliEMCALTriggerPatchInfo *maxpatch(
nullptr);
383 double maxenergy = 0;
384 for(
auto patch : matchedPatches) {
387 case 0: patche = patch->GetADCAmp();
break;
388 case 1: patche = patch->GetPatchE();
break;
389 case 2: patche = patch->GetSmearedEnergy();
break;
391 if(patche > maxenergy) {
396 fHistos->
FillTH2(
"hCorrClusterEPatchADC" + triggerclass, energy, maxpatch->GetADCAmp());
397 fHistos->
FillTH2(
"hCorrClusterEPatchE" + triggerclass, energy, maxpatch->GetPatchE());
403 double v0amult = fInputEvent->GetVZEROData()->GetMTotV0A(),
404 trackletmult =
static_cast<double>(
CountTracklets(-0.8, 0.8, 0., TMath::TwoPi())),
405 emctrackletmult = static_cast<double>(
CountTracklets(-0.8, 0.8, 1.4, TMath::Pi())),
406 itsclustermult = fInputEvent->GetMultiplicity()->GetNumberOfSPDClusters(),
413 if(std::find(supportedTriggers.begin(), supportedTriggers.end(), t) == supportedTriggers.end())
continue;
419 fHistos->
FillTH1(
"hTrgClustCounter" + t, static_cast<double>(trgclust), weight);
424 double data[6] = {v0amult, trackletmult, emctrackletmult, itsclustermult, emcclustermult, emccellocc};
431 std::vector<AliEMCALTriggerPatchInfo *> foundpatches;
432 for(
auto patchIter : triggerPatches){
434 auto testpatch =
static_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
437 etamax = TMath::Max(boundaries[0], boundaries[1]),
438 phimin = TMath::Min(boundaries[2], boundaries[3]),
439 phimax = TMath::Max(boundaries[2], boundaries[3]);
440 if(etaclust > etamin && etaclust < etamax && phiclust >
phimin && phiclust < phimax){
441 foundpatches.push_back(testpatch);
449 boundaries[0] = patch.GetEtaMin();
450 boundaries[1] = patch.GetEtaMax();
451 boundaries[2] = patch.GetPhiMin();
452 boundaries[3] = patch.GetPhiMax();
458 if(!clust->IsEMCAL())
continue;
459 if(clust->GetIsExotic())
continue;
460 if(clust->E() > ecut) nclusters++;
468 AliVMultiplicity *mult = fInputEvent->GetMultiplicity();
469 for(
int itl = 0; itl < mult->GetNumberOfTracklets(); itl++){
470 double eta = mult->GetEta(itl), phi = mult->GetPhi(itl);
471 if(!(eta > etamin && eta < etamax))
continue;
472 if(!(phi > phimin && phi < phimax))
continue;
479 std::set<int> cellIDs;
480 AliVCaloCells *emccells = fInputEvent->GetEMCALCells();
481 for(
short icell = 0; icell < emccells->GetNumberOfCells(); icell++){
482 if(emccells->GetAmplitude(icell) > ecut){
483 int cellID = emccells->GetCellNumber(icell);
484 if(cellIDs.find(cellID) == cellIDs.end()) cellIDs.insert(cellID);
487 return cellIDs.size();
516 TString outfile(mgr->GetCommonFileName());
517 outfile +=
":ClusterQA_" +
TString(suffix);
519 printf(
"Outfile: %s, container: %s\n", outfile.Data(), containername.Data());
521 task->ConnectInput(0, mgr->GetCommonInputContainer());
522 mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
550 TString outfile(mgr->GetCommonFileName());
551 outfile +=
":ClusterQA";
553 task->ConnectInput(0, mgr->GetCommonInputContainer());
554 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
TObjArray fRequiredOverlaps
Add option to require overlap with certain triggers.
THistManager * fHistos
Task Histogram container.
int CountEmcalClusters(double ecut)
Double_t GetTriggerWeight(const TString &triggerclass) const
void AddExcludedTriggerOverlap(const char *trigger)
Add trigger for which overlap is excluded.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
TObjArray fExcludedOverlaps
Add option to exclude overlap with certain triggers.
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.
static std::vector< PWG::EMCAL::Triggerinfo > DecodeTriggerString(const std::string &triggerstring)
Decoding trigger string.
void SetOfflineTriggerSelection(AliEmcalTriggerOfflineSelection *sel)
Set an offline trigger selection.
void AddRequiredTriggerOverlap(const char *trigger)
Add trigger for which overlap is required.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
Bool_t fDoFillMultiplicityHistograms
Swich for multiplcity histograms.
std::vector< TriggerCluster_t > fTriggerClusters
! Detected trigger clusters for event
void FillClusterHistograms(const TString &triggerclass, double energy, double eta, double phi, double clustertime, int ncell, int trgcluster, const TList *triggerpatches, int energycomp)
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.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
Helper class creating user defined custom binning.
Bool_t fFillTriggerClusters
Fill trigger cluster histograms.
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.
Bool_t fUseFiredTriggers
Study clusters connected with patches.
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.