All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sim::MCTrackCollectionAnaAlg Class Reference

#include <MCTrackCollectionAnaAlg.h>

Public Member Functions

 MCTrackCollectionAnaAlg ()
 
void SetOutputTree (TTree *, bool fill=true)
 
void FillTree (unsigned int, unsigned int, const std::vector< sim::MCTrack > &)
 

Private Member Functions

void FillDominantParticleInfo (const sim::MCTrack &)
 

Private Attributes

TTree * fTree
 
bool fFillTree
 
unsigned int fRun
 
unsigned int fEvent
 
unsigned int fNMCTracks
 
unsigned int fDParticle
 
float fDParticleFraction
 
int fDParticleOrigin
 
int fDParticlePdgCode
 
unsigned int fDParticleTrackId
 
float fDParticleStartY
 
float fDParticleStartZ
 
float fDParticleStartX
 
float fDParticleStartE
 
float fDParticleEndY
 
float fDParticleEndZ
 
float fDParticleEndX
 
float fDParticleEndE
 
int fDParticleMotherPdgCode
 
unsigned int fDParticleMotherTrackId
 
int fDParticleAncestorPdgCode
 
unsigned int fDParticleAncestorTrackId
 
float fCollectionY
 
float fCollectionZ
 
float fCollectionX
 
float fCollectionRMSY
 
float fCollectionRMSZ
 
float fCollectionRMSX
 
float fCollectionEnergy
 
float fMinX
 
float fMaxX
 
float fMinY
 
float fMaxY
 
float fMinZ
 
float fMaxZ
 

Detailed Description

Definition at line 21 of file MCTrackCollectionAnaAlg.h.

Constructor & Destructor Documentation

sim::MCTrackCollectionAnaAlg::MCTrackCollectionAnaAlg ( )
inline

Definition at line 25 of file MCTrackCollectionAnaAlg.h.

25 {};

Member Function Documentation

void sim::MCTrackCollectionAnaAlg::FillDominantParticleInfo ( const sim::MCTrack mctrack)
private

Definition at line 159 of file MCTrackCollectionAnaAlg.cxx.

160 {
161  size_t nsteps = mctrack.size();
162 
163  fDParticleOrigin = mctrack.Origin();
164  fDParticlePdgCode = mctrack.PdgCode();
165  fDParticleTrackId = mctrack.TrackID();
166  fDParticleStartY = mctrack[0].Y();
167  fDParticleStartZ = mctrack[0].Z();
168  fDParticleStartX = mctrack[0].X();
169  fDParticleStartE = mctrack[0].E();
170  fDParticleEndY = mctrack[nsteps-1].Y();
171  fDParticleEndZ = mctrack[nsteps-1].Z();
172  fDParticleEndX = mctrack[nsteps-1].X();
173  fDParticleEndE = mctrack[nsteps-1].E();
178 }
simb::Origin_t Origin() const
Definition: MCTrack.h:40
unsigned int AncestorTrackID() const
Definition: MCTrack.h:56
int AncestorPdgCode() const
Definition: MCTrack.h:55
unsigned int MotherTrackID() const
Definition: MCTrack.h:50
int PdgCode() const
Definition: MCTrack.h:41
int MotherPdgCode() const
Definition: MCTrack.h:49
unsigned int TrackID() const
Definition: MCTrack.h:42
void sim::MCTrackCollectionAnaAlg::FillTree ( unsigned int  run,
unsigned int  event,
const std::vector< sim::MCTrack > &  mctVec 
)

Definition at line 63 of file MCTrackCollectionAnaAlg.cxx.

