30 #include <unordered_map> 33 #include <TClonesArray.h> 37 #include <TObjString.h> 39 #include "AliAnalysisManager.h" 40 #include "AliEMCALTriggerPatchInfo.h" 72 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
73 const std::array<std::string, 6> kNamesTriggerClusters = {{
"ANY",
"CENT",
"CENTNOTRD",
"BOTH",
"ONLYCENT",
"ONLYCENTNOTRD"}};
74 const std::array<std::string, 4> kNamesPatchTypes = {{
"EGA",
"DGA",
"EJE",
"DJE"}};
76 TLinearBinning ADCBinning(2000, 0., 2000.), colbinning(48, -0.5, 47.5), rowbinning(104, -0.5, 103.5), npatchbinning(51, -0.5, 50.5), noverlapbinning(21, -0.5, 20.5);
77 const TBinning *firedpatchbinning[5] = {&ADCBinning, &colbinning, &rowbinning, &npatchbinning, &noverlapbinning},
78 *allpatchbinning[3] = {&ADCBinning, &npatchbinning, &noverlapbinning};
80 for(
const auto &kt : kNamesTriggerClasses){
83 if(kt.find(
"MB") != std::string::npos)
84 fHistos->
CreateTH1(Form(
"hEventCounter%s", kt.data()), Form(
"Event counter for %s", kt.data()), 1, 0.5, 1.5);
86 for(
const auto &kc : kNamesTriggerClusters) {
87 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);
94 for(
const auto &kp : kNamesPatchTypes)
fHistos->
CreateTH1(Form(
"hPatchADC%sMB", kp.data()), Form(
"Patch ADC spectra for %s patches in MB events", kp.data()), 2000, 0., 2000.,
fEnableSumw2 ?
"s" :
"");
97 for(
const auto &kt : kNamesTriggerClasses) {
98 if(kt ==
"MB")
continue;
99 const char detector = kt[0];
100 const char *patchtype = ((kt[1] ==
'G') ?
"GA" :
"JE");
102 for(
const auto &kc : kNamesTriggerClusters){
103 fHistos->
CreateTH1(Form(
"hPatchADC%c%s%s%s", detector, patchtype, kt.data(), kc.data()), Form(
"Patch ADC spectra for %c%s patches in %s events (cluster %s)", detector, patchtype, kt.data(), kc.data()), 2000, 0., 2000.,
fEnableSumw2 ?
"s" :
"");
104 fHistos->
CreateTHnSparse(Form(
"hFiredPatches%c%s%s%s", detector, patchtype, kt.data(), kc.data()), Form(
"Fired %c%s patches for trigger %s (cluster %s)", detector, patchtype, kt.data(), kc.data()), 5, firedpatchbinning,
fEnableSumw2 ?
"s" :
"");
105 fHistos->
CreateTHnSparse(Form(
"hAllPatches%c%s%s%s", detector, patchtype, kt.data(), kc.data()), Form(
"Fired %c%s patches for trigger %s (cluster %s)", detector, patchtype, kt.data(), kc.data()), 3, allpatchbinning,
fEnableSumw2 ?
"s" :
"");
116 auto trgstr =
static_cast<TObjString *
>(t)->String();
122 if(!allFound)
return false;
128 auto trgstr =
static_cast<TObjString *
>(t)->String();
134 if(oneFound)
return false;
141 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
144 auto findTriggerType = [](
const std::vector<TString> &triggers,
TString type) ->
bool {
146 for(
const auto t : triggers) {
147 if(t.Contains(type)) {
155 std::vector<TString> handledtriggers;
156 for(
auto t : kNamesTriggerClasses) {
158 handledtriggers.emplace_back(t);
162 for(
const auto &kt : handledtriggers) {
163 if(kt ==
"MB")
fHistos->
FillTH1(Form(
"hEventCounter%s", kt.Data()), 1.);
165 for(
const auto &kc : selclusters)
fHistos->
FillTH1(Form(
"hEventCounter%s%s", kt.Data(), kc.data()), 1.);
171 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
175 AliDebugStream(1) <<
"Found triggers" << std::endl;
177 AliDebugStream(1) <<
"Trigger patch container has " <<
fTriggerPatchInfo->GetEntries() <<
" patches" << std::endl;
182 auto findTriggerType = [](
const std::vector<TString> &triggers,
TString type) ->
bool {
184 for(
const auto t : triggers) {
185 if(t.Contains(type)) {
192 bool isMB = std::find(fSelectedTriggers.begin(), fSelectedTriggers.end(),
"MB") != fSelectedTriggers.end(),
193 isEG = findTriggerType(fSelectedTriggers,
"EG"),
194 isDG = findTriggerType(fSelectedTriggers,
"DG"),
195 isEJ = findTriggerType(fSelectedTriggers,
"EJ"),
196 isDJ = findTriggerType(fSelectedTriggers,
"DJ");
198 std::vector<TString> handledtriggers;
199 for(
auto t : kNamesTriggerClasses) {
200 if(findTriggerType(fSelectedTriggers, t.data())){
201 handledtriggers.emplace_back(t);
205 AliDebugStream(1) <<
"Processing triggers" << std::endl;
206 for(
auto t : handledtriggers) AliDebugStream(1) << t << std::endl;
207 if(!handledtriggers.size()){
208 AliDebugStream(1) <<
"No supported trigger class found " << std::endl;
212 std::vector<const AliEMCALTriggerPatchInfo *> EGApatches, DGApatches, EJEpatches, DJEpatches;
218 for(
const auto &t : handledtriggers) {
221 for(
auto patch : EGApatches)
fHistos->
FillTH1(
"hPatchADCEGAMB", patch->GetADCAmp());
222 for(
auto patch : DGApatches)
fHistos->
FillTH1(
"hPatchADCDGAMB", patch->GetADCAmp());
223 for(
auto patch : EJEpatches)
fHistos->
FillTH1(
"hPatchADCEJEMB", patch->GetADCAmp());
224 for(
auto patch : DJEpatches)
fHistos->
FillTH1(
"hPatchADCDJEMB", patch->GetADCAmp());
226 const char detector = t[0];
227 const char *patchtype = ((t[1] ==
'G') ?
"GA" :
"JE");
228 std::vector<const AliEMCALTriggerPatchInfo *> &patchhandler = (detector ==
'E' ? (t[1] ==
'G' ? EGApatches : EJEpatches) : (t[1] ==
'G' ? DGApatches : DJEpatches));
231 AliDebugStream(3) <<
"Trigger " << t <<
", patches " << patchhandler.size() <<
", firing " << firedpatches.size() << std::endl;
232 for(
auto p : patchhandler){
233 double point[3] = {
static_cast<double>(p->GetADCAmp()), static_cast<double>(firedpatches.size()), static_cast<double>(patchareas)};
234 for(
const auto &kc : selclusters) {
235 fHistos->
FillTH1(Form(
"hPatchADC%c%s%s%s", detector, patchtype, t.Data(), kc.data()), p->GetADCAmp());
236 fHistos->
FillTHnSparse(Form(
"hAllPatches%c%s%s%s", detector, patchtype, t.Data(), kc.data()), point);
239 for(
auto p : firedpatches) {
240 double point[5] = {
static_cast<double>(p->GetADCAmp()), static_cast<double>(p->GetColStart()), static_cast<double>(p->GetRowStart()), static_cast<double>(firedpatches.size()), static_cast<double>(patchareas)};
241 for(
const auto &kc : selclusters)
242 fHistos->
FillTHnSparse(Form(
"hFiredPatches%c%s%s%s", detector, patchtype, t.Data(), kc.data()), point);
250 AliDebugStream(2) <<
"Selecting all patches for trigger " <<
static_cast<int>(patchtype) << std::endl;
251 std::vector<const AliEMCALTriggerPatchInfo *> result;
253 AliEMCALTriggerPatchInfo *patch =
static_cast<AliEMCALTriggerPatchInfo *
>(p);
254 if(!patch->IsRecalc())
continue;
257 case kEGApatches:
if(patch->IsDCalPHOS() || !patch->IsGammaHighRecalc()) selected =
false;
break;
258 case kDGApatches:
if(patch->IsEMCal() || !patch->IsGammaHighRecalc()) selected =
false;
break;
259 case kEJEpatches:
if(patch->IsDCalPHOS() || !patch->IsJetHighRecalc()) selected =
false;
break;
260 case kDJEpatches:
if(patch->IsEMCal() || !patch->IsJetHighRecalc()) selected =
false;
break;
262 if(selected) result.emplace_back(patch);
264 AliDebugStream(2) <<
"In: " << list.GetEntries() <<
", out: " << result.size() << std::endl;
269 std::vector<const AliEMCALTriggerPatchInfo *> result;
280 default:
return result;
290 std::vector<std::string> selclusters;
291 selclusters.push_back(
"ANY");
292 bool isCENT(
false), isCENTNOTRD(
false);
293 for(
const auto &
c : clusters){
294 if((
c.Triggercluster() ==
"CENT") && !isCENT) {
295 selclusters.push_back(
"CENT");
297 }
else if((
c.Triggercluster() ==
"CENTNOTRD") && !isCENTNOTRD) {
298 selclusters.push_back(
"CENTNOTRD");
302 if(isCENT && isCENTNOTRD) selclusters.push_back(
"BOTH");
304 if(isCENT) selclusters.push_back(
"ONLYCENT");
305 if(isCENTNOTRD) selclusters.push_back(
"ONLYCENTNOTRD");
311 std::vector<const AliEMCALTriggerPatchInfo *> patchareas;
312 for(
const auto patch : firedpatches) {
313 if(!patchareas.size()) patchareas.push_back(patch);
315 bool overlapFound =
false;
316 for(
const auto refpatch : patchareas) {
318 AliErrorStream() <<
"Ref patch null" << std::endl;
319 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
320 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
323 AliErrorStream() <<
"Test patch null" << std::endl;
324 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
325 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
333 if(!overlapFound) patchareas.emplace_back(patch);
336 return patchareas.size();
340 int testcolmin = test.GetColStart(), testcolmax = test.GetColStart()+test.GetPatchSize()-1,
341 testrowmin = test.GetRowStart(), testrowmax = test.GetRowStart()+test.GetPatchSize()-1,
342 refcolmin = ref.GetColStart(), refcolmax = ref.GetColStart()+ref.GetPatchSize()-1,
343 refrowmin = ref.GetRowStart(), refrowmax = ref.GetRowStart()+ref.GetPatchSize()-1;
344 if((
InRange(testcolmin, refcolmin, refcolmax) &&
InRange(testrowmin, refrowmin, refrowmax)) ||
345 (
InRange(testcolmax, refcolmin, refcolmax) &&
InRange(testrowmax, refrowmin, refrowmax)))
return true;
362 std::cerr <<
"No analysis manager defined" << std::endl;
366 std::stringstream taskname;
367 taskname <<
"EmcalRecalcPatches_" <<
suffix;
381 std::stringstream outfilename, outlistname;
382 outfilename << mgr->GetCommonFileName() <<
":" << taskname.str();
383 outlistname <<
"Histos_" << taskname.str();
384 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
385 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
Bool_t fSwapPatches
Look explicitly for the wrong patches.
void SetOnlineThreshold(ETriggerThreshold_t trigger, Int_t value)
bool HasOverlap(const AliEMCALTriggerPatchInfo &ref, const AliEMCALTriggerPatchInfo &test) const
Class creating a linear binning, used in the histogram manager.
void AddRequiredTriggerOverlap(const char *trigger)
THistManager * fHistos
Task Histogram container.
AliAnalysisTaskEmcalRecalcPatchesRef()
virtual bool IsUserEventSelected()
TArrayI fOnlineThresholds
Online thresholds.
Interface for binnings used by the histogram handler.
static std::vector< PWG::EMCAL::Triggerinfo > DecodeTriggerString(const std::string &triggerstring)
Decoding trigger string.
void SetCaloTriggerPatchInfoName(const char *n)
TObjArray fRequiredOverlaps
Add option to require overlap with certain triggers.
Base class for analyses using EMCAL triggers.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
static AliAnalysisTaskEmcalRecalcPatchesRef * AddTaskEmcalRecalcPatches(const char *suffix)
std::vector< const AliEMCALTriggerPatchInfo * > SelectFiredPatchesByTrigger(const TClonesArray &patches, ETriggerThreshold_t trigger) const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
bool InRange(int test, int includemin, int includemax) const
int GetNumberNonOverlappingPatchAreas(const std::vector< const AliEMCALTriggerPatchInfo * > &diredpatches) const
virtual void UserFillHistosAfterEventSelection()
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
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.
virtual void CreateUserHistos()
TObjArray fExcludedOverlaps
Add option to exclude overlap with certain triggers.
std::vector< std::string > GetAcceptedTriggerClusters(const char *triggerstring) const
Analysis of high- tracks in triggered events.
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void test(int runnumber=195345)
void AddExcludedTriggerOverlap(const char *trigger)
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< const AliEMCALTriggerPatchInfo * > SelectAllPatchesByType(const TClonesArray &patches, EPatchType_t patchtype) const
Bool_t fEnableSumw2
Enable sum of weights.
void SetEnableSumw2(Bool_t doEnable)