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

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 CAFToEventList (fhicl::ParameterSet const &pset)
 
virtual ~CAFToEventList ()
 
 CAFToEventList (CAFToEventList const &)=delete
 
 CAFToEventList (CAFToEventList &&)=delete
 
CAFToEventListoperator= (CAFToEventList const &)=delete
 
CAFToEventListoperator= (CAFToEventList &&)=delete
 
void analyze (art::Event const &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void endJob () override
 
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 clear ()
 
void FindPOTPerPeriod (TFile &tf)
 
void InsertPeriod6Cosmics ()
 
int PeriodAdjustCosmics (int const &inputPeriod)
 
void InitializeEventListMaps ()
 
std::string RunToEpoch (int run)
 
bool PassesSelections (caf::SRProxy const &proxy) const
 
bool PassesNueSelections (caf::SRProxy const &proxy) const
 
bool PassesNumuSelections (caf::SRProxy const &proxy) const
 
bool PassesSpillAndBeamCuts (caf::SRProxy const &proxy) const
 
void FillVariables (std::vector< fnex::DataVarVals > &dataVals, std::vector< fnex::MCVarVals > &mcVals, std::vector< fnex::EventId > &evIds, std::vector< fnex::SelectionType_t > &sels)
 
void FillMCVarVals (fnex::MCVarVals &mcVarVals, caf::SRProxy &srProxy) const
 
void FillDataVarVals (fnex::DataVarVals &dataVals, caf::SRProxy const &srProxy) const
 
void FillEventId (fnex::EventId &evId, caf::SRProxy const &srProxy) const
 
fnex::SelectionType_t FindSelectionType (caf::SRProxy const &srProxy) const
 
void DefineNumuQuantiles ()
 

Private Attributes

std::vector< std::stringfCAFFileNames
 name of the CAF file we are using More...
 
std::string fFHCQuantFileName
 name of file in numudata ups product with FHC quantiles More...
 
std::string fRHCQuantFileName
 name of file in numudata ups product with FHC quantiles More...
 
std::string fSpillTreeName
 names of the CAF histogram with the total POT More...
 
std::string fPOTHistName
 names of the CAF histogram with the total POT More...
 
std::string fCAFRecTreeName
 names of the CAF tree with the reco info More...
 
novadaq::cnv::DetId fDetector
 which detector are we using More...
 
fnex::EventListMap fMDToEvents
 each entry in the vector is for a single slice More...
 
fnex::FileType_t fFileType
 get from the configuration for now More...
 
bool fIsRealData
 are we looking at real data? More...
 
bool fIsFHC
 are we looking at FHC files? More...
 
std::vector< ana::CutfNumuFHCQuantCuts
 quantile boundaries for the numu FHC data More...
 
std::vector< ana::CutfNumuRHCQuantCuts
 quantile boundaries for the numu RHC data More...
 
unsigned int fNumQuantiles
 number of quantiles More...
 
std::map< int, POTLiveTimefPeriodToPOTLiveTime
 keep track of the POT in each period More...
 
std::set< fnex::SelectionType_tfSelections
 Selections to use. More...
 
bool fMakeSelectedList
 configure to true to make a list More...
 

Detailed Description

Definition at line 85 of file CAFToEventList_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::CAFToEventList::CAFToEventList ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 146 of file CAFToEventList_module.cc.

References clear(), fPeriodToPOTLiveTime, MECModelEnuComparisons::i, and reconfigure().

147  : EDAnalyzer (pset)
150  , fIsRealData (false)
151  , fIsFHC (true)
152  , fNumQuantiles (1)
153  , fMakeSelectedList(false)
154  {
155  // make sure everything is zeroed out.
156  this->clear();
157 
158  this->reconfigure(pset);
159 
160  // initialize the period to POT map
161  // just allow for many periods, unlikely we will
162  // have more than 50, but it doesn't matter if we
163  // plan ahead
164  for(int i = 1; i < 51; ++i) fPeriodToPOTLiveTime[i * 1000] = POTLiveTime(0., 0.);
165 
166  // fMissingEvents.insert(fnex::EventId(16313, 30, 156, 0, 38));
167  // fMissingEvents.insert(fnex::EventId(17014, 40, 671, 0, 40));
168  // fMissingEvents.insert(fnex::EventId(17920, 36, 971, 0, 17));
169  // fMissingEvents.insert(fnex::EventId(17968, 10, 891, 0, 30));
170  // fMissingEvents.insert(fnex::EventId(18209, 27, 137, 0, 30));
171  // fMissingEvents.insert(fnex::EventId(18234, 10, 854, 0, 39));
172  // fMissingEvents.insert(fnex::EventId(18374, 4, 665, 0, 35));
173  // fMissingEvents.insert(fnex::EventId(18478, 33, 737, 0, 39));
174  // fMissingEvents.insert(fnex::EventId(18507, 41, 474, 0, 28));
175  // fMissingEvents.insert(fnex::EventId(18521, 8, 645, 0, 30));
176  // fMissingEvents.insert(fnex::EventId(18529, 48, 342, 0, 29));
177  // fMissingEvents.insert(fnex::EventId(18556, 58, 347, 0, 29));
178  // fMissingEvents.insert(fnex::EventId(18812, 29, 367, 0, 45));
179  // fMissingEvents.insert(fnex::EventId(18910, 43, 356, 0, 36));
180  // fMissingEvents.insert(fnex::EventId(19198, 44, 210, 0, 38));
181  // fMissingEvents.insert(fnex::EventId(19234, 55, 601, 0, 38));
182  // fMissingEvents.insert(fnex::EventId(19270, 15, 392, 0, 38));
183  // fMissingEvents.insert(fnex::EventId(19302, 9, 411, 0, 37));
184  // fMissingEvents.insert(fnex::EventId(19351, 25, 609, 0, 37));
185  // fMissingEvents.insert(fnex::EventId(19542, 13, 13, 0, 30));
186  // fMissingEvents.insert(fnex::EventId(19610, 47, 898, 0, 35));
187  // fMissingEvents.insert(fnex::EventId(19626, 6, 265, 0, 37));
188  // fMissingEvents.insert(fnex::EventId(19708, 37, 312, 0, 30));
189  // fMissingEvents.insert(fnex::EventId(19712, 25, 937, 0, 43));
190  // fMissingEvents.insert(fnex::EventId(19714, 11, 564, 0, 47));
191  // fMissingEvents.insert(fnex::EventId(19732, 27, 153, 0, 36));
192  // fMissingEvents.insert(fnex::EventId(20945, 40, 821, 0, 32));
193  // fMissingEvents.insert(fnex::EventId(21249, 24, 655, 0, 35));
194  // fMissingEvents.insert(fnex::EventId(21253, 31, 933, 0, 23));
195  // fMissingEvents.insert(fnex::EventId(21267, 43, 687, 0, 27));
196  // fMissingEvents.insert(fnex::EventId(21326, 56, 458, 0, 33));
197  // fMissingEvents.insert(fnex::EventId(21330, 16, 490, 0, 27));
198  // fMissingEvents.insert(fnex::EventId(22064, 42, 266, 0, 31));
199  // fMissingEvents.insert(fnex::EventId(22065, 55, 997, 0, 37));
200  // fMissingEvents.insert(fnex::EventId(22251, 54, 694, 0, 38));
201  // fMissingEvents.insert(fnex::EventId(22287, 35, 518, 0, 34));
202  // fMissingEvents.insert(fnex::EventId(22398, 47, 50, 0, 39));
203  // fMissingEvents.insert(fnex::EventId(22425, 59, 97, 0, 26));
204  // fMissingEvents.insert(fnex::EventId(22427, 12, 863, 0, 30));
205  // fMissingEvents.insert(fnex::EventId(22496, 34, 546, 0, 22));
206  // fMissingEvents.insert(fnex::EventId(22523, 34, 208, 0, 33));
207  // fMissingEvents.insert(fnex::EventId(22628, 2, 755, 0, 25));
208  // fMissingEvents.insert(fnex::EventId(22811, 3, 827, 0, 34));
209  // fMissingEvents.insert(fnex::EventId(22999, 58, 545, 0, 29));
210  // fMissingEvents.insert(fnex::EventId(23029, 57, 726, 0, 34));
211  // fMissingEvents.insert(fnex::EventId(23036, 25, 968, 0, 27));
212  // fMissingEvents.insert(fnex::EventId(23087, 10, 109, 0, 27));
213  // fMissingEvents.insert(fnex::EventId(23120, 22, 16, 0, 31));
214  // fMissingEvents.insert(fnex::EventId(23194, 40, 319, 0, 32));
215  // fMissingEvents.insert(fnex::EventId(23325, 22, 479, 0, 40));
216  // fMissingEvents.insert(fnex::EventId(23364, 26, 871, 0, 34));
217  // fMissingEvents.insert(fnex::EventId(24624, 19, 553, 0, 34));
218  // fMissingEvents.insert(fnex::EventId(24644, 39, 954, 0, 32));
219  // fMissingEvents.insert(fnex::EventId(24687, 10, 92, 0, 31));
220  // fMissingEvents.insert(fnex::EventId(24800, 27, 968, 0, 39));
221  // fMissingEvents.insert(fnex::EventId(24843, 63, 929, 0, 46));
222  // fMissingEvents.insert(fnex::EventId(25084, 47, 58, 0, 34));
223  // fMissingEvents.insert(fnex::EventId(25157, 10, 697, 0, 41));
224  // fMissingEvents.insert(fnex::EventId(25252, 60, 501, 0, 22));
225  // fMissingEvents.insert(fnex::EventId(25254, 61, 805, 0, 38));
226  // fMissingEvents.insert(fnex::EventId(25294, 27, 233, 0, 38));
227  // fMissingEvents.insert(fnex::EventId(25344, 8, 701, 0, 28));
228  // fMissingEvents.insert(fnex::EventId(25351, 55, 456, 0, 42));
229 
230  // fMissingEvents.insert(fnex::EventId(19195, 10, 73, 0, 37));
231  // fMissingEvents.insert(fnex::EventId(19546, 12, 222, 0, 30));
232  // fMissingEvents.insert(fnex::EventId(19580, 19, 584, 0, 36));
233  // fMissingEvents.insert(fnex::EventId(19662, 58, 54, 0, 27));
234  // fMissingEvents.insert(fnex::EventId(21650, 54, 267, 0, 28));
235  // fMissingEvents.insert(fnex::EventId(22797, 43, 678, 0, 22));
236  // fMissingEvents.insert(fnex::EventId(23330, 24, 252, 0, 33));
237 
238  }
unsigned int fNumQuantiles
number of quantiles
void reconfigure(fhicl::ParameterSet const &p)
novadaq::cnv::DetId fDetector
which detector are we using
Near Detector in the NuMI cavern.
bool fMakeSelectedList
configure to true to make a list
bool fIsFHC
are we looking at FHC files?
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::map< int, POTLiveTime > fPeriodToPOTLiveTime
keep track of the POT in each period
bool fIsRealData
are we looking at real data?
fnex::FileType_t fFileType
get from the configuration for now
fnex::CAFToEventList::~CAFToEventList ( )
virtual

Definition at line 241 of file CAFToEventList_module.cc.

References clear().

242  {
243  this->clear();
244  }
fnex::CAFToEventList::CAFToEventList ( CAFToEventList const &  )
delete
fnex::CAFToEventList::CAFToEventList ( CAFToEventList &&  )
delete

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 467 of file CAFToEventList_module.cc.

468  {
469  }
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::CAFToEventList::clear ( )
private

Definition at line 249 of file CAFToEventList_module.cc.

References fMDToEvents, fNumuFHCQuantCuts, fNumuRHCQuantCuts, and fSelections.

Referenced by CAFToEventList(), and ~CAFToEventList().

250  {
251  fMDToEvents .clear();
252  fNumuFHCQuantCuts.clear();
253  fNumuRHCQuantCuts.clear();
254  fSelections .clear();
255  }
std::vector< ana::Cut > fNumuRHCQuantCuts
quantile boundaries for the numu RHC data
std::vector< ana::Cut > fNumuFHCQuantCuts
quantile boundaries for the numu FHC data
fnex::EventListMap fMDToEvents
each entry in the vector is for a single slice
std::set< fnex::SelectionType_t > fSelections
Selections to use.
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::CAFToEventList::DefineNumuQuantiles ( )
private

Definition at line 311 of file CAFToEventList_module.cc.

References fFHCQuantFileName, cet::search_path::find_file(), fNumQuantiles, fNumuFHCQuantCuts, fNumuRHCQuantCuts, fRHCQuantFileName, ana::kHadEFracAxis, ana::kNumuCCOptimisedAxis, ana::QuantileCutsFromTH2(), and string.

Referenced by reconfigure().

312  {
313  // set up the numu quantile cuts
314 
315  std::string filePath;
316 
317  cet::search_path sp("FW_SEARCH_PATH");
318  if( !sp.find_file(fFHCQuantFileName, filePath) )
319  throw cet::exception("CAFToEventList")
320  << "Cannot find FHC numu quantile file "
322 
323  TFile fhcTF(filePath.c_str(), "READ");
324  TH2F *FDSpec2D = dynamic_cast<TH2F*>(fhcTF.Get("FDSpec2D"));
325  if(FDSpec2D == nullptr)
326  throw cet::exception("CAFToEventList")
327  << "Cannot find histogram FDSpec2D in "
328  << filePath;
329 
331 
332  if( !sp.find_file(fRHCQuantFileName, filePath) )
333  throw cet::exception("EventListMaker")
334  << "Cannot find RHC numu quantile file "
336 
337  TFile rhcTF(filePath.c_str(), "READ");
338  FDSpec2D = dynamic_cast<TH2F*>(rhcTF.Get("FDSpec2D"));
339  if(FDSpec2D == nullptr)
340  throw cet::exception("CAFToEventList")
341  << "Cannot find histogram FDSpec2D in "
342  << filePath;
343 
345  }
unsigned int fNumQuantiles
number of quantiles
std::string fFHCQuantFileName
name of file in numudata ups product with FHC quantiles
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
std::vector< ana::Cut > fNumuRHCQuantCuts
quantile boundaries for the numu RHC data
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::string fRHCQuantFileName
name of file in numudata ups product with FHC quantiles
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
std::vector< ana::Cut > fNumuFHCQuantCuts
quantile boundaries for the numu FHC data
enum BeamMode string
void fnex::CAFToEventList::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1042 of file CAFToEventList_module.cc.

References fnex::cSelectionType_Strings, fnex::DEFINE_ART_MODULE(), fDetector, fFileType, FillVariables(), fIsRealData, fMakeSelectedList, fMDToEvents, fPeriodToPOTLiveTime, MECModelEnuComparisons::i, InitializeEventListMaps(), InsertPeriod6Cosmics(), fnex::MetaData::isMC, it, fnex::kCosmicBackgroundFile, fnex::kCosmicMuon, simb::kNC, fnex::kNC, fnex::kNuEBarCC, fnex::kNuECC, fnex::kNuMuBarCC, fnex::kNuMuCC, fnex::kNuTauBarCC, fnex::kNuTauCC, fnex::kRPACCQE_Weight, fnex::kTrueCCNC, fnex::kTrueE, fnex::kTrueIntType, fnex::kTruePDG, fnex::kTruePDGOrig, fnex::kUnknownInteraction, fnex::kXSecCVPPFX_Weight, fnex::SpillSummary::liveTime, LOG_DEBUG, LOG_VERBATIM, LOG_WARNING, fetch_tb_beamline_files::md, make_root_from_grid_output::pdg, RunToEpoch(), ana::sels, fnex::SerializeEventListMap(), ss, and fnex::MetaData::ToString().

1043  {
1044  this->InitializeEventListMaps();
1045 
1048  float pdg = 0;
1049 
1050  std::vector<fnex::DataVarVals > dataVals;
1051  std::vector<fnex::MCVarVals > mcVals;
1052  std::vector<fnex::EventId > evIds;
1053  std::vector<fnex::SelectionType_t> sels;
1054 
1055  this->FillVariables(dataVals, mcVals, evIds, sels);
1056 
1057  LOG_VERBATIM("CAFToEventList")
1058  << "there are "
1059  << dataVals.size()
1060  << " data vals "
1061  << mcVals.size()
1062  << " mc vals "
1063  << evIds.size()
1064  << " event ids "
1065  << sels.size()
1066  << " selections ";
1067 
1068  auto periodToPOTItr = fPeriodToPOTLiveTime.begin();
1069 
1070  // loop over the event lists and add SpillSummary info
1071  for(auto & itr : fMDToEvents){
1072 
1074 
1075  periodToPOTItr = fPeriodToPOTLiveTime.find(itr.first.Period());
1076 
1077  // multiply the weight for this period by the total POT
1078  // indicated in the list of CAF files used. We only
1079  // look at either FHC or RHC SAM datalists separately,
1080  // so we don't have to worry about separate accounting
1081  // for those
1082  if(periodToPOTItr != fPeriodToPOTLiveTime.end()){
1083  ss += fnex::SpillSummary(periodToPOTItr->second.pot,
1084  periodToPOTItr->second.pot,
1085  periodToPOTItr->second.liveTime,
1086  1,
1087  1);
1088 
1089  LOG_DEBUG("CAFTToEventList")
1090  << " checking spill summary to add "
1091  << ss
1092  << " "
1093  << periodToPOTItr->second.pot
1094  << " "
1095  << periodToPOTItr->second.liveTime;
1096  }
1097  else{
1098  LOG_WARNING("CAFToEventList")
1099  << itr.first.ToString()
1100  << " could not find period "
1101  << itr.first.Period()
1102  << " in POT weight map, just add zeros";
1103  }
1104 
1105  itr.second.AddSpillSummary(ss);
1106 
1107  LOG_DEBUG("CAFToEventList")
1108  << "adding "
1109  << ss
1110  << " to "
1111  << itr.first.ToString()
1112  << " "
1113  << itr.second.ListSpillSummary();
1114 
1115  } // end loop over the metadata to event lists map
1116 
1117  // now make event lists
1118  for(size_t i = 0; i < dataVals.size(); ++i){
1119 
1120  fnex::EventPtr ev = std::make_unique<fnex::Event>();
1121 
1123 
1124  // figure out the interaction type and then get the correct metadata
1125  // for it
1127  it = fnex::kCosmicMuon;
1128  }
1129  else if(!fIsRealData){
1130  if( mcVals[i].val_at(fnex::kTrueCCNC) == 1.*simb::kNC )
1131  it = fnex::kNC;
1132  else{
1133  pdg = mcVals[i].val_at(fnex::kTruePDG);
1134  if (pdg == 12) it = fnex::kNuECC;
1135  else if(pdg == -12) it = fnex::kNuEBarCC;
1136  else if(pdg == 14) it = fnex::kNuMuCC;
1137  else if(pdg == -14) it = fnex::kNuMuBarCC;
1138  else if(pdg == 16) it = fnex::kNuTauCC;
1139  else if(pdg == -16) it = fnex::kNuTauBarCC;
1140  }
1141  } // end if neutrino MC
1142 
1144  fDetector,
1145  fFileType,
1146  sels[i],
1147  it,
1148  this->RunToEpoch(evIds[i].run));
1149 
1150  ev->eventId = std::make_unique<fnex::EventId >(evIds[i]);
1151  ev->dataVals = std::make_unique<fnex::DataVarVals>(dataVals[i]);
1152 
1154  ev->mcVals = std::make_unique<fnex::MCVarVals>(mcVals[i]);
1155  ev->mcVals->set_val_at(fnex::kTrueE, 0. );
1156  ev->mcVals->set_val_at(fnex::kTruePDG, 13 );
1157  ev->mcVals->set_val_at(fnex::kTruePDGOrig, 13 );
1158  ev->mcVals->set_val_at(fnex::kTrueCCNC, 0. );
1159  ev->mcVals->set_val_at(fnex::kTrueIntType, fnex::kCosmicMuon);
1160  ev->mcVals->set_val_at(fnex::kXSecCVPPFX_Weight, 1. );
1161  ev->mcVals->set_val_at(fnex::kRPACCQE_Weight, 1. );
1162 
1163  } // end if cosmic backgrounds
1164  else if(md.isMC)
1165  ev->mcVals = std::make_unique<fnex::MCVarVals>(mcVals[i]);
1166  else
1167  ev->mcVals.reset(nullptr);
1168 
1169  LOG_DEBUG("CAFToEventList")
1170  << "add the event to "
1171  << md.ToString()
1172  << " "
1173  << fMDToEvents.count(md);
1174 
1175  fMDToEvents.find(md)->second.AddEvent(ev);
1176 
1177  LOG_DEBUG("CAFToEventList")
1178  << i
1179  << " metadata is "
1180  << md.ToString()
1181  << " "
1182  << fMDToEvents.count(md);
1183 
1184  // Handle the nue ND peripheral sample. In the ND as of the 2017 analysis
1185  // the peripheral sample is just the high CVN set so we just copy that
1186  // and write it into a tree
1187  /*
1188  if(md.selectionType == fnex::kNuESelectionHighPID &&
1189  md.detector == novadaq::cnv::kNEARDET){
1190 
1191  // set the selection type to be the peripheral
1192  md.selectionType = fnex::kNuESelectionPeripheral;
1193 
1194  // add the event to the peripheral sample.
1195  fMDToEvents.find(md)->second.AddEvent(ev);
1196  } // end if nue high PID and ND
1197  */
1198 
1199  } // end loop to insert events
1200 
1201  // TODO: remove this hack when not doing the 2018 analysis
1203 
1204  for(auto const & itr : fMDToEvents){
1205 
1206  LOG_VERBATIM("CAFToEventList")
1207  << "metadata "
1208  << itr.first.ToString()
1209  << " has "
1210  << itr.second.ListSpillSummary()
1211  << " and "
1212  << itr.second.size()
1213  << " events";
1214 
1215  if(fMakeSelectedList){
1216  for(auto const& ev : itr.second)
1217  LOG_VERBATIM("SelectedEvents")
1218  << fnex::cSelectionType_Strings[itr.first.selectionType]
1219  << "\t\t"
1220  << ev->eventId->run
1221  << "\t"
1222  << ev->eventId->subrun
1223  << "\t"
1224  << ev->eventId->event
1225  << "\t"
1226  << ev->eventId->slice
1227  << "\t"
1228  << ev->eventId->cycle;
1229  } // end if we are making a list of selected events
1230  }
1231 
1232  LOG_DEBUG("CAFToEventList")
1233  << "Serialize the events";
1234 
1236  fMDToEvents);
1237 
1238  LOG_DEBUG("CAFToEventList")
1239  << "endJob() done";
1240 
1241  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
set< int >::iterator it
void SerializeEventListMap(std::string const &dirName, fnex::EventListMap const &listMap)
Definition: Event.cxx:176
Float_t ss
Definition: plot.C:24
enum fnex::interaction_type InteractionType_t
static const unsigned char kXSecCVPPFX_Weight
Definition: VarVals.h:56
novadaq::cnv::DetId fDetector
which detector are we using
static const unsigned char kTruePDGOrig
Definition: VarVals.h:46
static const unsigned char kTrueCCNC
Definition: VarVals.h:44
std::string const ToString() const
Definition: Structs.cxx:114
void FillVariables(std::vector< fnex::DataVarVals > &dataVals, std::vector< fnex::MCVarVals > &mcVals, std::vector< fnex::EventId > &evIds, std::vector< fnex::SelectionType_t > &sels)
const Cut sels[kNumSels]
Definition: vars.h:44
bool fMakeSelectedList
configure to true to make a list
static const unsigned char kTrueIntType
Definition: VarVals.h:45
std::map< int, POTLiveTime > fPeriodToPOTLiveTime
keep track of the POT in each period
Definition: run.py:1
#define LOG_WARNING(category)
static const unsigned char kRPACCQE_Weight
Definition: VarVals.h:57
std::shared_ptr< Event > EventPtr
Definition: Event.h:50
static const unsigned char kTrueE
Definition: VarVals.h:42
bool fIsRealData
are we looking at real data?
#define LOG_VERBATIM(category)
const std::string cSelectionType_Strings[11]
Definition: Constants.h:101
fnex::EventListMap fMDToEvents
each entry in the vector is for a single slice
std::string RunToEpoch(int run)
fnex::FileType_t fFileType
get from the configuration for now
static const unsigned char kTruePDG
Definition: VarVals.h:43
void fnex::CAFToEventList::FillDataVarVals ( fnex::DataVarVals dataVals,
caf::SRProxy const &  srProxy 
) const
private

