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
 

Detailed Description

Definition at line 19 of file EcalTimeMapDigitizer.h.

Member Typedef Documentation

◆ Digi

Definition at line 65 of file EcalTimeMapDigitizer.h.

◆ TimeSamples

Definition at line 63 of file EcalTimeMapDigitizer.h.

◆ VecInd

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

Definition at line 67 of file EcalTimeMapDigitizer.h.

Constructor & Destructor Documentation

◆ EcalTimeMapDigitizer()

EcalTimeMapDigitizer::EcalTimeMapDigitizer ( EcalSubdetector  myDet)
explicit

Definition at line 28 of file EcalTimeMapDigitizer.cc.

References cms::cuda::assert(), 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().

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

◆ ~EcalTimeMapDigitizer()

EcalTimeMapDigitizer::~EcalTimeMapDigitizer ( )
virtual

Definition at line 74 of file EcalTimeMapDigitizer.cc.

74 {}

Member Function Documentation

◆ add()

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

Definition at line 76 of file EcalTimeMapDigitizer.cc.

References gather_cfg::cout, findSignal(), hfClusterShapes_cfi::hits, edm::isNotFinite(), PCaloHit::kEcalDepthMask, PCaloHit::kEcalDepthOffset, m_maxBunch, m_minBunch, m_timeLayerId, MIN_ENERGY_THRESHOLD, mps_fire::result, protons_cff::time, and timeOfFlight().

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

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

◆ blankOutUsedSamples()

void EcalTimeMapDigitizer::blankOutUsedSamples ( )

Definition at line 126 of file EcalTimeMapDigitizer.cc.

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

Referenced by initializeMap().

127 {
128  const unsigned int size(m_index.size());
129 
130  for (unsigned int i(0); i != size; ++i) {
131 #ifdef ecal_time_debug
132  std::cout << "Zeroing " << m_index[i] << std::endl;
133 #endif
134  vSamAll(m_index[i])->setZero();
135  }
136 
137  m_index.erase(m_index.begin(), // done and make ready to start over
138  m_index.end());
139 }
size
Write out results.
TimeSamples * vSamAll(unsigned int i)

◆ finalizeHits()

void EcalTimeMapDigitizer::finalizeHits ( )

Definition at line 141 of file EcalTimeMapDigitizer.cc.

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

Referenced by run().

141  {
142  //Getting the size from the actual hits
143  const unsigned int size(m_index.size());
144 
145  //Here just averaging the MC truth
146  for (unsigned int i(0); i != size; ++i) {
147 #ifdef ecal_time_debug
148  std::cout << "Averaging " << m_index[i] << std::endl;
149 #endif
151 #ifdef ecal_time_debug
152  for (unsigned int j(0); j != vSamAll(m_index[i])->time_average_capacity; ++j)
153  std::cout << j << "\t" << vSamAll(m_index[i])->average_time[j] << "\t" << vSamAll(m_index[i])->nhits[j] << "\t"
154  << vSamAll(m_index[i])->tot_energy[j] << std::endl;
155 #endif
156  }
157 
158  //Noise can be added here
159 }
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]

◆ findSignal()

EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::findSignal ( const DetId detId)
private

Definition at line 116 of file EcalTimeMapDigitizer.cc.

References m_index, mps_fire::result, and vSamAll().

Referenced by add().

116  {
117  const unsigned int di(CaloGenericDetId(detId).denseIndex());
118  TimeSamples* result(vSamAll(di));
119  if (result->zero())
120  m_index.push_back(di);
121  return result;
122 }
TimeSamples * vSamAll(unsigned int i)

◆ getTimeLayerId()

int EcalTimeMapDigitizer::getTimeLayerId ( )
inline

Definition at line 85 of file EcalTimeMapDigitizer.h.

References m_timeLayerId.

◆ index() [1/2]

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

Definition at line 253 of file EcalTimeMapDigitizer.cc.

References m_index.

253 { return m_index; }

◆ index() [2/2]

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

Definition at line 255 of file EcalTimeMapDigitizer.cc.

References m_index.

255 { return m_index; }

◆ initializeMap()

void EcalTimeMapDigitizer::initializeMap ( )

Definition at line 161 of file EcalTimeMapDigitizer.cc.

References blankOutUsedSamples(), and gather_cfg::cout.

Referenced by EcalTimeDigiProducer::initializeEvent().

161  {
162 #ifdef ecal_time_debug
163  std::cout << "[EcalTimeMapDigitizer]::Zeroing the used samples" << std::endl;
164 #endif
166 }

