All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 20 of file MCShowerRecoPart.h.

Constructor & Destructor Documentation

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

Default constructor with fhicl parameters.

Definition at line 21 of file MCShowerRecoPart.cxx.

23  {
24  _debug_mode = pset.get<bool>("DebugMode");
25  }
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 28 of file MCShowerRecoPart.cxx.

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

40  {
41  if(shower_id >= _shower_daughters.size()) throw cet::exception(__FUNCTION__) << "Invalid shower index!";
42  return _shower_daughters.at(shower_id);
43  }
std::vector< std::vector< unsigned int > > _shower_daughters
Shower time-ordered daughters.
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 62 of file MCShowerRecoPart.h.

63  {
64  if(_shower_id.size() <= part_index) return kINVALID_INT;
65  return _shower_id.at(part_index);
66  }
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 48 of file MCShowerRecoPart.h.

49  {
50  std::vector<unsigned int> mothers(_shower_index.size(),0);
51  for(auto mother_iter = _shower_index.begin(); mother_iter!=_shower_index.end(); ++mother_iter)
52  mothers.at((*mother_iter).second) = (*mother_iter).first;
53  return mothers;
54  }
std::map< unsigned int, unsigned int > _shower_index
Shower Primary Index ID =&gt; Shower Index Map.

Member Data Documentation

bool sim::MCShowerRecoPart::_debug_mode
protected

lots of stdout stream

Definition at line 71 of file MCShowerRecoPart.h.

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

Shower time-ordered daughters.

Definition at line 83 of file MCShowerRecoPart.h.

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

Track index to shower index map.

Definition at line 74 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 80 of file MCShowerRecoPart.h.

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

Definition at line 24 of file MCShowerRecoPart.h.

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

Definition at line 23 of file MCShowerRecoPart.h.


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