AliPhysics  608b256 (608b256)
AliAnalysisTaskEmcalEmbeddingHelper.h
Go to the documentation of this file.
1 #ifndef ALIANALYSISTASKEMCALEMBEDDINGHELPER_H
2 #define ALIANALYSISTASKEMCALEMBEDDINGHELPER_H
3 
16 /* Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
17  * See cxx source for full Copyright notice */
18 
19 class TString;
20 class TChain;
21 class TFile;
22 class AliVEvent;
23 class AliVHeader;
24 class AliGenPythiaEventHeader;
25 class AliEmcalList;
26 
27 #include <iosfwd>
28 #include <vector>
29 #include <string>
30 
31 #include <TStopwatch.h>
32 #include <TRandom3.h>
33 #include <AliAnalysisTaskSE.h>
34 #include "AliEventCuts.h"
35 #include "AliYAMLConfiguration.h"
36 #include "THistManager.h"
37 
72  public:
73 
75  AliAnalysisTaskEmcalEmbeddingHelper(const char *name) ;
77 
82  void UserExec(Option_t *option) ;
84  void Terminate(Option_t *option) ;
85  /* @} */
86 
88 
93  AliVEvent* GetExternalEvent() const { return fExternalEvent ; }
94 
106  bool Initialize(bool removeDummyTask = false);
107 
108  // Get
109  Int_t GetPtHardBin() const { return fPtHardBin; }
110  Int_t GetNPtHardBins() const { return fNPtHardBins; }
111  TString GetTreeName() const { return fTreeName; }
114  TString GetFilePattern() const { return fFilePattern; }
118  bool GetCreateHistos() const { return fCreateHisto; }
119 
120  // Set
122  void SetPtHardBin(Int_t n) { fPtHardBin = n; }
126  void SetESD(const char * treeName = "esdTree") { fTreeName = treeName; }
128  void SetAOD(const char * treeName = "aodTree") { fTreeName = treeName; }
139  void SetFilePattern(const char * pattern) { fFilePattern = pattern; }
150  void SetCreateHistos(bool b) { fCreateHisto = b; }
152  void SetConfigurationPath(const char * path) { fConfigurationPath = path; }
153  /* @} */
154 
172  bool EmbeddedEventUsed() const { return fEmbeddedEventUsed; }
180  const AliEventCuts * GetInternalEventCuts() const { return (fUseInternalEventSelection ? &fInternalEventCuts : nullptr); }
183  AliEventCuts * GetInternalEventCuts();
185  void SetCentralityRange(double min, double max) { fCentMin = min; fCentMax = max; }
186  void SetRandomRejectionFactor(Double_t configure = 1.) { fRandomRejectionFactor = configure; }
187  /* @} */
188 
193  UInt_t GetTriggerMask() const { return fTriggerMask; }
194  bool GetMCRejectOutliers() const { return fMCRejectOutliers; }
196  Double_t GetZVertexCut() const { return fZVertexCut; }
198 
199  void SetTriggerMask(UInt_t triggerMask) { fTriggerMask = triggerMask; }
202  void SetZVertexCut(Double_t zVertex) { fZVertexCut = zVertex; }
203  void SetMaxVertexDistance(Double_t distance) { fMaxVertexDist = distance; }
204  /* @} */
205 
210  AliVHeader * GetEventHeader() const { return fExternalHeader; }
211  AliGenPythiaEventHeader * GetPythiaHeader() const { return fPythiaHeader; }
212  double GetPythiaXSection() const { return fPythiaCrossSection; }
213  int GetPythiaTrials() const { return fPythiaTrials; }
214  double GetPythiaPtHard() const { return fPythiaPtHard; }
215  /* @} */
216 
223  std::string GetAutoConfigureBasePath() const { return fAutoConfigureBasePath; }
225  std::string GetAutoConfigureIdentifier() const { return fAutoConfigureIdentifier; }
226 
227  void SetAutoConfigurePtHardBins(bool configure = true) { fAutoConfigurePtHardBins = configure; }
228  void SetAutoConfigureBasePath(std::string path) { fAutoConfigureBasePath = path; }
230  void SetAutoConfigureIdentifier(std::string path) { fAutoConfigureIdentifier = path; }
231  /* @} */
232 
256 
257  // Printing
258  friend std::ostream & operator<<(std::ostream &in, const AliAnalysisTaskEmcalEmbeddingHelper &myTask);
259  void Print(Option_t* opt = "") const;
260  std::ostream & Print(std::ostream &in) const;
261  std::string toString(bool includeFileList = false) const;
262  /* @} */
263 
279  AliVEvent* InputEvent() const { return GetExternalEvent(); }
280  /* @} */
281 
282  protected:
284  bool GetFilenames() ;
286  bool IsRunInRunlist(const std::string & path) const;
287  bool InitializeYamlConfig();
289  std::string GenerateUniqueFileListFilename() const;
290  std::string RemoveTrailingSlashes(std::string filename) const;
292  void SetupEmbedding() ;
294  std::string ConstructFullPythiaXSecFilename(std::string inputFilename, const std::string & pythiaFilename, bool testIfExists) const;
295  Bool_t GetNextEntry() ;
300  Bool_t InitEvent() ;
301  void InitTree() ;
302  bool PythiaInfoFromCrossSectionFile(std::string filename);
303  // Validation helper
305  // Helper functions
306  bool IsFileAccessible() const;
307  void ConnectToAliEn() const;
308  // LEGO Train utility
309  void RemoveDummyTask() const;
310 
316 
321 
327  bool fCreateHisto ;
329 
332  AliEventCuts fInternalEventCuts;
336  double fCentMin ;
337  double fCentMax ;
339  TRandom3 fRandom ;
340 
345 
350  std::vector <std::string> fFilenames ;
351  std::string fConfigurationPath;
352  std::vector <std::string> fEmbeddedRunlist ;
353  std::string fPythiaXSecFilename;
354  std::vector <std::string> fPythiaCrossSectionFilenames;
355  TFile *fExternalFile ;
365  AliVEvent *fExternalEvent ;
366  AliVHeader *fExternalHeader ;
367  AliGenPythiaEventHeader *fPythiaHeader ;
368 
373  double fPythiaPtHard ;
374 
377 
379 
380  private:
383 
387 };
388 #endif
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.
const char * filename
Definition: TestFCM.C:1
void SetPrintTimingInfoToLog(bool b)
Set whether to print and plot execution time of InitTree()
void SetESD(const char *treeName="esdTree")
Set to embed from ESD.
double Double_t
Definition: External.C:58
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.
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
void SetConfigurationPath(const char *path)
Set path to YAML configuration file.
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
AliVEvent * GetExternalEvent() const
Retrieve the embedded event from the embedding helper.
AliVHeader * fExternalHeader
! Header of the current external event
void SetFilePattern(const char *pattern)
Sets the file pattern to select AliEn files. This pattern is used as input to the alien_find command...
AliGenPythiaEventHeader * fPythiaHeader
! Pythia header of the current external event
void SetCentralityRange(double min, double max)
Set internal event centrality selection.
const AliEventCuts * GetInternalEventCuts() const
Event cuts object for accessing centrality, etc from another task if so inclined. ...
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/") ...
std::string fConfigurationPath
Path to YAML configuration.
int Int_t
Definition: External.C:63
std::string fPythiaXSecFilename
Name of the pythia x sec filename (either "pyxsec.root" or "pyxsec_hists.root")
unsigned int UInt_t
Definition: External.C:33
bool fInitializedEmbedding
! Notes where the TChain has been initialized for embedding
bool fUseInternalEventSelection
If true, apply internal event selection though AliEventCuts.
std::string toString(bool includeFileList=false) const
bool GetUseManualInternalEventSelection() const
Whether to use manual cuts for AliEventCuts.
Implementation of task to embed external events.
UInt_t fMaxNumberOfFiles
! Max number of files that are in the TChain
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 fValidatedPhysicsSelection
Validate that the physics selection is set appropriately.
void SetRandomFileAccess(Bool_t b)
Randomly select the first file to embed from the file list. Continues sequentially afterwards...
bool fPrintTimingInfoToLog
Flag to print time to execute InitTree(), for logging purposes.
TString fTreeName
Name of the ESD/AOD tree where the events are to be found.
void SetNPtHardBins(Int_t n)
Set the number of pt hard bins in the production to properly format the histograms.
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 ...
Enhanced TList-derived class that implements correct merging for pt_hard binned production.
Definition: AliEmcalList.h:25
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).
void SetFileListFilename(const char *filename)
Set the path to a file containing the list of files to embed.
AliGenPythiaEventHeader * GetPythiaHeader() const
static AliAnalysisTaskEmcalEmbeddingHelper * AddTaskEmcalEmbeddingHelper()
void SetPtHardBin(Int_t n)
Set the pt hard bin which will be added into the file pattern. Can also be omitted and set directly i...
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.
YAML configuration class for AliPhysics.
bool GetUseInternalEventSelection() const
Whether internal event selection is enabled.
Container class for histograms.
Definition: THistManager.h:99
std::string RemoveTrailingSlashes(std::string filename) const
AliAnalysisTaskEmcalEmbeddingHelper & operator=(const AliAnalysisTaskEmcalEmbeddingHelper &)
void SetCreateHistos(bool b)
Create QA histograms. These are necessary for proper scaling, so be careful disabling them! ...
double fCentMax
Maximum centrality for internal event selection.
const char Option_t
Definition: External.C:48
AliEmcalList * fOutput
! List which owns the output histograms to be saved
AliEventCuts fInternalEventCuts
If enabled, Handles internal event selection.
UInt_t fInternalEventTriggerMask
Internal event physics selection (trigger mask) to be used with AliEventCuts.
bool Bool_t
Definition: External.C:53
std::string fAutoConfigureIdentifier
How the auto configuration YAML file should be identified. (for example, "rehlersTrain") ...
Double_t fRandomRejectionFactor
factor by which to reject events
void SetStartingFileIndex(Int_t n)
Select the file ID to start embedding from.
void SetAOD(const char *treeName="aodTree")
Set to embed from AOD.
void SetUseInternalEventSelection(bool b=true)
Enable internal event selection. Can also be enabled through the YAML configuration.
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.
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.
AliVEvent * InputEvent() const
SHOULD NOT BE USED! Use GetExternalEvent()! SHOULD NOT BE USED! Use GetExternalEvent()! Returns the e...
int fPythiaTrials
! Number of pythia trials for the current event (extracted from the pythia header).
double fCentMin
Minimum centrality for internal event selection.
Bool_t reject
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()
std::string ConstructFullPythiaXSecFilename(std::string inputFilename, const std::string &pythiaFilename, bool testIfExists) const