CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalDetailedTimeRecHitProducer Class Reference
Inheritance diagram for EcalDetailedTimeRecHitProducer:
edm::stream::EDProducer<>

Public Member Functions

 EcalDetailedTimeRecHitProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

double deltaTimeOfFlight (GlobalPoint &vertex, const DetId &detId, int layer) const
 

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometry_
 
bool correctForVertexZPosition_
 
std::string EBDetailedTimeRecHitCollection_
 
edm::EDGetTokenT< EBRecHitCollectionEBRecHitCollection_
 
edm::EDGetTokenT< EcalTimeDigiCollectionebTimeDigiCollection_
 
int ebTimeLayer_
 
std::string EEDetailedTimeRecHitCollection_
 
edm::EDGetTokenT< EERecHitCollectionEERecHitCollection_
 
edm::EDGetTokenT< EcalTimeDigiCollectioneeTimeDigiCollection_
 
int eeTimeLayer_
 
const CaloGeometrym_geometry
 
edm::EDGetTokenT< reco::VertexCollectionrecoVertex_
 
edm::EDGetTokenT< edm::SimVertexContainersimVertex_
 
bool useMCTruthVertex_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

produce ECAL rechits associating them with improved ecalTimeDigis

Author
Paolo Meridiani, INFN Roma

Definition at line 49 of file EcalDetailedTimeRecHitProducer.cc.

Constructor & Destructor Documentation

◆ EcalDetailedTimeRecHitProducer()

EcalDetailedTimeRecHitProducer::EcalDetailedTimeRecHitProducer ( const edm::ParameterSet ps)
explicit

Definition at line 82 of file EcalDetailedTimeRecHitProducer.cc.

References caloGeometry_, correctForVertexZPosition_, EBDetailedTimeRecHitCollection_, EBRecHitCollection_, ebTimeDigiCollection_, ebTimeLayer_, EEDetailedTimeRecHitCollection_, EERecHitCollection_, eeTimeDigiCollection_, eeTimeLayer_, edm::ParameterSet::getParameter(), recoVertex_, simVertex_, AlCaHLTBitMon_QueryRunRegistry::string, and useMCTruthVertex_.

82  : m_geometry(nullptr) {
83  EBRecHitCollection_ = consumes<EBRecHitCollection>(ps.getParameter<edm::InputTag>("EBRecHitCollection"));
84  EERecHitCollection_ = consumes<EERecHitCollection>(ps.getParameter<edm::InputTag>("EERecHitCollection"));
85 
86  ebTimeDigiCollection_ = consumes<EcalTimeDigiCollection>(ps.getParameter<edm::InputTag>("EBTimeDigiCollection"));
87  eeTimeDigiCollection_ = consumes<EcalTimeDigiCollection>(ps.getParameter<edm::InputTag>("EETimeDigiCollection"));
88 
89  caloGeometry_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
90 
91  EBDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EBDetailedTimeRecHitCollection");
92  EEDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EEDetailedTimeRecHitCollection");
93 
94  correctForVertexZPosition_ = ps.getParameter<bool>("correctForVertexZPosition");
95  useMCTruthVertex_ = ps.getParameter<bool>("useMCTruthVertex");
97  if (not useMCTruthVertex_) {
98  recoVertex_ = consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("recoVertex"));
99  } else {
100  simVertex_ = consumes<edm::SimVertexContainer>(ps.getParameter<edm::InputTag>("simVertex"));
101  }
102  }
103 
104  ebTimeLayer_ = ps.getParameter<int>("EBTimeLayer");
105  eeTimeLayer_ = ps.getParameter<int>("EETimeLayer");
106 
107  produces<EBRecHitCollection>(EBDetailedTimeRecHitCollection_);
108  produces<EERecHitCollection>(EEDetailedTimeRecHitCollection_);
109 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< EcalTimeDigiCollection > eeTimeDigiCollection_
edm::EDGetTokenT< EcalTimeDigiCollection > ebTimeDigiCollection_
edm::EDGetTokenT< reco::VertexCollection > recoVertex_
edm::EDGetTokenT< EBRecHitCollection > EBRecHitCollection_
edm::EDGetTokenT< edm::SimVertexContainer > simVertex_
edm::EDGetTokenT< EERecHitCollection > EERecHitCollection_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometry_