◆ maxBunch()

int EcalTimeMapDigitizer::maxBunch ( ) const

Definition at line 251 of file EcalTimeMapDigitizer.cc.

References m_maxBunch.

251 { return m_maxBunch; }
static const int m_maxBunch

◆ minBunch()

int EcalTimeMapDigitizer::minBunch ( ) const

Definition at line 249 of file EcalTimeMapDigitizer.cc.

References m_minBunch.

249 { return m_minBunch; }
static const int m_minBunch

◆ operator[]() [1/2]

const EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::operator[] ( unsigned int  i) const
private

Definition at line 239 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

239 { return &m_vSam[i]; }
std::vector< TimeSamples > m_vSam

◆ operator[]() [2/2]

EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::operator[] ( unsigned int  i)
private

Definition at line 241 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

241 { return &m_vSam[i]; }
std::vector< TimeSamples > m_vSam

◆ run()

void EcalTimeMapDigitizer::run ( EcalTimeDigiCollection output)

Definition at line 168 of file EcalTimeMapDigitizer.cc.

References EcalTimeMapDigitizer::time_average::average_time, gather_cfg::cout, finalizeHits(), mps_fire::i, dqmiolumiharvest::j, m_index, m_minBunch, EcalTimeMapDigitizer::time_average::nhits, convertSQLitetoXML_cfg::output, EcalTimeMapDigitizer::time_average::time_average_capacity, and vSamAll().

Referenced by EcalTimeDigiProducer::finalizeEvent().

168  {
169 #ifdef ecal_time_debug
170  std::cout << "[EcalTimeMapDigitizer]::Finalizing hits and fill output collection" << std::endl;
171 #endif
172 
173  //Do the time averages and add noise if simulated
174  finalizeHits();
175 
176  //Until we do now simulated noise we can get the size from the index vector
177  const unsigned int ssize(m_index.size());
178 
179  output.reserve(ssize);
180 
181  for (unsigned int i(0); i != ssize; ++i) {
182 #ifdef ecal_time_debug
183  std::cout << "----- in digi loop " << i << std::endl;
184 #endif
185 
186  output.push_back(Digi(vSamAll(m_index[i])->id));
187 
188  unsigned int nTimeHits = 0;
189  float timeHits[vSamAll(m_index[i])->time_average_capacity];
190  unsigned int timeBX[vSamAll(m_index[i])->time_average_capacity];
191 
192  for (unsigned int j(0); j != vSamAll(m_index[i])->time_average_capacity; ++j) //here sampling on the OOTPU
193  {
194  if (vSamAll(m_index[i])->nhits[j] > 0) {
195  timeHits[nTimeHits] = vSamAll(m_index[i])->average_time[j];
196  timeBX[nTimeHits++] = m_minBunch + j;
197  }
198  }
199 
200  output.back().setSize(nTimeHits);
201 
202  for (unsigned int j(0); j != nTimeHits; ++j) //filling the !zero hits
203  {
204  output.back().setSample(j, timeHits[j]);
205  if (timeBX[j] == 0) {
206 #ifdef ecal_time_debug
207  std::cout << "setting interesting sample " << j << std::endl;
208 #endif
209  output.back().setSampleOfInterest(j);
210  }
211  }
212 
213 #ifdef ecal_time_debug
214  std::cout << "digi " << output.back().id().rawId() << "\t" << output.back().size();
215  if (output.back().sampleOfInterest() > 0)
216  std::cout << "\tBX0 time " << output.back().sample(output.back().sampleOfInterest()) << std::endl;
217  else
218  std::cout << "\tNo in time hits" << std::endl;
219 #endif
220  }
221 #ifdef ecal_time_debug
222  std::cout << "[EcalTimeMapDigitizer]::Output collection size " << output.size() << std::endl;
223 #endif
224 }
unsigned int nhits[time_average_capacity]
TimeSamples * vSamAll(unsigned int i)
static const unsigned short time_average_capacity
static const int m_minBunch
float average_time[time_average_capacity]

◆ samplesSize()

unsigned int EcalTimeMapDigitizer::samplesSize ( ) const
private

Definition at line 235 of file EcalTimeMapDigitizer.cc.

References m_vSam.

235 { return m_vSam.size(); }
std::vector< TimeSamples > m_vSam

◆ samplesSizeAll()

unsigned int EcalTimeMapDigitizer::samplesSizeAll ( ) const
private

Definition at line 237 of file EcalTimeMapDigitizer.cc.

