30 #include <TGridResult.h> 40 #include <AliAnalysisManager.h> 41 #include <AliVEvent.h> 42 #include <AliAODEvent.h> 43 #include <AliESDEvent.h> 44 #include <AliMCEvent.h> 45 #include <AliInputEventHandler.h> 46 #include <AliVHeader.h> 47 #include <AliAODMCHeader.h> 48 #include <AliGenPythiaEventHeader.h> 66 AliInfoGeneralStream(
"AliAnalysisTaskEmcalEmbeddingHelper") <<
"Trying to connect to AliEn ...\n";
67 TGrid::Connect(
"alien://");
70 AliFatalGeneral(
"AliAnalysisTaskEmcalEmbeddingHelper",
"Cannot access AliEn!");
84 if (!gGrid && filename.find(
"alien://") != std::string::npos) {
89 if (filename.find(
".zip#") != std::string::npos) {
90 std::size_t pos = filename.find_last_of(
"#");
98 bool res =
gSystem->AccessPathName(filename.c_str());
100 res = (res ==
false);
102 AliDebugGeneralStream(
"AliAnalysisTaskEmcalEmbeddingHelper", 4) <<
"File \"" << filename <<
"\" doees not exist!\n";
116 fMCRejectOutliers(false),
117 fPtHardJetPtRejectionFactor(4),
120 fInitializedConfiguration(false),
121 fInitializedNewFile(false),
122 fInitializedEmbedding(false),
123 fWrappedAroundTree(false),
127 fRandomEventNumberAccess(kFALSE),
128 fRandomFileAccess(kTRUE),
131 fUseInternalEventSelection(false),
132 fUseManualInternalEventCuts(false),
133 fInternalEventCuts(),
134 fEmbeddedEventUsed(true),
137 fAutoConfigurePtHardBins(false),
138 fAutoConfigureBasePath(
""),
139 fAutoConfigureTrainTypePath(
""),
140 fAutoConfigureIdentifier(
""),
143 fFileListFilename(
""),
146 fConfigurationPath(
""),
148 fPythiaCrossSectionFilenames(),
155 fMaxNumberOfFiles(0),
163 fPythiaTrialsFromFile(0),
164 fPythiaCrossSection(0.),
165 fPythiaCrossSectionFromFile(0.),
167 fPrintTimingInfoToLog(false),
171 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
241 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
248 DefineOutput(1, AliEmcalList::Class());
277 if (result && initializedYAML) {
281 if (removeDummyTask ==
true) {
305 std::vector<std::string> physicsSelection;
336 std::string baseName =
"internalEventSelection";
340 std::vector <double> centralityRange;
343 if (centralityRange.size() != 2) {
344 AliErrorStream() <<
"Passed centrality range with " << centralityRange.size() <<
" entries, but 2 values are required. Ignoring values.\n";
347 AliDebugStream(1) <<
"Setting internal event centrality range to [" << centralityRange.at(0) <<
", " << centralityRange.at(1) <<
"]\n";
399 AliFatal(TString::Format(
"Requested default (pattern) input filename, but could not determine file type from tree name \"%s\". Please check the tree name and set the pattern input filename",
fTreeName.Data()));
410 AliFatal(
"Requested both pt hard bin auto configuration and selected a non-zero pt hard bin. These are incompatible options. Please check your configuration.");
413 if (success ==
false) {
414 AliFatal(
"Pt hard bin auto configuration requested, but it failed. Please check the logs.\n");
430 bool usedFilePattern =
false;
432 usedFilePattern =
true;
433 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern file %s...",
fFilePattern.Data()));
442 filePattern.ReplaceAll(
"alien://",
"");
445 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern \"%s\" and input filename \"%s\"", filePattern.Data(),
fInputFilename.Data()));
446 auto result = gGrid->Query(filePattern.Data(),
fInputFilename.Data());
452 for (
int i = 0; i < result->GetEntries(); i++)
454 TString path = result->GetKey(i,
"turl");
459 outFile << path <<
"\n";
465 AliErrorStream() <<
"Failed to run grid query\n";
473 if (usedFilePattern) {
474 AliErrorStream() <<
"You set both the file pattern and the file list filename! The file list filename will override the pattern! Pattern: \"" <<
fFilePattern <<
"\", filename: \"" <<
fFileListFilename <<
"\"\nPlease check that this is the desired behavior!\n";
489 std::copy(std::istream_iterator<std::string>(inputFile),
490 std::istream_iterator<std::string>(),
497 AliFatal(TString::Format(
"Filenames from pattern \"%s\" and file list \"%s\" yielded an empty list!",
fFilePattern.Data(),
fFileListFilename.Data()));
504 if (
filename.find(
".zip") != std::string::npos &&
filename.find(
"#") == std::string::npos) {
514 AliError(TString::Format(
"Filename %s contains \".zip\" and not \"#\", but tree name %s is not recognized. Please check the file list to ensure that the proper path is set.",
filename.c_str(),
fTreeName.Data()));
524 if (
filename.find(
"alien://") != std::string::npos) {
532 unsigned int initialSize = fFilenames.size();
534 fFilenames.erase(std::remove_if(fFilenames.begin(), fFilenames.end(), [](
const std::string &
filename) {
return (::
IsFileAccessible(
filename) ==
false);} ), fFilenames.end());
536 AliInfoStream() <<
"Found " << fFilenames.size() <<
" files to embed (" << (initialSize - fFilenames.size()) <<
" filename(s) inaccessible or invalid)\n";
551 std::string externalEventFilename =
"";
559 std::vector <std::string> pythiaBaseFilenames = {
"pyxsec.root",
"pyxsec_hists.root"};
560 AliInfoStream() <<
"Attempting to determine pythia cross section filename. It can be normal to see some TFile::Init() errors!\n";
561 std::string pythiaXSecFilename =
"";
562 for (
auto & name : pythiaBaseFilenames) {
564 if (pythiaXSecFilename !=
"") {
565 AliDebugStream(4) <<
"Found pythia cross section filename \"" << name <<
"\"\n";
574 AliErrorStream() <<
"Failed to find pythia x sec file! Continuing with only the pythia header!\n";
596 if (path.find(run) != std::string::npos) {
611 AliInfo(
"No Embedding YAML configuration was provided");
614 AliInfoStream() <<
"Embedding YAML configuration was provided: \"" <<
fConfigurationPath <<
"\".\n";
617 if (addedConfig < 0) {
618 AliError(
"YAML Configuration not found!");
643 bool returnValue =
false;
645 AliInfoStream() <<
"Attempting to auto configure pt hard bins.\n";
656 const char * trainNumberStr =
gSystem->Getenv(
"TRAIN_RUN_ID");
657 std::stringstream trainNumberSS;
658 if (trainNumberStr) {
659 trainNumberSS << trainNumberStr;
661 if (trainNumberSS.str() ==
"") {
662 AliFatal(
"Cannot retrieve train ID.");
666 trainNumberSS >> trainNumber;
675 std::string yamlExtension =
".yaml";
676 if (
filename.find(yamlExtension) == std::string::npos) {
683 AliInfoStream() <<
"Train pt hard bin configuration file not available, so creating a new empty configuration named \"" <<
fAutoConfigureIdentifier <<
"\".\n";
688 AliInfoStream() <<
"Opening configuration located at \"" <<
filename <<
"\".\n";
695 int tempTrainNumber = -1;
696 bool getPropertyReturnValue =
false;
697 std::stringstream propertyName;
698 for (
int ptHardBin = 1; ptHardBin <=
fNPtHardBins; ptHardBin++)
700 propertyName.str(
"");
701 propertyName << ptHardBin;
702 getPropertyReturnValue = config.
GetProperty(propertyName.str(), tempTrainNumber,
false);
703 if (getPropertyReturnValue !=
true) {
704 AliInfoStream() <<
"Train " << trainNumber <<
" will use pt hard bin " << ptHardBin <<
".\n";
721 AliDebugStream(2) <<
"Found pt hard bin " << ptHardBin <<
" corresponding to train number " << trainNumber <<
".\n";
723 if (tempTrainNumber == trainNumber) {
724 AliInfoStream() <<
"Train run number " << trainNumber <<
" was already found assigned to pt hard bin " << ptHardBin <<
". That pt hard bin will be used.\n";
747 std::string tempStr =
"";
749 tempStr =
"fileList";
753 tempStr += tempUUID.AsString();
768 while (filename.rbegin() != filename.rend() && *(filename.rbegin()) ==
'/') {
788 AliInfo(TString::Format(
"Starting with random file number %i!",
fFilenameIndex+1));
794 AliWarning(TString::Format(
"File index %i out of range from 0 to %lu! Resetting to 0!",
fFilenameIndex,
fFilenames.size()));
842 AliError(
"====================================================================================================");
843 AliError(
"== No more files available to embed from the TChain! Restarting from the beginning of the TChain! ==");
844 AliError(
"== Be careful to check that this is the desired action! ==");
845 AliError(
"====================================================================================================");
869 if (attempts == 1000)
870 AliWarning(
"After 1000 attempts no event has been accepted by the event selection (trigger, centrality...)!");
884 if (!
fChain)
return kFALSE;
895 AliDebug(4,
"Set event properties");
899 AliAODMCHeader* aodMCH =
dynamic_cast<AliAODMCHeader*
>(
fExternalEvent->FindListObject(AliAODMCHeader::StdBranchName()));
901 for (
UInt_t i = 0;i<aodMCH->GetNCocktailHeaders();i++) {
902 fPythiaHeader =
dynamic_cast<AliGenPythiaEventHeader*
>(aodMCH->GetCocktailHeader(i));
914 AliDebugStream(4) <<
"Taking the pythia cross section avg from the xsec file.\n";
919 AliDebugStream(4) <<
"Taking the pythia trials avg from the xsec file.\n";
924 AliDebugStream(4) <<
"Pythia header is defined!\n";
971 AliDebugStream(3) <<
"Event rejected due to pt hard = 0, indicating a problem with the external event.\n";
983 AliFatal(
"Event selection is not implemented for embedding ESDs.");
993 res = (
dynamic_cast<AliVAODHeader*
>(aev->GetHeader()))->GetOfflineTrigger();
998 AliDebug(3, Form(
"Event rejected due to physics selection. Event trigger mask: %d, trigger mask selection: %d.",
1010 const AliVVertex *externalVert =
fExternalEvent->GetPrimaryVertex();
1011 const AliVVertex *inputVert = AliAnalysisTaskSE::InputEvent()->GetPrimaryVertex();
1012 if (externalVert && inputVert) {
1013 externalVert->GetXYZ(externalVertex);
1014 inputVert->GetXYZ(inputVertex);
1016 if (TMath::Abs(externalVertex[2]) >
fZVertexCut) {
1017 AliDebug(3, Form(
"Event rejected due to Z vertex selection. Event Z vertex: %f, Z vertex cut: %f",
1024 Double_t dist = TMath::Sqrt((externalVertex[0]-inputVertex[0])*(externalVertex[0]-inputVertex[0])+(externalVertex[1]-inputVertex[1])*(externalVertex[1]-inputVertex[1])+(externalVertex[2]-inputVertex[2])*(externalVertex[2]-inputVertex[2]));
1026 AliDebug(3, Form(
"Event rejected because the distance between the current and embedded vertices is > %f. " 1027 "Current event vertex (%f, %f, %f), embedded event vertex (%f, %f, %f). Distance = %f",
1028 fMaxVertexDist, inputVertex[0], inputVertex[1], inputVertex[2], externalVertex[0], externalVertex[1], externalVertex[2], dist));
1048 AliDebugStream(4) <<
"Pythia Njets: " << nTriggerJets <<
", pT Hard: " <<
fPythiaPtHard <<
"\n";
1051 for (
Int_t iJet = 0; iJet< nTriggerJets; iJet++) {
1054 jet.SetPxPyPzE(tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3]);
1056 AliDebugStream(5) <<
"Pythia jet " << iJet <<
", pycell jet pT: " << jet.Pt() <<
"\n";
1060 AliDebugStream(3) <<
"Event rejected because of MC outlier removal. Pythia header jet with: pT Hard " << fPythiaPtHard <<
", pycell jet pT " << jet.Pt() <<
", rejection factor " <<
fPtHardJetPtRejectionFactor <<
"\n";
1078 if (!
fChain)
return kFALSE;
1088 AliError(Form(
"Tree name %s not recognized!",
fTreeName.Data()));
1113 AliDebugStream(1) <<
"Configuring AliEventCuts for internal event selection.\n";
1121 bool useEventCutsAutomaticTriggerSelection =
false;
1122 bool res =
fYAMLConfig.
GetProperty(std::vector<std::string>({
"internalEventSelection",
"useEventCutsAutomaticTriggerSelection"}), useEventCutsAutomaticTriggerSelection,
false);
1123 if (res && useEventCutsAutomaticTriggerSelection) {
1125 AliDebugStream(1) <<
"Using the automatic trigger selection from AliEventCuts.\n";
1129 AliDebugStream(1) <<
"Using the trigger selection specified with SelectCollisionCandidates()\n.";
1152 eventCutsOutput->SetOwner(kTRUE);
1153 eventCutsOutput->SetName(
"EventCuts");
1157 fOutput->Add(eventCutsOutput);
1165 histName =
"fHistXsection";
1166 histTitle =
"Pythia Cross Section;p_{T} hard bin; XSection";
1170 histName =
"fHistTrials";
1171 histTitle =
"Number of Pythia Trials;p_{T} hard bin;Trials";
1175 histName =
"fHistPtHard";
1176 histTitle =
"p_{T} Hard Spectra;p_{T} hard;Counts";
1180 histName =
"fHistEventCount";
1181 histTitle =
"Event count;Result;Count";
1183 histEventCount->GetXaxis()->SetBinLabel(1,
"Accepted");
1184 histEventCount->GetXaxis()->SetBinLabel(2,
"Rejected");
1187 histName =
"fHistEmbeddedEventRejection";
1188 histTitle =
"Reasons to reject embedded event";
1189 std::vector<std::string> binLabels = {
"PhysSel",
"MCOutlier",
"Vz",
"VertexDist",
"PtHardIs0"};
1190 auto histEmbeddedEventRejection =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1192 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1193 histEmbeddedEventRejection->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1195 histEmbeddedEventRejection->GetYaxis()->SetTitle(
"Counts");
1198 histName =
"fHistEmbeddedEventsAttempted";
1199 histTitle =
"Number of embedded events rejected by event selection before success;Number of rejected events;Counts";
1203 histName =
"fHistNumberOfFilesEmbedded";
1204 histTitle =
"Number of files which contributed events to be embedded";
1208 histName =
"fHistAbsoluteFileNumber";
1209 histTitle =
"Number of times each absolute file number was embedded";
1214 histName =
"fHistInternalEventCutsStats";
1215 histTitle =
"Number of events to pass each cut";
1216 binLabels = {
"passedEventCuts",
"centrality",
"passedAllCuts"};
1217 auto histInternalEventCutsStats =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1219 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1220 histInternalEventCutsStats->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1222 histInternalEventCutsStats->GetYaxis()->SetTitle(
"Number of selected events");
1227 histName =
"fInitTreeCPUtime";
1228 histTitle =
"CPU time to execute InitTree() (s)";
1231 histName =
"fInitTreeRealtime";
1232 histTitle =
"Real time to execute InitTree() (s)";
1239 while ((obj = next())) {
1263 if (
filename.find(
"alien://") != std::string::npos) {
1272 bool wrapped =
false;
1273 std::string fullPythiaXSecFilename =
"";
1288 AliDebugStream(4) <<
"Adding file to the embedded input chain \"" << *
filename <<
"\".\n";
1299 AliDebugStream(4) <<
"Adding pythia cross section file \"" << fullPythiaXSecFilename <<
"\".\n";
1310 AliErrorStream() <<
"Number of input files (" << fFilenames.size() <<
") is larger than the number of available files (" <<
fMaxNumberOfFiles <<
"). Something went wrong when adding some of those files to the TChain!\n";
1315 if (!res)
return kFALSE;
1332 std::string pythiaXSecFilename =
"";
1335 if (externalEventFilename.find(
".zip#") != std::string::npos) {
1336 std::size_t pos = externalEventFilename.find_last_of(
"#");
1337 externalEventFilename.erase(pos);
1341 if (externalEventFilename.find(
".zip") != std::string::npos)
1344 pythiaXSecFilename = externalEventFilename;
1345 pythiaXSecFilename +=
"#";
1346 pythiaXSecFilename += pythiaFilename;
1352 std::unique_ptr<TFile> fTemp(TFile::Open(pythiaXSecFilename.c_str(),
"READ"));
1355 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1356 pythiaXSecFilename =
"";
1359 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1366 pythiaXSecFilename =
gSystem->DirName(externalEventFilename.c_str());
1367 pythiaXSecFilename +=
"/";
1368 pythiaXSecFilename += pythiaFilename;
1373 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1376 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1377 pythiaXSecFilename =
"";
1382 return pythiaXSecFilename;
1393 AliFatal(
"The configuration is not initialized. Check that Initialize() was called!");
1398 if (!res) {
return; }
1402 AliInfo(
"Random event number access enabled!");
1471 AliDebugStream(3) <<
"Failed to retrieve cross section from xsec file. Will still attempt to get the information from the header.\n";
1475 AliErrorStream() <<
"Attempted to read past the end of the pythia cross section filenames vector. File number: " <<
fFileNumber <<
", vector size: " <<
fPythiaCrossSectionFilenames.size() <<
".\nThis should only occur if we have run out of files to embed!\n";
1479 AliDebug(2, TString::Format(
"Will start embedding file %i beginning from entry %i (entry %i within the file). NOTE: This file number is not equal to the absolute file number in the file list!",
fFileNumber,
fCurrentEntry,
fCurrentEntry -
fLowerEntry));
1493 std::cout <<
"InitTree() complete. CPU time: " <<
fTimer.CpuTime() <<
" (s). Real time: " <<
fTimer.RealTime() <<
" (s)." << std::endl;
1509 std::unique_ptr<TFile> fxsec(TFile::Open(pythiaFileName.c_str()));
1514 double crossSection = 0;
1517 TTree *xtree =
dynamic_cast<TTree*
>(fxsec->Get(
"Xsection"));
1521 xtree->SetBranchAddress(
"xsection",&xsection);
1522 xtree->SetBranchAddress(
"ntrials",&ntrials);
1525 crossSection = xsection;
1528 AliFatal(
"Have no tested pyxsec.root files. Need to determine the proper way to get nevents!!");
1533 TKey* key =
static_cast<TKey*
>(fxsec->GetListOfKeys()->At(0));
1534 if (!key)
return false;
1535 TList *list =
dynamic_cast<TList*
>(key->ReadObj());
1536 if (!list)
return false;
1537 TProfile * crossSectionHist =
static_cast<TProfile*
>(list->FindObject(
"h1Xsec"));
1539 if(!(crossSectionHist->GetEntries())) {
1541 AliErrorStream() <<
"No cross section information available in file \"" << fxsec->GetName() <<
"\". Will still attempt to extract cross section information from pythia header.\n";
1544 crossSection = crossSectionHist->GetBinContent(1);
1545 if(!crossSection) AliErrorStream() << GetName() <<
": Cross section 0 for file " << pythiaFileName << std::endl;
1547 TH1F * trialsHist =
static_cast<TH1F*
>(list->FindObject(
"h1Trials"));
1548 trials = trialsHist->GetBinContent(1);
1549 nEvents = trialsHist->GetEntries();
1564 AliDebugStream(3) <<
"Unable to open file \"" << pythiaFileName <<
"\". Will attempt to use values from the hader.";
1579 AliError(
"Chain not initialized before running! Setting up now.");
1627 AliError(
"Unable to get the event to embed. Nothing will be embedded.");
1652 AliErrorStream() <<
"No analysis manager to connect to.\n";
1657 std::string dummyTaskName = GetName();
1658 dummyTaskName +=
"_dummyTask";
1663 AliErrorStream() <<
"Could not remove dummy task \"" << dummyTaskName <<
"\" from analysis manager! Was it added?\n";
1666 tasks->Remove(dummyTask);
1667 AliDebugStream(1) <<
"Removed dummy task named \"" << dummyTaskName <<
"\".\n";
1670 AliErrorStream() <<
"Could not retrieve tasks from the analysis manager.\n";
1680 AliErrorStream() <<
"Enable manual mode in AliEventCuts (though the embedding helper) to access this object.\n";
1692 ::Error(
"AddTaskEmcalEmbeddingHelper",
"No analysis manager to connect to.");
1698 AliVEventHandler* handler = mgr->GetInputEventHandler();
1701 ::Error(
"AddTaskEmcalEmbeddingHelper",
"This task requires an input event handler");
1705 TString name =
"AliAnalysisTaskEmcalEmbeddingHelper";
1708 if (mgrTask)
return mgrTask;
1717 mgr->AddTask(embeddingHelper);
1720 AliAnalysisDataContainer* cInput = mgr->GetCommonInputContainer();
1722 TString outputContainerName(name);
1723 outputContainerName +=
"_histos";
1725 AliAnalysisDataContainer * cOutput = mgr->CreateContainer(outputContainerName.Data(),
1727 AliAnalysisManager::kOutputContainer,
1728 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
1730 mgr->ConnectInput(embeddingHelper, 0, cInput);
1731 mgr->ConnectOutput(embeddingHelper, 1, cOutput);
1733 return embeddingHelper;
1743 ::Error(
"ConfigureEmcalEmbeddingHelperOnLEGOTrain",
"No analysis manager to connect to.");
1753 if (!embeddingHelper) {
1754 AliFatalClass(
"Could not find embedding helper, Did you remember to create it?");
1757 AliInfoClassStream() <<
"Found embedding helper to configure.\n";
1761 mgr->AddTask(
new AliAnalysisTaskSE(
"AliAnalysisTaskEmcalEmbeddingHelper_dummyTask"));
1763 return embeddingHelper;
1773 std::stringstream tempSS;
1776 tempSS << std::boolalpha;
1777 tempSS << GetName() <<
": Embedding helper configuration:\n";
1779 tempSS <<
"Pt Hard Bin: " <<
fPtHardBin <<
"\n";
1781 tempSS <<
"File pattern: \"" <<
fFilePattern <<
"\"\n";
1785 tempSS <<
"Tree name: " <<
fTreeName <<
"\n";
1790 tempSS <<
"Number of files to embed: " <<
fFilenames.size() <<
"\n";
1795 tempSS <<
"Internal event selection centrality range: [" <<
fCentMin <<
", " <<
fCentMax <<
"]\n";
1798 tempSS <<
"Internal event selection centrality range disabled.\n";
1802 tempSS <<
"\nEmbedded event settings:\n";
1803 tempSS <<
"Trigger mask (binary): " << triggerMask <<
"\n";
1806 tempSS <<
"Z vertex cut: " <<
fZVertexCut <<
"\n";
1807 tempSS <<
"Max difference between internal and embedded vertex: " <<
fMaxVertexDist <<
"\n";
1809 if (includeFileList) {
1810 tempSS <<
"\nFiles to embed:\n";
1812 tempSS <<
"\t" <<
filename <<
"\n";
1816 return tempSS.str();
1841 std::ostream & result = myTask.
Print(in);
1853 std::string temp(opt);
1854 bool includeFileList =
false;
1855 if (temp ==
"FILELIST") {
1856 includeFileList =
true;
1858 Printf(
"%s",
toString(includeFileList).c_str());
Bool_t fRandomEventNumberAccess
If true, it will start embedding from a random entry in the file rather than from the first...
Double_t fZVertexCut
Z vertex cut on embedded event.
void UserExec(Option_t *option)
void RecordEmbeddedEventProperties()
void ConnectToAliEn() const
Int_t fPtHardBin
ptHard bin for the given pythia production
bool fMCRejectOutliers
If true, MC outliers will be rejected.
double fPythiaCrossSection
! Pythia cross section for the current event (extracted from the pythia header).
Int_t fLowerEntry
! First entry of the current tree to be used for embedding
TString fFileListFilename
Name of the file list containing paths to files to embed.
void SetEmbeddedEventProperties()
int fPythiaTrialsFromFile
! Average number of trials extracted from a xsec file.
Bool_t fRandomFileAccess
If true, it will start embedding from a random file in the input files list.
TStopwatch fTimer
! Timer for the InitTree() function
Int_t fCurrentEntry
! Current entry in the current tree
TFile * fExternalFile
! External file used for embedding
Int_t fNPtHardBins
Total number of pt hard bins.
TChain * fChain
! External TChain (tree) containing the events available for embedding
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
void RemoveDummyTask() const
bool fAutoConfigurePtHardBins
If true, attempt to auto configure pt hard bins. Only works on the LEGO train.
bool fInitializedConfiguration
Notes if the configuration has been initialized.
bool IsRunInRunlist(const std::string &path) const
AliVHeader * fExternalHeader
! Header of the current external event
AliGenPythiaEventHeader * fPythiaHeader
! Pythia header of the current external event
void DetermineFirstFileToEmbed()
const AliEventCuts * GetInternalEventCuts() const
Event cuts object for accessing centrality, etc from another task if so inclined. ...
void RetrieveTaskPropertiesFromYAMLConfig()
TString fInputFilename
Filename of input root files.
friend std::ostream & operator<<(std::ostream &in, const AliAnalysisTaskEmcalEmbeddingHelper &myTask)
std::vector< std::string > fEmbeddedRunlist
Good runlist for files to embed.
std::string fAutoConfigureBasePath
The base path to the auto configuration (for example, "/alice/cern.ch/user/a/alitrain/") ...
void Terminate(Option_t *option)
std::string fConfigurationPath
Path to YAML configuration.
static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector< std::string > &selections)
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
Create a new TProfile within the container.
std::string fPythiaXSecFilename
Name of the pythia x sec filename (either "pyxsec.root" or "pyxsec_hists.root")
AliAnalysisTaskEmcalEmbeddingHelper()
THashList * GetListOfHistograms() const
Get the list of histograms.
bool fInitializedEmbedding
! Notes where the TChain has been initialized for embedding
bool fUseInternalEventSelection
If true, apply internal event selection though AliEventCuts.
virtual ~AliAnalysisTaskEmcalEmbeddingHelper()
std::string toString(bool includeFileList=false) const
Implementation of task to embed external events.
UInt_t fMaxNumberOfFiles
! Max number of files that are in the TChain
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 PythiaInfoFromCrossSectionFile(std::string filename)
Bool_t CheckIsEmbeddedEventSelected()
void FillProfile(const char *name, double x, double y, double weight=1.)
std::string GenerateUniqueFileListFilename() const
Double_t nEvents
plot quality messages
Double_t fMaxVertexDist
Max distance between Z vertex of internal and embedded event.
AliVEvent * fExternalEvent
! Current external event available for embedding
std::vector< std::string > fPythiaCrossSectionFilenames
Paths to the pythia xsection files.
bool fPrintTimingInfoToLog
Flag to print time to execute InitTree(), for logging purposes.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
TString fTreeName
Name of the ESD/AOD tree where the events are to be found.
void Print(Option_t *opt="") const
Int_t fOffset
! Offset from fLowerEntry where the loop over the tree should start
bool fCreateHisto
If true, create QA histograms.
bool fEmbeddedEventUsed
! If true, the internal event was selected, so the embedded event is used. Defaults to true so other ...
bool IsFileAccessible() const
UInt_t fTriggerMask
Trigger selection mask.
Enhanced TList-derived class that implements correct merging for pt_hard binned production.
bool fWrappedAroundTree
! Notes whether we have wrapped around the tree, which is important if the offset into the tree is no...
Double_t fPtHardJetPtRejectionFactor
Factor which the pt hard bin is multiplied by to compare against pythia header jets pt...
PWG::Tools::AliYAMLConfiguration fYAMLConfig
Hanldes configuration from YAML.
double fPythiaPtHard
! Pt hard of the current event (extracted from the pythia header).
static AliAnalysisTaskEmcalEmbeddingHelper * AddTaskEmcalEmbeddingHelper()
THistManager fHistManager
Manages access to all histograms.
bool fInitializedNewFile
! Notes where the entry indices have been initialized for a new tree in the chain ...
static AliAnalysisTaskEmcalEmbeddingHelper * fgInstance
! Global instance of this class
UInt_t fFileNumber
! File number corresponding to the current tree
bool fUseManualInternalEventCuts
If true, manual event cuts mode will be used for AliEventCuts.
bool IsFileAccessible(std::string filename)
std::string RemoveTrailingSlashes(std::string filename) const
double fCentMax
Maximum centrality for internal event selection.
AliEmcalList * fOutput
! List which owns the output histograms to be saved
AliEventCuts fInternalEventCuts
If enabled, Handles internal event selection.
void UserCreateOutputObjects()
std::string fAutoConfigureIdentifier
How the auto configuration YAML file should be identified. (for example, "rehlersTrain") ...
bool AutoConfigurePtHardBins()
Int_t fUpperEntry
! Last entry of the current tree to be used for embedding
Int_t fFilenameIndex
Index of vector containing paths to files to embed.
double fPythiaCrossSectionFromFile
! Average pythia cross section extracted from a xsec file.
std::vector< std::string > fFilenames
Paths to the files to embed.
bool InitializeYamlConfig()
static AliAnalysisTaskEmcalEmbeddingHelper * ConfigureEmcalEmbeddingHelperOnLEGOTrain()
std::string fAutoConfigureTrainTypePath
The path associated with the train type (for example, "PWGJE/Jets_EMC_PbPb/")
TString fFilePattern
File pattern to select AliEn files using alien_find.
bool Initialize(bool removeDummyTask=false)
void DeterminePythiaXSecFilename()
int fPythiaTrials
! Number of pythia trials for the current event (extracted from the pythia header).
double fCentMin
Minimum centrality for internal event selection.
TList * OpenFile(const char *fname)
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()
std::string ConstructFullPythiaXSecFilename(std::string inputFilename, const std::string &pythiaFilename, bool testIfExists) const