Member Function Documentation

◆ deltaTimeOfFlight()

double EcalDetailedTimeRecHitProducer::deltaTimeOfFlight ( GlobalPoint vertex,
const DetId detId,
int  layer 
) const
private

Definition at line 246 of file EcalDetailedTimeRecHitProducer.cc.

References cms::cuda::assert(), hcalRecHitTable_cff::detId, CaloGeometry::getGeometry(), nano_mu_digi_cff::layer, m_geometry, PV3DBase< T, PVType, FrameType >::mag(), and bphysicsOniaDQM_cfi::vertex.

Referenced by produce().

246  {
247  auto cellGeometry(m_geometry->getGeometry(detId));
248  assert(nullptr != cellGeometry);
249  GlobalPoint layerPos =
250  cellGeometry->getPosition(double(layer) + 0.5); //depth in mm in the middle of the layer position
251  GlobalVector tofVector = layerPos - vertex;
252  return (layerPos.mag() * cm - tofVector.mag() * cm) / (float)c_light;
253 }
assert(be >=bs)
T mag() const
Definition: PV3DBase.h:64
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60

◆ produce()

void EcalDetailedTimeRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 111 of file EcalDetailedTimeRecHitProducer.cc.

References cms::cuda::assert(), caloGeometry_, correctForVertexZPosition_, deltaTimeOfFlight(), EBDetailedTimeRecHitCollection_, EBRecHitCollection_, filterRecHits_cfi::EBRecHits, ebTimeDigiCollection_, ebTimeLayer_, EEDetailedTimeRecHitCollection_, EERecHitCollection_, filterRecHits_cfi::EERecHits, eeTimeDigiCollection_, eeTimeLayer_, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), edm::Event::getByToken(), edm::EventSetup::getHandle(), edm::HandleBase::isValid(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, m_geometry, eostools::move(), CoreSimVertex::position(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), recoVertex_, EcalRecHit::setTime(), simVertex_, edm::SortedCollection< T, SORT >::size(), useMCTruthVertex_, bphysicsOniaDQM_cfi::vertex, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

111  {
112  using namespace edm;
113  using namespace reco;
114 
116 
117  m_geometry = hGeometry.product();
118 
119  Handle<EBRecHitCollection> pEBRecHits;
120  Handle<EERecHitCollection> pEERecHits;
121 
122  const EBRecHitCollection* EBRecHits = nullptr;
123  const EERecHitCollection* EERecHits = nullptr;
124 
125  evt.getByToken(EBRecHitCollection_, pEBRecHits);
126  if (pEBRecHits.isValid()) {
127  EBRecHits = pEBRecHits.product(); // get a ptr to the product
128 #ifdef DEBUG
129  LogDebug("EcalRecHitDebug") << "total # EB rechits to be re-calibrated: " << EBRecHits->size();
130 #endif
131  }
132 
133  evt.getByToken(EERecHitCollection_, pEERecHits);
134  if (pEERecHits.isValid()) {
135  EERecHits = pEERecHits.product(); // get a ptr to the product
136 #ifdef DEBUG
137  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits to be re-calibrated: " << EERecHits->size();
138 #endif
139  }
140 
141  Handle<EcalTimeDigiCollection> pEBTimeDigis;
142  Handle<EcalTimeDigiCollection> pEETimeDigis;
143 
144  const EcalTimeDigiCollection* ebTimeDigis = nullptr;
145  const EcalTimeDigiCollection* eeTimeDigis = nullptr;
146 
147  evt.getByToken(ebTimeDigiCollection_, pEBTimeDigis);
148  //evt.getByToken( digiProducer_, pEBTimeDigis);
149  if (pEBTimeDigis.isValid()) {
150  ebTimeDigis = pEBTimeDigis.product(); // get a ptr to the produc
151  edm::LogInfo("EcalDetailedTimeRecHitInfo") << "total # ebTimeDigis: " << ebTimeDigis->size();
152  }
153 
154  evt.getByToken(eeTimeDigiCollection_, pEETimeDigis);
155  //evt.getByToken( digiProducer_, pEETimeDigis);
156  if (pEETimeDigis.isValid()) {
157  eeTimeDigis = pEETimeDigis.product(); // get a ptr to the product
158  edm::LogInfo("EcalDetailedTimeRecHitInfo") << "total # eeTimeDigis: " << eeTimeDigis->size();
159  }
160  // collection of rechits to put in the event
161  std::unique_ptr<EBRecHitCollection> EBDetailedTimeRecHits(new EBRecHitCollection);
162  std::unique_ptr<EERecHitCollection> EEDetailedTimeRecHits(new EERecHitCollection);
163 
164  std::unique_ptr<GlobalPoint> vertex;
165 
167  if (!useMCTruthVertex_) {
168  //Get the first reco vertex
169  // get primary vertices
170 
171  edm::Handle<VertexCollection> VertexHandle;
172  evt.getByToken(recoVertex_, VertexHandle);
173 
174  if (VertexHandle.isValid()) {
175  if (!(*VertexHandle).empty()) //at least 1 vertex
176  {
177  const reco::Vertex* myVertex = &(*VertexHandle)[0];
178  vertex = std::make_unique<GlobalPoint>(myVertex->x(), myVertex->y(), myVertex->z());
179  }
180  }
181 
182  } else {
183  edm::Handle<SimVertexContainer> VertexHandle;
184  evt.getByToken(simVertex_, VertexHandle);
185 
186  if (VertexHandle.isValid()) {
187  if (!(*VertexHandle).empty()) //at least 1 vertex
188  {
189  assert((*VertexHandle)[0].vertexId() == 0);
190  const SimVertex* myVertex = &(*VertexHandle)[0];
191  vertex = std::make_unique<GlobalPoint>(
192  myVertex->position().x(), myVertex->position().y(), myVertex->position().z());
193  }
194  }
195  }
196  }
197 
198  if (EBRecHits && ebTimeDigis) {
199  // loop over uncalibrated rechits to make calibrated ones
200  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
201  EcalRecHit aHit((*it));
202  EcalTimeDigiCollection::const_iterator timeDigi = ebTimeDigis->find((*it).id());
203  if (timeDigi != ebTimeDigis->end()) {
204  if (timeDigi->sampleOfInterest() >= 0) {
205  float myTime = (*timeDigi)[timeDigi->sampleOfInterest()];
206  //Vertex corrected ToF
207  if (vertex) {
208  aHit.setTime(myTime + deltaTimeOfFlight(*vertex, (*it).id(), ebTimeLayer_));
209  } else
210  //Uncorrected ToF
211  aHit.setTime(myTime);
212  }
213  }
214  // leave standard time if no timeDigi is associated (e.g. noise recHits)
215  EBDetailedTimeRecHits->push_back(aHit);
216  }
217  }
218 
219  if (EERecHits && eeTimeDigis) {
220  // loop over uncalibrated rechits to make calibrated ones
221  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
222  EcalRecHit aHit(*it);
223  EcalTimeDigiCollection::const_iterator timeDigi = eeTimeDigis->find((*it).id());
224  if (timeDigi != eeTimeDigis->end()) {
225  if (timeDigi->sampleOfInterest() >= 0) {
226  float myTime = (*timeDigi)[timeDigi->sampleOfInterest()];
227  //Vertex corrected ToF
228  if (vertex) {
229  aHit.setTime(myTime + deltaTimeOfFlight(*vertex, (*it).id(), eeTimeLayer_));
230  } else
231  //Uncorrected ToF
232  aHit.setTime(myTime);
233  }
234  }
235  EEDetailedTimeRecHits->push_back(aHit);
236  }
237  }
238  // put the collection of recunstructed hits in the event
239  LogInfo("EcalDetailedTimeRecHitInfo") << "total # EB rechits: " << EBDetailedTimeRecHits->size();
240  LogInfo("EcalDetailedTimeRecHitInfo") << "total # EE rechits: " << EEDetailedTimeRecHits->size();
241 
242  evt.put(std::move(EBDetailedTimeRecHits), EBDetailedTimeRecHitCollection_);
243  evt.put(std::move(EEDetailedTimeRecHits), EEDetailedTimeRecHitCollection_);
244 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
double z() const
z coordinate
Definition: Vertex.h:134
size_type size() const
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
edm::EDGetTokenT< EcalTimeDigiCollection > eeTimeDigiCollection_
T const * product() const
Definition: Handle.h:70
std::vector< EcalRecHit >::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
assert(be >=bs)
edm::EDGetTokenT< EcalTimeDigiCollection > ebTimeDigiCollection_
T const * product() const
Definition: ESHandle.h:86
double deltaTimeOfFlight(GlobalPoint &vertex, const DetId &detId, int layer) const
edm::EDGetTokenT< reco::VertexCollection > recoVertex_
double x() const
x coordinate
Definition: Vertex.h:130
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
double y() const
y coordinate
Definition: Vertex.h:132
const_iterator end() const
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< EBRecHitCollection > EBRecHitCollection_
iterator find(key_type k)
fixed size matrix
HLT enums.
edm::EDGetTokenT< edm::SimVertexContainer > simVertex_
edm::EDGetTokenT< EERecHitCollection > EERecHitCollection_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometry_
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ caloGeometry_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> EcalDetailedTimeRecHitProducer::caloGeometry_
private