References m_vSam.

237 { return m_vSam.size(); }
std::vector< TimeSamples > m_vSam

◆ setGeometry()

void EcalTimeMapDigitizer::setGeometry ( const CaloSubdetectorGeometry geometry)

Definition at line 124 of file EcalTimeMapDigitizer.cc.

References relativeConstraints::geometry, and m_geometry.

Referenced by EcalTimeDigiProducer::updateGeometry().

124 { m_geometry = geometry; }
const CaloSubdetectorGeometry * m_geometry

◆ setTimeLayerId()

void EcalTimeMapDigitizer::setTimeLayerId ( const int &  layerId)
inline

Definition at line 83 of file EcalTimeMapDigitizer.h.

References m_timeLayerId.

Referenced by EcalTimeDigiProducer::EcalTimeDigiProducer().

83 { m_timeLayerId = layerId; };

◆ subdetector()

EcalSubdetector EcalTimeMapDigitizer::subdetector ( )
inline

Definition at line 87 of file EcalTimeMapDigitizer.h.

References m_subDet.

87 { return m_subDet; };

◆ timeOfFlight()

double EcalTimeMapDigitizer::timeOfFlight ( const DetId detId,
int  layer 
) const
private

Definition at line 226 of file EcalTimeMapDigitizer.cc.

References cms::cuda::assert(), CaloSubdetectorGeometry::getGeometry(), pixelTopology::layer, m_geometry, and PV3DBase< T, PVType, FrameType >::mag().

Referenced by add().

226  {
227  //not using the layer yet
228  auto cellGeometry(m_geometry->getGeometry(detId));
229  assert(nullptr != cellGeometry);
230  GlobalPoint layerPos =
231  (cellGeometry)->getPosition(double(layer) + 0.5); //depth in mm in the middle of the layer position
232  return layerPos.mag() * cm / c_light;
233 }
const CaloSubdetectorGeometry * m_geometry
assert(be >=bs)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
T mag() const
Definition: PV3DBase.h:64
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.

◆ vSam()

EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSam ( unsigned int  i)
private

Definition at line 243 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

243 { return &m_vSam[i]; }
std::vector< TimeSamples > m_vSam

◆ vSamAll() [1/2]

EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSamAll ( unsigned int  i)
private

Definition at line 245 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

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

245 { return &m_vSam[i]; }
std::vector< TimeSamples > m_vSam

◆ vSamAll() [2/2]

const EcalTimeMapDigitizer::TimeSamples * EcalTimeMapDigitizer::vSamAll ( unsigned int  i) const
private

Definition at line 247 of file EcalTimeMapDigitizer.cc.

References mps_fire::i, and m_vSam.

247 { return &m_vSam[i]; }
std::vector< TimeSamples > m_vSam

Member Data Documentation

◆ BUNCHSPACE

const int EcalTimeMapDigitizer::BUNCHSPACE = 25
staticprivate

Definition at line 121 of file EcalTimeMapDigitizer.h.

◆ m_geometry

const CaloSubdetectorGeometry* EcalTimeMapDigitizer::m_geometry
private

Definition at line 130 of file EcalTimeMapDigitizer.h.

Referenced by setGeometry(), and timeOfFlight().

◆ m_index

VecInd EcalTimeMapDigitizer::m_index
private

Definition at line 136 of file EcalTimeMapDigitizer.h.

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

◆ m_maxBunch

const int EcalTimeMapDigitizer::m_maxBunch = 5
staticprivate

Definition at line 126 of file EcalTimeMapDigitizer.h.

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

◆ m_minBunch

const int EcalTimeMapDigitizer::m_minBunch = -4
staticprivate

Definition at line 125 of file EcalTimeMapDigitizer.h.

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

◆ m_subDet

EcalSubdetector EcalTimeMapDigitizer::m_subDet
private

Definition at line 118 of file EcalTimeMapDigitizer.h.

Referenced by EcalTimeMapDigitizer(), and subdetector().

◆ m_timeLayerId

int EcalTimeMapDigitizer::m_timeLayerId
private

Definition at line 128 of file EcalTimeMapDigitizer.h.

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

◆ m_vSam

std::vector<TimeSamples> EcalTimeMapDigitizer::m_vSam
private

◆ MIN_ENERGY_THRESHOLD

const float EcalTimeMapDigitizer::MIN_ENERGY_THRESHOLD
staticprivate
Initial value:
=
5e-5

Definition at line 123 of file EcalTimeMapDigitizer.h.

Referenced by add().