Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
photrans::PhotonSystRewriter Class Reference
Inheritance diagram for photrans::PhotonSystRewriter:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 PhotonSystRewriter (const fhicl::ParameterSet &pset)
 
virtual ~PhotonSystRewriter ()
 
void produce (art::Event &evt)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () 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
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fGeneratorProcessName
 
std::string fGeantLabel
 
std::string fPhotonTransportLabel
 
double fPhotonsPerMeVShift
 
double fCerenkovEffShift
 
double fXViewFactorShift
 
double fYViewFactorShift
 
CLHEP::RandPoissonQfPoisson
 

Detailed Description

Modify already-simulated photons to alter the balance of Cerenkov and scintillation light.

Definition at line 28 of file PhotonSystRewriter_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

photrans::PhotonSystRewriter::PhotonSystRewriter ( const fhicl::ParameterSet pset)
explicit

Definition at line 48 of file PhotonSystRewriter_module.cc.

References art::EngineCreator::createEngine(), fPoisson, fhicl::ParameterSet::get(), art::RandomNumberGenerator::getEngine(), sim::GetRandomNumberSeed(), art::EngineCreator::rng(), and seed.

49  : fGeneratorProcessName(pset.get<std::string>("GeneratorProcessName")),
50  fGeantLabel(pset.get<std::string>("GeantLabel")),
51  fPhotonTransportLabel(pset.get<std::string>("PhotonTransportLabel")),
52  fPhotonsPerMeVShift (pset.get<double>("PhotonsPerMeVShift")),
53  fCerenkovEffShift (pset.get<double>("CerenkovEffShift")),
54  fXViewFactorShift (pset.get<double>("XViewFactorShift")),
55  fYViewFactorShift (pset.get<double>("YViewFactorShift"))
56  {
57  // Get the random number seed. Use a random default if not specified in the
58  // configuration file.
59  unsigned int seed = pset.get<unsigned int>("Seed", sim::GetRandomNumberSeed());
60  createEngine(seed);
61 
64 
65  produces<std::vector<sim::PhotonSignal>>();
66  }
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
base_engine_t & createEngine(seed_t seed)
base_engine_t & getEngine() const
unsigned int seed
Definition: runWimpSim.h:102
T get(std::string const &key) const
Definition: ParameterSet.h:231
unsigned int GetRandomNumberSeed()
Definition: Simulation.cxx:13
enum BeamMode string
photrans::PhotonSystRewriter::~PhotonSystRewriter ( )
virtual

Definition at line 69 of file PhotonSystRewriter_module.cc.

References fPoisson.

70  {
71  delete fPoisson;
72  }

Member Function Documentation

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::EDProducer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
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::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void photrans::PhotonSystRewriter::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 75 of file PhotonSystRewriter_module.cc.

References om::cout, DEFINE_ART_MODULE(), allTimeWatchdog::endl, fCerenkovEffShift, fGeantLabel, fGeneratorProcessName, CLHEP::RandPoissonQ::fire(), fPhotonsPerMeVShift, fPhotonTransportLabel, fPoisson, fXViewFactorShift, fYViewFactorShift, fhicl::ParameterSet::get(), art::DataViewImpl::getByLabel(), sim::FLSHit::GetCellID(), sim::FLSHit::GetEdepBirks(), sim::FLSHit::GetNCerenkov(), sim::FLSHit::GetNSteps(), sim::FLSHit::GetPlaneID(), art::Event::getProcessParameterSet(), sim::FLSHit::GetTrackID(), fhicl::ParameterSet::is_empty(), it, findDuplicateFiles::key, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, geo::kX, geo::GeometryBase::Plane(), nd_projection_maker::ps, art::Event::put(), sim::PhotonSignal::SetNPhoton(), sim::PhotonSignal::SetPlaneCell(), sim::PhotonSignal::SetPoissonLambda(), sim::PhotonSignal::SetTimeMean(), sim::PhotonSignal::SetTrackId(), fillBadChanDBTables::step, and string.

