All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sbnd::AnalysisTree Class Reference

Creates a simple ROOT tree with tracking and calorimetry information. More...

Inheritance diagram for sbnd::AnalysisTree:

Public Member Functions

 AnalysisTree (fhicl::ParameterSet const &pset)
 
virtual ~AnalysisTree ()
 
void analyze (const art::Event &evt)
 read access to event More...
 
void beginSubRun (const art::SubRun &sr)
 

Private Member Functions

void HitsPurity (detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit > > const &hits, Int_t &trackid, Float_t &purity, double &maxe)
 
void HitTruth (detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit, Int_t &truthid, Float_t &frac, Float_t &energy, Float_t &numElectrons)
 
bool HitTruthId (detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit, Int_t &mcid)
 
bool TrackIdToMCTruth (Int_t const trkID, art::Ptr< simb::MCTruth > &mctruth)
 
bool DoesHitHaveSimChannel (std::vector< const sim::SimChannel * > chans, art::Ptr< recob::Hit > const &hit)
 
double length (const recob::Track &track)
 
double length (const simb::MCParticle &part, TVector3 &start, TVector3 &end)
 
double bdist (const recob::Track::Point_t &pos)
 
size_t GetNTrackers () const
 Returns the number of trackers configured. More...
 
void CreateData (bool bClearData=false)
 Creates the structure for the tree data; optionally initializes it. More...
 
void SetAddresses ()
 Sets the addresses of all the tree branches, creating the missing ones. More...
 
void SetTrackerAddresses (size_t iTracker)
 
void SetVerticesAddresses (size_t iTracker)
 
void SetShowerAddresses ()
 Sets the addresses of all the tree branches, creating the missing ones. More...
 
void CreateTree (bool bClearData=false)
 Create the output tree and the data structures, if needed. More...
 
void DestroyData ()
 Destroy the local buffers (existing branches will point to invalid address!) More...
 
void CheckData (std::string caller) const
 Helper function: throws if no data structure is available. More...
 
void CheckTree (std::string caller) const
 Helper function: throws if no tree is available. More...
 

Private Attributes

TTree * fTree
 
AnalysisTreeDataStructfData
 
AnalysisTreeDataStruct::SubRunData_t SubRunData
 
std::string fDigitModuleLabel
 
std::string fHitsModuleLabel
 
std::string fLArG4ModuleLabel
 
std::string fTPCSimChannelModuleLabel
 
std::string fCalDataModuleLabel
 
std::string fGenieGenModuleLabel
 
std::string fCryGenModuleLabel
 
std::string fG4ModuleLabel
 
std::string fPFParticleModuleLabel
 
std::string fShowerModuleLabel
 
std::vector< std::string > fVertexModuleLabel
 
std::vector< std::string > fTrackModuleLabel
 
std::vector< std::string > fCalorimetryModuleLabel
 
std::vector< std::string > fParticleIDModuleLabel
 
std::string fPOTModuleLabel
 
bool fUseBuffer
 whether to use a permanent buffer (faster, huge memory) More...
 
bool fSaveAuxDetInfo
 whether to extract and save auxiliary detector data More...
 
bool fSaveCryInfo
 
bool fSaveGenieInfo
 whether to extract and save CRY particle data More...
 
bool fSaveGeantInfo
 whether to extract and save Genie information More...
 
bool fSaveHitInfo
 whether to extract and save Geant information More...
 
bool fSaveTrackInfo
 whether to extract and save Hit information More...
 
bool fSaveShowerInfo
 whether to extract and save Track information More...
 
bool fSaveVertexInfo
 whether to extract and save Shower information More...
 
bool fSaveSliceInfo
 whether to extract and save Vertex information More...
 
std::vector< bool > fSaveHierarchyInfo
 whether to extract and save Slice information More...
 
bool fSaveShowerHierarchyInfo
 if the user wants to access the showers with their hierarchy More...
 
