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

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 ReadCAFMakeEventList (fhicl::ParameterSet const &p)
 
 ReadCAFMakeEventList (ReadCAFMakeEventList const &)=delete
 
 ReadCAFMakeEventList (ReadCAFMakeEventList &&)=delete
 
ReadCAFMakeEventListoperator= (ReadCAFMakeEventList const &)=delete
 
ReadCAFMakeEventListoperator= (ReadCAFMakeEventList &&)=delete
 
void analyze (art::Event const &e) override
 
void endJob () 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 Member Functions

void ReadCAFTree ()
 Function to read in the CAF or DeCAF trees. More...
 
std::string EpochName (int, int)
 Function to find the epoch an event belongs to. More...
 
void clear ()
 Function to clear out the collections of data products. More...
 
void Serialize ()
 Function to make the metadata, spill and eventlist trees. More...
 
void FillSpillInformation ()
 Function to fill the spill summary information. More...
 
void FindEpochFile ()
 Function to find the number of files per epoch. More...
 

Private Attributes

std::vector< std::stringfCAF_files
 A vector of input CAF files. More...
 
fnex::EventVarValsMap fVarVals
 each entry in the vector is for a single slice More...
 
fnex::FileType_t fFileType
 get from the configuration for now More...
 
std::vector< fnex::SelectionType_tfSelectionTypes
 get from the analysis configuration More...
 
art::ServiceHandle< art::TFileServicefTFS
 TFileService. More...
 
std::map< std::string, intfFilesPerEpoch
 number of files seen per epoch More...
 
float fSpillsPerFile
 spills in each ND file More...
 
fnex::SpillPOT fNDMC_SpillPOT
 Spill information for the ND MC files. More...
 
fnex::SpillPOT fFDMC_SpillPOT
 Spill information for the FD MC files. More...
 
fnex::SpillPOT fNDData_SpillPOT
 Spill information for the ND Data files. More...
 
std::map< std::string, fnex::SpillPOTfPOTSum
 total summary of the POT information More...
 
std::string fEpochName
 Name of the epoch from fhicl configuration. More...
 
int fInputFilesPerEpoch
 
double fPOT
 
std::vector< std::stringfAnalysisType
 Name of the Analysis type. More...
 
std::vector< double > fPIDMin
 Minimum value of the CVN for nue selected events. More...
 
std::vector< double > fPIDMax
 Maximum value of the CVN for nue selected events. More...
 

Detailed Description

Definition at line 91 of file ReadCAFMakeEventList_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::ReadCAFMakeEventList::ReadCAFMakeEventList ( fhicl::ParameterSet const &  p)
explicit

Definition at line 141 of file ReadCAFMakeEventList_module.cc.

References clear(), fFDMC_SpillPOT, fNDData_SpillPOT, fNDMC_SpillPOT, fSpillsPerFile, fnex::SpillPOT::goodspills, reconfigure(), fnex::SpillPOT::totgoodpot, fnex::SpillPOT::totpot, and fnex::SpillPOT::totspills.

142  :
143  EDAnalyzer(p) // ,
144 {
145  this->clear();
146 
147  this->reconfigure(p);
148 
149  //Initialize the spill summary information
154 
157 
160 
161  return;
162 }//end of ReadCAFMakeEventList
void reconfigure(fhicl::ParameterSet const &p)
const char * p
Definition: xmltok.h:285
fnex::SpillPOT fFDMC_SpillPOT
Spill information for the FD MC files.
fnex::SpillPOT fNDData_SpillPOT
Spill information for the ND Data files.
void clear()
Function to clear out the collections of data products.
fnex::SpillPOT fNDMC_SpillPOT
Spill information for the ND MC files.
unsigned long int goodspills
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
float fSpillsPerFile
spills in each ND file
unsigned long int totspills
fnex::ReadCAFMakeEventList::ReadCAFMakeEventList ( ReadCAFMakeEventList const &  )
delete
fnex::ReadCAFMakeEventList::ReadCAFMakeEventList ( ReadCAFMakeEventList &&  )
delete

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 164 of file ReadCAFMakeEventList_module.cc.

References fVarVals, it, LOG_VERBATIM, ReadCAFTree(), Serialize(), gen_flatrecord::size, and ToString().

165 {
166 
167  //Call ReadCAFTree function to read in the CAF file
168  this->ReadCAFTree();
169 
170  LOG_VERBATIM("ReadCAFMakeEventList")
171  << " Size of fVarVals is "
172  << fVarVals.size();
173 
174  int fnex_total_events = 0;
175 
176  for(std::map<fnex::MetaData, std::vector<EventInfo> >::iterator it = fVarVals.begin(); it != fVarVals.end(); ++it){
177  LOG_VERBATIM("ReadCAFMakeEventList")
178  << " Metadata: "
179  << (it->first).ToString()
180  << " Having events: "
181  << (it->second).size();
182  fnex_total_events += (it->second).size();
183  }
184 
185  LOG_VERBATIM("ReadCAFMakeEventList")
186  << "Total events in FNEX trees : "
187  << fnex_total_events;
188 
189  //Call the Serialize functions to make the metadata and event list trees
190  this->Serialize();
191 
192  return;
193 }//end of analyze
set< int >::iterator it
void Serialize()
Function to make the metadata, spill and eventlist trees.
fnex::EventVarValsMap fVarVals
each entry in the vector is for a single slice
std::string ToString(double value)
void ReadCAFTree()
Function to read in the CAF or DeCAF trees.
#define LOG_VERBATIM(category)
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_
void fnex::ReadCAFMakeEventList::clear ( )
private

Function to clear out the collections of data products.

Definition at line 690 of file ReadCAFMakeEventList_module.cc.

References fPOTSum, and fVarVals.

Referenced by ReadCAFMakeEventList().

690  {
691 
692  fVarVals .clear();
693  fPOTSum .clear();
694 
695 }//end of clear functions
fnex::EventVarValsMap fVarVals
each entry in the vector is for a single slice
std::map< std::string, fnex::SpillPOT > fPOTSum
total summary of the POT information
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
void fnex::ReadCAFMakeEventList::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 195 of file ReadCAFMakeEventList_module.cc.

