LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
TCCR.cxx
Go to the documentation of this file.
4 
5 namespace tca {
6 
8  void SaveCRInfo(TCSlice& slc, PFPStruct& pfp, bool prt, bool fIsRealData){
9 
10  //Check the origin of pfp
11  if (tcc.modes[kSaveCRTree]){
12  if (fIsRealData){
13  slc.crt.cr_origin.push_back(-1);
14  }
15  else{
16  slc.crt.cr_origin.push_back(GetOrigin(slc, pfp));
17  }
18  }
19 
20  // save the xmin and xmax of each pfp
21  slc.crt.cr_pfpxmin.push_back(std::min(pfp.XYZ[0][0], pfp.XYZ[1][0]));
22  slc.crt.cr_pfpxmax.push_back(std::max(pfp.XYZ[0][0], pfp.XYZ[1][0]));
23 
24  //find max
25  const geo::TPCGeo &tpc = tcc.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  slc.crt.cr_pfpyzmindis.push_back(mindis0+mindis1);
38 
39  if (slc.crt.cr_pfpxmin.back()<-2||
40  slc.crt.cr_pfpxmax.back()>260||
41  slc.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 = slc.allTraj[tjID - 1];
52  TrajPoint& beginPoint = tj.Pts[tj.EndPt[0]];
53  TrajPoint& endPoint = tj.Pts[tj.EndPt[1]];
54  if (beginPoint.Pos[1]/slc.unitsPerTick<minx){
55  minx = beginPoint.Pos[1]/slc.unitsPerTick;
56  }
57  if (beginPoint.Pos[1]/slc.unitsPerTick>maxx){
58  maxx = beginPoint.Pos[1]/slc.unitsPerTick;
59  }
60  if (endPoint.Pos[1]/slc.unitsPerTick<minx){
61  minx = endPoint.Pos[1]/slc.unitsPerTick;
62  }
63  if (endPoint.Pos[1]/slc.unitsPerTick>maxx){
64  maxx = endPoint.Pos[1]/slc.unitsPerTick;
65  }
66  } // tjID
67 
68  slc.crt.cr_pfpmintick.push_back(minx);
69  slc.crt.cr_pfpmaxtick.push_back(maxx);
70  */
71 // std::cout<<pfp.mcpListIndex<<std::endl;
72 // std::cout<<pfp.XYZ[0][0]<<" "<<pfp.XYZ[1][0]<<std::endl;
73 
74  }
75 
77  int GetOrigin(TCSlice& slc, PFPStruct& pfp){
78 
81 
82  std::map<int, float> omap; //<origin, energy>
83 
84  for(auto& tjID : pfp.TjIDs) {
85 
86  Trajectory& tj = slc.tjs[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& slhit = slc.slHits[iht];
92  auto& hit = (*evt.allHits)[slhit.allHitsIndex];
93  raw::ChannelID_t channel = tcc.geom->PlaneWireToChannel((int)hit.WireID().Plane, (int)hit.WireID().Wire, (int)hit.WireID().TPC, (int)hit.WireID().Cryostat);
94  double startTick = hit.PeakTime() - hit.RMS();
95  double endTick = hit.PeakTime() + hit.RMS();
96  // get a list of track IDEs that are close to this hit
97  std::vector<sim::TrackIDE> tides;
98  tides = bt_serv->ChannelToTrackIDEs(channel, startTick, endTick);
99  for(auto itide = tides.begin(); itide != tides.end(); ++itide) {
100  omap[pi_serv->TrackIdToMCTruth_P(itide->trackID)->Origin()] += itide->energy;
101  }
102  }
103  }
104  }
105 
106  float maxe = -1;
107  int origin = 0;
108  for (auto & i : omap){
109  if (i.second > maxe){
110  maxe = i.second;
111  origin = i.first;
112  }
113  }
114  return origin;
115  }
116 
118  void ClearCRInfo(TCSlice& slc){
119  slc.crt.cr_origin.clear();
120  slc.crt.cr_pfpxmin.clear();
121  slc.crt.cr_pfpxmax.clear();
122  slc.crt.cr_pfpyzmindis.clear();
123  }
124 }
std::vector< Trajectory > tjs
vector of all trajectories in each plane
Definition: DataStructs.h:570
std::vector< float > cr_pfpyzmindis
Definition: DataStructs.h:342
std::vector< float > cr_pfpxmax
Definition: DataStructs.h:341
TCConfig tcc
Definition: DataStructs.cxx:6
simb::Origin_t Origin() const
Definition: MCTruth.h:71
Geometry information for a single TPC.
Definition: TPCGeo.h:37
CRTreeVars crt
Definition: DataStructs.h:568
Int_t max
Definition: plot.C:27
std::array< Point3_t, 2 > XYZ
Definition: DataStructs.h:212
std::vector< TrajPoint > Pts
Trajectory points.
Definition: DataStructs.h:143
double MinZ() const
Returns the world z coordinate of the start of the box.
std::vector< int > cr_origin
Definition: DataStructs.h:339
void SaveCRInfo(TCSlice &slc, PFPStruct &pfp, bool prt, bool fIsRealData)
Definition: TCCR.cxx:8
int GetOrigin(TCSlice &slc, PFPStruct &pfp)
Definition: TCCR.cxx:77
const geo::GeometryCore * geom
Definition: DataStructs.h:493
Detector simulation of raw signals on wires.
double MaxY() const
Returns the world y coordinate of the end of the box.
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
std::vector< TCHit > slHits
Definition: DataStructs.h:569
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
save cosmic ray tree
Definition: DataStructs.h:454
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:207
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
std::vector< float > cr_pfpxmin
Definition: DataStructs.h:340
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
TCEvent evt
Definition: DataStructs.cxx:5
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
unsigned int allHitsIndex
Definition: DataStructs.h:529
double MinY() const
Returns the world y coordinate of the start of the box.
void ClearCRInfo(TCSlice &slc)
Definition: TCCR.cxx:118
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)