File indexing completed on 2024-04-06 12:24:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include <memory>
0027
0028
0029 #include "FWCore/Framework/interface/Frameworkfwd.h"
0030 #include "FWCore/Framework/interface/global/EDProducer.h"
0031
0032 #include "FWCore/Framework/interface/Event.h"
0033 #include "FWCore/Framework/interface/MakerMacros.h"
0034
0035 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0036 #include "FWCore/Utilities/interface/StreamID.h"
0037
0038 #include "FWCore/Framework/interface/ESHandle.h"
0039 #include "FWCore/Framework/interface/EventSetup.h"
0040 #include "FWCore/Utilities/interface/ESGetToken.h"
0041
0042
0043 #include "DataFormats/BTauReco/interface/PixelClusterTagInfo.h"
0044
0045
0046 #include "DataFormats/VertexReco/interface/Vertex.h"
0047 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0048
0049
0050 #include "DataFormats/JetReco/interface/PFJet.h"
0051 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0052
0053
0054 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0055 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0056 #include "DataFormats/Common/interface/Ref.h"
0057 #include "DataFormats/DetId/interface/DetId.h"
0058 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0059 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0060
0061
0062 #include "DataFormats/Math/interface/deltaR.h"
0063 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0064 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0065 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0066 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0067
0068 class PixelClusterTagInfoProducer : public edm::global::EDProducer<> {
0069 public:
0070 explicit PixelClusterTagInfoProducer(const edm::ParameterSet&);
0071 ~PixelClusterTagInfoProducer() override;
0072
0073 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0074
0075 private:
0076 void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0077
0078 const edm::ParameterSet iConfig;
0079
0080 const edm::EDGetTokenT<edm::View<reco::Jet> > m_jets;
0081 const edm::EDGetTokenT<reco::VertexCollection> m_vertices;
0082 const edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > m_pixelhit;
0083 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> m_geomToken;
0084 const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_topoToken;
0085 const bool m_isPhase1;
0086 const bool m_addFPIX;
0087 const int m_minADC;
0088 const float m_minJetPt;
0089 const float m_maxJetEta;
0090 const float m_hadronMass;
0091 const unsigned int m_nLayers;
0092 };
0093
0094 PixelClusterTagInfoProducer::PixelClusterTagInfoProducer(const edm::ParameterSet& iConfig)
0095 : m_jets(consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jets"))),
0096 m_vertices(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
0097 m_pixelhit(consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelhit"))),
0098 m_geomToken(esConsumes()),
0099 m_topoToken(esConsumes()),
0100 m_isPhase1(iConfig.getParameter<bool>("isPhase1")),
0101 m_addFPIX(iConfig.getParameter<bool>("addForward")),
0102 m_minADC(iConfig.getParameter<int>("minAdcCount")),
0103 m_minJetPt(iConfig.getParameter<double>("minJetPtCut")),
0104 m_maxJetEta(iConfig.getParameter<double>("maxJetEtaCut")),
0105 m_hadronMass(iConfig.getParameter<double>("hadronMass")),
0106 m_nLayers(m_isPhase1 ? 4 : 3) {
0107 produces<reco::PixelClusterTagInfoCollection>();
0108 }
0109
0110 PixelClusterTagInfoProducer::~PixelClusterTagInfoProducer() {}
0111
0112
0113 void PixelClusterTagInfoProducer::produce(edm::StreamID iID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0114
0115 auto collectionTagInfo = std::make_unique<reco::PixelClusterTagInfoCollection>();
0116
0117
0118 edm::Handle<edm::View<reco::Jet> > collectionJets;
0119 iEvent.getByToken(m_jets, collectionJets);
0120
0121
0122 edm::Handle<reco::VertexCollection> collectionPVs;
0123 iEvent.getByToken(m_vertices, collectionPVs);
0124
0125
0126 int nJets(0);
0127 for (auto jetIt = collectionJets->begin(); jetIt != collectionJets->end(); ++jetIt) {
0128 if (jetIt->pt() > m_minJetPt)
0129 nJets++;
0130 }
0131
0132
0133 if (collectionPVs->empty() || nJets <= 0) {
0134 iEvent.put(std::move(collectionTagInfo));
0135 return;
0136 }
0137
0138
0139 reco::VertexCollection::const_iterator firstPV = collectionPVs->begin();
0140 GlobalPoint v3(firstPV->x(), firstPV->y(), firstPV->z());
0141
0142
0143 edm::Handle<edmNew::DetSetVector<SiPixelCluster> > collectionHandle;
0144 iEvent.getByToken(m_pixelhit, collectionHandle);
0145 const edmNew::DetSetVector<SiPixelCluster>& collectionClusters(*collectionHandle);
0146
0147
0148 const TrackerGeometry& theTracker = iSetup.getData(m_geomToken);
0149
0150
0151 const TrackerTopology* tTopo = &iSetup.getData(m_topoToken);
0152
0153 std::vector<reco::PixelClusterProperties> clusters;
0154
0155
0156 for (auto const& detUnit : collectionClusters) {
0157 if (detUnit.empty())
0158 continue;
0159 DetId detId = DetId(detUnit.detId());
0160 if (detId.det() != DetId::Tracker)
0161 continue;
0162 if (!(detId.subdetId() == PixelSubdetector::PixelBarrel ||
0163 (m_addFPIX && detId.subdetId() == PixelSubdetector::PixelEndcap)))
0164 continue;
0165 unsigned int layer = tTopo->layer(detId);
0166 if (layer == 0 || layer > m_nLayers)
0167 continue;
0168
0169
0170 const auto* geomDet = theTracker.idToDet(detId);
0171 const auto* topol = &geomDet->topology();
0172
0173 for (auto const& clUnit : detUnit) {
0174 if (m_minADC > 0 and clUnit.charge() < m_minADC)
0175 continue;
0176
0177 LocalPoint lp = topol->localPosition(MeasurementPoint(clUnit.x(), clUnit.y()));
0178 GlobalPoint gp = geomDet->surface().toGlobal(lp);
0179
0180 reco::PixelClusterProperties cp = {gp.x(), gp.y(), gp.z(), clUnit.charge(), layer};
0181 clusters.push_back(cp);
0182 }
0183 }
0184
0185
0186 for (unsigned int j = 0, nj = collectionJets->size(); j < nj; j++) {
0187 if (collectionJets->at(j).pt() < m_minJetPt)
0188 continue;
0189
0190 float cR = m_hadronMass * 2. / (collectionJets->at(j).pt());
0191 edm::RefToBase<reco::Jet> jetRef = collectionJets->refAt(j);
0192 reco::PixelClusterData data(m_nLayers);
0193
0194 for (auto const& cluster : clusters) {
0195 GlobalPoint c3(cluster.x, cluster.y, cluster.z);
0196 float dR = reco::deltaR(c3 - v3, jetRef->momentum());
0197
0198 if (cluster.layer >= 1 && cluster.layer <= m_nLayers) {
0199 int idx(cluster.layer - 1);
0200 if (dR < 0.16) {
0201 data.r016[idx]++;
0202 if (dR < 0.10) {
0203 data.r010[idx]++;
0204 if (dR < 0.08) {
0205 data.r008[idx]++;
0206 if (dR < 0.06) {
0207 data.r006[idx]++;
0208 if (dR < 0.04)
0209 data.r004[idx]++;
0210 }
0211 }
0212 }
0213 }
0214 if (dR < cR) {
0215 data.rvar[idx]++;
0216 data.rvwt[idx] += cluster.charge;
0217 }
0218 }
0219 }
0220
0221 reco::PixelClusterTagInfo tagInfo(data, jetRef);
0222 collectionTagInfo->push_back(tagInfo);
0223 }
0224
0225
0226 iEvent.put(std::move(collectionTagInfo));
0227 }
0228
0229
0230 void PixelClusterTagInfoProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0231 edm::ParameterSetDescription desc;
0232 desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJetsCHS"));
0233 desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
0234 desc.add<edm::InputTag>("pixelhit", edm::InputTag("siPixelClusters"));
0235 desc.add<bool>("isPhase1", true);
0236 desc.add<bool>("addForward", true);
0237 desc.add<int>("minAdcCount", -1);
0238 desc.add<double>("minJetPtCut", 100.);
0239 desc.add<double>("maxJetEtaCut", 2.5);
0240 desc.add<double>("hadronMass", 12.);
0241 descriptions.add("pixelClusterTagInfos", desc);
0242 }
0243
0244
0245 DEFINE_FWK_MODULE(PixelClusterTagInfoProducer);