36 #include "TDatabasePDG.h" 103 ,
fPDG(pset.get<std::vector<int>>(
"PDG"))
104 ,
fXYZ_Off(pset.get<std::vector<double>>(
"InitialXYZOffsets"))
105 ,
fFileName(pset.get<std::string>(
"FileName"))
107 ,
fTreeName(pset.get<std::string>(
"TreeName"))
108 ,
fBranchNames(pset.get<std::vector<std::string>>(
"BranchNames"))
111 produces<std::vector<simb::MCTruth>>();
112 produces<sumdata::RunData, art::InRun>();
122 std::cout <<
"FileMuons: Not yet equipped to walk through muons with TFS mojo." << std::endl;
125 std::cout <<
"FileMuons: You have chosen to read muons from Root File " <<
fFileName 129 std::cout <<
"FileMuons: You have chosen to read muons from " <<
fFileName <<
"." 133 std::cout <<
"FileMuons: You must specify one of source/text/root file to read for muons." 142 std::cout <<
"FileMuons: " <<
fFileName <<
" size is: " << (end -
begin) <<
" bytes.\n";
145 for (
unsigned int header = 0; header < 3 &&
fMuonFile->good(); ++header) {
150 std::cout <<
"FileMuons: Problem reading muon file header." << std::endl;
157 TNtuple->SetBranchAddress(
"x", &
xtmp, &
b_x);
158 TNtuple->SetBranchAddress(
"y", &
ytmp, &
b_y);
159 TNtuple->SetBranchAddress(
"z", &
ztmp, &
b_z);
160 TNtuple->SetBranchAddress(
"E", &
E, &
b_E);
162 TNtuple->SetBranchAddress(
"phi", &
phi, &
b_phi);
163 TNtuple->SetBranchAddress(
"xdet", &
xdet, &
b_xdet);
164 TNtuple->SetBranchAddress(
"ydet", &
ydet, &
b_ydet);
165 TNtuple->SetBranchAddress(
"zdet", &
zdet, &
b_zdet);
166 TNtuple->SetBranchAddress(
"px", &
pxtmp, &
b_px);
167 TNtuple->SetBranchAddress(
"py", &
pytmp, &
b_py);
168 TNtuple->SetBranchAddress(
"pz", &
pztmp, &
b_pz);
193 std::unique_ptr<std::vector<simb::MCTruth>> truthcol(
new std::vector<simb::MCTruth>);
200 truthcol->push_back(truth);
203 evt.
put(std::move(truthcol));
215 for (
unsigned int i = 0; i <
fPDG.size(); ++i) {
231 std::cout <<
"FileMuons: Problem reading muon file line ...." <<
countFile 232 <<
". Perhaps you've exhausted the events in " <<
fFileName << std::endl;
244 cstr =
new char[line.size() + 1];
245 strcpy(cstr, line.c_str());
247 ptok = strtok(cstr,
"*");
248 unsigned int fieldCount = 0;
249 unsigned int posIndex = 0;
250 unsigned int pIndex = 0;
251 while (ptok != NULL) {
253 ptok = strtok(NULL,
"*");
254 if (fieldCount == 9 || fieldCount == 10 || fieldCount == 11) {
255 p[pIndex] = atof(ptok);
259 if (fieldCount == 6 || fieldCount == 7 || fieldCount == 8) {
260 x[posIndex] = atof(ptok);
262 if (posIndex == 2) { x[posIndex] = -1.0 * x[posIndex]; }
265 if (fieldCount == 12) { q = atof(ptok); }
294 static TDatabasePDG pdgt;
295 pdgLocal = -q *
fPDG[i];
297 TParticlePDG* pdgp = pdgt.GetParticle(pdgLocal);
298 if (pdgp) m = pdgp->Mass();
303 const double cryoGap = 15.0;
309 x.RotateX(-M_PI / 2);
310 p.RotateX(-M_PI / 2);
320 TLorentzVector pos(x[0] * 100.0, x[1] * 100.0, x[2] * 100.0, 0.0);
322 p[0] * 1000.0, p[1] * 1000.0, p[2] * 1000.0, std::sqrt(p.Mag2() * 1000.0 * 1000.0 + m * m));
323 std::cout <<
"x[m] and p [TeV] are " << std::endl;
329 std::string primary(
"primary");
std::vector< double > fXYZ_Off
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
void SetOrigin(simb::Origin_t origin)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
Length_t CryostatHalfWidth(CryostatID const &cid=cryostat_zero) const
Returns the half width of the cryostat (x direction)
std::string fMuonsFileType
void ReadEvents(simb::MCTruth &mct)
void beginRun(art::Run &run)
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::ifstream * fMuonFile
Length_t CryostatHalfHeight(CryostatID const &cid=cryostat_zero) const
Returns the height of the cryostat (y direction)
std::vector< std::string > fBranchNames
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
#define DEFINE_ART_MODULE(klass)
single particles thrown at the detector
module to produce single or multiple specified particles in the detector
FileMuons(fhicl::ParameterSet const &pset)
void Add(simb::MCParticle const &part)
Length_t CryostatLength(CryostatID const &cid=cryostat_zero) const
Returns the length of the cryostat (z direction)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Event generator information.
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
art framework interface to geometry description
void produce(art::Event &evt)