30 #include <unordered_map> 33 #include <TClonesArray.h> 38 #include "AliAnalysisManager.h" 39 #include "AliEMCALTriggerPatchInfo.h" 64 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
65 const std::array<std::string, 6> kNamesTriggerClusters = {{
"ANY",
"CENT",
"CENTNOTRD",
"BOTH",
"ONLYCENT",
"ONLYCENTNOTRD"}};
66 const std::array<std::string, 4> kNamesPatchTypes = {{
"EGA",
"DGA",
"EJE",
"DJE"}};
68 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);
69 const TBinning *firedpatchbinning[5] = {&ADCBinning, &colbinning, &rowbinning, &npatchbinning, &noverlapbinning},
70 *allpatchbinning[3] = {&ADCBinning, &npatchbinning, &noverlapbinning};
72 for(
const auto &kt : kNamesTriggerClasses){
75 if(kt.find(
"MB") != std::string::npos)
76 fHistos->
CreateTH1(Form(
"hEventCounter%s", kt.data()), Form(
"Event counter for %s", kt.data()), 1, 0.5, 1.5);
78 for(
const auto &kc : kNamesTriggerClusters) {
79 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);
86 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" :
"");
89 for(
const auto &kt : kNamesTriggerClasses) {
90 if(kt ==
"MB")
continue;
91 const char detector = kt[0];
92 const char *patchtype = ((kt[1] ==
'G') ?
"GA" :
"JE");
94 for(
const auto &kc : kNamesTriggerClusters){
95 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" :
"");
96 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" :
"");
97 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" :
"");
103 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
105 for(
const auto &kt : kNamesTriggerClasses) {
107 if(kt ==
"MB")
fHistos->
FillTH1(Form(
"hEventCounter%s", kt.data()), 1.);
109 for(
const auto &kc : selclusters)
fHistos->
FillTH1(Form(
"hEventCounter%s%s", kt.data(), kc.data()), 1.);
116 const std::array<std::string, 9> kNamesTriggerClasses = {{
"MB",
"EG1",
"EG2",
"DG1",
"DG2",
"EJ1",
"EJ2",
"DJ1",
"DJ2"}};
124 auto findTriggerType = [](
const std::vector<TString> &triggers,
TString type) ->
bool {
126 for(
const auto t : triggers) {
127 if(t.Contains(type)) {
140 std::vector<const AliEMCALTriggerPatchInfo *> EGApatches, DGApatches, EJEpatches, DJEpatches;
147 if(!std::find(kNamesTriggerClasses.begin(), kNamesTriggerClasses.end(), t.Data()))
continue;
150 for(
auto patch : EGApatches)
fHistos->
FillTH1(
"hPatchADCEGAMB", patch->GetADCAmp());
151 for(
auto patch : DGApatches)
fHistos->
FillTH1(
"hPatchADCDGAMB", patch->GetADCAmp());
152 for(
auto patch : EJEpatches)
fHistos->
FillTH1(
"hPatchADCEJEMB", patch->GetADCAmp());
153 for(
auto patch : DJEpatches)
fHistos->
FillTH1(
"hPatchADCDJEMB", patch->GetADCAmp());
156 }
else if(std::find(kNamesTriggerClasses.begin(), kNamesTriggerClasses.end(), t.Data()) != kNamesTriggerClasses.end()) {
157 const char detector = t[0];
158 const char *patchtype = ((t[1] ==
'G') ?
"GA" :
"JE");
159 std::vector<const AliEMCALTriggerPatchInfo *> &patchhandler = (detector ==
'E' ? (t[1] ==
'G' ? EGApatches : EJEpatches) : (t[1] ==
'G' ? DGApatches : DJEpatches));
162 for(
auto p : patchhandler){
163 double point[3] = {
static_cast<double>(p->GetADCAmp()), static_cast<double>(firedpatches.size()), static_cast<double>(patchareas)};
164 for(
const auto &kc : selclusters) {
165 fHistos->
FillTH1(Form(
"hPatchADC%c%s%s%s", detector, patchtype, t.Data(), kc.data()), p->GetADCAmp());
166 fHistos->
FillTHnSparse(Form(
"hAllPatches%c%s%s%s", detector, patchtype, t.Data(), kc.data()), point);
169 for(
auto p : firedpatches) {
170 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)};
171 for(
const auto &kc : selclusters)
172 fHistos->
FillTHnSparse(Form(
"hFiredPatches%c%s%s%s", detector, patchtype, t.Data(), kc.data()), point);
180 std::vector<const AliEMCALTriggerPatchInfo *> result;
182 AliEMCALTriggerPatchInfo *patch =
static_cast<AliEMCALTriggerPatchInfo *
>(p);
183 if(!patch->IsRecalc())
continue;
186 case kEGApatches:
if(patch->IsDCalPHOS() || !patch->IsGammaHighRecalc()) selected =
false;
break;
187 case kDGApatches:
if(patch->IsEMCal() || !patch->IsGammaHighRecalc()) selected =
false;
break;
188 case kEJEpatches:
if(patch->IsDCalPHOS() || !patch->IsJetHighRecalc()) selected =
false;
break;
189 case kDJEpatches:
if(patch->IsEMCal() || !patch->IsJetHighRecalc()) selected =
false;
break;
191 if(selected) result.emplace_back(patch);
197 std::vector<const AliEMCALTriggerPatchInfo *> result;
208 default:
return result;
218 std::vector<std::string> selclusters;
219 selclusters.push_back(
"ANY");
220 bool isCENT(
false), isCENTNOTRD(
false);
221 for(
const auto &
c : clusters){
222 if((
c.Triggercluster() ==
"CENT") && !isCENT) {
223 selclusters.push_back(
"CENT");
225 }
else if((
c.Triggercluster() ==
"CENTNOTRD") && !isCENTNOTRD) {
226 selclusters.push_back(
"CENTNOTRD");
230 if(isCENT && isCENTNOTRD) selclusters.push_back(
"BOTH");
232 if(isCENT) selclusters.push_back(
"ONLYCENT");
233 if(isCENTNOTRD) selclusters.push_back(
"ONLYCENTNOTRD");
239 std::vector<const AliEMCALTriggerPatchInfo *> patchareas;
240 for(
const auto patch : firedpatches) {
241 if(!patchareas.size()) patchareas.push_back(patch);
243 bool overlapFound =
false;
244 for(
const auto refpatch : patchareas) {
246 AliErrorStream() <<
"Ref patch null" << std::endl;
247 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
248 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
251 AliErrorStream() <<
"Test patch null" << std::endl;
252 AliErrorStream() <<
"Patchareas has size " << patchareas.size() << std::endl;
253 AliErrorStream() <<
"Firedpatches has size " << firedpatches.size() << std::endl;
261 if(!overlapFound) patchareas.emplace_back(patch);
264 return patchareas.size();
268 int testcolmin = test.GetColStart(), testcolmax = test.GetColStart()+test.GetPatchSize()-1,
269 testrowmin = test.GetRowStart(), testrowmax = test.GetRowStart()+test.GetPatchSize()-1,
270 refcolmin = ref.GetColStart(), refcolmax = ref.GetColStart()+ref.GetPatchSize()-1,
271 refrowmin = ref.GetRowStart(), refrowmax = ref.GetRowStart()+ref.GetPatchSize()-1;
272 if((
InRange(testcolmin, refcolmin, refcolmax) &&
InRange(testrowmin, refrowmin, refrowmax)) ||
273 (
InRange(testcolmax, refcolmin, refcolmax) &&
InRange(testrowmax, refrowmin, refrowmax)))
return true;
280 std::cerr <<
"No analysis manager defined" << std::endl;
284 std::stringstream taskname;
285 taskname <<
"EmcalRecalcPatches_" <<
suffix;
299 std::stringstream outfilename, outlistname;
300 outfilename << mgr->GetCommonFileName() <<
":" << taskname.str();
301 outlistname <<
"Histos_" << taskname.str();
302 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
303 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
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.
THistManager * fHistos
Task Histogram container.
AliAnalysisTaskEmcalRecalcPatchesRef()
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.
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()
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)
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)