196 {
197  return;
198 }//end of endJob
std::string fnex::ReadCAFMakeEventList::EpochName ( int  detector,
int  run_number 
)
private

Function to find the epoch an event belongs to.

Definition at line 649 of file ReadCAFMakeEventList_module.cc.

References novadaq::cnv::kFARDET, and novadaq::cnv::kNEARDET.

Referenced by ReadCAFTree().

650  {
651  //The ranges of run number are used from the Period and epoch naming page
652  //https://cdcvs.fnal.gov/redmine/projects/novaart/wiki/Period_and_Epoch_Naming#fn1
653  //Right now I'm only using runs from epoch 1 to 3c
654  //TODO: more epochs can be used for the next analysis
656  if(run_number > 10376 && run_number < 10408) return "1a";
657  else if(run_number > 10495 && run_number < 10825) return "2a";
658  else if(run_number > 10824 && run_number < 10933) return "2b";
659  else if(run_number > 10932 && run_number < 10974) return "2c";
660  else if(run_number > 11249 && run_number < 11302) return "3b";
661  else if(run_number > 11301 && run_number < 11384) return "3c";
662  else throw cet::exception("ReadCAFMakeEventList")
663  << " The run number "
664  << run_number
665  << " doesn't belong to any epochs for the "
666  << " Near Detector";
667  }//end of NEARDET condition
668 
669  else if(detector == novadaq::cnv::kFARDET){
670  if(run_number > 12941 && run_number < 17140) return "1a";
671  else if(run_number > 17890 && run_number < 19097) return "2a";
672  else if(run_number > 19096 && run_number < 19587) return "2b";
673  else if(run_number > 19586 && run_number < 19747) return "2c";
674  else if(run_number > 20922 && run_number < 21231) return "3b";
675  else if(run_number > 21230 && run_number < 22020) return "3c";
676  else throw cet::exception("ReadCAFMakeEventList")
677  << " The run number "
678  << run_number
679  << " doesn't belong to any epochs for the "
680  << " FAR Detector";
681  }////end of FARDET condition
682 
683  else throw cet::exception("ReadCAFMakeEventList")
684  << " Unknown detector: "
685  << detector
686  << " ";
687 
688 }//end of EpochName function
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Far Detector at Ash River, MN.
Near Detector in the NuMI cavern.
void fnex::ReadCAFMakeEventList::FillSpillInformation ( )
private

Function to fill the spill summary information.

Definition at line 833 of file ReadCAFMakeEventList_module.cc.

References fFDMC_SpillPOT, fFilesPerEpoch, fNDData_SpillPOT, fNDMC_SpillPOT, fPOT, fPOTSum, fVarVals, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, LOG_VERBATIM, fetch_tb_beamline_files::md, and fnex::SpillPOT::totpot.

Referenced by ReadCAFTree().

833  {
834 
835  //Get the metadata from the fVarVals
836  auto md = fVarVals.begin()->first;
837 
838  //Check that we are using ND MC and set the POT accordingly
839  if(md.isMC && md.detector == novadaq::cnv::kNEARDET){
840 
841  //loop over files per epoch
842  for(auto itr : fFilesPerEpoch){
843 
844  LOG_VERBATIM("FillSpillInformation")
845  << " Epoch : "
846  << itr.first
847  << " has "
848  << itr.second
849  << " files.";
850 
851  auto mcPOT = fNDMC_SpillPOT;
852  mcPOT.totpot *= itr.second;
853  mcPOT.totgoodpot *= itr.second;
854  mcPOT.totspills *= itr.second;
855  mcPOT.goodspills *= itr.second;
856 
857  fPOTSum[itr.first] = mcPOT;
858 
859  LOG_VERBATIM("EventListMaker")
860  << "POT of "
861  << mcPOT.totgoodpot
862  << " for epoch "
863  << itr.first
864  << " "
865  << fPOTSum.find(itr.first)->second.totgoodpot;
866  }//end of loop over files per epoch
867  }//end of condition that we have ND MC metadata
868 
869  //Check that we are using FD MC and set the POT accordingly
870  if(md.isMC && md.detector == novadaq::cnv::kFARDET){
871 
872  for(auto itr : fFilesPerEpoch){
873 
874  LOG_VERBATIM("FillSpillInformation")
875  << " Epoch : "
876  << itr.first
877  << " has "
878  << itr.second
879  << " files.";
880 
881  auto mcPOT = fFDMC_SpillPOT;
882  mcPOT.totpot = fPOT;
883  mcPOT.totgoodpot = fPOT;
884  mcPOT.totspills *= itr.second;
885  mcPOT.goodspills *= itr.second;
886 
887  fPOTSum[itr.first] = mcPOT;
888 
889  LOG_VERBATIM("EventListMaker")
890  << "POT of "
891  << mcPOT.totgoodpot
892  << " for epoch "
893  << itr.first
894  << " "
895  << fPOTSum.find(itr.first)->second.totgoodpot;
896  }//end of loop over files per epoch
897  }//end of FD MC condition
898 
899  //Check that we are using ND Data and set the POT accordingly
900  if(!md.isMC && md.detector == novadaq::cnv::kNEARDET){
901 
902  for(auto itr : fFilesPerEpoch){
903 
904  LOG_VERBATIM("FillSpillInformation")
905  << " Epoch : "
906  << itr.first
907  << " has "
908  << itr.second
909  << " files.";
910 
911  auto dataPOT = fNDData_SpillPOT;
912  dataPOT.totpot = fPOT;
913  dataPOT.totgoodpot = fPOT;
914  dataPOT.totspills *= itr.second;
915  dataPOT.goodspills *= itr.second;
916 
917  fPOTSum[itr.first] = dataPOT;
918 
919  LOG_VERBATIM("EventListMaker")
920  << "POT of "
921  << dataPOT.totgoodpot
922  << " for epoch "
923  << itr.first
924  << " "
925  << fPOTSum.find(itr.first)->second.totgoodpot;
926  }//end of loop over files per epoch
927  }//end of ND Data condition
928 
929  return;
930 
931 }//end of FillSpillInformation
fnex::SpillPOT fFDMC_SpillPOT
Spill information for the FD MC files.
std::map< std::string, int > fFilesPerEpoch
number of files seen per epoch
fnex::SpillPOT fNDData_SpillPOT
Spill information for the ND Data files.
fnex::EventVarValsMap fVarVals
each entry in the vector is for a single slice
Far Detector at Ash River, MN.
fnex::SpillPOT fNDMC_SpillPOT
Spill information for the ND MC files.
Near Detector in the NuMI cavern.
std::map< std::string, fnex::SpillPOT > fPOTSum
total summary of the POT information
#define LOG_VERBATIM(category)
void fnex::ReadCAFMakeEventList::FindEpochFile ( )
private