std::vector< std::string > fCosmicTaggerAssocLabel
 
std::vector< std::string > fFlashMatchAssocLabel
 
bool isCosmics
 if it contains cosmics More...
 
bool fSaveCaloCosmics
 save calorimetry information for cosmics More...
 
float fG4minE
 Energy threshold to save g4 particle info. More...
 
calo::CalorimetryAlg fCaloAlg
 
art::ServiceHandle
< cheat::ParticleInventoryService
pi_serv
 
art::ServiceHandle
< cheat::BackTrackerService
bt_serv
 

Detailed Description

Creates a simple ROOT tree with tracking and calorimetry information.

Configuration parameters

Definition at line 819 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

Constructor & Destructor Documentation

sbnd::AnalysisTree::AnalysisTree ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 2100 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

2100  :
2101  EDAnalyzer(pset),
2102  fTree(nullptr), fData(nullptr),
2103  fDigitModuleLabel (pset.get< std::string >("DigitModuleLabel") ),
2104  fHitsModuleLabel (pset.get< std::string >("HitsModuleLabel") ),
2105  fLArG4ModuleLabel (pset.get< std::string >("LArGeantModuleLabel") ),
2106  fTPCSimChannelModuleLabel (pset.get< std::string >("TPCSimChannelModuleLabel") ),
2107  fCalDataModuleLabel (pset.get< std::string >("CalDataModuleLabel") ),
2108  fGenieGenModuleLabel (pset.get< std::string >("GenieGenModuleLabel") ),
2109  fCryGenModuleLabel (pset.get< std::string >("CryGenModuleLabel") ),
2110  fG4ModuleLabel (pset.get< std::string >("G4ModuleLabel") ),
2111  fPFParticleModuleLabel (pset.get< std::string> ("PFParticleModuleLabel") ),
2112  fShowerModuleLabel (pset.get< std::string> ("ShowerModuleLabel") ),
2113  fVertexModuleLabel (pset.get< std::vector<std::string> >("VertexModuleLabel") ),
2114  fTrackModuleLabel (pset.get< std::vector<std::string> >("TrackModuleLabel") ),
2115  fCalorimetryModuleLabel (pset.get< std::vector<std::string> >("CalorimetryModuleLabel")),
2116  fParticleIDModuleLabel (pset.get< std::vector<std::string> >("ParticleIDModuleLabel") ),
2117  fPOTModuleLabel (pset.get< std::string >("POTModuleLabel") ),
2118 
2119  fUseBuffer (pset.get< bool >("UseBuffers", false)),
2120  fSaveAuxDetInfo (pset.get< bool >("SaveAuxDetInfo", false)),
2121  fSaveCryInfo (pset.get< bool >("SaveCryInfo", false)),
2122  fSaveGenieInfo (pset.get< bool >("SaveGenieInfo", false)),
2123  fSaveGeantInfo (pset.get< bool >("SaveGeantInfo", false)),
2124  fSaveHitInfo (pset.get< bool >("SaveHitInfo", false)),
2125  fSaveTrackInfo (pset.get< bool >("SaveTrackInfo", false)),
2126  fSaveShowerInfo (pset.get< bool >("SaveShowerInfo", false)),
2127  fSaveVertexInfo (pset.get< bool >("SaveVertexInfo", false)),
2128  fSaveSliceInfo (pset.get< bool >("SaveSliceInfo",true)),
2129  fSaveHierarchyInfo (pset.get< std::vector<bool> >("SaveHierarchyInfo", {false})),
bool fSaveGenieInfo
whether to extract and save CRY particle data
std::vector< bool > fSaveHierarchyInfo
whether to extract and save Slice information
bool fSaveTrackInfo
whether to extract and save Hit information
bool fSaveShowerInfo
whether to extract and save Track information
bool fSaveVertexInfo
whether to extract and save Shower information
bool fSaveSliceInfo
whether to extract and save Vertex information
bool fSaveGeantInfo
whether to extract and save Genie information
bool fUseBuffer
whether to use a permanent buffer (faster, huge memory)
bool fSaveHitInfo
whether to extract and save Geant information
bool fSaveAuxDetInfo
whether to extract and save auxiliary detector data
virtual sbnd::AnalysisTree::~AnalysisTree ( )
virtual

