30 #include <unordered_map> 33 #include <TClonesArray.h> 38 #include "AliAnalysisManager.h" 39 #include "AliAODInputHandler.h" 41 #include "AliEMCALTriggerPatchInfo.h" 67 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
68 const std::array<std::string, 6> kNamesTriggerClusters = {{
"ANY",
"CENT",
"CENTNOTRD",
"BOTH",
"ONLYCENT",
"ONLYCENTNOTRD"}};
69 const std::array<std::string, 2> kNamesDetectors = {{
"EMCAL",
"DCAL"}};
71 TLinearBinning energybinning(2000, 0., 2000.), npatchbinning(51, -0.5, 50.5), noverlapbinning(21, -0.5, 20.5);
72 const TBinning *corrbinning[3] = {&energybinning, &npatchbinning, &noverlapbinning};
74 for(
const auto &kt : kNamesTriggerClasses){
77 if(kt.find(
"MB") != std::string::npos)
78 fHistos->
CreateTH1(Form(
"hEventCounter%s", kt.data()), Form(
"Event counter for %s", kt.data()), 1, 0.5, 1.5);
80 for(
const auto &kc : kNamesTriggerClusters) {
81 fHistos->
CreateTH1(Form(
"hEventCounter%s%s", kt.data(), kc.data()), Form(
"Event counter for %s in cluster %s", kt.data(), kc.data()), 1, 0.5, 1.5);
88 for(
const auto &kd : kNamesDetectors)
fHistos->
CreateTH1(Form(
"hClusterEnergy%sMB", kd.data()), Form(
"%s cluster energy spectrum in MB events", kd.data()), 200, 0., 200.,
fEnableSumw2 ?
"s" :
"");
91 for(
const auto &kt : kNamesTriggerClasses) {
92 if(kt ==
"MB")
continue;
94 for(
const auto &kc : kNamesTriggerClusters){
95 fHistos->
CreateTH1(Form(
"hClusterEnergy%s%s", kt.data(), kc.data()), Form(
"Cluster energy spectra in %s events (cluster %s)", kt.data(), kc.data()), 200, 0., 200.,
fEnableSumw2 ?
"s" :
"");
96 fHistos->
CreateTHnSparse(Form(
"hClusterEnergyCorr%s%s", kt.data(), kc.data()), Form(
"Cluster energy spectra for trigger %s (cluster %s)", kt.data(), kc.data()), 3, corrbinning,
fEnableSumw2 ?
"s" :
"");
102 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
104 for(
const auto &kt : kNamesTriggerClasses) {
106 if(kt ==
"MB")
fHistos->
FillTH1(Form(
"hEventCounter%s", kt.data()), 1.);
108 for(
const auto &kc : selclusters)
fHistos->
FillTH1(Form(
"hEventCounter%s%s", kt.data(), kc.data()), 1.);
115 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
123 auto findTriggerType = [](
const std::vector<TString> &triggers,
TString type) ->
bool {
125 for(
const auto t : triggers) {
126 if(t.Contains(type)) {
142 if(!std::find(kNamesTriggerClasses.begin(), kNamesTriggerClasses.end(), t.Data()))
continue;
145 for(
auto c : clustercont->accepted()){
146 bool emccluster = (
c->GetCellAbsId(0)<12288);
147 if(emccluster)
fHistos->
FillTH1(
"hClusterEnergyEMCALMB",
c->GetNonLinCorrEnergy());
148 else fHistos->
FillTH1(
"hClusterEnergyDCALMB",
c->GetNonLinCorrEnergy());
150 }
else if(std::find(kNamesTriggerClasses.begin(), kNamesTriggerClasses.end(), t.Data()) != kNamesTriggerClasses.end()) {
151 const char detector = t[0];
154 for(
auto c : clustercont->accepted()){
155 bool emccluster = (
c->GetCellAbsId(0)<12288);
156 if((detector ==
'E' && !emccluster) || (detector ==
'D' && emccluster))
continue;
157 double point[3] = {
c->GetNonLinCorrEnergy(),
static_cast<double>(firedpatches.size()), static_cast<double>(patchareas)};
158 for(
const auto &kc : selclusters) {
159 fHistos->
FillTH1(Form(
"hClusterEnergy%s%s", t.Data(), kc.data()),
c->GetNonLinCorrEnergy());
169 std::vector<const AliEMCALTriggerPatchInfo *> result;
171 AliEMCALTriggerPatchInfo *patch =
static_cast<AliEMCALTriggerPatchInfo *
>(p);
172 if(!patch->IsRecalc())
continue;
175 case kEGApatches:
if(patch->IsDCalPHOS() || !patch->IsGammaHighRecalc()) selected =
false;
break;
176 case kDGApatches:
if(patch->IsEMCal() || !patch->IsGammaHighRecalc()) selected =
false;
break;
177 case kEJEpatches:
if(patch->IsDCalPHOS() || !patch->IsJetHighRecalc()) selected =
false;
break;
178 case kDJEpatches:
if(patch->IsEMCal() || !patch->IsJetHighRecalc()) selected =
false;
break;
180 if(selected) result.emplace_back(patch);
186 std::vector<const AliEMCALTriggerPatchInfo *> result;
197 default:
return result;
207 std::vector<std::string> selclusters;
208 selclusters.push_back(
"ANY");
209 bool isCENT(
false), isCENTNOTRD(
false);
210 for(
const auto &
c : clusters){
211 if((
c.Triggercluster() ==
"CENT") && !isCENT) {
212 selclusters.push_back(
"CENT");
214 }
else if((
c.Triggercluster() ==
"CENTNOTRD") && !isCENTNOTRD) {
215 selclusters.push_back(
"CENTNOTRD");
219 if(isCENT && isCENTNOTRD) selclusters.push_back(
"BOTH");
221 if(isCENT) selclusters.push_back(
"ONLYCENT");
222 if(isCENTNOTRD) selclusters.push_back(
"ONLYCENTNOTRD");
228 std::vector<const AliEMCALTriggerPatchInfo *> patchareas;
229 for(
const auto patch : firedpatches) {
230 if(!patchareas.size()) patchareas.push_back(patch);
232 bool overlapFound =
false;
233 for(
const auto refpatch : patchareas) {
235 AliErrorStream() <<
"Ref patch null" << std::endl;
236 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
237 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
240 AliErrorStream() <<
"Test patch null" << std::endl;
241 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
242 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
250 if(!overlapFound) patchareas.emplace_back(patch);
253 return patchareas.size();
257 int testcolmin = test.GetColStart(), testcolmax = test.GetColStart()+test.GetPatchSize()-1,
258 testrowmin = test.GetRowStart(), testrowmax = test.GetRowStart()+test.GetPatchSize()-1,
259 refcolmin = ref.GetColStart(), refcolmax = ref.GetColStart()+ref.GetPatchSize()-1,
260 refrowmin = ref.GetRowStart(), refrowmax = ref.GetRowStart()+ref.GetPatchSize()-1;
261 if((
InRange(testcolmin, refcolmin, refcolmax) &&
InRange(testrowmin, refrowmin, refrowmax)) ||
262 (
InRange(testcolmax, refcolmin, refcolmax) &&
InRange(testrowmax, refrowmin, refrowmax)))
return true;
269 std::cerr <<
"No analysis manager defined" << std::endl;
273 bool isAOD = (mgr->GetInputEventHandler()->IsA() == AliAODInputHandler::Class());
275 std::stringstream taskname;
276 taskname <<
"EmcalRecalcPatches_" <<
suffix;
293 clustercont->SetExoticCut(
true);
295 std::stringstream outfilename, outlistname;
296 outfilename << mgr->GetCommonFileName() <<
":" << taskname.str();
297 outlistname <<
"Histos_" << taskname.str();
298 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
299 mgr->ConnectOutput(task, 1, mgr->CreateContainer(outlistname.str().data(), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
std::vector< TString > fSelectedTriggers
! Triggers selected for given event
std::vector< std::string > GetAcceptedTriggerClusters(const char *triggerstring) const
void SetEnableSumw2(Bool_t doEnable)
std::vector< const AliEMCALTriggerPatchInfo * > SelectAllPatchesByType(const TClonesArray &patches, EPatchType_t patchtype) const
static AliAnalysisTaskEmcalClusterNoiseTriggers * AddTaskEmcalClusterNoiseTriggers(const char *suffix)
Class creating a linear binning, used in the histogram manager.
THistManager * fHistos
Task Histogram container.
virtual void UserFillHistosAfterEventSelection()
virtual void CreateUserHistos()
TArrayI fOnlineThresholds
Online thresholds.
AliAnalysisTaskEmcalClusterNoiseTriggers()
Bool_t fEnableSumw2
Enable sum of weights.
Interface for binnings used by the histogram handler.
static std::vector< PWG::EMCAL::Triggerinfo > DecodeTriggerString(const std::string &triggerstring)
Decoding trigger string.
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
Base class for analyses using EMCAL triggers.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
void SetOnlineThreshold(ETriggerThreshold_t trigger, Int_t value)
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.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
bool HasOverlap(const AliEMCALTriggerPatchInfo &ref, const AliEMCALTriggerPatchInfo &test) const
int GetNumberNonOverlappingPatchAreas(const std::vector< const AliEMCALTriggerPatchInfo * > &diredpatches) const
Analysis of high- tracks in triggered events.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
std::vector< const AliEMCALTriggerPatchInfo * > SelectFiredPatchesByTrigger(const TClonesArray &patches, ETriggerThreshold_t trigger) const
void test(int runnumber=195345)
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
bool InRange(int test, int includemin, int includemax) const
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.
void SetClusTimeCut(Double_t min, Double_t max)
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.