16 #include "AliAnalysisManager.h"
17 #include "AliVEventHandler.h"
18 #include "AliMCEventHandler.h"
48 fReconstructed.Set(reco);
56 fGenerated.Set(truth);
69 fReconstructed.Reset();
77 fReconstructed.Set(reco);
85 fGenerated.Set(truth);
99 fMaxJetDmesonDistance(0),
103 fCurrentJetInfoReco(0),
104 fCurrentJetInfoTruth(0),
118 fCandidateType(type),
120 fMaxJetDmesonDistance(1),
124 fCurrentJetInfoReco(0),
125 fCurrentJetInfoTruth(0),
139 fCandidateType(source.fCandidateType),
140 fInhibit(source.fInhibit),
141 fMaxJetDmesonDistance(1),
145 fCurrentJetInfoReco(0),
146 fCurrentJetInfoTruth(0),
147 fDataSlotNumber(source.fDataSlotNumber),
148 fRecontructed(source.fRecontructed),
149 fGenerated(source.fGenerated),
183 fInhibit = (fRecontructed == 0 || fGenerated == 0);
184 fName = fRecontructed->GetName();
201 switch (fCandidateType) {
204 classname =
"AliAnalysisTaskDmesonJetsDetectorResponse::AliD0MatchInfoSummary";
208 classname =
"AliAnalysisTaskDmesonJetsDetectorResponse::AliDStarMatchInfoSummary";
212 TString treeName = TString::Format(
"%s_%s", taskName, GetName());
213 fTree =
new TTree(treeName, treeName);
214 fTree->Branch(
"DmesonJet", classname, &fCurrentDmeson);
216 fCurrentJetInfoTruth =
new AliJetInfoSummary*[fGenerated->GetJetDefinitions().size()];
217 for (
Int_t i = 0; i < fGenerated->GetJetDefinitions().size(); i++) {
218 if (fGenerated->GetJetDefinitions()[i].GetRhoName().IsNull()) {
220 TString bname = TString::Format(
"%s_truth", fGenerated->GetJetDefinitions()[i].GetName());
221 fTree->Branch(bname,
"AliAnalysisTaskDmesonJets::AliJetInfoSummary", &fCurrentJetInfoTruth[i]);
225 TString bname = TString::Format(
"%s_truth", fGenerated->GetJetDefinitions()[i].GetName());
226 fTree->Branch(bname,
"AliAnalysisTaskDmesonJets::AliJetInfoPbPbSummary", &fCurrentJetInfoTruth[i]);
230 fCurrentJetInfoReco =
new AliJetInfoSummary*[fRecontructed->GetJetDefinitions().size()];
231 for (
Int_t i = 0; i < fRecontructed->GetJetDefinitions().size(); i++) {
232 if (fGenerated->GetJetDefinitions()[i].GetRhoName().IsNull()) {
234 TString bname = TString::Format(
"%s_reco", fRecontructed->GetJetDefinitions()[i].GetName());
235 fTree->Branch(bname,
"AliAnalysisTaskDmesonJets::AliJetInfoSummary", &fCurrentJetInfoReco[i]);
239 TString bname = TString::Format(
"%s_reco", fRecontructed->GetJetDefinitions()[i].GetName());
240 fTree->Branch(bname,
"AliAnalysisTaskDmesonJets::AliJetInfoPbPbSummary", &fCurrentJetInfoReco[i]);
253 std::map<int, AliDmesonJetInfo>& recoDmesons = fRecontructed->GetDmesons();
254 std::map<int, AliDmesonJetInfo>& truthDmesons = fGenerated->GetDmesons();
258 for (
auto& dmeson_reco : recoDmesons) {
259 if (dmeson_reco.second.fMCLabel < 0) {
260 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoPt", GetName());
263 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoEta", GetName());
266 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoPhi", GetName());
272 fCurrentDmeson->Reset();
273 for (
UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
274 fCurrentJetInfoReco[ij]->Reset();
276 for (
UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
277 fCurrentJetInfoTruth[ij]->Reset();
281 fCurrentDmeson->SetReconstructed(dmeson_reco.second);
283 Int_t accRecJets = 0;
284 Int_t accGenJets = 0;
287 for (
UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
288 AliJetInfo* jet = dmeson_reco.second.GetJet(fRecontructed->GetJetDefinitions()[ij].GetName());
290 if (applyKinCuts && !fRecontructed->GetJetDefinitions()[ij].IsJetInAcceptance(*jet))
continue;
291 fCurrentJetInfoReco[ij]->Set(dmeson_reco.second, fRecontructed->GetJetDefinitions()[ij].GetName());
296 std::map<int, AliDmesonJetInfo>::iterator it = truthDmesons.find(dmeson_reco.second.fMCLabel);
297 if (it != truthDmesons.end()) {
298 std::pair<const int, AliDmesonJetInfo>& dmeson_truth = (*it);
300 dmeson_truth.second.fReconstructed = kTRUE;
302 fCurrentDmeson->SetGenerated((*it).second);
305 for (
UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
306 AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
308 if (!applyKinCuts || fGenerated->GetJetDefinitions()[ij].IsJetInAcceptance(*jet)) accGenJets++;
309 fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
313 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoPt", GetName());
316 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoEta", GetName());
319 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoPhi", GetName());
325 if (accRecJets > 0 || accGenJets > 0) fTree->Fill();
329 for (
UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) fCurrentJetInfoReco[ij]->Reset();
330 for (
UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) fCurrentJetInfoTruth[ij]->Reset();
333 for (
auto& dmeson_truth : truthDmesons) {
335 if (dmeson_truth.second.fReconstructed)
continue;
338 fCurrentDmeson->Reset();
341 fCurrentDmeson->SetGenerated(dmeson_truth.second);
344 Int_t accGenJets = 0;
345 for (
UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
346 fCurrentJetInfoTruth[ij]->Reset();
347 AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
349 if (!applyKinCuts || fGenerated->GetJetDefinitions()[ij].IsJetInAcceptance(*jet)) accGenJets++;
350 fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
354 if (accGenJets > 0) fTree->Fill();
357 for (
auto& dmeson_truth : truthDmesons) {
358 dmeson_truth.second.fReconstructed = kFALSE;
384 fHistManagerResponse(
TString::Format(
"%s_QA", name)),
393 ::Info(
"UserCreateOutputObjects",
"CreateOutputObjects of task %s", GetName());
398 if (param.IsInhibit())
continue;
407 for (
auto ¶m : fAnalysisEngines) {
408 if (param.IsInhibit())
continue;
409 if (param.GetMCMode() !=
kMCTruth)
continue;
410 if (resp.fRecontructed->GetCandidateType() != param.GetCandidateType())
continue;
412 resp.SetGeneratedAnalysisEngine(¶m);
422 for (
auto &resp : fResponseEngines) {
423 if (!resp.CheckInit())
continue;
425 resp.BuildTree(GetName());
427 resp.AssignDataSlot(treeSlot+2);
432 AliError(Form(
"Number of data output slots %d not sufficient. Tree of response engine %s will not be posted!",
fNOutputTrees, resp.GetName()));
437 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoPt", resp.GetName());
438 htitle = hname +
";#it{p}_{T,D} (GeV/#it{c});counts";
441 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoEta", resp.GetName());
442 htitle = hname +
";#eta_{D};counts";
445 hname = TString::Format(
"%s/fHistGeneratedDMesonNotFoundRecoPhi", resp.GetName());
446 htitle = hname +
";#phi_{D};counts";
449 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoPt", resp.GetName());
450 htitle = hname +
";#it{p}_{T,D} (GeV/#it{c});counts";
453 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoEta", resp.GetName());
454 htitle = hname +
";#eta_{D};counts";
457 hname = TString::Format(
"%s/fHistGeneratedDMesonOutsideAccRecoPhi", resp.GetName());
458 htitle = hname +
";#phi_{D};counts";
488 if (resp.IsInhibit())
continue;
496 if (
ana.IsInhibit())
continue;
512 AliWarning(
"This class only provides a tree output.");
548 ::Error(
"AddTaskDmesonJetsDetectorResponse",
"No analysis manager to connect to.");
553 AliVEventHandler* handler = mgr->GetInputEventHandler();
555 ::Error(
"AddTaskDmesonJetsDetectorResponse",
"This task requires an input event handler");
561 if (handler->InheritsFrom(
"AliESDInputHandler")) {
564 else if (handler->InheritsFrom(
"AliAODInputHandler")) {
569 if (trackName ==
"usedefault") {
570 if (dataType ==
kESD) {
571 trackName =
"Tracks";
573 else if (dataType ==
kAOD) {
574 trackName =
"tracks";
581 if (clusName ==
"usedefault") {
582 if (dataType ==
kESD) {
583 clusName =
"CaloClusters";
585 else if (dataType ==
kAOD) {
586 clusName =
"caloClusters";
593 if (mcPartName ==
"usedefault") {
594 mcPartName =
"mcparticles";
597 TString name(
"AliAnalysisTaskDmesonJetsDetectorResponse");
598 if (!suffix.IsNull()) {
599 name += TString::Format(
"_%s", suffix.Data());
604 if (!trackName.IsNull()) {
609 if (!mcPartName.IsNull()) {
611 partCont->SetEtaLimits(-1.5, 1.5);
612 partCont->SetPtLimits(0, 1000);
619 mgr->AddTask(jetTask);
622 AliAnalysisDataContainer* cinput1 = mgr->GetCommonInputContainer();
624 contname1 +=
"_histos";
625 AliAnalysisDataContainer* coutput1 = mgr->CreateContainer(contname1.Data(),
626 TList::Class(), AliAnalysisManager::kOutputContainer,
627 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
629 mgr->ConnectInput(jetTask, 0, cinput1);
630 mgr->ConnectOutput(jetTask, 1, coutput1);
632 for (
Int_t i = 0; i < nMaxTrees; i++) {
633 TString contname = TString::Format(
"%s_tree_%d", name.Data(), i);
634 AliAnalysisDataContainer *coutput = mgr->CreateContainer(contname.Data(),
635 TTree::Class(),AliAnalysisManager::kOutputContainer,
636 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
637 mgr->ConnectOutput(jetTask, 2+i, coutput);
virtual void SetGenerated(const AliDmesonJetInfo &truth)
AliClusterContainer * AddClusterContainer(std::string branchName, std::string contName="")
std::list< AnalysisEngine > fAnalysisEngines
Array of analysis parameters.
static AliAnalysisTaskDmesonJetsDetectorResponse * AddTaskDmesonJetsDetectorResponse(TString trackName, TString clusName, TString mcPartName, Int_t nMaxTrees, TString suffix)
Int_t PostDataFromResponseEngine(const ResponseEngine &eng)
Analysis task for D meson jets.
void ana(Int_t mode=mGRID)
Lightweight class that encapsulates matching between reconstructed and generated D0 mesons...
virtual void Reset()
Reset the object.
TList * fOutput
!output list
EDataType_t
Switch for the data type.
Analysis task used to build a detector response for D meson jets.
Bool_t FillTree(Bool_t applyKinCuts)
Lightweight class that encapsulates D meson jets.
AliHFAODMCParticleContainer * fMCContainer
! MC particle container
AliD0InfoSummary fReconstructed
Reconstructed D meson.
virtual void SetReconstructed(const AliDmesonJetInfo &reco)
Analysis engine to produce detector response matrix in the D meson jet analysis.
virtual void UserCreateOutputObjects()
Creates the output containers.
void FillPartonLevelHistograms()
Fill histograms with parton-level information.
virtual void Reset()
Reset the object.
virtual void Reset()
Reset the object.
virtual void UserCreateOutputObjects()
Creates the output containers.
TTree * BuildTree(const char *taskName)
void SetReconstructedAnalysisEngine(AnalysisEngine *reco)
AliAnalysisTaskDmesonJetsDetectorResponse()
This is the default constructor, used for ROOT I/O purposes.
AnalysisEngine * fRecontructed
! Reconstructed level analysis engine
Lightweight class that encapsulates matching between reconstructed and generated D mesons...
Select tracks based on specific prescriptions of HF analysis.
bool operator<(const AliAnalysisTaskDmesonJetsDetectorResponse::ResponseEngine &lhs, const AliAnalysisTaskDmesonJetsDetectorResponse::ResponseEngine &rhs)
THashList * GetListOfHistograms() const
Get the list of histograms.
Lightweight class that encapsulates D meson jets for PbPb analysis.
bool operator==(const AliAnalysisTaskDmesonJetsDetectorResponse::ResponseEngine &lhs, const AliAnalysisTaskDmesonJetsDetectorResponse::ResponseEngine &rhs)
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
virtual void SetReconstructed(const AliDmesonJetInfo &reco)
THistManager fHistManagerResponse
Histogram manager for response.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
ResponseEngine()
Default constructor, for ROOT I/O.
Select MC particles based on specific prescriptions of HF analysis.
Lightweight class that encapsulates matching between reconstructed and generated D* mesons...
virtual void SetOutputTypeInternal(EOutputType_t b)
ResponseEngine & operator=(const ResponseEngine &source)
AliDmesonMCInfoSummary fGenerated
Generated D meson.
Int_t GetDataSlotNumber() const
Class that encapsulates jets.
Bool_t fApplyKinematicCuts
Apply jet kinematic cuts.
std::vector< ResponseEngine > fResponseEngines
! Response engines
virtual void Reset()
Reset the object.
EOutputType_t fOutputType
Output type: none, TTree or THnSparse.
Int_t fNOutputTrees
Maximum number of output trees.
Container for MC-true particles within the EMCAL framework.
virtual Bool_t FillHistograms()
void AdoptParticleContainer(AliParticleContainer *cont)
void RunAnalysis()
Run the requested analysis for the current event.
virtual void SetGenerated(const AliDmesonJetInfo &truth)