The main routine of this module: Fetch the primary particles from the event, simulate their evolution in the detctor, and produce the detector response.
504 std::unique_ptr< std::vector<simb::MCTruth> > mctruthcol(
new std::vector<simb::MCTruth> );
505 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol(
new std::vector<simb::GTruth> );
508 std::unique_ptr< std::vector<gar::sdp::GenieParticle> > geniepartcol(
new std::vector<gar::sdp::GenieParticle> );
511 std::vector< ::art::Ptr<simb::MCTruth> > mctPtrs;
518 unsigned int_idx = 0;
538 if(
nullptr == neutrino) {
545 TObjArrayIter piter(
event);
546 unsigned int idx = 0;
549 geniepartcol->emplace_back(int_idx, idx, p->
Pdg(), p->
Status(), p->
Name(), p->
FirstMother(), p->
LastMother(), p->
FirstDaughter(), p->
LastDaughter(), p->
Px(), p->
Py(), p->
Pz(), p->
E(), p->
Mass(), p->
RescatterCode());
556 evgb::FillMCTruth(
event, 0., mctruth);
559 mctruthcol->push_back(mctruth);
560 gtruthcol->push_back(gtruth);
564 mctPtrs.push_back(MCTruthPtr);
566 evgb::util::CreateAssn(*
this, evt, *mctruthcol, *gtruthcol, *tgassn, gtruthcol->size()-1, gtruthcol->size());
584 TObjArrayIter piter(
event);
585 unsigned int idx = 0;
588 geniepartcol->emplace_back(int_idx, idx, p->
Pdg(), p->
Status(), p->
Name(), p->
FirstMother(), p->
LastMother(), p->
FirstDaughter(), p->
LastDaughter(), p->
Px(), p->
Py(), p->
Pz(), p->
E(), p->
Mass(), p->
RescatterCode());
595 evgb::FillMCTruth(
event, 0., mctruth);
598 mctruthcol->push_back(mctruth);
599 gtruthcol->push_back(gtruth);
603 mctPtrs.push_back(MCTruthPtr);
605 evgb::util::CreateAssn(*
this, evt, *mctruthcol, *gtruthcol, *tgassn, gtruthcol->size()-1, gtruthcol->size());
617 double evWeight =
t->Weight;
620 int trackid = p->GetTrackId();
627 part.SetWeight(evWeight);
629 MF_LOG_DEBUG(
"ConvertEdep2Art") <<
"Adding primary particle with " 630 <<
" momentum " << part.P()
631 <<
" position " << part.Vx() <<
" " << part.Vy() <<
" " << part.Vz();
637 MF_LOG_DEBUG(
"ConvertEdep2Art") <<
"Adding mctruth with " 639 <<
" Origin " << truth.
Origin();
641 mctruthcol->push_back(truth);
645 mctPtrs.push_back(MCTruthPtr);
650 std::unique_ptr< std::vector<simb::MCParticle> > partCol(
new std::vector<simb::MCParticle> );
659 int trackID =
t->GetTrackId();
660 int parentID =
t->GetParentId();
661 int pdg =
t->GetPDGCode();
667 if(
nullptr != part) {
672 <<
" Could not find TParticlePDG for pdg " 674 <<
" Mass is ut to 0 GeV";
682 process_name =
"primary";
688 process =
t->Points.at(0).GetProcess();
689 subprocess =
t->Points.at(0).GetSubprocess();
697 TLorentzVector
position = p->GetPosition();
700 TVector3
momentum = p->GetMomentum();
704 TLorentzVector fourMom(px, py, pz, std::sqrt( px*px + py*py + pz*pz + mass*mass ));
706 int pt_process = p->GetProcess();
707 int pt_subprocess = p->GetSubprocess();
710 if(p ==
t->Points.begin()) pt_process_name =
"Start";
715 process =
t->Points.at(
t->Points.size()-1).GetProcess();
716 subprocess =
t->Points.at(
t->Points.size()-1).GetSubprocess();
723 size_t mcTruthIndex = 0;
724 int fCurrentTrackID = 0;
729 int parentID = part.
Mother();
731 fCurrentTrackID = trackID;
734 if( process_name ==
"primary" )
746 TGeoNode *node =
fGeo->
FindNode(part_start.X(), part_start.Y(), part_start.Z());
750 material_name = node->GetMedium()->GetMaterial()->GetName();
758 if( isEMShowerProcess && not std::regex_match(material_name, re_material) ) {
765 <<
" Skipping EM shower daughter " 766 <<
" with trackID " << trackID
767 <<
" with parent id " << parentID
769 <<
" created with process [ " << process_name <<
" ]";
786 <<
"can't find parent id: " 787 << parentID <<
" in the particle list, or fTrkIDParent." 788 <<
" Make " << parentID <<
" the mother ID for track ID " 789 << fCurrentTrackID <<
" in the hope that it will aid debugging.";
807 <<
"Cannot find MCTruth index for track id " 808 << fCurrentTrackID <<
" or " << parentID
809 <<
" exception " << e.what();
818 size_t nGeneratedParticles = 0;
826 <<
"adding mc particle with track id: " 832 <<
" Particle with pdg " << p.
PdgCode()
834 <<
" parent id " << p.
Mother()
835 <<
" created with process [ " << p.
Process() <<
" ]" 837 <<
" with energy " << p.
E();
842 if( fTrackIDToMCTruthIndex_local.count(trackID) > 0) {
843 size_t mctidx = fTrackIDToMCTruthIndex_local.find(trackID)->second;
849 <<
"Cannot find MCTruth for Track Id: " << trackID
850 <<
" to create association between Particle and MCTruth" 851 <<
" exception " << e.what();
856 ++nGeneratedParticles;
859 MF_LOG_DEBUG(
"ConvertEdep2Art") <<
"Finished linking MCTruth and MCParticles";
873 if(
d->first ==
"TPC_Drift1" ||
d->first ==
"TPC_Drift2" )
892 std::string VolumeName = node->GetVolume()->GetName();
893 std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
894 if ( ! std::regex_match(volmaterial, std::regex(
fTPCMaterial)) )
continue;
896 fGArDeposits.emplace_back(trackID, time, edep, x, y, z, stepLength, (trackID > 0));
899 else if(
d->first ==
"BarrelECal_vol" ||
d->first ==
"EndcapECal_vol"){
918 std::string VolumeName = node->GetVolume()->GetName();
919 std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
920 if ( ! std::regex_match(volmaterial, std::regex(
fECALMaterial)) )
continue;
928 std::array<double, 3> GlobalPosCM = {
x,
y, z};
929 std::array<double, 3> LocalPosCM;
934 <<
"Sensitive volume " <<
d->first
936 <<
" in volume " << VolumeName
937 <<
" in material " << volmaterial
938 <<
" det_id " << det_id
939 <<
" module " << module
940 <<
" stave " << stave
941 <<
" layer " << layer
942 <<
" slice " << slice;
946 double G4Pos[3] = {0., 0., 0.};
947 G4Pos[0] = GlobalPosCM[0];
948 G4Pos[1] = GlobalPosCM[1];
949 G4Pos[2] = GlobalPosCM[2];
955 std::vector<gar::sdp::CaloDeposit> vechit;
956 vechit.push_back(calohit);
961 else if(
d->first ==
"Tracker_vol" ) {
980 std::string VolumeName = node->GetVolume()->GetName();
981 std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
982 if ( ! std::regex_match(volmaterial, std::regex(
fECALMaterial)) )
continue;
986 unsigned int det_id = 3;
988 std::array<double, 3> GlobalPosCM = {
x,
y, z};
989 std::array<double, 3> LocalPosCM;
994 <<
"Sensitive volume " <<
d->first
996 <<
" in volume " << VolumeName
997 <<
" in material " << volmaterial
998 <<
" det_id " << det_id
999 <<
" layer " << layer
1000 <<
" slice " << slice;
1005 <<
"Sensitive volume " <<
d->first
1006 <<
" TrackLength " << stepLength
1007 <<
" Energy " << edep
1008 <<
" cellID " << cellID
1009 <<
" local ( " << LocalPosCM[0] <<
" , " << LocalPosCM[1] <<
" , " << LocalPosCM[2] <<
" )" 1010 <<
" global ( " << GlobalPosCM[0] <<
" , " << GlobalPosCM[1] <<
" , " << GlobalPosCM[2] <<
" )";
1012 double G4Pos[3] = {0., 0., 0.};
1013 G4Pos[0] = GlobalPosCM[0];
1014 G4Pos[1] = GlobalPosCM[1];
1015 G4Pos[2] = GlobalPosCM[2];
1021 std::vector<gar::sdp::CaloDeposit> vechit;
1022 vechit.push_back(calohit);
1027 else if(
d->first ==
"MuID_vol" ) {
1046 std::string VolumeName = node->GetVolume()->GetName();
1047 std::string volmaterial = node->GetMedium()->GetMaterial()->GetName();
1048 if ( ! std::regex_match(volmaterial, std::regex(
fECALMaterial)) )
continue;
1052 unsigned int det_id = 4;
1056 std::array<double, 3> GlobalPosCM = {
x,
y, z};
1057 std::array<double, 3> LocalPosCM;
1062 <<
"Sensitive volume " <<
d->first
1064 <<
" in volume " << VolumeName
1065 <<
" in material " << volmaterial
1066 <<
" det_id " << det_id
1067 <<
" layer " << layer
1068 <<
" slice " << slice
1069 <<
" stave " << stave
1070 <<
" module " << module;
1074 double G4Pos[3] = {0., 0., 0.};
1075 G4Pos[0] = GlobalPosCM[0];
1076 G4Pos[1] = GlobalPosCM[1];
1077 G4Pos[2] = GlobalPosCM[2];
1083 std::vector<gar::sdp::CaloDeposit> vechit;
1084 vechit.push_back(calohit);
1091 <<
"Ignoring hits for sensitive material: " 1097 MF_LOG_DEBUG(
"ConvertEdep2Art") <<
"Finished collection sensitive hits";
1101 std::unique_ptr< std::vector< gar::sdp::EnergyDeposit> > TPCCol(
new std::vector<gar::sdp::EnergyDeposit> );
1102 std::unique_ptr< std::vector< gar::sdp::CaloDeposit > > ECALCol(
new std::vector<gar::sdp::CaloDeposit> );
1103 std::unique_ptr< std::vector< gar::sdp::CaloDeposit > > TrackerCol(
new std::vector<gar::sdp::CaloDeposit> );
1104 std::unique_ptr< std::vector< gar::sdp::CaloDeposit > > MuIDCol(
new std::vector<gar::sdp::CaloDeposit> );
1105 std::unique_ptr< std::vector< gar::sdp::LArDeposit > > LArCol(
new std::vector<gar::sdp::LArDeposit> );
1107 bool hasGAr =
false;
1108 bool hasECAL =
false;
1109 bool hasTrackerSc =
false;
1110 bool hasMuID =
false;
1111 bool hasLAr =
false;
1123 <<
"adding GAr deposits for track id: " 1124 << garhit.TrackID();
1125 TPCCol->emplace_back(garhit);
1136 <<
"adding calo deposits for track id: " 1137 << ecalhit.TrackID();
1139 ECALCol->emplace_back(ecalhit);
1150 <<
"adding tracker Sc deposits for track id: " 1151 << trkhit.TrackID();
1153 TrackerCol->emplace_back(trkhit);
1164 <<
"adding muID deposits for track id: " 1165 << muidhit.TrackID();
1167 MuIDCol->emplace_back(muidhit);
1184 unsigned int imcp = 0;
1185 for(
auto const &part : *partCol)
1187 int mpc_trkid = part.
TrackId();
1190 unsigned int igashit = 0;
1191 unsigned int iecalhit = 0;
1192 unsigned int itrkhit = 0;
1193 unsigned int imuidhit = 0;
1196 for(
auto const& gashit : *TPCCol)
1198 if(mpc_trkid == gashit.TrackID()){
1200 ghmcassn->addSingle(gashitPtr, partPtr);
1207 for(
auto const& ecalhit : *ECALCol)
1209 if(mpc_trkid == ecalhit.TrackID()){
1211 ehmcassn->addSingle(ecalhitPtr, partPtr);
1218 for(
auto const& trkhit : *TrackerCol)
1220 if(mpc_trkid == trkhit.TrackID()){
1222 thmcassn->addSingle(trkhitPtr, partPtr);
1229 for(
auto const& muidhit : *MuIDCol)
1231 if(mpc_trkid == muidhit.TrackID()){
1233 mhmcassn->addSingle(muIDhitPtr, partPtr);
static constexpr double cm
double E(const int i=0) const
TG4PrimaryVertexContainer Primaries
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
std::map< int, size_t > fTrackIDToMCTruthIndex
std::map< int, size_t > TrackIDToMCTruthIndexMap() const
unsigned int GetStaveNumber(std::string volname) const
int RescatterCode(void) const
bool WorldToLocal(std::array< double, 3 > const &world, std::array< double, 3 > &local, gar::geo::LocalTransformation< TGeoHMatrix > &trans) const
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_TrackerDeposits
NtpMCRecHeader hdr
record header
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
double E(void) const
Get energy.
void SetOrigin(simb::Origin_t origin)
const simb::MCTrajectory & Trajectory() const
int FirstDaughter(void) const
TG4TrajectoryContainer Trajectories
double GetEnergyDeposit() const
The total energy deposit in this hit.
simb::Origin_t Origin() const
std::string fECALMaterial
gar::raw::CellID_t GetCellID(const TGeoNode *node, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const
double Mass(void) const
Mass that corresponds to the PDG code.
static constexpr double MeV
void AddHitsMinerva(std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > &m_Deposits, std::vector< gar::sdp::CaloDeposit > &fDeposits) const
std::string Process() const
sim::ParticleList * fParticleList
const gar::geo::seg::MinervaSegmentationAlg * fMinervaSegAlg
double Pz(void) const
Get Pz.
GHepStatus_t Status(void) const
const gar::geo::GeometryCore * fGeo
geometry information
size_t FindMCTruthIndex(std::vector< simb::MCTruth > *mctruthcol, const simb::MCParticle &part) const
double Px(void) const
Get Px.
int LastMother(void) const
int FirstMother(void) const
string Name(void) const
Name that corresponds to the PDG code.
std::map< unsigned int, unsigned int > fTrkIDParent
std::vector< int > fStopSpill
int LastDaughter(void) const
genie::NtpMCEventRecord * fMCRec
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
TG4HitSegmentDetectors SegmentDetectors
unsigned int GetParentage(unsigned int trkid) const
static constexpr double GeV
void FillGTruth(const simb::GTruth >, garana::GTruth &outtruth)
single particles thrown at the detector
std::string FindProcessName(int process, int subprocess)
std::string fEMShowerDaughterMatRegex
keep EM shower daughters only in these materials
unsigned int GetLayerNumber(std::string volname) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
const TLorentzVector & Position(const size_type) const
The accessor methods described above.
#define MF_LOG_INFO(category)
unsigned int GetDetNumber(std::string volname) const
std::vector< gar::sdp::EnergyDeposit > fGArDeposits
Detector simulation of raw signals on wires.
unsigned int GetSliceNumber(std::string volname) const
genie::PDGLibrary * pdglib
unsigned int GetModuleNumber(std::string volname) const
void SetEndProcess(std::string s)
double GetTrackLength() const
double VisibleEnergyDeposition(const TG4HitSegment *hit, bool applyBirks) const
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_MuIDDeposits
std::vector< gar::sdp::CaloDeposit > fMuIDDeposits
std::vector< int > fStartSpill
std::vector< gar::sdp::CaloDeposit > fECALDeposits
void Add(simb::MCParticle const &part)
bool CheckProcess(std::string process_name) const
IDNumber_t< Level::Event > EventNumber_t
EventNumber_t event() const
std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_ECALDeposits
void AddHits(std::map< gar::raw::CellID_t, std::vector< gar::sdp::CaloDeposit > > m_Deposits, std::vector< gar::sdp::CaloDeposit > &fDeposits)
TParticlePDG * Find(int pdgc, bool must_exist=true)
Event generator information.
def momentum(x1, x2, x3, scale=1.)
const TLorentzVector & GetStop() const
The stopping position of the segment.
STDHEP-like event record entry that can fit a particle or a nucleus.
cet::coded_exception< error, detail::translate > exception
std::vector< gar::sdp::CaloDeposit > fTrackerDeposits
Event finding and building.
const TLorentzVector & GetStart() const
The starting position of the segment.
double Py(void) const
Get Py.