38 #include "fastjet/ClusterSequence.hh"
39 #include "fastjet/JetDefinition.hh"
40 #include "fastjet/PseudoJet.hh"
44 template <
typename Trait>
66 template <
typename Trait>
69 inputToken_(consumes<typename Trait::
InputType>(iConfig.getParameter<edm::
InputTag>(
"recHitLabel"))),
70 rParam_(iConfig.getParameter<double>(
"rParam")),
71 nRechitMin_(iConfig.getParameter<int>(
"nRechitMin")),
72 nStationThres_(iConfig.getParameter<int>(
"nStationThres")) {
73 produces<RecHitClusterCollection>();
81 template <
typename Trait>
83 auto const& geo = iSetup.
getData(geometryToken_);
86 std::vector<fastjet::PseudoJet> fjInput;
89 fastjet::JetDefinition
jet_def(fastjet::cambridge_algorithm, rParam_);
94 for (
auto const& rechit :
rechits) {
95 LocalPoint recHitLocalPosition = rechit.localPosition();
96 auto detid = recHitTrait.detid(rechit);
97 auto thischamber = geo.chamber(detid);
99 GlobalPoint globalPosition = thischamber->toGlobal(recHitLocalPosition);
100 float x = globalPosition.
x();
101 float y = globalPosition.
y();
102 float z = globalPosition.
z();
104 inputs.push_back(ref);
105 fjInput.push_back(fastjet::PseudoJet(x, y, z, globalPosition.
mag()));
106 fjInput.back().set_user_index(recIt);
110 fastjet::ClusterSequence clus_seq(fjInput, jet_def);
114 std::vector<fastjet::PseudoJet> fjJets = clus_seq.inclusive_jets(ptmin);
116 auto clusters = std::make_unique<RecHitClusterCollection>();
117 for (
auto const& fjJet : fjJets) {
119 if (
int(fjJet.constituents().size()) < nRechitMin_)
123 for (
auto const& constituent : fjJet.constituents()) {
124 auto index = constituent.user_index();
125 if (
index >= 0 && static_cast<unsigned int>(
index) < inputs.size()) {
126 rechits.push_back(inputs[
index]);
133 float avgStation = 0.0;
134 std::map<int, int> station_count_map;
135 for (
auto const& rechit : rechits) {
136 station_count_map[recHitTrait.station(*rechit)]++;
139 std::map<int, int>::iterator it;
140 for (
auto const& [
station,
count] : station_count_map) {
141 if (
count >= nStationThres_) {
147 if (totStation != 0) {
148 avgStation = avgStation / totStation;
150 float invN = 1.f / rechits.size();
152 float jetX = fjJet.px() * invN;
153 float jetY = fjJet.py() * invN;
154 float jetZ = fjJet.pz() * invN;
157 std::sqrt(jetX * jetX + jetY * jetY), etaFromXYZ(jetX, jetY, jetZ), std::atan2(jetY, jetX));
164 template <
typename Trait>
167 desc.
add<
int>(
"nRechitMin", 50);
168 desc.
add<
double>(
"rParam", 0.4);
169 desc.
add<
int>(
"nStationThres", 10);
171 descriptions.
add(Trait::producerName(), desc);
195 for (
auto const& rechit : rechits) {
196 DetId geoid = rechit->geographicalId();
204 reco::MuonRecHitCluster cls(position, rechits.size(), nStation, avgStation, 0.0, 0.0, 0, 0, 0, 0, nMB1, nMB2);
205 clusters->emplace_back(cls);
228 float timeSpread = 0.0;
230 float time_strip = 0.0;
231 for (
auto const& rechit : rechits) {
232 CSCDetId cscdetid = rechit->cscDetId();
236 if (stationRing == 11)
238 if (stationRing == 12)
240 if (stationRing == 41)
242 if (stationRing == 42)
244 time += (rechit->tpeak() + rechit->wireTime());
245 time_strip += rechit->tpeak();
247 float invN = 1.f / rechits.size();
248 time = (time / 2.f) * invN;
249 time_strip = time_strip * invN;
252 for (
auto& rechit : rechits) {
253 timeSpread += (rechit->tpeak() - time_strip) * (rechit->tpeak() - time_strip);
255 timeSpread =
std::sqrt(timeSpread * invN);
259 position, rechits.size(), nStation, avgStation, time, timeSpread, nME11, nME12, nME41, nME42, 0, 0);
260 clusters->emplace_back(cls);
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< typename Trait::GeometryType, MuonGeometryRecord > geometryToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< reco::MuonRecHitCluster > RecHitClusterCollection
CSCDetId cscDetId() const
edm::RangeMap< DTLayerId, edm::OwnVector< DTRecHit1DPair > > DTRecHitCollection
edm::RangeMap< CSCDetId, edm::OwnVector< CSCRecHit2D > > CSCRecHit2DCollection
#define DEFINE_FWK_MODULE(type)
static std::string producerName()
Trait::RecHitRef RechitRef
static DTChamberId detid(const DTRecHit1DPair &dtRechit)
static int station(const CSCRecHit2D &cscRechit)
static CSCDetId detid(const CSCRecHit2D &cscRechit)
ROOT::Math::DisplacementVector3D< ROOT::Math::CylindricalEta3D< float > > RhoEtaPhiVectorF
spatial vector with cylindrical internal representation using pseudorapidity
static void emplace_back(RecHitClusterCollection *clusters, math::RhoEtaPhiVectorF const &position, int nStation, float avgStation, RecHitRefVector const &rechits)
bool getData(T &iHolder) const
virtual DetId geographicalId() const
Return the detId of the Det (a DTLayer).
static std::string producerName()
RechitClusterProducerT(const edm::ParameterSet &)
~RechitClusterProducerT() override=default
static std::string recHitLabel()
bool get(ProductID const &oid, Handle< PROD > &result) const
std::vector< reco::MuonRecHitCluster > RecHitClusterCollection
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Trait::RecHitRefVector RecHitRefVector
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static int position[264][3]
edm::EDGetTokenT< typename Trait::InputType > inputToken_
int station() const
Return the station number.
static void emplace_back(RecHitClusterCollection *clusters, math::RhoEtaPhiVectorF const &position, int nStation, float avgStation, RecHitRefVector const &rechits)
static int station(const DTRecHit1DPair &dtRechit)
static std::string recHitLabel()