Definition at line 767 of file CAFToEventList_module.cc.

References ana::kCCE, ana::kCVNSSe, fnex::kHad_RecoE, ana::kHadE, fnex::kLep_RecoE, fnex::kLep_RecoE_MCFrac, ana::kNMichels, fnex::kNuE_CVN, fnex::kNuE_NumMichel, ana::kRecoEME, ana::kRecoHADE, fnex::kRecoQ2, ana::kRecoQ2, PassesNueSelections(), PassesNumuSelections(), and fnex::DataVarVals::set_val_at().

Referenced by FillVariables().

769  {
770 
771  if(this->PassesNueSelections(srProxy)){
772  dataVals.set_val_at(fnex::kLep_RecoE, (float)ana::kRecoEME (&srProxy));
773  dataVals.set_val_at(fnex::kHad_RecoE, (float)ana::kRecoHADE(&srProxy));
774  dataVals.set_val_at(fnex::kNuE_CVN, (float)ana::kCVNSSe (&srProxy));
775  dataVals.set_val_at(fnex::kNuE_NumMichel, (float)ana::kNMichels(&srProxy));
776  }
777  else if(this->PassesNumuSelections(srProxy)){
778  dataVals.set_val_at(fnex::kLep_RecoE, (float)(ana::kCCE(&srProxy) - ana::kHadE(&srProxy)));
779  dataVals.set_val_at(fnex::kHad_RecoE, (float)ana::kHadE(&srProxy) );
780  dataVals.set_val_at(fnex::kLep_RecoE_MCFrac, 1. );
781  dataVals.set_val_at(fnex::kRecoQ2, (float)ana::kRecoQ2(&srProxy));
782  }
783 
784  }
const Var kHadE
Definition: NumuVars.h:23
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
const ana::Var kRecoQ2([](const caf::SRProxy *sr){const double M_mu_sqrd=util::sqr(0.1056);double E_mu=kMuE(sr);double p_mu=sqrt(util::sqr(E_mu)-M_mu_sqrd);return 2 *kCCE(sr)*(E_mu-p_mu *kCosNumi(sr))-M_mu_sqrd;})
Reconstructed four-momentum transfer invariant (Q^2)
Definition: NumuVars.h:146
static const unsigned char kRecoQ2
Definition: VarVals.h:38
static const unsigned char kLep_RecoE_MCFrac
Definition: VarVals.h:37
const Var kCCE
Definition: NumuVars.h:21
static const unsigned char kNuE_NumMichel
Definition: VarVals.h:33
const Var kRecoEME([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;double CVNem_CalE=0.0;const caf::SRFuzzyKProngProxy &prim_png=sr->vtx.elastic.fuzzyk.png[0];for(const caf::SRFuzzyKProngProxy &png:sr->vtx.elastic.fuzzyk.png){double png_CalE=png.shwlid.calE;double emPID=((double) png.cvnpart.photonid+ (double) png.cvnpart.pizeroid+ (double) png.cvnpart.electronid);double haPID=((double) png.cvnpart.protonid+ (double) png.cvnpart.pionid+ (double) png.cvnpart.neutronid+ (double) png.cvnpart.otherid+ (double) png.cvnpart.muonid);if(emPID< 0) continue;if(emPID >=haPID ) CVNem_CalE+=png_CalE;else continue;}if(CVNem_CalE==0.0) CVNem_CalE=prim_png.shwlid.calE;return CVNem_CalE *CalibrationBugCorrectionFactor(sr->hdr);})
Definition: NueEnergy2018.h:17
const Var kCVNSSe([](const caf::SRProxy *sr){throw std::runtime_error("kCVNSSe is no longer available. Fix your macro so you don't use it.");return-5.;})
2018 nue PID
Definition: Vars.h:52
bool PassesNumuSelections(caf::SRProxy const &proxy) const
const Var kNMichels([](const caf::SRProxy *sr){int n_me=0;for(int i=0;i< (int) sr->me.nslc;i++) if(sr->me.slc[i].mid > 1. &&sr->me.slc[i].deltat > 1200.) n_me++;for(int i=0;i< (int) sr->me.nkalman;i++) if(sr->me.trkkalman[i].mid > 0. &&sr->me.trkkalman[i].deltat > 800.) n_me++;if(n_me > 2) n_me=2;return n_me;})
Number of SlcME&#39;s assoc with slice.
Definition: Vars.h:85
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
bool PassesNueSelections(caf::SRProxy const &proxy) const
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
const Var kRecoHADE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;const double CVNha_CalE=sr->slc.calE *CalibrationBugCorrectionFactor(sr->hdr);return std::max(CVNha_CalE-kRecoEME(sr), 0.);})
Definition: NueEnergy2018.h:18
void fnex::CAFToEventList::FillEventId ( fnex::EventId evId,
caf::SRProxy const &  srProxy 
) const
private

