LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
evgen::CosmicsGen Class Reference

A module to check the results from the Monte Carlo generator. More...

Inheritance diagram for evgen::CosmicsGen:
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

 CosmicsGen (fhicl::ParameterSet const &pset)
 
virtual ~CosmicsGen ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
void reconfigure (fhicl::ParameterSet const &p)
 
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< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (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< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (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< T > mayConsumeView (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
 

Private Attributes

evgb::CRYHelperfCRYHelp
 CRY generator object. More...
 
std::vector< double > fbuffbox
 
TH2F * fPhotonAngles
 Photon rate vs angle. More...
 
TH2F * fPhotonAnglesLo
 Photon rate vs angle, low momenta. More...
 
TH2F * fPhotonAnglesMi
 Photon rate vs angle, middle momenta. More...
 
TH2F * fPhotonAnglesHi
 Photon rate vs angle, high momenta. More...
 
TH1F * fPhotonCosQ
 Photon rate vs cos(Q) More...
 
TH1F * fPhotonEnergy
 Photon energy (GeV) More...
 
TH1F * fPhotonsPerSample
 number of photons in the sampled time window More...
 
TH1F * fPhotonsInCStat
 
TH1F * fPhotonsInTPC
 
TH2F * fElectronAngles
 Electron rate vs angle. More...
 
TH2F * fElectronAnglesLo
 Electron rate vs angle, low momenta. More...
 
TH2F * fElectronAnglesMi
 Electron rate vs angle, middle momenta. More...
 
TH2F * fElectronAnglesHi
 Electron rate vs angle, high momenta. More...
 
TH1F * fElectronCosQ
 Electron rate vs cos(Q) More...
 
TH1F * fElectronEnergy
 Electron energy (GeV) More...
 
TH1F * fElectronsPerSample
 number of electrons in the sampled time window More...
 
TH1F * fElectronsInCStat
 
TH1F * fElectronsInTPC
 
TH2F * fMuonAngles
 Muon rate vs angle. More...
 
TH2F * fMuonAnglesLo
 Muon rate vs angle, low momenta. More...
 
TH2F * fMuonAnglesMi
 Muon rate vs angle, middle momenta. More...
 
TH2F * fMuonAnglesHi
 Muon rate vs angle, high momenta. More...
 
TH1F * fMuonCosQ
 Muon rate vs cos(Q) More...
 
TH1F * fMuonEnergy
 Muon energy (GeV) More...
 
TH1F * fMuonsPerSample
 number of muons in the sampled time window More...
 
TH1F * fMuonsInCStat
 
TH1F * fMuonsInTPC
 

Detailed Description

A module to check the results from the Monte Carlo generator.

Definition at line 46 of file CosmicsGen_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

evgen::CosmicsGen::CosmicsGen ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 105 of file CosmicsGen_module.cc.

References art::EngineCreator::createEngine(), fbuffbox, fhicl::ParameterSet::get(), and reconfigure().

106  : fCRYHelp(0)
107  {
108  // create a default random engine; obtain the random seed from NuRandomService,
109  // unless overridden in configuration with key "Seed"
111  ->createEngine(*this, pset, "Seed");
112 
113  //the buffer box bounds specified here will extend on the cryostat boundaries
114  fbuffbox = pset.get< std::vector<double> >("BufferBox",{0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
115 
116  this->reconfigure(pset);
117 
118  produces< std::vector<simb::MCTruth> >();
119  produces< sumdata::RunData, art::InRun >();
120  }
void reconfigure(fhicl::ParameterSet const &p)
evgb::CRYHelper * fCRYHelp
CRY generator object.
base_engine_t & createEngine(seed_t seed)
std::vector< double > fbuffbox
evgen::CosmicsGen::~CosmicsGen ( )
virtual

Definition at line 123 of file CosmicsGen_module.cc.

References fCRYHelp.

124  {
125  if(fCRYHelp) delete fCRYHelp;
126  }
evgb::CRYHelper * fCRYHelp
CRY generator object.

Member Function Documentation

void evgen::CosmicsGen::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 148 of file CosmicsGen_module.cc.

References fElectronAngles, fElectronAnglesHi, fElectronAnglesLo, fElectronAnglesMi, fElectronCosQ, fElectronEnergy, fElectronsInCStat, fElectronsInTPC, fElectronsPerSample, fMuonAngles, fMuonAnglesHi, fMuonAnglesLo, fMuonAnglesMi, fMuonCosQ, fMuonEnergy, fMuonsInCStat, fMuonsInTPC, fMuonsPerSample, fPhotonAngles, fPhotonAnglesHi, fPhotonAnglesLo, fPhotonAnglesMi, fPhotonCosQ, fPhotonEnergy, fPhotonsInCStat, fPhotonsInTPC, fPhotonsPerSample, and art::TFileDirectory::make().

149  {
151 
152  fPhotonAngles = tfs->make<TH2F>("fPhotonAngles", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
153  fPhotonAnglesLo = tfs->make<TH2F>("fPhotonAnglesLo", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
154  fPhotonAnglesMi = tfs->make<TH2F>("fPhotonAnglesMi", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
155  fPhotonAnglesHi = tfs->make<TH2F>("fPhotonAnglesHi", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
156  fPhotonCosQ = tfs->make<TH1F>("fPhotonCosQ", ";cos#theta;tracks", 50,-1.0,1.0);
157  fPhotonEnergy = tfs->make<TH1F>("fPhotonEnergy", ";E (GeV)", 5000,0.0,1000.0);
158  fPhotonsPerSample = tfs->make<TH1F>("fPhotonsPerSample", ";Number Photons;Samples", 100, 0, 1000);
159  fPhotonsInCStat = tfs->make<TH1F>("fPhotonsInCryostat", ";Number Photons;Samples", 100, 0, 1000);
160  fPhotonsInTPC = tfs->make<TH1F>("fPhotonsInTPC", ";Number Photons;Samples", 100, 0, 1000);
161 
162  fElectronAngles = tfs->make<TH2F>("fElectronAngles", ";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
163  fElectronAnglesLo = tfs->make<TH2F>("fElectronAnglesLo", ";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
164  fElectronAnglesMi = tfs->make<TH2F>("fElectronAnglesMi", ";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
165  fElectronAnglesHi = tfs->make<TH2F>("fElectronAnglesHi", ";#phi;cos#theta",36,-180.0,180.0,50,-1.0,1.0);
166  fElectronCosQ = tfs->make<TH1F>("fElectronCosQ", ";cos#theta;tracks",50,-1.0,1.0);
167  fElectronEnergy = tfs->make<TH1F>("fElectronEnergy", ";E (GeV)", 5000,0.0,1000.0);
168  fElectronsPerSample = tfs->make<TH1F>("fElectronsPerSample", ";Number Electrons;Samples", 100, 0, 1000);
169  fElectronsInCStat = tfs->make<TH1F>("fElectronsInCryotat", ";Number Electrons;Samples", 100, 0, 1000);
170  fElectronsInTPC = tfs->make<TH1F>("fElectronsInTPC", ";Number Electrons;Samples", 100, 0, 1000);
171 
172  fMuonAngles = tfs->make<TH2F>("fMuonAngles", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
173  fMuonAnglesLo = tfs->make<TH2F>("fMuonAnglesLo", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
174  fMuonAnglesMi = tfs->make<TH2F>("fMuonAnglesMi", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
175  fMuonAnglesHi = tfs->make<TH2F>("fMuonAnglesHi", ";#phi;cos#theta", 36,-180.0,180.0,50,-1.0,1.0);
176  fMuonCosQ = tfs->make<TH1F>("fMuonCosQ", ";cos#theta;tracks",50,-1.0,1.0);
177  fMuonEnergy = tfs->make<TH1F>("fMuonEnergy", ";E (GeV)", 5000,0.0,1000.0);
178  fMuonsPerSample = tfs->make<TH1F>("fMuonsPerSample", ";Number Muons;Samples", 100, 0, 1000);
179  fMuonsInCStat = tfs->make<TH1F>("fMuonsInCryostat", ";Number Muons;Samples", 100, 0, 1000);
180  fMuonsInTPC = tfs->make<TH1F>("fMuonsInTPC", ";Number Muons;Samples", 100, 0, 1000);
181 
182  }
TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
TH2F * fPhotonAngles
Photon rate vs angle.
TH2F * fMuonAnglesHi
Muon rate vs angle, high momenta.
TH1F * fElectronEnergy
Electron energy (GeV)
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
TH2F * fMuonAngles
Muon rate vs angle.
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
TH1F * fMuonCosQ
Muon rate vs cos(Q)
TH1F * fElectronsPerSample
number of electrons in the sampled time window
TH1F * fPhotonsPerSample
number of photons in the sampled time window
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
TH2F * fMuonAnglesMi
Muon rate vs angle, middle momenta.
TH2F * fPhotonAnglesMi
Photon rate vs angle, middle momenta.
TH2F * fPhotonAnglesLo
Photon rate vs angle, low momenta.
T * make(ARGS...args) const
TH2F * fPhotonAnglesHi
Photon rate vs angle, high momenta.
TH1F * fMuonsPerSample
number of muons in the sampled time window
TH1F * fMuonEnergy
Muon energy (GeV)
void evgen::CosmicsGen::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 185 of file CosmicsGen_module.cc.

References geo::GeometryCore::DetectorName(), and art::Run::put().

186  {
187 
188  // grab the geometry object to see what geometry we are using
190 
191  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetectorName()));
192 
193  run.put(std::move(runcol));
194 
195  return;
196  }
art::ProductID put(std::unique_ptr< PROD > &&)
Definition: Run.h:148
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
Namespace collecting geometry-related classes utilities.
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 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

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

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
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_.

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 B, and 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  }
Int_t B
Definition: plot.C:25
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 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
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 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void evgen::CosmicsGen::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 199 of file CosmicsGen_module.cc.

References simb::MCTruth::Add(), bounds(), geo::GeometryCore::CryostatBoundaries(), DEFINE_ART_MODULE, geo::GeometryCore::DetLength(), fbuffbox, fCRYHelp, fElectronAngles, fElectronAnglesHi, fElectronAnglesLo, fElectronAnglesMi, fElectronCosQ, fElectronEnergy, fElectronsInCStat, fElectronsPerSample, fMuonAngles, fMuonAnglesHi, fMuonAnglesLo, fMuonAnglesMi, fMuonCosQ, fMuonEnergy, fMuonsInCStat, fMuonsPerSample, fPhotonAngles, fPhotonAnglesHi, fPhotonAnglesLo, fPhotonAnglesMi, fPhotonCosQ, fPhotonEnergy, fPhotonsInCStat, fPhotonsPerSample, simb::MCTruth::GetParticle(), simb::kCosmicRay, simb::MCParticle::Momentum(), geo::GeometryCore::Ncryostats(), simb::MCTruth::NParticles(), simb::MCParticle::PdgCode(), simb::MCParticle::Position(), art::Event::put(), evgb::CRYHelper::Sample(), simb::MCTruth::SetOrigin(), and geo::GeometryCore::SurfaceY().

200  {
201  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
202 
203  // fill some histograms about this event
205 
206  int nCrossCryostat = 0;
207 
208  simb::MCTruth truth;
209 
210  while(nCrossCryostat < 1){
211 
212  simb::MCTruth pretruth;
214  fCRYHelp->Sample(pretruth,
215  geom->SurfaceY(),
216  geom->DetLength(),
217  0);
218 
219  int numPhotons = 0;
220  int numElectrons = 0;
221  int numMuons = 0;
222  int allPhotons = 0;
223  int allElectrons = 0;
224  int allMuons = 0;
225  // for c2: remove unused variables
226  //int tpcPhotons = 0;
227  //int tpcElectrons = 0;
228  //int tpcMuons = 0;
229 
230  // loop over particles in the truth object
231  for(int i = 0; i < pretruth.NParticles(); ++i){
232  simb::MCParticle particle = pretruth.GetParticle(i);
233  const TLorentzVector& v4 = particle.Position();
234  const TLorentzVector& p4 = particle.Momentum();
235  double x0[3] = {v4.X(), v4.Y(), v4.Z() };
236  double dx[3] = {p4.Px(), p4.Py(), p4.Pz()};
237 
238  if (std::abs(particle.PdgCode())==13) ++allMuons;
239  else if (std::abs(particle.PdgCode())==22) ++allPhotons;
240  else if (std::abs(particle.PdgCode())==11) ++allElectrons;
241 
242  TH1F* hCosQ = 0;
243  TH2F* hAngles = 0;
244  TH2F* hAnglesLo = 0;
245  TH2F* hAnglesMi = 0;
246  TH2F* hAnglesHi = 0;
247  TH1F* hEnergy = 0;
248  if (std::abs(particle.PdgCode())==13) {
249  hCosQ = fMuonCosQ;
250  hAngles = fMuonAngles;
251  hAnglesLo = fMuonAnglesLo;
252  hAnglesMi = fMuonAnglesMi;
253  hAnglesHi = fMuonAnglesHi;
254  hEnergy = fMuonEnergy;
255  }
256  else if (std::abs(particle.PdgCode())==22) {
257  hCosQ = fPhotonCosQ;
258  hAngles = fPhotonAngles;
259  hAnglesLo = fPhotonAnglesLo;
260  hAnglesMi = fPhotonAnglesMi;
261  hAnglesHi = fPhotonAnglesHi;
262  hEnergy = fPhotonEnergy;
263  }
264  else if (std::abs(particle.PdgCode())==11) {
265  hCosQ = fElectronCosQ;
266  hAngles = fElectronAngles;
267  hAnglesLo = fElectronAnglesLo;
268  hAnglesMi = fElectronAnglesMi;
269  hAnglesHi = fElectronAnglesHi;
270  hEnergy = fElectronEnergy;
271  }
272 
273  // now check if the particle goes through any cryostat in the detector
274  // if so, add it to the truth object.
275  for(unsigned int c = 0; c < geom->Ncryostats(); ++c){
276 
277  double bounds[6] = {0.};
278  geom->CryostatBoundaries(bounds, c);
279 
280  //add a buffer box around the cryostat bounds to increase the acceptance
281  //(geometrically) at the CRY level to make up for particles we will loose
282  //due to multiple scattering effects that pitch in during GEANT4 tracking
283  //By default, the buffer box has zero size
284  for (unsigned int cb=0; cb<6; cb++)
285  bounds[cb] = bounds[cb]+fbuffbox[cb];
286 
287  //calculate the intersection point with each cryostat surface
288  bool intersects_cryo = false;
289  for (int bnd=0; bnd!=6; ++bnd) {
290  if (bnd<2) {
291  double p2[3] = {bounds[bnd], x0[1] + (dx[1]/dx[0])*(bounds[bnd] - x0[0]), x0[2] + (dx[2]/dx[0])*(bounds[bnd] - x0[0])};
292  if ( p2[1] >= bounds[2] && p2[1] <= bounds[3] &&
293  p2[2] >= bounds[4] && p2[2] <= bounds[5] ) {
294  intersects_cryo = true;
295  break;
296  }
297  }
298  else if (bnd>=2 && bnd<4) {
299  double p2[3] = {x0[0] + (dx[0]/dx[1])*(bounds[bnd] - x0[1]), bounds[bnd], x0[2] + (dx[2]/dx[1])*(bounds[bnd] - x0[1])};
300  if ( p2[0] >= bounds[0] && p2[0] <= bounds[1] &&
301  p2[2] >= bounds[4] && p2[2] <= bounds[5] ) {
302  intersects_cryo = true;
303  break;
304  }
305  }
306  else if (bnd>=4) {
307  double p2[3] = {x0[0] + (dx[0]/dx[2])*(bounds[bnd] - x0[2]), x0[1] + (dx[1]/dx[2])*(bounds[bnd] - x0[2]), bounds[bnd]};
308  if ( p2[0] >= bounds[0] && p2[0] <= bounds[1] &&
309  p2[1] >= bounds[2] && p2[1] <= bounds[3] ) {
310  intersects_cryo = true;
311  break;
312  }
313  }
314  }
315 
316 
317  if (intersects_cryo) {
318  truth.Add(particle);
319 
320  if (std::abs(particle.PdgCode())==13) ++numMuons;
321  else if (std::abs(particle.PdgCode())==22) ++numPhotons;
322  else if (std::abs(particle.PdgCode())==11) ++numElectrons;
323 
324  //The following code no longer works now that we require intersection with the cryostat boundary
325  //For example, the particle could intersect this cryostat but miss its TPC, but intersect a TPC
326  //in another cryostat
327  /*try{
328  unsigned int tpc = 0;
329  unsigned int cstat = 0;
330  geom->PositionToTPC(x2, tpc, cstat);
331  if (std::abs(particle.PdgCode())==13) ++tpcMuons;
332  else if (std::abs(particle.PdgCode())==22) ++tpcPhotons;
333  else if (std::abs(particle.PdgCode())==11) ++tpcElectrons;
334  }
335  catch(cet::exception &e){
336  LOG_DEBUG("CosmicsGen") << "current particle does not go through any tpc";
337  }*///
338 
339  if (hCosQ!=0) {
340  double cosq = -p4.Py()/p4.P();
341  double phi = std::atan2(p4.Pz(),p4.Px());
342  phi *= 180/M_PI;
343  hCosQ->Fill(cosq);
344  hAngles->Fill(phi,cosq);
345  if (p4.E()<1.0) hAnglesLo->Fill(phi,cosq);
346  else if (p4.E()<10.0) hAnglesMi->Fill(phi,cosq);
347  else hAnglesHi->Fill(phi,cosq);
348  hEnergy->Fill(p4.E());
349  }//end if there is a cos(theta) histogram
350  break; //leave loop over cryostats to avoid adding particle multiple times
351  }// end if particle goes into a cryostat
352  }// end loop over cryostats in the detector
353 
354  }// loop on particles
355 
356  nCrossCryostat = truth.NParticles();
357 
358  fPhotonsPerSample ->Fill(allPhotons);
359  fElectronsPerSample->Fill(allElectrons);
360  fMuonsPerSample ->Fill(allMuons);
361 
362  fPhotonsInCStat ->Fill(numPhotons);
363  fElectronsInCStat->Fill(numElectrons);
364  fMuonsInCStat ->Fill(numMuons);
365 
366  /*fPhotonsInTPC ->Fill(tpcPhotons);
367  fElectronsInTPC->Fill(tpcElectrons);
368  fMuonsInTPC ->Fill(tpcMuons);*/
369  }
370 
371  truthcol->push_back(truth);
372  evt.put(std::move(truthcol));
373 
374  return;
375  }// end produce
TH2F * fElectronAnglesHi
Electron rate vs angle, high momenta.
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:223
TH2F * fPhotonAngles
Photon rate vs angle.
int PdgCode() const
Definition: MCParticle.h:216
TH2F * fMuonAnglesHi
Muon rate vs angle, high momenta.
TH1F * fElectronEnergy
Electron energy (GeV)
TH2F * fElectronAnglesLo
Electron rate vs angle, low momenta.
TH2F * fElectronAngles
Electron rate vs angle.
TH1F * fElectronCosQ
Electron rate vs cos(Q)
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:78
TH2F * fMuonAngles
Muon rate vs angle.
TH2F * fMuonAnglesLo
Muon rate vs angle, low momenta.
TH1F * fPhotonEnergy
Photon energy (GeV)
int NParticles() const
Definition: MCTruth.h:72
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
TH2F * fElectronAnglesMi
Electron rate vs angle, middle momenta.
void Add(simb::MCParticle &part)
Definition: MCTruth.h:77
TH1F * fMuonCosQ
Muon rate vs cos(Q)
TH1F * fElectronsPerSample
number of electrons in the sampled time window
void CryostatBoundaries(double *boundaries, geo::CryostatID const &cid) const
Returns the boundaries of the specified cryostat.
TH1F * fPhotonsPerSample
number of photons in the sampled time window
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
evgb::CRYHelper * fCRYHelp
CRY generator object.
double Sample(simb::MCTruth &mctruth, double const &surfaceY, double const &detectorLength, double *w, double rantime=0)
Definition: CRYHelper.cxx:97
TH1F * fPhotonCosQ
Photon rate vs cos(Q)
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
geo::Length_t SurfaceY() const
The position of the detector respect to earth surface.
TH2F * fMuonAnglesMi
Muon rate vs angle, middle momenta.
std::vector< double > fbuffbox
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:73
TH2F * fPhotonAnglesMi
Photon rate vs angle, middle momenta.
TH2F * fPhotonAnglesLo
Photon rate vs angle, low momenta.
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:224
TH2F * fPhotonAnglesHi
Photon rate vs angle, high momenta.
Event generator information.
Definition: MCTruth.h:30
TH1F * fMuonsPerSample
number of muons in the sampled time window
TH1F * fMuonEnergy
Muon energy (GeV)
BoundingBox bounds(int x, int y, int w, int h)
Definition: main.cpp:37
Cosmic rays.
Definition: MCTruth.h:22
void evgen::CosmicsGen::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 129 of file CosmicsGen_module.cc.

References fCRYHelp, art::RandomNumberGenerator::getEngine(), geo::GeometryCore::GetWorldVolumeName(), and art::EngineCreator::rng().

Referenced by CosmicsGen().

130  {
131  if(fCRYHelp){
132  delete fCRYHelp;
133  fCRYHelp = 0;
134  }
135 
136  // get the random number generator service and make some CLHEP generators
138  CLHEP::HepRandomEngine& engine = rng->getEngine();
139 
141 
142  fCRYHelp = new evgb::CRYHelper(p, engine, geo->GetWorldVolumeName());
143 
144  return;
145  }
Interface to the CRY cosmic-ray generator.
Definition: CRYHelper.h:26
const std::string GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
evgb::CRYHelper * fCRYHelp
CRY generator object.
base_engine_t & getEngine() const
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
Namespace collecting geometry-related classes utilities.
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

std::vector<double> evgen::CosmicsGen::fbuffbox
private

Definition at line 61 of file CosmicsGen_module.cc.

Referenced by CosmicsGen(), and produce().

evgb::CRYHelper* evgen::CosmicsGen::fCRYHelp
private

CRY generator object.

Definition at line 59 of file CosmicsGen_module.cc.

Referenced by produce(), reconfigure(), and ~CosmicsGen().

TH2F* evgen::CosmicsGen::fElectronAngles
private

Electron rate vs angle.

Definition at line 75 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesHi
private

Electron rate vs angle, high momenta.

Definition at line 78 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesLo
private

Electron rate vs angle, low momenta.

Definition at line 76 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fElectronAnglesMi
private

Electron rate vs angle, middle momenta.

Definition at line 77 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronCosQ
private

Electron rate vs cos(Q)

Definition at line 79 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronEnergy
private

Electron energy (GeV)

Definition at line 80 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronsInCStat
private

number of electrons in the cryostat during the sampled time window

Definition at line 82 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fElectronsInTPC
private

number of electrons in the tpc during the sampled time window

Definition at line 84 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fElectronsPerSample
private

number of electrons in the sampled time window

Definition at line 81 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAngles
private

Muon rate vs angle.

Definition at line 87 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesHi
private

Muon rate vs angle, high momenta.

Definition at line 90 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesLo
private

Muon rate vs angle, low momenta.

Definition at line 88 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fMuonAnglesMi
private

Muon rate vs angle, middle momenta.

Definition at line 89 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonCosQ
private

Muon rate vs cos(Q)

Definition at line 91 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonEnergy
private

Muon energy (GeV)

Definition at line 92 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonsInCStat
private

number of muons in the cryostat during the sampled time window

Definition at line 94 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fMuonsInTPC
private

number of muons in the tpc during the sampled time window

Definition at line 96 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fMuonsPerSample
private

number of muons in the sampled time window

Definition at line 93 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAngles
private

Photon rate vs angle.

Definition at line 63 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesHi
private

Photon rate vs angle, high momenta.

Definition at line 66 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesLo
private

Photon rate vs angle, low momenta.

Definition at line 64 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH2F* evgen::CosmicsGen::fPhotonAnglesMi
private

Photon rate vs angle, middle momenta.

Definition at line 65 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonCosQ
private

Photon rate vs cos(Q)

Definition at line 67 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonEnergy
private

Photon energy (GeV)

Definition at line 68 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonsInCStat
private

number of photons in the cryostat during the sampled time window

Definition at line 70 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().

TH1F* evgen::CosmicsGen::fPhotonsInTPC
private

number of photons in the tpc during the sampled time window

Definition at line 72 of file CosmicsGen_module.cc.

Referenced by beginJob().

TH1F* evgen::CosmicsGen::fPhotonsPerSample
private

number of photons in the sampled time window

Definition at line 69 of file CosmicsGen_module.cc.

Referenced by beginJob(), and produce().


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