CMS 3D CMS Logo

AlcaPCCProducer.cc
Go to the documentation of this file.
1 
10 // C++ standard
11 #include <string>
12 // CMS
16 
29 
30 #include "TMath.h"
31 //The class
32 class AlcaPCCProducer : public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks> {
33 public:
34  explicit AlcaPCCProducer(const edm::ParameterSet&);
35  ~AlcaPCCProducer() override;
36 
37 private:
38  void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override;
39  void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override;
40  void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) override;
41  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
42 
45 
46  std::string trigstring_; //specifies the trigger Rand or ZeroBias
47  int countEvt_; //counter
48  int countLumi_; //counter
49 
50  std::unique_ptr<reco::PixelClusterCounts> thePCCob;
51 };
52 
53 //--------------------------------------------------------------------------------------------------
55  fPixelClusterLabel = iConfig.getParameter<edm::ParameterSet>("AlcaPCCProducerParameters")
56  .getParameter<edm::InputTag>("pixelClusterLabel");
57  trigstring_ = iConfig.getParameter<edm::ParameterSet>("AlcaPCCProducerParameters")
58  .getUntrackedParameter<std::string>("trigstring", "alcaPCC");
59 
60  countLumi_ = 0;
61 
62  produces<reco::PixelClusterCounts, edm::Transition::EndLuminosityBlock>(trigstring_);
63  pixelToken = consumes<edmNew::DetSetVector<SiPixelCluster> >(fPixelClusterLabel);
64 }
65 
66 //--------------------------------------------------------------------------------------------------
68 
69 //--------------------------------------------------------------------------------------------------
71  countEvt_++;
72 
73  unsigned int bx = iEvent.bunchCrossing();
74  //std::cout<<"The Bunch Crossing"<<bx<<std::endl;
75  thePCCob->eventCounter(bx);
76 
77  //Looping over the clusters and adding the counts up
79  iEvent.getByToken(pixelToken, hClusterColl);
80 
81  const edmNew::DetSetVector<SiPixelCluster>& clustColl = *(hClusterColl.product());
82  // ----------------------------------------------------------------------
83  // -- Clusters without tracks
84  for (auto const& mod : clustColl) {
85  if (mod.empty()) {
86  continue;
87  }
88  DetId detId = mod.id();
89 
90  //--The following will be used when we make a theshold for the clusters.
91  //--Keeping this for features that may be implemented later.
92  // -- clusters on this det
93  //edmNew::DetSet<SiPixelCluster>::const_iterator di;
94  //int nClusterCount=0;
95  //for (di = mod.begin(); di != mod.end(); ++di) {
96  // nClusterCount++;
97  //}
98  int nCluster = mod.size();
99  thePCCob->increment(detId(), bx, nCluster);
100  }
101 }
102 
103 //--------------------------------------------------------------------------------------------------
105  //New PCC object at the beginning of each lumi section
106  thePCCob = std::make_unique<reco::PixelClusterCounts>();
107  countLumi_++;
108 }
109 
110 //--------------------------------------------------------------------------------------------------
112 
113 //--------------------------------------------------------------------------------------------------
115  //Saving the PCC object
117 }
118 
edm::InputTag fPixelClusterLabel
T getParameter(std::string const &) const
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int bunchCrossing() const
Definition: EventBase.h:64
std::unique_ptr< reco::PixelClusterCounts > thePCCob
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~AlcaPCCProducer() override
void put(std::unique_ptr< PROD > product)
Put a new product.
AlcaPCCProducer(const edm::ParameterSet &)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) override
void endLuminosityBlockProduce(edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup) override
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:74
std::string trigstring_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelToken
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override