Definition at line 787 of file CAFToEventList_module.cc.

References caf::Proxy< caf::SRHeader >::cycle, fnex::EventId::cycle, fnex::EventId::event, caf::Proxy< caf::SRHeader >::evt, caf::Proxy< caf::StandardRecord >::hdr, caf::Proxy< caf::SRHeader >::run, fnex::EventId::run, fnex::EventId::slice, caf::Proxy< caf::SRHeader >::subevt, caf::Proxy< caf::SRHeader >::subrun, and fnex::EventId::subrun.

Referenced by FillVariables().

789  {
790  evId.run = srProxy.hdr.run;
791  evId.subrun = srProxy.hdr.subrun;
792  evId.event = srProxy.hdr.evt;
793  evId.slice = srProxy.hdr.subevt;
794  evId.cycle = srProxy.hdr.cycle;
795 
796  }
void fnex::CAFToEventList::FillMCVarVals ( fnex::MCVarVals mcVarVals,
caf::SRProxy srProxy 
) const
private

Definition at line 605 of file CAFToEventList_module.cc.

References simb::kCC, fnex::kEmpiricalMEC_Weight, fnex::kEmpiricalMECtoGENIEQE_Weight, ana::kEmpiricalMECtoGENIEQEWgt, fnex::kEmpiricalMECtoGENIERES_Weight, ana::kEmpiricalMECtoGENIERESWgt, ana::kEmpiricalMECWgt2018, ana::kHitNuc, ana::kMode, simb::kNC, ana::kPPFXFluxCVWgt, fnex::kRPACCQE_Weight, ana::kRPACCQEEnhSyst2018, fnex::kRPACCQEshapeEnh, fnex::kRPACCQEshapeSupp, ana::kRPACCQESuppSyst2018, fnex::kRPARES_Weight, ana::kRPAWeightCCQE2018, ana::kRPAWeightRES2017, fnex::kTrueCCNC, ana::kTrueE, fnex::kTrueE, fnex::kTrueHitNuc, fnex::kTrueIntMode, fnex::kTrueIntType, fnex::kTrueParentDecay, fnex::kTrueParentPDG, fnex::kTrueParentPT, fnex::kTrueParentPZ, fnex::kTrueParentTargetPDG, fnex::kTruePDG, ana::kTruePDG, fnex::kTruePDGOrig, ana::kTruetpT, ana::kTruetpz, fnex::kXSecCVPPFX_Weight, ana::kXSecCVWgt2018, caf::Proxy< caf::StandardRecord >::mc, min(), caf::Proxy< caf::SRTruthBranch >::nu, fnex::MCVarVals::set_GENIEWgt(), fnex::MCVarVals::set_val_at(), ana::ISyst::Shift(), and string.

