Classes | Public Types | Public Member Functions | Public Attributes | List of all members
evgendp::DataGen311 Class Reference
Inheritance diagram for evgendp::DataGen311:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 
- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 

Public Member Functions

 DataGen311 (Parameters const &config)
 
 DataGen311 (DataGen311 const &)=delete
 
 DataGen311 (DataGen311 &&)=delete
 
DataGen311operator= (DataGen311 const &)=delete
 
DataGen311operator= (DataGen311 &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Public Attributes

int fEventsToProcess
 
int fStartEvent
 
int fPDG
 
bool fGetEnergyFromCORSIKA
 
double fUniformEnergyMin
 
double fUniformEnergyMax
 
std::string fTrackFile
 
std::string fHistFile
 
std::map< int, std::vector< Track * > > fEventTrackMap
 

Additional Inherited Members

- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 116 of file DataGen311_module.cc.

Member Typedef Documentation

Definition at line 167 of file DataGen311_module.cc.

Constructor & Destructor Documentation

evgendp::DataGen311::DataGen311 ( Parameters const &  config)
explicit

Definition at line 198 of file DataGen311_module.cc.

199  : EDProducer{config},
200  fEventsToProcess (config().EventsToProcess()),
201  fStartEvent (config().StartEvent()),
202  fPDG (config().PDG()),
203  fGetEnergyFromCORSIKA (config().GetEnergyFromCORSIKA()),
204  fUniformEnergyMin (config().UniformEnergyMin()),
205  fUniformEnergyMax (config().UniformEnergyMax()),
206  fTrackFile (config().TrackFile()),
207  fHistFile (config().HistFile())
208 {
209  produces< std::vector<simb::MCTruth> >();
210  produces< sumdata::RunData, art::InRun >();
211 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
const uint PDG
Definition: qregexp.cpp:140
static Config * config
Definition: config.cpp:1054
evgendp::DataGen311::DataGen311 ( DataGen311 const &  )
delete
evgendp::DataGen311::DataGen311 ( DataGen311 &&  )
delete

Member Function Documentation

void evgendp::DataGen311::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 217 of file DataGen311_module.cc.

217  {
218 
219  //Random number generator for particle energy
220  gRandom = new TRandom3();
221 
222  //read the files and store the information on the map
223  std::ifstream trackfile;
224  trackfile.open( fTrackFile );
225  if( !trackfile.is_open() )
226  throw cet::exception("DataGen311") << "Can't open file " << fTrackFile <<"\n";
227 
228  TFile *chistfile = new TFile(fHistFile.c_str());
229  if( chistfile->IsOpen() == kFALSE )
230  throw cet::exception("DataGen311") << "Can't open file " << fHistFile <<"\n";
231 
232  std::stringstream hetss;
233  hetss << "hEnergyTheta" << fPDG;
234  TH2D *hEnergyTheta = (TH2D*)chistfile->Get(hetss.str().c_str());
235 
236  int eventBefore=0;
237  int eventCounter=0;
238  int trackCounter=0, skippedTrackCounter=0;
240  std::getline(trackfile, line); // Skip header
241  while(std::getline( trackfile, line )){
242  std::stringstream sstream(line);
243 
244  int eventID = 9999999;
245  sstream >> eventID;
246  if (eventID < fStartEvent) {
247  continue;
248  } else if (eventID >= fStartEvent+fEventsToProcess) {
249  break;
250  }
251 
252  Track *track = new Track();
253  sstream >> track->run >> track->subrun >> track->event >> track->trackID >> track->startDirectionX >> track->startDirectionY >> track->startDirectionZ >> track->length >> track->startX >> track->startY >> track->startZ;
254  track->pdg = fPDG;
255  trackCounter++;
256 
257  // Start direction components might not be perfectly normalized
258  double sdirmag = sqrt(track->startDirectionX*track->startDirectionX + track->startDirectionY*track->startDirectionY + track->startDirectionZ*track->startDirectionZ);
259  track->startDirectionX /= sdirmag;
260  track->startDirectionY /= sdirmag;
261  track->startDirectionZ /= sdirmag;
262 
263 
265  {
266  // Theta from +X to -X
267  double theta = acos(track->startDirectionX);
268 
269  int biny = hEnergyTheta->GetYaxis()->FindBin(theta);
270  TH1D *hEnergyAtTheta = hEnergyTheta->ProjectionX("", biny, biny);
271 
272  if( hEnergyAtTheta->GetEntries() < 1 ){
273  skippedTrackCounter++;
274  delete track;
275  continue;
276  }
277 
278  track->energy = hEnergyAtTheta->GetRandom();
279  }
280  else if(fUniformEnergyMin == fUniformEnergyMax) //get energy from .fcl parameter
281  {
282  track->energy = fUniformEnergyMin;
283  }
284  else //get energy from .fcl parameter
285  {
286  track->energy = gRandom->Uniform(fUniformEnergyMin, fUniformEnergyMax);
287  }
288 
289  if( track->event != eventBefore ){
290  eventBefore = track->event;
291  eventCounter++;
292  }
293 
294  //push back in map
295  fEventTrackMap[eventCounter].push_back(track);
296  }
297 
298  trackfile.close();
299 
300  //initialize randomn number seed for
301 
302 }
std::string string
Definition: nybbler.cc:12
std::map< int, std::vector< Track * > > fEventTrackMap
void line(double t, double *p, double &x, double &y, double &z)
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
DataGen311& evgendp::DataGen311::operator= ( DataGen311 const &  )
delete
DataGen311& evgendp::DataGen311::operator= ( DataGen311 &&  )
delete
void evgendp::DataGen311::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 306 of file DataGen311_module.cc.

306  {
307  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
308 
309  simb::MCTruth truth;
311 
312  //read the particle map and create the particle
313  int trackCtr=0;
314  for(Track* track : fEventTrackMap[e.id().event()] ){
315 
316  simb::MCParticle particle( trackCtr, track->pdg ,"primary",-200, track->m , 1 );
317  particle.AddTrajectoryPoint( track->getPosition() , track->getMomentum() );
318 
319  truth.Add(particle);
320 
321  trackCtr++;
322  }
323 
324  truthcol->push_back(truth);
325  e.put(std::move(truthcol));
326 
327 }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
std::map< int, std::vector< Track * > > fEventTrackMap
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
EventNumber_t event() const
Definition: EventID.h:116
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
Event generator information.
Definition: MCTruth.h:32
EventID id() const
Definition: Event.cc:34
Cosmic rays.
Definition: MCTruth.h:24

Member Data Documentation

int evgendp::DataGen311::fEventsToProcess

Definition at line 181 of file DataGen311_module.cc.

std::map< int, std::vector< Track*> > evgendp::DataGen311::fEventTrackMap

Definition at line 190 of file DataGen311_module.cc.

bool evgendp::DataGen311::fGetEnergyFromCORSIKA

Definition at line 184 of file DataGen311_module.cc.

std::string evgendp::DataGen311::fHistFile

Definition at line 188 of file DataGen311_module.cc.

int evgendp::DataGen311::fPDG

Definition at line 183 of file DataGen311_module.cc.

int evgendp::DataGen311::fStartEvent

Definition at line 182 of file DataGen311_module.cc.

std::string evgendp::DataGen311::fTrackFile

Definition at line 187 of file DataGen311_module.cc.

double evgendp::DataGen311::fUniformEnergyMax

Definition at line 186 of file DataGen311_module.cc.

double evgendp::DataGen311::fUniformEnergyMin

Definition at line 185 of file DataGen311_module.cc.


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