CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
EcalTimeMapDigitizer Class Reference

#include <EcalTimeMapDigitizer.h>

Classes

struct  time_average
 

Public Types

typedef EcalTimeDigi Digi
 
typedef time_average TimeSamples
 
typedef std::vector< unsigned int > VecInd
 

Public Member Functions

void add (const std::vector< PCaloHit > &hits, int bunchCrossing)
 
void blankOutUsedSamples ()
 
 EcalTimeMapDigitizer (EcalSubdetector myDet)
 
void finalizeHits ()
 
int getTimeLayerId ()
 
void initializeMap ()
 
int maxBunch () const
 
int minBunch () const
 
void run (EcalTimeDigiCollection &output)
 
void setGeometry (const CaloSubdetectorGeometry *geometry)
 
void setTimeLayerId (const int &layerId)
 
EcalSubdetector subdetector ()
 
virtual ~EcalTimeMapDigitizer ()
 

Private Member Functions

TimeSamplesfindSignal (const DetId &detId)
 
VecIndindex ()
 
const VecIndindex () const
 
const TimeSamplesoperator[] (unsigned int i) const
 
TimeSamplesoperator[] (unsigned int i)
 
unsigned int samplesSize () const
 
unsigned int samplesSizeAll () const
 
double timeOfFlight (const DetId &detId, int layer) const
 
TimeSamplesvSam (unsigned int i)
 
TimeSamplesvSamAll (unsigned int i)
 
const TimeSamplesvSamAll (unsigned int i) const
 

Private Attributes

const CaloSubdetectorGeometrym_geometry
 
VecInd m_index
 
EcalSubdetector m_subDet
 
int m_timeLayerId
 
std::vector< TimeSamplesm_vSam
 

Static Private Attributes

static const int BUNCHSPACE =25
 
static const int m_maxBunch =5
 
static const int m_minBunch =-4
 
static const float MIN_ENERGY_THRESHOLD =5e-5
 

Detailed Description

Definition at line 19 of file EcalTimeMapDigitizer.h.

Member Typedef Documentation

Definition at line 82 of file EcalTimeMapDigitizer.h.

Definition at line 80 of file EcalTimeMapDigitizer.h.

typedef std::vector< unsigned int > EcalTimeMapDigitizer::VecInd

Definition at line 84 of file EcalTimeMapDigitizer.h.

Constructor & Destructor Documentation

EcalTimeMapDigitizer::EcalTimeMapDigitizer ( EcalSubdetector  myDet)
explicit

Definition at line 27 of file EcalTimeMapDigitizer.cc.

References gather_cfg::cout, DetId::det(), EBDetId::detIdFromDenseIndex(), EEDetId::detIdFromDenseIndex(), EcalBarrel, EcalEndcap, mps_fire::i, EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, m_maxBunch, m_minBunch, m_subDet, m_vSam, findQualityFiles::size, and DetId::subdetId().

27  :
28  m_subDet(myDet),
29  m_geometry(nullptr)
30 {
31 // edm::Service<edm::RandomNumberGenerator> rng ;
32 // if ( !rng.isAvailable() )
33 // {
34 // throw cms::Exception("Configuration")
35 // << "EcalTimeMapDigitizer requires the RandomNumberGeneratorService\n"
36 // "which is not present in the configuration file. You must add the service\n"
37 // "in the configuration file or remove the modules that require it.";
38 // }
39 // m_RandPoisson = new CLHEP::RandPoissonQ( rng->getEngine() ) ;
40 // m_RandGauss = new CLHEP::RandGaussQ( rng->getEngine() ) ;
41 
42  unsigned int size=0;
43  DetId detId(0);
44 
45  //Initialize the map
46  if (myDet==EcalBarrel)
47  {
49  detId=EBDetId::detIdFromDenseIndex( 0 ) ;
50  }
51  else if (myDet==EcalEndcap)
52  {
54  detId=EEDetId::detIdFromDenseIndex( 0 ) ;
55  }
56  else
57  edm::LogError("TimeDigiError") << "[EcalTimeMapDigitizer]::ERROR::This subdetector " << myDet << " is not implemented";
58 
59 
60  assert(m_maxBunch-m_minBunch+1<=10);
61  assert(m_minBunch<=0);
62 
63  m_vSam.reserve( size ) ;
64 
65  for( unsigned int i ( 0 ) ; i != size ; ++i )
66  {
67  // m_vSam.emplace_back(CaloGenericDetId( detId.det(), detId.subdetId(), i ) ,
68  // m_maxBunch-m_minBunch+1, abs(m_minBunch) );
69  m_vSam.emplace_back(TimeSamples(CaloGenericDetId( detId.det(), detId.subdetId(), i )));
70  }
71 
72 
73  edm::LogInfo("TimeDigiInfo") << "[EcalTimeDigitizer]::Subdetector " << m_subDet << "::Reserved size for time digis " << m_vSam.size();
74 
75 #ifdef ecal_time_debug
76  std::cout << "[EcalTimeDigitizer]::Subdetector " << m_subDet << "::Reserved size for time digis " << m_vSam.size() << std::endl;
77 #endif
78 
79 }
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
size
Write out results.
static const int m_maxBunch
const CaloSubdetectorGeometry * m_geometry
std::vector< TimeSamples > m_vSam
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:111
Definition: DetId.h:18
static const int m_minBunch
EcalTimeMapDigitizer::~EcalTimeMapDigitizer ( )
virtual

