CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalZeroSuppressionProducer.cc
Go to the documentation of this file.
1 
3 
5  : glbBarrelThreshold_(params.getUntrackedParameter<double>("glbBarrelThreshold", 0.2)),
6  glbEndcapThreshold_(params.getUntrackedParameter<double>("glbEndcapThreshold", 0.4)),
7  digiProducer_(params.getParameter<std::string>("digiProducer")),
8  ebDigiCollection_(params.getParameter<std::string>("EBdigiCollection")),
9  eeDigiCollection_(params.getParameter<std::string>("EEdigiCollection")),
10  ebZSdigiCollection_(params.getParameter<std::string>("EBZSdigiCollection")),
11  eeZSdigiCollection_(params.getParameter<std::string>("EEZSdigiCollection")),
12  ebToken_(consumes<EBDigiCollection>(edm::InputTag(digiProducer_))),
13  eeToken_(consumes<EEDigiCollection>(edm::InputTag(digiProducer_))),
15  produces<EBDigiCollection>(ebZSdigiCollection_);
16  produces<EEDigiCollection>(eeZSdigiCollection_);
17 }
18 
20 
22  // Get Inputs
23 
24  initCalibrations(eventSetup);
25 
28 
29  const EBDigiCollection *fullBarrelDigis = nullptr;
30  const EEDigiCollection *fullEndcapDigis = nullptr;
31 
32  event.getByToken(ebToken_, pEBDigis);
33  if (pEBDigis.isValid()) {
34  fullBarrelDigis = pEBDigis.product(); // get a ptr to the produc
35  edm::LogInfo("ZeroSuppressionInfo") << "total # fullBarrelDigis: " << fullBarrelDigis->size();
36  } else {
37  edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << ebDigiCollection_.c_str();
38  }
39 
40  event.getByToken(eeToken_, pEEDigis);
41  if (pEEDigis.isValid()) {
42  fullEndcapDigis = pEEDigis.product(); // get a ptr to the product
43  edm::LogInfo("ZeroSuppressionInfo") << "total # fullEndcapDigis: " << fullEndcapDigis->size();
44  } else {
45  edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << eeDigiCollection_.c_str();
46  }
47 
48  // collection of zero suppressed digis to put in the event
49 
50  auto gzsBarrelDigis = std::make_unique<EBDigiCollection>();
51  auto gzsEndcapDigis = std::make_unique<EEDigiCollection>();
52 
54 
55  // Barrel zero suppression
56 
57  if (fullBarrelDigis) {
58  for (EBDigiCollection::const_iterator digiItr = (*fullBarrelDigis).begin(); digiItr != (*fullBarrelDigis).end();
59  ++digiItr) {
60  bool isAccepted = theBarrelZeroSuppressor_.accept(*digiItr, glbBarrelThreshold_);
61  if (isAccepted) {
62  (*gzsBarrelDigis).push_back(digiItr->id(), digiItr->begin());
63  }
64  }
65  edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
66 
67  // std::vector<EBDataFrame> sortedDigisEB =
68  // sorter.sortedVector(*gzsBarrelDigis); LogDebug("ZeroSuppressionDump") <<
69  // "Top 10 EB digis"; for(int i = 0; i < std::min(10,(int)
70  // sortedDigisEB.size()); ++i)
71  // {
72  // LogDebug("ZeroSuppressionDump") << sortedDigisEB[i];
73  // }
74  }
75 
76  // Endcap zero suppression
77 
78  if (fullEndcapDigis) {
79  for (EEDigiCollection::const_iterator digiItr = (*fullEndcapDigis).begin(); digiItr != (*fullEndcapDigis).end();
80  ++digiItr) {
81  bool isAccepted = theEndcapZeroSuppressor_.accept(*digiItr, glbEndcapThreshold_);
82  if (isAccepted) {
83  (*gzsEndcapDigis).push_back(digiItr->id(), digiItr->begin());
84  }
85  }
86  edm::LogInfo("ZeroSuppressionInfo") << "EB Digis: " << gzsBarrelDigis->size();
87 
88  // std::vector<EEDataFrame> sortedDigisEE =
89  // sorter.sortedVector(*gzsEndcapDigis);
90  // LogDebug("ZeroSuppressionDump") << "Top 10 EE digis";
91  // for(int i = 0; i < std::min(10,(int) sortedDigisEE.size()); ++i)
92  // {
93  // LogDebug("ZeroSuppressionDump") << sortedDigisEE[i];
94  // }
95  }
96  // Step D: Put outputs into event
97  event.put(std::move(gzsBarrelDigis), ebZSdigiCollection_);
98  event.put(std::move(gzsEndcapDigis), eeZSdigiCollection_);
99 }
100 
102  // Pedestals from event setup
103  const auto &thePedestals = eventSetup.getData(pedestalToken_);
104 
105  theBarrelZeroSuppressor_.setPedestals(&thePedestals);
106  theEndcapZeroSuppressor_.setPedestals(&thePedestals);
107 }
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
const edm::EDGetTokenT< EEDigiCollection > eeToken_
void setPedestals(const EcalPedestals *pedestals)
can be fetched every event from the EventSetup
Log< level::Error, false > LogError
bool getData(T &iHolder) const
Definition: EventSetup.h:128
EcalZeroSuppressor< EBDataFrame > theBarrelZeroSuppressor_
bool accept(const C &frame, const double &threshold)
void initCalibrations(const edm::EventSetup &eventSetup)
EcalZeroSuppressionProducer(const edm::ParameterSet &params)
def move
Definition: eostools.py:511
EcalZeroSuppressor< EEDataFrame > theEndcapZeroSuppressor_
bool isValid() const
Definition: HandleBase.h:70
Log< level::Info, false > LogInfo
T const * product() const
Definition: Handle.h:70
const edm::EDGetTokenT< EBDigiCollection > ebToken_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
const edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedestalToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283