20 #include "TDatabasePDG.h" 27 #include "TLorentzVector.h" 40 #include "art_root_io/TFileService.h" 41 #include "art_root_io/TFileDirectory.h" 44 #include "cetlib_except/exception.h" 49 #include "nugen/EventGeneratorBase/evgenbase.h" 54 #include "TDatabasePDG.h" 116 Name(
"NumberOfEvents"),
121 Name(
"StartPositionX"),
126 Name(
"StartPositionY"),
131 Name(
"StartPositionZ"),
141 Name(
"UseRotatedStartMomentum"),
142 Comment(
"Set to true to use rotated start momentum")
178 : EDProducer{config},
188 produces< std::vector<simb::MCTruth> >();
189 produces< sumdata::RunData, art::InRun >();
198 const int NMaxParticlesPerEvent = 1000;
201 int tStdHepStatus[NMaxParticlesPerEvent] = {0};
202 int tStdHepPdg[NMaxParticlesPerEvent] = {0};
203 double tStdHepP4[4*NMaxParticlesPerEvent] = {0.};
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;
211 neutTree->SetBranchAddress(
"StdHepN",&tStdHepN);
212 neutTree->SetBranchAddress(
"StdHepStatus",&tStdHepStatus);
213 neutTree->SetBranchAddress(
"StdHepPdg",&tStdHepPdg);
215 TTree *neutTreeRot = NULL;
219 neutTreeRot = (TTree*)neutFile->Get(
"nRooTrackerRot");
220 neutTreeRot->SetBranchAddress(
"StdHepP4Rot",&tStdHepP4);
224 neutTree->SetBranchAddress(
"StdHepP4",&tStdHepP4);
230 neutTree->GetEntry(i);
233 neutTreeRot->GetEntry(i);
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;
244 for(
int j=0; j<tStdHepN; j++)
246 double fAbsoluteParticleMomentum = sqrt(
pow(tStdHepP4[4*j],2) +
pow(tStdHepP4[4*j+1],2) +
pow(tStdHepP4[4*j+2],2) );
249 if( tStdHepPdg[j] != 0 && tStdHepStatus[j] == 1 && j > 0 && fAbsoluteParticleMomentum > 0 )
251 static TDatabasePDG pdgt;
252 TParticlePDG* pdgp = pdgt.GetParticle(tStdHepPdg[j]);
255 rootrackerparticle->
pdg = tStdHepPdg[j];
256 rootrackerparticle->
mass = pdgp->Mass();
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];
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;
290 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
296 int rootrackerparticlecounter=0;
299 simb::MCParticle particle( rootrackerparticlecounter, rootrackerparticle->pdg ,
"primary",-200, rootrackerparticle->mass , 1 );
300 particle.
AddTrajectoryPoint( rootrackerparticle->getPosition() , rootrackerparticle->getMomentum() );
304 rootrackerparticlecounter++;
307 truthcol->push_back(truth);
TLorentzVector getPosition()
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
bool fUseRotatedStartMomentum
std::map< int, std::vector< RooTrackerParticle * > > RooTrackerEventMap
NEUTImport(Parameters const &config)
ChannelGroupService::Name Name
void produce(art::Event &e) override
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
TLorentzVector getMomentum()
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
void Add(simb::MCParticle const &part)
EventNumber_t event() const
Event generator information.
QTextStream & endl(QTextStream &s)