CMS 3D CMS Logo

EcalTrigPrimProducer.cc
Go to the documentation of this file.
1 
18 
24 
29 
60 
61 #include "EcalTrigPrimProducer.h"
62 
63 #include <memory>
64 
66 
68  : barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
69  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
70  debug_(iConfig.getParameter<bool>("Debug")),
71  famos_(iConfig.getParameter<bool>("Famos")),
72  tokenEB_(consumes<EBDigiCollection>(
73  edm::InputTag(iConfig.getParameter<std::string>("Label"), iConfig.getParameter<std::string>("InstanceEB")))),
74  tokenEE_(consumes<EEDigiCollection>(
75  edm::InputTag(iConfig.getParameter<std::string>("Label"), iConfig.getParameter<std::string>("InstanceEE")))),
76  binOfMaximum_(iConfig.getParameter<int>("binOfMaximum")),
77  fillBinOfMaximumFromHistory_(-1 == binOfMaximum_) {
78  // register your products
79  produces<EcalTrigPrimDigiCollection>();
80  if (tcpFormat_)
81  produces<EcalTrigPrimDigiCollection>("formatTCP");
82 }
83 
84 static int findBinOfMaximum(bool iFillFromHistory, int iPSetValue, edm::ProcessHistory const &iHistory) {
85  // get binOfMax
86  // try first in cfg, then in ProcessHistory
87  // =6 is default (1-10 possible values)
88  int binOfMaximum = 0; // starts at 1!
89  if (not iFillFromHistory) {
90  binOfMaximum = iPSetValue;
91  edm::LogInfo("EcalTPG") << "EcalTrigPrimProducer is using binOfMaximum found in cfg file : " << binOfMaximum;
92  }
93 
94  // search backwards in history looking for the particular module
95  const std::string kModuleName{"ecalUnsuppressedDigis"};
96  for (auto it = iHistory.rbegin(), itEnd = iHistory.rend(); it != itEnd; ++it) {
97  auto const &topLevelPSet = getParameterSet(it->parameterSetID());
98  if (topLevelPSet.exists(kModuleName)) {
99  int psetBinOfMax = topLevelPSet.getParameter<edm::ParameterSet>(kModuleName).getParameter<int>("binOfMaximum");
100 
101  if (not iFillFromHistory) {
102  if (psetBinOfMax != binOfMaximum)
103  edm::LogWarning("EcalTPG") << "binofMaximum given in configuration (=" << binOfMaximum
104  << ") is different from the one found in ProductRegistration(=" << psetBinOfMax
105  << ")!!!";
106  } else {
107  binOfMaximum = psetBinOfMax;
108  edm::LogInfo("EcalTPG") << "EcalTrigPrimProducer is using binOfMaximum "
109  "found in ProductRegistry : "
110  << binOfMaximum;
111  }
112  break;
113  }
114  }
115  if (binOfMaximum == 0) {
116  binOfMaximum = 6;
117  edm::LogWarning("EcalTPG") << "Could not find product registry of EBDigiCollection (label "
118  "ecalUnsuppressedDigis), had to set the following parameters by "
119  "Hand: binOfMaximum="
120  << binOfMaximum;
121  }
122  return binOfMaximum;
123 }
124 
126  // ProcessHistory is guaranteed to be constant for an entire Run
128 
129  algo_ = std::make_unique<EcalTrigPrimFunctionalAlgo>(setup, binOfMaximum_, tcpFormat_, barrelOnly_, debug_, famos_);
130 
131  // get a first version of the records
132  cacheID_ = this->getRecords(setup);
133 }
134 
136 
138  // get Eventsetup records
139 
140  // for EcalFenixStrip...
141  // get parameter records for xtals
142  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
143  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
144  const EcalTPGLinearizationConst *ecaltpLin = theEcalTPGLinearization_handle.product();
145  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
146  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
147  const EcalTPGPedestals *ecaltpPed = theEcalTPGPedestals_handle.product();
148  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
149  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
150  const EcalTPGCrystalStatus *ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
151 
152  // for strips
153  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
154  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
155  const EcalTPGSlidingWindow *ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
156  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
157  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
158  const EcalTPGWeightIdMap *ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
159  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
160  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
161  const EcalTPGWeightGroup *ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
162  edm::ESHandle<EcalTPGFineGrainStripEE> theEcalTPGFineGrainStripEE_handle;
163  setup.get<EcalTPGFineGrainStripEERcd>().get(theEcalTPGFineGrainStripEE_handle);
164  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product();
165  edm::ESHandle<EcalTPGStripStatus> theEcalTPGStripStatus_handle;
166  setup.get<EcalTPGStripStatusRcd>().get(theEcalTPGStripStatus_handle);
167  const EcalTPGStripStatus *ecaltpgStripStatus = theEcalTPGStripStatus_handle.product();
168 
169  algo_->setPointers(ecaltpLin,
170  ecaltpPed,
171  ecaltpgSlidW,
172  ecaltpgWeightMap,
173  ecaltpgWeightGroup,
174  ecaltpgFgStripEE,
175  ecaltpgBadX,
176  ecaltpgStripStatus);
177 
178  // .. and for EcalFenixTcp
179  // get parameter records for towers
180  edm::ESHandle<EcalTPGFineGrainEBGroup> theEcalTPGFineGrainEBGroup_handle;
181  setup.get<EcalTPGFineGrainEBGroupRcd>().get(theEcalTPGFineGrainEBGroup_handle);
182  const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product();
183 
184  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
185  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
186  const EcalTPGLutGroup *ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
187 
188  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
189  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
190  const EcalTPGLutIdMap *ecaltpgLut = theEcalTPGLutIdMap_handle.product();
191 
192  edm::ESHandle<EcalTPGFineGrainEBIdMap> theEcalTPGFineGrainEBIdMap_handle;
193  setup.get<EcalTPGFineGrainEBIdMapRcd>().get(theEcalTPGFineGrainEBIdMap_handle);
194  const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product();
195 
196  edm::ESHandle<EcalTPGFineGrainTowerEE> theEcalTPGFineGrainTowerEE_handle;
197  setup.get<EcalTPGFineGrainTowerEERcd>().get(theEcalTPGFineGrainTowerEE_handle);
198  const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product();
199 
200  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
201  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
202  const EcalTPGTowerStatus *ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
203 
204  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle;
205  setup.get<EcalTPGSpikeRcd>().get(theEcalTPGSpike_handle);
206  const EcalTPGSpike *ecaltpgSpike = theEcalTPGSpike_handle.product();
207 
208  algo_->setPointers2(ecaltpgFgEBGroup,
209  ecaltpgLutGroup,
210  ecaltpgLut,
211  ecaltpgFineGrainEB,
212  ecaltpgFineGrainTowerEE,
213  ecaltpgBadTT,
214  ecaltpgSpike);
215 
216  // we will suppose that everything is to be updated if the
217  // EcalTPGLinearizationConstRcd has changed
218  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
219 }
220 
222 
223 // ------------ method called to produce the data ------------
225  // update constants if necessary
227  cacheID_ = this->getRecords(iSetup);
228 
229  // get input collections
230 
233  bool barrel = true;
234  bool endcap = true;
235  if (barrelOnly_)
236  endcap = false;
237 
238  if (!e.getByToken(tokenEB_, ebDigis)) {
239  barrel = false;
241  labelsForToken(tokenEB_, labels);
242  edm::LogWarning("EcalTPG") << " Couldnt find Barrel dataframes with producer " << labels.module << " and label "
243  << labels.productInstance << "!!!";
244  }
245  if (!barrelOnly_) {
246  if (!e.getByToken(tokenEE_, eeDigis)) {
247  endcap = false;
249  labelsForToken(tokenEE_, labels);
250  edm::LogWarning("EcalTPG") << " Couldnt find Endcap dataframes with producer " << labels.module << " and label "
251  << labels.productInstance << "!!!";
252  }
253  }
254  if (!barrel && !endcap) {
256  labelsForToken(tokenEB_, labels);
257  throw cms::Exception(" ProductNotFound") << "No EBDataFrames(EEDataFrames) with producer " << labels.module
258  << " and label " << labels.productInstance << " found in input!!\n";
259  }
260 
261  if (!barrelOnly_)
262  LogDebug("EcalTPG") << " =================> Treating event " << e.id() << ", Number of EBDataFrames "
263  << ebDigis.product()->size() << ", Number of EEDataFrames " << eeDigis.product()->size();
264  else
265  LogDebug("EcalTPG") << " =================> Treating event " << e.id() << ", Number of EBDataFrames "
266  << ebDigis.product()->size();
267 
268  auto pOut = std::make_unique<EcalTrigPrimDigiCollection>();
269  auto pOutTcp = std::make_unique<EcalTrigPrimDigiCollection>();
270 
271  // invoke algorithm
272 
273  const EBDigiCollection *ebdc = nullptr;
274  const EEDigiCollection *eedc = nullptr;
275  if (barrel) {
276  ebdc = ebDigis.product();
277  algo_->run(iSetup, ebdc, *pOut, *pOutTcp);
278  }
279 
280  if (endcap) {
281  eedc = eeDigis.product();
282  algo_->run(iSetup, eedc, *pOut, *pOutTcp);
283  }
284 
285  edm::LogInfo("produce") << "For Barrel + Endcap, " << pOut->size() << " TP Digis were produced";
286 
287  // debug prints if TP >0
288 
289  for (unsigned int i = 0; i < pOut->size(); ++i) {
290  bool print = false;
291  for (int isam = 0; isam < (*pOut)[i].size(); ++isam) {
292  if ((*pOut)[i][isam].raw())
293  print = true;
294  }
295  if (print)
296  LogDebug("EcalTPG") << " For tower " << (((*pOut)[i])).id() << ", TP is " << (*pOut)[i];
297  }
298  if (barrelOnly_)
299  LogDebug("EcalTPG") << "\n =================> For Barrel , " << pOut->size()
300  << " TP Digis were produced (including zero ones)";
301  else
302  LogDebug("EcalTPG") << "\n =================> For Barrel + Endcap, " << pOut->size()
303  << " TP Digis were produced (including zero ones)";
304 
305  // put result into the Event
306 
307  e.put(std::move(pOut));
308  if (tcpFormat_)
309  e.put(std::move(pOutTcp), "formatTCP");
310 }
311 
314  desc.add<bool>("BarrelOnly", false);
315  desc.add<bool>("TcpOutput", false);
316  desc.add<bool>("Debug", false);
317  desc.add<bool>("Famos", false);
318  desc.add<std::string>("Label", "simEcalUnsuppressedDigis");
319  desc.add<std::string>("InstanceEB", "");
320  desc.add<std::string>("InstanceEE", "");
321  const std::string kComment(
322  "A value of -1 will make the module lookup the value of 'binOfMaximum' "
323  "from the module 'ecalUnsuppressedDigis' from the process history. "
324  "Allowed values are -1 and from 1-10.");
325  // The code before the existence of fillDescriptions did something special if
326  // 'binOfMaximum' was missing. This replicates that behavior.
327  desc.add<int>("binOfMaximum", -1)->setComment(kComment);
328  descriptions.addDefault(desc);
329 }
EcalTrigPrimProducer::tokenEE_
edm::EDGetTokenT< EEDigiCollection > tokenEE_
Definition: EcalTrigPrimProducer.h:54
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalTPGLutGroupRcd.h
EcalTrigPrimProducer::barrelOnly_
bool barrelOnly_
Definition: EcalTrigPrimProducer.h:49
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::ProcessHistory::rend
const_reverse_iterator rend() const
Definition: ProcessHistory.h:66
mps_fire.i
i
Definition: mps_fire.py:428
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
MessageLogger.h
findBinOfMaximum
static int findBinOfMaximum(bool iFillFromHistory, int iPSetValue, edm::ProcessHistory const &iHistory)
Definition: EcalTrigPrimProducer.cc:84
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalTPGFineGrainTowerEERcd
Definition: EcalTPGFineGrainTowerEERcd.h:5
EcalTPGStripStatusRcd.h
EcalTPGLinearizationConstRcd.h
edm::Run
Definition: Run.h:45
EcalTPGSpikeRcd.h
EcalTPGSpike
Definition: EcalTPGSpike.h:9
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalTPGFineGrainStripEE
Definition: EcalTPGFineGrainStripEE.h:9
edm::ProcessHistory::rbegin
const_reverse_iterator rbegin() const
Definition: ProcessHistory.h:65
EcalTPGCrystalStatusRcd
Definition: EcalTPGCrystalStatusRcd.h:5
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
EcalTPGFineGrainEBIdMap.h
EcalTPGFineGrainEBIdMap
Definition: EcalTPGFineGrainEBIdMap.h:10
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EcalTPGPedestalsRcd
Definition: EcalTPGPedestalsRcd.h:5
EcalTrigPrimProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EcalTrigPrimProducer.cc:312
EcalTrigPrimProducer::tokenEB_
edm::EDGetTokenT< EBDigiCollection > tokenEB_
Definition: EcalTrigPrimProducer.h:53
EcalTPGCrystalStatusRcd.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:13
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::Handle< EBDigiCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalTPGFineGrainStripEERcd
Definition: EcalTPGFineGrainStripEERcd.h:5
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalTPGFineGrainTowerEE.h
EcalTPGFineGrainStripEE.h
EcalTrigPrimProducer::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: EcalTrigPrimProducer.cc:125
EcalTPGStripStatusRcd
Definition: EcalTPGStripStatusRcd.h:5
MakerMacros.h
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
EcalTPGFineGrainTowerEE
Definition: EcalTPGFineGrainTowerEE.h:9
EcalTPGSpike.h
EcalTrigPrimProducer::algo_
std::unique_ptr< EcalTrigPrimFunctionalAlgo > algo_
Definition: EcalTrigPrimProducer.h:48
EcalTPGLutIdMap.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
EcalTrigPrimProducer::cacheID_
unsigned long long cacheID_
Definition: EcalTrigPrimProducer.h:61
EcalTrigPrimProducer::debug_
bool debug_
Definition: EcalTrigPrimProducer.h:51
Provenance.h
EcalDigiCollections.h
ProductID.h
edm::ESHandle
Definition: DTSurvey.h:22
EcalTPGSpikeRcd
Definition: EcalTPGSpikeRcd.h:5
EcalTPGFineGrainEBGroupRcd
Definition: EcalTPGFineGrainEBGroupRcd.h:5
EcalTPGWeightIdMapRcd.h
EcalTrigPrimProducer::tcpFormat_
bool tcpFormat_
Definition: EcalTrigPrimProducer.h:50
EcalTPGSlidingWindowRcd.h
EcalTrigPrimProducer::fillBinOfMaximumFromHistory_
bool fillBinOfMaximumFromHistory_
Definition: EcalTrigPrimProducer.h:57
EcalTPGFineGrainEBGroupRcd.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalTPGWeightGroup.h
EcalTrigPrimProducer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: EcalTrigPrimProducer.cc:135
EcalTPGLutGroup.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EcalTPGLinearizationConst.h
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
EcalTPGFineGrainEBGroup
Definition: EcalTPGFineGrainEBGroup.h:13
EBDigiCollection
Definition: EcalDigiCollections.h:56
EEDigiCollection
Definition: EcalDigiCollections.h:69
EcalTPGFineGrainEBIdMapRcd
Definition: EcalTPGFineGrainEBIdMapRcd.h:5
topLevelPSet
static std::string topLevelPSet(std::string const &iName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
Definition: EdmProvDump.cc:266
createfilelist.int
int
Definition: createfilelist.py:10
EcalTPGFineGrainEBGroup.h
kComment
static const char *const kComment
Definition: edmodule_mightGet_config.cc:29
EcalTPGPedestals.h
edm::EventSetup
Definition: EventSetup.h:57
EcalTPGStripStatus.h
get
#define get
EcalTrigPrimProducer::binOfMaximum_
int binOfMaximum_
Definition: EcalTrigPrimProducer.h:56
EcalTPGTowerStatus.h
ecalEBTriggerPrimitiveDigis_cfi.binOfMaximum
binOfMaximum
Definition: ecalEBTriggerPrimitiveDigis_cfi.py:9
EcalTPGFineGrainEBIdMapRcd.h
EcalTPGFineGrainTowerEERcd.h
InputTag.h
EcalTPGWeightGroupRcd
Definition: EcalTPGWeightGroupRcd.h:5
EcalTPGLutIdMapRcd
Definition: EcalTPGLutIdMapRcd.h:5
edm::getParameterSet
ParameterSet const & getParameterSet(ParameterSetID const &id)
Definition: ParameterSet.cc:862
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
EcalTrigPrimFunctionalAlgo.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
EcalTPGSlidingWindow.h
EcalTPGWeightIdMapRcd
Definition: EcalTPGWeightIdMapRcd.h:5
Frameworkfwd.h
EcalTrigPrimProducer::famos_
bool famos_
Definition: EcalTrigPrimProducer.h:52
EcalTPGSlidingWindowRcd
Definition: EcalTPGSlidingWindowRcd.h:5
Exception
Definition: hltDiff.cc:246
EcalTPGLutIdMapRcd.h
EcalTPGCrystalStatus.h
EcalTPGTowerStatusRcd.h
EcalTPGWeightGroupRcd.h
EcalTPGStripStatus
Definition: EcalTPGStripStatus.h:9
ParameterSetID.h
EcalTPGPedestalsRcd.h
EcalTrigPrimProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: EcalTrigPrimProducer.cc:224
edm::eventsetup::EventSetupRecord::cacheIdentifier
unsigned long long cacheIdentifier() const
Definition: EventSetupRecord.h:184
edm::ProcessHistory
Definition: ProcessHistory.h:13
EcalTrigPrimProducer::~EcalTrigPrimProducer
~EcalTrigPrimProducer() override
Definition: EcalTrigPrimProducer.cc:221
EcalTrigPrimProducer::EcalTrigPrimProducer
EcalTrigPrimProducer(const edm::ParameterSet &conf)
Definition: EcalTrigPrimProducer.cc:67
ParameterSet.h
EcalTPGLutGroupRcd
Definition: EcalTPGLutGroupRcd.h:5
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
EcalTPGTowerStatusRcd
Definition: EcalTPGTowerStatusRcd.h:5
EcalTPGLinearizationConstRcd
Definition: EcalTPGLinearizationConstRcd.h:5
SimL1EmulatorDM_cff.eeDigis
eeDigis
Definition: SimL1EmulatorDM_cff.py:18
EcalTPGWeightIdMap.h
EcalTPGFineGrainStripEERcd.h
EcalTrigPrimProducer.h
edm::ProductLabels
Definition: ProductLabels.h:4
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162
EcalTrigPrimProducer::getRecords
unsigned long long getRecords(edm::EventSetup const &setup)
Definition: EcalTrigPrimProducer.cc:137
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37