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

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 CMFSpectraMaker (fhicl::ParameterSet const &pset)
 
 ~CMFSpectraMaker ()=default
 
void analyze (art::Event const &evt) override
 
void beginJob () override
 
void endJob () override
 
void reconfigure (fhicl::ParameterSet const &pset)
 
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 Initialize ()
 
void FillHistograms (art::TFileDirectory &td, int sigmaVal, cmf::EventListColl &eventLists, cmf::ExposureMap &exposureMap)
 

Private Attributes

fhicl::ParameterSet fManipulatorParameters
 event list manipulator parameters More...
 
fhicl::ParameterSet fSAWParameters
 shifter and weighter parameters More...
 
art::ServiceHandle< art::TFileServicefTFS
 
cmf::Location loc
 
std::vector< std::stringfITypeStrings
 
std::map< std::string, cmf::InteractionType_tITypes
 
std::vector< intfSigmaValues
 
bool fApplyExposureNorm
 

Detailed Description

Definition at line 31 of file CMFSpectraMaker_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

cmf::CMFSpectraMaker::CMFSpectraMaker ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 65 of file CMFSpectraMaker_module.cc.

References reconfigure().

66  : EDAnalyzer(pset)
67  {
68  this->reconfigure(pset);
69  }
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void reconfigure(fhicl::ParameterSet const &pset)
cmf::CMFSpectraMaker::~CMFSpectraMaker ( )
default

Member Function Documentation

void cmf::CMFSpectraMaker::analyze ( art::Event const &  evt)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 118 of file CMFSpectraMaker_module.cc.

119  {
120  }
void cmf::CMFSpectraMaker::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 113 of file CMFSpectraMaker_module.cc.

114  {
115  }
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

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

Definition at line 146 of file Consumer.h.

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

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

Definition at line 161 of file Consumer.h.

References T.

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

Definition at line 171 of file Consumer.h.

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

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDAnalyzer::currentContext ( ) const
protectedinherited
void cmf::CMFSpectraMaker::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 163 of file CMFSpectraMaker_module.cc.

References DEFINE_ART_MODULE(), cmf::EventListManipulator::Deserialize(), cmf::EventListManipulator::ExposureMap(), FillHistograms(), fManipulatorParameters, fSigmaValues, fTFS, cmf::ParameterUtility::Instance(), cmf::ShifterAndWeighter::Instance(), cmf::kFARDET, cmf::kMC, cmf::kNEARDET, loc, art::TFileDirectory::mkdir(), cmf::ShifterAndWeighter::ReportCurrentVals(), cmf::ShifterAndWeighter::SetCurrentVals(), cmf::Location::SetParameterValue(), and cmf::ParameterUtility::SysParNames().

164  {
165  // get the lists of events from the TTree and put them into a map
166  // of event lists
168 
169  cmf::EventListColl eventLists;
170  manipulator.Deserialize(eventLists, cmf::kMC);
171 
172  cmf::ExposureMap exposureMap = manipulator.ExposureMap();
173 
174  // this allows us to get systematically spectra by setting
175  // the systematic sigma
176  auto parNames = cmf::ParameterUtility::Instance()->SysParNames();
177  if (parNames.size() > 0){
178  for (auto& parItr : parNames) {
179 
180  art::TFileDirectory td = fTFS->mkdir(parItr, parItr);
181 
182  for (size_t is = 0; is < fSigmaValues.size(); ++is){
183 
186 
189 
190  this->FillHistograms(td, fSigmaValues.at(is), eventLists, exposureMap);
191  }
192  }
193  }
194  else{
195  art::TFileDirectory td = fTFS->mkdir("nosyst", "Not systematically shifted");
196  this->FillHistograms(td, 0, eventLists, exposureMap);
197  }
198 
199  }
std::map< cmf::MetaData, cmf::SpillSummary > ExposureMap
Definition: Structs.h:215
std::vector< int > fSigmaValues
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
fhicl::ParameterSet fManipulatorParameters
event list manipulator parameters
art::ServiceHandle< art::TFileService > fTFS
std::vector< std::string > SysParNames() const
static ParameterUtility * Instance()
static ShifterAndWeighter * Instance()
std::vector< cmf::EventList > EventListColl
Definition: Event.h:147
void FillHistograms(art::TFileDirectory &td, int sigmaVal, cmf::EventListColl &eventLists, cmf::ExposureMap &exposureMap)
void SetCurrentVals(cmf::Location const &loc)
void SetParameterValue(std::string const &parName, double const &value, cmf::DetType_t const &det)
Definition: Parameter.cxx:220
void cmf::CMFSpectraMaker::FillHistograms ( art::TFileDirectory td,
int  sigmaVal,
cmf::EventListColl eventLists,
cmf::ExposureMap exposureMap 
)
private

