Belle II Software development
RawSecMapRootInterface Class Reference

To be used as an interface to root-stuff. More...

#include <RawSecMapRootInterface.h>

Public Member Functions

 RawSecMapRootInterface (const std::string &mapName, const std::string &tag, const std::string &outputdir="./")
 Constructor - prepares TTree.
 
 ~RawSecMapRootInterface ()
 destructor deleting the rootFile.
 
 RawSecMapRootInterface (const RawSecMapRootInterface &rawSecMapInterFace)=delete
 That class shall not be copied.
 
 RawSecMapRootInterface (RawSecMapRootInterface &&other)
 but it may be moved
 
RawSecMapRootInterfaceoperator= (const RawSecMapRootInterface &rawSecMapInterFace)=delete
 That class shall not be copied.
 
void initialize2Hit (std::vector< std::string > filterNames)
 initialize the RawSecMapRootInterface for two-hit-combinations (to be called in Module::initialize().
 
void initialize3Hit (std::vector< std::string > filterNames)
 initialize the RawSecMapRootInterface for three-hit-combinations (to be called in Module::initialize().
 
FilterValueDataSet< SecIDPair > & get2HitDataSet ()
 returns a reference to the 2-hit-dataset so one can set the relevant values.
 
FilterValueDataSet< SecIDTriplet > & get3HitDataSet ()
 returns a reference to the 3-hit-dataset so one can set the relevant values.
 
void fill2Hit ()
 fill two-hit-combinations in tree, triggers an Error if values not set yet.
 
void fill3Hit ()
 fill three-hit-combinations in tree, triggers an Error if values not set yet.
 
void write ()
 write all trees to file at end of processing.
 

Protected Attributes

TFile * m_file
 a pointer to the file where the Tree shall be stored.
 
std::string m_name
 name of the StoreObjPtr.
 
StoreObjPtr< RootMergeable< TTree > > m_tree2Hit
 interface to the TTree storing two-hit-variables.
 
FilterValueDataSet< SecIDPairm_data2Hit
 Mask for storing dataSets to be piped into 2hit-tree.
 
StoreObjPtr< RootMergeable< TTree > > m_tree3Hit
 interface to the TTree storing three-hit-variables.
 
FilterValueDataSet< SecIDTripletm_data3Hit
 Mask for storing dataSets to be piped into 3hit-tree.
 

Detailed Description

To be used as an interface to root-stuff.

Definition at line 32 of file RawSecMapRootInterface.h.

Constructor & Destructor Documentation

◆ RawSecMapRootInterface() [1/2]

RawSecMapRootInterface ( const std::string &  mapName,
const std::string &  tag,
const std::string &  outputdir = "./" 
)
inline

Constructor - prepares TTree.

Without calling the initializer-functions this Object is still not working!

Definition at line 58 of file RawSecMapRootInterface.h.

58 :
59 m_name(mapName),
60 m_tree2Hit((m_name + std::string("2Hit")), DataStore::c_Persistent),
61 m_data2Hit({}),
62 m_tree3Hit((m_name + std::string("3Hit")), DataStore::c_Persistent),
63 m_data3Hit({})
64
65 {
66 // the "create" option results in the file not being opened if already existing
67 std::string fileName = outputdir + "/" + mapName + "_" + tag + ".root";
68 m_file = new TFile((fileName).c_str(), "CREATE");
69 if (!m_file->IsOpen()) {
70 B2FATAL("File was not opened! File name: " << fileName << " (maybe it already exists!?)");
71 }
72 m_file->cd();
73 }
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
FilterValueDataSet< SecIDPair > m_data2Hit
Mask for storing dataSets to be piped into 2hit-tree.
StoreObjPtr< RootMergeable< TTree > > m_tree3Hit
interface to the TTree storing three-hit-variables.
StoreObjPtr< RootMergeable< TTree > > m_tree2Hit
interface to the TTree storing two-hit-variables.
TFile * m_file
a pointer to the file where the Tree shall be stored.
FilterValueDataSet< SecIDTriplet > m_data3Hit
Mask for storing dataSets to be piped into 3hit-tree.
std::string m_name
name of the StoreObjPtr.

◆ ~RawSecMapRootInterface()

destructor deleting the rootFile.

Definition at line 76 of file RawSecMapRootInterface.h.

76{ if (m_file) delete m_file; }

◆ RawSecMapRootInterface() [2/2]

but it may be moved

Definition at line 82 of file RawSecMapRootInterface.h.

82 :
83 m_file(nullptr),
84 m_name(std::move(other.m_name)),
85 m_tree2Hit(std::move(other.m_tree2Hit)),
86 m_data2Hit(std::move(other.m_data2Hit)),
87 m_tree3Hit(std::move(other.m_tree3Hit)),
88 m_data3Hit(std::move(other.m_data3Hit))
89 {
90 // the new object takes ownership of the file
91 m_file = other.m_file;
92 other.m_file = nullptr;
93 }

Member Function Documentation

◆ fill2Hit()

void fill2Hit ( )
inline

fill two-hit-combinations in tree, triggers an Error if values not set yet.

(data is reset during each fill2Hit-call).

Definition at line 191 of file RawSecMapRootInterface.h.

192 {
193 if (!m_data2Hit.isValid()) {
194 B2ERROR("RawSecMapRootInterface::fill2Hit: attempt to fill invalid data in the tree! -> unintended behavior, data will not be filled.");
195 m_data2Hit.reset();
196 return;
197 }
198 m_tree2Hit->get().Fill();
199 m_data2Hit.reset();
200 }

◆ fill3Hit()

void fill3Hit ( )
inline

fill three-hit-combinations in tree, triggers an Error if values not set yet.

(data is reset during each fill3Hit-call).

Definition at line 205 of file RawSecMapRootInterface.h.

206 {
207 if (!m_data3Hit.isValid()) {
208 B2ERROR("RawSecMapRootInterface::fill3Hit: attempt to fill invalid data in the tree! -> unintended behavior, data will not be filled.");
209 m_data3Hit.reset();
210 return;
211 }
212 m_tree3Hit->get().Fill();
213 m_data3Hit.reset();
214 }

◆ get2HitDataSet()

FilterValueDataSet< SecIDPair > & get2HitDataSet ( )
inline

returns a reference to the 2-hit-dataset so one can set the relevant values.

Definition at line 181 of file RawSecMapRootInterface.h.

181{ return m_data2Hit; }

◆ get3HitDataSet()

FilterValueDataSet< SecIDTriplet > & get3HitDataSet ( )
inline

returns a reference to the 3-hit-dataset so one can set the relevant values.

Definition at line 185 of file RawSecMapRootInterface.h.

185{ return m_data3Hit; }

◆ initialize2Hit()

void initialize2Hit ( std::vector< std::string >  filterNames)
inline

initialize the RawSecMapRootInterface for two-hit-combinations (to be called in Module::initialize().

Definition at line 100 of file RawSecMapRootInterface.h.

101 {
102 B2DEBUG(20, "RawSecMapRootInterface::initialize2Hit: start - got " << filterNames.size() << " filters");
103 B2DEBUG(20, "and root file got size of: " << m_file->GetSize());
104 m_file->cd();
105
106 // preparing StoreObjPtr:
107 bool registered = m_tree2Hit.registerInDataStore((m_name + std::string("2Hit")), DataStore::c_ErrorIfAlreadyRegistered);
108 bool constructed = m_tree2Hit.construct((m_name + std::string("2Hit")).c_str(), "Raw data of two-hit-combinations for a sectorMap");
109 B2DEBUG(20, "RawSecMapRootInterface::initialize2Hit: isRegistered/isConstructed: " << registered << "/" << constructed);
110
111 // preparing data-mask for 2-hit-combinations:
112 m_data2Hit = FilterValueDataSet<SecIDPair>(filterNames);
113
114 m_tree2Hit->get().Branch("expNo", &(m_data2Hit.expNo));
115 m_tree2Hit->get().Branch("runNo", &(m_data2Hit.runNo));
116 m_tree2Hit->get().Branch("evtNo", &(m_data2Hit.evtNo));
117 m_tree2Hit->get().Branch("trackNo", &(m_data2Hit.trackNo));
118 m_tree2Hit->get().Branch("pdg", &(m_data2Hit.pdg));
119 m_tree2Hit->get().Branch("outerSecID", &(m_data2Hit.secIDs.outer));
120 m_tree2Hit->get().Branch("innerSecID", &(m_data2Hit.secIDs.inner));
121
122 B2DEBUG(20, "RawSecMapRootInterface::initialize2Hit: adding " << filterNames.size() << " filters as branches to ttree ");
123 for (auto& name : filterNames) {
124 double* valuePtr = m_data2Hit.getValuePtr(name);
125 if (valuePtr != nullptr) {
126 B2DEBUG(20, "RawSecMapRootInterface::initialize2Hit: adding now branch with name " << name);
127 m_tree2Hit->get().Branch(name.c_str(), valuePtr);
128 } else {
129 B2ERROR("RawSecMapRootInterface::initialize2Hit: filterName " << name <<
130 " not known! this is unintended behavior - skipping filter");
131 }
132
133 }
134 B2DEBUG(20, "RawSecMapRootInterface::initialize2Hit: nBranches/nEntries: " << m_tree2Hit->get().GetNbranches() << "/" <<
135 m_tree2Hit->get().GetEntries());
136 }
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
Definition: DataStore.h:72

◆ initialize3Hit()

void initialize3Hit ( std::vector< std::string >  filterNames)
inline

initialize the RawSecMapRootInterface for three-hit-combinations (to be called in Module::initialize().

Definition at line 141 of file RawSecMapRootInterface.h.

142 {
143 B2DEBUG(20, "RawSecMapRootInterface::initialize3Hit: start");
144 m_file->cd();
145
146 // preparing StoreObjPtr:
147 bool registered = m_tree3Hit.registerInDataStore((m_name + std::string("3Hit")), DataStore::c_ErrorIfAlreadyRegistered);
148 bool constructed = m_tree3Hit.construct((m_name + std::string("3Hit")).c_str(),
149 "Raw data of three-hit-combinations for a sectorMap");
150 B2DEBUG(20, "RawSecMapRootInterface::initialize3Hit: isRegistered/isConstructed: " << registered << "/" << constructed);
151
152 // preparing data-mask for 2-hit-combinations:
153 m_data3Hit = FilterValueDataSet<SecIDTriplet>(filterNames);
154
155 m_tree3Hit->get().Branch("expNo", &(m_data3Hit.expNo));
156 m_tree3Hit->get().Branch("runNo", &(m_data3Hit.runNo));
157 m_tree3Hit->get().Branch("evtNo", &(m_data3Hit.evtNo));
158 m_tree3Hit->get().Branch("trackNo", &(m_data3Hit.trackNo));
159 m_tree3Hit->get().Branch("pdg", &(m_data3Hit.pdg));
160 m_tree3Hit->get().Branch("outerSecID", &(m_data3Hit.secIDs.outer));
161 m_tree3Hit->get().Branch("centerSecID", &(m_data3Hit.secIDs.center));
162 m_tree3Hit->get().Branch("innerSecID", &(m_data3Hit.secIDs.inner));
163
164 B2DEBUG(20, "RawSecMapRootInterface::initialize3Hit: adding " << filterNames.size() << " filters as branches to ttree ");
165 for (auto& name : filterNames) {
166 double* valuePtr = m_data3Hit.getValuePtr(name);
167 if (valuePtr != nullptr) {
168 B2DEBUG(20, "RawSecMapRootInterface::initialize3Hit: adding now branch with name " << name);
169 m_tree3Hit->get().Branch(name.c_str(), valuePtr);
170 } else {
171 B2ERROR("RawSecMapRootInterface::initialize3Hit: filterName " << name <<
172 " not known! this is unintended behavior - skipping filter");
173 }
174
175 }
176 B2DEBUG(20, "RawSecMapRootInterface::initialize3Hit: nBranches/nEntries: " << m_tree3Hit->get().GetNbranches() << "/" <<
177 m_tree3Hit->get().GetEntries());
178 }

◆ write()

void write ( )
inline

write all trees to file at end of processing.

Definition at line 218 of file RawSecMapRootInterface.h.

219 {
220 B2DEBUG(20, "RawSecMapRootInterface::write: start");
221 m_file->cd();
222
224 //use TFile you created in initialize()
225 m_tree2Hit->write(m_file);
226 m_tree3Hit->write(m_file);
227
228 }
229 }
static bool isOutputProcess()
Return true if the process is an output process.
Definition: ProcHandler.cc:232
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
Definition: ProcHandler.cc:226

Member Data Documentation

◆ m_data2Hit

FilterValueDataSet<SecIDPair> m_data2Hit
protected

Mask for storing dataSets to be piped into 2hit-tree.

Definition at line 45 of file RawSecMapRootInterface.h.

◆ m_data3Hit

FilterValueDataSet<SecIDTriplet> m_data3Hit
protected

Mask for storing dataSets to be piped into 3hit-tree.

Definition at line 51 of file RawSecMapRootInterface.h.

◆ m_file

TFile* m_file
protected

a pointer to the file where the Tree shall be stored.

Definition at line 36 of file RawSecMapRootInterface.h.

◆ m_name

std::string m_name
protected

name of the StoreObjPtr.

Definition at line 39 of file RawSecMapRootInterface.h.

◆ m_tree2Hit

StoreObjPtr<RootMergeable<TTree> > m_tree2Hit
protected

interface to the TTree storing two-hit-variables.

Definition at line 42 of file RawSecMapRootInterface.h.

◆ m_tree3Hit

StoreObjPtr<RootMergeable<TTree> > m_tree3Hit
protected

interface to the TTree storing three-hit-variables.

Definition at line 48 of file RawSecMapRootInterface.h.


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