CMS 3D CMS Logo

AlcaPCCProducer.cc
Go to the documentation of this file.
1 
11 // C++ standard
12 #include <string>
13 // CMS
17 
30 
31 #include "TMath.h"
32 //The class
33 class AlcaPCCProducer : public edm::one::EDProducer<edm::EndLuminosityBlockProducer,edm::one::WatchLuminosityBlocks>{
34  public:
35  explicit AlcaPCCProducer(const edm::ParameterSet&);
36  ~AlcaPCCProducer() override;
37 
38  private:
39  void beginLuminosityBlock (edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override ;
40  void endLuminosityBlock (edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override ;
41  void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) override ;
42  void produce (edm::Event& iEvent, const edm::EventSetup& iSetup) override ;
43 
46 
47  std::string trigstring_; //specifies the trigger Rand or ZeroBias
48  int countEvt_; //counter
49  int countLumi_; //counter
50 
51  std::unique_ptr<reco::PixelClusterCounts> thePCCob;
52 
53 };
54 
55 //--------------------------------------------------------------------------------------------------
57 {
58  fPixelClusterLabel = iConfig.getParameter<edm::ParameterSet>("AlcaPCCProducerParameters").getParameter<edm::InputTag>("pixelClusterLabel");
59  trigstring_ = iConfig.getParameter<edm::ParameterSet>("AlcaPCCProducerParameters").getUntrackedParameter<std::string>("trigstring","alcaPCC");
60 
61  countLumi_ = 0;
62 
63  produces<reco::PixelClusterCounts, edm::Transition::EndLuminosityBlock>(trigstring_);
64  pixelToken=consumes<edmNew::DetSetVector<SiPixelCluster> >(fPixelClusterLabel);
65 }
66 
67 //--------------------------------------------------------------------------------------------------
69 }
70 
71 //--------------------------------------------------------------------------------------------------
73  countEvt_++;
74 
75  unsigned int bx=iEvent.bunchCrossing();
76  //std::cout<<"The Bunch Crossing"<<bx<<std::endl;
77  thePCCob->eventCounter(bx);
78 
79  //Looping over the clusters and adding the counts up
81  iEvent.getByToken(pixelToken,hClusterColl);
82 
83  const edmNew::DetSetVector<SiPixelCluster>& clustColl = *(hClusterColl.product());
84  // ----------------------------------------------------------------------
85  // -- Clusters without tracks
86  for (auto const & mod: clustColl) {
87  if(mod.empty()) { continue; }
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 
111 //--------------------------------------------------------------------------------------------------
113 }
114 
115 //--------------------------------------------------------------------------------------------------
117 
118  //Saving the PCC object
120 
121 }
122 
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:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int bunchCrossing() const
Definition: EventBase.h:66
std::unique_ptr< reco::PixelClusterCounts > thePCCob
int iEvent
Definition: GenABIO.cc:230
~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:81
std::string trigstring_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelToken
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override