CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalBarrelClusterFastTimer Class Reference
Inheritance diagram for EcalBarrelClusterFastTimer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalBarrelClusterFastTimer (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~EcalBarrelClusterFastTimer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

float correctTimeToVertex (const float intime, const DetId &timeDet, const reco::Vertex &vtx, const CaloSubdetectorGeometry *ecalGeom) const
 
std::pair< float, DetIdgetTimeForECALPFCluster (const EcalRecHitCollection &, const reco::PFCluster &) const
 

Private Attributes

std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
 
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
 
edm::EDGetTokenT< EcalRecHitCollectionebTimeHitsToken_
 
const unsigned ecalDepth_
 
const float minEnergy_
 
const float minFraction_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 35 of file EcalBarrelClusterFastTimer.cc.

Constructor & Destructor Documentation

EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer ( const edm::ParameterSet conf)

Definition at line 78 of file EcalBarrelClusterFastTimer.cc.

References _resolutions, beamerCreator::create(), timingPdfMaker::get, edm::ParameterSet::getParameterSetVector(), Skims_PA_cff::name, L1TObjectsTimingClient_cff::resolution, and AlCaHLTBitMon_QueryRunRegistry::string.

79  : ebTimeHitsToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("ebTimeHits"))),
80  ebClustersToken_(consumes<std::vector<reco::PFCluster>>(conf.getParameter<edm::InputTag>("ebClusters"))),
81  minFraction_(conf.getParameter<double>("minFractionToConsider")),
82  minEnergy_(conf.getParameter<double>("minEnergyToConsider")),
83  ecalDepth_(conf.getParameter<double>("ecalDepth")) {
84  // setup resolution models
85  const std::vector<edm::ParameterSet>& resos = conf.getParameterSetVector("resolutionModels");
86  for (const auto& reso : resos) {
87  const std::string& name = reso.getParameter<std::string>("modelName");
88  _resolutions.emplace_back(ResolutionModelFactory::get()->create(name, reso));
89 
90  // times and time resolutions for general tracks
91  produces<edm::ValueMap<float>>(name);
92  produces<edm::ValueMap<float>>(name + resolution);
93  }
94 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
def create(alignables, pedeDump, additionalData, outputFile, config)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
EcalBarrelClusterFastTimer::~EcalBarrelClusterFastTimer ( )
inlineoverride

Definition at line 38 of file EcalBarrelClusterFastTimer.cc.

References produce().

38 {}

Member Function Documentation

float EcalBarrelClusterFastTimer::correctTimeToVertex ( const float  intime,
const DetId timeDet,
const reco::Vertex vtx,
const CaloSubdetectorGeometry ecalGeom 
) const
private

Definition at line 171 of file EcalBarrelClusterFastTimer.cc.

References TauDecayModes::dec, ecalDepth_, Exception, CaloSubdetectorGeometry::getGeometry(), reco::Vertex::position(), DetId::rawId(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

174  {
175  if (timeDet.rawId() == 0)
176  return -999.;
177  // correct the cluster time from 0,0,0 to the primary vertex given
178  auto cellGeometry = ecalGeom->getGeometry(timeDet);
179  if (nullptr == cellGeometry) {
180  throw cms::Exception("BadECALBarrelCell")
181  << std::hex << timeDet.rawId() << std::dec << " is not a valid ECAL Barrel DetId!";
182  }
183  //depth in mm in the middle of the layer position;
184  GlobalPoint layerPos = cellGeometry->getPosition(ecalDepth_ + 0.5);
185  const math::XYZPoint layerPos_cm(layerPos.x(), layerPos.y(), layerPos.z());
186  const math::XYZVector to_center = layerPos_cm - math::XYZPoint(0., 0., 0.);
187  const math::XYZVector to_vtx = layerPos_cm - vtx.position();
188 
189  /*
190  std::cout << intime << ' ' << to_center.r()/cm_per_ns << ' ' << to_vtx.r()/cm_per_ns
191  << ' ' << intime + to_center.r()/cm_per_ns - to_vtx.r()/cm_per_ns << std::endl;
192  */
193 
194  return intime + to_center.r() / cm_per_ns - to_vtx.r() / cm_per_ns;
195 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
const Point & position() const
position
Definition: Vertex.h:113
T z() const
Definition: PV3DBase.h:61
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.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
T x() const
Definition: PV3DBase.h:59
std::pair< float, DetId > EcalBarrelClusterFastTimer::getTimeForECALPFCluster ( const EcalRecHitCollection timehits,
const reco::PFCluster cluster 
) const
private

Definition at line 141 of file EcalBarrelClusterFastTimer.cc.

References HCALHighEnergyHPDFilter_cfi::energy, edm::SortedCollection< T, SORT >::find(), HLT_2018_cff::fraction, SiStripPI::max, minEnergy_, minFraction_, and reco::PFCluster::recHitFractions().

Referenced by produce().

142  {
143  const auto& rhfs = cluster.recHitFractions();
144  unsigned best_hit = 0;
145  float best_energy = -1.f;
146  for (const auto& rhf : rhfs) {
147  const auto& hitref = rhf.recHitRef();
148  const unsigned detid = hitref->detId();
149  const auto fraction = rhf.fraction();
150  const auto energy = hitref->energy();
152  continue;
153  auto timehit = timehits.find(detid);
154  float e_hit = rhf.fraction() * hitref->energy();
155  if (e_hit > best_energy && timehit->isTimeValid()) {
156  best_energy = e_hit;
157  best_hit = detid;
158  }
159  }
160 
161  float best_time_guess = std::numeric_limits<float>::max();
162  if (best_energy > 0.) {
163  best_time_guess = timehits.find(best_hit)->time();
164  }
165 
166  //std::cout << "EcalBarrelFastTimer: " << best_time_guess << ' ' << best_energy << ' ' << best_hit << std::endl;
167 
168  return std::make_pair(best_time_guess, DetId(best_hit));
169 }
Definition: DetId.h:17
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:69
iterator find(key_type k)
void EcalBarrelClusterFastTimer::produce ( edm::StreamID  sid,
edm::Event evt,
const edm::EventSetup es 
) const
override

Definition at line 96 of file EcalBarrelClusterFastTimer.cc.

References _resolutions, bsc_activity_cfg::clusters, ebClustersToken_, ebTimeHitsToken_, edm::EventID::event(), dqmdumpme::first, edm::Event::getByToken(), getTimeForECALPFCluster(), mps_fire::i, edm::EventBase::id(), edm::EventID::luminosityBlock(), Skims_PA_cff::name, L1TObjectsTimingClient_cff::resolution, electronProducer_cfi::resolutions, edm::EventID::run(), SurveyInfoScenario_cff::seed, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~EcalBarrelClusterFastTimer().

96  {
99 
100  evt.getByToken(ebClustersToken_, clustersH);
101  evt.getByToken(ebTimeHitsToken_, timehitsH);
102 
103  const auto& clusters = *clustersH;
104  const auto& timehits = *timehitsH;
105 
106  // get event-based seed for RNG
107  unsigned int runNum_uint = static_cast<unsigned int>(evt.id().run());
108  unsigned int lumiNum_uint = static_cast<unsigned int>(evt.id().luminosityBlock());
109  unsigned int evNum_uint = static_cast<unsigned int>(evt.id().event());
110  std::uint32_t seed = (lumiNum_uint << 10) + (runNum_uint << 20) + evNum_uint;
111  std::mt19937 rng(seed);
112 
113  std::vector<std::pair<float, DetId>> times; // perfect times keyed to cluster index
114  times.reserve(clusters.size());
115 
116  for (const auto& cluster : clusters) {
117  times.push_back(getTimeForECALPFCluster(timehits, cluster));
118  }
119 
120  for (const auto& reso : _resolutions) {
121  const std::string& name = reso->name();
122  std::vector<float> resolutions;
123  std::vector<float> smeared_times;
124  resolutions.reserve(clusters.size());
125  smeared_times.reserve(clusters.size());
126 
127  // smear once then correct to multiple vertices
128  for (unsigned i = 0; i < clusters.size(); ++i) {
129  const float theresolution = reso->getTimeResolution(clusters[i]);
130  std::normal_distribution<float> gausTime(times[i].first, theresolution);
131 
132  smeared_times.emplace_back(gausTime(rng));
133  resolutions.push_back(theresolution);
134  }
135 
136  writeValueMap(evt, clustersH, smeared_times, name);
137  writeValueMap(evt, clustersH, resolutions, name + resolution);
138  }
139 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
edm::EventID id() const
Definition: EventBase.h:59
std::pair< float, DetId > getTimeForECALPFCluster(const EcalRecHitCollection &, const reco::PFCluster &) const

Member Data Documentation

std::vector<std::unique_ptr<const ResolutionModel> > EcalBarrelClusterFastTimer::_resolutions
private

Definition at line 47 of file EcalBarrelClusterFastTimer.cc.

Referenced by EcalBarrelClusterFastTimer(), and produce().

edm::EDGetTokenT<std::vector<reco::PFCluster> > EcalBarrelClusterFastTimer::ebClustersToken_
private

Definition at line 45 of file EcalBarrelClusterFastTimer.cc.

Referenced by produce().

edm::EDGetTokenT<EcalRecHitCollection> EcalBarrelClusterFastTimer::ebTimeHitsToken_
private

Definition at line 44 of file EcalBarrelClusterFastTimer.cc.

Referenced by produce().

const unsigned EcalBarrelClusterFastTimer::ecalDepth_
private

Definition at line 49 of file EcalBarrelClusterFastTimer.cc.

Referenced by correctTimeToVertex().

const float EcalBarrelClusterFastTimer::minEnergy_
private

Definition at line 48 of file EcalBarrelClusterFastTimer.cc.

Referenced by getTimeForECALPFCluster().

const float EcalBarrelClusterFastTimer::minFraction_
private

Definition at line 48 of file EcalBarrelClusterFastTimer.cc.

Referenced by getTimeForECALPFCluster().