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> 65 AliInfoGeneralStream(
"AliAnalysisTaskEmcalEmbeddingHelper") <<
"Trying to connect to AliEn ...\n";
66 TGrid::Connect(
"alien://");
69 AliFatalGeneral(
"AliAnalysisTaskEmcalEmbeddingHelper",
"Cannot access AliEn!");
83 if (!gGrid && filename.find(
"alien://") != std::string::npos) {
88 if (filename.find(
".zip#") != std::string::npos) {
89 std::size_t pos = filename.find_last_of(
"#");
97 bool res =
gSystem->AccessPathName(filename.c_str());
101 AliDebugGeneralStream(
"AliAnalysisTaskEmcalEmbeddingHelper", 4) <<
"File \"" << filename <<
"\" doees not exist!\n";
114 fTriggerMask(AliVEvent::kAny),
115 fMCRejectOutliers(false),
116 fPtHardJetPtRejectionFactor(4),
119 fInitializedConfiguration(false),
120 fInitializedNewFile(false),
121 fInitializedEmbedding(false),
122 fWrappedAroundTree(false),
126 fRandomEventNumberAccess(kFALSE),
127 fRandomFileAccess(kTRUE),
130 fUseInternalEventSelection(false),
131 fUseManualInternalEventCuts(false),
132 fInternalEventCuts(),
133 fEmbeddedEventUsed(true),
136 fAutoConfigurePtHardBins(false),
137 fAutoConfigureBasePath(
""),
138 fAutoConfigureTrainTypePath(
""),
139 fAutoConfigureIdentifier(
""),
142 fFileListFilename(
""),
145 fConfigurationPath(
""),
147 fPythiaCrossSectionFilenames(),
154 fMaxNumberOfFiles(0),
162 fPythiaTrialsFromFile(0),
163 fPythiaCrossSection(0.),
164 fPythiaCrossSectionFromFile(0.),
168 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
236 AliError(
"An instance of AliAnalysisTaskEmcalEmbeddingHelper already exists: it will be deleted!!!");
243 DefineOutput(1, AliEmcalList::Class());
272 if (result && initializedYAML) {
276 if (removeDummyTask ==
true) {
326 std::string baseName =
"internalEventSelection";
330 std::vector <double> centralityRange;
333 if (centralityRange.size() != 2) {
334 AliErrorStream() <<
"Passed centrality range with " << centralityRange.size() <<
" entries, but 2 values are required. Ignoring values.\n";
337 AliDebugStream(1) <<
"Setting internal event centrality range to [" << centralityRange.at(0) <<
", " << centralityRange.at(1) <<
"]\n";
384 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()));
395 AliFatal(
"Requested both pt hard bin auto configuration and selected a non-zero pt hard bin. These are incompatible options. Please check your configuration.");
398 if (success ==
false) {
399 AliFatal(
"Pt hard bin auto configuration requested, but it failed. Please check the logs.\n");
415 bool usedFilePattern =
false;
417 usedFilePattern =
true;
418 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern file %s...",
fFilePattern.Data()));
427 filePattern.ReplaceAll(
"alien://",
"");
430 AliDebug(2, TString::Format(
"Trying to retrieve file list from AliEn with pattern \"%s\" and input filename \"%s\"", filePattern.Data(),
fInputFilename.Data()));
431 auto result = gGrid->Query(filePattern.Data(),
fInputFilename.Data());
437 for (
int i = 0; i < result->GetEntries(); i++)
439 TString path = result->GetKey(i,
"turl");
444 outFile << path <<
"\n";
450 AliErrorStream() <<
"Failed to run grid query\n";
458 if (usedFilePattern) {
459 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";
474 std::copy(std::istream_iterator<std::string>(inputFile),
475 std::istream_iterator<std::string>(),
482 AliFatal(TString::Format(
"Filenames from pattern \"%s\" and file list \"%s\" yielded an empty list!",
fFilePattern.Data(),
fFileListFilename.Data()));
489 if (
filename.find(
".zip") != std::string::npos &&
filename.find(
"#") == std::string::npos) {
499 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()));
509 if (
filename.find(
"alien://") != std::string::npos) {
517 unsigned int initialSize = fFilenames.size();
519 fFilenames.erase(std::remove_if(fFilenames.begin(), fFilenames.end(), [](
const std::string &
filename) {
return (::
IsFileAccessible(
filename) ==
false);} ), fFilenames.end());
521 AliInfoStream() <<
"Found " << fFilenames.size() <<
" files to embed (" << (initialSize - fFilenames.size()) <<
" filename(s) inaccessible or invalid)\n";
536 std::string externalEventFilename =
"";
544 std::vector <std::string> pythiaBaseFilenames = {
"pyxsec.root",
"pyxsec_hists.root"};
545 AliInfoStream() <<
"Attempting to determine pythia cross section filename. It can be normal to see some TFile::Init() errors!\n";
546 std::string pythiaXSecFilename =
"";
547 for (
auto & name : pythiaBaseFilenames) {
549 if (pythiaXSecFilename !=
"") {
550 AliDebugStream(4) <<
"Found pythia cross section filename \"" << name <<
"\"\n";
559 AliErrorStream() <<
"Failed to find pythia x sec file! Continuing with only the pythia header!\n";
581 if (path.find(run) != std::string::npos) {
596 AliInfo(
"No Embedding %YAML configuration was provided");
599 AliInfoStream() <<
"Embedding %YAML configuration was provided: \"" <<
fConfigurationPath <<
"\".\n";
602 if (addedConfig < 0) {
603 AliError(
"YAML Configuration not found!");
628 bool returnValue =
false;
630 AliInfoStream() <<
"Attempting to auto configure pt hard bins.\n";
641 const char * trainNumberStr =
gSystem->Getenv(
"TRAIN_RUN_ID");
642 std::stringstream trainNumberSS;
643 if (trainNumberStr) {
644 trainNumberSS << trainNumberStr;
646 if (trainNumberSS.str() ==
"") {
647 AliFatal(
"Cannot retrieve train ID.");
651 trainNumberSS >> trainNumber;
660 std::string yamlExtension =
".yaml";
661 if (
filename.find(yamlExtension) == std::string::npos) {
668 AliInfoStream() <<
"Train pt hard bin configuration file not available, so creating a new empty configuration named \"" <<
fAutoConfigureIdentifier <<
"\".\n";
673 AliInfoStream() <<
"Opening configuration located at \"" <<
filename <<
"\".\n";
680 int tempTrainNumber = -1;
681 bool getPropertyReturnValue =
false;
682 std::stringstream propertyName;
683 for (
int ptHardBin = 1; ptHardBin <=
fNPtHardBins; ptHardBin++)
685 propertyName.str(
"");
686 propertyName << ptHardBin;
687 getPropertyReturnValue = config.
GetProperty(propertyName.str(), tempTrainNumber,
false);
688 if (getPropertyReturnValue !=
true) {
689 AliInfoStream() <<
"Train " << trainNumber <<
" will use pt hard bin " << ptHardBin <<
".\n";
706 AliDebugStream(2) <<
"Found pt hard bin " << ptHardBin <<
" corresponding to train number " << trainNumber <<
".\n";
708 if (tempTrainNumber == trainNumber) {
709 AliInfoStream() <<
"Train run number " << trainNumber <<
" was already found assigned to pt hard bin " << ptHardBin <<
". That pt hard bin will be used.\n";
732 std::string tempStr =
"";
734 tempStr =
"fileList";
738 tempStr += tempUUID.AsString();
753 while (filename.rbegin() != filename.rend() && *(filename.rbegin()) ==
'/') {
773 AliInfo(TString::Format(
"Starting with random file number %i!",
fFilenameIndex+1));
779 AliWarning(TString::Format(
"File index %i out of range from 0 to %lu! Resetting to 0!",
fFilenameIndex,
fFilenames.size()));
827 AliError(
"====================================================================================================");
828 AliError(
"== No more files available to embed from the TChain! Restarting from the beginning of the TChain! ==");
829 AliError(
"== Be careful to check that this is the desired action! ==");
830 AliError(
"====================================================================================================");
854 if (attempts == 1000)
855 AliWarning(
"After 1000 attempts no event has been accepted by the event selection (trigger, centrality...)!");
869 if (!
fChain)
return kFALSE;
880 AliDebug(4,
"Set event properties");
884 AliAODMCHeader* aodMCH =
dynamic_cast<AliAODMCHeader*
>(
fExternalEvent->FindListObject(AliAODMCHeader::StdBranchName()));
886 for (
UInt_t i = 0;i<aodMCH->GetNCocktailHeaders();i++) {
887 fPythiaHeader =
dynamic_cast<AliGenPythiaEventHeader*
>(aodMCH->GetCocktailHeader(i));
899 AliDebugStream(4) <<
"Taking the pythia cross section avg from the xsec file.\n";
904 AliDebugStream(4) <<
"Taking the pythia trials avg from the xsec file.\n";
909 AliDebugStream(4) <<
"Pythia header is defined!\n";
956 AliDebugStream(3) <<
"Event rejected due to pt hard = 0, indicating a problem with the external event.\n";
968 AliFatal(
"Event selection is not implemented for embedding ESDs.");
978 res = (
dynamic_cast<AliVAODHeader*
>(aev->GetHeader()))->GetOfflineTrigger();
983 AliDebug(3, Form(
"Event rejected due to physics selection. Event trigger mask: %d, trigger mask selection: %d.",
995 const AliVVertex *externalVert =
fExternalEvent->GetPrimaryVertex();
996 const AliVVertex *inputVert = AliAnalysisTaskSE::InputEvent()->GetPrimaryVertex();
997 if (externalVert && inputVert) {
998 externalVert->GetXYZ(externalVertex);
999 inputVert->GetXYZ(inputVertex);
1001 if (TMath::Abs(externalVertex[2]) >
fZVertexCut) {
1002 AliDebug(3, Form(
"Event rejected due to Z vertex selection. Event Z vertex: %f, Z vertex cut: %f",
1009 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]));
1011 AliDebug(3, Form(
"Event rejected because the distance between the current and embedded vertices is > %f. " 1012 "Current event vertex (%f, %f, %f), embedded event vertex (%f, %f, %f). Distance = %f",
1013 fMaxVertexDist, inputVertex[0], inputVertex[1], inputVertex[2], externalVertex[0], externalVertex[1], externalVertex[2], dist));
1033 AliDebugStream(4) <<
"Pythia Njets: " << nTriggerJets <<
", pT Hard: " <<
fPythiaPtHard <<
"\n";
1036 for (
Int_t iJet = 0; iJet< nTriggerJets; iJet++) {
1039 jet.SetPxPyPzE(tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3]);
1041 AliDebugStream(5) <<
"Pythia jet " << iJet <<
", pycell jet pT: " << jet.Pt() <<
"\n";
1045 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";
1063 if (!
fChain)
return kFALSE;
1073 AliError(Form(
"Tree name %s not recognized!",
fTreeName.Data()));
1098 AliDebugStream(1) <<
"Configuring AliEventCuts for internal event selection.\n";
1106 bool useEventCutsAutomaticTriggerSelection =
false;
1107 bool res =
fYAMLConfig.
GetProperty(std::vector<std::string>({
"internalEventSelection",
"useEventCutsAutomaticTriggerSelection"}), useEventCutsAutomaticTriggerSelection,
false);
1108 if (res && useEventCutsAutomaticTriggerSelection) {
1110 AliDebugStream(1) <<
"Using the automatic trigger selection from AliEventCuts.\n";
1114 AliDebugStream(1) <<
"Using the trigger selection specified with SelectCollisionCandidates()\n.";
1132 eventCutsOutput->SetOwner(kTRUE);
1133 eventCutsOutput->SetName(
"EventCuts");
1137 fOutput->Add(eventCutsOutput);
1145 histName =
"fHistXsection";
1146 histTitle =
"Pythia Cross Section;p_{T} hard bin; XSection";
1150 histName =
"fHistTrials";
1151 histTitle =
"Number of Pythia Trials;p_{T} hard bin;Trials";
1155 histName =
"fHistPtHard";
1156 histTitle =
"p_{T} Hard Spectra;p_{T} hard;Counts";
1160 histName =
"fHistEventCount";
1161 histTitle =
"Event count;Result;Count";
1163 histEventCount->GetXaxis()->SetBinLabel(1,
"Accepted");
1164 histEventCount->GetXaxis()->SetBinLabel(2,
"Rejected");
1167 histName =
"fHistEmbeddedEventRejection";
1168 histTitle =
"Reasons to reject embedded event";
1169 std::vector<std::string> binLabels = {
"PhysSel",
"MCOutlier",
"Vz",
"VertexDist",
"PtHardIs0"};
1170 auto histEmbeddedEventRejection =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1172 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1173 histEmbeddedEventRejection->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1175 histEmbeddedEventRejection->GetYaxis()->SetTitle(
"Counts");
1178 histName =
"fHistEmbeddedEventsAttempted";
1179 histTitle =
"Number of embedded events rejected by event selection before success;Number of rejected events;Counts";
1183 histName =
"fHistNumberOfFilesEmbedded";
1184 histTitle =
"Number of files which contributed events to be embedded";
1188 histName =
"fHistAbsoluteFileNumber";
1189 histTitle =
"Number of times each absolute file number was embedded";
1194 histName =
"fHistInternalEventCutsStats";
1195 histTitle =
"Number of events to pass each cut";
1196 binLabels = {
"passedEventCuts",
"centrality",
"passedAllCuts"};
1197 auto histInternalEventCutsStats =
fHistManager.
CreateTH1(histName, histTitle, binLabels.size(), 0, binLabels.size());
1199 for (
unsigned int i = 1; i <= binLabels.size(); i++) {
1200 histInternalEventCutsStats->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
1202 histInternalEventCutsStats->GetYaxis()->SetTitle(
"Number of selected events");
1208 while ((obj = next())) {
1232 if (
filename.find(
"alien://") != std::string::npos) {
1241 bool wrapped =
false;
1242 std::string fullPythiaXSecFilename =
"";
1257 AliDebugStream(4) <<
"Adding file to the embedded input chain \"" << *
filename <<
"\".\n";
1268 AliDebugStream(4) <<
"Adding pythia cross section file \"" << fullPythiaXSecFilename <<
"\".\n";
1279 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";
1284 if (!res)
return kFALSE;
1301 std::string pythiaXSecFilename =
"";
1304 if (externalEventFilename.find(
".zip#") != std::string::npos) {
1305 std::size_t pos = externalEventFilename.find_last_of(
"#");
1306 externalEventFilename.erase(pos);
1310 if (externalEventFilename.find(
".zip") != std::string::npos)
1313 pythiaXSecFilename = externalEventFilename;
1314 pythiaXSecFilename +=
"#";
1315 pythiaXSecFilename += pythiaFilename;
1321 std::unique_ptr<TFile> fTemp(TFile::Open(pythiaXSecFilename.c_str(),
"READ"));
1324 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1325 pythiaXSecFilename =
"";
1328 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1335 pythiaXSecFilename =
gSystem->DirName(externalEventFilename.c_str());
1336 pythiaXSecFilename +=
"/";
1337 pythiaXSecFilename += pythiaFilename;
1342 AliDebugStream(4) <<
"Found pythia cross section file \"" << pythiaXSecFilename.c_str() <<
"\".\n";
1345 AliDebugStream(4) <<
"File " << pythiaXSecFilename.c_str() <<
" does not exist!\n";
1346 pythiaXSecFilename =
"";
1351 return pythiaXSecFilename;
1362 AliFatal(
"The configuration is not initialized. Check that Initialize() was called!");
1367 if (!res) {
return; }
1371 AliInfo(
"Random event number access enabled!");
1434 AliDebugStream(3) <<
"Failed to retrieve cross section from xsec file. Will still attempt to get the information from the header.\n";
1438 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";
1442 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));
1463 std::unique_ptr<TFile> fxsec(TFile::Open(pythiaFileName.c_str()));
1468 double crossSection = 0;
1471 TTree *xtree =
dynamic_cast<TTree*
>(fxsec->Get(
"Xsection"));
1475 xtree->SetBranchAddress(
"xsection",&xsection);
1476 xtree->SetBranchAddress(
"ntrials",&ntrials);
1479 crossSection = xsection;
1482 AliFatal(
"Have no tested pyxsec.root files. Need to determine the proper way to get nevents!!");
1487 TKey* key =
static_cast<TKey*
>(fxsec->GetListOfKeys()->At(0));
1488 if (!key)
return false;
1489 TList *list =
dynamic_cast<TList*
>(key->ReadObj());
1490 if (!list)
return false;
1491 TProfile * crossSectionHist =
static_cast<TProfile*
>(list->FindObject(
"h1Xsec"));
1493 if(!(crossSectionHist->GetEntries())) {
1495 AliErrorStream() <<
"No cross section information available in file \"" << fxsec->GetName() <<
"\". Will still attempt to extract cross section information from pythia header.\n";
1498 crossSection = crossSectionHist->GetBinContent(1);
1499 if(!crossSection) AliErrorStream() << GetName() <<
": Cross section 0 for file " << pythiaFileName << std::endl;
1501 TH1F * trialsHist =
static_cast<TH1F*
>(list->FindObject(
"h1Trials"));
1502 trials = trialsHist->GetBinContent(1);
1503 nEvents = trialsHist->GetEntries();
1518 AliDebugStream(3) <<
"Unable to open file \"" << pythiaFileName <<
"\". Will attempt to use values from the hader.";
1533 AliError(
"Chain not initialized before running! Setting up now.");
1581 AliError(
"Unable to get the event to embed. Nothing will be embedded.");
1606 AliErrorStream() <<
"No analysis manager to connect to.\n";
1611 std::string dummyTaskName = GetName();
1612 dummyTaskName +=
"_dummyTask";
1617 AliErrorStream() <<
"Could not remove dummy task \"" << dummyTaskName <<
"\" from analysis manager! Was it added?\n";
1620 tasks->Remove(dummyTask);
1621 AliDebugStream(1) <<
"Removed dummy task named \"" << dummyTaskName <<
"\".\n";
1624 AliErrorStream() <<
"Could not retrieve tasks from the analysis manager.\n";
1634 AliErrorStream() <<
"Enable manual mode in AliEventCuts (though the embedding helper) to access this object.\n";
1646 ::Error(
"AddTaskEmcalEmbeddingHelper",
"No analysis manager to connect to.");
1652 AliVEventHandler* handler = mgr->GetInputEventHandler();
1655 ::Error(
"AddTaskEmcalEmbeddingHelper",
"This task requires an input event handler");
1659 TString name =
"AliAnalysisTaskEmcalEmbeddingHelper";
1662 if (mgrTask)
return mgrTask;
1671 mgr->AddTask(embeddingHelper);
1674 AliAnalysisDataContainer* cInput = mgr->GetCommonInputContainer();
1676 TString outputContainerName(name);
1677 outputContainerName +=
"_histos";
1679 AliAnalysisDataContainer * cOutput = mgr->CreateContainer(outputContainerName.Data(),
1681 AliAnalysisManager::kOutputContainer,
1682 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
1684 mgr->ConnectInput(embeddingHelper, 0, cInput);
1685 mgr->ConnectOutput(embeddingHelper, 1, cOutput);
1687 return embeddingHelper;
1697 ::Error(
"ConfigureEmcalEmbeddingHelperOnLEGOTrain",
"No analysis manager to connect to.");
1707 if (!embeddingHelper) {
1708 AliFatalClass(
"Could not find embedding helper, Did you remember to create it?");
1711 AliInfoClassStream() <<
"Found embedding helper to configure.\n";
1715 mgr->AddTask(
new AliAnalysisTaskSE(
"AliAnalysisTaskEmcalEmbeddingHelper_dummyTask"));
1717 return embeddingHelper;
1727 std::stringstream tempSS;
1730 tempSS << std::boolalpha;
1731 tempSS << GetName() <<
": Embedding helper configuration:\n";
1733 tempSS <<
"Pt Hard Bin: " <<
fPtHardBin <<
"\n";
1735 tempSS <<
"File pattern: \"" <<
fFilePattern <<
"\"\n";
1739 tempSS <<
"Tree name: " <<
fTreeName <<
"\n";
1743 tempSS <<
"Number of files to embed: " <<
fFilenames.size() <<
"\n";
1748 tempSS <<
"Internal event selection centrality range: [" <<
fCentMin <<
", " <<
fCentMax <<
"]\n";
1751 tempSS <<
"Internal event selection centrality range disabled.\n";
1755 tempSS <<
"\nEmbedded event settings:\n";
1756 tempSS <<
"Trigger mask (binary): " << triggerMask <<
"\n";
1759 tempSS <<
"Z vertex cut: " <<
fZVertexCut <<
"\n";
1760 tempSS <<
"Max difference between internal and embedded vertex: " <<
fMaxVertexDist <<
"\n";
1762 if (includeFileList) {
1763 tempSS <<
"\nFiles to embed:\n";
1765 tempSS <<
"\t" <<
filename <<
"\n";
1769 return tempSS.str();
1794 std::ostream & result = myTask.
Print(in);
1806 std::string temp(opt);
1807 bool includeFileList =
false;
1808 if (temp ==
"FILELIST") {
1809 includeFileList =
true;
1811 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.
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.
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.
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