623 auto TrackHandle =
event.getHandle< std::vector<rec::Track> >(
fTrackLabel);
626 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
628 auto RecoClusterHandle =
event.getHandle< std::vector<rec::Cluster> >(
fClusterLabel);
629 if (!RecoClusterHandle) {
631 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
634 auto TrackIonHandle =
event.getHandle< std::vector<rec::TrackIoniz> >(
fTrackLabel);
635 if (!TrackIonHandle) {
636 throw cet::exception(
"HNLAnalysis") <<
" No rec::TrackIoniz branch." 637 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
640 art::FindOneP<rec::TrackIoniz>* findIonization = NULL;
641 findIonization =
new art::FindOneP<rec::TrackIoniz>(TrackHandle,
event,
fTrackLabel);
643 art::FindManyP<rec::Track, rec::TrackEnd>* findManyCALTrackEnd = NULL;
644 findManyCALTrackEnd =
new art::FindManyP<rec::Track, rec::TrackEnd>(RecoClusterHandle,
event,
fECALAssnLabel);
648 auto mctruthHandles =
event.getMany<std::vector<simb::MCTruth> >();
649 if (mctruthHandles.size()!=1) {
650 throw cet::exception(
"HNLAnalysis") <<
" Need just 1 simb::MCTruth" 651 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
654 auto MCPHandle =
event.getHandle< std::vector<simb::MCParticle> >(
fGeantLabel);
657 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
663 fEvent =
event.id().event();
668 for (
size_t imchl = 0; imchl < mctruthHandles.size(); ++imchl) {
669 for (
auto const& mct : (*mctruthHandles.at(imchl)) ) {
670 if(mct.NeutrinoSet()){
677 fW.push_back(nuw.
W());
678 fX.push_back(nuw.
X());
679 fY.push_back(nuw.
Y());
715 int nparticles = mct.NParticles();
716 for(
int i = 0; i < nparticles; i++){
726 fMCP_X.push_back(position.X());
727 fMCP_Y.push_back(position.Y());
728 fMCP_Z.push_back(position.Z());
730 fMCP_PX.push_back(momentum.Px());
731 fMCP_PY.push_back(momentum.Py());
732 fMCP_PZ.push_back(momentum.Pz());
734 TVector3 nupos(position.X(), position.Y(), position.Z());
746 std::unordered_map<TrkId, Int_t> TrackIdToIndex;
748 for (
auto const& mcp : (*MCPHandle) ) {
749 int TrackId = mcp.TrackId();
750 TrackIdToIndex[TrackId] = index++;
755 for (
auto const& track : (*TrackHandle) ) {
757 std::vector<std::pair<simb::MCParticle*,float>> MCsfromTrack;
760 int nMCsfromTrack = MCsfromTrack.size();
761 if(nMCsfromTrack==0){
766 for (
int iMCfromTrack =0; iMCfromTrack<nMCsfromTrack; ++iMCfromTrack) {
768 theMCPart = *(MCsfromTrack[iMCfromTrack].first);
770 if ( particle->Charge() == 0.0 )
continue;
771 if ( particle->Stable() == 0 )
continue;
779 bool whackThatECAL =
false;
780 for (
int iTraj=0; iTraj<nTraj; ++iTraj) {
781 doink.SetXYZ(theMCPart.
Vx(iTraj),theMCPart.
Vy(iTraj),theMCPart.
Vz(iTraj));
783 whackThatECAL =
true;
791 const TLorentzVector& positionMCP = theMCPart.
Position(0);
792 float distStart =
std::hypot(track.Vertex()[0] -positionMCP[0],
793 track.Vertex()[1] -positionMCP[1],
794 track.Vertex()[2] -positionMCP[2]);
795 float distEnd =
std::hypot(track.End()[0] -positionMCP[0],
796 track.End()[1] -positionMCP[1],
797 track.End()[2] -positionMCP[2]);
801 std::vector< std::pair<int, float> >
pid;
806 fTrackX.push_back (track.Vertex()[0]);
807 fTrackY.push_back (track.Vertex()[1]);
808 fTrackZ.push_back (track.Vertex()[2]);
809 fTrackPX.push_back (track.Momentum_beg()*track.VtxDir()[0]);
810 fTrackPY.push_back (track.Momentum_beg()*track.VtxDir()[1]);
811 fTrackPZ.push_back (track.Momentum_beg()*track.VtxDir()[2]);
812 fTrackP.push_back (track.Momentum_beg());
813 fTrackQ.push_back (track.ChargeBeg());
814 fTrackLen.push_back (track.LengthForward());
820 fTrackEndPX.push_back (track.Momentum_end()*track.EndDir()[0]);
821 fTrackEndPY.push_back (track.Momentum_end()*track.EndDir()[1]);
822 fTrackEndPZ.push_back (track.Momentum_end()*track.EndDir()[2]);
830 fTrackX.push_back (track.End()[0]);
831 fTrackY.push_back (track.End()[1]);
832 fTrackZ.push_back (track.End()[2]);
833 fTrackPX.push_back (track.Momentum_end()*track.EndDir()[0]);
834 fTrackPY.push_back (track.Momentum_end()*track.EndDir()[1]);
835 fTrackPZ.push_back (track.Momentum_end()*track.EndDir()[2]);
836 fTrackP.push_back (track.Momentum_end());
837 fTrackQ.push_back (track.ChargeEnd());
838 fTrackLen.push_back (track.LengthBackward());
844 fTrackEndPX.push_back (track.Momentum_beg()*track.VtxDir()[0]);
845 fTrackEndPY.push_back (track.Momentum_beg()*track.VtxDir()[1]);
846 fTrackEndPZ.push_back (track.Momentum_beg()*track.VtxDir()[2]);
857 float pidhypo[5] = {5.0, 5.0, 5.0, 5.0, 5.0};
858 for(
size_t ipid = 0; ipid < pid.size(); ipid++){
859 if(pid.at(ipid).first == 1000010020)
continue;
860 if (pid.at(ipid).first == 13 && pid.at(ipid).second < pidhypo[0]) pidhypo[0] = pid.at(ipid).second;
861 else if(pid.at(ipid).first == 211 && pid.at(ipid).second < pidhypo[1]) pidhypo[1] = pid.at(ipid).second;
862 else if(pid.at(ipid).first == 321 && pid.at(ipid).second < pidhypo[2]) pidhypo[2] = pid.at(ipid).second;
863 else if(pid.at(ipid).first == 2212 && pid.at(ipid).second < pidhypo[3]) pidhypo[3] = pid.at(ipid).second;
864 else if(pid.at(ipid).first == 11 && pid.at(ipid).second < pidhypo[4]) pidhypo[4] = pid.at(ipid).second;
867 for(
int ihypo = 0; ihypo < 5; ihypo++){
868 if(pidhypo[ihypo] == 5.0) pidhypo[ihypo] = 0.0;
873 if(trpdg == 22) trpdg = 11;
874 else if(trpdg == 2112) trpdg = 2212;
876 CLHEP::RandFlat FlatRand(
fEngine);
877 if( (trpdg == 11 and pidhypo[4] == 1) ||
878 (trpdg == 13 and pidhypo[0] == 1) ||
879 (trpdg == 211 and pidhypo[1] == 1) ||
880 (trpdg == 321 and pidhypo[2] == 1) ||
881 (trpdg == 2212 and pidhypo[3] == 1) ) {
886 for(
int ihypo = 0; ihypo < 5; ihypo++){
887 if(pidhypo[ihypo] == 1 || pidhypo[ihypo] == 0)
continue;
889 float random_number = FlatRand.fire();
890 if(random_number < pidhypo[ihypo]){
896 if (pidpdg == 0)
fTrackPID.push_back(13);
897 else if(pidpdg == 1)
fTrackPID.push_back(211);
898 else if(pidpdg == 2)
fTrackPID.push_back(321);
899 else if(pidpdg == 3)
fTrackPID.push_back(2212);
900 else if(pidpdg == 4)
fTrackPID.push_back(11);
905 std::vector<ULong64_t> clusterID;
907 for (
auto const&
cluster : (*RecoClusterHandle) ) {
909 if ( findManyCALTrackEnd->isValid() ) {
910 nCALedTracks = findManyCALTrackEnd->at(iCluster).size();
913 for (
int iCALedTrack=0; iCALedTrack<nCALedTracks; ++iCALedTrack) {
914 rec::Track temptrack = *(findManyCALTrackEnd->at(iCluster).at(iCALedTrack));
915 if(temptrack.getIDNumber() == track.getIDNumber()){
916 clusterID.push_back(
cluster.getIDNumber());
927 if(clusterID.size() > 0){
929 for (
auto const&
cluster : (*RecoClusterHandle) ) {
930 for(
long unsigned int i = 0; i < clusterID.size(); i++){
931 if(clusterID.at(i) ==
cluster.getIDNumber()){
953 if (findIonization->isValid()) {
955 rec::TrackIoniz ionization = *(findIonization->at(iTrack));
956 float avgIonF, avgIonB;
972 TrkId momTrkId = theMCPart.
Mother();
975 int momIndex = TrackIdToIndex[momTrkId];
976 momPDG = (*MCPHandle).at(momIndex).PdgCode();
980 const TLorentzVector& position = theMCPart.
Position(0);
984 const TLorentzVector& momentum = theMCPart.
Momentum(0);
998 for (
size_t imchl = 0; imchl < mctruthHandles.size(); ++imchl) {
999 for (
auto const& mct : (*mctruthHandles.at(imchl)) ) {
1000 if (mct.NeutrinoSet()) {
1002 Float_t vertX = nuw.
Nu().
EndX();
1003 Float_t vertY = nuw.
Nu().
EndY();
1004 Float_t vertZ = nuw.
Nu().
EndZ();
1005 Float_t
dist =
std::hypot(position.X()-vertX,position.Y()-vertY,position.Z()-vertZ);
1013 f_W.push_back(nuw.
W());
1014 f_X.push_back(nuw.
X());
1015 f_Y.push_back(nuw.
Y());
1090 if(iTrack > 0)
fTree->Fill();
double E(const int i=0) const
std::vector< Float_t > fMCPStartPX
std::vector< Float_t > fY
std::vector< Float_t > fTrackEndPX
unsigned int NumberTrajectoryPoints() const
std::vector< Int_t > fClusterNhits
std::vector< Float_t > fTrackPZ
const TLorentzVector & Position(const int i=0) const
std::vector< Float_t > fMCVertexZ
double Theta() const
angle between incoming and outgoing leptons, in radians
double Py(const int i=0) const
std::vector< Float_t > fTheta
std::vector< std::pair< int, float > > processPIDInfo(float p)
std::vector< Int_t > f_Mode
std::vector< Float_t > fQ2
std::vector< Float_t > fMCnuPz
std::vector< Float_t > fMCPStartPY
std::vector< Float_t > fMCP_PZ
std::vector< Float_t > fMCPStartZ
std::vector< Float_t > fTrackPX
bool PointInECALEndcap(TVector3 const &point) const
std::vector< Float_t > fW
cheat::BackTrackerCore * fBack
std::vector< Int_t > f_NeutrinoType
const simb::MCParticle & Nu() const
std::vector< Int_t > fMCP_PDG
bool PointInGArTPC(TVector3 const &point) const
std::vector< Double_t > fTrackTime
double Px(const int i=0) const
std::vector< Float_t > fMCP_PY
std::vector< Float_t > fX
std::vector< Float_t > fClusterTheta
std::vector< Int_t > fMCVertexInGasTPC
std::vector< Float_t > fMCnuPx
TDatabasePDG * pdgInstance
Cluster finding and building.
std::vector< Float_t > f_MCnuE
TrackEnd const TrackEndEnd
std::vector< Float_t > fMCnuE
std::string Process() const
std::vector< Float_t > fMCP_X
std::vector< Int_t > fMCP_InGasTPC
std::vector< Int_t > fCCNC
std::vector< Int_t > fMCPDG
std::vector< Float_t > fClusterZ
std::vector< Float_t > fTrackEndP
std::vector< Float_t > f_Q2
std::vector< Float_t > fMCVertexX
std::vector< Int_t > fMCP_TrackID
std::vector< Int_t > fTrackEndQ
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
std::vector< Float_t > f_W
std::vector< Float_t > fTrackEndX
std::vector< Float_t > f_Theta
std::vector< Float_t > fTrackEndZ
std::vector< std::string > fMCPEndProc
std::vector< Int_t > fMode
std::vector< Float_t > fClusterX
std::vector< Float_t > fTrackZ
int InteractionType() const
std::vector< Float_t > fMCPStartEndP
std::vector< Float_t > fMCPStartPZ
CLHEP::HepRandomEngine & fEngine
random engine
std::vector< Float_t > fClusterTimeDiffFirstLast
void processIonizationInfo(rec::TrackIoniz &ion, float ionizeTruncate, float &forwardIonVal, float &backwardIonVal)
std::string EndProcess() const
std::vector< Float_t > fTrackEndY
std::vector< Int_t > fMCPDGMother
double P(const int i=0) const
double T(const int i=0) const
std::vector< Float_t > fMCPStartY
std::vector< Float_t > fClusterPhi
std::vector< Int_t > fMCPTrackID
std::vector< Float_t > fTrackLen
std::vector< Int_t > fClusterPID
float fIonizTruncate
Default=1.00;.
bool PointInECALBarrel(TVector3 const &point) const
std::vector< Float_t > fTrackPY
float fMatchMCPtoVertDist
Default=roundoff.
std::vector< Float_t > f_MCVertexZ
std::vector< Float_t > fClusterMainAxisX
std::vector< Float_t > fClusterTime
std::vector< Int_t > f_TgtPDG
std::vector< Float_t > fMCP_PX
std::vector< Float_t > fTrackY
std::vector< Int_t > fTrackQ
std::vector< Float_t > fTrackEndPY
std::vector< Int_t > fMCPInECal
std::vector< Float_t > f_X
std::string fECALAssnLabel
double Vx(const int i=0) const
std::vector< Float_t > fMCPStartP
std::vector< Float_t > fTrackEndPZ
TrackEnd const TrackEndBeg
std::vector< Float_t > fTrackChi2
std::vector< Int_t > fNECalClustersForTrack
std::vector< Int_t > f_MCVertexInGasTPC
std::vector< ULong64_t > fTrackIDNumber
std::vector< Int_t > f_CCNC
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
std::vector< std::pair< simb::MCParticle *, float > > TrackToMCParticles(rec::Track *const t)
std::vector< Float_t > fTrackAvgIon
std::vector< Float_t > f_MCVertexX
std::vector< Float_t > f_MCVertexY
std::vector< Int_t > fNeutrinoType
const TLorentzVector & Momentum(const int i=0) const
std::vector< Int_t > f_InteractionType
double Pz(const int i=0) const
std::vector< Float_t > fMCnuPy
std::vector< Float_t > fClusterMainAxisZ
std::vector< Int_t > fNTPCClustersOnTrack
std::vector< Float_t > fMCVertexY
std::vector< Int_t > fInteractionType
double Vz(const int i=0) const
std::vector< Float_t > fTrackX
std::vector< Float_t > f_Y
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
std::vector< Float_t > fMCP_E
int GetECalPIDParameterized(int pdg, float ptrue)
std::vector< Float_t > fMCPStartX
std::vector< Int_t > fTgtPDG
std::vector< std::string > fMCPProc
std::vector< Float_t > fMCPTime
def momentum(x1, x2, x3, scale=1.)
std::vector< Float_t > fMCP_Z
const gar::geo::GeometryCore * fGeo
Event generator information.
std::vector< Float_t > fMCP_T
std::string fClusterLabel
std::vector< Float_t > fMCP_Y
std::vector< Int_t > fTrackPID
std::vector< Int_t > fClusterTrackIDMatched
double Vy(const int i=0) const
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
std::vector< Float_t > fClusterEnergy
std::vector< Float_t > fClusterY
std::vector< Float_t > fClusterMainAxisY
std::vector< Float_t > fTrackP