Definition at line 123 of file CMFSpectraMaker_module.cc.

References confusionMatrixTree::count, fApplyExposureNorm, cmf::FillSpectrum(), cmf::PlotUtilities::Instance(), ITypes, cmf::kUnknownInteraction, cmf::PlotUtilities::MakeEnergySpectraFromBins(), string, and art::to_string().

Referenced by endJob().

127  {
128  for (auto& iType : ITypes){
129 
130  std::vector<float> spectrum;
131  std::vector<float> count;
132 
133  if (iType.second == cmf::kUnknownInteraction)
134  cmf::FillSpectrum(eventLists,
135  exposureMap,
136  spectrum,
137  count,
139  else
140  cmf::FillSpectrum(eventLists,
141  exposureMap,
142  spectrum,
143  count,
144  iType.second,
146 
147  std::map<long, TH1D*> energySpecMap;
148 
149  std::string preName = "";
150  if (sigmaValue != 0)
151  preName = std::to_string(sigmaValue)+"Sigma";
152 
154  count,
155  energySpecMap,
156  iType.first,
157  td,
158  preName);
159  }
160  }
void MakeEnergySpectraFromBins(std::vector< float > const &binSpec, std::vector< float > const &binCount, std::map< long, TH1D * > &energySpecMap, std::string const &name, art::TFileDirectory &tfd, std::string const &uniqueID)
std::map< std::string, cmf::InteractionType_t > ITypes
void FillSpectrum(cmf::EventListColl const &eventLists, cmf::ExposureMap const &exposureMap, std::vector< float > &spectrum, std::vector< float > &count, cmf::InteractionType_t intType, bool applyExposureNorm)
static PlotUtilities * Instance()
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
enum BeamMode string
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 cmf::CMFSpectraMaker::Initialize ( )
private
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
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void cmf::CMFSpectraMaker::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 72 of file CMFSpectraMaker_module.cc.

References cmf::cInteractionType_Strings, fApplyExposureNorm, fITypeStrings, fManipulatorParameters, fSAWParameters, fSigmaValues, fhicl::ParameterSet::get(), cmf::CovarianceBinUtility::Initialize(), cmf::ParameterUtility::Initialize(), cmf::PlotUtilities::Initialize(), cmf::SelectionUtility::Initialize(), cmf::ShifterAndWeighter::InitShiftsAndWeightsToUse(), cmf::CovarianceBinUtility::Instance(), cmf::ParameterUtility::Instance(), cmf::PlotUtilities::Instance(), cmf::SelectionUtility::Instance(), cmf::ShifterAndWeighter::Instance(), ITypes, cmf::kCosmicMuon, cmf::kNC, cmf::kNuEBarCC, cmf::kNuECC, cmf::kNuMuBarCC, cmf::kNuMuCC, cmf::kNuTauBarCC, cmf::kNuTauCC, cmf::kRockMuon, cmf::kUnknownInteraction, loc, and cmf::ParameterUtility::ParametersAsLocation().

Referenced by CMFSpectraMaker().

73  {
74  fManipulatorParameters = pset.get< fhicl::ParameterSet >("EventListManipulator" );
75  fSAWParameters = pset.get< fhicl::ParameterSet >("ShifterAndWeighterConfig");
76  fSigmaValues = pset.get< std::vector<int> >("SigmaValues", {0} );
77  fApplyExposureNorm = pset.get< bool >("ApplyExposureNorm", true );
78 
81  cmf::ParameterUtility::Instance() ->Initialize(pset.get< fhicl::ParameterSet >("ParametersToUse" ));
82  cmf::PlotUtilities::Instance() ->Initialize(pset.get< fhicl::ParameterSet >("PlotConfig" ));
84 
86  fSAWParameters);
87 
88  fITypeStrings = pset.get< std::vector<std::string>> ("InteractionTypes");
89 
91  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuMuCC") != fITypeStrings.end())
93  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuMuBarCC") != fITypeStrings.end())
95  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuECC") != fITypeStrings.end())
97  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuEBarCC") != fITypeStrings.end())
99  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuTauCC") != fITypeStrings.end())
101  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NuTauBarCC") != fITypeStrings.end())
103  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "NC") != fITypeStrings.end())
105  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "CosmicMuon") != fITypeStrings.end())
107  if (std::find(fITypeStrings.begin(), fITypeStrings.end(), "RockMuon") != fITypeStrings.end())
109 
110  }
std::vector< int > fSigmaValues
void Initialize(fhicl::ParameterSet const &pset)
fhicl::ParameterSet fManipulatorParameters
event list manipulator parameters
static SelectionUtility * Instance()
std::map< std::string, cmf::InteractionType_t > ITypes
const std::string cInteractionType_Strings[11]
Definition: Constants.h:136
static ParameterUtility * Instance()
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< std::string > fITypeStrings
void Initialize(fhicl::ParameterSet const &pset)
static ShifterAndWeighter * Instance()
void Initialize(fhicl::ParameterSet const &plottingPars)
void InitShiftsAndWeightsToUse(cmf::Location const &loc, fhicl::ParameterSet const &parset)
static PlotUtilities * Instance()
cmf::Location ParametersAsLocation()
fhicl::ParameterSet fSAWParameters
shifter and weighter parameters
void Initialize(fhicl::ParameterSet const &pset)
static CovarianceBinUtility * Instance()
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

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

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

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

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

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

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

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

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