Referenced by FillVariables().

607  {
608 
609  mcVarVals.set_val_at (fnex::kTrueE, (float)ana::kTrueE(&srProxy) );
610  mcVarVals.set_val_at (fnex::kTruePDG, (float)ana::kTruePDG(&srProxy) );
611  mcVarVals.set_val_at (fnex::kTrueCCNC, (srProxy.mc.nu[0].iscc) ? simb::kCC : simb::kNC);
612  mcVarVals.set_val_at (fnex::kTrueIntType, srProxy.mc.nu[0].inttype);
613  mcVarVals.set_val_at (fnex::kTrueIntMode, (float)ana::kMode(&srProxy) );
614  mcVarVals.set_val_at (fnex::kTrueHitNuc, (float)ana::kHitNuc(&srProxy) );
615  mcVarVals.set_val_at (fnex::kTruePDGOrig, srProxy.mc.nu[0].pdgorig );
616  mcVarVals.set_val_at (fnex::kTrueParentPDG, srProxy.mc.nu[0].beam.ptype );
617  mcVarVals.set_val_at (fnex::kTrueParentDecay, srProxy.mc.nu[0].beam.ndecay );
618  mcVarVals.set_val_at (fnex::kTrueParentTargetPDG, srProxy.mc.nu[0].beam.tptype );
619  mcVarVals.set_val_at (fnex::kTrueParentPZ, (float)ana::kTruetpz(&srProxy) );
620  mcVarVals.set_val_at (fnex::kTrueParentPT, (float)ana::kTruetpT(&srProxy));
621  mcVarVals.set_val_at (fnex::kXSecCVPPFX_Weight, (float)(ana::kXSecCVWgt2018(&srProxy) * ana::kPPFXFluxCVWgt(&srProxy)));
622 
623  mcVarVals.set_val_at (fnex::kRPACCQE_Weight, (float)ana::kRPAWeightCCQE2018(&srProxy));
624  mcVarVals.set_val_at (fnex::kRPARES_Weight, (float)ana::kRPAWeightRES2017(&srProxy));
625  mcVarVals.set_val_at (fnex::kEmpiricalMEC_Weight, (float)ana::kEmpiricalMECWgt2018(&srProxy) );
628 
629  double wgtPlus = 1.;
630  double wgtMinus = 1.;
631  ana::kRPACCQEEnhSyst2018.Shift( 1., &srProxy, wgtPlus);
632  ana::kRPACCQEEnhSyst2018.Shift(-1., &srProxy, wgtMinus);
633  mcVarVals.set_GENIEWgt(fnex::kRPACCQEshapeEnh, "-1sigma", (float)wgtMinus);
634  mcVarVals.set_GENIEWgt(fnex::kRPACCQEshapeEnh, "+1sigma", (float)wgtPlus);
635 
636  ana::kRPACCQESuppSyst2018.Shift( 1., &srProxy, wgtPlus);
637  ana::kRPACCQESuppSyst2018.Shift(-1., &srProxy, wgtMinus);
638  mcVarVals.set_GENIEWgt(fnex::kRPACCQEshapeSupp, "-1sigma", (float)wgtMinus);
639  mcVarVals.set_GENIEWgt(fnex::kRPACCQEshapeSupp, "+1sigma", (float)wgtPlus);
640 
645 
646 
647  // Now for the full set of possible GENIE knobs
648 
649  static std::map<rwgt::EReweightLabel, std::string> labelMap
650  {
651  // NC elastic parameters
652  {rwgt::fReweightMaNCEL, "MaNCEL"},
653  {rwgt::fReweightEtaNCEL, "EtaNCEL"},
654 
655  // CCQE parameters
656  {rwgt::fReweightNormCCQE, "NormCCQE"},
657  {rwgt::fReweightNormCCQEenu, "NormCCQE_EnuDep"},
658  {rwgt::fReweightMaCCQEshape, "MaCCQE_shape"},
659  {rwgt::fReweightMaCCQE, "MaCCQE"},
660  {rwgt::fReweightVecCCQEshape, "VecCCQE_shape"},
661 
662  // Resonant production: CC
663  {rwgt::fReweightNormCCRES, "NormCCRES"},
664  {rwgt::fReweightMaCCRESshape, "MaCCRES_shape"},
665  {rwgt::fReweightMvCCRESshape, "MvCCRES_shape"},
666  {rwgt::fReweightMaCCRES, "MaCCRES"},
667  {rwgt::fReweightMvCCRES, "MvCCRES"},
668 
669  // Resonant production: NC
670  {rwgt::fReweightNormNCRES, "NormNCRES"},
671  {rwgt::fReweightMaNCRESshape, "MaNCRES_shape"},
672  {rwgt::fReweightMvNCRESshape, "MvNCRES_shape"},
673  {rwgt::fReweightMaNCRES, "MaNCRES"},
674  {rwgt::fReweightMvNCRES, "MvNCRES"},
675 
676  // Coherent pion production
677  {rwgt::fReweightMaCOHpi, "MaCOHpi"},
678  {rwgt::fReweightR0COHpi, "R0COHpi"},
679 
680  // Non-resonant background
681  {rwgt::fReweightRvpCC1pi, "RvpCC1pi"},
682  {rwgt::fReweightRvpCC2pi, "RvpCC2pi"},
683  {rwgt::fReweightRvpNC1pi, "RvpNC1pi"},
684  {rwgt::fReweightRvpNC2pi, "RvpNC2pi"},
685  {rwgt::fReweightRvnCC1pi, "RvnCC1pi"},
686  {rwgt::fReweightRvnCC2pi, "RvnCC2pi"},
687  {rwgt::fReweightRvnNC1pi, "RvnNC1pi"},
688  {rwgt::fReweightRvnNC2pi, "RvnNC2pi"},
689  {rwgt::fReweightRvbarpCC1pi, "RvbarpCC1pi"},
690  {rwgt::fReweightRvbarpCC2pi, "RvbarpCC2pi"},
691  {rwgt::fReweightRvbarpNC1pi, "RvbarpNC1pi"},
692  {rwgt::fReweightRvbarpNC2pi, "RvbarpNC2pi"},
693  {rwgt::fReweightRvbarnCC1pi, "RvbarnCC1pi"},
694  {rwgt::fReweightRvbarnCC2pi, "RvbarnCC2pi"},
695  {rwgt::fReweightRvbarnNC1pi, "RvbarnNC1pi"},
696  {rwgt::fReweightRvbarnNC2pi, "RvbarnNC2pi"},
697 
698  // DIS tweaking parameters
699  {rwgt::fReweightAhtBY, "AhtBY"},
700  {rwgt::fReweightBhtBY, "BhtBY"},
701  {rwgt::fReweightCV1uBY, "CV1uBY"},
702  {rwgt::fReweightCV2uBY, "CV2uBY"},
703  {rwgt::fReweightAhtBYshape, "AhtBYshape"},
704  {rwgt::fReweightBhtBYshape, "BhtBYshape"},
705  {rwgt::fReweightCV1uBYshape, "CV1uBYshape"},
706  {rwgt::fReweightCV2uBYshape, "CV2uBYshape"},
707  {rwgt::fReweightNormDISCC, "NormDISCC"},
708  {rwgt::fReweightRnubarnuCC, "RnubarnuCC"},
709  {rwgt::fReweightDISNuclMod, "DISNuclMod"},
710 
711  {rwgt::fReweightNC, "NC"},
712 
713  // Hadronization (free nucleon target)
714  {rwgt::fReweightAGKY_xF1pi, "AGKY_xF1pi"},
715  {rwgt::fReweightAGKY_pT1pi, "AGKY_pT1pi"},
716 
717  // Medium-effects to hadronization
718  {rwgt::fReweightFormZone, "FormZone"},
719 
720  // Intranuclear rescattering parameters.
721  {rwgt::fReweightMFP_pi, "MFP_pi"},
722  {rwgt::fReweightMFP_N, "MFP_N"},
723  {rwgt::fReweightFrCEx_pi, "FrCEx_pi"},
724  {rwgt::fReweightFrInel_pi, "FrInel_pi"},
725  {rwgt::fReweightFrAbs_pi, "FrAbs_pi"},
726  {rwgt::fReweightFrPiProd_pi, "FrPiProd_pi"},
727  {rwgt::fReweightFrCEx_N, "FrCEx_N"},
728  // the next two appear no longer to be in use with GENIE v3
729  //{rwgt::fReweightFrElas_pi, "FrElas_pi"},
730  //{rwgt::fReweightFrElas_N, "FrElas_N"},
731  {rwgt::fReweightFrInel_N, "FrInel_N"},
732  {rwgt::fReweightFrAbs_N, "FrAbs_N"},
733  {rwgt::fReweightFrPiProd_N, "FrPiProd_N"},
734 
735  // Nuclear model
736  {rwgt::fReweightCCQEPauliSupViaKF, "CCQEPauliSupViaKF"},
737  {rwgt::fReweightCCQEMomDistroFGtoSF, "CCQEMomDistroFGtoSF"},
738 
739  // Resonance decays
740  {rwgt::fReweightBR1gamma, "BR1gamma"},
741  {rwgt::fReweightBR1eta, "BR1eta"},
742  {rwgt::fReweightTheta_Delta2Npi, "Theta_Delta2Npi"}
743  };
744 
745  std::string rwgtLabel;
746  for (auto const& rwgtPair : labelMap){
747 
748  auto wgtFunc = ana::GetGenieRwgtSyst(rwgtPair.first);
749  rwgtLabel = rwgtPair.second;
750 
751  wgtFunc->Shift(-2., &srProxy, wgtMinus);
752  mcVarVals.set_GENIEWgt(rwgtLabel, "-2sigma", (float)wgtMinus);
753 
754  wgtFunc->Shift(-1., &srProxy, wgtMinus);
755  mcVarVals.set_GENIEWgt(rwgtLabel, "-1sigma", (float)wgtMinus);
756 
757  wgtFunc->Shift( 1., &srProxy, wgtPlus);
758  mcVarVals.set_GENIEWgt(rwgtLabel, "+1sigma", (float)wgtPlus);
759 
760 
761  wgtFunc->Shift( 2., &srProxy, wgtPlus);
762  mcVarVals.set_GENIEWgt(rwgtLabel, "+2sigma", (float)wgtPlus);
763  } // end loop over genie reweight variables
764  }
const Var kTruePDG
Definition: TruthVars.h:48
const Var kMode([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?-1:int(sr->mc.nu[0].mode);})
Neutrino interaction mode.
Definition: Vars.h:99
const NOvARwgtSyst kRPACCQEEnhSyst2018("RPAShapeenh2018","RPA shape: higher-Q^{2} enhancement (2018)", novarwgt::kRPACCQEEnhSyst2018)
Definition: RPASysts.h:13
static const unsigned char kEmpiricalMEC_Weight
Definition: VarVals.h:60
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
static const unsigned char kTrueParentPT
Definition: VarVals.h:48
static const unsigned char kEmpiricalMECtoGENIERES_Weight
Definition: VarVals.h:62
void set_val_at(std::string const &varkey, float const &val)
Definition: VarVals.cxx:164
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
static const unsigned char kRPACCQEshapeSupp
Definition: VarVals.h:75
static const unsigned char kXSecCVPPFX_Weight
Definition: VarVals.h:56
const Var kRPAWeightRES2017
Definition: GenieWeights.h:115
static const unsigned char kTrueHitNuc
Definition: VarVals.h:52
virtual void Shift(double sigma, caf::SRProxy *sr, double &weight) const
Perform the systematic shift.
Definition: ISyst.cxx:26
static const unsigned char kTrueParentPDG
Definition: VarVals.h:47
const Var kEmpiricalMECWgt2018
See kEmpiricalMECWgt2018_NT.
Definition: GenieWeights.h:254
const Var kTruetpT([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:util::pythag(sr->mc.nu[0].beam.tp.X(), sr->mc.nu[0].beam.tp.Y());})
True neutrino ancestor (off-target) pT.
Definition: Vars.h:102
static const unsigned char kRPARES_Weight
Definition: VarVals.h:58
const Var kHitNuc
Definition: TruthVars.h:19
const Var kRPAWeightCCQE2018
Definition: GenieWeights.h:96
static const unsigned char kTruePDGOrig
Definition: VarVals.h:46
static const unsigned char kTrueCCNC
Definition: VarVals.h:44
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
const Var kTruetpz([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].beam.tp.z);})
True neutrino ancestor (off-target) pz.
Definition: Vars.h:105
const Var kEmpiricalMECtoGENIERESWgt
Definition: GenieWeights.h:184
const Var kEmpiricalMECtoGENIEQEWgt
Definition: GenieWeights.h:180
static const unsigned char kTrueIntType
Definition: VarVals.h:45
static const unsigned char kTrueParentDecay
Definition: VarVals.h:50
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
static const unsigned char kTrueParentTargetPDG
Definition: VarVals.h:51
void set_GENIEWgt(unsigned char const &varkey, std::string const &sigma, float const &wgt)
Definition: VarVals.cxx:282
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
static const unsigned char kEmpiricalMECtoGENIEQE_Weight
Definition: VarVals.h:61
static const unsigned char kRPACCQE_Weight
Definition: VarVals.h:57
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
static const unsigned char kTrueE
Definition: VarVals.h:42
const NOvARwgtSyst kRPACCQESuppSyst2018("RPAShapesupp2018","RPA shape: low-Q^{2} suppression (2018)", novarwgt::kRPACCQESuppSyst2018)
Definition: RPASysts.h:14
static const unsigned char kTrueIntMode
Definition: VarVals.h:53
static const unsigned char kRPACCQEshapeEnh
Definition: VarVals.h:74
static const unsigned char kTrueParentPZ
Definition: VarVals.h:49
static const unsigned char kTruePDG
Definition: VarVals.h:43
enum BeamMode string
void fnex::CAFToEventList::FillVariables ( std::vector< fnex::DataVarVals > &  dataVals,
std::vector< fnex::MCVarVals > &  mcVals,
std::vector< fnex::EventId > &  evIds,
std::vector< fnex::SelectionType_t > &  sels 
)
private

