4141#include " EventNtuple/rooutil/inc/Track.hh"
4242#include " EventNtuple/rooutil/inc/CrvCoinc.hh"
4343#include " EventNtuple/rooutil/inc/CaloCluster.hh"
44+ #include " EventNtuple/rooutil/inc/Trigger.hh"
4445
4546#include " TChain.h"
4647
@@ -50,16 +51,7 @@ namespace rooutil {
5051 CheckForBranch (ntuple, " evtinfo" , &this ->evtinfo );
5152 CheckForBranch (ntuple, " hitcount" , &this ->hitcount );
5253 CheckForBranch (ntuple, " crvsummary" , &this ->crvsummary );
53- const auto & branches = ntuple->GetListOfBranches ();
54- int i_trig_branch = 0 ;
55- for (const auto & branch : *branches) {
56- std::string brname = branch->GetName ();
57- if (brname.substr (0 , 5 ) == " trig_" ) {
58- ntuple->SetBranchAddress (brname.c_str (), &this ->triginfo ._triggerArray [i_trig_branch]);
59- trigNameMap.insert ({brname, i_trig_branch});
60- i_trig_branch++;
61- }
62- }
54+ AddTriggerInfo (ntuple);
6355
6456 CheckForBranch (ntuple, " trk" , &this ->trk );
6557 CheckForBranch (ntuple, " trksegs" , &this ->trksegs );
@@ -104,6 +96,24 @@ namespace rooutil {
10496 return true ;
10597 }
10698
99+ // Add trigger branches and store the path name information
100+ void AddTriggerInfo (TChain* ntuple) {
101+ trigger.SetTrigInfo (&triginfo); // pointer to the underlying trigger data read in event-by-event
102+
103+ // trigger branches are named "trig_<trigger path name>" --> look for these
104+ const auto & branches = ntuple->GetListOfBranches ();
105+ int i_trig_branch = 0 ;
106+ for (const auto & branch : *branches) {
107+ std::string brname = branch->GetName ();
108+ if (brname.substr (0 , 5 ) == " trig_" ) {
109+ ntuple->SetBranchAddress (brname.c_str (), &this ->triginfo ._triggerArray [i_trig_branch]);
110+ const std::string trigname = brname.substr (5 ); // name of the trigger path
111+ trigger.AssignIndex (i_trig_branch, trigname); // map the array index to the path name
112+ i_trig_branch++;
113+ }
114+ }
115+ }
116+
107117 void Update (bool debug = false ) {
108118 if (debug) { std::cout << " Event::Update(): Clearing previous Tracks... " << std::endl; }
109119 tracks.clear ();
@@ -300,6 +310,7 @@ namespace rooutil {
300310 mu2e::CrvSummaryReco* crvsummary = nullptr ;
301311 mu2e::CrvSummaryMC* crvsummarymc = nullptr ;
302312 mu2e::TrigInfo triginfo; // not a pointer because we give the address of array elements inside this
313+ Trigger trigger; // contains additional trigger information
303314
304315 std::vector<mu2e::TrkInfo>* trk = nullptr ;
305316 std::vector<mu2e::TrkInfoMC>* trkmc = nullptr ;
@@ -331,9 +342,6 @@ namespace rooutil {
331342 std::vector<mu2e::CrvPlaneInfoMC>* crvcoincsmcplane = nullptr ;
332343
333344 std::vector<std::vector<mu2e::SimInfo>>* trkmcsim = nullptr ;
334-
335- // Need to keep track of trigger name to element in triginfo
336- std::map<std::string, unsigned int > trigNameMap;
337345 };
338346} // namespace rooutil
339347#endif
0 commit comments