76  {
79  if(ps.is_empty()){
80  std::cout << "PhotonSystRewriter: Couldn't find original PhotonTransport parameter set under process name " << fGeneratorProcessName << std::endl;
81  abort();
82  }
83 
84  std::string detStr;
86  case novadaq::cnv::kNEARDET: detStr = "nd"; break;
87  case novadaq::cnv::kFARDET: detStr = "fd"; break;
88  default:
89  std::cout << "PhotonSystRewriter: Unknown detector." << std::endl;
90  abort();
91  }
92 
93  const fhicl::ParameterSet phot_pset =
94  ps.get<fhicl::ParameterSet>("physics")
95  .get<fhicl::ParameterSet>("producers")
97  .get<fhicl::ParameterSet>(detStr);
98 
99  const double photonsPerMeVOrig = phot_pset.get<double>("PhotonsPerMeV");
100  const double cerenkovEffOrig = phot_pset.get<double>("CerenkovEff");
101  const double xViewFactorOrig = phot_pset.get<double>("XViewFactor");
102  const double yViewFactorOrig = phot_pset.get<double>("YViewFactor");
103 
104  // The FLSHits that led to the original photons
106  evt.getByLabel(fGeantLabel, flslistHandle);
107 
108  // We want an accounting of how much of each deposit was cherenkov light
109  // and how much scintillation light.
110  struct DepositInfo
111  {
112  DepositInfo() : cherenkovPhots(0), birksGeV(0) {}
113  double cherenkovPhots, birksGeV;
114  };
115 
116  // As a function of cell in the detector and track ID
117  typedef std::pair<geo::OfflineChan, int> Key_t;
118 
119  std::map<Key_t, DepositInfo> deposits;
120 
121  for(const sim::FLSHitList& hitlist: *flslistHandle){
122  for(const sim::FLSHit& hit: hitlist.fHits){
123  const Key_t key(geo::OfflineChan(hit.GetPlaneID(), hit.GetCellID()),
124  hit.GetTrackID());
125 
126  DepositInfo& info = deposits[key];
127 
128  for(int step = 0; step < hit.GetNSteps(); ++step){
129  info.cherenkovPhots += hit.GetNCerenkov(step);
130  info.birksGeV += hit.GetEdepBirks(step);
131  } // end for step
132  } // end for ihit
133  } // end for ilist
134 
135  // The original photons that we'll modify
137  evt.getByLabel(fPhotonTransportLabel, phots);
138 
140 
141  // Our output photons
142  auto pscol = std::make_unique<std::vector<sim::PhotonSignal>>();
143 
144  for(const sim::PhotonSignal& phot: *phots){
145  const Key_t key(geo::OfflineChan(phot.Plane(), phot.Cell()),
146  phot.TrackId());
147 
148  auto it = deposits.find(key);
149  if(it == deposits.end()){
150  std::cout << "PhotonSystRewriter: Photon with no matching FLSHits!" << std::endl;
151  abort();
152  }
153 
154  const double nCherenkov = it->second.cherenkovPhots;
155  const double birksGeV = it->second.birksGeV;
156 
157  double ViewFactorOrig(0.0), ViewFactorNew(0.0);
158  if (fGeo->Plane(phot.Plane())->View() == geo::kX) {
159  ViewFactorOrig = xViewFactorOrig;
160  ViewFactorNew = ViewFactorOrig*(1.0 + fXViewFactorShift);
161  }
162  else {
163  ViewFactorOrig = yViewFactorOrig;
164  ViewFactorNew = ViewFactorOrig*(1.0 + fYViewFactorShift);
165  }
166 
167  double cerenkovEffNew = cerenkovEffOrig*(1.0 + fCerenkovEffShift);
168  double photonsPerMeVNew = photonsPerMeVOrig*(1.0 + fPhotonsPerMeVShift);
169 
170  // How many photons were made in the fiber originally
171  const double greenOrig = ViewFactorOrig*(cerenkovEffOrig*nCherenkov + 1000*photonsPerMeVOrig*birksGeV);
172 
173  // How many will be made by the new settings
174  const double greenNew = ViewFactorNew*(cerenkovEffNew*nCherenkov + 1000*photonsPerMeVNew*birksGeV);
175 
176  // Everything downstream of here is common between the two cases, so just
177  // scale the mean expected number of photons by the ratio.
178  const double newLambda = greenNew / greenOrig * phot.PoissonLambda();
179 
180  // Copy the old hit to the new hit but with new lambda and NPhoton
182  ps.SetTimeMean(phot.TimeMean());
183  ps.SetNPhoton(fPoisson->fire(newLambda));
184  ps.SetPlaneCell(phot.Plane(), phot.Cell());
185  ps.SetTrackId(phot.TrackId());
186  ps.SetPoissonLambda(newLambda);
187 
188  pscol->push_back(ps);
189  } // end for phot
190 
191  evt.put(std::move(pscol));
192  }
void SetPoissonLambda(double l)
Definition: PhotonSignal.h:26
bool getProcessParameterSet(std::string const &processName, fhicl::ParameterSet &ps) const
const XML_Char XML_Encoding * info
Definition: expat.h:530
void SetTrackId(int t)
Definition: PhotonSignal.h:25
set< int >::iterator it
int GetPlaneID() const
Plane ID.
Definition: FLSHit.h:37
int GetCellID() const
Cell ID.
Definition: FLSHit.h:39
bool is_empty() const
int GetNSteps() const
Number of steps in FLSHit. Should be equal to GetNPoints() - 1.
Definition: FLSHit.h:63
Vertical planes which measure X.
Definition: PlaneGeo.h:28
float GetNCerenkov() const
Get total N Cerenkov photons.
Definition: FLSHit.h:35
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
const PlaneGeo * Plane(unsigned int i) const
void SetPlaneCell(int plane, int cell)
Definition: PhotonSignal.h:24
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Far Detector at Ash River, MN.
T get(std::string const &key) const
Definition: ParameterSet.h:231
Near Detector in the NuMI cavern.
void SetNPhoton(int npe)
Definition: PhotonSignal.h:23
Definition: View.py:1
float GetEdepBirks() const
Get total Energy with Birks suppression deposited into the cell for the whole FLSHit.
Definition: FLSHit.h:33
OStream cout
Definition: OStream.cxx:6
int GetTrackID() const
Track ID.
Definition: FLSHit.h:45
A vector of FLSHit from single neutrino interaction.
Definition: FLSHitList.h:13
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
A (plane, cell) pair.
Definition: OfflineChan.h:17
void SetTimeMean(double t)
Definition: PhotonSignal.h:22
enum BeamMode string
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

