31 #include "CLHEP/Units/SystemOfUnits.h"
33 #include "CLHEP/Random/RandGauss.h"
68 const std::vector<T> &
values,
70 auto valMap = std::make_unique<edm::ValueMap<T>>();
72 filler.insert(
handle, values.begin(), values.end());
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") )
87 for(
const auto& reso : resos ) {
93 produces<edm::ValueMap<float> >(
name);
94 produces<edm::ValueMap<float> >(name+
resolution);
100 <<
"EcalBarrelClusterFastTimer::EcalBarrelClusterFastTimer() - RandomNumberGeneratorService is not present in configuration file.\n"
101 <<
"Add the service in the configuration file or remove the modules that require it.";
108 auto rng_engine = &(rng->
getEngine(sid));
117 const auto& timehits = *timehitsH;
119 std::vector<std::pair<float,DetId> >
times;
122 for(
const auto& cluster :
clusters ) {
128 std::vector<float> resolutions;
129 std::vector<float> smeared_times;
130 resolutions.reserve(clusters.size());
131 smeared_times.reserve(clusters.size());
134 for(
unsigned i = 0 ;
i < clusters.size(); ++
i ) {
135 const float theresolution = reso->getTimeResolution(clusters[
i]);
137 smeared_times.emplace_back( CLHEP::RandGauss::shoot(rng_engine, times[i].
first, theresolution) );
138 resolutions.push_back( theresolution );
141 writeValueMap(evt,clustersH,smeared_times,name);
142 writeValueMap(evt,clustersH,resolutions,name+
resolution);
150 unsigned best_hit = 0;
151 float best_energy = -1.f;
152 for(
const auto& rhf : rhfs ) {
153 const auto& hitref = rhf.recHitRef();
154 const unsigned detid = hitref->detId();
155 const auto fraction = rhf.fraction();
156 const auto energy = hitref->energy();
158 auto timehit = timehits.
find(detid);
159 float e_hit = rhf.fraction() * hitref->energy();
160 if( e_hit > best_energy && timehit->isTimeValid() ) {
167 if( best_energy > 0. ) {
168 best_time_guess = timehits.
find(best_hit)->time();
173 return std::make_pair(best_time_guess,
DetId(best_hit));
178 if( timeDet.
rawId() == 0 )
return -999.;
181 if(
nullptr == cellGeometry ) {
183 << timeDet <<
" is not a valid ECAL Barrel DetId!";
196 return intime + to_center.r()/cm_per_ns - to_vtx.r()/cm_per_ns;
VParameterSet const & getParameterSetVector(std::string const &name) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< std::vector< reco::PFCluster > > ebClustersToken_
edm::Service< edm::RandomNumberGenerator > rng
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const Point & position() const
position
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
EcalBarrelClusterFastTimer(const edm::ParameterSet &)
float correctTimeToVertex(const float intime, const DetId &timeDet, const reco::Vertex &vtx, const CaloSubdetectorGeometry *ecalGeom) const
const std::vector< edm::ParameterSet > & resos
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const unsigned ecalDepth_
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
iterator find(key_type k)
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
std::pair< float, DetId > getTimeForECALPFCluster(const EcalRecHitCollection &, const reco::PFCluster &) const
T get(const Candidate &c)
~EcalBarrelClusterFastTimer()