Definition at line 913 of file CAFToEventList_module.cc.

References fCAFFileNames, fCAFRecTreeName, plotROC::fileName, FillDataVarVals(), FillEventId(), FillMCVarVals(), FindPOTPerPeriod(), FindSelectionType(), caf::Proxy< caf::StandardRecord >::hdr, MECModelEnuComparisons::i, caf::Proxy< caf::SRHeader >::ismc, LOG_DEBUG, LOG_VERBATIM, caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRTruthBranch >::nu, PassesSelections(), and sr.

Referenced by endJob().

917  {
918  dataVals.clear();
919  mcVals .clear();
920  evIds .clear();
921 
922  for(auto const& fileName : fCAFFileNames){
923 
924  // open the CAF file and get the TTrees and histograms for reading
925  TFile *tf = TFile::Open(fileName.c_str());
926 
927  this->FindPOTPerPeriod(*tf);
928 
929  auto *cafTree = dynamic_cast<TTree*>(tf->Get(fCAFRecTreeName.c_str()));
930 
931  // hook the TTree up to a standard record and get the first entry to initialize things
932  caf::StandardRecord *sr = nullptr;
933 
934  cafTree->SetBranchAddress("rec", &sr);
935  cafTree->GetEntry(0);
936 
937  static caf::SRProxy srProxy(nullptr, "");
938 
939  LOG_DEBUG("CAFToEventList")
940  << "There are "
941  << cafTree->GetEntriesFast()
942  << " caf entries";
943 
944  // now loop over the CAF entries and fill the event list variables
945  //for(int i = 0; i < 10; ++i){
946  for(int i = 0; i < cafTree->GetEntriesFast(); ++i){
947 
948  cafTree->GetEntry(i);
949 
950  // get a proxy for each entry
951  srProxy = *sr;
952 
953 
954  // Uncomment the following block to debug cases where events
955  // show up in the official CAF selection but not this one, or
956  // vice versa
957  /*
958  fnex::EventId curEvent(srProxy.hdr.run,
959  srProxy.hdr.subrun,
960  srProxy.hdr.evt,
961  srProxy.hdr.cycle,
962  srProxy.hdr.subevt);
963 
964  if( fMissingEvents.find(curEvent) != fMissingEvents.end())
965  LOG_VERBATIM("MissingEventsCheck")
966  << curEvent
967  << " beam "
968  << ana::kInBeamSpill(&srProxy)
969  << " spill "
970  << ana::kStandardSpillCuts(&(srProxy.spill))
971  << " FD all "
972  << ana::kNue2018FDAllSamples(&srProxy);
973  */
974  if( !this->PassesSelections(srProxy) ) continue;
975 
976  fnex::MCVarVals mcVarVals;
977  fnex::DataVarVals dataVarVals;
978  fnex::EventId evId;
979 
980  // fill the event id information
981  this->FillEventId(evId, srProxy);
982 
983  // fill MC information if this is mc
984  if(srProxy.hdr.ismc){
985  if(srProxy.mc.nu.size() == 1) this->FillMCVarVals(mcVarVals, srProxy);
986  else{
987  LOG_VERBATIM("CAFToEventList")
988  << "There are "
989  << srProxy.mc.nu.size()
990  << " neutrinos in this event "
991  << evId;
992 
993  continue;
994  }
995  } // end if the event is MC
996 
997  // fill the data values
998  this->FillDataVarVals(dataVarVals, srProxy);
999 
1000  // add everything to the vectors
1001  dataVals.push_back(dataVarVals);
1002  mcVals .push_back(mcVarVals );
1003  evIds .push_back(evId );
1004  sels .push_back(this->FindSelectionType(srProxy));
1005 
1006  } // end loop over the CAF StandardRecords
1007 
1008  tf->Close();
1009  } // end loop over CAF file names
1010  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
fileName
Definition: plotROC.py:78
std::string fCAFRecTreeName
names of the CAF tree with the reco info
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:930
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
Timing fit.
void FindPOTPerPeriod(TFile &tf)
const Cut sels[kNumSels]
Definition: vars.h:44
fnex::SelectionType_t FindSelectionType(caf::SRProxy const &srProxy) const
caf::StandardRecord * sr
void FillDataVarVals(fnex::DataVarVals &dataVals, caf::SRProxy const &srProxy) const
void FillMCVarVals(fnex::MCVarVals &mcVarVals, caf::SRProxy &srProxy) const
The StandardRecord is the primary top-level object in the Common Analysis File trees.
std::vector< std::string > fCAFFileNames
name of the CAF file we are using
void FillEventId(fnex::EventId &evId, caf::SRProxy const &srProxy) const
#define LOG_VERBATIM(category)
bool PassesSelections(caf::SRProxy const &proxy) const
Base container for the MC related Vars that constitute an event.
Definition: VarVals.h:874
void fnex::CAFToEventList::FindPOTPerPeriod ( TFile &  tf)
private

Definition at line 820 of file CAFToEventList_module.cc.

References std::abs(), caf::SRSpill::evt, fFileType, fPeriodToPOTLiveTime, fPOTHistName, fSpillTreeName, MECModelEnuComparisons::i, std::isnan(), fnex::kCosmicBackgroundFile, ana::kStandardSpillCuts, caf::SRSpill::livetime, LOG_DEBUG, LOG_VERBATIM, DCS_db_parser::period, PeriodAdjustCosmics(), caf::SRSpill::run, RunToEpoch(), caf::SRSpill::spillpot, caf::Proxy< caf::SRSpill >::spillpot, and caf::SRSpill::subrun.

Referenced by FillVariables().

821  {
822  auto *spillTree = dynamic_cast<TTree*>(tf.Get(fSpillTreeName.c_str()));
823 
824  caf::SRSpill *sp = nullptr;
825 
826  spillTree->SetBranchAddress("spill", &sp);
827  spillTree->GetEntry(0);
828 
829  static caf::SRSpillProxy spProxy(nullptr, "");
830 
831  LOG_VERBATIM("CAFToEventList")
832  << "There are "
833  << spillTree->GetEntriesFast()
834  << " spills";
835 
836  int period;
837  float totalPOT = 0.;
838 
839  // loop over the spill tree to add up the POT for each period
840  //for(int i = 0; i < 10; ++i){
841  for(int i = 0; i < spillTree->GetEntriesFast(); ++i){
842 
843  spillTree->GetEntry(i);
844 
845  // get a proxy for each entry
846  spProxy = *sp;
847 
848  // ignore spills that don't pass the standard cuts
849  if(!ana::kStandardSpillCuts(&spProxy)) continue;
850 
851  // now figure out which period this spill belongs to
852  // periods always have a factor of 1000 applied to
853  // them in case we want epoch by epoch
854  period = 1000 * std::atoi((this->RunToEpoch(sp->run)).c_str());
855 
856  // TODO: remove this hack for post 2018 analyses
857  if(fFileType == fnex::kCosmicBackgroundFile) period = this->PeriodAdjustCosmics(period);
858 
859  if(std::isnan(sp->spillpot) ||
860  std::isnan(sp->livetime) ){
861  LOG_DEBUG("CAFToEventList")
862  << tf.GetName()
863  << " "
864  << sp->run
865  << " "
866  << sp->subrun
867  << " "
868  << sp->evt
869  << " spill has nan for pot or livetime "
870  << sp->spillpot
871  << " "
872  << sp->livetime
873  << " period "
874  << period;
875 
876  continue;
877  }
878 
879  // spillpot is in units of 10^20 POT
881  fPeriodToPOTLiveTime[period].liveTime += sp->livetime;
882 
883  totalPOT += spProxy.spillpot;
884 
885  } // end loop over the entries in the spill tree
886 
887  // if the spill tree and histogram totals are off by more than 1%, say something
888  if(std::abs(1. - totalPOT / dynamic_cast<TH1F* >(tf.Get(fPOTHistName.c_str()))->Integral()) > 0.01)
889  LOG_VERBATIM("CAFToEventList")
890  << "pot hist has "
891  << dynamic_cast<TH1F* >(tf.Get(fPOTHistName.c_str()))->Integral()
892  << " POT compared to "
893  << totalPOT
894  << " from the tree";
895 
896  // print out the number of pot for all files so far
897  for(auto const& itr : fPeriodToPOTLiveTime){
898  if(itr.second.pot > 0. ||
899  itr.second.liveTime > 0.)
900  LOG_VERBATIM("CAFToEventList")
901  << "period "
902  << itr.first
903  << " has "
904  << itr.second.pot * 1.e-20
905  << " x 10^20 POT and "
906  << itr.second.liveTime
907  << " s live time";
908  }
909 
910  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::string fSpillTreeName
names of the CAF histogram with the total POT
int PeriodAdjustCosmics(int const &inputPeriod)
unsigned int run
run number
Definition: SRSpill.h:25
Timing fit.
float abs(float number)
Definition: d0nt_math.hpp:39
int isnan(const stan::math::var &a)
Definition: std_isnan.hpp:18
unsigned int subrun
subrun number
Definition: SRSpill.h:26
std::string fPOTHistName
names of the CAF histogram with the total POT
unsigned int evt
ART event number, indexes trigger windows.
Definition: SRSpill.h:27
std::map< int, POTLiveTime > fPeriodToPOTLiveTime
keep track of the POT in each period
Proxy for caf::SRSpill.
Definition: SRProxy.h:1346
float livetime
Length of readout [s].
Definition: SRSpill.h:40
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
float spillpot
Definition: SRSpill.h:38
#define LOG_VERBATIM(category)
std::string RunToEpoch(int run)
fnex::FileType_t fFileType
get from the configuration for now
fnex::SelectionType_t fnex::CAFToEventList::FindSelectionType ( caf::SRProxy const &  srProxy) const
private

Definition at line 573 of file CAFToEventList_module.cc.

References fNumuFHCQuantCuts, fNumuRHCQuantCuts, caf::Proxy< caf::SRSpill >::isFHC, ana::kCVNSSe, ana::kNue2018CVNCut, ana::kNue2018CVNFHCHighEdge, ana::kNue2018CVNRHCHighEdge, ana::kNue2018FDPeripheral(), fnex::kNuESelectionHighPID, fnex::kNuESelectionLowPID, fnex::kNuESelectionPeripheral, fnex::kNuMuSelectionQ1, fnex::kNuMuSelectionQ2, fnex::kNuMuSelectionQ3, fnex::kNuMuSelectionQ4, fnex::kUnknownSelection, PassesNueSelections(), PassesNumuSelections(), and caf::Proxy< caf::StandardRecord >::spill.

Referenced by FillVariables().

574  {
575  if(this->PassesNumuSelections(srProxy)){
576  if(srProxy.spill.isFHC){
577  if(fNumuFHCQuantCuts[0](&srProxy)) return fnex::kNuMuSelectionQ1;
578  else if(fNumuFHCQuantCuts[1](&srProxy)) return fnex::kNuMuSelectionQ2;
579  else if(fNumuFHCQuantCuts[2](&srProxy)) return fnex::kNuMuSelectionQ3;
580  else if(fNumuFHCQuantCuts[3](&srProxy)) return fnex::kNuMuSelectionQ4;
581  } // end if fhc
582  else{
583  if(fNumuRHCQuantCuts[0](&srProxy)) return fnex::kNuMuSelectionQ1;
584  else if(fNumuRHCQuantCuts[1](&srProxy)) return fnex::kNuMuSelectionQ2;
585  else if(fNumuRHCQuantCuts[2](&srProxy)) return fnex::kNuMuSelectionQ3;
586  else if(fNumuRHCQuantCuts[3](&srProxy)) return fnex::kNuMuSelectionQ4;
587  }
588  } // end if numu
589  else if(this->PassesNueSelections(srProxy) && ana::kNue2018CVNCut(&srProxy)){
591  else if(ana::kCVNSSe(&srProxy) < ana::kNue2018CVNFHCHighEdge &&
592  srProxy.spill.isFHC) return fnex::kNuESelectionHighPID;
593  else if(ana::kCVNSSe(&srProxy) < ana::kNue2018CVNRHCHighEdge &&
594  !srProxy.spill.isFHC) return fnex::kNuESelectionHighPID;
595  else return fnex::kNuESelectionLowPID;
596 
597  }
598 
600  }
const double kNue2018CVNFHCHighEdge
Definition: NueCuts2018.h:41
std::vector< ana::Cut > fNumuRHCQuantCuts
quantile boundaries for the numu RHC data
const Cut kNue2018CVNCut([](const caf::SRProxy *sr){if(kIsRHC(sr)) return kNue2018RHCCVNCut(sr);else return kNue2018FHCCVNCut(sr);})
Definition: NueCuts2018.h:49
const Var kCVNSSe([](const caf::SRProxy *sr){throw std::runtime_error("kCVNSSe is no longer available. Fix your macro so you don't use it.");return-5.;})
2018 nue PID
Definition: Vars.h:52
bool PassesNumuSelections(caf::SRProxy const &proxy) const
const Cut kNue2018FDPeripheral(kNue2018FDPeripheralFunc)
const double kNue2018CVNRHCHighEdge
Definition: NueCuts2018.h:44
std::vector< ana::Cut > fNumuFHCQuantCuts
quantile boundaries for the numu FHC data
bool PassesNueSelections(caf::SRProxy const &proxy) const
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
void fnex::CAFToEventList::InitializeEventListMaps ( )
private

Definition at line 386 of file CAFToEventList_module.cc.

References e, fDetector, fFileType, fMDToEvents, fSelections, MECModelEnuComparisons::i, fnex::kCosmicBackgroundFile, fnex::kCosmicMuon, fnex::kDataFile, fnex::kNC, novadaq::cnv::kNEARDET, fnex::kNuEBarCC, fnex::kNuECC, fnex::kNuESelectionPeripheral, fnex::kNuMuBarCC, fnex::kNuMuCC, fnex::kNuTauBarCC, fnex::kNuTauCC, fnex::kUnknownInteraction, fetch_tb_beamline_files::md, and ss.

Referenced by endJob().

387  {
388  // here we will create an event list for each possible meta data
389  // for the current epoch and data/MC type.
390 
392 
393  std::set<fnex::InteractionType_t> intTypes({fnex::kNuMuCC,
395  fnex::kNuECC,
399  fnex::kNC});
400 
401  // TODO: make sure to update the epoch list - better yet would be to configure this somehow
402  std::set<std::string> epochs({"1", "2", "3", "4", "5", "6"});
403 
404  // set the bits of the metadata that won't change
405  bool isMC = (fFileType != fnex::kDataFile);
406 
407  for(auto const& e : epochs){
408 
409  // loop over the selection and interaction types to flesh out the lists
410  for(auto const& s : fSelections){
411 
412  // there are no nue peripheral events in the ND
414  s == fnex::kNuESelectionPeripheral) continue;
415 
416  if(fFileType == fnex::kDataFile){
417 
418  // data have an unknown interaction type
419  fnex::MetaData md(isMC,
420  fDetector,
421  fFileType,
422  s,
424  e);
425 
426  // make a new EventList for the data
427  fMDToEvents.emplace(md, fnex::EventList(md, ss));
428  } // end if data
430 
431  fnex::MetaData md(true,
432  fDetector,
433  fFileType,
434  s,
436  e);
437 
438  // make a new EventList for the cosmic background
439  fMDToEvents.emplace(md, fnex::EventList(md, ss));
440  } // end if cosmic background
441  else{
442  // loop over possible interaction types for the metadata
443  // don't use cosmic muons, those are special and are handled
444  // in another way - we don't want to inflate the POT for those lists
445  for(auto const& i : intTypes){
446 
447  fnex::MetaData md(isMC,
448  fDetector,
449  fFileType,
450  s,
451  i,
452  e);
453 
454  // make a new EventList for the MC
455  fMDToEvents.emplace(md, fnex::EventList(md, ss));
456  } // end loop over interaction types
457  } // end if not data or MC, ie cosmic background
458 
459  } // end loop over selection types
460  } // end loop over epochs
461 
462  }
Float_t ss
Definition: plot.C:24
novadaq::cnv::DetId fDetector
which detector are we using
const XML_Char * s
Definition: expat.h:262
Near Detector in the NuMI cavern.
fnex::EventListMap fMDToEvents
each entry in the vector is for a single slice
Float_t e
Definition: plot.C:35
std::set< fnex::SelectionType_t > fSelections
Selections to use.
fnex::FileType_t fFileType
get from the configuration for now
void fnex::CAFToEventList::InsertPeriod6Cosmics ( )
private