double photrans::PhotonSystRewriter::fCerenkovEffShift
protected

Definition at line 41 of file PhotonSystRewriter_module.cc.

Referenced by produce().

std::string photrans::PhotonSystRewriter::fGeantLabel
protected

Definition at line 38 of file PhotonSystRewriter_module.cc.

Referenced by produce().

std::string photrans::PhotonSystRewriter::fGeneratorProcessName
protected

Definition at line 37 of file PhotonSystRewriter_module.cc.

Referenced by produce().

double photrans::PhotonSystRewriter::fPhotonsPerMeVShift
protected

Definition at line 41 of file PhotonSystRewriter_module.cc.

Referenced by produce().

std::string photrans::PhotonSystRewriter::fPhotonTransportLabel
protected

Definition at line 39 of file PhotonSystRewriter_module.cc.

Referenced by produce().

CLHEP::RandPoissonQ* photrans::PhotonSystRewriter::fPoisson
protected

Definition at line 44 of file PhotonSystRewriter_module.cc.

Referenced by PhotonSystRewriter(), produce(), and ~PhotonSystRewriter().

double photrans::PhotonSystRewriter::fXViewFactorShift
protected

Definition at line 42 of file PhotonSystRewriter_module.cc.

Referenced by produce().

double photrans::PhotonSystRewriter::fYViewFactorShift
protected

Definition at line 42 of file PhotonSystRewriter_module.cc.

Referenced by produce().


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