Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
cmf::RandomUniverses Class Reference
Inheritance diagram for cmf::RandomUniverses:
art::ResultsProducer art::ProductRegistryHelper art::Consumer

Public Types

template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::PluginConfig, KeysToIgnore >
 

Public Member Functions

 RandomUniverses (fhicl::ParameterSet const &pset)
 
virtual ~RandomUniverses ()
 
 RandomUniverses (RandomUniverses const &)=delete
 
 RandomUniverses (RandomUniverses &&)=delete
 
RandomUniversesoperator= (RandomUniverses const &)=delete
 
RandomUniversesoperator= (RandomUniverses &&)=delete
 
void readResults (art::Results const &r) override
 
void writeResults (art::Results &r) override
 
void clear () override
 
void beginJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void doBeginJob ()
 
void doEndJob ()
 
void doBeginSubRun (SubRunPrincipal const &)
 
void doEndSubRun (SubRunPrincipal const &)
 
void doBeginRun (RunPrincipal const &)
 
void doEndRun (RunPrincipal const &)
 
void doEvent (EventPrincipal const &)
 
void doReadResults (ResultsPrincipal const &)
 
void doWriteResults (ResultsPrincipal &)
 
void doClear ()
 
void registerProducts (MasterProductRegistry &mpr, ProductDescriptions &producedProducts, ModuleDescription const &md)
 
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)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

template<class P >
void produces (std::string const &instanceName={})
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void setModuleDescription (ModuleDescription const &md)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

std::map< cmf::DetType_t, fhicl::ParameterSetfManipulatorPars
 parameters to make object for deserializing events More...
 
fhicl::ParameterSet fSAWPars
 parameters for the shifter and weighter More...
 
bool fIsFCJob
 are we making Feldman Cousins points or not? More...
 
unsigned int fStartUniverse
 which universe to start? More...
 
TH2D * fPoissonDraws
 histogram recording the Poisson draws for each logical bin More...
 
std::vector< cmf::LocationfUniverseLocs
 vector of input points for the random universes More...
 
std::vector< cmf::LocationfAsimovLocs
 the Asimov input points, ie no systematic shifts More...
 

Detailed Description

Definition at line 44 of file CMFRandomUniverses_plugin.cc.

Member Typedef Documentation

template<typename UserConfig , typename KeysToIgnore = void>
using art::ResultsProducer::Table = ProducerTable<UserConfig, detail::PluginConfig, KeysToIgnore>
inherited

Definition at line 114 of file ResultsProducer.h.

Constructor & Destructor Documentation

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

Definition at line 73 of file CMFRandomUniverses_plugin.cc.

References fSAWPars, LOG_DEBUG, reconfigure(), fhicl::ParameterSet::to_string(), and ~RandomUniverses().