Definition at line 1015 of file CAFToEventList_module.cc.

References fnex::MetaData::epoch, fIsFHC, fMDToEvents, fnex::kCosmicBackgroundFile, and fetch_tb_beamline_files::md.

Referenced by endJob().

1016  {
1017  if(fIsFHC) return;
1018 
1019  // loop over the fMDToEvents map and for all period 4 cosmic metadata
1020  // add a corresponding period 6 cosmic metadata
1021  for(auto const& itr : fMDToEvents){
1022 
1023  if(itr.first.Period() == 4000 &&
1024  itr.first.fileType == fnex::kCosmicBackgroundFile){
1025 
1026  fnex::MetaData md = itr.first;
1027  md.epoch = 6000;
1028 
1029  fMDToEvents.find(md)->second.AddSpillSummary(itr.second.ListSpillSummary());
1030 
1031  // loop over the events in the list and add them to the new list
1032  for(auto const& ev : itr.second)
1033  fMDToEvents.find(md)->second.AddEvent(ev);
1034 
1035  }// end if we are hacking cosmic backgrounds for rhc
1036 
1037  } // end loop over metadata and event lists
1038 
1039  }
bool fIsFHC
are we looking at FHC files?
fnex::EventListMap fMDToEvents
each entry in the vector is for a single slice
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
CAFToEventList& fnex::CAFToEventList::operator= ( CAFToEventList const &  )
delete
CAFToEventList& fnex::CAFToEventList::operator= ( CAFToEventList &&  )
delete
bool fnex::CAFToEventList::PassesNueSelections ( caf::SRProxy const &  proxy) const
private

