17 #include "cetlib_except/exception.h" 20 #include "TLorentzVector.h" 26 #include "CLHEP/Random/RandFlat.h" 27 #include "art_root_io/TFileDirectory.h" 28 #include "art_root_io/TFileService.h" 79 ,
fmode{
p.get<
int>(
"Mode",0)}
81 ,
fEnergyRange{
p.get<std::pair<float,float>>(
"EnergyRange",std::make_pair(2,3))}
86 produces< std::vector<simb::MCTruth> >();
87 produces< sumdata::RunData, art::InRun >();
95 std::cout<<
" fmode=0 - Sending muons uniformly distributed on the CRT panels." <<
std::endl;
103 std::cout<<
" fEnergyDistributionMode=0 - Muons will follow a uniform distribution between the values: " <<
fEnergyRange.first<<
" " <<
fEnergyRange.second <<
std::endl;
106 std::cout<<
" fEnergyDistributionMode=1 - Sending muons following the distribution contained on file: " <<
fInputFileNameEnergy <<
std::endl;}
114 if( !fInputFileCRT->IsOpen() )
117 <<
" cannot be read.\n";
119 TH2D *
h =(TH2D*)fInputFileCRT->Get(
"CRTTop");
120 if (!h)
throw cet::exception(
"CRTGen") <<
"TH2D named CRTTop not found in " 124 h =(TH2D*)fInputFileCRT->Get(
"CRTBot");
125 if (!h)
throw cet::exception(
"CRTGen") <<
"TH2D named CRTBot not found in " 129 fInputFileCRT->Close();
137 if( !fInputFileEnergy->IsOpen() )
140 <<
" cannot be read.\n";
142 TH1D *
h =(TH1D*)fInputFileEnergy->Get(
"EnergyDistribution");
143 if (!h)
throw cet::exception(
"CRTGen") <<
"TH1D named EnergyDistribution not found in " 147 fInputFileEnergy->Close();
152 fTH2CRTTop = tfs->make<TH2F>(
"CRTTop",
"Start position at CRT Top",10,0,0,10,0,0);
153 fTH2CRTBot = tfs->make<TH2F>(
"CRTBot",
"Expected end track position at CRT Bot",10,0,0,10,0,0);
154 fTH1Energy = tfs->make<TH1F>(
"TH1Energy",
"Muon energy GeV",100,0,0);
209 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
219 double mass = 0.1056583745;
220 double xPosition, yPosition, zPosition, xPositionEnd, yPositionEnd, zPositionEnd;
225 CRTTop.GetRandom2(zPosition,xPosition);
226 CRTBot.GetRandom2(zPositionEnd,xPositionEnd);
235 CRTTop.GetRandom2(zPosition,yPosition);
236 CRTBot.GetRandom2(zPositionEnd,yPositionEnd);
276 double totmom = sqrt(
pow(energy,2)-
pow(mass,2));
278 double dx=xPositionEnd-xPosition;
279 double dy=yPositionEnd-yPosition;
280 double dz=zPositionEnd-zPosition;
286 double xMomentum = dx*totmom;
287 double yMomentum = dy*totmom;
288 double zMomentum = dz*totmom;
289 mf::LogPrint(
"CRTGen") <<
"Shooting muon on " << xPosition <<
" " << yPosition <<
" " << zPosition <<
"to "<< xPositionEnd <<
" " << yPositionEnd <<
" " << zPositionEnd <<
" With momentum: " << xMomentum <<
" " << yMomentum <<
" " << zMomentum <<
" E=" << energy <<
" m=" << mass;
291 TLorentzVector
pos(xPosition, yPosition, zPosition, time);
292 TLorentzVector mom(xMomentum, yMomentum, zMomentum, energy);
301 truthcol->push_back(truth);
void beginRun(art::Run &run) override
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
std::pair< float, float > fEnergyRange
void produce(art::Event &e) override
EDProducer(fhicl::ParameterSet const &pset)
CRTGen(fhicl::ParameterSet const &p)
art framework interface to geometry description
std::string fInputFileNameEnergy
Name of text file containing events to simulate.
std::vector< double > CRT_TOP_center
#define DEFINE_ART_MODULE(klass)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
short int driftcoordinate
int fEnergyDistributionMode
std::string fInputFileNameCRT
Name of text file containing events to simulate.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< double > CRT_BOT_center_driftY
auto norm(Vector const &v)
Return norm of the specified vector.
double BufferLengthOnCRTBottom
void Add(simb::MCParticle const &part)
std::vector< double > CRT_TOP_center_driftY
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
Event generator information.
LArSoft geometry interface.
Event Generation using GENIE, cosmics or single particles.
std::vector< double > CRT_BOT_center
cet::coded_exception< error, detail::translate > exception
MaybeLogger_< ELseverityLevel::ELsev_warning, true > LogPrint
QTextStream & endl(QTextStream &s)