7 #ifndef HLTrigger_JetMET_plugins_HLTJetTimingProducer_h
8 #define HLTrigger_JetMET_plugins_HLTJetTimingProducer_h
63 ecalRecHitsEBToken_{consumes<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit>>>(
65 ecalRecHitsEEToken_{consumes<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit>>>(
67 barrelJets_{
iConfig.getParameter<
bool>(
"barrelJets")},
68 endcapJets_{
iConfig.getParameter<
bool>(
"endcapJets")},
69 ecalCellEnergyThresh_{
iConfig.getParameter<
double>(
"ecalCellEnergyThresh")},
70 ecalCellTimeThresh_{
iConfig.getParameter<
double>(
"ecalCellTimeThresh")},
71 ecalCellTimeErrorThresh_{
iConfig.getParameter<
double>(
"ecalCellTimeErrorThresh")},
72 matchingRadius2_{
std::pow(
iConfig.getParameter<
double>(
"matchingRadius"), 2)} {
73 produces<edm::ValueMap<float>>(
"");
74 produces<edm::ValueMap<unsigned int>>(
"jetCellsForTiming");
75 produces<edm::ValueMap<float>>(
"jetEcalEtForTiming");
83 float& weightedTimeCell,
84 float& totalEmEnergyCell,
86 for (
auto const& ecalRH : ecalRecHits) {
91 if (ecalRH.energy() < ecalCellEnergyThresh_)
93 if (ecalRH.timeError() <= 0. || ecalRH.timeError() > ecalCellTimeErrorThresh_)
95 if (
std::abs(ecalRH.time()) > ecalCellTimeThresh_)
97 auto const pos = caloGeometry.
getPosition(ecalRH.detid());
100 weightedTimeCell += ecalRH.time() * ecalRH.energy() *
sin(pos.theta());
101 totalEmEnergyCell += ecalRH.energy() *
sin(pos.theta());
104 if (totalEmEnergyCell > 0) {
105 weightedTimeCell /= totalEmEnergyCell;
109 template <
typename T>
111 auto const& caloGeometry = iSetup.
getData(caloGeometryToken_);
116 std::vector<float> jetTimings;
120 jetTimings.reserve(
jets->size());
121 jetEcalEtForTiming.reserve(
jets->size());
122 jetCellsForTiming.reserve(
jets->size());
124 for (
auto const&
jet : *
jets) {
125 float weightedTimeCell = 0;
126 float totalEmEnergyCell = 0;
129 jetTimeFromEcalCells(
jet,
ecalRecHitsEB, caloGeometry, weightedTimeCell, totalEmEnergyCell, nCells);
131 weightedTimeCell *= totalEmEnergyCell;
132 jetTimeFromEcalCells(
jet,
ecalRecHitsEE, caloGeometry, weightedTimeCell, totalEmEnergyCell, nCells);
136 jetTimings.emplace_back(totalEmEnergyCell > 0 ? weightedTimeCell : -50);
137 jetEcalEtForTiming.emplace_back(totalEmEnergyCell);
138 jetCellsForTiming.emplace_back(nCells);
143 jetTimings_filler.
insert(jets, jetTimings.begin(), jetTimings.end());
144 jetTimings_filler.
fill();
149 jetEcalEtForTiming_filler.
insert(jets, jetEcalEtForTiming.begin(), jetEcalEtForTiming.end());
150 jetEcalEtForTiming_filler.
fill();
151 iEvent.
put(
std::move(jetEcalEtForTiming_out),
"jetEcalEtForTiming");
155 jetCellsForTiming_filler.
insert(jets, jetCellsForTiming.begin(), jetCellsForTiming.end());
156 jetCellsForTiming_filler.
fill();
157 iEvent.
put(
std::move(jetCellsForTiming_out),
"jetCellsForTiming");
160 template <
typename T>
164 desc.
add<
bool>(
"barrelJets",
false);
165 desc.
add<
bool>(
"endcapJets",
false);
166 desc.
add<
double>(
"ecalCellEnergyThresh", 0.5);
167 desc.
add<
double>(
"ecalCellTimeThresh", 12.5);
168 desc.
add<
double>(
"ecalCellTimeErrorThresh", 100.);
169 desc.
add<
double>(
"matchingRadius", 0.4);
175 #endif // HLTrigger_JetMET_plugins_HLTJetTimingProducer_h
HLTJetTimingProducer(const edm::ParameterSet &)
const double ecalCellEnergyThresh_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
const double ecalCellTimeThresh_
Sin< T >::type sin(const T &t)
void insert(const H &h, I begin, I end)
const double ecalCellTimeErrorThresh_
std::string defaultModuleLabel()
const edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > ecalRecHitsEEToken_
const edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > ecalRecHitsEBToken_
bool getData(T &iHolder) const
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
const edm::EDGetTokenT< std::vector< T > > jetInputToken_
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Abs< T >::type abs(const T &t)
bool get(ProductID const &oid, Handle< PROD > &result) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
This produces timing and associated ecal cell information for calo jets.
void produce(edm::Event &, const edm::EventSetup &) override
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ nCells
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const double matchingRadius2_
void jetTimeFromEcalCells(const T &, const edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit >> &, const CaloGeometry &, float &, float &, uint &)
Power< A, B >::type pow(const A &a, const B &b)