Definition at line 51 of file EventObserverBase.h.

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

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

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

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

Member Data Documentation

bool cmf::CMFSpectraMaker::fApplyExposureNorm
private

Definition at line 61 of file CMFSpectraMaker_module.cc.

Referenced by FillHistograms(), and reconfigure().

std::vector<std::string> cmf::CMFSpectraMaker::fITypeStrings
private

Definition at line 58 of file CMFSpectraMaker_module.cc.

Referenced by reconfigure().

fhicl::ParameterSet cmf::CMFSpectraMaker::fManipulatorParameters
private

event list manipulator parameters

Definition at line 52 of file CMFSpectraMaker_module.cc.

Referenced by endJob(), and reconfigure().

fhicl::ParameterSet cmf::CMFSpectraMaker::fSAWParameters
private

shifter and weighter parameters

Definition at line 53 of file CMFSpectraMaker_module.cc.

Referenced by reconfigure().

std::vector<int> cmf::CMFSpectraMaker::fSigmaValues
private

Definition at line 60 of file CMFSpectraMaker_module.cc.

Referenced by endJob(), and reconfigure().

art::ServiceHandle<art::TFileService> cmf::CMFSpectraMaker::fTFS
private

Definition at line 55 of file CMFSpectraMaker_module.cc.

Referenced by endJob().

std::map<std::string, cmf::InteractionType_t> cmf::CMFSpectraMaker::ITypes
private

Definition at line 59 of file CMFSpectraMaker_module.cc.

Referenced by FillHistograms(), and reconfigure().

cmf::Location cmf::CMFSpectraMaker::loc
private

Definition at line 57 of file CMFSpectraMaker_module.cc.

Referenced by endJob(), and reconfigure().


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