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 fUseExclusiveTriggers(true),
87 fClusterTimeRange(-50e-6, 50e-6),
119 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);
131 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.);
132 const TBinning *multbinning[6] = {&v0abinning, &trackletbinning, &trackletbinning, &itsclustbinning, &emcclustbinning, &emccellbinning};
133 const TBinning *clustallbinning[6] = {&smbinning, &energybinning, &energybinning, &etabinning, &phibinning, &trgclustbinning};
134 AliDebugStream(1) <<
"Using exclusive triggers: " << (
fUseExclusiveTriggers ?
"yes" :
"no") << std::endl;
136 AliDebugStream(1) <<
"Creating histograms for trigger " << trg << std::endl;
137 fHistos->
CreateTH1(
"hTrgClustCounter" + trg,
"Event counter in trigger cluster " + trg, trgclustbinning);
138 fHistos->
CreateTH1(
"hEventCentrality" + trg,
"Event centrality for trigger class " + trg, 103, -2., 101., optionstring);
139 fHistos->
CreateTH1(
"hVertexZ" + trg,
"z-position of the primary vertex for trigger class " + trg, 200, -40., 40., optionstring);
141 fHistos->
CreateTHnSparse(
"hClusterTHnSparseAll" + trg,
"Cluster THnSparse (all) for trigger" + trg, 6, clustallbinning);
142 fHistos->
CreateTHnSparse(
"hClusterTHnSparseFired" + trg,
"Cluster THnSparse (firing) for trigger" + trg, 6, clustallbinning);
143 fHistos->
CreateTH2(
"hTimeEnergy" + trg,
"Cluster time vs. energy for trigger class " + trg, timebinning, energybinning, optionstring);
144 fHistos->
CreateTH2(
"hNCellEnergy" + trg,
"Cluster number of cells vs energy for trigger class " + trg, ncellbinning, energybinning, optionstring);
145 fHistos->
CreateTH2(
"hNCellET" + trg,
"Cluster number of cells vs transverse energy for trigger class " + trg, ncellbinning, 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);
154 AliMultSelection *mult =
dynamic_cast<AliMultSelection *
>(InputEvent()->FindListObject(
"MultSelection"));
156 AliErrorStream() << GetName() <<
": Centrality selection enabled but no centrality estimator found" << std::endl;
159 if(mult->IsEventSelected())
return false;
161 AliDebugStream(1) << GetName() <<
": Centrality " <<
fEventCentrality << std::endl;
163 AliDebugStream(1) << GetName() <<
": reject centrality: " <<
fEventCentrality << std::endl;
166 AliDebugStream(1) << GetName() <<
": select centrality " <<
fEventCentrality << std::endl;
169 AliDebugStream(1) << GetName() <<
": No centrality selection applied" << std::endl;
173 int bcindex = fInputEvent->GetHeader()->GetBunchCrossNumber() % 4;
182 auto trgstr =
static_cast<TObjString *
>(t)->String();
188 if(!allFound)
return false;
194 auto trgstr =
static_cast<TObjString *
>(t)->String();
200 if(oneFound)
return false;
208 Bool_t isCENT(
false), isCENTNOTRD(
false), isCALO(
false), isCALOFAST(
false);
210 auto trgclust = trg.Triggercluster();
211 if(trgclust ==
"CENT" && !isCENT){
215 if(trgclust ==
"CENTNOTRD" && ! isCENTNOTRD){
219 if(trgclust ==
"CALO" && !isCALO){
223 if(trgclust ==
"CALOFAST" && ! isCALOFAST) {
229 if(isCENT || isCENTNOTRD) {
235 if(isCALO || isCALOFAST){
246 AliDebugStream(1) << GetName() <<
": UserExec start" << std::endl;
248 std::map<TString, const TList *> patchhandlers;
249 const std::vector<TString> l1triggers = {
"EJ1",
"EJ2",
"EG1",
"EG2",
"DJ1",
"DJ2",
"DG1",
"DG2"};
252 if(
auto trgsel = static_cast<PWG::EMCAL::AliEmcalTriggerDecisionContainer *>(fInputEvent->FindListObject(
"EmcalTriggerDecision"))){
259 for(
auto t : l1triggers){
260 auto decision = trgsel->FindTriggerDecision(t.Data());
262 patchhandlers[t] = decision->GetAcceptedPatches();
264 switch(decision->GetSelectionCuts()->GetSelectionMethod()){
276 const TList *selpatches(
nullptr);
279 if(!clust->IsEMCAL())
continue;
280 if(clust->GetIsExotic())
continue;
286 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: default" << std::endl;
290 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for non-linearity" << std::endl;
291 energy = clust->GetNonLinCorrEnergy();
294 AliDebugStream(2) << GetName() <<
": Using cluster energy definition: corrected for hadronic contribution" << std::endl;
295 energy = clust->GetHadCorrEnergy();
299 AliDebugStream(2) << GetName() <<
": Using energy " << energy <<
" (def: " << clust->E()
300 <<
" | NL: " << clust->GetNonLinCorrEnergy()
301 <<
" | HD: " << clust->GetHadCorrEnergy()
304 TLorentzVector posvec;
305 clust->GetMomentum(posvec,
fVertex);
310 if(phi < 0) phi += TMath::TwoPi();
314 if(std::find(supportedTriggers.begin(), supportedTriggers.end(), trg) == supportedTriggers.end())
continue;
315 selpatches =
nullptr;
316 for(
auto t : l1triggers) {
317 if(trg.Contains(t)) {
318 auto patchdata = patchhandlers.find(t);
319 if(patchdata != patchhandlers.end()){
320 selpatches = patchdata->second;
333 std::vector<AliEMCALTriggerPatchInfo *> matchedPatches;
337 auto hasTriggerPatch = matchedPatches.size() > 0;
338 Int_t supermoduleID = -1;
340 AliDebugStream(1) << GetName() <<
": Using weight " << weight <<
" for trigger " << triggerclass << std::endl;
342 fGeom->SuperModuleNumberFromEtaPhi(eta, phi, supermoduleID);
343 double point[6] = {
static_cast<double>(supermoduleID), energy, transverseenergy, eta, phi, static_cast<double>(trgcluster)};
346 fHistos->
FillTH2(
"hTimeEnergy" + triggerclass, clustertime, energy, weight);
347 fHistos->
FillTH2(
"hNCellEnergy" + triggerclass, ncell, energy, weight);
348 fHistos->
FillTH2(
"hNCellET" + triggerclass, ncell, transverseenergy, weight);
351 AliEMCALTriggerPatchInfo *maxpatch(
nullptr);
352 double maxenergy = 0;
353 for(
auto patch : matchedPatches) {
356 case 0: patche = patch->GetADCAmp();
break;
357 case 1: patche = patch->GetPatchE();
break;
358 case 2: patche = patch->GetSmearedEnergy();
break;
360 if(patche > maxenergy) {
365 fHistos->
FillTH2(
"hCorrClusterEPatchADC" + triggerclass, energy, maxpatch->GetADCAmp());
366 fHistos->
FillTH2(
"hCorrClusterEPatchE" + triggerclass, energy, maxpatch->GetPatchE());
372 double v0amult = fInputEvent->GetVZEROData()->GetMTotV0A(),
373 trackletmult =
static_cast<double>(
CountTracklets(-0.8, 0.8, 0., TMath::TwoPi())),
374 emctrackletmult = static_cast<double>(
CountTracklets(-0.8, 0.8, 1.4, TMath::Pi())),
375 itsclustermult = fInputEvent->GetMultiplicity()->GetNumberOfSPDClusters(),
382 if(std::find(supportedTriggers.begin(), supportedTriggers.end(), t) == supportedTriggers.end())
continue;
388 fHistos->
FillTH1(
"hTrgClustCounter" + t, static_cast<double>(trgclust), weight);
393 double data[6] = {v0amult, trackletmult, emctrackletmult, itsclustermult, emcclustermult, emccellocc};
400 std::vector<AliEMCALTriggerPatchInfo *> foundpatches;
401 for(
auto patchIter : triggerPatches){
403 auto testpatch =
static_cast<AliEMCALTriggerPatchInfo *
>(patchIter);
406 etamax = TMath::Max(boundaries[0], boundaries[1]),
407 phimin = TMath::Min(boundaries[2], boundaries[3]),
408 phimax = TMath::Max(boundaries[2], boundaries[3]);
409 if(etaclust > etamin && etaclust < etamax && phiclust >
phimin && phiclust < phimax){
410 foundpatches.push_back(testpatch);
418 boundaries[0] = patch.GetEtaMin();
419 boundaries[1] = patch.GetEtaMax();
420 boundaries[2] = patch.GetPhiMin();
421 boundaries[3] = patch.GetPhiMax();
427 if(!clust->IsEMCAL())
continue;
428 if(clust->GetIsExotic())
continue;
429 if(clust->E() > ecut) nclusters++;
437 AliVMultiplicity *mult = fInputEvent->GetMultiplicity();
438 for(
int itl = 0; itl < mult->GetNumberOfTracklets(); itl++){
439 double eta = mult->GetEta(itl), phi = mult->GetPhi(itl);
440 if(!(eta > etamin && eta < etamax))
continue;
441 if(!(phi > phimin && phi < phimax))
continue;
448 std::set<int> cellIDs;
449 AliVCaloCells *emccells = fInputEvent->GetEMCALCells();
450 for(
short icell = 0; icell < emccells->GetNumberOfCells(); icell++){
451 if(emccells->GetAmplitude(icell) > ecut){
452 int cellID = emccells->GetCellNumber(icell);
453 if(cellIDs.find(cellID) == cellIDs.end()) cellIDs.insert(cellID);
456 return cellIDs.size();
485 TString outfile(mgr->GetCommonFileName());
486 outfile +=
":ClusterQA_" +
TString(suffix);
488 printf(
"Outfile: %s, container: %s\n", outfile.Data(), containername.Data());
490 task->ConnectInput(0, mgr->GetCommonInputContainer());
491 mgr->ConnectOutput(task, 1, mgr->CreateContainer(containername.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfile.Data()));
519 TString outfile(mgr->GetCommonFileName());
520 outfile +=
":ClusterQA";
522 task->ConnectInput(0, mgr->GetCommonInputContainer());
523 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
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 FillClusterHistograms(const TString &triggerclass, double energy, double transversenergy, double eta, double phi, double clustertime, int ncell, int trgcluster, const TList *triggerpatches, int energycomp)
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.
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.