74  : fSAWPars (pset.get<fhicl::ParameterSet>("ShifterAndWeighterParameters"))
75  , fPoissonDraws(nullptr)
76  {
77  this->reconfigure(pset);
78 
79  LOG_DEBUG("RandomUniverses")
80  << "ShifterAndWeighter parameters: "
81  << fSAWPars.to_string();
82 
83  // produce a vector of FakeUniverses
84  produces< std::vector<cmf::FakeUniverse> >();
85  produces< std::vector<cmf::Location> >();
86  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TH2D * fPoissonDraws
histogram recording the Poisson draws for each logical bin
fhicl::ParameterSet fSAWPars
parameters for the shifter and weighter
void reconfigure(fhicl::ParameterSet const &p)
std::string to_string() const
Definition: ParameterSet.h:137
cmf::RandomUniverses::~RandomUniverses ( )
virtualdefault

Referenced by RandomUniverses().

cmf::RandomUniverses::RandomUniverses ( RandomUniverses const &  )
delete
cmf::RandomUniverses::RandomUniverses ( RandomUniverses &&  )
delete

Member Function Documentation

void cmf::RandomUniverses::beginJob ( )
overridevirtual

Reimplemented from art::ResultsProducer.

Definition at line 111 of file CMFRandomUniverses_plugin.cc.

References cmf::RandomUniverseUtility::CreateLocationsWithVariedOscParameters(), cmf::RandomUniverseUtility::CreateLocationsWithVariedSystematics(), cmf::RandomUniverseUtility::CreateLocationWithVariedSystematics(), fAsimovLocs, cmf::Location::FDLocation(), fIsFCJob, fPoissonDraws, fUniverseLocs, cmf::RandomUniverseUtility::Instance(), cmf::CovarianceBinUtility::Instance(), cmf::ParameterUtility::Instance(), cmf::kFARDET, cmf::kNEARDET, LOG_DEBUG, LOG_VERBATIM, art::TFileDirectory::make(), cmf::ParameterUtility::ParametersAsLocation(), moon_position_table_new3::second, cmf::CovarianceBinUtility::TotalBins(), and submit_hadd::u.

112  {
114 
115  LOG_DEBUG("RandomUniverse")
116  << "nominal location is\n"
117  << nominalLoc;
118 
119  // get a list of the oscillation parameter names
120  std::set<std::string> oscParNames;
121  for(auto const& itr : nominalLoc.FDLocation()){
122  if(itr.second.IsOscPar())
123  oscParNames.emplace(itr.first);
124  }
125 
126  if(fIsFCJob){
127  // use the RandomUniverseUtility to get our random values for the hidden
128  // parameters in oscillation space first then use those oscillation
129  // parameters to create systematically varied points as well
131  fAsimovLocs);
132 
133  // now loop over the Asimov points and for each one create a template
134  // to be used to get the systematic uncertainty parameter variations
135  fUniverseLocs.resize(fAsimovLocs.size(), nominalLoc);
136 
137  for(size_t u = 0; u < fAsimovLocs.size(); ++u){
138  // grab the oscillation parameters from this Asimov point
139  // the oscillation parameter values are the same in both detectors
140  for(auto const& itr : oscParNames){
141  fUniverseLocs[u].SetParameterValue(itr, fAsimovLocs[u].NDLocation().find(itr)->second.Value(), cmf::kNEARDET);
142  fUniverseLocs[u].SetParameterValue(itr, fAsimovLocs[u].FDLocation().find(itr)->second.Value(), cmf::kFARDET );
143  }
144 
146  fUniverseLocs[u],
147  u);
148  }
149  }
150  else{
151  // In this mode we are only going to change the systematic parameters but not the
152  // oscillation parameters so we only need 1 Asimov point
153  fAsimovLocs.emplace_back(nominalLoc);
154 
155  // get the set of locations for our universes
157  fUniverseLocs);
158  }
159 
160  for(size_t u = 0; u < fUniverseLocs.size(); ++u)
161  LOG_VERBATIM("RandomUniverses")
162  << " new location "
163  << u
164  << "\n"
165  << fUniverseLocs[u];
166 
167  // now make some histograms
169 
170  fPoissonDraws = tfs->make<TH2D>("PoissonDraws",
171  ";Energy Bin;Poisson Draw",
173  0,
175  fUniverseLocs.size(),
176  0.,
177  fUniverseLocs.size());
178 
179  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::vector< cmf::Location > fAsimovLocs
the Asimov input points, ie no systematic shifts
std::vector< cmf::Location > fUniverseLocs
vector of input points for the random universes
TH2D * fPoissonDraws
histogram recording the Poisson draws for each logical bin
static ParameterUtility * Instance()
void CreateLocationWithVariedSystematics(cmf::Location const &nominalLoc, cmf::Location &vecLoc, size_t universeNum)
cmf::ParameterSpaceLoc const & FDLocation() const
Definition: Parameter.h:159
size_t TotalBins(bool allSels=false)
bool fIsFCJob
are we making Feldman Cousins points or not?
void CreateLocationsWithVariedSystematics(cmf::Location const &nominalLoc, std::vector< cmf::Location > &vecLocs)
static RandomUniverseUtility * Instance()
T * make(ARGS...args) const
cmf::Location ParametersAsLocation()
#define LOG_VERBATIM(category)
static CovarianceBinUtility * Instance()
void CreateLocationsWithVariedOscParameters(cmf::Location const &nominalLoc, std::vector< cmf::Location > &vecLoc)
void cmf::RandomUniverses::clear ( )
overridevirtual

Implements art::ResultsProducer.