Definition at line 76 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ correctForVertexZPosition_

bool EcalDetailedTimeRecHitProducer::correctForVertexZPosition_
private

Definition at line 65 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EBDetailedTimeRecHitCollection_

std::string EcalDetailedTimeRecHitProducer::EBDetailedTimeRecHitCollection_
private

Definition at line 78 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EBRecHitCollection_

edm::EDGetTokenT<EBRecHitCollection> EcalDetailedTimeRecHitProducer::EBRecHitCollection_
private

Definition at line 60 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ ebTimeDigiCollection_

edm::EDGetTokenT<EcalTimeDigiCollection> EcalDetailedTimeRecHitProducer::ebTimeDigiCollection_
private

Definition at line 72 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ ebTimeLayer_

int EcalDetailedTimeRecHitProducer::ebTimeLayer_
private

Definition at line 68 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EEDetailedTimeRecHitCollection_

std::string EcalDetailedTimeRecHitProducer::EEDetailedTimeRecHitCollection_
private

Definition at line 79 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EERecHitCollection_

edm::EDGetTokenT<EERecHitCollection> EcalDetailedTimeRecHitProducer::EERecHitCollection_
private

Definition at line 61 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ eeTimeDigiCollection_

edm::EDGetTokenT<EcalTimeDigiCollection> EcalDetailedTimeRecHitProducer::eeTimeDigiCollection_
private

Definition at line 74 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ eeTimeLayer_

int EcalDetailedTimeRecHitProducer::eeTimeLayer_
private

Definition at line 69 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ m_geometry

const CaloGeometry* EcalDetailedTimeRecHitProducer::m_geometry
private

Definition at line 58 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by deltaTimeOfFlight(), and produce().

◆ recoVertex_

edm::EDGetTokenT<reco::VertexCollection> EcalDetailedTimeRecHitProducer::recoVertex_
private

Definition at line 63 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ simVertex_

edm::EDGetTokenT<edm::SimVertexContainer> EcalDetailedTimeRecHitProducer::simVertex_
private

Definition at line 64 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ useMCTruthVertex_

bool EcalDetailedTimeRecHitProducer::useMCTruthVertex_
private

Definition at line 66 of file EcalDetailedTimeRecHitProducer.cc.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().