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

module to produce single or multiple specified particles in the detector More...

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

 FileMuons (fhicl::ParameterSet const &pset)
 
virtual ~FileMuons ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void beginRun (art::Run &run)
 
void endJob ()
 
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 Member Functions

void ReadEvents (simb::MCTruth &mct)
 

Private Attributes

int fEventNumberOffset
 
std::vector< int > fPDG
 
std::vector< double > fXYZ_Off
 
std::string fFileName
 
std::string fMuonsFileType
 
std::string fTreeName
 
std::vector< std::string > fBranchNames
 
std::ifstream * fMuonFile
 
TFile * fMuonFileR
 
TTree * TNtuple
 
unsigned int countFile
 
Float_t xtmp
 
Float_t ytmp
 
Float_t ztmp
 
Float_t pxtmp
 
Float_t pytmp
 
Float_t pztmp
 
Float_t charge
 
Float_t E
 
Float_t costheta
 
Float_t phi
 
Float_t xdet
 
Float_t ydet
 
Float_t zdet
 
TBranch * b_x
 
TBranch * b_y
 
TBranch * b_z
 
TBranch * b_E
 
TBranch * b_costheta
 
TBranch * b_phi
 
TBranch * b_xdet
 
TBranch * b_ydet
 
TBranch * b_zdet
 
TBranch * b_px
 
TBranch * b_py
 
TBranch * b_pz
 
TBranch * b_charge
 

Detailed Description

module to produce single or multiple specified particles in the detector

Definition at line 53 of file FileMuons_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::FileMuons::FileMuons ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 115 of file FileMuons_module.cc.

116  : fEventNumberOffset(pset.get< int >("EventNumberOffset"))
117  , fPDG (pset.get< std::vector<int> >("PDG") )
118  , fXYZ_Off (pset.get< std::vector<double> >("InitialXYZOffsets"))
119  , fFileName (pset.get< std::string >("FileName") )
120  , fMuonsFileType (pset.get< std::string >("MuonsFileType") )
121  , fTreeName (pset.get< std::string >("TreeName") )
122  , fBranchNames (pset.get< std::vector<std::string> >("BranchNames") )
123  {
124 
125  produces< std::vector<simb::MCTruth> >();
126  produces< sumdata::RunData, art::InRun >();
127 
128  }
std::vector< double > fXYZ_Off
std::string fMuonsFileType
std::vector< std::string > fBranchNames
std::string fFileName
std::vector< int > fPDG
std::string fTreeName
evgen::FileMuons::~FileMuons ( )
virtual

Definition at line 219 of file FileMuons_module.cc.

220  {
221  }

Member Function Documentation

void evgen::FileMuons::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 131 of file FileMuons_module.cc.

References b_charge, b_costheta, b_E, b_phi, b_px, b_py, b_pz, b_x, b_xdet, b_y, b_ydet, b_z, b_zdet, evd::details::begin(), charge, costheta, countFile, E, evd::details::end(), fEventNumberOffset, fFileName, fMuonFile, fMuonFileR, fMuonsFileType, fTreeName, phi, pxtmp, pytmp, pztmp, TNtuple, xdet, xtmp, ydet, ytmp, zdet, and ztmp.