Definition at line 184 of file CMFRandomUniverses_plugin.cc.

185  {
186  }
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
void art::ResultsProducer::doBeginJob ( )
inlineinherited

Definition at line 165 of file ResultsProducer.h.

References ana::assert(), breakpoints::beginJob(), fhicl::ParameterSetRegistry::get(), and art::Consumer::setModuleDescription().

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

166 {
168  // Preparing the consumer for the job must be done after the
169  // constructer has been called.
170  auto const& mainID = moduleDescription_->mainParameterSetID();
171  auto const& scheduler_pset =
173  "services.scheduler");
175  prepareForJob(scheduler_pset);
176  beginJob();
177 }
static collection_type const & get() noexcept
void setModuleDescription(ModuleDescription const &md)
void prepareForJob(fhicl::ParameterSet const &pset)
assert(nhit_max >=nhit_nbins)
virtual void beginJob()
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginRun ( RunPrincipal const &  rp)
inlineinherited

Definition at line 201 of file ResultsProducer.h.

References r().

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

202 {
203  Run const r{rp, *moduleDescription_, this};
204  beginRun(r);
205 }
virtual void beginRun(Run const &)
TRandom3 r(0)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginSubRun ( SubRunPrincipal const &  srp)
inlineinherited

Definition at line 187 of file ResultsProducer.h.

References sr.

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

188 {
189  SubRun const sr{srp, *moduleDescription_, this};
190  beginSubRun(sr);
191 }
virtual void beginSubRun(SubRun const &)
caf::StandardRecord * sr
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doClear ( )
inlineinherited

Definition at line 229 of file ResultsProducer.h.

References clear.

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

230 {
231  clear();
232 }
virtual void clear()=0
void art::ResultsProducer::doEndJob ( )
inlineinherited

Definition at line 180 of file ResultsProducer.h.

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

181 {
182  endJob();
184 }
virtual void endJob()
void showMissingConsumes() const
void art::ResultsProducer::doEndRun ( RunPrincipal const &  rp)
inlineinherited

Definition at line 208 of file ResultsProducer.h.

References r().

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

209 {
210  Run const r{rp, *moduleDescription_, this};
211  endRun(r);
212 }
virtual void endRun(Run const &)
TRandom3 r(0)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEndSubRun ( SubRunPrincipal const &  srp)
inlineinherited

Definition at line 194 of file ResultsProducer.h.

References sr.

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

