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 ) {
90 produces<edm::ValueMap<float> >(
name);
91 produces<edm::ValueMap<float> >(name+
resolution);
103 const auto& timehits = *timehitsH;
106 unsigned int runNum_uint = static_cast <
unsigned int> (evt.
id().
run());
107 unsigned int lumiNum_uint = static_cast <
unsigned int> (evt.
id().
luminosityBlock());
108 unsigned int evNum_uint = static_cast <
unsigned int> (evt.
id().
event());
109 std::uint32_t
seed = (lumiNum_uint<<10) + (runNum_uint<<20) + evNum_uint;
110 std::mt19937 rng(seed);
112 std::vector<std::pair<float,DetId> >
times;
115 for(
const auto& cluster :
clusters ) {
122 std::vector<float> smeared_times;
123 resolutions.reserve(clusters.size());
124 smeared_times.reserve(clusters.size());
127 for(
unsigned i = 0 ;
i < clusters.size(); ++
i ) {
128 const float theresolution = reso->getTimeResolution(clusters[
i]);
129 std::normal_distribution<float> gausTime(times[i].
first, theresolution);
131 smeared_times.emplace_back( gausTime(rng) );
132 resolutions.push_back( theresolution );
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 auto timehit = timehits.
find(detid);
153 float e_hit = rhf.fraction() * hitref->energy();
154 if( e_hit > best_energy && timehit->isTimeValid() ) {
161 if( best_energy > 0. ) {
162 best_time_guess = timehits.
find(best_hit)->time();
167 return std::make_pair(best_time_guess,
DetId(best_hit));
172 if( timeDet.
rawId() == 0 )
return -999.;
174 auto cellGeometry = ecalGeom->
getGeometry(timeDet);
175 if(
nullptr == cellGeometry ) {
177 << std::hex << timeDet.
rawId() <<
std::dec<<
" is not a valid ECAL Barrel DetId!";
190 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_
def create(alignables, pedeDump, additionalData, outputFile, config)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t rawId() const
get the raw id
LuminosityBlockNumber_t luminosityBlock() const
const Point & position() const
position
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::unique_ptr< const ResolutionModel > > _resolutions
#define DEFINE_FWK_MODULE(type)
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)