32 #include "CLHEP/Units/SystemOfUnits.h" 66 const std::vector<T> &
values,
68 auto valMap = std::make_unique<edm::ValueMap<T>>();
79 minFraction_( conf.getParameter<double>(
"minFractionToConsider") ),
80 minEnergy_(conf.getParameter<double>(
"minEnergyToConsider") ),
81 ecalDepth_(conf.getParameter<double>(
"ecalDepth") )
85 for(
const auto& reso : resos ) {
91 produces<edm::ValueMap<float> >(
name);
92 produces<edm::ValueMap<float> >(name+
resolution);
104 const auto& timehits = *timehitsH;
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);
113 std::vector<std::pair<float,DetId> >
times;
116 for(
const auto& cluster :
clusters ) {
123 std::vector<float> smeared_times;
124 resolutions.reserve(clusters.size());
125 smeared_times.reserve(clusters.size());
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);
132 smeared_times.emplace_back( gausTime(rng) );
133 resolutions.push_back( theresolution );
136 writeValueMap(evt,clustersH,smeared_times,name);
137 writeValueMap(evt,clustersH,resolutions,name+
resolution);
145 unsigned best_hit = 0;
146 float best_energy = -1.f;
147 for(
const auto& rhf : rhfs ) {
148 const auto& hitref = rhf.recHitRef();
149 const unsigned detid = hitref->detId();
150 const auto fraction = rhf.fraction();
151 const auto energy = hitref->energy();
153 auto timehit = timehits.
find(detid);
154 float e_hit = rhf.fraction() * hitref->energy();
155 if( e_hit > best_energy && timehit->isTimeValid() ) {
162 if( best_energy > 0. ) {
163 best_time_guess = timehits.
find(best_hit)->time();
168 return std::make_pair(best_time_guess,
DetId(best_hit));
173 if( timeDet.
rawId() == 0 )
return -999.;
175 auto cellGeometry = ecalGeom->
getGeometry(timeDet);
176 if(
nullptr == cellGeometry ) {
178 << timeDet <<
" is not a valid ECAL Barrel DetId!";
191 return intime + to_center.r()/cm_per_ns - to_vtx.r()/cm_per_ns;
EventNumber_t event() const
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_
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
LuminosityBlockNumber_t luminosityBlock() const
const Point & position() const
position
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
edm::EDGetTokenT< EcalRecHitCollection > ebTimeHitsToken_
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
XYZPointD XYZPoint
point in space with cartesian internal representation
const unsigned ecalDepth_
~EcalBarrelClusterFastTimer() override
iterator find(key_type k)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
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)