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 fRandomRejectionFactor(1.),
139 fAutoConfigurePtHardBins(false),
140 fAutoConfigureBasePath(
""),
141 fAutoConfigureTrainTypePath(
""),
142 fAutoConfigureIdentifier(
""),
145 fFileListFilename(
""),
148 fConfigurationPath(
""),
150 fPythiaCrossSectionFilenames(),
157 fMaxNumberOfFiles(0),
165 fPythiaTrialsFromFile(0),
166 fPythiaCrossSection(0.),
167 fPythiaCrossSectionFromFile(0.),
169 fPrintTimingInfoToLog(false),
173 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
245 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
252 DefineOutput(1, AliEmcalList::Class());
281 if (result && initializedYAML) {
285 if (removeDummyTask ==
true) {
309 std::vector<std::string> physicsSelection;
340 std::string baseName =
"internalEventSelection";
344 std::vector <double> centralityRange;
347 if (centralityRange.size() != 2) {
348 AliErrorStream() <<
"Passed centrality range with " << centralityRange.size() <<
" entries, but 2 values are required. Ignoring values.\n";
351 AliDebugStream(1) <<
"Setting internal event centrality range to [" << centralityRange.at(0) <<
", " << centralityRange.at(1) <<
"]\n";
405 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()));
416 AliFatal(
"Requested both pt hard bin auto configuration and selected a non-zero pt hard bin. These are incompatible options. Please check your configuration.");
419 if (success ==
false) {
420 AliFatal(
"Pt hard bin auto configuration requested, but it failed. Please check the logs.\n");
436 bool usedFilePattern =
false;
438 usedFilePattern =
true;
439 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern file %s...",
fFilePattern.Data()));
448 filePattern.ReplaceAll(
"alien://",
"");
451 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern \"%s\" and input filename \"%s\"", filePattern.Data(),
fInputFilename.Data()));
452 auto result = gGrid->Query(filePattern.Data(),
fInputFilename.Data());
458 for (
int i = 0; i < result->GetEntries(); i++)
460 TString path = result->GetKey(i,
"turl");
465 outFile << path <<
"\n";
471 AliErrorStream() <<
"Failed to run grid query\n";
479 if (usedFilePattern) {
480 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";
495 std::copy(std::istream_iterator<std::string>(inputFile),
496 std::istream_iterator<std::string>(),
503 AliFatal(TString::Format(
"Filenames from pattern \"%s\" and file list \"%s\" yielded an empty list!",
fFilePattern.Data(),
fFileListFilename.Data()));
510 if (
filename.find(
".zip") != std::string::npos &&
filename.find(
"#") == std::string::npos) {
520 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()));
530 if (
filename.find(
"alien://") != std::string::npos) {
538 unsigned int initialSize = fFilenames.size();
540 fFilenames.erase(std::remove_if(fFilenames.begin(), fFilenames.end(), [](
const std::string &
filename) {
return (::
IsFileAccessible(
filename) ==
false);} ), fFilenames.end());
542 AliInfoStream() <<
"Found " << fFilenames.size() <<
" files to embed (" << (initialSize - fFilenames.size()) <<
" filename(s) inaccessible or invalid)\n";
557 std::string externalEventFilename =
"";
565 std::vector <std::string> pythiaBaseFilenames = {
"pyxsec.root",
"pyxsec_hists.root"};
566 AliInfoStream() <<
"Attempting to determine pythia cross section filename. It can be normal to see some TFile::Init() errors!\n";
567 std::string pythiaXSecFilename =
"";
568 for (
auto & name : pythiaBaseFilenames) {
570 if (pythiaXSecFilename !=
"") {
571 AliDebugStream(4) <<
"Found pythia cross section filename \"" << name <<
"\"\n";
580 AliErrorStream() <<
"Failed to find pythia x sec file! Continuing with only the pythia header!\n";
602 if (path.find(run) != std::string::npos) {
617 AliInfo(
"No Embedding YAML configuration was provided");
620 AliInfoStream() <<
"Embedding YAML configuration was provided: \"" <<
fConfigurationPath <<
"\".\n";
623 if (addedConfig < 0) {
624 AliError(
"YAML Configuration not found!");
649 bool returnValue =
false;
651 AliInfoStream() <<
"Attempting to auto configure pt hard bins.\n";
662 const char * trainNumberStr =
gSystem->Getenv(
"TRAIN_RUN_ID");
663 std::stringstream trainNumberSS;
664 if (trainNumberStr) {
665 trainNumberSS << trainNumberStr;
667 if (trainNumberSS.str() ==
"") {
668 AliFatal(
"Cannot retrieve train ID.");
672 trainNumberSS >> trainNumber;
681 std::string yamlExtension =
".yaml";
682 if (
filename.find(yamlExtension) == std::string::npos) {
689 AliInfoStream() <<
"Train pt hard bin configuration file not available, so creating a new empty configuration named \"" <<
fAutoConfigureIdentifier <<
"\".\n";
694 AliInfoStream() <<
"Opening configuration located at \"" <<
filename <<
"\".\n";
701 int tempTrainNumber = -1;
702 bool getPropertyReturnValue =
false;
703 std::stringstream propertyName;
704 for (
int ptHardBin = 1; ptHardBin <=
fNPtHardBins; ptHardBin++)
706 propertyName.str(
"");
707 propertyName << ptHardBin;
708 getPropertyReturnValue = config.
GetProperty(propertyName.str(), tempTrainNumber,
false);
709 if (getPropertyReturnValue !=
true) {
710 AliInfoStream() <<
"Train " << trainNumber <<
" will use pt hard bin " << ptHardBin <<
".\n";
727 AliDebugStream(2) <<
"Found pt hard bin " << ptHardBin <<
" corresponding to train number " << trainNumber <<
".\n";
729 if (tempTrainNumber == trainNumber) {
730 AliInfoStream() <<
"Train run number " << trainNumber <<
" was already found assigned to pt hard bin " << ptHardBin <<
". That pt hard bin will be used.\n";
753 std::string tempStr =
"";
755 tempStr =
"fileList";
759 tempStr += tempUUID.AsString();
774 while (filename.rbegin() != filename.rend() && *(filename.rbegin()) ==
'/') {
794 AliInfo(TString::Format(
"Starting with random file number %i!",
fFilenameIndex+1));
800 AliWarning(TString::Format(
"File index %i out of range from 0 to %lu! Resetting to 0!",
fFilenameIndex,
fFilenames.size()));
848 AliError(
"====================================================================================================");
849 AliError(
"== No more files available to embed from the TChain! Restarting from the beginning of the TChain! ==");
850 AliError(
"== Be careful to check that this is the desired action! ==");
851 AliError(
"====================================================================================================");
875 if (attempts == 1000)
876 AliWarning(
"After 1000 attempts no event has been accepted by the event selection (trigger, centrality...)!");
890 if (!
fChain)
return kFALSE;
901 AliDebug(4,
"Set event properties");
905 AliAODMCHeader* aodMCH =
dynamic_cast<AliAODMCHeader*
>(
fExternalEvent->FindListObject(AliAODMCHeader::StdBranchName()));
907 for (
UInt_t i = 0;i<aodMCH->GetNCocktailHeaders();i++) {
908 fPythiaHeader =
dynamic_cast<AliGenPythiaEventHeader*
>(aodMCH->GetCocktailHeader(i));
920 AliDebugStream(4) <<
"Taking the pythia cross section avg from the xsec file.\n";
925 AliDebugStream(4) <<
"Taking the pythia trials avg from the xsec file.\n";
930 AliDebugStream(4) <<
"Pythia header is defined!\n";
977 AliDebugStream(3) <<
"Event rejected due to pt hard = 0, indicating a problem with the external event.\n";
989 AliFatal(
"Event selection is not implemented for embedding ESDs.");
999 res = (
dynamic_cast<AliVAODHeader*
>(aev->GetHeader()))->GetOfflineTrigger();
1004 AliDebug(3, Form(
"Event rejected due to physics selection. Event trigger mask: %d, trigger mask selection: %d.",
1005 res, fTriggerMask));
1016 const AliVVertex *externalVert =
fExternalEvent->GetPrimaryVertex();
1017 const AliVVertex *inputVert = AliAnalysisTaskSE::InputEvent()->GetPrimaryVertex();
1018 if (externalVert && inputVert) {
1019 externalVert->GetXYZ(externalVertex);
1020 inputVert->GetXYZ(inputVertex);
1022 if (TMath::Abs(externalVertex[2]) >
fZVertexCut) {
1023 AliDebug(3, Form(
"Event rejected due to Z vertex selection. Event Z vertex: %f, Z vertex cut: %f",
1030 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]));
1032 AliDebug(3, Form(
"Event rejected because the distance between the current and embedded vertices is > %f. " 1033 "Current event vertex (%f, %f, %f), embedded event vertex (%f, %f, %f). Distance = %f",
1034 fMaxVertexDist, inputVertex[0], inputVertex[1], inputVertex[2], externalVertex[0], externalVertex[1], externalVertex[2], dist));
1054 AliDebugStream(4) <<
"Pythia Njets: " << nTriggerJets <<
", pT Hard: " <<
fPythiaPtHard <<
"\n";
1057 for (
Int_t iJet = 0; iJet< nTriggerJets; iJet++) {
1060 jet.SetPxPyPzE(tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3]);
1062 AliDebugStream(5) <<
"Pythia jet " << iJet <<
", pycell jet pT: " << jet.Pt() <<
"\n";
1066 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";
1084 if (!
fChain)
return kFALSE;
1094 AliError(Form(
"Tree name %s not recognized!",
fTreeName.Data()));
1119 AliDebugStream(1) <<
"Configuring AliEventCuts for internal event selection.\n";
1127 bool useEventCutsAutomaticTriggerSelection =
false;
1128 bool res =
fYAMLConfig.
GetProperty(std::vector<std::string>({
"internalEventSelection",
"useEventCutsAutomaticTriggerSelection"}), useEventCutsAutomaticTriggerSelection,
false);
1129 if (res && useEventCutsAutomaticTriggerSelection) {
1131 AliDebugStream(1) <<
"Using the automatic trigger selection from AliEventCuts.\n";
1135 AliDebugStream(1) <<
"Using the trigger selection specified with SelectCollisionCandidates().\n";
1158 eventCutsOutput->SetOwner(kTRUE);
1159 eventCutsOutput->SetName(
"EventCuts");
1163 fOutput->Add(eventCutsOutput);
1171 histName =
"fHistXsection";
1172 histTitle =
"Pythia Cross Section;p_{T} hard bin; XSection";
1176 histName =
"fHistTrials";
1177 histTitle =
"Number of Pythia Trials;p_{T} hard bin;Trials";
1181 histName =
"fHistPtHard";
1182 histTitle =
"p_{T} Hard Spectra;p_{T} hard;Counts";
1186 histName =
"fHistEventCount";
1187 histTitle =
"Event count;Result;Count";
1189 histEventCount->GetXaxis()->SetBinLabel(1,
"Accepted");
1190 histEventCount->GetXaxis()->SetBinLabel(2,
"Rejected");
1193 histName =
"fHistEmbeddedEventRejection";
1194 histTitle =
"Reasons to reject embedded event";
1195 std::vector<std::string> binLabels = {
"PhysSel",
"MCOutlier",
"Vz",
"VertexDist",
"PtHardIs0"};
1196 auto histEmbeddedEventRejection =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1198 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1199 histEmbeddedEventRejection->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1201 histEmbeddedEventRejection->GetYaxis()->SetTitle(
"Counts");
1204 histName =
"fHistEmbeddedEventsAttempted";
1205 histTitle =
"Number of embedded events rejected by event selection before success;Number of rejected events;Counts";
1209 histName =
"fHistNumberOfFilesEmbedded";
1210 histTitle =
"Number of files which contributed events to be embedded";
1214 histName =
"fHistAbsoluteFileNumber";
1215 histTitle =
"Number of times each absolute file number was embedded";
1220 histName =
"fHistInternalEventCutsStats";
1221 histTitle =
"Number of events to pass each cut";
1222 binLabels = {
"passedEventCuts",
"centrality",
"passedRandomRejection",
"passedAllCuts"};
1223 auto histInternalEventCutsStats =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1225 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1226 histInternalEventCutsStats->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1228 histInternalEventCutsStats->GetYaxis()->SetTitle(
"Number of selected events");
1233 histName =
"fInitTreeCPUtime";
1234 histTitle =
"CPU time to execute InitTree() (s)";
1237 histName =
"fInitTreeRealtime";
1238 histTitle =
"Real time to execute InitTree() (s)";
1245 while ((obj = next())) {
1269 if (
filename.find(
"alien://") != std::string::npos) {
1278 bool wrapped =
false;
1279 std::string fullPythiaXSecFilename =
"";
1294 AliDebugStream(4) <<
"Adding file to the embedded input chain \"" << *
filename <<
"\".\n";
1305 AliDebugStream(4) <<
"Adding pythia cross section file \"" << fullPythiaXSecFilename <<
"\".\n";
1316 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";
1321 if (!res)
return kFALSE;
1338 std::string pythiaXSecFilename =
"";
1341 if (externalEventFilename.find(
".zip#") != std::string::npos) {
1342 std::size_t pos = externalEventFilename.find_last_of(
"#");
1343 externalEventFilename.erase(pos);
1347 if (externalEventFilename.find(
".zip") != std::string::npos)
1350 pythiaXSecFilename = externalEventFilename;
1351 pythiaXSecFilename +=
"#";
1352 pythiaXSecFilename += pythiaFilename;
1358 std::unique_ptr<TFile> fTemp(TFile::Open(pythiaXSecFilename.c_str(),
"READ"));
1361 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1362 pythiaXSecFilename =
"";
1365 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1372 pythiaXSecFilename =
gSystem->DirName(externalEventFilename.c_str());
1373 pythiaXSecFilename +=
"/";
1374 pythiaXSecFilename += pythiaFilename;
1379 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1382 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1383 pythiaXSecFilename =
"";
1388 return pythiaXSecFilename;
1399 AliFatal(
"The configuration is not initialized. Check that Initialize() was called!");
1404 if (!res) {
return; }
1408 AliInfo(
"Random event number access enabled!");
1477 AliDebugStream(3) <<
"Failed to retrieve cross section from xsec file. Will still attempt to get the information from the header.\n";
1481 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";
1485 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));
1499 std::cout <<
"InitTree() complete. CPU time: " <<
fTimer.CpuTime() <<
" (s). Real time: " <<
fTimer.RealTime() <<
" (s)." << std::endl;
1515 std::unique_ptr<TFile> fxsec(TFile::Open(pythiaFileName.c_str()));
1520 double crossSection = 0;
1523 TTree *xtree =
dynamic_cast<TTree*
>(fxsec->Get(
"Xsection"));
1527 xtree->SetBranchAddress(
"xsection",&xsection);
1528 xtree->SetBranchAddress(
"ntrials",&ntrials);
1531 crossSection = xsection;
1534 AliFatal(
"Have no tested pyxsec.root files. Need to determine the proper way to get nevents!!");
1539 TKey* key =
static_cast<TKey*
>(fxsec->GetListOfKeys()->At(0));
1540 if (!key)
return false;
1541 TList *list =
dynamic_cast<TList*
>(key->ReadObj());
1542 if (!list)
return false;
1543 TProfile * crossSectionHist =
static_cast<TProfile*
>(list->FindObject(
"h1Xsec"));
1545 if(!(crossSectionHist->GetEntries())) {
1547 AliErrorStream() <<
"No cross section information available in file \"" << fxsec->GetName() <<
"\". Will still attempt to extract cross section information from pythia header.\n";
1550 crossSection = crossSectionHist->GetBinContent(1);
1551 if(!crossSection) AliErrorStream() << GetName() <<
": Cross section 0 for file " << pythiaFileName << std::endl;
1553 TH1F * trialsHist =
static_cast<TH1F*
>(list->FindObject(
"h1Trials"));
1554 trials = trialsHist->GetBinContent(1);
1555 nEvents = trialsHist->GetEntries();
1570 AliDebugStream(3) <<
"Unable to open file \"" << pythiaFileName <<
"\". Will attempt to use values from the hader.";
1585 AliError(
"Chain not initialized before running! Setting up now.");
1643 AliError(
"Unable to get the event to embed. Nothing will be embedded.");
1668 AliErrorStream() <<
"No analysis manager to connect to.\n";
1673 std::string dummyTaskName = GetName();
1674 dummyTaskName +=
"_dummyTask";
1679 AliErrorStream() <<
"Could not remove dummy task \"" << dummyTaskName <<
"\" from analysis manager! Was it added?\n";
1682 tasks->Remove(dummyTask);
1683 AliDebugStream(1) <<
"Removed dummy task named \"" << dummyTaskName <<
"\".\n";
1686 AliErrorStream() <<
"Could not retrieve tasks from the analysis manager.\n";
1696 AliErrorStream() <<
"Enable manual mode in AliEventCuts (though the embedding helper) to access this object.\n";
1708 ::Error(
"AddTaskEmcalEmbeddingHelper",
"No analysis manager to connect to.");
1714 AliVEventHandler* handler = mgr->GetInputEventHandler();
1717 ::Error(
"AddTaskEmcalEmbeddingHelper",
"This task requires an input event handler");
1721 TString name =
"AliAnalysisTaskEmcalEmbeddingHelper";
1724 if (mgrTask)
return mgrTask;
1733 mgr->AddTask(embeddingHelper);
1736 AliAnalysisDataContainer* cInput = mgr->GetCommonInputContainer();
1738 TString outputContainerName(name);
1739 outputContainerName +=
"_histos";
1741 AliAnalysisDataContainer * cOutput = mgr->CreateContainer(outputContainerName.Data(),
1743 AliAnalysisManager::kOutputContainer,
1744 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
1746 mgr->ConnectInput(embeddingHelper, 0, cInput);
1747 mgr->ConnectOutput(embeddingHelper, 1, cOutput);
1749 return embeddingHelper;
1759 ::Error(
"ConfigureEmcalEmbeddingHelperOnLEGOTrain",
"No analysis manager to connect to.");
1769 if (!embeddingHelper) {
1770 AliFatalClass(
"Could not find embedding helper, Did you remember to create it?");
1773 AliInfoClassStream() <<
"Found embedding helper to configure.\n";
1777 mgr->AddTask(
new AliAnalysisTaskSE(
"AliAnalysisTaskEmcalEmbeddingHelper_dummyTask"));
1779 return embeddingHelper;
1789 std::stringstream tempSS;
1792 tempSS << std::boolalpha;
1793 tempSS << GetName() <<
": Embedding helper configuration:\n";
1795 tempSS <<
"Pt Hard Bin: " <<
fPtHardBin <<
"\n";
1797 tempSS <<
"File pattern: \"" <<
fFilePattern <<
"\"\n";
1801 tempSS <<
"Tree name: " <<
fTreeName <<
"\n";
1806 tempSS <<
"Number of files to embed: " <<
fFilenames.size() <<
"\n";
1811 tempSS <<
"Internal event selection centrality range: [" <<
fCentMin <<
", " <<
fCentMax <<
"]\n";
1814 tempSS <<
"Internal event selection centrality range disabled.\n";
1818 tempSS <<
"\nEmbedded event settings:\n";
1819 tempSS <<
"Trigger mask (binary): " << triggerMask <<
"\n";
1822 tempSS <<
"Z vertex cut: " <<
fZVertexCut <<
"\n";
1823 tempSS <<
"Max difference between internal and embedded vertex: " <<
fMaxVertexDist <<
"\n";
1826 if (includeFileList) {
1827 tempSS <<
"\nFiles to embed:\n";
1829 tempSS <<
"\t" <<
filename <<
"\n";
1833 return tempSS.str();
1858 std::ostream & result = myTask.
Print(in);
1870 std::string temp(opt);
1871 bool includeFileList =
false;
1872 if (temp ==
"FILELIST") {
1873 includeFileList =
true;
1875 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
TRandom3 fRandom
for random rejection of events
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") ...
Double_t fRandomRejectionFactor
factor by which to reject events
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