Definition at line 487 of file CAFToEventList_module.cc.

References fDetector, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, ana::kNue2018FDAllSamples, ana::kNue2018NDCVNSsb, ana::kNue2018NDEnergy, ana::kNue2018NDPresel, and LOG_DEBUG.

Referenced by FillDataVarVals(), FindSelectionType(), and PassesSelections().

488  {
490  if(!ana::kNue2018FDAllSamples(&proxy)){
491  LOG_DEBUG("CAFToEventList")
492  << "Fails nue FD All samples";
493 
494  return false;
495  }
496  }
497  else if(fDetector == novadaq::cnv::kNEARDET){
498  if(!ana::kNue2018NDEnergy(&proxy) ||
499  !ana::kNue2018NDPresel(&proxy) ||
500  !ana::kNue2018NDCVNSsb(&proxy) ){
501  LOG_DEBUG("CAFToEventList")
502  << "Fails nue ND energy, presel and CVNSsb "
503  << ana::kNue2018NDEnergy(&proxy)
504  << " "
505  << ana::kNue2018NDPresel(&proxy)
506  << " "
507  << ana::kNue2018NDCVNSsb(&proxy);
508  return false;
509  }
510  }
511 
512  return true;
513  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const Cut kNue2018NDCVNSsb
Definition: NueCuts2018.h:153
const Cut kNue2018NDEnergy
Definition: NueCuts2018.h:143
const Cut kNue2018NDPresel
Definition: NueCuts2018.h:145
novadaq::cnv::DetId fDetector
which detector are we using
Far Detector at Ash River, MN.
Near Detector in the NuMI cavern.
const Cut kNue2018FDAllSamples
Definition: NueCuts2018.h:77
bool fnex::CAFToEventList::PassesNumuSelections ( caf::SRProxy const &  proxy) const
private

Definition at line 516 of file CAFToEventList_module.cc.

References caf::Proxy< caf::SRCosRej >::anglekal, caf::Proxy< caf::SRIDBranch >::cosrej, fDetector, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, ana::kNumuContainFD2017, ana::kNumuContainND2017, ana::kNumuCosmicRej2018, ana::kNumuCutFD2018, ana::kNumuCutND2018, ana::kNumuOptimizedContainFD2017, ana::kNumuPID2018, ana::kNumuProngsContainFD2017, ana::kNumuQuality, LOG_DEBUG, caf::Proxy< caf::SRSlice >::nhit, caf::Proxy< caf::SRIDBranch >::nuecosrej, caf::Proxy< caf::SRRemid >::pid, caf::Proxy< caf::SRNueCosRej >::pngptp, caf::Proxy< caf::SRIDBranch >::remid, caf::Proxy< caf::StandardRecord >::sel, and caf::Proxy< caf::StandardRecord >::slc.

Referenced by FillDataVarVals(), FindSelectionType(), and PassesSelections().

517  {
518  // check that this event passes the quality cuts and PID selections
519  // for numu
521  if(!ana::kNumuCutFD2018(&proxy)){
522 
523 #ifdef PROD4
524 
525  LOG_DEBUG("CAFToEventList")
526  << "failed numu FD "
527  << ana::kNumuQuality(&proxy)
528  << " contain "
529  << ana::kNumuContainFD2017(&proxy)
530  << " "
532  << " "
534  << " PID 2018 "
535  << ana::kNumuPID2018(&proxy)
536  << " "
537  << proxy.sel.remid.pid
538  << " "
539  << proxy.sel.cvnProd3Train.numuid
540  << " "
541  << proxy.sel.cvn2017.numuid
542  << " cosRej: "
543  << ana::kNumuCosmicRej2018(&proxy)
544  << " "
545  << proxy.sel.cosrej.anglekal
546  << " "
547  << proxy.sel.cosrej.numucontpid
548  << " "
549  << proxy.slc.nhit
550  << " "
551  << proxy.sel.nuecosrej.pngptp;
552 #endif
553  return false;
554  }
555  }
556  else if(fDetector == novadaq::cnv::kNEARDET){
557  if(!ana::kNumuCutND2018(&proxy)){
558  LOG_DEBUG("CAFToEventList")
559  << "failed numu ND "
560  << ana::kNumuQuality(&proxy)
561  << " "
562  << ana::kNumuContainND2017(&proxy)
563  << " "
564  << ana::kNumuPID2018(&proxy);
565  return false;
566  }
567  }
568 
569  return true;
570  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const Cut kNumuContainND2017([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.nshwlid;++i){TVector3 start=sr->vtx.elastic.fuzzyk.png[i].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[i].shwlid.stop;if(std::min(start.X(), stop.X())< -180.0) return false;if(std::max(start.X(), stop.X()) > 180.0) return false;if(std::min(start.Y(), stop.Y())< -180.0) return false;if(std::max(start.Y(), stop.Y()) > 180.0) return false;if(std::min(start.Z(), stop.Z())< 20.0) return false;if(std::max(start.Z(), stop.Z()) > 1525.0) return false;}if(sr->trk.kalman.ntracks< 1) return false;for(unsigned int i=0;i< sr->trk.kalman.ntracks;++i){if(i==sr->trk.kalman.idxremid) continue;else if(sr->trk.kalman.tracks[i].start.Z() > 1275||sr->trk.kalman.tracks[i].stop.Z() > 1275) return false;}return(sr->trk.kalman.ntracks > sr->trk.kalman.idxremid &&sr->slc.firstplane > 1 &&sr->slc.lastplane< 212 &&sr->trk.kalman.tracks[0].start.Z()< 1100 &&(sr->trk.kalman.tracks[0].stop.Z()< 1275 ||sr->sel.contain.kalyposattrans< 55) &&sr->sel.contain.kalfwdcellnd > 5 &&sr->sel.contain.kalbakcellnd > 10);})
Definition: NumuCuts2017.h:11
const Cut kNumuCutND2018
Definition: NumuCuts2018.h:41
novadaq::cnv::DetId fDetector
which detector are we using
const Cut kNumuCosmicRej2018([](const caf::SRProxy *sr){return(sr->sel.cosrej.anglekal > 0.5 && sr->sel.cosrej.numucontpid2019 > 0.53 && sr->slc.nhit< 400 && sr->sel.nuecosrej.pngptp< 0.9 );})
Definition: NumuCuts2018.h:19
Far Detector at Ash River, MN.
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const Cut kNumuOptimizedContainFD2017([](const caf::SRProxy *sr){std::pair< int, int > planes=calcFirstLastLivePlane(sr->slc.firstplane, std::bitset< 14 >(sr->hdr.dibmask));int planestofront=sr->slc.firstplane-planes.first;int planestoback=planes.second-sr->slc.lastplane;return(sr->sel.contain.kalfwdcell > 6 &&sr->sel.contain.kalbakcell > 6 &&sr->sel.contain.cosfwdcell > 0 &&sr->sel.contain.cosbakcell > 7 &&planestofront > 1 &&planestoback > 1);})
Definition: NumuCuts2017.h:16
Near Detector in the NuMI cavern.
const Cut kNumuProngsContainFD2017
Definition: NumuCuts2017.h:19
const Cut kNumuPID2018([](const caf::SRProxy *sr){std::cout<< "ERROR::kNumuPID2018, cutting on both cvnProd3Train and cvn2017."<< " Neither branch exists anymore. Returning False."<< std::endl;abort();return false;})
Definition: NumuCuts2018.h:22
const Cut kNumuCutFD2018
Definition: NumuCuts2018.h:39
const Cut kNumuQuality
Definition: NumuCuts.h:18
bool fnex::CAFToEventList::PassesSelections ( caf::SRProxy const &  proxy) const
private

Definition at line 472 of file CAFToEventList_module.cc.

References fSelections, fnex::kNuESelectionLowPID, fnex::kNuMuSelectionQ1, PassesNueSelections(), PassesNumuSelections(), and PassesSpillAndBeamCuts().

Referenced by FillVariables().

473  {
474  if(!this->PassesSpillAndBeamCuts(proxy)) return false;
475 
477  if(this->PassesNumuSelections(proxy)) return true;
478  }
479  else if(fSelections.find(fnex::kNuESelectionLowPID) != fSelections.end()){
480  if(this->PassesNueSelections(proxy)) return true;
481  }
482 
483  return false;
484  }
bool PassesSpillAndBeamCuts(caf::SRProxy const &proxy) const
bool PassesNumuSelections(caf::SRProxy const &proxy) const
bool PassesNueSelections(caf::SRProxy const &proxy) const
std::set< fnex::SelectionType_t > fSelections
Selections to use.
bool fnex::CAFToEventList::PassesSpillAndBeamCuts ( caf::SRProxy const &  proxy) const
private

Definition at line 799 of file CAFToEventList_module.cc.

References ana::kInBeamSpill, ana::kStandardSpillCuts, and caf::Proxy< caf::StandardRecord >::spill.

Referenced by PassesSelections().

