LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
TCCR.cxx
Go to the documentation of this file.
4 
5 namespace tca {
6 
8  void SaveCRInfo(TjStuff& tjs, PFPStruct& pfp, bool prt, bool fIsRealData){
9 
10  //Check the origin of pfp
11  if (tjs.SaveCRTree){
12  if (fIsRealData){
13  tjs.crt.cr_origin.push_back(-1);
14  }
15  else{
16  tjs.crt.cr_origin.push_back(GetOrigin(tjs, pfp));
17  }
18  }
19 
20  // save the xmin and xmax of each pfp
21  tjs.crt.cr_pfpxmin.push_back(std::min(pfp.XYZ[0][0], pfp.XYZ[1][0]));
22  tjs.crt.cr_pfpxmax.push_back(std::max(pfp.XYZ[0][0], pfp.XYZ[1][0]));
23 
24  //find max
25  const geo::TPCGeo &tpc = tjs.geom->TPC(0);
26  float mindis0 = FLT_MAX;
27  float mindis1 = FLT_MAX;
28  if (std::abs(pfp.XYZ[0][1] - tpc.MinY())<mindis0) mindis0 = std::abs(pfp.XYZ[0][1] - tpc.MinY());
29  if (std::abs(pfp.XYZ[0][1] - tpc.MaxY())<mindis0) mindis0 = std::abs(pfp.XYZ[0][1] - tpc.MaxY());
30  if (std::abs(pfp.XYZ[0][2] - tpc.MinZ())<mindis0) mindis0 = std::abs(pfp.XYZ[0][2] - tpc.MinZ());
31  if (std::abs(pfp.XYZ[0][2] - tpc.MaxZ())<mindis0) mindis0 = std::abs(pfp.XYZ[0][2] - tpc.MaxZ());
32  if (std::abs(pfp.XYZ[1][1] - tpc.MinY())<mindis1) mindis1 = std::abs(pfp.XYZ[1][1] - tpc.MinY());
33  if (std::abs(pfp.XYZ[1][1] - tpc.MaxY())<mindis1) mindis1 = std::abs(pfp.XYZ[1][1] - tpc.MaxY());
34  if (std::abs(pfp.XYZ[1][2] - tpc.MinZ())<mindis1) mindis1 = std::abs(pfp.XYZ[1][2] - tpc.MinZ());
35  if (std::abs(pfp.XYZ[1][2] - tpc.MaxZ())<mindis1) mindis1 = std::abs(pfp.XYZ[1][2] - tpc.MaxZ());
36  //std::cout<<pfp.XYZ[0][1]<<" "<<pfp.XYZ[0][2]<<" "<<pfp.XYZ[1][1]<<" "<<pfp.XYZ[1][2]<<" "<<tpc.MinY()<<" "<<tpc.MaxY()<<" "<<tpc.MinZ()<<" "<<tpc.MaxZ()<<" "<<mindis0<<" "<<mindis1<<" "<<mindis0+mindis1<<std::endl;
37  tjs.crt.cr_pfpyzmindis.push_back(mindis0+mindis1);
38 
39  if (tjs.crt.cr_pfpxmin.back()<-2||
40  tjs.crt.cr_pfpxmax.back()>260||
41  tjs.crt.cr_pfpyzmindis.back()<30){
42  pfp.CosmicScore = 1.;
43  }
44  else pfp.CosmicScore = 0;
45 
46  /*
47  float minx = FLT_MAX;
48  float maxx = FLT_MIN;
49 
50  for(auto& tjID : pfp.TjIDs) {
51  Trajectory& tj = tjs.allTraj[tjID - 1];
52  TrajPoint& beginPoint = tj.Pts[tj.EndPt[0]];
53  TrajPoint& endPoint = tj.Pts[tj.EndPt[1]];
54  if (beginPoint.Pos[1]/tjs.UnitsPerTick<minx){
55  minx = beginPoint.Pos[1]/tjs.UnitsPerTick;
56  }
57  if (beginPoint.Pos[1]/tjs.UnitsPerTick>maxx){
58  maxx = beginPoint.Pos[1]/tjs.UnitsPerTick;
59  }
60  if (endPoint.Pos[1]/tjs.UnitsPerTick<minx){
61  minx = endPoint.Pos[1]/tjs.UnitsPerTick;
62  }
63  if (endPoint.Pos[1]/tjs.UnitsPerTick>maxx){
64  maxx = endPoint.Pos[1]/tjs.UnitsPerTick;
65  }
66  } // tjID
67 
68  tjs.crt.cr_pfpmintick.push_back(minx);
69  tjs.crt.cr_pfpmaxtick.push_back(maxx);
70  */
71 // std::cout<<pfp.MCPartListIndex<<std::endl;
72 // std::cout<<pfp.XYZ[0][0]<<" "<<pfp.XYZ[1][0]<<std::endl;
73 
74  }
75 
77  int GetOrigin(TjStuff& tjs, PFPStruct& pfp){
78 
81 
82  std::map<int, float> omap; //<origin, energy>
83 
84  for(auto& tjID : pfp.TjIDs) {
85 
86  Trajectory& tj = tjs.allTraj[tjID - 1];
87  for(auto& tp : tj.Pts) {
88  for(unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
89  if(!tp.UseHit[ii]) continue;
90  unsigned int iht = tp.Hits[ii];
91  TCHit& hit = tjs.fHits[iht];
92  raw::ChannelID_t channel = tjs.geom->PlaneWireToChannel((int)hit.ArtPtr->WireID().Plane, (int)hit.ArtPtr->WireID().Wire, (int)hit.ArtPtr->WireID().TPC, (int)hit.ArtPtr->WireID().Cryostat);
93  double startTick = hit.PeakTime - hit.RMS;
94  double endTick = hit.PeakTime + hit.RMS;
95  // get a list of track IDEs that are close to this hit
96  std::vector<sim::TrackIDE> tides;
97  tides = bt_serv->ChannelToTrackIDEs(channel, startTick, endTick);
98  for(auto itide = tides.begin(); itide != tides.end(); ++itide) {
99  omap[pi_serv->TrackIdToMCTruth_P(itide->trackID)->Origin()] += itide->energy;
100  }
101  }
102  }
103  }
104 
105  float maxe = -1;
106  int origin = 0;
107  for (auto & i : omap){
108  if (i.second > maxe){
109  maxe = i.second;
110  origin = i.first;
111  }
112  }
113  return origin;
114  }
115 
117  void ClearCRInfo(TjStuff& tjs){
118  tjs.crt.cr_origin.clear();
119  tjs.crt.cr_pfpxmin.clear();
120  tjs.crt.cr_pfpxmax.clear();
121  tjs.crt.cr_pfpyzmindis.clear();
122  }
123 }
std::vector< float > cr_pfpyzmindis
Definition: DataStructs.h:370
art::Ptr< recob::Hit > ArtPtr
Definition: DataStructs.h:206
std::vector< float > cr_pfpxmax
Definition: DataStructs.h:369
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
simb::Origin_t Origin() const
Definition: MCTruth.h:71
Geometry information for a single TPC.
Definition: TPCGeo.h:37
CRTreeVars crt
Definition: DataStructs.h:489
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
Int_t max
Definition: plot.C:27
std::array< Point3_t, 2 > XYZ
Definition: DataStructs.h:241
const geo::GeometryCore * geom
Definition: DataStructs.h:526
std::vector< TrajPoint > Pts
Trajectory points.
Definition: DataStructs.h:169
std::vector< Trajectory > allTraj
vector of all trajectories in each plane
Definition: DataStructs.h:493
double MinZ() const
Returns the world z coordinate of the start of the box.
std::vector< int > cr_origin
Definition: DataStructs.h:367
void SaveCRInfo(TjStuff &tjs, PFPStruct &pfp, bool prt, bool fIsRealData)
Definition: TCCR.cxx:8
int GetOrigin(TjStuff &tjs, PFPStruct &pfp)
Definition: TCCR.cxx:77
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
double MaxY() const
Returns the world y coordinate of the end of the box.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
std::vector< TCHit > fHits
Definition: DataStructs.h:495
Int_t min
Definition: plot.C:26
double MaxZ() const
Returns the world z coordinate of the end of the box.
std::vector< int > TjIDs
Definition: DataStructs.h:237
float PeakTime
Definition: DataStructs.h:198
std::vector< float > cr_pfpxmin
Definition: DataStructs.h:368
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
void ClearCRInfo(TjStuff &tjs)
Definition: TCCR.cxx:117
double MinY() const
Returns the world y coordinate of the start of the box.
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time)
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:230
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id)