62 std::map<int,std::unique_ptr<ReconTrack> > reconTracks;
63 for (
std::vector<art::Ptr<recob::Track> >::const_iterator trackIt = tracks.begin(); trackIt != tracks.end(); ++trackIt) {
64 std::unique_ptr<ReconTrack>
track = std::make_unique<ReconTrack>(trackIt->key());
65 track->SetVertex((*trackIt)->Vertex<TVector3>());
66 track->SetEnd((*trackIt)->End<TVector3>());
67 track->SetVertexDir((*trackIt)->VertexDirection<TVector3>());
68 track->SetLength((*trackIt)->Length());
69 track->SetDirection(
Gradient(*trackIt));
70 track->SetHits(fmht.at(trackIt->key()));
71 track->SetSpacePoints(fmspt.at(trackIt->key()));
72 const std::vector<art::Ptr<recob::SpacePoint> > spsss = fmspt.at(trackIt->key());
77 reconTracks[trackIt->key()] = std::move(track);
84 double avCylinderSpacePoints = 0;
85 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
87 TVector3 point = trackIt->second->Vertex();
88 TVector3 direction = trackIt->second->Direction();
103 for (
std::vector<art::Ptr<recob::SpacePoint> >::const_iterator spacePointIt = spacePoints.begin(); spacePointIt != spacePoints.end(); ++spacePointIt) {
104 const std::vector<art::Ptr<recob::Track> > spTracks = fmtsp.at(spacePointIt->key());
105 if (find_if(spTracks.begin(), spTracks.end(), [&trackIt](
const art::Ptr<recob::Track>& t){
return (
int)t.key() == trackIt->first; }) != spTracks.end())
109 TVector3 proj =
ProjPoint(pos, direction, point);
111 trackIt->second->AddCylinderSpacePoint(spacePointIt->key());
117 avCylinderSpacePoints += trackIt->second->CylinderSpacePointRatio();
119 avCylinderSpacePoints /= (double)reconTracks.size();
122 std::cout << std::endl <<
"Cylinder space point ratios:" << std::endl;
123 for (std::map<
int,std::unique_ptr<ReconTrack> >::const_iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt)
124 std::cout <<
" Track " << trackIt->first <<
" has cylinder space point ratio " << trackIt->second->CylinderSpacePointRatio() <<
" (event average " << avCylinderSpacePoints <<
")" << std::endl;
129 std::cout << std::endl <<
"Identifying tracks:" << std::endl;
130 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt)
131 if (trackIt->second->CylinderSpacePointRatio() / avCylinderSpacePoints <
fCylinderCut) {
133 std::cout <<
" Making track " << trackIt->first <<
" a track (Type I)" << std::endl;
134 trackIt->second->MakeTrack();
149 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
150 if (trackIt->second->IsTrack())
152 for (std::map<
int,std::unique_ptr<ReconTrack> >::const_iterator otherTrackIt = reconTracks.begin(); otherTrackIt != reconTracks.end(); ++otherTrackIt) {
153 if (trackIt->first == otherTrackIt->first or !otherTrackIt->second->IsTrack())
155 if ((trackIt->second->Vertex() - otherTrackIt->second->Vertex()).Mag() <
fTrackVertexCut or
156 (trackIt->second->Vertex() - otherTrackIt->second->End()).Mag() <
fTrackVertexCut or
157 (trackIt->second->End() - otherTrackIt->second->Vertex()).Mag() <
fTrackVertexCut or
158 (trackIt->second->End() - otherTrackIt->second->End()).Mag() <
fTrackVertexCut) {
160 std::cout <<
" Making track " << trackIt->first <<
" a track (Type II)" << std::endl;
161 trackIt->second->MakeTrack();
169 std::vector<art::Ptr<recob::SpacePoint> > showerSpacePoints;
170 for (
std::vector<art::Ptr<recob::SpacePoint> >::const_iterator spacePointIt = spacePoints.begin(); spacePointIt != spacePoints.end(); ++spacePointIt) {
171 bool showerSpacePoint =
true;
172 const std::vector<art::Ptr<recob::Track> > spacePointTracks = fmtsp.at(spacePointIt->key());
173 for (
std::vector<art::Ptr<recob::Track> >::const_iterator trackIt = spacePointTracks.begin(); trackIt != spacePointTracks.end(); ++trackIt)
174 if (reconTracks[trackIt->key()]->IsTrack())
175 showerSpacePoint =
false;
176 if (showerSpacePoint)
177 showerSpacePoints.push_back(*spacePointIt);
182 double avConeSize = 0;
183 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
184 for (
std::vector<art::Ptr<recob::SpacePoint> >::const_iterator spacePointIt = showerSpacePoints.begin(); spacePointIt != showerSpacePoints.end(); ++spacePointIt) {
185 bool associatedSpacePoint =
false;
186 const std::vector<art::Ptr<recob::Track> > spTracks = fmtsp.at(spacePointIt->key());
187 for (
std::vector<art::Ptr<recob::Track> >::const_iterator spTrackIt = spTracks.begin(); spTrackIt != spTracks.end(); ++spTrackIt)
188 if ((
int)spTrackIt->key() == trackIt->first)
189 associatedSpacePoint =
true;
190 if (associatedSpacePoint)
192 if ((
SpacePointPos(*spacePointIt) - trackIt->second->Vertex()).Angle(trackIt->second->Direction()) <
fConeAngle * TMath::Pi() / 180) {
193 trackIt->second->AddForwardSpacePoint(spacePointIt->key());
194 trackIt->second->AddForwardTrack(spTracks.at(0).key());
196 if ((
SpacePointPos(*spacePointIt) - trackIt->second->Vertex()).Angle(-1*trackIt->second->Direction()) <
fConeAngle * TMath::Pi() / 180) {
197 trackIt->second->AddBackwardSpacePoint(spacePointIt->key());
198 trackIt->second->AddBackwardTrack(spTracks.at(0).key());
201 avConeSize += trackIt->second->ConeSize();
203 avConeSize /= (double)reconTracks.size();
205 std::cout << std::endl <<
"Identifying showers:" << std::endl;
206 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
218 std::cout <<
" Track " << trackIt->first <<
" has space point cone size " << trackIt->second->ConeSize() <<
" and track cone size " << trackIt->second->TrackConeSize() << std::endl;
219 if (TMath::Abs(trackIt->second->ConeSize()) > 30
and TMath::Abs(trackIt->second->TrackConeSize()) > 3) {
220 trackIt->second->MakeShower();
222 std::cout <<
" Making track " << trackIt->first <<
" a shower (Type I)" << std::endl;
223 if (trackIt->second->ConeSize() < 0)
224 trackIt->second->FlipTrack();
229 std::cout << std::endl <<
" Shower cones:" << std::endl;
230 for (std::map<
int,std::unique_ptr<ReconTrack> >::const_iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
231 if (trackIt->second->IsShower()) {
233 std::cout <<
" Track " << trackIt->first << std::endl;
234 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator otherTrackIt = reconTracks.begin(); otherTrackIt != reconTracks.end(); ++otherTrackIt) {
235 if (trackIt->first == otherTrackIt->first or !otherTrackIt->second->IsUndetermined())
237 if ((otherTrackIt->second->Vertex()-trackIt->second->Vertex()).Angle(trackIt->second->Direction()) <
fConeAngle * TMath::Pi() / 180 or
238 (otherTrackIt->second->End()-trackIt->second->Vertex()).Angle(trackIt->second->Direction()) <
fConeAngle * TMath::Pi() / 180) {
239 std::cout <<
" " << otherTrackIt->first << std::endl;
240 otherTrackIt->second->MakeShower();
242 std::cout <<
" Making track " << otherTrackIt->first <<
" a shower (Type II)" << std::endl;
249 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt) {
250 if (trackIt->second->IsUndetermined()) {
253 trackIt->second->MakeShower();
257 std::cout << std::endl <<
"Event " <<
event <<
" track shower separation:" << std::endl;
258 std::cout <<
"Shower initial tracks are:" << std::endl;
259 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt)
260 if (trackIt->second->IsShowerTrack())
261 std::cout <<
" " << trackIt->first << std::endl;
263 std::cout <<
"Track tracks are:" << std::endl;
264 for (std::map<
int,std::unique_ptr<ReconTrack> >::iterator trackIt = reconTracks.begin(); trackIt != reconTracks.end(); ++trackIt)
265 if (trackIt->second->IsTrack())
266 std::cout <<
" " << trackIt->first << std::endl;
270 for (
std::vector<art::Ptr<recob::Hit> >::const_iterator hitIt = hits.begin(); hitIt != hits.end(); ++hitIt) {
271 bool showerHit =
true;
272 const std::vector<art::Ptr<recob::Track> > hitTracks = fmth.at(hitIt->key());
273 for (
std::vector<art::Ptr<recob::Track> >::const_iterator hitTrackIt = hitTracks.begin(); hitTrackIt != hitTracks.end(); ++hitTrackIt)
274 if (reconTracks[hitTrackIt->key()]->IsTrack())
277 showerHits.push_back(*hitIt);
TVector3 ProjPoint(const TVector3 &point, const TVector3 &direction, const TVector3 &origin=TVector3(0, 0, 0)) const
process_name use argoneut_mc_hitfinder track
TVector3 SpacePointPos(const art::Ptr< recob::SpacePoint > &spacePoint) const
Return 3D point of this space point.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
for($it=0;$it< $RaceTrack_number;$it++)
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
TVector3 Gradient(const std::vector< TVector3 > &points, const std::unique_ptr< TVector3 > &dir) const
BEGIN_PROLOG could also be cout