Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:35:02

0001 /**_________________________________________________________________
0002 class:   AlcaPCCProducer.cc
0003 
0004 
0005 
0006 authors:Sam Higginbotham (shigginb@cern.ch) and Chris Palmer (capalmer@cern.ch) 
0007 
0008 ________________________________________________________________**/
0009 
0010 // C++ standard
0011 #include <string>
0012 // CMS
0013 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0014 #include "DataFormats/Luminosity/interface/PixelClusterCounts.h"
0015 #include "DataFormats/DetId/interface/DetId.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 #include "FWCore/Framework/interface/ConsumesCollector.h"
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/one/EDProducer.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/Utilities/interface/EDGetToken.h"
0024 #include "FWCore/Framework/interface/EventSetup.h"
0025 #include "FWCore/Framework/interface/LuminosityBlock.h"
0026 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0027 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0028 //The class
0029 class AlcaPCCProducer
0030     : public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<reco::PixelClusterCounts>> {
0031 public:
0032   explicit AlcaPCCProducer(const edm::ParameterSet&);
0033 
0034 private:
0035   std::shared_ptr<reco::PixelClusterCounts> globalBeginLuminosityBlock(edm::LuminosityBlock const& lumiSeg,
0036                                                                        edm::EventSetup const& iSetup) const final;
0037   void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) final;
0038   void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final {}
0039   void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) final;
0040 
0041   edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster>> pixelToken_;
0042   edm::EDPutTokenT<reco::PixelClusterCounts> putToken_;
0043 };
0044 
0045 //--------------------------------------------------------------------------------------------------
0046 AlcaPCCProducer::AlcaPCCProducer(const edm::ParameterSet& iConfig)
0047     : pixelToken_(consumes(iConfig.getParameter<edm::InputTag>("pixelClusterLabel"))),
0048       //specifies the trigger Rand or ZeroBias
0049       putToken_(produces<reco::PixelClusterCounts, edm::Transition::EndLuminosityBlock>(
0050           iConfig.getUntrackedParameter<std::string>("trigstring", "alcaPCC"))) {}
0051 
0052 //--------------------------------------------------------------------------------------------------
0053 void AlcaPCCProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0054   unsigned int bx = iEvent.bunchCrossing();
0055   //std::cout<<"The Bunch Crossing"<<bx<<std::endl;
0056   auto* pccOb = luminosityBlockCache(iEvent.getLuminosityBlock().index());
0057   pccOb->eventCounter(bx);
0058 
0059   //Looping over the clusters and adding the counts up
0060   const edmNew::DetSetVector<SiPixelCluster>& clustColl = iEvent.get(pixelToken_);
0061   // ----------------------------------------------------------------------
0062   // -- Clusters without tracks
0063   for (auto const& mod : clustColl) {
0064     if (mod.empty()) {
0065       continue;
0066     }
0067     DetId detId = mod.id();
0068 
0069     //--The following will be used when we make a theshold for the clusters.
0070     //--Keeping this for features that may be implemented later.
0071     // -- clusters on this det
0072     //edmNew::DetSet<SiPixelCluster>::const_iterator  di;
0073     //int nClusterCount=0;
0074     //for (di = mod.begin(); di != mod.end(); ++di) {
0075     //    nClusterCount++;
0076     //}
0077     int nCluster = mod.size();
0078     pccOb->increment(detId(), bx, nCluster);
0079   }
0080 }
0081 
0082 //--------------------------------------------------------------------------------------------------
0083 std::shared_ptr<reco::PixelClusterCounts> AlcaPCCProducer::globalBeginLuminosityBlock(
0084     edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) const {
0085   //New PCC object at the beginning of each lumi section
0086   return std::make_shared<reco::PixelClusterCounts>();
0087 }
0088 
0089 //--------------------------------------------------------------------------------------------------
0090 void AlcaPCCProducer::endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) {
0091   //Saving the PCC object
0092   lumiSeg.emplace(putToken_, std::move(*luminosityBlockCache(lumiSeg.index())));
0093 }
0094 
0095 DEFINE_FWK_MODULE(AlcaPCCProducer);