Function to find the number of files per epoch.

Definition at line 933 of file ReadCAFMakeEventList_module.cc.

References fnex::DEFINE_ART_MODULE(), fEpochName, fFilesPerEpoch, and fInputFilesPerEpoch.

Referenced by ReadCAFTree().

933  {
934 
936 
937 }//end of FindEpochFile
std::map< std::string, int > fFilesPerEpoch
number of files seen per epoch
std::string fEpochName
Name of the epoch from fhicl configuration.
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
ReadCAFMakeEventList& fnex::ReadCAFMakeEventList::operator= ( ReadCAFMakeEventList const &  )
delete
ReadCAFMakeEventList& fnex::ReadCAFMakeEventList::operator= ( ReadCAFMakeEventList &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void fnex::ReadCAFMakeEventList::ReadCAFTree ( )
private

Function to read in the CAF or DeCAF trees.

Definition at line 265 of file ReadCAFMakeEventList_module.cc.

References a, make_root_from_grid_output::cycle, runNovaSAM::detector, EpochName(), MakeMiniprodValidationCuts::f, fAnalysisType, fCAF_files, fFileType, plotROC::fileName, FillSpillInformation(), FindEpochFile(), fPIDMax, fPIDMin, fSelectionTypes, fVarVals, MECModelEnuComparisons::i, it, simb::kCC, fnex::kDataFile, novadaq::cnv::kFARDET, fnex::kHad_RecoE, fnex::kLep_RecoE, simb::kNC, fnex::kNC, novadaq::cnv::kNEARDET, fnex::kNuE_CVN, fnex::kNuE_NumMichel, fnex::kNuEBarCC, fnex::kNuECC, fnex::kNuESelectionHighPID, fnex::kNuESelectionLowPID, fnex::kNuESelectionMidPID, fnex::kNuMuBarCC, fnex::kNuMuCC, fnex::kNuMuSelection, fnex::kNuTauBarCC, fnex::kNuTauCC, fnex::kRPACCQE_Weight, fnex::kTrueCCNC, fnex::kTrueE, fnex::kTrueIntType, fnex::kTrueParentDecay, fnex::kTrueParentPDG, fnex::kTrueParentPT, fnex::kTrueParentPZ, fnex::kTrueParentTargetPDG, fnex::kTruePDG, fnex::kTruePDGOrig, novadaq::cnv::kUNKNOWN_DET, fnex::kUnknownInteraction, fnex::kXSecCVPPFX_Weight, LOG_DEBUG, LOG_VERBATIM, fetch_tb_beamline_files::md, make_root_from_grid_output::pdg, make_template_knob_config::recTree, updateRunHistoryTables::run, fnex::MCVarVals::set_val_at(), fnex::DataVarVals::set_val_at(), string, getGoodRuns4SAM::subrun, fnex::MetaData::ToString(), and fnex::DataVarVals::val_at().

Referenced by analyze().

265  {
266 
267  LOG_VERBATIM("ReadCAFTree")
268  << "Ready to read the CAF file:";
269 
270  //loop over all CAF files
271  for(auto & fileName : fCAF_files){
272 
273  //CAF file name
274  TFile *f = TFile::Open(fileName.c_str());
275 
276  //Rec tree containing information about the
277  //run, subrun, showers, tracks etc
278  std::string recTreeName = "caf_new_tree";
279  TTree *recTree = dynamic_cast<TTree*>(f->Get(recTreeName.c_str() ) );
280 
281  //cet::exception if the recTree doesn't exist
282  if( !recTree){
283  throw cet::exception("ReadCAFMakeEventList")
284  << "cannot find recTree tree: "
285  << recTreeName;
286  }//end of condition that rec Tree not found
287 
288  //Print the name of the recTree name just for sanity check
289  //that we are reading a CAF file
290  LOG_VERBATIM("ReadCAFMakeEventList:ReadCAFTree: ")
291  << " Tree name: "
292  << recTree->GetName()
293  << " Entries: "
294  << recTree->GetEntries();
295 
296  //Set the branch address
297  int run;
298  int subrun;
299  int event;
300  int slice;
301  int cycle;
302  int pdg_orig;
303  int pdg;
304  int interation_type;
305  int pdg_parent;
306  int parent_decay;
307  int pdg_parent_target;
308  int detector;
309  int nmichels;
310 
311  double trueNuE;
312  double hadE;
313  double lepE;
314  double recoNuE;
315  double RPACCQE_weight;
316  double XSecCV_weight;
317  double cvne;
318 
319  float ParentPZ;
320  float ParentPT;
321 
322  bool IsCC;
323  bool IsMC;
324 
325  //Let's now loop over Analysis type
326  //Numu and nue analysis types have different number of entries
327  //in the CAF text file, so, fill FNEX lists accordingly
328  LOG_VERBATIM("ReadCAFMakeEventList")
329  << "Size of Selection Vector: " << fSelectionTypes.size();
330 
331  for(size_t a = 0; a < fSelectionTypes.size(); ++a){
332 
334  LOG_VERBATIM("ReadCAFMakeEventList")
335  << "Analysis is "
336  << fAnalysisType[a];
337  }
338  else{
339  LOG_VERBATIM("ReadCAFMakeEventList")
340  << "Analysis is "
341  << fAnalysisType[a]
342  << " PID range [ "
343  << fPIDMin[a]
344  << " , "
345  << fPIDMax[a]
346  << " ]";
347  }
348 
349  //There are different number of entries for the Data file
350  //Therfore set bracnch address according to the type of file
352  if(fFileType == kDataFile){
353  recTree->SetBranchAddress("run", &run);
354  recTree->SetBranchAddress("subrun", &subrun);
355  recTree->SetBranchAddress("event", &event);
356  recTree->SetBranchAddress("slice", &slice);
357  recTree->SetBranchAddress("cycle", &cycle);
358  recTree->SetBranchAddress("det", &detector);
359  recTree->SetBranchAddress("truenuE", &trueNuE);
360  recTree->SetBranchAddress("hadE", &hadE);
361  recTree->SetBranchAddress("lepE", &lepE);
362  recTree->SetBranchAddress("nuE", &recoNuE);
363  recTree->SetBranchAddress("RPACCQE_Weight", &RPACCQE_weight);
364  recTree->SetBranchAddress("XSecCVPPFX_Weight", &XSecCV_weight);
365  recTree->SetBranchAddress("ismc", &IsMC);
366  }//end of condition that CAF file is a Data file
367  else{
368  recTree->SetBranchAddress("run", &run);
369  recTree->SetBranchAddress("subrun", &subrun);
370  recTree->SetBranchAddress("event", &event);
371  recTree->SetBranchAddress("slice", &slice);
372  recTree->SetBranchAddress("cycle", &cycle);
373  recTree->SetBranchAddress("pdg_orig", &pdg_orig);
374  recTree->SetBranchAddress("pdg", &pdg);
375  recTree->SetBranchAddress("interactionType", &interation_type);
376  recTree->SetBranchAddress("pdg_parent", &pdg_parent);
377  recTree->SetBranchAddress("parent_decay_mode", &parent_decay);
378  recTree->SetBranchAddress("pdg_parent_target", &pdg_parent_target);
379  recTree->SetBranchAddress("det", &detector);
380  recTree->SetBranchAddress("truenuE", &trueNuE);
381  recTree->SetBranchAddress("hadE", &hadE);
382  recTree->SetBranchAddress("lepE", &lepE);
383  recTree->SetBranchAddress("nuE", &recoNuE);
384  recTree->SetBranchAddress("RPACCQE_Weight", &RPACCQE_weight);
385  recTree->SetBranchAddress("XSecCVPPFX_Weight", &XSecCV_weight);
386  recTree->SetBranchAddress("parent_pz", &ParentPZ);
387  recTree->SetBranchAddress("parent_pt", &ParentPT);
388  recTree->SetBranchAddress("iscc", &IsCC);
389  recTree->SetBranchAddress("ismc", &IsMC);
390  }//end of condition that CAF file is a MC file
391  }//read above branches only if it is a Numu Selection CAF file
392  else{
393  if(fFileType == kDataFile){
394  recTree->SetBranchAddress("run", &run);
395  recTree->SetBranchAddress("subrun", &subrun);
396  recTree->SetBranchAddress("event", &event);
397  recTree->SetBranchAddress("slice", &slice);
398  recTree->SetBranchAddress("cycle", &cycle);
399  recTree->SetBranchAddress("det", &detector);
400  recTree->SetBranchAddress("truenuE", &trueNuE);
401  recTree->SetBranchAddress("hadE", &hadE);
402  recTree->SetBranchAddress("lepE", &lepE);
403  recTree->SetBranchAddress("nuE", &recoNuE);
404  recTree->SetBranchAddress("RPACCQE_Weight", &RPACCQE_weight);
405  recTree->SetBranchAddress("XSecCVPPFX_Weight", &XSecCV_weight);
406  recTree->SetBranchAddress("ismc", &IsMC);
407  recTree->SetBranchAddress("nmichels", &nmichels);
408  recTree->SetBranchAddress("cvne", &cvne);
409  }//end of condition that CAF file is a Data file
410  else{
411  recTree->SetBranchAddress("run", &run);
412  recTree->SetBranchAddress("subrun", &subrun);
413  recTree->SetBranchAddress("event", &event);
414  recTree->SetBranchAddress("slice", &slice);
415  recTree->SetBranchAddress("cycle", &cycle);
416  recTree->SetBranchAddress("pdg_orig", &pdg_orig);
417  recTree->SetBranchAddress("pdg", &pdg);
418  recTree->SetBranchAddress("interactionType", &interation_type);
419  recTree->SetBranchAddress("pdg_parent", &pdg_parent);
420  recTree->SetBranchAddress("parent_decay_mode", &parent_decay);
421  recTree->SetBranchAddress("pdg_parent_target", &pdg_parent_target);
422  recTree->SetBranchAddress("det", &detector);
423  recTree->SetBranchAddress("truenuE", &trueNuE);
424  recTree->SetBranchAddress("hadE", &hadE);
425  recTree->SetBranchAddress("lepE", &lepE);
426  recTree->SetBranchAddress("nuE", &recoNuE);
427  recTree->SetBranchAddress("RPACCQE_Weight", &RPACCQE_weight);
428  recTree->SetBranchAddress("XSecCVPPFX_Weight", &XSecCV_weight);
429  recTree->SetBranchAddress("parent_pz", &ParentPZ);
430  recTree->SetBranchAddress("parent_pt", &ParentPT);
431  recTree->SetBranchAddress("iscc", &IsCC);
432  recTree->SetBranchAddress("ismc", &IsMC);
433  recTree->SetBranchAddress("nmichels", &nmichels);
434  recTree->SetBranchAddress("cvne", &cvne);
435  }//end of condition that CAF file is a MC file
436  }//read above branches only if it is a Numu Selection CAF file
437 
438  //Loop over rec tree enetries and fill the FNEX eventlist
439  for(int ctr = 0; ctr < recTree->GetEntries(); ++ctr){
440 
441  //Get the ctr-th entry
442  recTree->GetEntry(ctr);
443 
444  //Print the values for sanity check
445  if(fFileType == kDataFile){
446  LOG_DEBUG("ReadCAFMakeEventList")
447  << " Entry: "
448  << ctr
449  << " Run: "
450  << run
451  << " Subrun: "
452  << subrun
453  << " Event: "
454  << event
455  << " slice: "
456  << slice
457  << " Cycle: "
458  << cycle
459  << " Detector: "
460  << detector
461  << " Epoch: "
462  << this->EpochName(detector, run);
463  }//end of condition that CAF file is a Data file
464  else{
465  LOG_DEBUG("ReadCAFMakeEventList")
466  << " Entry: "
467  << ctr
468  << " Run: "
469  << run
470  << " Subrun: "
471  << subrun
472  << " Event: "
473  << event
474  << " slice: "
475  << slice
476  << " Cycle: "
477  << cycle
478  << " Detector: "
479  << detector
480  << " Epoch: "
481  << this->EpochName(detector, run);
482  }//end of condition that CAF file is a MC file
483 
484  //remove the event if trueNuE is zero
485  if(trueNuE==0){
486  LOG_VERBATIM("ReadCAFMakeEventList")
487  << " Event with true nuE zero.. "
488  << " Run: "
489  << run
490  << " Subrun: "
491  << subrun
492  << " Event: "
493  << event
494  << " slice: "
495  << slice
496  << " Cycle: "
497  << cycle
498  << " Epoch: "
499  << this->EpochName(detector, run)
500  << " True nue E: "
501  << trueNuE;
502  continue;
503  }
504 
505  //Declaration of fnex::Metadata, fnex::InteractionType_t,
506  //DataVarVals and MCVarVals
507 
510  int PDG = 0;
511  std::vector<fnex::DataVarVals> dataVals;
512  std::vector<fnex::MCVarVals > mcVals;
513 
514  //clear the Data and MC Var Vals for every event
515  dataVals.clear();
516  mcVals .clear();
517 
518  //Declaration of DataVarVals and MCVarVals
519  fnex::DataVarVals dataVarVals;
520  fnex::MCVarVals mcVarVals;
521 
522  //Fill reco lepE and hadE variables for the DataVarVals
523  dataVarVals.set_val_at(fnex::kLep_RecoE, lepE );
524  dataVarVals.set_val_at(fnex::kHad_RecoE, hadE );
525 
526  //Fill CVN and number of micheal electrons information
527  //for nue selected events
531  ){
532  dataVarVals.set_val_at(fnex::kNuE_CVN, cvne );
533  dataVarVals.set_val_at(fnex::kNuE_NumMichel, nmichels );
534  }//end of condition that it is a nue selected event
535 
536  //Fill true variables for the MCVarVals
537  //Make sure you have only MC event
538  if(IsMC){
539  mcVarVals.set_val_at(fnex::kTrueE, trueNuE );
540  mcVarVals.set_val_at(fnex::kTruePDG, pdg );
541  //My CAF list has 0 as NC and 1 as CC
542  //Need to fix it because in nusimdata/SimulationBase/MCNeutrino.h
543  //I see 0 is CC and 1 is NC
544  //Need to swap my NC with CC and vice-cersa
545  int ccnc = simb::kNC;
546  if(IsCC) ccnc = simb::kCC;
547  mcVarVals.set_val_at(fnex::kTrueCCNC, ccnc );
548  mcVarVals.set_val_at(fnex::kTrueIntType, interation_type );
549  mcVarVals.set_val_at(fnex::kXSecCVPPFX_Weight, XSecCV_weight );
550  mcVarVals.set_val_at(fnex::kRPACCQE_Weight, RPACCQE_weight );
551  mcVarVals.set_val_at(fnex::kTruePDGOrig, pdg_orig );
552  mcVarVals.set_val_at(fnex::kTrueParentPDG, pdg_parent );
553  mcVarVals.set_val_at(fnex::kTrueParentDecay, parent_decay );
554  mcVarVals.set_val_at(fnex::kTrueParentTargetPDG, pdg_parent_target );
555  mcVarVals.set_val_at(fnex::kTrueParentPZ, ParentPZ );
556  mcVarVals.set_val_at(fnex::kTrueParentPT, ParentPT );
557 
558  }//end of MC event condition
559 
560  //save dataVarVals and mcVarVals in their corresponding vectors for each event and slice
562  dataVals .push_back(dataVarVals );
563  mcVals .push_back(mcVarVals );
564  }
568  // check the cvn value and only add the vars to the collection
569  //if we are in the desired range
570  auto cvnVal = dataVarVals.val_at(fnex::kNuE_CVN, fnex::MetaData());
571  if(cvnVal >= fPIDMin[a] && cvnVal < fPIDMax[a] ){
572 
573  dataVals .push_back(dataVarVals );
574  mcVals .push_back(mcVarVals );
575 
576  }//fill variables only for desired range of cvn values
577  }//end of condition that fill data and mc Var vals for nue selected events
578 
579  // check that the filled variable vectors are the same size
580  if(dataVals.size() != mcVals.size())
581  throw cet::exception("EventListMaker")
582  << "Data and MC variable vectors have different sizes: "
583  << dataVals.size()
584  << " : "
585  << mcVals.size()
586  << " cannot do anything with this slice, bail";
587 
588  //Now we can loop over VarVals vectors and can make the metadatas
589  for(size_t i = 0; i < dataVals.size(); ++i){
590 
592 
593  if(IsMC){
594  if( mcVals[i].val_at(fnex::kTrueCCNC) == 1.*simb::kNC )
595  it = fnex::kNC;
596  else{
597  PDG = mcVals[i].val_at(fnex::kTruePDG);
598  if (PDG == 12) it = fnex::kNuECC;
599  else if(PDG == -12) it = fnex::kNuEBarCC;
600  else if(PDG == 14) it = fnex::kNuMuCC;
601  else if(PDG == -14) it = fnex::kNuMuBarCC;
602  else if(PDG == 16) it = fnex::kNuTauCC;
603  else if(PDG == -16) it = fnex::kNuTauBarCC;
604  }//end of condition that we have CC interactions
605  }//end of condition that we have MC
606 
607  novadaq::cnv::DetId det_daq;
608  if(detector == 1) det_daq = novadaq::cnv::kNEARDET;
609  else if(detector == 2) det_daq = novadaq::cnv::kFARDET;
610  else det_daq = novadaq::cnv::kUNKNOWN_DET;
611 
612  //Metadata
613  md = fnex::MetaData(IsMC,
614  det_daq,
615  fFileType,
616  fSelectionTypes[a],
617  it,
618  this->EpochName(detector, run)
619  );
620 
621  LOG_DEBUG("ReadCAFMakeEventList::ReadCAFTree")
622  << " Inside ReadCAFTree "
623  << " Metadata : "
624  << md.ToString()
625  << " Selection index : "
626  << a;
627 
628  //Fill Var Vals Map
629  fnex::EventId evId(run, subrun, event, cycle, slice);
630 
631  fVarVals[md].emplace_back(evId,
632  dataVals[i],
633  mcVals[i]
634  );
635  }//end of loop over VarVals vectors
636  }//end of loop over recTree entries
637  }//end of loop over Analysis type
638  }//end of loop over all CAF files
639 
640  //Find epoch files
641  this->FindEpochFile();
642 
643  //Fill the Spill information
644  this->FillSpillInformation();
645 
646  return;
647 }//end of main function ReadCAFTree
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
fileName
Definition: plotROC.py:78
set< int >::iterator it
fnex::FileType_t fFileType
get from the configuration for now
static const unsigned char kTrueParentPT
Definition: VarVals.h:48
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:930
void set_val_at(std::string const &varkey, float const &val)
Definition: VarVals.cxx:164
std::vector< double > fPIDMax
Maximum value of the CVN for nue selected events.
enum fnex::interaction_type InteractionType_t
static const unsigned char kXSecCVPPFX_Weight
Definition: VarVals.h:56
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::vector< double > fPIDMin
Minimum value of the CVN for nue selected events.
static const unsigned char kTrueParentPDG
Definition: VarVals.h:47
static const unsigned char kTruePDGOrig
Definition: VarVals.h:46
static const unsigned char kTrueCCNC
Definition: VarVals.h:44
fnex::EventVarValsMap fVarVals
each entry in the vector is for a single slice
std::string const ToString() const
Definition: Structs.cxx:114
Far Detector at Ash River, MN.
std::string EpochName(int, int)
Function to find the epoch an event belongs to.
std::vector< fnex::SelectionType_t > fSelectionTypes
get from the analysis configuration
void FillSpillInformation()
Function to fill the spill summary information.
const double a
static const unsigned char kNuE_NumMichel
Definition: VarVals.h:33
Near Detector in the NuMI cavern.
float val_at(unsigned char const &varkey, fnex::MetaData const &md) const
Definition: VarVals.cxx:499
static const unsigned char kTrueIntType
Definition: VarVals.h:45
static const unsigned char kTrueParentDecay
Definition: VarVals.h:50
void FindEpochFile()
Function to find the number of files per epoch.
static const unsigned char kTrueParentTargetPDG
Definition: VarVals.h:51
static const unsigned char kRPACCQE_Weight
Definition: VarVals.h:57
std::vector< std::string > fAnalysisType
Name of the Analysis type.
static const unsigned char kTrueE
Definition: VarVals.h:42
void set_val_at(std::string const &varkey, float const &val)
Definition: VarVals.cxx:525
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
#define LOG_VERBATIM(category)
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
std::vector< std::string > fCAF_files
A vector of input CAF files.
static const unsigned char kTrueParentPZ
Definition: VarVals.h:49
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:874
static const unsigned char kTruePDG
Definition: VarVals.h:43
enum BeamMode string
void fnex::ReadCAFMakeEventList::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 200 of file ReadCAFMakeEventList_module.cc.

