Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
fnex::SortEventLists Class Reference
Inheritance diagram for fnex::SortEventLists:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 SortEventLists (fhicl::ParameterSet const &pset)
 
virtual ~SortEventLists ()
 
 SortEventLists (SortEventLists const &)=delete
 
 SortEventLists (SortEventLists &&)=delete
 
SortEventListsoperator= (SortEventLists const &)=delete
 
SortEventListsoperator= (SortEventLists &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

art::ServiceHandle< art::TFileServicefTFS
 TFileService. More...
 
std::string fInputFile
 Input file name, should be an hadd'ed file. More...
 

Detailed Description

Definition at line 34 of file SortEventLists_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

fnex::SortEventLists::SortEventLists ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 56 of file SortEventLists_module.cc.

References reconfigure().

57  : EDAnalyzer(pset)
58  {
59 
60  this->reconfigure(pset);
61 
62  return;
63  }
void reconfigure(fhicl::ParameterSet const &p)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
fnex::SortEventLists::~SortEventLists ( )
virtual

Definition at line 66 of file SortEventLists_module.cc.

67  {
68  }
fnex::SortEventLists::SortEventLists ( SortEventLists const &  )
delete
fnex::SortEventLists::SortEventLists ( SortEventLists &&  )
delete

Member Function Documentation

void fnex::SortEventLists::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 281 of file SortEventLists_module.cc.

References fnex::DEFINE_ART_MODULE().

282  {
283  return;
284  }
void fnex::SortEventLists::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 123 of file SortEventLists_module.cc.

References dirName, art::rootNames::eventTreeName(), fInputFile, fTFS, fnex::SpillSummary::goodPOT, fnex::MetaData::interactionType, fnex::MetaData::IsNuMuSelected(), fnex::kCosmicMuon, LOG_DEBUG, LOG_VERBATIM, LOG_WARNING, art::TFileDirectory::make(), fetch_tb_beamline_files::md, fnex::potTracker::pot, ss, string, fnex::MetaData::ToString(), and fnex::SpillSummary::totalPOT.

124  {
125  TFile tf(fInputFile.c_str(), "READ");
126 
127  std::string dirName("list");
128 
129  std::string metadataTreeName(dirName);
130  metadataTreeName += "/metadata";
131  TTree *metadataTree = dynamic_cast<TTree*>(tf.Get(metadataTreeName.c_str()));
132 
133  if( !metadataTree){
134  throw cet::exception("SortEventLists")
135  << "cannot find metadata tree: "
136  << metadataTreeName;
137  }
138 
139  // loop over the entries in the metadataTree
140  fnex::MetaData *md = nullptr;
141  fnex::SpillSummary *ss = nullptr;
142  metadataTree->SetBranchAddress("metadata", &md);
143  metadataTree->SetBranchAddress("spillsummary", &ss);
144 
145  std::set<potTracker> potTrackers;
146  std::set<potTracker>::iterator itr;
147  potTracker trkr;
148 
149  std::set<fnex::MetaData> mdSet;
150  for(int ctr = 0; ctr < metadataTree->GetEntries(); ++ctr){
151  metadataTree->GetEntry(ctr);
152 
153  // don't copy the cosmic muon events into the new tree as
154  // they are duplicated and hard to disentangle. Instead
155  // the code creating them will be moved to the EventListManipulator
156  // and they will be made at the time of the fits.
157  if(md->interactionType == fnex::kCosmicMuon) continue;
158 
159  mdSet.insert(*md);
160 
161  // we don't want to add the spill summary over and over again for
162  // the same epoch with different MC interaction types.
163  if(md->IsNuMuSelected()){
164  trkr = potTracker(*md);
165  trkr.pot = ss->goodPOT;
166  itr = potTrackers.find(trkr);
167  if(itr != potTrackers.end()){
168  // stupid, but true: apparently the iterator reads as constant
169  // to the compiler, even when it isn't. So add its POT info
170  // to trkr, erase the set element, and then put trkr in its place
171  trkr.pot += (*itr).pot;
172  potTrackers.erase(itr);
173  }
174  itr = potTrackers.insert(trkr).first;
175 
176  LOG_DEBUG("SortEventList")
177  << md->ToString()
178  << " adding "
179  << ss->goodPOT
180  << " : "
181  << (*itr).pot;
182  }
183 
184  }// end loop over metadata tree
185 
186  fnex::MetaData outMD;
187  fnex::SpillSummary outSS;
188  TTree *outMDTree = fTFS->make<TTree>( "metadata", "Event list metadata" );
189  outMDTree->Branch("metadata", &outMD);
190  outMDTree->Branch("spillsummary", &outSS);
191 
192  TTree *outTree = nullptr;
193 
194  for(auto mditr : mdSet){
195 
196  outMD = mditr;
197 
198  trkr = potTracker(outMD);
199  itr = potTrackers.find(trkr);
200  if(itr == potTrackers.end()){
201  LOG_WARNING("SortEventLists")
202  << outMD.ToString()
203  << " is not found in collection of pot trackers, move on";
204  continue;
205  }
206 
207  outSS.goodPOT = (*itr).pot;
208  outSS.totalPOT = outSS.goodPOT;
209 
210  LOG_VERBATIM("SortEventLists")
211  << outMD.ToString()
212  << " "
213  << outSS.goodPOT;
214 
215  outMDTree->Fill();
216 
217  // find the event tree using the metadata information
219  eventTreeName += "/" + outMD.ToString();
220  TTree *eventTree = dynamic_cast<TTree*>(tf.Get(eventTreeName.c_str()));
221 
222  if( !eventTree ){
223  throw cet::exception("SortEventLists")
224  << "cannot find event tree: "
225  << eventTreeName;
226  }
227 
228  std::vector<std::string> *indepVarNames = nullptr;
229  std::vector<float> *indepVarVals = nullptr;
230  std::vector<std::string> *depVarNames = nullptr;
231  std::vector<std::string> *compoundVarNames = nullptr;
232  std::vector<std::vector<std::string>> *compoundVarPropNames = nullptr;
233  std::vector<std::vector<float>> *compoundVarPropVals = nullptr;
234 
235  eventTree->SetBranchAddress("indepVarNames", &indepVarNames );
236  eventTree->SetBranchAddress("indepVarVals", &indepVarVals );
237  eventTree->SetBranchAddress("depVarNames", &depVarNames );
238  eventTree->SetBranchAddress("compoundVarNames", &compoundVarNames );
239  eventTree->SetBranchAddress("compoundVarPropNames", &compoundVarPropNames);
240  eventTree->SetBranchAddress("compoundVarPropVals", &compoundVarPropVals );
241 
242  LOG_DEBUG("SortNDMCLists")
243  << "copying "
244  << outMD.ToString()
245  << " "
246  << eventTree->GetEntries()
247  << " has an exposure of "
248  << outSS.goodPOT;
249 
250 
251  outTree = fTFS->make<TTree>(outMD.ToString().c_str(), "FNEX event records");
252 
253  outTree->Branch("indepVarNames", &indepVarNames );
254  outTree->Branch("indepVarVals", &indepVarVals );
255  outTree->Branch("depVarNames", &depVarNames );
256  outTree->Branch("compoundVarNames", &compoundVarNames );
257  outTree->Branch("compoundVarPropNames", &compoundVarPropNames);
258  outTree->Branch("compoundVarPropVals", &compoundVarPropVals );
259 
260  for(int evctr = 0; evctr < eventTree->GetEntries(); ++evctr){
261  eventTree->GetEntry(evctr);
262  outTree->Fill();
263  }
264 
265  } // end loop over metadata branch
266 
267  return;
268  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
bool IsNuMuSelected() const
Definition: Structs.cxx:256
Float_t ss
Definition: plot.C:24
std::string const & eventTreeName()
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Timing fit.
std::string const ToString() const
Definition: Structs.cxx:114
std::string fInputFile
Input file name, should be an hadd&#39;ed file.
#define LOG_WARNING(category)
T * make(ARGS...args) const
std::string dirName
Definition: PlotSpectra.h:47
fnex::InteractionType_t interactionType
Definition: Structs.h:53
#define LOG_VERBATIM(category)
art::ServiceHandle< art::TFileService > fTFS
TFileService.
enum BeamMode string
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDAnalyzer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:35
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
SortEventLists& fnex::SortEventLists::operator= ( SortEventLists const &  )
delete
SortEventLists& fnex::SortEventLists::operator= ( SortEventLists &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void fnex::SortEventLists::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 271 of file SortEventLists_module.cc.

References fInputFile, fhicl::ParameterSet::get(), and string.

Referenced by SortEventLists().

272  {
273  fInputFile = pset.get<std::string>("InputFileName");
274 
275  return;
276  }
std::string fInputFile
Input file name, should be an hadd&#39;ed file.
enum BeamMode string
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

Referenced by art::RootOutput::RootOutput().

47  {
48  return wantAllEvents_;
49  }
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited

Definition at line 51 of file EventObserverBase.h.

References art::EventObserverBase::selectors_, and art::detail::CachedProducts::wantEvent().

52  {
53  return selectors_.wantEvent(e);
54  }
detail::CachedProducts selectors_
Float_t e
Definition: plot.C:35
bool wantEvent(Event const &)
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

std::string fnex::SortEventLists::fInputFile
private

Input file name, should be an hadd'ed file.

Definition at line 52 of file SortEventLists_module.cc.

Referenced by beginJob(), and reconfigure().

art::ServiceHandle<art::TFileService> fnex::SortEventLists::fTFS
private

TFileService.

Definition at line 51 of file SortEventLists_module.cc.

Referenced by beginJob().


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