Member Function Documentation

void sbnd::AnalysisTree::analyze ( const art::Event &  evt)

read access to event

double sbnd::AnalysisTree::bdist ( const recob::Track::Point_t pos)
private
void sbnd::AnalysisTree::beginSubRun ( const art::SubRun &  sr)
void sbnd::AnalysisTree::CheckData ( std::string  caller) const
inlineprivate

Helper function: throws if no data structure is available.

Definition at line 969 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

970  {
971  if (fData) return;
972  throw art::Exception(art::errors::LogicError)
973  << "AnalysisTree::" << caller << ": no data";
974  } // CheckData()
void sbnd::AnalysisTree::CheckTree ( std::string  caller) const
inlineprivate

Helper function: throws if no tree is available.

Definition at line 976 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

977  {
978  if (fTree) return;
979  throw art::Exception(art::errors::LogicError)
980  << "AnalysisTree::" << caller << ": no tree";
981  } // CheckData()
void sbnd::AnalysisTree::CreateData ( bool  bClearData = false)
inlineprivate

Creates the structure for the tree data; optionally initializes it.

Definition at line 901 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

902  {
903  if (!fData) {
904  fData = new AnalysisTreeDataStruct(GetNTrackers());
909  }
910  else {
918  if (bClearData) fData->Clear();
919  }
920  } // CreateData()
bool fSaveGenieInfo
whether to extract and save CRY particle data
void SetTrackers(size_t nTrackers)
Allocates data structures for the given number of trackers (no Clear())
bool fSaveTrackInfo
whether to extract and save Hit information
bool fSaveShowerInfo
whether to extract and save Track information
bool fSaveVertexInfo
whether to extract and save Shower information
void SetBits(unsigned int setbits, bool unset=false)
Sets the specified bits.
bool fSaveSliceInfo
whether to extract and save Vertex information
bool fSaveGeantInfo
whether to extract and save Genie information
void SetVertices(size_t nTrackers)
Allocates data structures for the given number of trackers (no Clear())
size_t GetNTrackers() const
Returns the number of trackers configured.
bool fSaveHitInfo
whether to extract and save Geant information
bool fSaveAuxDetInfo
whether to extract and save auxiliary detector data
void sbnd::AnalysisTree::CreateTree ( bool  bClearData = false)
private

Create the output tree and the data structures, if needed.

void sbnd::AnalysisTree::DestroyData ( )
inlineprivate

Destroy the local buffers (existing branches will point to invalid address!)

Definition at line 966 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

966 { if (fData) { delete fData; fData = nullptr; } }
bool sbnd::AnalysisTree::DoesHitHaveSimChannel ( std::vector< const sim::SimChannel * >  chans,
art::Ptr< recob::Hit > const &  hit 
)
private
size_t sbnd::AnalysisTree::GetNTrackers ( ) const
inlineprivate

Returns the number of trackers configured.

Definition at line 898 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

898 { return fTrackModuleLabel.size(); }
void sbnd::AnalysisTree::HitsPurity ( detinfo::DetectorClocksData const &  clockData,
std::vector< art::Ptr< recob::Hit > > const &  hits,
Int_t &  trackid,
Float_t &  purity,
double &  maxe 
)
private
void sbnd::AnalysisTree::HitTruth ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::Hit > const &  hit,
Int_t &  truthid,
Float_t &  frac,
Float_t &  energy,
Float_t &  numElectrons 
)
private
bool sbnd::AnalysisTree::HitTruthId ( detinfo::DetectorClocksData const &  clockData,
art::Ptr< recob::Hit > const &  hit,
Int_t &  mcid 
)
private
double sbnd::AnalysisTree::length ( const recob::Track track)
private
double sbnd::AnalysisTree::length ( const simb::MCParticle &  part,
TVector3 &  start,
TVector3 &  end 
)
private
void sbnd::AnalysisTree::SetAddresses ( )
inlineprivate

