949 TPCClusterHandle =
e.getHandle< std::vector<rec::TPCCluster> >(
fTPCClusterLabel);
950 if (!TPCClusterHandle) {
952 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
960 art::FindManyP<rec::TPCCluster>* findManyTPCClusters = NULL;
961 art::FindOneP<rec::TrackIoniz>* findIonization = NULL;
963 TrackHandle =
e.getHandle< std::vector<rec::Track> >(
fTrackLabel);
966 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
968 TrackIonHandle =
e.getHandle< std::vector<rec::TrackIoniz> >(
fTrackLabel);
969 if (!TrackIonHandle) {
971 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
974 findManyTPCClusters =
new art::FindManyP<rec::TPCCluster>(TrackHandle,
e,
fTrackLabel);
975 findIonization =
new art::FindOneP<rec::TrackIoniz>(TrackHandle,
e,
fTrackLabel);
979 if (!TrackTrajHandle) {
980 throw cet::exception(
"CAFMaker") <<
" No rec::TrackTrajectory branch." 981 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
988 art::FindManyP<rec::Track, rec::TrackEnd>* findManyTrackEnd = NULL;
990 VertexHandle = e.getHandle< std::vector<rec::Vertex> >(
fVertexLabel);
993 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
995 findManyTrackEnd =
new art::FindManyP<rec::Track, rec::TrackEnd>(VertexHandle,
e,
fVertexLabel);
1000 art::FindManyP<rec::Track, rec::TrackEnd>* findManyVeeTrackEnd = NULL;
1002 VeeHandle = e.getHandle< std::vector<rec::Vee> >(
fVeeLabel);
1005 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
1007 findManyVeeTrackEnd =
new art::FindManyP<rec::Track, rec::TrackEnd>(VeeHandle,
e,
fVeeLabel);
1015 art::FindManyP<rec::Track, rec::TrackEnd>* findManyCALTrackEnd = NULL;
1020 RecoClusterHandle = e.getHandle< std::vector<rec::Cluster> >(ecalclustertag);
1021 if (!RecoClusterHandle) {
1023 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
1029 RecoClusterMuIDHandle = e.getHandle< std::vector<rec::Cluster> >(muidclustertag);
1030 if (!RecoClusterMuIDHandle) {
1031 throw cet::exception(
"CAFMaker") <<
" No rec::Cluster (MuID) branch." 1032 <<
" Line " << __LINE__ <<
" in file " << __FILE__ <<
std::endl;
1043 findManyCALTrackEnd =
new art::FindManyP<rec::Track, rec::TrackEnd>(RecoClusterHandle,
e,
fECALAssnLabel);
1050 for (
auto const& TPCCluster : (*TPCClusterHandle) ) {
1052 srclust.
x = TPCCluster.Position()[0];
1053 srclust.
y = TPCCluster.Position()[1];
1054 srclust.
z = TPCCluster.Position()[2];
1055 srclust.
sig = TPCCluster.Signal();
1056 srclust.
rms = TPCCluster.RMS();
1057 const float* cov = TPCCluster.CovMatPacked();
1058 srclust.
cov.
xx = cov[0];
1059 srclust.
cov.
xy = cov[1];
1060 srclust.
cov.
xz = cov[2];
1061 srclust.
cov.
yy = cov[3];
1062 srclust.
cov.
yz = cov[4];
1063 srclust.
cov.
zz = cov[5];
1065 Int_t trackForThisTPCluster = -1;
1068 for (
auto const& track : (*TrackHandle) ) {
1069 for (
size_t iCluster=0; iCluster<track.NHits(); iCluster++) {
1070 auto const& trackedCluster =
1071 *(findManyTPCClusters->at(iTrack).at(iCluster));
1072 if (TPCCluster==trackedCluster) {
1073 trackForThisTPCluster = track.getIDNumber();
1082 srclust.
trkid = trackForThisTPCluster;
1092 for (
auto const& track : (*TrackHandle) ) {
1096 srtrk.
id = track.getIDNumber();
1102 track.Momentum_beg()*track.VtxDir()[1],
1103 track.Momentum_beg()*track.VtxDir()[2]);
1104 srtrk.
startq = track.ChargeBeg();
1110 track.Momentum_end()*track.EndDir()[1],
1111 track.Momentum_end()*track.EndDir()[2]);
1112 srtrk.
endq = track.ChargeEnd();
1114 srtrk.
fwd.
len = track.LengthForward();
1115 srtrk.
bak.
len = track.LengthBackward();
1116 srtrk.
fwd.
chi2 = track.ChisqForward();
1117 srtrk.
bak.
chi2 = track.ChisqBackward();
1121 TVector3 momF(track.Momentum_beg()*track.VtxDir()[0], track.Momentum_beg()*track.VtxDir()[1], track.Momentum_beg()*track.VtxDir()[2]);
1122 TVector3 momB(track.Momentum_end()*track.EndDir()[0], track.Momentum_end()*track.EndDir()[1], track.Momentum_end()*track.EndDir()[2]);
1125 float pF = momF.Mag();
1126 float pB = momB.Mag();
1127 std::vector< std::pair<int, float> > pidF =
processPIDInfo( pF );
1128 std::vector< std::pair<int, float> > pidB =
processPIDInfo( pB );
1131 for(
size_t ipid = 0; ipid < pidF.size(); ipid++) {
1133 srpid.
id = pidF.at(ipid).first;
1134 srpid.
prob = pidF.at(ipid).second;
1135 srtrk.
fwd.
pid.push_back(srpid);
1137 for(
size_t ipid = 0; ipid < pidB.size(); ipid++) {
1139 srpid.
id = pidB.at(ipid).first;
1140 srpid.
prob = pidB.at(ipid).second;
1141 srtrk.
bak.
pid.push_back(srpid);
1145 std::vector<std::pair<simb::MCParticle*,float>> trakt;
1152 if (srtrk.
mcidx > -1) {
1153 srtrk.
mcfrac = trakt[0].second;
1158 if (findIonization->isValid()) {
1160 rec::TrackIoniz ionization = *(findIonization->at(iTrack));
1161 float avgIonF, avgIonB;
1171 rec.
trk.push_back(srtrk);
1179 size_t iTrackTraj = 0;
1180 for (
auto const& tracktraj : (*TrackTrajHandle) ) {
1183 std::vector<TVector3>
temp = tracktraj.getFWDTrajectory();
1184 for(
size_t i = 0; i < temp.size(); i++) {
1185 srtrk.
fwd.
traj.emplace_back(temp.at(i).X(),
1190 temp = tracktraj.getBAKTrajectory();
1191 for(
size_t i = 0; i < temp.size(); i++) {
1192 srtrk.
bak.
traj.emplace_back(temp.at(i).X(),
1203 for (
auto const&
vertex : (*VertexHandle) ) {
1206 srvtx.
x =
vertex.Position()[0];
1207 srvtx.
y =
vertex.Position()[1];
1208 srvtx.
z =
vertex.Position()[2];
1212 if ( findManyTrackEnd->isValid() ) {
1213 srvtx.
ntrks = findManyTrackEnd->at(iVertex).size();
1216 int vertexCharge = 0;
1217 for (
int iVertexedTrack=0; iVertexedTrack < srvtx.
ntrks; ++iVertexedTrack) {
1223 rec::Track track = *(findManyTrackEnd->at(iVertex).at(iVertexedTrack));
1224 srassn.
trkid = track.getIDNumber();
1231 rec::TrackEnd fee = *(findManyTrackEnd->data(iVertex).at(iVertexedTrack));
1235 rec.
assn.
vtx.push_back(srassn);
1238 vertexCharge += track.ChargeBeg();
1240 vertexCharge += track.ChargeEnd();
1243 srvtx.
Q = vertexCharge;
1246 rec.
vtx.push_back(srvtx);
1256 for (
auto const& vee : (*VeeHandle) ) {
1258 srvee.
id = vee.getIDNumber();
1259 srvee.
x = vee.Position()[0];
1260 srvee.
y = vee.Position()[1];
1261 srvee.
z = vee.Position()[2];
1262 srvee.
t = vee.Time();
1263 srvee.
Kpipi.
p.
x = vee.FourMomentum(0).X();
1264 srvee.
Kpipi.
p.
y = vee.FourMomentum(0).Y();
1265 srvee.
Kpipi.
p.
z = vee.FourMomentum(0).Z();
1266 srvee.
Kpipi.
E = vee.FourMomentum(0).E();
1267 srvee.
Kpipi.
m = vee.FourMomentum(0).M();
1268 srvee.
Lppi.
p.
x = vee.FourMomentum(1).X();
1269 srvee.
Lppi.
p.
y = vee.FourMomentum(1).Y();
1270 srvee.
Lppi.
p.
z = vee.FourMomentum(1).Z();
1271 srvee.
Lppi.
E = vee.FourMomentum(1).E();
1272 srvee.
Lppi.
m = vee.FourMomentum(1).M();
1273 srvee.
Lpip.
p.
x = vee.FourMomentum(2).X();
1274 srvee.
Lpip.
p.
y = vee.FourMomentum(2).Y();
1275 srvee.
Lpip.
p.
z = vee.FourMomentum(2).Z();
1276 srvee.
Lpip.
E = vee.FourMomentum(2).E();
1277 srvee.
Lpip.
m = vee.FourMomentum(2).M();
1279 rec.
vee.push_back(srvee);
1282 if ( findManyVeeTrackEnd->isValid() ) {
1283 nVeeTracks = findManyVeeTrackEnd->at(iVee).size();
1286 for (
int iVeeTrack=0; iVeeTrack<nVeeTracks; ++iVeeTrack) {
1288 srassn.
veeid = vee.getIDNumber();
1291 rec::Track track = *(findManyVeeTrackEnd->at(iVee).at(iVeeTrack));
1292 srassn.
trkid = track.getIDNumber();
1294 rec::TrackEnd fee = *(findManyVeeTrackEnd->data(iVee).at(iVeeTrack));
1298 rec.
assn.
vee.push_back(srassn);
1309 for (
auto const&
cluster : (*RecoClusterHandle) ) {
1328 std::vector<std::pair<simb::MCParticle*,float>> trakt;
1334 if (srclust.
mcidx > -1) {
1335 srclust.
mcfrac = trakt[0].second;
1344 for (
auto const&
cluster : (*RecoClusterMuIDHandle) ) {
1363 std::vector<std::pair<simb::MCParticle*,float>> trakt;
1369 if (srclust.
mcidx > -1) {
1370 srclust.
mcfrac = trakt[0].second;
1385 size_t iCluster = 0;
1386 for (
auto const&
cluster : (*RecoClusterHandle) ) {
1387 int nCALedTracks(0);
1388 if ( findManyCALTrackEnd->isValid() ) {
1389 nCALedTracks = findManyCALTrackEnd->at(iCluster).size();
1391 for (
int iCALedTrack=0; iCALedTrack<nCALedTracks; ++iCALedTrack) {
1394 rec::Track track = *(findManyCALTrackEnd->at(iCluster).at(iCALedTrack));
1395 srassn.
trkid = track.getIDNumber();
1397 rec::TrackEnd fee = *(findManyCALTrackEnd->data(iCluster).at(iCALedTrack));
std::string fClusterLabel
module label for calo clusters rec::Cluster
std::vector< SRTrackPID > pid
bool fWriteCaloClusters
Write ECAL clusters. Default=true.
A 3-vector with more efficient storage than TVector3.
std::string fInstanceLabelCalo
Instance name for ECAL.
std::string fTPCClusterLabel
module label for TPC Clusters rec::TPCCluster
bool fWriteTPCClusters
Write TPCClusters info Default=true.
bool fWriteVertices
Reco vertexes & their tracks Default=true.
Cluster finding and building.
std::vector< SRClusterAssn > ecalclust
std::vector< SRVeeAssn > vee
bool fWriteTracks
Start/end X, P for tracks Default=true.
std::string fTrackLabel
module label for TPC Tracks rec:Track
void processIonizationInfo(rec::TrackIoniz &ion, float ionizeTruncate, float &forwardIonVal, float &backwardIonVal)
std::vector< std::pair< simb::MCParticle *, float > > ClusterToMCParticles(rec::Cluster *const c)
const geo::GeometryCore * fGeo
pointer to the geometry
std::unordered_map< TrkId, Int_t > TrackIdToIndex
bool fWriteVees
Reco vees & their tracks Default=true.
float avgion
average ionization
cheat::BackTrackerCore * BackTrack
bool fWriteMatchedTracks
Write ECAL-track Assns Default=true.
std::vector< SRTrack > trk
SRVector3D start
Track 3D start point.
SRVector3D end
Track 3D end point.
std::string fClusterMuIDLabel
module label for calo clusters rec::Cluster in MuID
std::string fVertexLabel
module label for vertexes rec:Vertex
std::vector< SRVector3D > traj
std::vector< SRMuIDCluster > muid
std::vector< std::pair< int, float > > processPIDInfo(float p)
std::string fTrackTrajectoryLabel
module label for TPC Track Trajectories rec:TrackTrajectory
TrackEnd const TrackEndBeg
bool fWriteTrackTrajectories
Point traj of reco tracks Default=false.
float fIonizTruncate
Default=1.00;.
std::vector< std::pair< simb::MCParticle *, float > > TrackToMCParticles(rec::Track *const t)
bool HasMuonDetector() const
std::string fVeeLabel
module label for conversion/decay vertexes rec:Vee
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
std::vector< SRECalCluster > ecal
std::string fInstanceLabelMuID
Instance name for MuID.
std::vector< SRVertexAssn > vtx
std::vector< SRVertex > vtx
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
std::string fECALAssnLabel
module label for track-clusters associations
std::vector< SRTPCCluster > tpc