References fAnalysisType, fCAF_files, fEpochName, fFileType, fInputFilesPerEpoch, fPIDMax, fPIDMin, fPOT, fSelectionTypes, fSpillsPerFile, fhicl::ParameterSet::get(), fnex::kBeam, fnex::kCosmicBackgroundFile, fnex::kDataFile, fnex::kNuESelection, fnex::kNuESelectionHighPID, fnex::kNuESelectionLowPID, fnex::kNuESelectionMidPID, fnex::kNuMuSelection, fnex::kSwap, fnex::kTauSwap, LOG_DEBUG, LOG_VERBATIM, and string.

Referenced by ReadCAFMakeEventList().

201 {
202 
203  fCAF_files = p.get< std::vector<std::string> >("CAF_files", std::vector<std::string>() );
204 
205  auto ftString = p.get<std::string >("FileType" );
206  if (ftString.compare("NonSwap") == 0)
207  fFileType = kBeam;
208  else if (ftString.compare("FluxSwap") == 0)
209  fFileType = kSwap;
210  else if (ftString.compare("TauSwap") == 0)
212  else if (ftString.compare("CosmicBackground") == 0)
214  else
216 
217  fSpillsPerFile = p.get<float >("SpillsPerFile" );
218  fEpochName = p.get<std::string >("EpochName", " " );
219  fInputFilesPerEpoch = p.get<int >("InputFilesPerEpoch" );
220  fPOT = p.get<double >("POT" );
221 
222  // create the analysis object we need
223  for(auto const& apset : p.get<std::vector<fhicl::ParameterSet> >("AnalysisPSets")){
224 
225  auto const& type = apset.get<std::string>("AnalysisType");
226 
227  LOG_VERBATIM("ReadCAFMakeEventList::reconfigure")
228  << "AnalysisType is " << type;
229 
230  fAnalysisType .push_back(type);
231 
232  if(type.compare("NuMu_Standard") == 0){
234  }
235  else if(type.compare("NuE_AllPID") == 0){
237  }
238  else if(type.compare("NuE_LowPID") == 0){
240  fPIDMin .push_back(apset.get<double>("PIDMin"));
241  fPIDMax .push_back(apset.get<double>("PIDMax"));
242  }
243  else if(type.compare("NuE_MidPID") == 0){
245  fPIDMin .push_back(apset.get<double>("PIDMin"));
246  fPIDMax .push_back(apset.get<double>("PIDMax"));
247  }
248  else if(type.compare("NuE_HighPID") == 0){
250  fPIDMin .push_back(apset.get<double>("PIDMin"));
251  fPIDMax .push_back(apset.get<double>("PIDMax"));
252  }
253  else
254  throw cet::exception("ReadCAFMakeEventList") << "unknown AnalysisType: " << type;
255 
256  }//end of loop over vector of fhicl parameters AnalysisPSets
257 
258  LOG_DEBUG("ReadCAFMakeEventList::reconfigure")
259  << "Size of SelectionTypes vector : "
260  << fSelectionTypes.size();
261 
262  return;
263 }//end of reconfigure
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
fnex::FileType_t fFileType
get from the configuration for now
const char * p
Definition: xmltok.h:285
std::vector< double > fPIDMax
Maximum value of the CVN for nue selected events.
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::vector< double > fPIDMin
Minimum value of the CVN for nue selected events.
std::vector< fnex::SelectionType_t > fSelectionTypes
get from the analysis configuration
std::string fEpochName
Name of the epoch from fhicl configuration.
float fSpillsPerFile
spills in each ND file
std::vector< std::string > fAnalysisType
Name of the Analysis type.
#define LOG_VERBATIM(category)
std::vector< std::string > fCAF_files
A vector of input CAF files.
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 fnex::ReadCAFMakeEventList::Serialize ( )
private

