CMS 3D CMS Logo

EcalEBTrigPrimPhase2Producer.cc
Go to the documentation of this file.
11 //
19 
36 
40 
41 // We keep these lines for future posssible necessary additions
42 //#include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
43 //#include "CondFormats/DataRecord/interface/EcalTPGStripStatusRcd.h"
44 //#include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h"
46 #include <memory>
47 
48 // Class declaration
52 
54 public:
55  explicit EcalEBTrigPrimPhase2Producer(const edm::ParameterSet& conf);
56 
58 
59  void beginRun(const edm::Run& run, const edm::EventSetup& es) override;
60  void endRun(const edm::Run&, const edm::EventSetup&) override;
61  void produce(edm::Event& e, const edm::EventSetup& c) override;
63 
64 private:
65  std::unique_ptr<EcalEBPhase2TrigPrimAlgo> algo_;
66  bool debug_;
67  bool famos_;
68  int nEvent_;
73 
75 
79 
81 
84 
87 
90 
91  unsigned long long getRecords(edm::EventSetup const& setup);
92  unsigned long long cacheID_;
93 };
94 
96  : debug_(iConfig.getParameter<bool>("Debug")),
97  famos_(iConfig.getParameter<bool>("Famos")),
98  binOfMaximum_(iConfig.getParameter<int>("binOfMaximum")) {
99  tokenEBdigi_ = consumes<EBDigiCollectionPh2>(iConfig.getParameter<edm::InputTag>("barrelEcalDigis"));
100 
101  eTTmapToken_ = esConsumes<edm::Transition::BeginRun>();
102  theGeometryToken_ = esConsumes<edm::Transition::BeginRun>();
103 
105  esConsumes<EcalLiteDTUPedestalsMap, EcalLiteDTUPedestalsRcd, edm::Transition::BeginRun>();
107  esConsumes<EcalEBPhase2TPGPedestalsMap, EcalEBPhase2TPGPedestalsRcd, edm::Transition::BeginRun>();
108 
110  esConsumes<EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd, edm::Transition::BeginRun>();
112  esConsumes<EcalEBPhase2TPGLinearizationConst, EcalEBPhase2TPGLinearizationConstRcd, edm::Transition::BeginRun>();
114  esConsumes<EcalEBPhase2TPGAmplWeightIdMap, EcalEBPhase2TPGAmplWeightIdMapRcd, edm::Transition::BeginRun>();
116  esConsumes<EcalEBPhase2TPGTimeWeightIdMap, EcalEBPhase2TPGTimeWeightIdMapRcd, edm::Transition::BeginRun>();
117  theEcalTPGWeightGroup_Token_ = esConsumes<EcalTPGWeightGroup, EcalTPGWeightGroupRcd, edm::Transition::BeginRun>();
118 
119  //register your products
120  produces<EcalEBPhase2TrigPrimDigiCollection>();
121 }
122 
124  auto const& theGeometry = setup.getData(theGeometryToken_);
125  auto const& eTTmap = setup.getData(eTTmapToken_);
126 
127  algo_ = std::make_unique<EcalEBPhase2TrigPrimAlgo>(&eTTmap, &theGeometry, binOfMaximum_, debug_);
128 
129  // get a first version of the records
130  cacheID_ = this->getRecords(setup);
131 
132  nEvent_ = 0;
133 }
134 
137  desc.add<bool>("Debug", false);
138  desc.add<bool>("Famos", false);
139  desc.add<int>("BinOfMaximum", 6); // this needs to be at the same value used for the Phase2 LiteDTU digis !
140  desc.add<edm::InputTag>("barrelEcalDigis", edm::InputTag("simEcalUnsuppressedDigis"));
141 }
142 
144  // get parameter records for xtals
145  auto theEcalEBPhase2TPGLinearization_handle = setup.getHandle(theEcalEBPhase2TPGLinearization_Token_);
146  const EcalEBPhase2TPGLinearizationConst* ecaltpLin = theEcalEBPhase2TPGLinearization_handle.product();
147  //
148  edm::ESHandle<EcalLiteDTUPedestalsMap> theEcalTPGPedestals_handle = setup.getHandle(theEcalTPGPedestals_Token_);
149  const EcalLiteDTUPedestalsMap* ecaltpPed = theEcalTPGPedestals_handle.product();
150  //
151  // auto theEcalEBPhase2TPGPedestals_handle = setup.getHandle(theEcalEBPhase2TPGPedestals_Token_);
152  //const EcalEBPhase2TPGPedestalsMap* ebTPPedestals = theEcalEBPhase2TPGPedestals_handle.product();
153  //
154  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle = setup.getHandle(theEcalTPGCrystalStatus_Token_);
155  const EcalTPGCrystalStatus* ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
156  //
157  edm::ESHandle<EcalEBPhase2TPGAmplWeightIdMap> theEcalEBTPGAmplWeightIdMap_handle =
159  const EcalEBPhase2TPGAmplWeightIdMap* ecaltpgAmplWeightMap = theEcalEBTPGAmplWeightIdMap_handle.product();
160  //
161  edm::ESHandle<EcalEBPhase2TPGTimeWeightIdMap> theEcalEBTPGTimeWeightIdMap_handle =
163  const EcalEBPhase2TPGTimeWeightIdMap* ecaltpgTimeWeightMap = theEcalEBTPGTimeWeightIdMap_handle.product();
164  //
165  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWeightGroup_handle = setup.getHandle(theEcalTPGWeightGroup_Token_);
166  const EcalTPGWeightGroup* ecaltpgWeightGroup = theEcalTPGWeightGroup_handle.product();
167  // These commented out lines are for reminder for possible needed implementations
168  //edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle = setup.getHandle(theEcalTPGTowerStatus_Token_);
169  //const EcalTPGTowerStatus* ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
170  //
171  //edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle = setup.getHandle(theEcalTPGSpike_Token_);
172  //const EcalTPGSpike* ecaltpgSpike = theEcalTPGSpike_handle.product();
173 
175  algo_->setPointers(ecaltpPed, ecaltpLin, ecaltpgBadX, ecaltpgAmplWeightMap, ecaltpgTimeWeightMap, ecaltpgWeightGroup);
176 
177  return setup.get<EcalEBPhase2TPGLinearizationConstRcd>().cacheIdentifier();
178  // return setup.get<EcalLiteDTUPedestalsRcd>().cacheIdentifier();
179 }
180 
182 
184 
185 // ------------ method called to produce the data ------------
187  nEvent_++;
188 
189  // get input collections
190  edm::Handle<EBDigiCollectionPh2> barrelDigiHandle;
191 
192  if (!e.getByToken(tokenEBdigi_, barrelDigiHandle)) {
194  labelsForToken(tokenEBdigi_, labels);
195  edm::LogWarning("EcalTPG") << " Couldnt find Barrel digis " << labels.module << " and label "
196  << labels.productInstance << "!!!";
197  }
198  const auto* ebdigi = barrelDigiHandle.product();
199 
200  if (debug_)
201  LogDebug("EcalEBTrigPrimPhase2Producer")
202  << " EcalTPG"
203  << " =================> Treating event " << nEvent_ << ", Number of EB digis "
204  << barrelDigiHandle.product()->size() << std::endl;
205 
206  auto pOut = std::make_unique<EcalEBPhase2TrigPrimDigiCollection>();
207 
208  // invoke algorithm
209  algo_->run(ebdigi, *pOut);
210 
211  if (debug_) {
212  LogDebug("EcalEBTrigPrimPhase2Producer")
213  << "produce"
214  << " For Barrel " << pOut->size() << " TP Digis were produced" << std::endl;
215  }
216 
217  // debug prints if TP > 0. The number of TP with Et>0 is also used later for a LogInfo
218  int nonZeroTP = 0;
219  int nXstal = 0;
220  for (unsigned int i = 0; i < pOut->size(); ++i) {
221  nXstal++;
222  for (int isam = 0; isam < (*pOut)[i].size(); ++isam) {
223  if ((*pOut)[i][isam].encodedEt() > 0) {
224  nonZeroTP++;
225  if (debug_) {
226  LogDebug("EcalEBTrigPrimPhase2Producer")
227  << " For xStal n " << nXstal << " xTsal Id " << (((*pOut)[i])).id() << ", TP is " << (*pOut)[i]
228  << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() "
229  << (*pOut)[i][isam].encodedEt() << " (*pOut)[i][isam].time() " << (*pOut)[i][isam].time() << std::endl;
230  }
231  }
232  }
233  }
234 
235  edm::LogInfo("EcalEBTrigPrimPhase2Producer")
236  << "EcalTPG"
237  << "\n =================> For Barrel , " << pOut->size() << " TP Digis were produced (including zero ones)"
238  << " Non zero primitives were " << nonZeroTP << std::endl;
239 
240  // put result into the Event
241  e.put(std::move(pOut));
242 }
243 
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &)
unsigned long long getRecords(edm::EventSetup const &setup)
edm::ESGetToken< EcalEBPhase2TPGPedestalsMap, EcalEBPhase2TPGPedestalsRcd > theEcalEBPhase2TPGPedestals_Token_
T const * product() const
Definition: Handle.h:70
edm::ESGetToken< EcalLiteDTUPedestalsMap, EcalLiteDTUPedestalsRcd > theEcalTPGPedestals_Token_
edm::ESGetToken< EcalEBPhase2TPGAmplWeightIdMap, EcalEBPhase2TPGAmplWeightIdMapRcd > theEcalEBTPGAmplWeightIdMap_Token_
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmapToken_
T const * product() const
Definition: ESHandle.h:86
void produce(edm::Event &e, const edm::EventSetup &c) override
edm::EDGetTokenT< EBDigiCollectionPh2 > tokenEBdigi_
std::unique_ptr< EcalEBPhase2TrigPrimAlgo > algo_
edm::ESGetToken< EcalEBPhase2TPGTimeWeightIdMap, EcalEBPhase2TPGTimeWeightIdMapRcd > theEcalEBTPGTimeWeightIdMap_Token_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< EcalEBPhase2TPGLinearizationConst, EcalEBPhase2TPGLinearizationConstRcd > theEcalEBPhase2TPGLinearization_Token_
edm::ESGetToken< EcalTPGSpike, EcalTPGSpikeRcd > theEcalTPGSpike_Token_
Log< level::Info, false > LogInfo
edm::ESGetToken< EcalTPGTowerStatus, EcalTPGTowerStatusRcd > theEcalTPGTowerStatus_Token_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > theGeometryToken_
edm::ESGetToken< EcalTPGWeightGroup, EcalTPGWeightGroupRcd > theEcalTPGWeightGroup_Token_
edm::ESGetToken< EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd > theEcalTPGCrystalStatus_Token_
void endRun(const edm::Run &, const edm::EventSetup &) override
EcalEBTrigPrimPhase2Producer(const edm::ParameterSet &conf)
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
#define LogDebug(id)