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(0)
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(), 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  if ((*it).depth()!=100+m_timeLayerId) //modified layerId start from 100
97  continue;
98 
99  if ((*it).energy()<MIN_ENERGY_THRESHOLD) //apply a minimal cut on the hit energy
100  continue;
101 
102  const DetId detId ( (*it).id() ) ;
103 
104  double time = (*it).time();
105 
106  //time of flight is not corrected here for the vertex position
107  const double jitter ( time - timeOfFlight( detId, m_timeLayerId ) ) ;
108 
109  TimeSamples& result ( *findSignal( detId ) ) ;
110 
111  //here fill the result for the given bunch crossing
112  result.average_time[bunchCrossing-m_minBunch]+=jitter*(*it).energy();
113  result.tot_energy[bunchCrossing-m_minBunch]+=(*it).energy();
114  result.nhits[bunchCrossing-m_minBunch]++;
115 
116 #ifdef ecal_time_debug
117  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;
118 #endif
119  }
120  }
121 }
static const int m_maxBunch
bool isNotFinite(T x)
Definition: isFinite.h:10
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 143 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().

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

Definition at line 162 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().

163 {
164  //Getting the size from the actual hits
165  const unsigned int size ( m_index.size() ) ;
166 
167  //Here just averaging the MC truth
168  for( unsigned int i ( 0 ) ; i != size ; ++i )
169  {
170 #ifdef ecal_time_debug
171  std::cout << "Averaging " << m_index[i] << std::endl;
172 #endif
174 #ifdef ecal_time_debug
175  for ( unsigned int j ( 0 ) ; j != vSamAll( m_index[i] )->time_average_capacity; ++j )
176  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;
177 #endif
178  }
179 
180  //Noise can be added here
181 
182 }
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 125 of file EcalTimeMapDigitizer.cc.

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

Referenced by add(), and subdetector().

126 {
127  const unsigned int di ( CaloGenericDetId( detId ).denseIndex() ) ;
128  TimeSamples* result ( vSamAll( di ) ) ;
129  if( result->zero() ) m_index.push_back( di ) ;
130  return result ;
131 }
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 326 of file EcalTimeMapDigitizer.cc.

References m_index.

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

327 {
328  return m_index ;
329 }
const EcalTimeMapDigitizer::VecInd & EcalTimeMapDigitizer::index ( ) const
private

Definition at line 332 of file EcalTimeMapDigitizer.cc.

References m_index.

Referenced by BeautifulSoup.PageElement::insert().

333 {
334  return m_index ;
335 }
void EcalTimeMapDigitizer::initializeMap ( )

Definition at line 185 of file EcalTimeMapDigitizer.cc.

References blankOutUsedSamples(), and gather_cfg::cout.

Referenced by EcalTimeDigiProducer::initializeEvent().

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

Definition at line 320 of file EcalTimeMapDigitizer.cc.

References m_maxBunch.

Referenced by subdetector().

321 {
322  return m_maxBunch ;
323 }
static const int m_maxBunch
int EcalTimeMapDigitizer::minBunch ( ) const

Definition at line 314 of file EcalTimeMapDigitizer.cc.

References m_minBunch.

Referenced by subdetector().

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

Definition at line 284 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

Referenced by subdetector().

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

Definition at line 290 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

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

Definition at line 195 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().

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

References m_vSam.

Referenced by subdetector().

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

Definition at line 278 of file EcalTimeMapDigitizer.cc.

References m_vSam.

Referenced by subdetector().

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

Definition at line 136 of file EcalTimeMapDigitizer.cc.

References geometry, and m_geometry.

Referenced by EcalTimeDigiProducer::updateGeometry().

137 {
138  m_geometry = geometry ;
139 }
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 261 of file EcalTimeMapDigitizer.cc.

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

Referenced by add().

262 {
263  //not using the layer yet
264  const CaloCellGeometry* cellGeometry ( m_geometry->getGeometry( detId ) ) ;
265  assert( 0 != cellGeometry ) ;
266  GlobalPoint layerPos = (dynamic_cast<const TruncatedPyramid*>(cellGeometry))->getPosition( double(layer)+0.5 ); //depth in mm in the middle of the layer position
267  return layerPos.mag()*cm/c_light ;
268 }
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 296 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

Referenced by subdetector().

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

Definition at line 302 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

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

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

Definition at line 308 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

309 {
310  return &m_vSam[ i ] ;
311 }
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().