Function to make the metadata, spill and eventlist trees.

Definition at line 697 of file ReadCAFMakeEventList_module.cc.

References make_root_from_grid_output::cycle, fnex::MetaData::EpochString(), fPOTSum, fTFS, fVarVals, fnex::SpillSummary::goodPOT, fnex::SpillPOT::goodspills, fnex::MetaData::isMC, it, findDuplicateFiles::key, fnex::KeyToVarName(), fnex::kMinus2Sigma, fnex::kNu_RecoE, fnex::kNuE_CVN, fnex::kTrueE, LOG_DEBUG, LOG_VERBATIM, art::TFileDirectory::make(), fetch_tb_beamline_files::md, fnex::SpillSummary::numGoodSpills, pot, updateRunHistoryTables::run, ss, string, fnex::MetaData::ToString(), fnex::SpillSummary::totalNumSpills, fnex::SpillSummary::totalPOT, fnex::SpillPOT::totgoodpot, fnex::SpillPOT::totpot, fnex::SpillPOT::totspills, fnex::MCVarVals::val_at(), and fnex::DataVarVals::val_at().

Referenced by analyze().

697  {
698 
699  //Declaration of Metadata, SpillSummary and epoch
702  std::string epoch;
704 
705  // first make the metadata tree
706  // with metadata and spill summary as branches
707  TTree *metadataTree = fTFS->make<TTree>( "metadata", "Event list metadata" );
708  metadataTree->Branch("metadata", &md);
709  metadataTree->Branch("spillsummary", &ss);
710 
711  //Loop over VarVals map
712  for(auto it : fVarVals){
713 
714  md = it.first;
715  epoch = md.EpochString();
716 
717  //find the pot information for an epoch
718  if( fPOTSum.count(epoch) > 0) pot = fPOTSum.find(epoch)->second;
719  else
720  throw cet::exception("EventListMaker")
721  << "Unable to find POT for epoch "
722  << epoch << " ";
723 
724  //The correct spill summary informations
725  ss.totalPOT = pot.totpot;
726  ss.goodPOT = pot.totgoodpot;
727  ss.totalNumSpills = pot.totspills;
728  ss.numGoodSpills = pot.goodspills;
729 
730  LOG_VERBATIM("EventListMaker")
731  << md.ToString()
732  << " totalPOT "
733  << pot.totpot
734  << " : "
735  << ss.totalPOT
736  << " and "
737  << " total number of spills: "
738  << pot.totspills
739  << " : "
740  << ss.totalNumSpills;
741 
742  metadataTree->Fill();
743 
744  LOG_DEBUG("EventListMaker")
745  << "there are "
746  << it.second.size()
747  << " sets of variables, ie slices for "
748  << md.ToString();
749 
750  // create a new event list with one event per standard record
751  fnex::EventList eventList(md, ss);
752 
753  std::vector<std::string> indepVarNames;
754  std::vector<float> indepVarVals;
755  int run;
756  int subRun;
757  int event;
758  int cycle;
759  int slice;
760  fnex::DataVarVals dataVars;
761  fnex::MCVarVals mcVars;
762  std::string varName;
763 
764  // same principle as above for the event tree
765  TTree *eventTree = fTFS->make<TTree>( md.ToString().c_str(), "FNEX event records" );
766 
767  eventTree->Branch("run", &run );
768  eventTree->Branch("subRun", &subRun );
769  eventTree->Branch("event", &event );
770  eventTree->Branch("cycle", &cycle );
771  eventTree->Branch("slice", &slice );
772  eventTree->Branch("indepVarNames", &indepVarNames);
773  eventTree->Branch("indepVarVals", &indepVarVals );
774 
775  //loop over events for each metadata
776  for(auto & itr : it.second){
777 
778  // empty the containers so we don't get the last event spilling over into this one
779  indepVarNames.clear();
780  indepVarVals .clear();
781 
782  event = itr.eventId.event;
783  run = itr.eventId.run;
784  subRun = itr.eventId.subrun;
785  cycle = itr.eventId.cycle;
786  //slice = itr.slice;
787  dataVars = itr.dataVars;
788  mcVars = itr.mcVars;
789 
790  // load up the data related values. Skip the Nu_RecoE because that is
791  // calculated from the leptonic and hadronic energy
792 
793  for(auto key = fnex::kNuE_CVN; key < fnex::kNu_RecoE; ++key){
794  indepVarNames.push_back(fnex::KeyToVarName(key));
795  indepVarVals .push_back(dataVars.val_at(key, md));
796  } // end loop over data variables
797 
798  // load up the MC related values.
799  if( md.isMC ){
800  LOG_DEBUG("EventListMaker")
801  << "Filling tree, mcVars: "
802  << mcVars;
803 
804  //TODO: Fill GENIE weights later on
805  for(auto key = fnex::kTrueE; key < fnex::kMinus2Sigma; ++key){
806 
807  varName = fnex::KeyToVarName(key);
808 
809  //store the indepVarNames and indepVarVals
810  indepVarNames.push_back(varName);
811  indepVarVals .push_back(mcVars.val_at(key));
812 
813  LOG_DEBUG("EventListMaker")
814  << " indepVar Names and Values: "
815  << indepVarNames.back()
816  << " "
817  << indepVarVals.back();
818 
819  }//end of loop over MC keys
820  }//end of condition that it is a MC file
821 
822  //Fill the eventlist trees
823  eventTree->Fill();
824 
825  }//end of loop over events for each metadata
826 
827  }//end of looping over VarVals map
828 
829  return;
830 
831 }//end of Serialize functions
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
static const unsigned char kNu_RecoE
Definition: VarVals.h:36
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
set< int >::iterator it
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:930
Float_t ss
Definition: plot.C:24
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::string const EpochString() const
Definition: Structs.cxx:101
unsigned long int numGoodSpills
Definition: Structs.h:108
fnex::EventVarValsMap fVarVals
each entry in the vector is for a single slice
std::string const ToString() const
Definition: Structs.cxx:114
#define pot
float val_at(unsigned char const &varkey, fnex::MetaData const &md) const
Definition: VarVals.cxx:499
unsigned long int goodspills
float val_at(unsigned char const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:77
std::map< std::string, fnex::SpillPOT > fPOTSum
total summary of the POT information
unsigned long int totalNumSpills
Definition: Structs.h:107
T * make(ARGS...args) const
static const unsigned char kMinus2Sigma
Definition: VarVals.h:65
static const unsigned char kTrueE
Definition: VarVals.h:42
art::ServiceHandle< art::TFileService > fTFS
TFileService.
unsigned long int totspills
std::string KeyToVarName(unsigned char const &key)
Definition: VarVals.h:445
#define LOG_VERBATIM(category)
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:874
enum BeamMode string
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::vector<std::string> fnex::ReadCAFMakeEventList::fAnalysisType
private

Name of the Analysis type.

Definition at line 134 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

std::vector<std::string> fnex::ReadCAFMakeEventList::fCAF_files
private

A vector of input CAF files.

Definition at line 112 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

std::string fnex::ReadCAFMakeEventList::fEpochName
private

Name of the epoch from fhicl configuration.

Definition at line 124 of file ReadCAFMakeEventList_module.cc.

Referenced by FindEpochFile(), and reconfigure().

fnex::SpillPOT fnex::ReadCAFMakeEventList::fFDMC_SpillPOT
private

Spill information for the FD MC files.

Definition at line 121 of file ReadCAFMakeEventList_module.cc.

Referenced by FillSpillInformation(), and ReadCAFMakeEventList().

std::map<std::string, int> fnex::ReadCAFMakeEventList::fFilesPerEpoch
private

number of files seen per epoch

Definition at line 118 of file ReadCAFMakeEventList_module.cc.

Referenced by FillSpillInformation(), and FindEpochFile().

fnex::FileType_t fnex::ReadCAFMakeEventList::fFileType
private

get from the configuration for now

Definition at line 115 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

int fnex::ReadCAFMakeEventList::fInputFilesPerEpoch
private

Definition at line 125 of file ReadCAFMakeEventList_module.cc.

Referenced by FindEpochFile(), and reconfigure().

fnex::SpillPOT fnex::ReadCAFMakeEventList::fNDData_SpillPOT
private

Spill information for the ND Data files.

Definition at line 122 of file ReadCAFMakeEventList_module.cc.

Referenced by FillSpillInformation(), and ReadCAFMakeEventList().

fnex::SpillPOT fnex::ReadCAFMakeEventList::fNDMC_SpillPOT
private

Spill information for the ND MC files.

Definition at line 120 of file ReadCAFMakeEventList_module.cc.

Referenced by FillSpillInformation(), and ReadCAFMakeEventList().

std::vector<double> fnex::ReadCAFMakeEventList::fPIDMax
private

Maximum value of the CVN for nue selected events.

Definition at line 136 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

std::vector<double> fnex::ReadCAFMakeEventList::fPIDMin
private

Minimum value of the CVN for nue selected events.

Definition at line 135 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

double fnex::ReadCAFMakeEventList::fPOT
private

Definition at line 126 of file ReadCAFMakeEventList_module.cc.

Referenced by FillSpillInformation(), and reconfigure().

std::map<std::string, fnex::SpillPOT> fnex::ReadCAFMakeEventList::fPOTSum
private

total summary of the POT information

Definition at line 123 of file ReadCAFMakeEventList_module.cc.

Referenced by clear(), FillSpillInformation(), and Serialize().

std::vector<fnex::SelectionType_t> fnex::ReadCAFMakeEventList::fSelectionTypes
private

get from the analysis configuration

Definition at line 116 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFTree(), and reconfigure().

float fnex::ReadCAFMakeEventList::fSpillsPerFile
private

spills in each ND file

Definition at line 119 of file ReadCAFMakeEventList_module.cc.

Referenced by ReadCAFMakeEventList(), and reconfigure().

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

TFileService.

Definition at line 117 of file ReadCAFMakeEventList_module.cc.

Referenced by Serialize().

fnex::EventVarValsMap fnex::ReadCAFMakeEventList::fVarVals
private

each entry in the vector is for a single slice

Definition at line 114 of file ReadCAFMakeEventList_module.cc.

Referenced by analyze(), clear(), FillSpillInformation(), ReadCAFTree(), and Serialize().


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