The constructor tries to initialize the object by connecting to all the available branches. However it's possible to create the object without an existing event-wise TTree as well.
The destructor deletes all the allocated objects, and releases whatever resource it can.
This function can be used to instruct the object to start using a new event-wise TTree. This is very useful when processing multiple D3PD files.
Note that it is possible to provide a null pointer to the function. In this case the object will be reset, and the previous TTree will be released without connecting to a new one.
Also note that unfortunately we can't just check if the passed TTree pointer is the same as the cached one. ROOT has the habit of putting the same sort of TTree into the same memory space when the second file is opened for instance. I've seen some weird problems because of this.
Unfortunately however I tried I didn't manage to figure out an elegant way of automatically figuring out which event the tool should be operating on. Of course if the user issues TTree::GetEntry(...) calls on the event-wise TTree himself/herself, then the tool gets the correct data automatically. But since this is usually a slow thing to do, the user can also explicitly request the tool to read a new event using this function.
29 DataAccess::DataAccess( TTree* eventTree,
const TString&
prefix )
30 : TNamed(
"DataAccess",
"Sub-class accessing the data in the D3PD" ),
31 m_tree( eventTree ), m_prefix(
prefix ), m_initialized( kFALSE ),
33 m_l1_tav( 0 ), m_l2_physics( 0 ), m_ef_physics( 0 ),
34 m_l1_tbp( 0 ), m_l1_tap( 0 ), m_l2_raw( 0 ), m_ef_raw( 0 ),
35 m_l2_resurrected( 0 ), m_ef_resurrected( 0 ),
36 m_l2_passedThrough( 0 ), m_ef_passedThrough( 0 ) {
46 DataAccess::~DataAccess() {
51 TTree* DataAccess::GetEventTree()
const {
73 Bool_t DataAccess::SetEventTree( TTree* eventTree ) {
103 Int_t DataAccess::GetEntry( Long64_t
entry, Int_t getall ) {
109 Long64_t centry =
entry;
110 TChain*
chain =
dynamic_cast< TChain*
>( m_tree );
115 if( m_b_smk ) bytes += m_b_smk->GetEntry( centry, getall );
116 if( m_b_l1psk ) bytes += m_b_l1psk->GetEntry( centry, getall );
117 if( m_b_hltpsk ) bytes += m_b_hltpsk->GetEntry( centry, getall );
119 if( m_b_l1_tav ) bytes += m_b_l1_tav->GetEntry( centry, getall );
120 if( m_b_l2_physics ) bytes += m_b_l2_physics->GetEntry( centry, getall );
121 if( m_b_ef_physics ) bytes += m_b_ef_physics->GetEntry( centry, getall );
123 if( m_b_l1_tbp ) bytes += m_b_l1_tbp->GetEntry( centry, getall );
124 if( m_b_l1_tap ) bytes += m_b_l1_tap->GetEntry( centry, getall );
125 if( m_b_l2_raw ) bytes += m_b_l2_raw->GetEntry( centry, getall );
126 if( m_b_ef_raw ) bytes += m_b_ef_raw->GetEntry( centry, getall );
128 if( m_b_l2_resurrected ) bytes += m_b_l2_resurrected->GetEntry( centry, getall );
129 if( m_b_ef_resurrected ) bytes += m_b_ef_resurrected->GetEntry( centry, getall );
130 if( m_b_l2_passedThrough ) bytes += m_b_l2_passedThrough->GetEntry( centry, getall );
131 if( m_b_ef_passedThrough ) bytes += m_b_ef_passedThrough->GetEntry( centry, getall );
136 Int_t DataAccess::GetDetailLevel()
const {
138 return m_detailLevel;
141 Int_t DataAccess::GetSMK()
const {
146 Int_t DataAccess::GetL1PSK()
const {
151 Int_t DataAccess::GetHLTPSK()
const {
156 const std::vector< unsigned int >* DataAccess::GetL1Result( L1ResultType
type )
const {
170 Error(
"GetL1Result",
"Unknown result type requested" );
176 const std::vector< short >* DataAccess::GetL2Result( HLTResultType
type )
const {
187 return m_l2_resurrected;
190 return m_l2_passedThrough;
193 Error(
"GetL2Result",
"Unknown result type requested" );
199 const std::vector< short >* DataAccess::GetEFResult( HLTResultType
type )
const {
210 return m_ef_resurrected;
213 return m_ef_passedThrough;
216 Error(
"GetEFResult",
"Unknown result type requested" );
225 if( m_initialized )
return kTRUE;
231 Info(
"Initialize",
"Null pointer provided as event tree -> "
232 "Delaying initialization" );
239 TChain*
chain =
dynamic_cast< TChain*
>( m_tree );
242 if( !
chain->GetTree() ) {
243 chain->LoadTree( 0 );
250 if( ( ! ( m_b_smk = m_tree->GetBranch( m_prefix +
"DB_SMK" ) ) ) ||
251 ( ! ( m_b_l1psk = m_tree->GetBranch( m_prefix +
"DB_L1PSK" ) ) ) ||
252 ( ! ( m_b_hltpsk = m_tree->GetBranch( m_prefix +
"DB_HLTPSK" ) ) ) ) {
253 Error(
"Initialize",
"The supplied D3PD doesn't seem to hold trigger configuration "
258 m_tree->SetBranchAddress( m_prefix +
"DB_SMK", &m_smk, &m_b_smk );
259 m_tree->SetBranchAddress( m_prefix +
"DB_L1PSK", &m_l1psk, &m_b_l1psk );
260 m_tree->SetBranchAddress( m_prefix +
"DB_HLTPSK", &m_hltpsk, &m_b_hltpsk );
265 if( ( ! ( m_b_l1_tav = m_tree->GetBranch( m_prefix +
"L1_TAV" ) ) ) ||
266 ( ! ( m_b_l2_physics = m_tree->GetBranch( m_prefix +
"L2_passedPhysics" ) ) ) ||
267 ( ! ( m_b_ef_physics = m_tree->GetBranch( m_prefix +
"EF_passedPhysics" ) ) ) ) {
268 Error(
"Initialize",
"The supplied TTree doesn't seem to hold trigger decision "
273 m_tree->SetBranchAddress( m_prefix +
"L1_TAV", &m_l1_tav,
275 m_tree->SetBranchAddress( m_prefix +
"L2_passedPhysics", &m_l2_physics,
277 m_tree->SetBranchAddress( m_prefix +
"EF_passedPhysics", &m_ef_physics,
285 if( ( ! ( m_b_l1_tbp = m_tree->GetBranch( m_prefix +
"L1_TBP" ) ) ) ||
286 ( ! ( m_b_l1_tap = m_tree->GetBranch( m_prefix +
"L1_TAP" ) ) ) ||
287 ( ! ( m_b_l2_raw = m_tree->GetBranch( m_prefix +
"L2_passedRaw" ) ) ) ||
288 ( ! ( m_b_ef_raw = m_tree->GetBranch( m_prefix +
"EF_passedRaw" ) ) ) ) {
293 m_tree->SetBranchAddress( m_prefix +
"L1_TBP", &m_l1_tbp, &m_b_l1_tbp );
294 m_tree->SetBranchAddress( m_prefix +
"L1_TAP", &m_l1_tap, &m_b_l1_tap );
295 m_tree->SetBranchAddress( m_prefix +
"L2_passedRaw", &m_l2_raw, &m_b_l2_raw );
296 m_tree->SetBranchAddress( m_prefix +
"EF_passedRaw", &m_ef_raw, &m_b_ef_raw );
303 if( ( ! ( m_b_l2_resurrected = m_tree->GetBranch( m_prefix +
"L2_resurrected" ) ) ) ||
304 ( ! ( m_b_ef_resurrected = m_tree->GetBranch( m_prefix +
"EF_resurrected" ) ) ) ||
305 ( ! ( m_b_l2_passedThrough = m_tree->GetBranch( m_prefix +
"L2_passedThrough" ) ) ) ||
306 ( ! ( m_b_ef_passedThrough = m_tree->GetBranch( m_prefix +
"EF_passedThrough" ) ) ) ) {
311 m_tree->SetBranchAddress( m_prefix +
"L2_resurrected", &m_l2_resurrected,
312 &m_b_l2_resurrected );
313 m_tree->SetBranchAddress( m_prefix +
"EF_resurrected", &m_ef_resurrected,
314 &m_b_ef_resurrected );
315 m_tree->SetBranchAddress( m_prefix +
"L2_passedThrough", &m_l2_passedThrough,
316 &m_b_l2_passedThrough );
317 m_tree->SetBranchAddress( m_prefix +
"EF_passedThrough", &m_ef_passedThrough,
318 &m_b_ef_passedThrough );
325 void DataAccess::Reset() {
327 m_initialized = kFALSE;
334 if( m_l1_tav )
delete m_l1_tav; m_l1_tav = 0;
335 if( m_l2_physics )
delete m_l2_physics; m_l2_physics = 0;
336 if( m_ef_physics )
delete m_ef_physics; m_ef_physics = 0;
342 if( m_l1_tbp )
delete m_l1_tbp; m_l1_tbp = 0;
343 if( m_l1_tap )
delete m_l1_tap; m_l1_tap = 0;
344 if( m_l2_raw )
delete m_l2_raw; m_l2_raw = 0;
345 if( m_ef_raw )
delete m_ef_raw; m_ef_raw = 0;
352 if( m_l2_resurrected )
delete m_l2_resurrected; m_l2_resurrected = 0;
353 if( m_ef_resurrected )
delete m_ef_resurrected; m_ef_resurrected = 0;
355 m_b_l2_resurrected = 0;
356 m_b_ef_resurrected = 0;
358 if( m_l2_passedThrough )
delete m_l2_passedThrough; m_l2_passedThrough = 0;
359 if( m_ef_passedThrough )
delete m_ef_passedThrough; m_ef_passedThrough = 0;
361 m_b_l2_passedThrough = 0;
362 m_b_ef_passedThrough = 0;