20 #include "art/Framework/Core/EDProducer.h"
21 #include "art/Framework/Principal/Event.h"
22 #include "art/Framework/Principal/Run.h"
23 #include "art/Framework/Core/ModuleMacros.h"
24 #include "art/Framework/Services/Registry/ServiceHandle.h"
25 #include "messagefacility/MessageLogger/MessageLogger.h"
26 #include "fhiclcpp/ParameterSet.h"
29 #include "nusimdata/SimulationBase/MCTruth.h"
30 #include "nusimdata/SimulationBase/MCParticle.h"
37 #include "TDatabasePDG.h"
48 explicit FileMuons(fhicl::ParameterSet
const& pset);
108 , fEventNumberOffset(pset.get<
int >(
"EventNumberOffset"))
109 ,
fPDG (pset.get< std::vector<int> >(
"PDG") )
110 , fXYZ_Off (pset.get< std::vector<double> >(
"InitialXYZOffsets"))
111 , fFileName (pset.get< std::string >(
"FileName") )
112 , fMuonsFileType (pset.get< std::string >(
"MuonsFileType") )
113 , fTreeName (pset.get< std::string >(
"TreeName") )
114 , fBranchNames (pset.get< std::vector<std::string> >(
"BranchNames") )
117 produces< std::vector<simb::MCTruth> >();
126 mf::LogInfo(
"FileMuons : starting at event ") <<
countFile <<std::endl;
130 std::cout <<
"FileMuons: Not yet equipped to walk through muons with TFS mojo."<< std::endl;
134 std::cout <<
"FileMuons: You have chosen to read muons from Root File " <<
fFileName << std::endl;
138 std::cout <<
"FileMuons: You have chosen to read muons from " <<
fFileName <<
"." << std::endl;
142 std::cout <<
"FileMuons: You must specify one of source/text/root file to read for muons."<< std::endl;
155 for (
unsigned int header=0; header<3 &&
fMuonFile->good(); ++header)
162 std::cout <<
"FileMuons: Problem reading muon file header."<< std::endl;
170 TNtuple->SetBranchAddress(
"x", &
xtmp, &
b_x);
171 TNtuple->SetBranchAddress(
"y", &
ytmp, &
b_y);
172 TNtuple->SetBranchAddress(
"z", &
ztmp, &
b_z);
173 TNtuple->SetBranchAddress(
"E", &
E, &
b_E);
175 TNtuple->SetBranchAddress(
"phi", &
phi, &
b_phi);
176 TNtuple->SetBranchAddress(
"xdet", &
xdet, &
b_xdet);
177 TNtuple->SetBranchAddress(
"ydet", &
ydet, &
b_ydet);
178 TNtuple->SetBranchAddress(
"zdet", &
zdet, &
b_zdet);
179 TNtuple->SetBranchAddress(
"px", &
pxtmp, &
b_px);
180 TNtuple->SetBranchAddress(
"py", &
pytmp, &
b_py);
181 TNtuple->SetBranchAddress(
"pz", &
pztmp, &
b_pz);
200 art::ServiceHandle<geo::Geometry const> geo;
201 run.put(std::make_unique<sumdata::RunData>(geo->DetectorName()));
209 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
212 truth.SetOrigin(simb::kSingleParticle);
216 truthcol->push_back(truth);
219 evt.put(std::move(truthcol));
231 for (
unsigned int i=0; i<
fPDG.size(); ++i) {
249 std::cout <<
"FileMuons: Problem reading muon file line ...."<<
countFile <<
". Perhaps you've exhausted the events in " <<
fFileName << std::endl;
exit(0);
257 MF_LOG_DEBUG(
"FileMuons: countFile is ") <<
countFile <<std::endl;
261 cstr =
new char [line.size()+1];
262 strcpy (cstr, line.c_str());
264 ptok=strtok (cstr,
"*");
265 unsigned int fieldCount = 0;
266 unsigned int posIndex = 0;
267 unsigned int pIndex = 0;
271 ptok=strtok(NULL,
"*");
272 if (fieldCount==9 || fieldCount==10 || fieldCount==11)
274 p[pIndex] = atof(ptok); pIndex++;
277 if (fieldCount==6 || fieldCount==7 || fieldCount==8)
279 x[posIndex] = atof(ptok);
281 if (posIndex==2) {x[posIndex] = -1.0*x[posIndex];}
317 static TDatabasePDG pdgt;
318 pdgLocal = -q*
fPDG[i];
320 TParticlePDG* pdgp = pdgt.GetParticle(pdgLocal);
321 if (pdgp) m = pdgp->Mass();
327 const double cryoGap = 15.0;
338 art::ServiceHandle<geo::Geometry const> geom;
339 TVector3 off3(geom->CryostatHalfWidth()*0.01,geom->CryostatHalfHeight()*0.01,geom->CryostatLength()*0.01+cryoGap*0.01/2.0) ;
342 TLorentzVector pos(x[0]*100.0, x[1]*100.0, x[2]*100.0, 0.0);
343 TLorentzVector pvec(p[0]*1000.0,p[1]*1000.0,p[2]*1000.0,std::sqrt(p.Mag2()*1000.0*1000.0+m*
m));
344 std::cout <<
"x[m] and p [TeV] are " << std::endl;
348 int trackid = -1*(i+1);
349 std::string primary(
"primary");
350 simb::MCParticle part(trackid, pdgLocal, primary);
351 part.AddTrajectoryPoint(pos, pvec);
std::vector< double > fXYZ_Off
process_name opflash particleana ie x
std::string fMuonsFileType
void ReadEvents(simb::MCTruth &mct)
void beginRun(art::Run &run)
produces< sumdata::RunData, art::InRun >()
std::ifstream * fMuonFile
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
std::vector< std::string > fBranchNames
auto end(FixedBins< T, C > const &) noexcept
module to produce single or multiple specified particles in the detector
FileMuons(fhicl::ParameterSet const &pset)
auto begin(FixedBins< T, C > const &) noexcept
art framework interface to geometry description
BEGIN_PROLOG could also be cout
void produce(art::Event &evt)