CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalDetailedTimeRecHitProducer Class Reference

#include <EcalDetailedTimeRecHitProducer.h>

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
 
 ~EcalDetailedTimeRecHitProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

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

Private Attributes

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

produce ECAL detailed time Rechits

Author
Paolo Meridiani

produce ECAL rechits associating them with improved ecalTimeDigis

Author
Paolo Meridiani, INFN Roma

Definition at line 26 of file EcalDetailedTimeRecHitProducer.h.

Constructor & Destructor Documentation

◆ EcalDetailedTimeRecHitProducer()

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

Definition at line 43 of file EcalDetailedTimeRecHitProducer.cc.

43  : m_geometry(nullptr) {
44  EBRecHitCollection_ = consumes<EBRecHitCollection>(ps.getParameter<edm::InputTag>("EBRecHitCollection"));
45  EERecHitCollection_ = consumes<EERecHitCollection>(ps.getParameter<edm::InputTag>("EERecHitCollection"));
46 
47  ebTimeDigiCollection_ = consumes<EcalTimeDigiCollection>(ps.getParameter<edm::InputTag>("EBTimeDigiCollection"));
48  eeTimeDigiCollection_ = consumes<EcalTimeDigiCollection>(ps.getParameter<edm::InputTag>("EETimeDigiCollection"));
49 
50  EBDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EBDetailedTimeRecHitCollection");
51  EEDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EEDetailedTimeRecHitCollection");
52 
53  correctForVertexZPosition_ = ps.getParameter<bool>("correctForVertexZPosition");
54  useMCTruthVertex_ = ps.getParameter<bool>("useMCTruthVertex");
56  if (not useMCTruthVertex_) {
57  recoVertex_ = consumes<reco::VertexCollection>(ps.getParameter<edm::InputTag>("recoVertex"));
58  } else {
59  simVertex_ = consumes<edm::SimVertexContainer>(ps.getParameter<edm::InputTag>("simVertex"));
60  }
61  }
62 
63  ebTimeLayer_ = ps.getParameter<int>("EBTimeLayer");
64  eeTimeLayer_ = ps.getParameter<int>("EETimeLayer");
65 
66  produces<EBRecHitCollection>(EBDetailedTimeRecHitCollection_);
67  produces<EERecHitCollection>(EEDetailedTimeRecHitCollection_);
68 }

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

◆ ~EcalDetailedTimeRecHitProducer()

EcalDetailedTimeRecHitProducer::~EcalDetailedTimeRecHitProducer ( )
override

Definition at line 70 of file EcalDetailedTimeRecHitProducer.cc.

70 {}

Member Function Documentation

◆ deltaTimeOfFlight()

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

Definition at line 207 of file EcalDetailedTimeRecHitProducer.cc.

207  {
208  auto cellGeometry(m_geometry->getGeometry(detId));
209  assert(nullptr != cellGeometry);
210  GlobalPoint layerPos =
211  cellGeometry->getPosition(double(layer) + 0.5); //depth in mm in the middle of the layer position
212  GlobalVector tofVector = layerPos - vertex;
213  return (layerPos.mag() * cm - tofVector.mag() * cm) / (float)c_light;
214 }

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

Referenced by produce().

◆ produce()

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

Definition at line 72 of file EcalDetailedTimeRecHitProducer.cc.

72  {
73  using namespace edm;
74  using namespace reco;
75 
77  es.get<CaloGeometryRecord>().get(hGeometry);
78 
79  m_geometry = hGeometry.product();
80 
81  Handle<EBRecHitCollection> pEBRecHits;
82  Handle<EERecHitCollection> pEERecHits;
83 
84  const EBRecHitCollection* EBRecHits = nullptr;
85  const EERecHitCollection* EERecHits = nullptr;
86 
87  evt.getByToken(EBRecHitCollection_, pEBRecHits);
88  if (pEBRecHits.isValid()) {
89  EBRecHits = pEBRecHits.product(); // get a ptr to the product
90 #ifdef DEBUG
91  LogDebug("EcalRecHitDebug") << "total # EB rechits to be re-calibrated: " << EBRecHits->size();
92 #endif
93  }
94 
95  evt.getByToken(EERecHitCollection_, pEERecHits);
96  if (pEERecHits.isValid()) {
97  EERecHits = pEERecHits.product(); // get a ptr to the product
98 #ifdef DEBUG
99  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits to be re-calibrated: " << EERecHits->size();
100 #endif
101  }
102 
103  Handle<EcalTimeDigiCollection> pEBTimeDigis;
104  Handle<EcalTimeDigiCollection> pEETimeDigis;
105 
106  const EcalTimeDigiCollection* ebTimeDigis = nullptr;
107  const EcalTimeDigiCollection* eeTimeDigis = nullptr;
108 
109  evt.getByToken(ebTimeDigiCollection_, pEBTimeDigis);
110  //evt.getByToken( digiProducer_, pEBTimeDigis);
111  if (pEBTimeDigis.isValid()) {
112  ebTimeDigis = pEBTimeDigis.product(); // get a ptr to the produc
113  edm::LogInfo("EcalDetailedTimeRecHitInfo") << "total # ebTimeDigis: " << ebTimeDigis->size();
114  }
115 
116  evt.getByToken(eeTimeDigiCollection_, pEETimeDigis);
117  //evt.getByToken( digiProducer_, pEETimeDigis);
118  if (pEETimeDigis.isValid()) {
119  eeTimeDigis = pEETimeDigis.product(); // get a ptr to the product
120  edm::LogInfo("EcalDetailedTimeRecHitInfo") << "total # eeTimeDigis: " << eeTimeDigis->size();
121  }
122  // collection of rechits to put in the event
123  std::unique_ptr<EBRecHitCollection> EBDetailedTimeRecHits(new EBRecHitCollection);
124  std::unique_ptr<EERecHitCollection> EEDetailedTimeRecHits(new EERecHitCollection);
125 
126  std::unique_ptr<GlobalPoint> vertex;
127 
129  if (!useMCTruthVertex_) {
130  //Get the first reco vertex
131  // get primary vertices
132 
133  edm::Handle<VertexCollection> VertexHandle;
134  evt.getByToken(recoVertex_, VertexHandle);
135 
136  if (VertexHandle.isValid()) {
137  if (!(*VertexHandle).empty()) //at least 1 vertex
138  {
139  const reco::Vertex* myVertex = &(*VertexHandle)[0];
140  vertex.reset(new GlobalPoint(myVertex->x(), myVertex->y(), myVertex->z()));
141  }
142  }
143 
144  } else {
145  edm::Handle<SimVertexContainer> VertexHandle;
146  evt.getByToken(simVertex_, VertexHandle);
147 
148  if (VertexHandle.isValid()) {
149  if (!(*VertexHandle).empty()) //at least 1 vertex
150  {
151  assert((*VertexHandle)[0].vertexId() == 0);
152  const SimVertex* myVertex = &(*VertexHandle)[0];
153  vertex.reset(new GlobalPoint(myVertex->position().x(), myVertex->position().y(), myVertex->position().z()));
154  }
155  }
156  }
157  }
158 
159  if (EBRecHits && ebTimeDigis) {
160  // loop over uncalibrated rechits to make calibrated ones
161  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
162  EcalRecHit aHit((*it));
163  EcalTimeDigiCollection::const_iterator timeDigi = ebTimeDigis->find((*it).id());
164  if (timeDigi != ebTimeDigis->end()) {
165  if (timeDigi->sampleOfInterest() >= 0) {
166  float myTime = (*timeDigi)[timeDigi->sampleOfInterest()];
167  //Vertex corrected ToF
168  if (vertex) {
169  aHit.setTime(myTime + deltaTimeOfFlight(*vertex, (*it).id(), ebTimeLayer_));
170  } else
171  //Uncorrected ToF
172  aHit.setTime(myTime);
173  }
174  }
175  // leave standard time if no timeDigi is associated (e.g. noise recHits)
176  EBDetailedTimeRecHits->push_back(aHit);
177  }
178  }
179 
180  if (EERecHits && eeTimeDigis) {
181  // loop over uncalibrated rechits to make calibrated ones
182  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
183  EcalRecHit aHit(*it);
184  EcalTimeDigiCollection::const_iterator timeDigi = eeTimeDigis->find((*it).id());
185  if (timeDigi != eeTimeDigis->end()) {
186  if (timeDigi->sampleOfInterest() >= 0) {
187  float myTime = (*timeDigi)[timeDigi->sampleOfInterest()];
188  //Vertex corrected ToF
189  if (vertex) {
190  aHit.setTime(myTime + deltaTimeOfFlight(*vertex, (*it).id(), eeTimeLayer_));
191  } else
192  //Uncorrected ToF
193  aHit.setTime(myTime);
194  }
195  }
196  EEDetailedTimeRecHits->push_back(aHit);
197  }
198  }
199  // put the collection of recunstructed hits in the event
200  LogInfo("EcalDetailedTimeRecHitInfo") << "total # EB rechits: " << EBDetailedTimeRecHits->size();
201  LogInfo("EcalDetailedTimeRecHitInfo") << "total # EE rechits: " << EEDetailedTimeRecHits->size();
202 
203  evt.put(std::move(EBDetailedTimeRecHits), EBDetailedTimeRecHitCollection_);
204  evt.put(std::move(EEDetailedTimeRecHits), EEDetailedTimeRecHitCollection_);
205 }

References cms::cuda::assert(), 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::EventSetup::get(), get, edm::Event::getByToken(), edm::HandleBase::isValid(), 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().

Member Data Documentation

◆ correctForVertexZPosition_

bool EcalDetailedTimeRecHitProducer::correctForVertexZPosition_
private

Definition at line 43 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EBDetailedTimeRecHitCollection_

std::string EcalDetailedTimeRecHitProducer::EBDetailedTimeRecHitCollection_
private

Definition at line 54 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EBRecHitCollection_

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

Definition at line 38 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ ebTimeDigiCollection_

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

Definition at line 50 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ ebTimeLayer_

int EcalDetailedTimeRecHitProducer::ebTimeLayer_
private

Definition at line 46 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EEDetailedTimeRecHitCollection_

std::string EcalDetailedTimeRecHitProducer::EEDetailedTimeRecHitCollection_
private

Definition at line 55 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ EERecHitCollection_

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

Definition at line 39 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ eeTimeDigiCollection_

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

Definition at line 52 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ eeTimeLayer_

int EcalDetailedTimeRecHitProducer::eeTimeLayer_
private

Definition at line 47 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ m_geometry

const CaloGeometry* EcalDetailedTimeRecHitProducer::m_geometry
private

Definition at line 36 of file EcalDetailedTimeRecHitProducer.h.

Referenced by deltaTimeOfFlight(), and produce().

◆ recoVertex_

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

Definition at line 41 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ simVertex_

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

Definition at line 42 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

◆ useMCTruthVertex_

bool EcalDetailedTimeRecHitProducer::useMCTruthVertex_
private

Definition at line 44 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

Vector3DBase
Definition: Vector3DBase.h:8
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalDetailedTimeRecHitProducer::simVertex_
edm::EDGetTokenT< edm::SimVertexContainer > simVertex_
Definition: EcalDetailedTimeRecHitProducer.h:42
EcalRecHit
Definition: EcalRecHit.h:15
EcalDetailedTimeRecHitProducer::m_geometry
const CaloGeometry * m_geometry
Definition: EcalDetailedTimeRecHitProducer.h:36
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
SimVertex
Definition: SimVertex.h:5
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalDetailedTimeRecHitProducer::deltaTimeOfFlight
double deltaTimeOfFlight(GlobalPoint &vertex, const DetId &detId, int layer) const
Definition: EcalDetailedTimeRecHitProducer.cc:207
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::LogInfo
Definition: MessageLogger.h:254
cms::cuda::assert
assert(be >=bs)
edm::SortedCollection< EcalRecHit >
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
EcalDetailedTimeRecHitProducer::recoVertex_
edm::EDGetTokenT< reco::VertexCollection > recoVertex_
Definition: EcalDetailedTimeRecHitProducer.h:41
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle< CaloGeometry >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
CaloGeometry::getGeometry
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
EcalDetailedTimeRecHitProducer::EEDetailedTimeRecHitCollection_
std::string EEDetailedTimeRecHitCollection_
Definition: EcalDetailedTimeRecHitProducer.h:55
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
reco::Vertex::x
double x() const
x coordinate
Definition: Vertex.h:116
EcalDetailedTimeRecHitProducer::useMCTruthVertex_
bool useMCTruthVertex_
Definition: EcalDetailedTimeRecHitProducer.h:44
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
EcalDetailedTimeRecHitProducer::EBRecHitCollection_
edm::EDGetTokenT< EBRecHitCollection > EBRecHitCollection_
Definition: EcalDetailedTimeRecHitProducer.h:38
CoreSimVertex::position
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
get
#define get
EcalDetailedTimeRecHitProducer::eeTimeLayer_
int eeTimeLayer_
Definition: EcalDetailedTimeRecHitProducer.h:47
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalDetailedTimeRecHitProducer::correctForVertexZPosition_
bool correctForVertexZPosition_
Definition: EcalDetailedTimeRecHitProducer.h:43
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Vertex::y
double y() const
y coordinate
Definition: Vertex.h:118
EcalDetailedTimeRecHitProducer::ebTimeLayer_
int ebTimeLayer_
Definition: EcalDetailedTimeRecHitProducer.h:46
EcalDetailedTimeRecHitProducer::EERecHitCollection_
edm::EDGetTokenT< EERecHitCollection > EERecHitCollection_
Definition: EcalDetailedTimeRecHitProducer.h:39
EcalDetailedTimeRecHitProducer::ebTimeDigiCollection_
edm::EDGetTokenT< EcalTimeDigiCollection > ebTimeDigiCollection_
Definition: EcalDetailedTimeRecHitProducer.h:50
EcalDetailedTimeRecHitProducer::EBDetailedTimeRecHitCollection_
std::string EBDetailedTimeRecHitCollection_
Definition: EcalDetailedTimeRecHitProducer.h:54
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
EcalDetailedTimeRecHitProducer::eeTimeDigiCollection_
edm::EDGetTokenT< EcalTimeDigiCollection > eeTimeDigiCollection_
Definition: EcalDetailedTimeRecHitProducer.h:52
filterRecHits_cfi.EBRecHits
EBRecHits
Definition: filterRecHits_cfi.py:8