Definition at line 81 of file EcalTimeMapDigitizer.cc.

82 {
83 }

Member Function Documentation

void EcalTimeMapDigitizer::add ( const std::vector< PCaloHit > &  hits,
int  bunchCrossing 
)

Definition at line 86 of file EcalTimeMapDigitizer.cc.

References EcalTimeMapDigitizer::time_average::average_time, gather_cfg::cout, findSignal(), edm::isNotFinite(), PCaloHit::kEcalDepthMask, PCaloHit::kEcalDepthOffset, m_maxBunch, m_minBunch, m_timeLayerId, MIN_ENERGY_THRESHOLD, EcalTimeMapDigitizer::time_average::nhits, mps_fire::result, ntuplemaker::time, timeOfFlight(), and EcalTimeMapDigitizer::time_average::tot_energy.

Referenced by EcalTimeDigiProducer::accumulateCaloHits(), and counter.Counter::register().

86  {
87  if(bunchCrossing>=m_minBunch && bunchCrossing<=m_maxBunch ) {
88 
89  for(std::vector<PCaloHit>::const_iterator it = hits.begin(), itEnd = hits.end(); it != itEnd; ++it) {
90  //here goes the map logic
91 
92  if (edm::isNotFinite( (*it).time() ) )
93  continue;
94 
95  //Just consider only the hits belonging to the specified time layer
96  int depth2 = (((*it).depth() >> PCaloHit::kEcalDepthOffset) &
98 
99  if (depth2 != m_timeLayerId) continue;
100 
101  if ((*it).energy()<MIN_ENERGY_THRESHOLD) //apply a minimal cut on the hit energy
102  continue;
103 
104  const DetId detId ( (*it).id() ) ;
105 
106  double time = (*it).time();
107 
108  //time of flight is not corrected here for the vertex position
109  const double jitter ( time - timeOfFlight( detId, m_timeLayerId ) ) ;
110 
111  TimeSamples& result ( *findSignal( detId ) ) ;
112 
113  //here fill the result for the given bunch crossing
114  result.average_time[bunchCrossing-m_minBunch]+=jitter*(*it).energy();
115  result.tot_energy[bunchCrossing-m_minBunch]+=(*it).energy();
116  result.nhits[bunchCrossing-m_minBunch]++;
117 
118 #ifdef ecal_time_debug
119  std::cout << (*it).id() << "\t" << (*it).depth() << "\t" << jitter << "\t" << (*it).energy() << "\t" << result.average_time[bunchCrossing-m_minBunch] << "\t" << result.nhits[bunchCrossing-m_minBunch] << "\t" << timeOfFlight( detId, m_timeLayerId ) << std::endl;
120 #endif
121  }
122  }
123 }
static const int m_maxBunch
bool isNotFinite(T x)
Definition: isFinite.h:10
static const int kEcalDepthMask
Definition: PCaloHit.h:68
static const int kEcalDepthOffset
Definition: PCaloHit.h:69
Definition: DetId.h:18
static const int m_minBunch
TimeSamples * findSignal(const DetId &detId)
double timeOfFlight(const DetId &detId, int layer) const
static const float MIN_ENERGY_THRESHOLD
void EcalTimeMapDigitizer::blankOutUsedSamples ( )

Definition at line 145 of file EcalTimeMapDigitizer.cc.

References gather_cfg::cout, mps_fire::i, m_index, EcalTimeMapDigitizer::time_average::setZero(), findQualityFiles::size, and vSamAll().

Referenced by initializeMap(), and subdetector().

146 {
147  const unsigned int size ( m_index.size() ) ;
148 
149 
150  for( unsigned int i ( 0 ) ; i != size ; ++i )
151  {
152 #ifdef ecal_time_debug
153  std::cout << "Zeroing " << m_index[i] << std::endl;
154 #endif
155  vSamAll( m_index[i] )->setZero() ;
156  }
157 
158  m_index.erase( m_index.begin() , // done and make ready to start over
159  m_index.end() ) ;
160 }
size
Write out results.
TimeSamples * vSamAll(unsigned int i)
void EcalTimeMapDigitizer::finalizeHits ( )

Definition at line 164 of file EcalTimeMapDigitizer.cc.

References EcalTimeMapDigitizer::time_average::average_time, EcalTimeMapDigitizer::time_average::calculateAverage(), gather_cfg::cout, mps_fire::i, m_index, EcalTimeMapDigitizer::time_average::nhits, findQualityFiles::size, EcalTimeMapDigitizer::time_average::time_average_capacity, EcalTimeMapDigitizer::time_average::tot_energy, and vSamAll().

Referenced by run().

165 {
166  //Getting the size from the actual hits
167  const unsigned int size ( m_index.size() ) ;
168 
169  //Here just averaging the MC truth
170  for( unsigned int i ( 0 ) ; i != size ; ++i )
171  {
172 #ifdef ecal_time_debug
173  std::cout << "Averaging " << m_index[i] << std::endl;
174 #endif
176 #ifdef ecal_time_debug
177  for ( unsigned int j ( 0 ) ; j != vSamAll( m_index[i] )->time_average_capacity; ++j )
178  std::cout << j << "\t" << vSamAll( m_index[i] )->average_time[j] << "\t" << vSamAll( m_index[i] )->nhits[j] << "\t" << vSamAll( m_index[i] )->tot_energy[j] << std::endl;
179 #endif
180  }
181 
182  //Noise can be added here
183 
184 }
size
Write out results.
unsigned int nhits[time_average_capacity]
TimeSamples * vSamAll(unsigned int i)
static const unsigned short time_average_capacity
float average_time[time_average_capacity]
float tot_energy[time_average_capacity]
EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::findSignal ( const DetId detId)
private

Definition at line 127 of file EcalTimeMapDigitizer.cc.

References m_index, mps_fire::result, vSamAll(), and EcalTimeMapDigitizer::time_average::zero().

Referenced by add(), and subdetector().

128 {
129  const unsigned int di ( CaloGenericDetId( detId ).denseIndex() ) ;
130  TimeSamples* result ( vSamAll( di ) ) ;
131  if( result->zero() ) m_index.push_back( di ) ;
132  return result ;
133 }
TimeSamples * vSamAll(unsigned int i)
int EcalTimeMapDigitizer::getTimeLayerId ( )
inline

Definition at line 102 of file EcalTimeMapDigitizer.h.

References m_timeLayerId.

EcalTimeMapDigitizer::VecInd & EcalTimeMapDigitizer::index ( )
private

Definition at line 328 of file EcalTimeMapDigitizer.cc.

References m_index.

Referenced by BeautifulSoup.PageElement::insert(), and subdetector().

329 {
330  return m_index ;
331 }
const EcalTimeMapDigitizer::VecInd & EcalTimeMapDigitizer::index ( ) const
private

Definition at line 334 of file EcalTimeMapDigitizer.cc.

References m_index.

Referenced by BeautifulSoup.PageElement::insert().

335 {
336  return m_index ;
337 }
void EcalTimeMapDigitizer::initializeMap ( )

Definition at line 187 of file EcalTimeMapDigitizer.cc.

References blankOutUsedSamples(), and gather_cfg::cout.

Referenced by EcalTimeDigiProducer::initializeEvent().

188 {
189 #ifdef ecal_time_debug
190  std::cout << "[EcalTimeMapDigitizer]::Zeroing the used samples" << std::endl;
191 #endif
193 }
int EcalTimeMapDigitizer::maxBunch ( ) const

Definition at line 322 of file EcalTimeMapDigitizer.cc.

References m_maxBunch.

Referenced by subdetector().

323 {
324  return m_maxBunch ;
325 }
static const int m_maxBunch
int EcalTimeMapDigitizer::minBunch ( ) const

Definition at line 316 of file EcalTimeMapDigitizer.cc.

References m_minBunch.

Referenced by subdetector().

317 {
318  return m_minBunch ;
319 }
static const int m_minBunch
const EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::operator[] ( unsigned int  i) const
private

Definition at line 286 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

Referenced by subdetector().

287 {
288  return &m_vSam[ i ] ;
289 }
std::vector< TimeSamples > m_vSam
EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::operator[] ( unsigned int  i)
private

Definition at line 292 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

293 {
294  return &m_vSam[ i ] ;
295 }
std::vector< TimeSamples > m_vSam
void EcalTimeMapDigitizer::run ( EcalTimeDigiCollection output)

Definition at line 197 of file EcalTimeMapDigitizer.cc.

References EcalTimeMapDigitizer::time_average::average_time, edm::SortedCollection< T, SORT >::back(), gather_cfg::cout, finalizeHits(), mps_fire::i, m_index, m_minBunch, EcalTimeMapDigitizer::time_average::nhits, edm::SortedCollection< T, SORT >::push_back(), edm::SortedCollection< T, SORT >::reserve(), edm::SortedCollection< T, SORT >::size(), EcalTimeMapDigitizer::time_average::time_average_capacity, and vSamAll().

Referenced by EcalTimeDigiProducer::finalizeEvent().

198 {
199 #ifdef ecal_time_debug
200  std::cout << "[EcalTimeMapDigitizer]::Finalizing hits and fill output collection" << std::endl;
201 #endif
202 
203  //Do the time averages and add noise if simulated
204  finalizeHits();
205 
206  //Until we do now simulated noise we can get the size from the index vector
207  const unsigned int ssize ( m_index.size() ) ;
208 
209  output.reserve( ssize ) ;
210 
211  for( unsigned int i ( 0 ) ; i != ssize ; ++i )
212  {
213 
214  #ifdef ecal_time_debug
215  std::cout << "----- in digi loop " << i << std::endl;
216  #endif
217 
218  output.push_back( Digi(vSamAll( m_index[i] )->id) );
219 
220  unsigned int nTimeHits=0;
221  float timeHits[vSamAll( m_index[i] )->time_average_capacity];
222  unsigned int timeBX[vSamAll( m_index[i] )->time_average_capacity];
223 
224  for ( unsigned int j ( 0 ) ; j != vSamAll( m_index[i] )->time_average_capacity; ++j ) //here sampling on the OOTPU
225  {
226  if (vSamAll( m_index[i] )->nhits[j]>0)
227  {
228  timeHits[nTimeHits]= vSamAll( m_index[i] )->average_time[j];
229  timeBX[nTimeHits++]= m_minBunch+j;
230  }
231  }
232 
233  output.back().setSize(nTimeHits);
234 
235  for (unsigned int j ( 0 ) ; j != nTimeHits; ++j ) //filling the !zero hits
236  {
237  output.back().setSample(j,timeHits[j]);
238  if (timeBX[j]==0)
239  {
240 #ifdef ecal_time_debug
241  std::cout << "setting interesting sample " << j << std::endl;
242 #endif
243  output.back().setSampleOfInterest(j);
244  }
245  }
246 
247  #ifdef ecal_time_debug
248  std::cout << "digi " << output.back().id().rawId() << "\t" << output.back().size();
249  if (output.back().sampleOfInterest()>0)
250  std::cout << "\tBX0 time " << output.back().sample(output.back().sampleOfInterest()) << std::endl;
251  else
252  std::cout << "\tNo in time hits" << std::endl;
253  #endif
254  }
255 #ifdef ecal_time_debug
256  std::cout << "[EcalTimeMapDigitizer]::Output collection size " << output.size() << std::endl;
257 #endif
258 
259 }
void push_back(T const &t)
unsigned int nhits[time_average_capacity]
TimeSamples * vSamAll(unsigned int i)
static const unsigned short time_average_capacity
static const int m_minBunch
size_type size() const
float average_time[time_average_capacity]
void reserve(size_type n)
const_reference back() const
unsigned int EcalTimeMapDigitizer::samplesSize ( ) const
private

Definition at line 274 of file EcalTimeMapDigitizer.cc.

References m_vSam.

Referenced by subdetector().

275 {
276  return m_vSam.size() ;
277 }
std::vector< TimeSamples > m_vSam
unsigned int EcalTimeMapDigitizer::samplesSizeAll ( ) const
private

Definition at line 280 of file EcalTimeMapDigitizer.cc.

References m_vSam.

Referenced by subdetector().

281 {
282  return m_vSam.size() ;
283 }
std::vector< TimeSamples > m_vSam
void EcalTimeMapDigitizer::setGeometry ( const CaloSubdetectorGeometry geometry)

Definition at line 138 of file EcalTimeMapDigitizer.cc.

References geometry, and m_geometry.

Referenced by EcalTimeDigiProducer::updateGeometry().

139 {
140  m_geometry = geometry ;
141 }
const CaloSubdetectorGeometry * m_geometry
ESHandle< TrackerGeometry > geometry
void EcalTimeMapDigitizer::setTimeLayerId ( const int &  layerId)
inline

Definition at line 100 of file EcalTimeMapDigitizer.h.

References m_timeLayerId.

Referenced by EcalTimeDigiProducer::EcalTimeDigiProducer().

100 { m_timeLayerId = layerId; };
EcalSubdetector EcalTimeMapDigitizer::subdetector ( )
inline
double EcalTimeMapDigitizer::timeOfFlight ( const DetId detId,
int  layer 
) const
private

Definition at line 263 of file EcalTimeMapDigitizer.cc.

References CaloSubdetectorGeometry::getGeometry(), m_geometry, and PV3DBase< T, PVType, FrameType >::mag().

Referenced by add().

264 {
265  //not using the layer yet
266  const CaloCellGeometry* cellGeometry ( m_geometry->getGeometry( detId ) ) ;
267  assert( nullptr != cellGeometry ) ;
268  GlobalPoint layerPos = (dynamic_cast<const TruncatedPyramid*>(cellGeometry))->getPosition( double(layer)+0.5 ); //depth in mm in the middle of the layer position
269  return layerPos.mag()*cm/c_light ;
270 }
const CaloSubdetectorGeometry * m_geometry
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T mag() const
Definition: PV3DBase.h:67
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSam ( unsigned int  i)
private

Definition at line 298 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

Referenced by subdetector().

299 {
300  return &m_vSam[ i ] ;
301 }
std::vector< TimeSamples > m_vSam
EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSamAll ( unsigned int  i)
private

Definition at line 304 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

Referenced by blankOutUsedSamples(), finalizeHits(), findSignal(), run(), and subdetector().

305 {
306  return &m_vSam[ i ] ;
307 }
std::vector< TimeSamples > m_vSam
const EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSamAll ( unsigned int  i) const
private

Definition at line 310 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

311 {
312  return &m_vSam[ i ] ;
313 }
std::vector< TimeSamples > m_vSam

Member Data Documentation

const int EcalTimeMapDigitizer::BUNCHSPACE =25
staticprivate

Definition at line 140 of file EcalTimeMapDigitizer.h.

const CaloSubdetectorGeometry* EcalTimeMapDigitizer::m_geometry
private

Definition at line 149 of file EcalTimeMapDigitizer.h.

Referenced by setGeometry(), and timeOfFlight().

VecInd EcalTimeMapDigitizer::m_index
private

Definition at line 155 of file EcalTimeMapDigitizer.h.

Referenced by blankOutUsedSamples(), finalizeHits(), findSignal(), index(), and run().

const int EcalTimeMapDigitizer::m_maxBunch =5
staticprivate

Definition at line 145 of file EcalTimeMapDigitizer.h.

Referenced by add(), EcalTimeMapDigitizer(), and maxBunch().

const int EcalTimeMapDigitizer::m_minBunch =-4
staticprivate

Definition at line 144 of file EcalTimeMapDigitizer.h.

Referenced by add(), EcalTimeMapDigitizer(), minBunch(), and run().

EcalSubdetector EcalTimeMapDigitizer::m_subDet
private

Definition at line 137 of file EcalTimeMapDigitizer.h.

Referenced by EcalTimeMapDigitizer(), and subdetector().

int EcalTimeMapDigitizer::m_timeLayerId
private

Definition at line 147 of file EcalTimeMapDigitizer.h.

Referenced by add(), getTimeLayerId(), and setTimeLayerId().

std::vector<TimeSamples> EcalTimeMapDigitizer::m_vSam
private
const float EcalTimeMapDigitizer::MIN_ENERGY_THRESHOLD =5e-5
staticprivate

Definition at line 142 of file EcalTimeMapDigitizer.h.

Referenced by add().