195 {
196  SubRun const sr{srp, *moduleDescription_, this};
197  endSubRun(sr);
198 }
caf::StandardRecord * sr
virtual void endSubRun(SubRun const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEvent ( EventPrincipal const &  ep)
inlineinherited

Definition at line 215 of file ResultsProducer.h.

References e, and lem_server::ep.

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

216 {
217  Event const e{ep, *moduleDescription_, this};
218  event(e);
219 }
Float_t e
Definition: plot.C:35
virtual void event(Event const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doReadResults ( ResultsPrincipal const &  resp)
inlineinherited

Definition at line 222 of file ResultsProducer.h.

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

223 {
224  Results const res{resp, *moduleDescription_, this};
225  readResults(res);
226 }
virtual void readResults(Results const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doWriteResults ( ResultsPrincipal )
inherited
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
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
RandomUniverses& cmf::RandomUniverses::operator= ( RandomUniverses const &  )
delete
RandomUniverses& cmf::RandomUniverses::operator= ( RandomUniverses &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
template<class P >
void art::ResultsProducer::produces ( std::string const &  instanceName = {})
inlineprotectedinherited

Definition at line 159 of file ResultsProducer.h.

160 {
161  ProductRegistryHelper::produces<P, InResults>(instanceName);
162 }
void cmf::RandomUniverses::readResults ( art::Results const &  r)
overridevirtual

Reimplemented from art::ResultsProducer.

Definition at line 189 of file CMFRandomUniverses_plugin.cc.

190  {
191  }
void cmf::RandomUniverses::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 93 of file CMFRandomUniverses_plugin.cc.

References fIsFCJob, fManipulatorPars, fStartUniverse, fhicl::ParameterSet::get(), cmf::CovarianceBinUtility::Initialize(), cmf::ParameterUtility::Initialize(), cmf::RandomUniverseUtility::Initialize(), cmf::SelectionUtility::Initialize(), cmf::RandomUniverseUtility::Instance(), cmf::CovarianceBinUtility::Instance(), cmf::ParameterUtility::Instance(), cmf::SelectionUtility::Instance(), cmf::kFARDET, and cmf::kNEARDET.

Referenced by RandomUniverses().

94  {
97  cmf::ParameterUtility::Instance() ->Initialize(p.get< fhicl::ParameterSet >("ParametersToUse" ));
98 
99  fManipulatorPars.emplace(cmf::kFARDET, p.get<fhicl::ParameterSet>("FarDetEventListManipulator" ));
100  fManipulatorPars.emplace(cmf::kNEARDET, p.get<fhicl::ParameterSet>("NearDetEventListManipulator"));
101  fIsFCJob = p.get<bool >("IsFeldmanCousinsJob", false);
102  fStartUniverse = p.get<unsigned int>("StartUniverse");
103 
104  // set the seed for the random number to be what is configured, plus the
105  // start universe value in case lots are jobs are submitted with the same seed
106  // by accident
108  }
void Initialize(fhicl::ParameterSet const &pset)
void Initialize(fhicl::ParameterSet const &pset)
const char * p
Definition: xmltok.h:285
static SelectionUtility * Instance()
static ParameterUtility * Instance()
unsigned int fStartUniverse
which universe to start?
void Initialize(fhicl::ParameterSet const &pset)
bool fIsFCJob
are we making Feldman Cousins points or not?
static RandomUniverseUtility * Instance()
std::map< cmf::DetType_t, fhicl::ParameterSet > fManipulatorPars
parameters to make object for deserializing events
void Initialize(fhicl::ParameterSet const &pset)
static CovarianceBinUtility * Instance()
void art::ResultsProducer::registerProducts ( MasterProductRegistry mpr,
ProductDescriptions producedProducts,
ModuleDescription const &  md 
)
inlineinherited

Definition at line 128 of file ResultsProducer.h.

References fetch_tb_beamline_files::md, and art::ProductRegistryHelper::registerProducts().

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

131  {
132  ProductRegistryHelper::registerProducts(mpr, producedProducts, md);
134  }
void registerProducts(MasterProductRegistry &mpr, ProductDescriptions &productsToRegister, ModuleDescription const &md)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::Consumer::setModuleDescription ( ModuleDescription const &  md)
protectedinherited
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
void cmf::RandomUniverses::writeResults ( art::Results r)
overridevirtual

Implements art::ResultsProducer.

Definition at line 195 of file CMFRandomUniverses_plugin.cc.

References b, cmf::CovarianceBinUtility::BinToDetector(), cmf::cDetType_Strings, confusionMatrixTree::count, DEFINE_ART_RESULTS_PLUGIN, cmf::EventListManipulator::Deserialize(), msf_helper::dets, cmf::EventListManipulator::ExposureMap(), fAsimovLocs, cmf::RandomUniverseUtility::FillPoissonSpectrum(), cmf::FillSpectrum(), fIsFCJob, fManipulatorPars, fPoissonDraws, fSAWPars, fStartUniverse, fUniverseLocs, cmf::ShifterAndWeighter::InitShiftsAndWeightsToUse(), cmf::RandomUniverseUtility::Instance(), cmf::CovarianceBinUtility::Instance(), cmf::ShifterAndWeighter::Instance(), cmf::kMC, LOG_DEBUG, LOG_VERBATIM, cmf::RandomUniverseUtility::MakeUniverseHistograms(), art::Results::put(), and submit_hadd::u.

196  {
197  cmf::EventListColl mcLists;
198 
199  std::vector<cmf::Spectrum> spectrum (fUniverseLocs.size());
200  std::vector<cmf::Spectrum> poissonSpectrum(fUniverseLocs.size());
201  std::vector<cmf::Spectrum> fakeCount (fUniverseLocs.size());
202  std::vector<cmf::Spectrum> count (fUniverseLocs.size());
203  std::vector<cmf::Spectrum> asimov (fAsimovLocs.size() );
204 
205  std::set<cmf::DetType_t> dets;
206  for(auto const& mpItr : fManipulatorPars){
207 
208  mcLists.clear();
209 
210  dets.clear();
211  dets.insert(mpItr.first);
212 
213  LOG_VERBATIM("RandomUniverses")
214  << "Fill spectrum from "
215  << cmf::cDetType_Strings[mpItr.first]
216  << " starting universe "
217  << fStartUniverse
218  << " "
219  << fUniverseLocs.size();
220 
221  // get the manipulator to deserialize the data and MC
222  // we'll keep the MC lists around, but will drop the data lists as
223  // soon as we leave this method
224  cmf::EventListManipulator elm(mpItr.second);
225 
226  elm.Deserialize(mcLists, cmf::kMC, dets);
227  auto const& exposureMap = elm.ExposureMap();
228 
229  // now make the spectra for all the universes
230  unsigned int uni = 0;
231  for(unsigned int u = fStartUniverse; u < fStartUniverse + fUniverseLocs.size(); ++u){
232 
233  uni = u - fStartUniverse;
234 
235  if(fIsFCJob){
236  LOG_DEBUG("RandomUniverses")
237  << "Filling FC Asimov Spectra";
238 
240  fSAWPars);
241 
242  // fill the asimov spectrum
243  cmf::FillSpectrum(mcLists,
244  exposureMap,
245  asimov[uni],
246  count[uni]);
247  }
248  else if(!fIsFCJob && u == 0){
249  LOG_DEBUG("RandomUniverses")
250  << fIsFCJob
251  << " "
252  << u
253  << " fill Asimov spectrum for "
254  << fAsimovLocs.size()
255  << " locations";
256 
258  fSAWPars);
259  // fill the asimov spectrum
260  cmf::FillSpectrum(mcLists,
261  exposureMap,
262  asimov[u],
263  count[u]);
264 
265  LOG_DEBUG("RandomUniverses")
266  << "Asimov spectrum filled "
267  << asimov.size()
268  << " "
269  << count.size();
270 
271  }
272 
273  LOG_DEBUG("CMFRandomUniverses")
274  << "Finished filling asimov spectrum";
275 
277  fSAWPars);
278 
279  LOG_DEBUG("CMFRandomUniverses")
280  << "Filling universe spectrum";
281 
282  cmf::FillSpectrum(mcLists,
283  exposureMap,
284  spectrum[uni],
285  fakeCount[uni]);
286 
287  cmf::RandomUniverseUtility::Instance()->FillPoissonSpectrum(spectrum[uni], poissonSpectrum[uni]);
288 
289  for(size_t b = 0; b < poissonSpectrum[uni].size(); ++b){
290  // the ND bins fill twice without the following check because
291  // the ND portion of the spectrum is filled before the FD portion
292  if(mcLists.begin()->ListMetaData().detector == cmf::CovarianceBinUtility::Instance()->BinToDetector(b))
293  fPoissonDraws->Fill(b, uni, poissonSpectrum[uni][b]);
294  }
295 
296  // for(size_t b = 0; b < spectrum[uni].size(); ++b){
297  // LOG_VERBATIM("RandomUniverses")
298  // << "universe "
299  // << u
300  // << " spectrum bin "
301  // << b
302  // << " fluctuated spectrum: "
303  // << poissonSpectrum[uni][b]
304  // << " unfluctuated/asimov: "
305  // << spectrum[uni][b]
306  // << " / "
307  // << asimov[0][b];
308  // }
309 
310  LOG_VERBATIM("RandomUniverses")
311  << " Finished universe "
312  << uni
313  << " for "
314  << cmf::cDetType_Strings[mpItr.first];
315 
316  } // end loop to make fake universe spectra
317  } // end loop over the manipulators
318 
319  // actually make the fake universes and their locations
320  // we are storing these separately so that we don't have to
321  // read in the locations (which use a lot of memory) unless we want to
322  std::unique_ptr<std::vector<cmf::FakeUniverse>> fakeUniverses = std::make_unique<std::vector<cmf::FakeUniverse>>();
323  std::unique_ptr<std::vector<cmf::Location>> fakeUniverseLocs = std::make_unique<std::vector<cmf::Location>>();
324 
325  for(size_t u = 0; u < fUniverseLocs.size(); ++u){
326  cmf::Spectrum asimovSpec(asimov[0]);
327  if(fIsFCJob) asimovSpec.swap(asimov[u]);
328  fakeUniverses->emplace_back(fUniverseLocs[u],
329  asimovSpec,
330  poissonSpectrum[u]);
331  fakeUniverseLocs->emplace_back(fUniverseLocs[u]);
332 
333  LOG_DEBUG("RandomUniverses")
334  << "added fake universe "
335  << u;
336 
337  // make histograms for the fake spectra and the total spectrum to compare
338  // them against each other.
340  u + fStartUniverse);
341 
342  LOG_DEBUG("RandomUniverses")
343  << fakeUniverses->back();
344  }
345 
346  r.put(std::move(fakeUniverses ));
347  r.put(std::move(fakeUniverseLocs));
348  } // end writeResults
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
std::vector< cmf::Location > fAsimovLocs
the Asimov input points, ie no systematic shifts
void FillPoissonSpectrum(std::vector< float > &spectrum, std::vector< float > &poissonSpectrum)
art::ProductID put(std::unique_ptr< PROD > &&product)
Definition: Results.h:78
std::vector< cmf::Location > fUniverseLocs
vector of input points for the random universes
TH2D * fPoissonDraws
histogram recording the Poisson draws for each logical bin
fhicl::ParameterSet fSAWPars
parameters for the shifter and weighter
unsigned int fStartUniverse
which universe to start?
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 ShifterAndWeighter * Instance()
std::vector< float > Spectrum
Definition: Constants.h:610
void MakeUniverseHistograms(cmf::FakeUniverse &fakeU, unsigned int uNumber)
bool fIsFCJob
are we making Feldman Cousins points or not?
std::vector< cmf::EventList > EventListColl
Definition: Event.h:147
void InitShiftsAndWeightsToUse(cmf::Location const &loc, fhicl::ParameterSet const &parset)
static RandomUniverseUtility * Instance()
cmf::DetType_t BinToDetector(int const &bin, bool allSels=false)
const hit & b
Definition: hits.cxx:21
std::map< cmf::DetType_t, fhicl::ParameterSet > fManipulatorPars
parameters to make object for deserializing events
#define LOG_VERBATIM(category)
const std::string cDetType_Strings[5]
Definition: Constants.h:592
cons_index_list< index_uni, nil_index_list > uni
static CovarianceBinUtility * Instance()

