CMS 3D CMS Logo

EcalZeroSuppressionProducer.cc
Go to the documentation of this file.
1 
3 
5  digiProducer_ = params.getParameter<std::string>("digiProducer");
6  EBdigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
7  EEdigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
8  EBZSdigiCollection_ = params.getParameter<std::string>("EBZSdigiCollection");
9  EEZSdigiCollection_ = params.getParameter<std::string>("EEZSdigiCollection");
10 
11  // initialize the default values for the thresholds in number of noise sigmas
12 
13  glbBarrelThreshold_ = params.getUntrackedParameter<double>("glbBarrelThreshold", 0.2);
14  glbEndcapThreshold_ = params.getUntrackedParameter<double>("glbEndcapThreshold", 0.4);
15 
16  produces<EBDigiCollection>(EBZSdigiCollection_);
17  produces<EEDigiCollection>(EEZSdigiCollection_);
18 
19  EB_token = consumes<EBDigiCollection>(edm::InputTag(digiProducer_));
20  EE_token = consumes<EEDigiCollection>(edm::InputTag(digiProducer_));
21  ;
22 }
23 
25 
27  // Get Inputs
28 
29  initCalibrations(eventSetup);
30 
33 
34  const EBDigiCollection *fullBarrelDigis = nullptr;
35  const EEDigiCollection *fullEndcapDigis = nullptr;
36 
37  event.getByToken(EB_token, pEBDigis);
38  if (pEBDigis.isValid()) {
39  fullBarrelDigis = pEBDigis.product(); // get a ptr to the produc
40  edm::LogInfo("ZeroSuppressionInfo") << "total # fullBarrelDigis: " << fullBarrelDigis->size();
41  } else {
42  edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EBdigiCollection_.c_str();
43  }
44 
45  event.getByToken(EE_token, pEEDigis);
46  if (pEEDigis.isValid()) {
47  fullEndcapDigis = pEEDigis.product(); // get a ptr to the product
48  edm::LogInfo("ZeroSuppressionInfo") << "total # fullEndcapDigis: " << fullEndcapDigis->size();
49  } else {
50  edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EEdigiCollection_.c_str();
51  }
52 
53  // collection of zero suppressed digis to put in the event
54 
55  std::unique_ptr<EBDigiCollection> gzsBarrelDigis(new EBDigiCollection());
56  std::unique_ptr<EEDigiCollection> gzsEndcapDigis(new EEDigiCollection());
57 
59 
60  // Barrel zero suppression
61 
62  if (fullBarrelDigis) {
63  for (EBDigiCollection::const_iterator digiItr = (*fullBarrelDigis).begin(); digiItr != (*fullBarrelDigis).end();
64  ++digiItr) {
65  bool isAccepted = theBarrelZeroSuppressor_.accept(*digiItr, glbBarrelThreshold_);
66  if (isAccepted) {
67  (*gzsBarrelDigis).push_back(digiItr->id(), digiItr->begin());
68  }
69  }
70  edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
71 
72  // std::vector<EBDataFrame> sortedDigisEB =
73  // sorter.sortedVector(*gzsBarrelDigis); LogDebug("ZeroSuppressionDump") <<
74  // "Top 10 EB digis"; for(int i = 0; i < std::min(10,(int)
75  // sortedDigisEB.size()); ++i)
76  // {
77  // LogDebug("ZeroSuppressionDump") << sortedDigisEB[i];
78  // }
79  }
80 
81  // Endcap zero suppression
82 
83  if (fullEndcapDigis) {
84  for (EEDigiCollection::const_iterator digiItr = (*fullEndcapDigis).begin(); digiItr != (*fullEndcapDigis).end();
85  ++digiItr) {
86  bool isAccepted = theEndcapZeroSuppressor_.accept(*digiItr, glbEndcapThreshold_);
87  if (isAccepted) {
88  (*gzsEndcapDigis).push_back(digiItr->id(), digiItr->begin());
89  }
90  }
91  edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
92 
93  // std::vector<EEDataFrame> sortedDigisEE =
94  // sorter.sortedVector(*gzsEndcapDigis);
95  // LogDebug("ZeroSuppressionDump") << "Top 10 EE digis";
96  // for(int i = 0; i < std::min(10,(int) sortedDigisEE.size()); ++i)
97  // {
98  // LogDebug("ZeroSuppressionDump") << sortedDigisEE[i];
99  // }
100  }
101  // Step D: Put outputs into event
102  event.put(std::move(gzsBarrelDigis), EBZSdigiCollection_);
103  event.put(std::move(gzsEndcapDigis), EEZSdigiCollection_);
104 }
105 
107  // Pedestals from event setup
108 
110  eventSetup.get<EcalPedestalsRcd>().get(dbPed);
111  const EcalPedestals *thePedestals = dbPed.product();
112 
115 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
void setPedestals(const EcalPedestals *pedestals)
can be fetched every event from the EventSetup
EcalZeroSuppressor< EBDataFrame > theBarrelZeroSuppressor_
bool accept(const C &frame, const double &threshold)
void initCalibrations(const edm::EventSetup &eventSetup)
edm::EDGetTokenT< EEDigiCollection > EE_token
EcalZeroSuppressionProducer(const edm::ParameterSet &params)
edm::EDGetTokenT< EBDigiCollection > EB_token
EcalZeroSuppressor< EEDataFrame > theEndcapZeroSuppressor_
bool isValid() const
Definition: HandleBase.h:74
T const * product() const
Definition: Handle.h:74
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1