132  {
134  mf::LogInfo("FileMuons : starting at event ") << countFile <<std::endl;
135 
136  if (fMuonsFileType.compare("source")==0)
137  {
138  std::cout << "FileMuons: Not yet equipped to walk through muons with TFS mojo."<< std::endl;
139  }
140  else if (fMuonsFileType.compare("root")==0)
141  {
142  std::cout << "FileMuons: You have chosen to read muons from Root File " << fFileName << std::endl;
143  }
144  else if (fMuonsFileType.compare("text")==0)
145  {
146  std::cout << "FileMuons: You have chosen to read muons from " << fFileName << "." << std::endl;
147  }
148  else
149  {
150  std::cout << "FileMuons: You must specify one of source/text/root file to read for muons."<< std::endl;
151 
152  }
153 
154  if (fMuonsFileType.compare("text")==0)
155  {
156  fMuonFile = new std::ifstream(fFileName.c_str());
157  long begin = fMuonFile->tellg();
158  fMuonFile->seekg (0, std::ios::end);
159  long end = fMuonFile->tellg();
160  std::cout << "FileMuons: " << fFileName << " size is: " << (end-begin) << " bytes.\n";
161  fMuonFile->seekg (0, std::ios::beg);
162 
163  for (unsigned int header=0; header<3 && fMuonFile->good(); ++header)
164  {
165  std::string line;
166  getline(*fMuonFile,line);
167  }
168  if (!fMuonFile->good())
169  {
170  std::cout << "FileMuons: Problem reading muon file header."<< std::endl;
171  }
172  } // fMuonsFileType is a text file.
173  else if (fMuonsFileType.compare("root")==0)
174  {
175  fMuonFileR = new TFile(fFileName.c_str(),"READ");
176  TNtuple = (TTree*)(fMuonFileR->Get(fTreeName.c_str()));
177 
178  TNtuple->SetBranchAddress("x", &xtmp, &b_x);
179  TNtuple->SetBranchAddress("y", &ytmp, &b_y);
180  TNtuple->SetBranchAddress("z", &ztmp, &b_z);
181  TNtuple->SetBranchAddress("E", &E, &b_E);
182  TNtuple->SetBranchAddress("costheta", &costheta, &b_costheta);
183  TNtuple->SetBranchAddress("phi", &phi, &b_phi);
184  TNtuple->SetBranchAddress("xdet", &xdet, &b_xdet);
185  TNtuple->SetBranchAddress("ydet", &ydet, &b_ydet);
186  TNtuple->SetBranchAddress("zdet", &zdet, &b_zdet);
187  TNtuple->SetBranchAddress("px", &pxtmp, &b_px);
188  TNtuple->SetBranchAddress("py", &pytmp, &b_py);
189  TNtuple->SetBranchAddress("pz", &pztmp, &b_pz);
190  TNtuple->SetBranchAddress("charge", &charge, &b_charge);
191 
192  } // fMuonsFileType is a root file.
193 
194  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fMuonsFileType
std::ifstream * fMuonFile
unsigned int countFile
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::string fFileName
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::string fTreeName
void evgen::FileMuons::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 206 of file FileMuons_module.cc.

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

207  {
208 
209  // grab the geometry object to see what geometry we are using
211  std::unique_ptr<sumdata::RunData> runcol(new sumdata::RunData(geo->DetectorName()));
212 
213  run.put(std::move(runcol));
214 
215  return;
216  }
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
void evgen::FileMuons::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 197 of file FileMuons_module.cc.

References fMuonFile, fMuonFileR, and fMuonsFileType.

198  {
199  if (fMuonsFileType.compare("text")==0)
200  fMuonFile->close();
201  if (fMuonsFileType.compare("root")==0)
202  fMuonFileR->Close();
203  }
std::string fMuonsFileType
std::ifstream * fMuonFile
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::FileMuons::produce ( art::Event evt)
virtual

unique_ptr allows ownership to be transferred to the art::Event after the put statement

Implements art::EDProducer.

Definition at line 224 of file FileMuons_module.cc.

References simb::kSingleParticle, art::Event::put(), ReadEvents(), and simb::MCTruth::SetOrigin().

225  {
226 
228  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
229 
230  simb::MCTruth truth;
232  ReadEvents(truth);
233 
234 // std::cout << "put mctruth into the vector" << std::endl;
235  truthcol->push_back(truth);
236 
237 // std::cout << "add vector to the event " << truthcol->size() << std::endl;
238  evt.put(std::move(truthcol));
239 
240  return;
241  }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:78
void ReadEvents(simb::MCTruth &mct)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
single particles thrown at the detector
Definition: MCTruth.h:24
Event generator information.
Definition: MCTruth.h:30
void evgen::FileMuons::ReadEvents ( simb::MCTruth mct)
private

every event will have one of each particle species in the fPDG array

Definition at line 244 of file FileMuons_module.cc.

References simb::MCTruth::Add(), simb::MCParticle::AddTrajectoryPoint(), charge, countFile, geo::GeometryCore::CryostatHalfHeight(), geo::GeometryCore::CryostatHalfWidth(), geo::GeometryCore::CryostatLength(), DEFINE_ART_MODULE, fFileName, fMuonFile, fMuonsFileType, fPDG, fXYZ_Off, LOG_DEBUG, part, pxtmp, pytmp, pztmp, TNtuple, x, xdet, ydet, and zdet.

Referenced by produce().

245  {
246 
247 // std::cout << "size of particle vector is " << fPDG.size() << std::endl;
248 
250  for (unsigned int i=0; i<fPDG.size(); ++i) {
251 
252  // Choose momentum
253  //double p = 0.0;
254  double m(0.108);
255 
256  TVector3 x;
257  TVector3 p;
258  Double_t q = 0.;
259  Int_t pdgLocal;
260 
261  if (fMuonsFileType.compare("text")==0)
262  {
263 
264  std::string line;
265  getline(*fMuonFile,line);
266  if (!fMuonFile->good())
267  {
268  std::cout << "FileMuons: Problem reading muon file line ...."<< countFile << ". Perhaps you've exhausted the events in " << fFileName << std::endl; exit(0);
269  }
270  else
271  {
272  // std::cout << "FileMuons: getline() gives "<< line << " for event " << countFile << std::endl;
273  }
274  countFile++;
275 
276  LOG_DEBUG("FileMuons: countFile is ") << countFile <<std::endl;
277  char * cstr, *ptok;
278 
279  // Split this line into tokens
280  cstr = new char [line.size()+1];
281  strcpy (cstr, line.c_str());
282  // cstr now contains a c-string copy of str
283  ptok=strtok (cstr,"*");
284  unsigned int fieldCount = 0;
285  unsigned int posIndex = 0;
286  unsigned int pIndex = 0;
287  while (ptok!=NULL)
288  {
289  // std::cout << ptok << std::endl;
290  ptok=strtok(NULL,"*");
291  if (fieldCount==9 || fieldCount==10 || fieldCount==11)
292  {
293  p[pIndex] = atof(ptok); pIndex++;
294  // std::cout << ptok << std::endl;
295  }
296  if (fieldCount==6 || fieldCount==7 || fieldCount==8)
297  {
298  x[posIndex] = atof(ptok);
299  // make the z axis point up for x, as with p
300  if (posIndex==2) {x[posIndex] = -1.0*x[posIndex];}
301  posIndex++;
302  }
303  if (fieldCount==12)
304  {
305  q = atof(ptok);
306  }
307  fieldCount++;
308  }
309 
310  delete[] cstr;
311 
312  }
313  else if (fMuonsFileType.compare("root")==0) // from root file
314  {
315  /*
316  // Don't use this yet. Keep the specific branch-by-branch identification.
317  for (unsigned int ii=0;ii<fBranchNames.size();ii++)
318  {
319  TNtuple->SetBranchAddress(fBranchNames[ii], x+ii);
320  }
321  */
322  // TNtuple->ResetBranchAddresses();
323  TNtuple->GetEntry(countFile);
324  //TNtuple->Show(countFile);
325 
326  x.SetXYZ(xdet,ydet,-zdet); // as with txt file, make z point up.
327  // Watch for units change to mm in Modern JdJ files!!
328  // This is for pre Spring-2012 JdJ Ntuples.
329  p.SetXYZ(pxtmp,pytmp,pztmp);
330  q = charge;
331 
332  countFile++;
333 
334  } // End read.
335 
336  static TDatabasePDG pdgt;
337  pdgLocal = -q*fPDG[i];
338 
339  TParticlePDG* pdgp = pdgt.GetParticle(pdgLocal);
340  if (pdgp) m = pdgp->Mass();
341 
342 
343  // std::cout << "set the position "<<std::endl;
344  // This gives coordinates at the center of the 300mx300m plate that is 3m above top of
345  // cavern. Got these by histogramming deJong's xdet,ydet,zdet.
346  const double cryoGap = 15.0;
347  x[0] -= fXYZ_Off[0];
348  x[1] -= fXYZ_Off[1];
349  x[2] -= fXYZ_Off[2]; // 3 for plate height above top of cryostat.
350  // Now, must rotate to TPC coordinates. Let's orient TPC axis along z axis,
351  // Cosmics, mostly going along deJong's +z axis must be going along TPC -y axis.
352  x.RotateX(-M_PI/2);
353  p.RotateX(-M_PI/2);
354  //add vector of the position of the center of the point between Cryostats
355  // level with top. (To which I've added 3m - in above code - in height.)
356  // This is referenced from origin at center-right of first cryostat.
358  TVector3 off3(geom->CryostatHalfWidth()*0.01,geom->CryostatHalfHeight()*0.01,geom->CryostatLength()*0.01+cryoGap*0.01/2.0) ;
359  x += off3;
360 
361  TLorentzVector pos(x[0]*100.0, x[1]*100.0, x[2]*100.0, 0.0);
362  TLorentzVector pvec(p[0]*1000.0,p[1]*1000.0,p[2]*1000.0,std::sqrt(p.Mag2()*1000.0*1000.0+m*m));
363  std::cout << "x[m] and p [TeV] are " << std::endl;
364  x.Print();
365  p.Print();
366 
367  int trackid = -1*(i+1); // set track id to -i as these are all primary particles and have id <= 0
368  std::string primary("primary");
369  simb::MCParticle part(trackid, pdgLocal, primary);
370  part.AddTrajectoryPoint(pos, pvec);
371 
372  // std::cout << "add the particle to the primary" << std::endl;
373 
374  mct.Add(part);
375 
376  }//end loop over particles
377 
378  return;
379  }
Float_t x
Definition: compare.C:6
std::vector< double > fXYZ_Off
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
std::string fMuonsFileType
std::ifstream * fMuonFile
void Add(simb::MCParticle &part)
Definition: MCTruth.h:77
unsigned int countFile
TString part[npart]
Definition: Style.C:32
std::string fFileName
geo::Length_t CryostatHalfWidth(geo::CryostatID const &cid) const
Returns the half width of the cryostat (x direction)
#define LOG_DEBUG(id)
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
std::vector< int > fPDG
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

TBranch* evgen::FileMuons::b_charge
private

Definition at line 104 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_costheta
private

Definition at line 96 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_E
private

Definition at line 95 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_phi
private

Definition at line 97 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_px
private

Definition at line 101 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_py
private

Definition at line 102 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_pz
private

Definition at line 103 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_x
private

Definition at line 92 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_xdet
private

Definition at line 98 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_y
private

Definition at line 93 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_ydet
private

Definition at line 99 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_z
private

Definition at line 94 of file FileMuons_module.cc.

Referenced by beginJob().

TBranch* evgen::FileMuons::b_zdet
private

Definition at line 100 of file FileMuons_module.cc.

Referenced by beginJob().

Float_t evgen::FileMuons::charge
private

Definition at line 84 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::costheta
private

Definition at line 86 of file FileMuons_module.cc.

Referenced by beginJob().

unsigned int evgen::FileMuons::countFile
private

Definition at line 80 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::E
private

Definition at line 85 of file FileMuons_module.cc.

Referenced by beginJob().

std::vector<std::string> evgen::FileMuons::fBranchNames
private

Definition at line 75 of file FileMuons_module.cc.

int evgen::FileMuons::fEventNumberOffset
private

Definition at line 69 of file FileMuons_module.cc.

Referenced by beginJob().

std::string evgen::FileMuons::fFileName
private

Definition at line 72 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

std::ifstream* evgen::FileMuons::fMuonFile
private

Definition at line 77 of file FileMuons_module.cc.

Referenced by beginJob(), endJob(), and ReadEvents().

TFile* evgen::FileMuons::fMuonFileR
private

Definition at line 78 of file FileMuons_module.cc.

Referenced by beginJob(), and endJob().

std::string evgen::FileMuons::fMuonsFileType
private

Definition at line 73 of file FileMuons_module.cc.

Referenced by beginJob(), endJob(), and ReadEvents().

std::vector<int> evgen::FileMuons::fPDG
private

Definition at line 70 of file FileMuons_module.cc.

Referenced by ReadEvents().

std::string evgen::FileMuons::fTreeName
private

Definition at line 74 of file FileMuons_module.cc.

Referenced by beginJob().

std::vector<double> evgen::FileMuons::fXYZ_Off
private

Definition at line 71 of file FileMuons_module.cc.

Referenced by ReadEvents().

Float_t evgen::FileMuons::phi
private

Definition at line 87 of file FileMuons_module.cc.

Referenced by beginJob().

Float_t evgen::FileMuons::pxtmp
private

Definition at line 83 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::pytmp
private

Definition at line 83 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::pztmp
private

Definition at line 83 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

TTree* evgen::FileMuons::TNtuple
private

Definition at line 79 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::xdet
private

Definition at line 88 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::xtmp
private

Definition at line 82 of file FileMuons_module.cc.

Referenced by beginJob().

Float_t evgen::FileMuons::ydet
private

Definition at line 89 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::ytmp
private

Definition at line 82 of file FileMuons_module.cc.

Referenced by beginJob().

Float_t evgen::FileMuons::zdet
private

Definition at line 90 of file FileMuons_module.cc.

Referenced by beginJob(), and ReadEvents().

Float_t evgen::FileMuons::ztmp
private

Definition at line 82 of file FileMuons_module.cc.

Referenced by beginJob().


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