Member Data Documentation

std::vector<cmf::Location> cmf::RandomUniverses::fAsimovLocs
private

the Asimov input points, ie no systematic shifts

Definition at line 69 of file CMFRandomUniverses_plugin.cc.

Referenced by beginJob(), and writeResults().

bool cmf::RandomUniverses::fIsFCJob
private

are we making Feldman Cousins points or not?

Definition at line 65 of file CMFRandomUniverses_plugin.cc.

Referenced by beginJob(), reconfigure(), and writeResults().

std::map<cmf::DetType_t, fhicl::ParameterSet> cmf::RandomUniverses::fManipulatorPars
private

parameters to make object for deserializing events

Definition at line 63 of file CMFRandomUniverses_plugin.cc.

Referenced by reconfigure(), and writeResults().

TH2D* cmf::RandomUniverses::fPoissonDraws
private

histogram recording the Poisson draws for each logical bin

Definition at line 67 of file CMFRandomUniverses_plugin.cc.

Referenced by beginJob(), and writeResults().

fhicl::ParameterSet cmf::RandomUniverses::fSAWPars
private

parameters for the shifter and weighter

Definition at line 64 of file CMFRandomUniverses_plugin.cc.

Referenced by RandomUniverses(), and writeResults().

unsigned int cmf::RandomUniverses::fStartUniverse
private

which universe to start?

Definition at line 66 of file CMFRandomUniverses_plugin.cc.

Referenced by reconfigure(), and writeResults().

std::vector<cmf::Location> cmf::RandomUniverses::fUniverseLocs
private

vector of input points for the random universes

Definition at line 68 of file CMFRandomUniverses_plugin.cc.

Referenced by beginJob(), and writeResults().


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