65 {
66  fRun = run;
67  fEvent = event;
68 
69  fNMCTracks = mctVec.size();
71 
72  fMinY = 99999;
73  fMinZ = 99999;
74  fMinX = 99999;
75  fMaxY = -99999;
76  fMaxZ = -99999;
77  fMaxX = -99999;
78 
79  if(mctVec.size()==0){
80  fTree->Fill();
81  return;
82  }
83 
84 
85  std::vector<double> y_vals;
86  std::vector<double> z_vals;
87  std::vector<double> x_vals;
88  std::vector<double> stepL_vals;
89 
90  std::vector<double> mct_length(mctVec.size(),0);
91  //int d_index = -1; // unused
92  for(size_t i_p=0; i_p<mctVec.size(); i_p++){
93 
94 
95  fCollectionEnergy += mctVec[i_p].Start().E();
96 
97  //y_vals.reserve( y_vals.size() + mctVec[i_p].size()-1 );
98  //z_vals.reserve( z_vals.size() + mctVec[i_p].size()-1 );
99  //x_vals.reserve( x_vals.size() + mctVec[i_p].size()-1 );
100 
101  for(size_t i_s=1; i_s < mctVec[i_p].size(); i_s++){
102 
103  TVector3 const& vec1 = mctVec[i_p][i_s-1].Position().Vect();
104  TVector3 const& vec2 = mctVec[i_p][i_s].Position().Vect();
105  double stepL = (vec2-vec1).Mag();
106 
107  double thisy = 0.5*(vec1.Y() + vec2.Y());
108  double thisz = 0.5*(vec1.Z() + vec2.Z());
109  double thisx = 0.5*(vec1.X() + vec2.X());
110 
111  y_vals.push_back(thisy);
112  z_vals.push_back(thisz);
113  x_vals.push_back(thisx);
114  stepL_vals.push_back(stepL);
115 
116  mct_length[i_p] += stepL;
117 
118  if(thisy > fMaxY) fMaxY = thisy;
119  if(thisy < fMinY) fMinY = thisy;
120  if(thisz > fMaxZ) fMaxZ = thisz;
121  if(thisz < fMinZ) fMinZ = thisz;
122  if(thisx > fMaxX) fMaxX = thisx;
123  if(thisx < fMinX) fMinX = thisx;
124 
125  }//end loop over steps
126  }//end loop over tracks
127 
128  double totalL = std::accumulate(mct_length.begin(),mct_length.end(),0.0);
129 
130  fDParticle = std::distance(mct_length.begin(),std::max_element(mct_length.begin(),mct_length.end()));
131  fDParticleFraction = mct_length.at(fDParticle) / totalL;
133 
134  double sumy=0,sumz=0,sumx=0;
135  for(size_t i_step=0; i_step<stepL_vals.size(); i_step++){
136  sumy += stepL_vals[i_step]*y_vals[i_step];
137  sumz += stepL_vals[i_step]*z_vals[i_step];
138  sumx += stepL_vals[i_step]*x_vals[i_step];
139  }
140 
141  fCollectionY = sumy/totalL;
142  fCollectionZ = sumz/totalL;
143  fCollectionX = sumx/totalL;
144 
145  double sumy2=0,sumz2=0,sumx2=0;
146  for(size_t i_step=0; i_step<stepL_vals.size(); i_step++){
147  sumy2 += stepL_vals[i_step]*(y_vals[i_step]-fCollectionY)*(y_vals[i_step]-fCollectionY);
148  sumz2 += stepL_vals[i_step]*(z_vals[i_step]-fCollectionZ)*(z_vals[i_step]-fCollectionZ);
149  sumx2 += stepL_vals[i_step]*(x_vals[i_step]-fCollectionX)*(x_vals[i_step]-fCollectionX);
150  }
151 
152  fCollectionRMSY = std::sqrt(sumy2/totalL);
153  fCollectionRMSZ = std::sqrt(sumz2/totalL);
154  fCollectionRMSX = std::sqrt(sumx2/totalL);
155 
156  if(fFillTree) fTree->Fill();
157 }
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
void FillDominantParticleInfo(const sim::MCTrack &)
void sim::MCTrackCollectionAnaAlg::SetOutputTree ( TTree *  tree,
bool  fill = true 
)

Title: MCTrackCollectionAnaAlg Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov)

Description: Alg to put properties of collection of MCTracks in a tree.

Definition at line 17 of file MCTrackCollectionAnaAlg.cxx.

18 {
19  fTree = tree;
20  fFillTree = fill;
21 
22  fTree->Branch("mct_run",&fRun,"mct_run/i");
23  fTree->Branch("mct_event",&fEvent,"mct_event/i");
24 
25  fTree->Branch("mct_nmctracks",&fNMCTracks,"mct_nmctracks/i");
26  fTree->Branch("mct_dp",&fDParticle,"mct_dp/i");
27  fTree->Branch("mct_dpfrac",&fDParticleFraction,"mct_dpfrac/F");
28 
29  fTree->Branch("mct_dporigin",&fDParticleOrigin,"mct_dporigin/I");
30  fTree->Branch("mct_dppdg",&fDParticlePdgCode,"mct_dppdg/I");
31  fTree->Branch("mct_dptrackid",&fDParticleTrackId,"mct_dptrackid/i");
32  fTree->Branch("mct_dpmpdg",&fDParticleMotherPdgCode,"mct_dpmpdg/I");
33  fTree->Branch("mct_dpmtrackid",&fDParticleMotherTrackId,"mct_dpmtrackid/i");
34  fTree->Branch("mct_dpapdg",&fDParticleAncestorPdgCode,"mct_dpapdg/I");
35  fTree->Branch("mct_dpatrackid",&fDParticleAncestorTrackId,"mct_dpatrackid/i");
36 
37  fTree->Branch("mct_dpstartx",&fDParticleStartX,"mct_dpstartx/F");
38  fTree->Branch("mct_dpstarty",&fDParticleStartY,"mct_dpstarty/F");
39  fTree->Branch("mct_dpstartz",&fDParticleStartZ,"mct_dpstartz/F");
40  fTree->Branch("mct_dpstarte",&fDParticleStartE,"mct_dpstarte/F");
41  fTree->Branch("mct_dpendx",&fDParticleEndX,"mct_dpendx/F");
42  fTree->Branch("mct_dpendy",&fDParticleEndY,"mct_dpendy/F");
43  fTree->Branch("mct_dpendz",&fDParticleEndZ,"mct_dpendz/F");
44  fTree->Branch("mct_dpende",&fDParticleEndE,"mct_dpende/F");
45 
46  fTree->Branch("mct_coly",&fCollectionY,"mct_coly/F");
47  fTree->Branch("mct_colz",&fCollectionZ,"mct_colz/F");
48  fTree->Branch("mct_colx",&fCollectionX,"mct_colx/F");
49  fTree->Branch("mct_colrmsy",&fCollectionRMSY,"mct_colrmsy/F");
50  fTree->Branch("mct_colrmsz",&fCollectionRMSZ,"mct_colrmsz/F");
51  fTree->Branch("mct_colrmsx",&fCollectionRMSX,"mct_colrmsx/F");
52  fTree->Branch("mct_colE",&fCollectionEnergy,"mct_colE/F");
53 
54  fTree->Branch("mct_miny",&fMinY,"mct_miny/F");
55  fTree->Branch("mct_maxy",&fMaxY,"mct_maxy/F");
56  fTree->Branch("mct_minz",&fMinZ,"mct_minz/F");
57  fTree->Branch("mct_maxz",&fMaxZ,"mct_maxz/F");
58  fTree->Branch("mct_minx",&fMinX,"mct_minx/F");
59  fTree->Branch("mct_maxx",&fMaxX,"mct_maxx/F");
60 
61 }
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)

Member Data Documentation

float sim::MCTrackCollectionAnaAlg::fCollectionEnergy
private

Definition at line 66 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionRMSX
private

Definition at line 65 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionRMSY
private

Definition at line 63 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionRMSZ
private

Definition at line 64 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionX
private

Definition at line 62 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionY
private

Definition at line 60 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fCollectionZ
private

Definition at line 61 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fDParticle
private

Definition at line 41 of file MCTrackCollectionAnaAlg.h.

int sim::MCTrackCollectionAnaAlg::fDParticleAncestorPdgCode
private

Definition at line 57 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fDParticleAncestorTrackId
private

Definition at line 58 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleEndE
private

Definition at line 54 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleEndX
private

Definition at line 53 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleEndY
private

Definition at line 51 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleEndZ
private

Definition at line 52 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleFraction
private

Definition at line 42 of file MCTrackCollectionAnaAlg.h.

int sim::MCTrackCollectionAnaAlg::fDParticleMotherPdgCode
private

Definition at line 55 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fDParticleMotherTrackId
private

Definition at line 56 of file MCTrackCollectionAnaAlg.h.

int sim::MCTrackCollectionAnaAlg::fDParticleOrigin
private

Definition at line 44 of file MCTrackCollectionAnaAlg.h.

int sim::MCTrackCollectionAnaAlg::fDParticlePdgCode
private

Definition at line 45 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleStartE
private

Definition at line 50 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleStartX
private

Definition at line 49 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleStartY
private

Definition at line 47 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fDParticleStartZ
private

Definition at line 48 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fDParticleTrackId
private

Definition at line 46 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fEvent
private

Definition at line 38 of file MCTrackCollectionAnaAlg.h.

bool sim::MCTrackCollectionAnaAlg::fFillTree
private

Definition at line 35 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMaxX
private

Definition at line 68 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMaxY
private

Definition at line 70 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMaxZ
private

Definition at line 72 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMinX
private

Definition at line 67 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMinY
private

Definition at line 69 of file MCTrackCollectionAnaAlg.h.

float sim::MCTrackCollectionAnaAlg::fMinZ
private

Definition at line 71 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fNMCTracks
private

Definition at line 40 of file MCTrackCollectionAnaAlg.h.

unsigned int sim::MCTrackCollectionAnaAlg::fRun
private

Definition at line 37 of file MCTrackCollectionAnaAlg.h.

TTree* sim::MCTrackCollectionAnaAlg::fTree
private

Definition at line 34 of file MCTrackCollectionAnaAlg.h.


The documentation for this class was generated from the following files: