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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 27 of file EcalDetailedTimeRecHitProducer.h.

Constructor & Destructor Documentation

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

Definition at line 45 of file EcalDetailedTimeRecHitProducer.cc.

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

45  :
46  m_geometry(nullptr)
47 {
48  EBRecHitCollection_ = consumes<EBRecHitCollection>( ps.getParameter<edm::InputTag>("EBRecHitCollection") );
49  EERecHitCollection_ = consumes<EERecHitCollection>( ps.getParameter<edm::InputTag>("EERecHitCollection") );
50 
51  ebTimeDigiCollection_ = consumes<EcalTimeDigiCollection>( ps.getParameter<edm::InputTag>("EBTimeDigiCollection") );
52  eeTimeDigiCollection_ = consumes<EcalTimeDigiCollection>( ps.getParameter<edm::InputTag>("EETimeDigiCollection") );
53 
54  EBDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EBDetailedTimeRecHitCollection");
55  EEDetailedTimeRecHitCollection_ = ps.getParameter<std::string>("EEDetailedTimeRecHitCollection");
56 
57  correctForVertexZPosition_ = ps.getParameter<bool>("correctForVertexZPosition");
58  useMCTruthVertex_ = ps.getParameter<bool>("useMCTruthVertex");
60  if(not useMCTruthVertex_) {
61  recoVertex_ = consumes<reco::VertexCollection>( ps.getParameter<edm::InputTag>("recoVertex") );
62  } else {
63  simVertex_ = consumes<edm::SimVertexContainer>( ps.getParameter<edm::InputTag>("simVertex") );
64  }
65  }
66 
67  ebTimeLayer_ = ps.getParameter<int>("EBTimeLayer");
68  eeTimeLayer_ = ps.getParameter<int>("EETimeLayer");
69 
70  produces< EBRecHitCollection >(EBDetailedTimeRecHitCollection_);
71  produces< EERecHitCollection >(EEDetailedTimeRecHitCollection_);
72 }
T getParameter(std::string const &) const
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_
EcalDetailedTimeRecHitProducer::~EcalDetailedTimeRecHitProducer ( )
override

Definition at line 74 of file EcalDetailedTimeRecHitProducer.cc.

74  {
75 }

Member Function Documentation

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

Definition at line 233 of file EcalDetailedTimeRecHitProducer.cc.

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

Referenced by produce().

234 {
235  auto cellGeometry (m_geometry->getGeometry( detId ) ) ;
236  assert( nullptr != cellGeometry ) ;
237  GlobalPoint layerPos = cellGeometry->getPosition( double(layer)+0.5 ); //depth in mm in the middle of the layer position
238  GlobalVector tofVector = layerPos-vertex;
239  return (layerPos.mag()*cm-tofVector.mag()*cm)/(float)c_light ;
240 }
T mag() const
Definition: PV3DBase.h:67
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:85
void EcalDetailedTimeRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 78 of file EcalDetailedTimeRecHitProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), correctForVertexZPosition_, deltaTimeOfFlight(), EBDetailedTimeRecHitCollection_, EBRecHitCollection_, egHLT::errCodes::EBRecHits, ebTimeDigiCollection_, ebTimeLayer_, EEDetailedTimeRecHitCollection_, EERecHitCollection_, egHLT::errCodes::EERecHits, eeTimeDigiCollection_, eeTimeLayer_, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), edm::EventSetup::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_, reco::Vertex::x(), reco::Vertex::y(), and reco::Vertex::z().

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

Member Data Documentation

bool EcalDetailedTimeRecHitProducer::correctForVertexZPosition_
private

Definition at line 46 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

std::string EcalDetailedTimeRecHitProducer::EBDetailedTimeRecHitCollection_
private

Definition at line 55 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

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

Definition at line 41 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

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

Definition at line 52 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

int EcalDetailedTimeRecHitProducer::ebTimeLayer_
private

Definition at line 49 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

std::string EcalDetailedTimeRecHitProducer::EEDetailedTimeRecHitCollection_
private

Definition at line 56 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

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

Definition at line 42 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

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

Definition at line 53 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

int EcalDetailedTimeRecHitProducer::eeTimeLayer_
private

Definition at line 50 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

const CaloGeometry* EcalDetailedTimeRecHitProducer::m_geometry
private

Definition at line 39 of file EcalDetailedTimeRecHitProducer.h.

Referenced by deltaTimeOfFlight(), and produce().

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

Definition at line 44 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

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

Definition at line 45 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().

bool EcalDetailedTimeRecHitProducer::useMCTruthVertex_
private

Definition at line 47 of file EcalDetailedTimeRecHitProducer.h.

Referenced by EcalDetailedTimeRecHitProducer(), and produce().