Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
sim::MCShowerRecoPart Class Reference

#include <MCShowerRecoPart.h>

Public Member Functions

 MCShowerRecoPart (fhicl::ParameterSet const &pset)
 Default constructor with fhicl parameters. More...
 
void ConstructShower (const MCRecoPart &part_v)
 Main function to read-in data and fill variables in this algorithm to reconstruct MC shower. More...
 
const std::vector< unsigned int > & ShowerDaughters (const unsigned int shower_id) const
 
const std::vector< unsigned int > ShowerMothers () const
 
int ShowerIndex (const unsigned int part_index) const
 

Static Public Attributes

static const unsigned int kINVALID_UINT = std::numeric_limits<unsigned int>::max()
 
static const int kINVALID_INT = std::numeric_limits<int>::max()
 

Protected Attributes

bool _debug_mode
 lots of stdout stream More...
 
std::vector< int > _shower_id
 Track index to shower index map. More...
 
std::map< unsigned int, unsigned int > _shower_index
 Shower Primary Index ID => Shower Index Map. More...
 
std::vector< std::vector< unsigned int > > _shower_daughters
 Shower time-ordered daughters. More...
 

Detailed Description

Definition at line 16 of file MCShowerRecoPart.h.

Constructor & Destructor Documentation

sim::MCShowerRecoPart::MCShowerRecoPart ( fhicl::ParameterSet const &  pset)
explicit

Default constructor with fhicl parameters.

Definition at line 18 of file MCShowerRecoPart.cxx.

20  {
21  _debug_mode = pset.get<bool>("DebugMode");
22  }
bool _debug_mode
lots of stdout stream

Member Function Documentation

void sim::MCShowerRecoPart::ConstructShower ( const MCRecoPart part_v)

Main function to read-in data and fill variables in this algorithm to reconstruct MC shower.

Definition at line 25 of file MCShowerRecoPart.cxx.

27  {
28  _shower_id.clear();
29  _shower_id.resize(part_v.size(),-1);
30  _shower_index.clear();
31  _shower_daughters.clear();
32 
33  if(!part_v.size()) return;
34 
35  // Construct MCShower
36  std::vector<std::multimap<double,unsigned int> > daughter_map;
37  for(size_t i=0; i<part_v.size(); ++i) {
38 
39  auto const& mcp = part_v[i];
40 
41  int candidate_mom_index=-1;
42  if( mcp._pdgcode == 22 ||
43  mcp._pdgcode == 11 ||
44  mcp._pdgcode == -11 )
45  candidate_mom_index = i;
46 
47  unsigned int mom_track = mcp._mother;
48  auto mom_iter = part_v._track_index.find(mom_track);
49  while(mom_iter != part_v._track_index.end()) {
50 
51  unsigned int mom_index = (*mom_iter).second;
52 
53  if( part_v.at(mom_index)._pdgcode == 22 || part_v.at(mom_index)._pdgcode == 11 || part_v.at(mom_index)._pdgcode == -11 )
54 
55  candidate_mom_index = mom_index;
56 
57  mom_iter = part_v._track_index.find(part_v.at(mom_index)._mother);
58 
59  }
60 
61  if(candidate_mom_index >= 0) {
62 
63  auto candidate_mom_iter = _shower_index.find(candidate_mom_index);
64  if(candidate_mom_iter == _shower_index.end()) {
65  _shower_index.insert(std::make_pair((unsigned int)candidate_mom_index, (unsigned int)_shower_index.size()));
66  daughter_map.push_back(std::multimap<double,unsigned int>());
67  }
68  unsigned int shower_index = (*_shower_index.find(candidate_mom_index)).second;
69  daughter_map.at(shower_index).insert(std::make_pair((double)(mcp._start_vtx[3]),(unsigned int)i));
70  _shower_id.at(i) = shower_index;
71 
72  } else if(_debug_mode) {
73 
74  std::cout
75  << "Found a particle that does not belong to a shower!" << std::endl
76  << Form(" PDGID: %d ... Track %d @ (%g,%g,%g,%g) with (%g,%g,%g,%g)",
77  mcp._pdgcode,
78  mcp._track_id,
79  mcp._start_vtx[0],
80  mcp._start_vtx[1],
81  mcp._start_vtx[2],
82  mcp._start_vtx[3],
83  mcp._start_mom[0],
84  mcp._start_mom[1],
85  mcp._start_mom[2],
86  mcp._start_mom[3])
87  << std::endl << std::endl;
88 
89  }
90  }
91 
92 
93  if(_debug_mode)
94  std::cout
95  << Form("Found %zu MCShowers....",_shower_index.size()) << std::endl;
96 
97  _shower_daughters.resize(_shower_index.size(),std::vector<unsigned int>());
98  for(auto const &mom : _shower_index) {
99 
100  _shower_daughters.at(mom.second).reserve(daughter_map.at(mom.second).size());
101  for(auto const &part_index : daughter_map.at(mom.second))
102 
103  _shower_daughters.at(mom.second).push_back(part_index.second);
104 
105  auto const& mcp = part_v.at(mom.first);
106  if(_debug_mode)
107  std::cout
108  << Form("PDGID: %d ... Track %d @ (%g,%g,%g,%g) with (%g,%g,%g,%g) ... %zu daughters!",
109  mcp._pdgcode,
110  mcp._track_id,
111  mcp._start_vtx[0],
112  mcp._start_vtx[1],
113  mcp._start_vtx[2],
114  mcp._start_vtx[3],
115  mcp._start_mom[0],
116  mcp._start_mom[1],
117  mcp._start_mom[2],
118  mcp._start_mom[3],
119  _shower_daughters.at(mom.second).size())
120  << std::endl;
121  }
122 
123  if(_debug_mode)
124  std::cout<<std::endl;
125  }
std::vector< int > _shower_id
Track index to shower index map.
std::vector< std::vector< unsigned int > > _shower_daughters
Shower time-ordered daughters.
bool _debug_mode
lots of stdout stream
std::map< unsigned int, unsigned int > _shower_index
Shower Primary Index ID => Shower Index Map.
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
QTextStream & endl(QTextStream &s)
const std::vector<unsigned int>& sim::MCShowerRecoPart::ShowerDaughters ( const unsigned int  shower_id) const
inline

Returns a list ot daughter particle index numbers for the specified shower with the shower index number as an input

Definition at line 35 of file MCShowerRecoPart.h.

36  {
37  if(shower_id >= _shower_daughters.size()) throw cet::exception(__FUNCTION__) << "Invalid shower index!";
38  return _shower_daughters.at(shower_id);
39  }
std::vector< std::vector< unsigned int > > _shower_daughters
Shower time-ordered daughters.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int sim::MCShowerRecoPart::ShowerIndex ( const unsigned int  part_index) const
inline

Take particle index number and returns shower index number to which this particle belongs. Returns -1 if a particle does not belong to any MC shower. Returns kINVALID_INT if input is invalid.

Definition at line 58 of file MCShowerRecoPart.h.

59  {
60  if(_shower_id.size() <= part_index) return kINVALID_INT;
61  return _shower_id.at(part_index);
62  }
std::vector< int > _shower_id
Track index to shower index map.
static const int kINVALID_INT
const std::vector<unsigned int> sim::MCShowerRecoPart::ShowerMothers ( ) const
inline

Returns a list of shower-mother's particle index. Order respects shower index number.

Definition at line 44 of file MCShowerRecoPart.h.

45  {
46  std::vector<unsigned int> mothers(_shower_index.size(),0);
47  for(auto mother_iter = _shower_index.begin(); mother_iter!=_shower_index.end(); ++mother_iter)
48  mothers.at((*mother_iter).second) = (*mother_iter).first;
49  return mothers;
50  }
std::map< unsigned int, unsigned int > _shower_index
Shower Primary Index ID => Shower Index Map.

Member Data Documentation

bool sim::MCShowerRecoPart::_debug_mode
protected

lots of stdout stream

Definition at line 67 of file MCShowerRecoPart.h.

std::vector<std::vector<unsigned int> > sim::MCShowerRecoPart::_shower_daughters
protected

Shower time-ordered daughters.

Definition at line 79 of file MCShowerRecoPart.h.

std::vector<int> sim::MCShowerRecoPart::_shower_id
protected

Track index to shower index map.

Definition at line 70 of file MCShowerRecoPart.h.

std::map<unsigned int, unsigned int> sim::MCShowerRecoPart::_shower_index
protected

Shower Primary Index ID => Shower Index Map.

Definition at line 76 of file MCShowerRecoPart.h.

const int sim::MCShowerRecoPart::kINVALID_INT = std::numeric_limits<int>::max()
static

Definition at line 20 of file MCShowerRecoPart.h.

const unsigned int sim::MCShowerRecoPart::kINVALID_UINT = std::numeric_limits<unsigned int>::max()
static

Definition at line 19 of file MCShowerRecoPart.h.


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