Sets the addresses of all the tree branches, creating the missing ones.

Definition at line 923 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

924  {
925  CheckData("SetAddress()"); CheckTree("SetAddress()");
927  } // SetAddresses()
void CheckTree(std::string caller) const
Helper function: throws if no tree is available.
void CheckData(std::string caller) const
Helper function: throws if no data structure is available.
std::vector< bool > fSaveHierarchyInfo
whether to extract and save Slice information
void SetAddresses(TTree *pTree, const std::vector< std::string > &trackers, std::string showerLabel, const std::vector< std::string > &vertexLabels, bool isCosmics, const std::vector< bool > &saveHierarchyInfo, bool saveShowerHierarchyInfo)
Connect this object with a tree.
bool fSaveShowerHierarchyInfo
if the user wants to access the showers with their hierarchy
void sbnd::AnalysisTree::SetShowerAddresses ( )
inlineprivate

Sets the addresses of all the tree branches, creating the missing ones.

Definition at line 956 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

957  {
958  CheckData("SetShowerAddress()"); CheckTree("SetShowerAddress()");
960  } // SetShowerAddresses()
void CheckTree(std::string caller) const
Helper function: throws if no tree is available.
void SetShowerAddresses(TTree *pTree, std::string showerLabel, bool saveHierarchyInfo)
void CheckData(std::string caller) const
Helper function: throws if no data structure is available.
bool fSaveShowerHierarchyInfo
if the user wants to access the showers with their hierarchy
void sbnd::AnalysisTree::SetTrackerAddresses ( size_t  iTracker)
inlineprivate

Sets the addresses of all the tree branches of the specified tracking algo, creating the missing ones

Definition at line 931 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

932  {
933  CheckData("SetTrackerAddresses()"); CheckTree("SetTrackerAddresses()");
934  if (iTracker >= fData->GetNTrackers()) {
935  throw art::Exception(art::errors::LogicError)
936  << "AnalysisTree::SetTrackerAddresses(): no tracker #" << iTracker
937  << " (" << fData->GetNTrackers() << " available)";
938  }
939  fData->GetTrackerData(iTracker) \
941  } // SetTrackerAddresses()
void CheckTree(std::string caller) const
Helper function: throws if no tree is available.
void CheckData(std::string caller) const
Helper function: throws if no data structure is available.
std::vector< bool > fSaveHierarchyInfo
whether to extract and save Slice information
void SetAddresses(TTree *pTree, std::string tracker, bool isCosmics, bool saveHierarchyInfo)
size_t GetNTrackers() const
Returns the number of trackers for which data structures are allocated.
void sbnd::AnalysisTree::SetVerticesAddresses ( size_t  iTracker)
inlineprivate

Definition at line 943 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

944  {
945  CheckData("SetVerticesAddresses()"); CheckTree("SetVerticesAddresses()");
946  if (iTracker >= fData->GetNTrackers()) {
947  throw art::Exception(art::errors::LogicError)
948  << "AnalysisTree::SetVerticesAddresses(): no tracker #" << iTracker
949  << " (" << fData->GetNTrackers() << " available)";
950  }
951  fData->GetVertexData(iTracker) \
953  } // SetVerticesAddresses()
void CheckTree(std::string caller) const
Helper function: throws if no tree is available.
void CheckData(std::string caller) const
Helper function: throws if no data structure is available.
std::vector< bool > fSaveHierarchyInfo
whether to extract and save Slice information
void SetAddresses(TTree *pTree, std::string vertexLabel, bool saveHierarchyInfo)
size_t GetNTrackers() const
Returns the number of trackers for which data structures are allocated.
bool sbnd::AnalysisTree::TrackIdToMCTruth ( Int_t const  trkID,
art::Ptr< simb::MCTruth > &  mctruth 
)
private

Member Data Documentation

art::ServiceHandle<cheat::BackTrackerService> sbnd::AnalysisTree::bt_serv
private
std::string sbnd::AnalysisTree::fCalDataModuleLabel
private
calo::CalorimetryAlg sbnd::AnalysisTree::fCaloAlg
private
std::vector<std::string> sbnd::AnalysisTree::fCalorimetryModuleLabel
private
std::vector<std::string> sbnd::AnalysisTree::fCosmicTaggerAssocLabel
private
std::string sbnd::AnalysisTree::fCryGenModuleLabel
private
AnalysisTreeDataStruct* sbnd::AnalysisTree::fData
private
std::string sbnd::AnalysisTree::fDigitModuleLabel
private
std::vector<std::string> sbnd::AnalysisTree::fFlashMatchAssocLabel
private
float sbnd::AnalysisTree::fG4minE
private

Energy threshold to save g4 particle info.

Definition at line 887 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

std::string sbnd::AnalysisTree::fG4ModuleLabel
private
std::string sbnd::AnalysisTree::fGenieGenModuleLabel
private
std::string sbnd::AnalysisTree::fHitsModuleLabel
private
std::string sbnd::AnalysisTree::fLArG4ModuleLabel
private
std::vector<std::string> sbnd::AnalysisTree::fParticleIDModuleLabel
private
std::string sbnd::AnalysisTree::fPFParticleModuleLabel
private
std::string sbnd::AnalysisTree::fPOTModuleLabel
private
bool sbnd::AnalysisTree::fSaveAuxDetInfo
private

whether to extract and save auxiliary detector data

Definition at line 870 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveCaloCosmics
private

save calorimetry information for cosmics

Definition at line 886 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveCryInfo
private
bool sbnd::AnalysisTree::fSaveGeantInfo
private

whether to extract and save Genie information

Definition at line 873 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveGenieInfo
private

whether to extract and save CRY particle data

Definition at line 872 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

std::vector<bool> sbnd::AnalysisTree::fSaveHierarchyInfo
private

whether to extract and save Slice information

if the user wants to access the tracks with their hierarchy for each tracker

Definition at line 879 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveHitInfo
private

whether to extract and save Geant information

Definition at line 874 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveShowerHierarchyInfo
private

if the user wants to access the showers with their hierarchy

Definition at line 880 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveShowerInfo
private

whether to extract and save Track information

Definition at line 876 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveSliceInfo
private

whether to extract and save Vertex information

Definition at line 878 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveTrackInfo
private

whether to extract and save Hit information

Definition at line 875 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

bool sbnd::AnalysisTree::fSaveVertexInfo
private

whether to extract and save Shower information

Definition at line 877 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

std::string sbnd::AnalysisTree::fShowerModuleLabel
private
std::string sbnd::AnalysisTree::fTPCSimChannelModuleLabel
private
std::vector<std::string> sbnd::AnalysisTree::fTrackModuleLabel
private
TTree* sbnd::AnalysisTree::fTree
private
bool sbnd::AnalysisTree::fUseBuffer
private

whether to use a permanent buffer (faster, huge memory)

Definition at line 869 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

std::vector<std::string> sbnd::AnalysisTree::fVertexModuleLabel
private
bool sbnd::AnalysisTree::isCosmics
private

if it contains cosmics

Definition at line 885 of file sbndcode/sbndcode/AnalysisTree/AnalysisTree_module.cc.

art::ServiceHandle<cheat::ParticleInventoryService> sbnd::AnalysisTree::pi_serv
private
AnalysisTreeDataStruct::SubRunData_t sbnd::AnalysisTree::SubRunData
private

The documentation for this class was generated from the following file: