ATLAS Offline Software
PileUpType.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // Author: Ketevi A. Assamagan
7 // Date: February 2008
8 
9 template<class Selector>
10 void PileUpType::signal_particles( std::vector<HepMC::ConstGenParticlePtr>& particleList,
11  const Selector& select ) const
12 {
13  unsigned int colSize = m_particleList->size();
14  if ( colSize > 0 ) {
15  for ( auto istart: *(m_particleList->at(0))) {
16  if ( select(istart) ) particleList.push_back ( istart );
17  }
18  }
19 }
20 
21 template<class Selector>
22 void PileUpType::in_time_minimum_bias_particles( std::vector<HepMC::ConstGenParticlePtr>& particleList,
23  const Selector& select ) const
24 {
25  McEventCollection::const_iterator ievent_begin = this->in_time_minimum_bias_event_begin();
26  McEventCollection::const_iterator ievent_end = this->in_time_minimum_bias_event_end();
27  for ( ; ievent_begin != ievent_end; ++ievent_begin ) {
28  for ( auto it : **ievent_begin ) {
29  if ( select(it) ) particleList.push_back(it);
30  }
31  }
32 }
33 
34 template<class Selector>
35 void PileUpType::in_time_particles( std::vector<HepMC::ConstGenParticlePtr>& particleList,
36  const Selector& select ) const
37 {
38  particleList.clear();
39  this->signal_particles( particleList, select );
40  this->in_time_minimum_bias_particles( particleList, select );
41 
42 }
43 
44 /** return the MC events in [-2BC, +2BC], including the signal McEvent at BC=0 */
45 template<class Selector>
46 void PileUpType::particles_in_two_bunch_crossings( std::vector<HepMC::ConstGenParticlePtr>& particleList,
47  const Selector& select ) const
48 {
49  particleList.clear();
50 
51  /** add the in-time particles at BC=0 */
52  this->in_time_particles( particleList, select );
53 
54  /** find the ranges of the out-of-time particles in [-2BC, +2BC] */
55  const unsigned int colSize = m_particleList->size();
56  unsigned int istart = 0;
57  unsigned int iend = 0;
58  for (unsigned int i=1; i<colSize; ++i)
59  {
60  // start of the out-of-time in [-2BC,+2BC]
61  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 ) istart=i+1;
62  if ( i >= istart )
63  {
64  // end of the out-of-time in [-2BC,+2BC]
65  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 )
66  {
67  iend=i-1;
68  break;
69  }
70  }
71  }
72 
73  /** collect the out-of-time particles within [-2BC,+2BC] */
74  for (unsigned int i=istart; i<iend; ++i)
75  {
76  for (auto it: *(m_particleList->at(i))) {
77  if ( select(it) ) particleList.push_back(it);
78  }
79  }
80 }
81 
82 /** return the MC events in [-inf,-2BC] and [+2BC,+inf], excluding the cavern background and the beam halo */
83 template<class Selector>
84 void PileUpType::particles_outside_two_bunch_crossings( std::vector<HepMC::ConstGenParticlePtr>& particleList,
85  const Selector& select ) const
86 {
87  particleList.clear();
88  const unsigned int colSize = m_particleList->size();
89  unsigned int istart = 0;
90  unsigned int iend = 0;
91  for (unsigned int i=1; i<colSize; ++i)
92  {
93  // start of the out-of-time in [-2BC, +2BC]
94  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 ) istart=i+1;
95  if ( i >= istart )
96  {
97  // start of the out-of-time in [-Inf,-2BC] and [+2BC,+Inf]
98  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 ) istart=i+1;
99  if ( i >= istart )
100  {
101  // end of the out-of-time in [-Inf,-2BC] and [+2Bc,+Inf]
102  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 )
103  {
104  iend=i-1;
105  break;
106  }
107  }
108  }
109  }
110 
111  /** collect the out-of-time particles within [-Inf, -2BC] and [+2BC,+Inf] */
112  for (unsigned int i=istart; i<iend; ++i)
113  {
114  for (auto it: *(m_particleList->at(i))) {
115  if ( select(it) ) particleList.push_back(it);
116  }
117  }
118 }
119 
120 /** return the MC events of the cavern background */
121 template<class Selector>
122 void PileUpType::cavern_background_particles( std::vector<HepMC::ConstGenParticlePtr>& particleList,
123  const Selector& select ) const
124 {
125  particleList.clear();
126  const unsigned int colSize = m_particleList->size();
127  unsigned int istart = 0;
128  for (unsigned int i=1; i<colSize; ++i)
129  {
130  // the cavern is at the end so, the last of this condition is the start of the cavern
131  if ( (m_particleList->at(i))->event_number() == -1 && HepMC::signal_process_id(m_particleList->at(i)) == 0 ) istart=i;
132  }
133 
134  /** collect the cavern background particles */
135  for (unsigned int i=istart+1; i<colSize; ++i)
136  {
137  for (auto it: *(m_particleList->at(i))) {
138  if ( select(it) ) particleList.push_back(it);
139  }
140  }
141 }
142 
143 
144