File indexing completed on 2024-10-04 22:54:24
0001
0002
0003
0004
0005
0006
0007
0008 #include <string>
0009
0010
0011 #include "DataFormats/DetId/interface/DetId.h"
0012 #include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h"
0013 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015 #include "FWCore/Framework/interface/ESHandle.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Framework/interface/Frameworkfwd.h"
0019 #include "FWCore/Framework/interface/LuminosityBlock.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021 #include "FWCore/Framework/interface/global/EDProducer.h"
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0026 #include "FWCore/ServiceRegistry/interface/Service.h"
0027 #include "FWCore/Utilities/interface/EDGetToken.h"
0028 #include "TMath.h"
0029
0030
0031 class AlcaPCCEventProducer : public edm::global::EDProducer<> {
0032 public:
0033 explicit AlcaPCCEventProducer(const edm::ParameterSet&);
0034 ~AlcaPCCEventProducer() override = default;
0035 void produce(edm::StreamID id, edm::Event& e, edm::EventSetup const& c) const final;
0036 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0037
0038 private:
0039 const edm::InputTag pixelClusterLabel_;
0040 const std::string trigstring_;
0041 const bool savePerROCInfo_;
0042 const edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelToken_;
0043
0044 static constexpr int rowsperroc = 52;
0045 static constexpr int colsperroc = 80;
0046 static constexpr int nROCcolumns = 8;
0047 };
0048
0049
0050 AlcaPCCEventProducer::AlcaPCCEventProducer(const edm::ParameterSet& iConfig)
0051 : pixelClusterLabel_(iConfig.getParameter<edm::InputTag>("pixelClusterLabel")),
0052 trigstring_(iConfig.getUntrackedParameter<std::string>("trigstring", "alcaPCCEvent")),
0053 savePerROCInfo_(iConfig.getParameter<bool>("savePerROCInfo")),
0054 pixelToken_(consumes<edmNew::DetSetVector<SiPixelCluster> >(pixelClusterLabel_)) {
0055 produces<reco::PixelClusterCountsInEvent, edm::Transition::Event>(trigstring_);
0056 }
0057
0058
0059 void AlcaPCCEventProducer::produce(edm::StreamID id, edm::Event& iEvent, edm::EventSetup const& iSetup) const {
0060 std::unique_ptr<reco::PixelClusterCountsInEvent> thePCCob = std::make_unique<reco::PixelClusterCountsInEvent>();
0061 unsigned int bx = iEvent.bunchCrossing();
0062
0063
0064 edm::Handle<edmNew::DetSetVector<SiPixelCluster> > hClusterColl;
0065 iEvent.getByToken(pixelToken_, hClusterColl);
0066
0067 const edmNew::DetSetVector<SiPixelCluster>& clustColl = *(hClusterColl.product());
0068
0069
0070 for (auto const& mod : clustColl) {
0071 if (mod.empty()) {
0072 continue;
0073 }
0074 DetId detId = mod.id();
0075
0076 if (savePerROCInfo_) {
0077
0078 for (auto const& cluster : mod) {
0079 for (int i = 0; i < cluster.size(); ++i) {
0080 const auto pix = cluster.pixel(i);
0081
0082 if (pix.adc > 0) {
0083 int irow = pix.x / rowsperroc;
0084 int icol = pix.y / colsperroc;
0085
0086
0087
0088 int key = icol + irow * nROCcolumns;
0089 thePCCob->incrementRoc(((detId << 7) + key), 1);
0090 }
0091 }
0092 }
0093 }
0094
0095 int nCluster = mod.size();
0096 thePCCob->increment(detId(), nCluster);
0097 thePCCob->setbxID(bx);
0098 }
0099
0100 iEvent.put(std::move(thePCCob), std::string(trigstring_));
0101 }
0102
0103
0104 void AlcaPCCEventProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0105 edm::ParameterSetDescription evtParamDesc;
0106 evtParamDesc.add<edm::InputTag>("pixelClusterLabel", edm::InputTag("siPixelClustersForLumi"));
0107 evtParamDesc.addUntracked<std::string>("trigstring", "alcaPCCEvent");
0108 evtParamDesc.add<bool>("savePerROCInfo", true);
0109 descriptions.add("alcaPCCEventProducer", evtParamDesc);
0110 }
0111
0112 DEFINE_FWK_MODULE(AlcaPCCEventProducer);