Classes | Public Types | Public Member Functions | Public Attributes | List of all members
evgendp::NEUTImport Class Reference
Inheritance diagram for evgendp::NEUTImport:
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

 NEUTImport (Parameters const &config)
 
 NEUTImport (NEUTImport const &)=delete
 
 NEUTImport (NEUTImport &&)=delete
 
NEUTImportoperator= (NEUTImport const &)=delete
 
NEUTImportoperator= (NEUTImport &&)=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 fLogLevel
 
int fStartEvent
 
int fNumberOfEvents
 
double fStartPositionX
 
double fStartPositionY
 
double fStartPositionZ
 
std::string fFileName
 
bool fUseRotatedStartMomentum
 
std::map< int, std::vector< RooTrackerParticle * > > RooTrackerEventMap
 

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 95 of file NEUTImport_module.cc.

Member Typedef Documentation

Definition at line 146 of file NEUTImport_module.cc.

Constructor & Destructor Documentation

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

Definition at line 177 of file NEUTImport_module.cc.

178  : EDProducer{config},
179  fLogLevel (config().LogLevel()),
180  fStartEvent (config().StartEvent()),
181  fNumberOfEvents (config().NumberOfEvents()),
182  fStartPositionX (config().StartPositionX()),
183  fStartPositionY (config().StartPositionY()),
184  fStartPositionZ (config().StartPositionZ()),
185  fFileName (config().FileName()),
186  fUseRotatedStartMomentum (config().UseRotatedStartMomentum())
187 {
188  produces< std::vector<simb::MCTruth> >();
189  produces< sumdata::RunData, art::InRun >();
190 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
static Config * config
Definition: config.cpp:1054
evgendp::NEUTImport::NEUTImport ( NEUTImport const &  )
delete
evgendp::NEUTImport::NEUTImport ( NEUTImport &&  )
delete

Member Function Documentation

void evgendp::NEUTImport::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 196 of file NEUTImport_module.cc.

196  {
197 
198  const int NMaxParticlesPerEvent = 1000;
199 
200  int tStdHepN = 0;
201  int tStdHepStatus[NMaxParticlesPerEvent] = {0};
202  int tStdHepPdg[NMaxParticlesPerEvent] = {0};
203  double tStdHepP4[4*NMaxParticlesPerEvent] = {0.};
204 
205 
206  TFile *neutFile = new TFile(fFileName.c_str(), "READ");
207  TTree *neutTree = (TTree*)neutFile->Get("nRooTracker");
208  int NEvents = (int)neutTree->GetEntries();
209  std::cout << "Reading in " << NEvents << " NEUT events. " << std::endl;
210 
211  neutTree->SetBranchAddress("StdHepN",&tStdHepN);
212  neutTree->SetBranchAddress("StdHepStatus",&tStdHepStatus);
213  neutTree->SetBranchAddress("StdHepPdg",&tStdHepPdg);
214 
215  TTree *neutTreeRot = NULL;
216 
218  {
219  neutTreeRot = (TTree*)neutFile->Get("nRooTrackerRot");
220  neutTreeRot->SetBranchAddress("StdHepP4Rot",&tStdHepP4);
221  }
222  else
223  {
224  neutTree->SetBranchAddress("StdHepP4",&tStdHepP4);
225  }
226 
227 
228  for(int i=fStartEvent; i<fStartEvent+fNumberOfEvents; i++) //Event loop
229  {
230  neutTree->GetEntry(i);
232  {
233  neutTreeRot->GetEntry(i);
234  }
235 
236  if(fLogLevel == 1)
237  {
238  std::cout << std::endl;
239  std::cout << std::endl;
240  std::cout << "Event #" << i+1 << " in LArSoft, event #" << i << " in ROOT file." << std::endl;
241  std::cout << "NParticles:\t" << tStdHepN << " (from 0 to " << tStdHepN-1 << ")" << std::endl;
242  }
243 
244  for(int j=0; j<tStdHepN; j++)
245  {
246  double fAbsoluteParticleMomentum = sqrt( pow(tStdHepP4[4*j],2) + pow(tStdHepP4[4*j+1],2) + pow(tStdHepP4[4*j+2],2) );
247  //Only take particles with real PDG code (!=0), status 1 and momentum > 0.
248  //Also ignore first particle (j=0): this is the decaying nucleon in case of nucleon decay or incoming neutrino in case of atmospheric neutrino background.
249  if( tStdHepPdg[j] != 0 && tStdHepStatus[j] == 1 && j > 0 && fAbsoluteParticleMomentum > 0 )
250  {
251  static TDatabasePDG pdgt;
252  TParticlePDG* pdgp = pdgt.GetParticle(tStdHepPdg[j]);
253 
254  RooTrackerParticle *rootrackerparticle = new RooTrackerParticle();
255  rootrackerparticle->pdg = tStdHepPdg[j];
256  rootrackerparticle->mass = pdgp->Mass();
257  rootrackerparticle->startX = fStartPositionX;
258  rootrackerparticle->startY = fStartPositionY;
259  rootrackerparticle->startZ = fStartPositionZ;
260  rootrackerparticle->momX = tStdHepP4[4*j];
261  rootrackerparticle->momY = tStdHepP4[4*j+1];
262  rootrackerparticle->momZ = tStdHepP4[4*j+2];
263  rootrackerparticle->energy = tStdHepP4[4*j+3];
264  RooTrackerEventMap[i-fStartEvent].push_back(rootrackerparticle);
265 
266  if(fLogLevel == 1)
267  {
268  std::cout << std::endl;
269  std::cout << "Particle " << j << ":" << std::endl;
270  std::cout << "Status particle " << j << ":\t" << tStdHepStatus[j] << std::endl;
271  std::cout << "PDG particle " << j << ":\t" << rootrackerparticle->pdg << std::endl;
272  std::cout << "Mass particle " << j << ":\t" << rootrackerparticle->mass << std::endl;
273  std::cout << "StartPositionX particle " << j << ":\t" << rootrackerparticle->startX << std::endl;
274  std::cout << "StartPositionY particle " << j << ":\t" <<rootrackerparticle->startY << std::endl;
275  std::cout << "StartPositionZ particle " << j << ":\t" << rootrackerparticle->startZ << std::endl;
276  std::cout << "StartMomentumX particle " << j << ":\t" << rootrackerparticle->momX << std::endl;
277  std::cout << "StartMomentumY particle " << j << ":\t" <<rootrackerparticle->momY << std::endl;
278  std::cout << "StartMomentumZ particle " << j << ":\t" << rootrackerparticle->momZ << std::endl;
279  std::cout << "StartEnergy particle " << j << ":\t" << tStdHepP4[4*j+3] << std::endl;
280  std::cout << "Absolute momentum particle " << j << ":\t" << fAbsoluteParticleMomentum << std::endl;
281  }
282  }
283  }
284  }
285 }
std::map< int, std::vector< RooTrackerParticle * > > RooTrackerEventMap
constexpr T pow(T x)
Definition: pow.h:72
QTextStream & endl(QTextStream &s)
NEUTImport& evgendp::NEUTImport::operator= ( NEUTImport const &  )
delete
NEUTImport& evgendp::NEUTImport::operator= ( NEUTImport &&  )
delete
void evgendp::NEUTImport::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 289 of file NEUTImport_module.cc.

289  {
290  std::unique_ptr< std::vector<simb::MCTruth> > truthcol(new std::vector<simb::MCTruth>);
291 
292  simb::MCTruth truth;
293  truth.SetOrigin(simb::kUnknown);
294 
295  //read the particle map and create the MCParticle
296  int rootrackerparticlecounter=0;
297  for(RooTrackerParticle* rootrackerparticle : RooTrackerEventMap[e.id().event()-1] ){ //-1: art events start at 1, events in EventMap start at 0.
298 
299  simb::MCParticle particle( rootrackerparticlecounter, rootrackerparticle->pdg ,"primary",-200, rootrackerparticle->mass , 1 );
300  particle.AddTrajectoryPoint( rootrackerparticle->getPosition() , rootrackerparticle->getMomentum() );
301 
302  truth.Add(particle);
303 
304  rootrackerparticlecounter++;
305  }
306 
307  truthcol->push_back(truth);
308  e.put(std::move(truthcol));
309 
310 }
void SetOrigin(simb::Origin_t origin)
Definition: MCTruth.h:82
std::map< int, std::vector< RooTrackerParticle * > > RooTrackerEventMap
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
void Add(simb::MCParticle const &part)
Definition: MCTruth.h:80
EventNumber_t event() const
Definition: EventID.h:116
Event generator information.
Definition: MCTruth.h:32
EventID id() const
Definition: Event.cc:34

Member Data Documentation

std::string evgendp::NEUTImport::fFileName

Definition at line 166 of file NEUTImport_module.cc.

int evgendp::NEUTImport::fLogLevel

Definition at line 160 of file NEUTImport_module.cc.

int evgendp::NEUTImport::fNumberOfEvents

Definition at line 162 of file NEUTImport_module.cc.

int evgendp::NEUTImport::fStartEvent

Definition at line 161 of file NEUTImport_module.cc.

double evgendp::NEUTImport::fStartPositionX

Definition at line 163 of file NEUTImport_module.cc.

double evgendp::NEUTImport::fStartPositionY

Definition at line 164 of file NEUTImport_module.cc.

double evgendp::NEUTImport::fStartPositionZ

Definition at line 165 of file NEUTImport_module.cc.

bool evgendp::NEUTImport::fUseRotatedStartMomentum

Definition at line 167 of file NEUTImport_module.cc.

std::map< int, std::vector< RooTrackerParticle*> > evgendp::NEUTImport::RooTrackerEventMap

Definition at line 169 of file NEUTImport_module.cc.


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