#include #include #include "HEPUnits.hxx" #include "IG4HitSegment.hxx" #include "ICOMETEvent.hxx" #include "IEventFolder.hxx" #include "ITrackIDMap.hxx" ClassImp(COMET::IG4HitSegment); COMET::IG4HitSegment::IG4HitSegment() : IG4VHit(), fContributors(0), fEnergyDeposit(0), fTrackLength(0), fStartX(0), fStartY(0), fStartZ(0), fStartT(0), fStopX(0), fStopY(0), fStopZ(0), fStopT(0), fTrackId(0), fMomentumX(0), fMomentumY(0), fMomentumZ(0), fStep() , fPDGEncoding(0) {} COMET::IG4HitSegment::IG4HitSegment(const COMET::IG4HitSegment& rhs) : IG4VHit(rhs), fContributors(rhs.fContributors), fEnergyDeposit(rhs.fEnergyDeposit), fTrackLength(rhs.fTrackLength), fStartX(rhs.fStartX), fStartY(rhs.fStartY), fStartZ(rhs.fStartZ), fStartT(rhs.fStartT), fStopX(rhs.fStopX), fStopY(rhs.fStopY), fStopZ(rhs.fStopZ), fStopT(rhs.fStopT), fTrackId(rhs.fTrackId), fMomentumX(rhs.fMomentumX), fMomentumY(rhs.fMomentumY), fMomentumZ(rhs.fMomentumZ), fStep(rhs.fStep), fPDGEncoding(rhs.fPDGEncoding) {} COMET::IG4HitSegment::~IG4HitSegment() {} void COMET::IG4HitSegment::MapTrackIDs(ITrackIDMap* aMap){ // Map the primary IDs COMET::IG4VHit::MapTrackIDs(aMap); // Map the other track ID fTrackId = aMap->Get(fTrackId); // Map all the contributor IDs for (std::vector::iterator oldId = fContributors.begin(); oldId != fContributors.end(); ++oldId){ // Reassign the value *oldId = aMap->Get(*oldId); } } void COMET::IG4HitSegment::ls(Option_t *opt) const { COMET::ls_header(this,opt); std::cout << " PDG Code: " << GetPDGEncoding(); std::cout << " Primary Id (Track ID): " << GetPrimaryId(); double energy = GetEnergyDeposit(); int prec = std::cout.precision(); std::cout.precision(3); if (energy > 1*unit::GeV) { std::cout << " E: " << GetEnergyDeposit()/unit::GeV << " GeV"; } else if (energy > 1*unit::MeV) { std::cout << " E: " << GetEnergyDeposit()/unit::MeV << " MeV"; } else { std::cout << " E: " << GetEnergyDeposit()/unit::keV << " keV"; } std::cout << " L: " << GetTrackLength()/unit::mm << " mm" << std::endl; std::string option(opt); if (option.find("dump") != std::string::npos) { TROOT::IncreaseDirLevel(); TROOT::IndentLevel(); std::cout << "Start: (" << fStartX*unit::mm << " mm" << ", " << fStartY*unit::mm << " mm" << ", " << fStartZ*unit::mm << " mm" << ", " << fStartT << " ns)" << std::endl; TROOT::IndentLevel(); std::cout << "Stop: (" << fStopX*unit::mm << " mm" << ", " << fStopY*unit::mm << " mm" << ", " << fStopZ*unit::mm << " mm" << ", " << fStopT << " ns)" << std::endl; TROOT::IndentLevel(); std::cout << "Traj. Ids:"; for (std::vector::const_iterator i = GetContributors().begin(); i != GetContributors().end(); ++i) std::cout << " " << *i; std::cout << std::endl; TROOT::DecreaseDirLevel(); } std::cout.precision(prec); } const COMET::IHandle COMET::IG4HitSegment::GetTrajectory(int contributor)const{ const COMET::ICOMETEvent* event = COMET::IEventFolder::GetCurrentEvent(); COMET::IHandle trajectories = event->Get("truth/G4Trajectories"); if(!trajectories) return COMET::IHandle(NULL); int id=0; if(contributor==-1) id=GetPrimaryId(); else if(contributor<(int) fContributors.size()) id=fContributors.at(contributor); else COMETError("Requested contributor-id ("<GetTrajectory(id); }