Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-23 03:12:44

0001 /**_________________________________________________________________
0002 class:   AlcaPCCEventProducer.cc
0003 
0004 
0005 
0006 authors: Sam Higginbotham (shigginb@cern.ch), Chris Palmer (capalmer@cern.ch), Attila Radl (attila.radl@cern.ch)
0007 
0008 ________________________________________________________________**/
0009 
0010 // C++ standard
0011 #include <string>
0012 
0013 // CMS
0014 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019 #include "FWCore/Framework/interface/ConsumesCollector.h"
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/stream/EDProducer.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "FWCore/Utilities/interface/EDGetToken.h"
0025 #include "FWCore/ServiceRegistry/interface/Service.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "FWCore/Framework/interface/EventSetup.h"
0028 #include "FWCore/Framework/interface/LuminosityBlock.h"
0029 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0031 #include "TMath.h"
0032 
0033 //The class
0034 class AlcaPCCEventProducer : public edm::stream::EDProducer<> {
0035 public:
0036   explicit AlcaPCCEventProducer(const edm::ParameterSet&);
0037   ~AlcaPCCEventProducer() override;
0038   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0039 
0040 private:
0041   void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0042 
0043   edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelToken;
0044   edm::InputTag fPixelClusterLabel;
0045 
0046   std::string trigstring_;  //specifies the trigger Rand or ZeroBias
0047   int countEvt_;            //counter
0048   int countLumi_;           //counter
0049 
0050   const int rowsperroc = 52;
0051   const int colsperroc = 80;
0052   const int nROCcolumns = 8;
0053 
0054   std::unique_ptr<reco::PixelClusterCountsInEvent> thePCCob;
0055 };
0056 
0057 //--------------------------------------------------------------------------------------------------
0058 AlcaPCCEventProducer::AlcaPCCEventProducer(const edm::ParameterSet& iConfig) {
0059   fPixelClusterLabel = iConfig.getParameter<edm::InputTag>("pixelClusterLabel");
0060   trigstring_ = iConfig.getUntrackedParameter<std::string>("trigstring", "alcaPCCEvent");
0061   produces<reco::PixelClusterCountsInEvent, edm::Transition::Event>(trigstring_);
0062   pixelToken = consumes<edmNew::DetSetVector<SiPixelCluster> >(fPixelClusterLabel);
0063 }
0064 
0065 //--------------------------------------------------------------------------------------------------
0066 AlcaPCCEventProducer::~AlcaPCCEventProducer() {}
0067 
0068 //--------------------------------------------------------------------------------------------------
0069 void AlcaPCCEventProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0070   countEvt_++;
0071   thePCCob = std::make_unique<reco::PixelClusterCountsInEvent>();
0072 
0073   unsigned int bx = iEvent.bunchCrossing();
0074 
0075   //Looping over the clusters and adding the counts up
0076   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > hClusterColl;
0077   iEvent.getByToken(pixelToken, hClusterColl);
0078 
0079   const edmNew::DetSetVector<SiPixelCluster>& clustColl = *(hClusterColl.product());
0080   // ----------------------------------------------------------------------
0081   // -- Clusters without tracks
0082   for (auto const& mod : clustColl) {
0083     if (mod.empty()) {
0084       continue;
0085     }
0086     DetId detId = mod.id();
0087 
0088     // Iterate over Clusters in module to fill per ROC histogram
0089     for (auto const& cluster : mod) {
0090       for (int i = 0; i < cluster.size(); ++i) {
0091         const auto pix = cluster.pixel(i);
0092         // TODO: add roc threshold to config if(di.adc > fRocThreshold_) {
0093         if (pix.adc > 0) {
0094           int irow = pix.x / rowsperroc; /* constant column direction is along x-axis */
0095           int icol = pix.y / colsperroc; /* constant row direction is along y-axis */
0096           /* generate the folling roc index that is going to map with ROC id as
0097           8  9  10 11 12 13 14 15
0098           0  1  2  3  4  5  6  7 */
0099           int key = icol + irow * nROCcolumns;
0100           thePCCob->incrementRoc(((detId << 7) + key), 1);
0101         }
0102       }
0103     }
0104 
0105     int nCluster = mod.size();
0106     thePCCob->increment(detId(), nCluster);
0107     thePCCob->setbxID(bx);
0108   }
0109 
0110   iEvent.put(std::move(thePCCob), std::string(trigstring_));
0111 }
0112 
0113 //--------------------------------------------------------------------------------------------------
0114 void AlcaPCCEventProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0115   edm::ParameterSetDescription evtParamDesc;
0116   evtParamDesc.add<edm::InputTag>("pixelClusterLabel", edm::InputTag("siPixelClustersForLumi"));
0117   evtParamDesc.addUntracked<std::string>("trigstring", "alcaPCCEvent");
0118   descriptions.add("alcaPCCEventProducer", evtParamDesc);
0119 }
0120 
0121 DEFINE_FWK_MODULE(AlcaPCCEventProducer);