800  {
801  return (ana::kStandardSpillCuts(&(proxy.spill)) && ana::kInBeamSpill(&proxy));
802  }
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
int fnex::CAFToEventList::PeriodAdjustCosmics ( int const &  inputPeriod)
private

Definition at line 805 of file CAFToEventList_module.cc.

References fIsFHC, and DCS_db_parser::period.

Referenced by FindPOTPerPeriod().

806  {
807  int period = inputPeriod;
808 
809  // set the period value to be 5000 for the fhc tune with
810  // period === 4000 and set the period value to 4000 with
811  // the rhc tune and period != 4000. Later we set the
812  // period == 6000 exposure to be the same as the period 4000
813  if (period == 4000 && fIsFHC) period = 5000;
814  else if(period != 4000 && !fIsFHC) period = 4000;
815 
816  return period;
817  }
bool fIsFHC
are we looking at FHC files?
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void fnex::CAFToEventList::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 258 of file CAFToEventList_module.cc.

References DefineNumuQuantiles(), mkDefs::detName, fCAFFileNames, fCAFRecTreeName, fDetector, fFHCQuantFileName, fFileType, fIsFHC, fIsRealData, fMakeSelectedList, fNumQuantiles, fPOTHistName, fRHCQuantFileName, fSelections, fSpillTreeName, fhicl::ParameterSet::get(), fnex::kBeam, fnex::kCosmicBackgroundFile, fnex::kDataFile, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, fnex::kNuESelectionHighPID, fnex::kNuESelectionLowPID, fnex::kNuESelectionPeripheral, fnex::kNuMuSelectionQ1, fnex::kNuMuSelectionQ2, fnex::kNuMuSelectionQ3, fnex::kNuMuSelectionQ4, fnex::kSwap, fnex::kTauSwap, and string.

Referenced by CAFToEventList().

259  {
260  fCAFFileNames = p.get<std::vector<std::string> >("CAFFileNames" );
261 
262  // assume we don't mix FHC and RHC files in the same job, and the
263  // fIsFHC should only be used for cosmics
264  if(fCAFFileNames.begin()->find("rhc") != std::string::npos)
265  fIsFHC = false;
266 
267  fCAFRecTreeName = p.get<std::string >("CAFRecTreeName", "recTree");
268  fSpillTreeName = p.get<std::string >("SpillTreeName", "spillTree");
269  fPOTHistName = p.get<std::string >("CAFPOTHistName", "TotalPOT");
270  fNumQuantiles = p.get<unsigned int>("NumQuantiles", 4);
271  fMakeSelectedList = p.get<bool >("MakeSelectedList", false);
272  fFHCQuantFileName = p.get<std::string >("FHCQuantFileName", "ana2018/Quantiles/quantiles__fhc__full__numu2018.root");
273  fRHCQuantFileName = p.get<std::string >("FHCQuantFileName", "ana2018/Quantiles/quantiles__rhc__full__numu2018.root");
274 
275  auto detName = p.get<std::string>("DetectorName", "Near");
276  fDetector = (detName == "Near") ? novadaq::cnv::kNEARDET : novadaq::cnv::kFARDET;
277 
278  auto selType = p.get<std::string>("Selections");
279 
280  if(selType == "NuESel"){
284  }
285  else if(selType == "NuMuSel"){
290 
291  this->DefineNumuQuantiles();
292  }
293 
294  auto ftString = p.get<std::string>("FileType");
295 
296  if (ftString == "FluxSwap")
297  fFileType = kSwap;
298  else if(ftString == "NonSwap")
299  fFileType = kBeam;
300  else if(ftString == "TauSwap")
302  else if(ftString == "CosmicBackground")
304  else{
306  fIsRealData = true;
307  } // end tests on ftString
308  }
std::string fCAFRecTreeName
names of the CAF tree with the reco info
std::string fSpillTreeName
names of the CAF histogram with the total POT
unsigned int fNumQuantiles
number of quantiles
std::string fFHCQuantFileName
name of file in numudata ups product with FHC quantiles
const char * p
Definition: xmltok.h:285
novadaq::cnv::DetId fDetector
which detector are we using
Far Detector at Ash River, MN.
std::string fRHCQuantFileName
name of file in numudata ups product with FHC quantiles
std::string fPOTHistName
names of the CAF histogram with the total POT
Near Detector in the NuMI cavern.
bool fMakeSelectedList
configure to true to make a list
bool fIsFHC
are we looking at FHC files?
std::vector< std::string > fCAFFileNames
name of the CAF file we are using
bool fIsRealData
are we looking at real data?
std::set< fnex::SelectionType_t > fSelections
Selections to use.
detName
Definition: mkDefs.py:106
fnex::FileType_t fFileType
get from the configuration for now
enum BeamMode string
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
std::string fnex::CAFToEventList::RunToEpoch ( int  run)
private

Definition at line 349 of file CAFToEventList_module.cc.

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

Referenced by endJob(), and FindPOTPerPeriod().

350  {
351  std::string epochStr("Unknown");
352 
354  if (run < 10408) epochStr = "1";
355  else if(run < 10974) epochStr = "2";
356  else if(run < 11629) epochStr = "3";
357  else if(run < 11926) epochStr = "4";
358  else if(run < 12087) epochStr = "5";
359  //else if(run < 12290) epochStr = "6a";
360  //else if(run < 12517) epochStr = "6b";
361  //else if(run < 12580) epochStr = "7a";
362  //else epochStr = "7b";
363  // In the 2018 analysis there is no MC for runs after epoch 6a
364  // so make that the last epoch string we worry about too
365  else epochStr = "6";
366  }
367  else if(fDetector == novadaq::cnv::kFARDET){
368  if (run < 17140) epochStr = "1";
369  else if(run < 19747) epochStr = "2";
370  else if(run < 23420) epochStr = "3";
371  else if(run < 24614) epochStr = "4";
372  else if(run < 25413) epochStr = "5";
373  //else if(run < 26686) epochStr = "6a";
374  //else if(run < 28037) epochStr = "6b";
375  //else if(run < 28550) epochStr = "7a";
376  //else epochStr = "7b";
377  // In the 2018 analysis there is no MC for runs after epoch 6a
378  // so make that the last epoch string we worry about too
379  else epochStr = "6";
380  }
381 
382  return epochStr;
383  }
novadaq::cnv::DetId fDetector
which detector are we using
Far Detector at Ash River, MN.
Near Detector in the NuMI cavern.
Definition: run.py:1
enum BeamMode string
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::vector<std::string> fnex::CAFToEventList::fCAFFileNames
private

name of the CAF file we are using

Definition at line 125 of file CAFToEventList_module.cc.

Referenced by FillVariables(), and reconfigure().

std::string fnex::CAFToEventList::fCAFRecTreeName
private

names of the CAF tree with the reco info

Definition at line 130 of file CAFToEventList_module.cc.

Referenced by FillVariables(), and reconfigure().

novadaq::cnv::DetId fnex::CAFToEventList::fDetector
private

which detector are we using

Definition at line 131 of file CAFToEventList_module.cc.

Referenced by endJob(), InitializeEventListMaps(), PassesNueSelections(), PassesNumuSelections(), reconfigure(), and RunToEpoch().

std::string fnex::CAFToEventList::fFHCQuantFileName
private

name of file in numudata ups product with FHC quantiles

Definition at line 126 of file CAFToEventList_module.cc.

Referenced by DefineNumuQuantiles(), and reconfigure().

fnex::FileType_t fnex::CAFToEventList::fFileType
private

get from the configuration for now

Definition at line 133 of file CAFToEventList_module.cc.

Referenced by endJob(), FindPOTPerPeriod(), InitializeEventListMaps(), and reconfigure().

bool fnex::CAFToEventList::fIsFHC
private

are we looking at FHC files?

Definition at line 135 of file CAFToEventList_module.cc.

Referenced by InsertPeriod6Cosmics(), PeriodAdjustCosmics(), and reconfigure().

bool fnex::CAFToEventList::fIsRealData
private

are we looking at real data?

Definition at line 134 of file CAFToEventList_module.cc.

Referenced by endJob(), and reconfigure().

bool fnex::CAFToEventList::fMakeSelectedList
private

configure to true to make a list

Definition at line 142 of file CAFToEventList_module.cc.

Referenced by endJob(), and reconfigure().

fnex::EventListMap fnex::CAFToEventList::fMDToEvents
private

each entry in the vector is for a single slice

Definition at line 132 of file CAFToEventList_module.cc.

Referenced by clear(), endJob(), InitializeEventListMaps(), and InsertPeriod6Cosmics().

unsigned int fnex::CAFToEventList::fNumQuantiles
private

number of quantiles

Definition at line 138 of file CAFToEventList_module.cc.

Referenced by DefineNumuQuantiles(), and reconfigure().

std::vector<ana::Cut> fnex::CAFToEventList::fNumuFHCQuantCuts
private

quantile boundaries for the numu FHC data

Definition at line 136 of file CAFToEventList_module.cc.

Referenced by clear(), DefineNumuQuantiles(), and FindSelectionType().

std::vector<ana::Cut> fnex::CAFToEventList::fNumuRHCQuantCuts
private

quantile boundaries for the numu RHC data

Definition at line 137 of file CAFToEventList_module.cc.

Referenced by clear(), DefineNumuQuantiles(), and FindSelectionType().

std::map<int, POTLiveTime> fnex::CAFToEventList::fPeriodToPOTLiveTime
private

keep track of the POT in each period

Definition at line 140 of file CAFToEventList_module.cc.

Referenced by CAFToEventList(), endJob(), and FindPOTPerPeriod().

std::string fnex::CAFToEventList::fPOTHistName
private

names of the CAF histogram with the total POT

Definition at line 129 of file CAFToEventList_module.cc.

Referenced by FindPOTPerPeriod(), and reconfigure().

std::string fnex::CAFToEventList::fRHCQuantFileName
private

name of file in numudata ups product with FHC quantiles

Definition at line 127 of file CAFToEventList_module.cc.

Referenced by DefineNumuQuantiles(), and reconfigure().

std::set<fnex::SelectionType_t> fnex::CAFToEventList::fSelections
private

Selections to use.

Definition at line 141 of file CAFToEventList_module.cc.

Referenced by clear(), InitializeEventListMaps(), PassesSelections(), and reconfigure().

std::string fnex::CAFToEventList::fSpillTreeName
private

names of the CAF histogram with the total POT

Definition at line 128 of file CAFToEventList_module.cc.

Referenced by FindPOTPerPeriod(), and reconfigure().


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