CMS 3D CMS Logo

EcalEBTrigPrimProducer.cc
Go to the documentation of this file.
1 
11 
17 
22 //
23 
24 /*
25 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBGroupRcd.h"
26 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBIdMapRcd.h"
27 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainTowerEERcd.h"
28 
29 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h"
30 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBIdMap.h"
31 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainTowerEE.h"
32 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainStripEERcd.h"
33 #include "CondFormats/EcalObjects/interface/EcalTPGWeightIdMap.h"
34 #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h"
35 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainStripEE.h"
36 #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
37 #include "CondFormats/DataRecord/interface/EcalTPGStripStatusRcd.h"
38 #include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h"
39 */
40 
41 #include "EcalEBTrigPrimProducer.h"
42 
43 #include <memory>
44 
46 
48  : barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
49  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
50  debug_(iConfig.getParameter<bool>("Debug")),
51  famos_(iConfig.getParameter<bool>("Famos")),
52  nSamples_(iConfig.getParameter<int>("nOfSamples")),
53  binOfMaximum_(iConfig.getParameter<int>("binOfMaximum")) {
54  tokenEBdigi_ = consumes<EBDigiCollection>(iConfig.getParameter<edm::InputTag>("barrelEcalDigis"));
56  esConsumes<EcalTPGLinearizationConst, EcalTPGLinearizationConstRcd, edm::Transition::BeginRun>();
57  theEcalTPGPedestals_Token_ = esConsumes<EcalTPGPedestals, EcalTPGPedestalsRcd, edm::Transition::BeginRun>();
59  esConsumes<EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd, edm::Transition::BeginRun>();
60  theEcalTPGWEightIdMap_Token_ = esConsumes<EcalTPGWeightIdMap, EcalTPGWeightIdMapRcd, edm::Transition::BeginRun>();
61  theEcalTPGWEightGroup_Token_ = esConsumes<EcalTPGWeightGroup, EcalTPGWeightGroupRcd, edm::Transition::BeginRun>();
63  esConsumes<EcalTPGSlidingWindow, EcalTPGSlidingWindowRcd, edm::Transition::BeginRun>();
64  theEcalTPGLutGroup_Token_ = esConsumes<EcalTPGLutGroup, EcalTPGLutGroupRcd, edm::Transition::BeginRun>();
65  theEcalTPGLutIdMap_Token_ = esConsumes<EcalTPGLutIdMap, EcalTPGLutIdMapRcd, edm::Transition::BeginRun>();
66  theEcalTPGTowerStatus_Token_ = esConsumes<EcalTPGTowerStatus, EcalTPGTowerStatusRcd, edm::Transition::BeginRun>();
67  theEcalTPGSpike_Token_ = esConsumes<EcalTPGSpike, EcalTPGSpikeRcd, edm::Transition::BeginRun>();
68  //register your products
69  produces<EcalEBTrigPrimDigiCollection>();
70  if (tcpFormat_)
71  produces<EcalEBTrigPrimDigiCollection>("formatTCP");
72 }
73 
75  //ProcessHistory is guaranteed to be constant for an entire Run
76  //binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_,binOfMaximum_,run.processHistory());
77 
78  algo_ = std::make_unique<EcalEBTrigPrimTestAlgo>(
80  // get a first version of the records
81  cacheID_ = this->getRecords(setup);
82  nEvent_ = 0;
83 }
84 
86  // get parameter records for xtals
87  auto theEcalTPGLinearization_handle = setup.getHandle(theEcalTPGLinearization_Token_);
88  const EcalTPGLinearizationConst* ecaltpLin = theEcalTPGLinearization_handle.product();
89  //
90  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle = setup.getHandle(theEcalTPGPedestals_Token_);
91  const EcalTPGPedestals* ecaltpPed = theEcalTPGPedestals_handle.product();
92  //
93  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle = setup.getHandle(theEcalTPGCrystalStatus_Token_);
94  const EcalTPGCrystalStatus* ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
95  //
96  //for strips
97  //
98  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle = setup.getHandle(theEcalTPGWEightIdMap_Token_);
99  const EcalTPGWeightIdMap* ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
100  //
101  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle = setup.getHandle(theEcalTPGWEightGroup_Token_);
102  const EcalTPGWeightGroup* ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
103  //
104  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle = setup.getHandle(theEcalTPGSlidingWindow_Token_);
105  const EcalTPGSlidingWindow* ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
106  // TCP
107  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle = setup.getHandle(theEcalTPGLutGroup_Token_);
108  const EcalTPGLutGroup* ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
109  //
110  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle = setup.getHandle(theEcalTPGLutIdMap_Token_);
111  const EcalTPGLutIdMap* ecaltpgLut = theEcalTPGLutIdMap_handle.product();
112  //
113  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle = setup.getHandle(theEcalTPGTowerStatus_Token_);
114  const EcalTPGTowerStatus* ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
115  //
116  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle = setup.getHandle(theEcalTPGSpike_Token_);
117  const EcalTPGSpike* ecaltpgSpike = theEcalTPGSpike_handle.product();
118 
120  algo_->setPointers(ecaltpLin,
121  ecaltpPed,
122  ecaltpgBadX,
123  ecaltpgWeightMap,
124  ecaltpgWeightGroup,
125  ecaltpgSlidW,
126  ecaltpgLutGroup,
127  ecaltpgLut,
128  ecaltpgBadTT,
129  ecaltpgSpike);
130  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
131 }
132 
134 
136 
137 // ------------ method called to produce the data ------------
139  nEvent_++;
140 
141  // get input collections
142  edm::Handle<EBDigiCollection> barrelDigiHandle;
143 
144  if (!e.getByToken(tokenEBdigi_, barrelDigiHandle)) {
146  labelsForToken(tokenEBdigi_, labels);
147  edm::LogWarning("EcalTPG") << " Couldnt find Barrel digis " << labels.module << " and label "
148  << labels.productInstance << "!!!";
149  }
150 
151  if (debug_)
152  std::cout << "EcalTPG"
153  << " =================> Treating event " << nEvent_ << ", Number of EB digis "
154  << barrelDigiHandle.product()->size() << std::endl;
155 
156  auto pOut = std::make_unique<EcalEBTrigPrimDigiCollection>();
157  auto pOutTcp = std::make_unique<EcalEBTrigPrimDigiCollection>();
158 
159  // if ( e.id().event() != 648 ) return;
160 
161  //std::cout << " Event number " << e.id().event() << std::endl;
162 
163  // invoke algorithm
164 
165  const EBDigiCollection* ebdigi = nullptr;
166  ebdigi = barrelDigiHandle.product();
167  algo_->run(iSetup, ebdigi, *pOut, *pOutTcp);
168 
169  if (debug_)
170  std::cout << "produce"
171  << " For Barrel " << pOut->size() << " TP Digis were produced" << std::endl;
172 
173  // debug prints if TP >0
174 
175  int nonZeroTP = 0;
176  for (unsigned int i = 0; i < pOut->size(); ++i) {
177  if (debug_) {
178  std::cout << "EcalTPG Printing only non zero TP "
179  << " For tower " << (((*pOut)[i])).id() << ", TP is " << (*pOut)[i];
180  for (int isam = 0; isam < (*pOut)[i].size(); ++isam) {
181  if ((*pOut)[i][isam].encodedEt() > 0) {
182  nonZeroTP++;
183  std::cout << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() "
184  << (*pOut)[i][isam].encodedEt() << std::endl;
185  }
186  }
187  }
188  }
189  if (debug_)
190  std::cout << "EcalTPG"
191  << "\n =================> For Barrel , " << pOut->size()
192  << " TP Digis were produced (including zero ones)"
193  << " Non zero primitives were " << nonZeroTP << std::endl;
194 
195  // put result into the Event
196  e.put(std::move(pOut));
197  if (tcpFormat_)
198  e.put(std::move(pOutTcp), "formatTCP");
199 }
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalEBTrigPrimProducer::algo_
std::unique_ptr< EcalEBTrigPrimTestAlgo > algo_
Definition: EcalEBTrigPrimProducer.h:56
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
EcalEBTrigPrimProducer::~EcalEBTrigPrimProducer
~EcalEBTrigPrimProducer() override
Definition: EcalEBTrigPrimProducer.cc:135
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalEBTrigPrimProducer::cacheID_
unsigned long long cacheID_
Definition: EcalEBTrigPrimProducer.h:80
EcalEBTrigPrimProducer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: EcalEBTrigPrimProducer.cc:133
edm::Run
Definition: Run.h:45
EcalTPGSpike
Definition: EcalTPGSpike.h:9
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalEBTrigPrimTestAlgo.h
EcalEBTrigPrimProducer::theEcalTPGLutGroup_Token_
edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > theEcalTPGLutGroup_Token_
Definition: EcalEBTrigPrimProducer.h:71
EcalEBTrigPrimProducer::famos_
bool famos_
Definition: EcalEBTrigPrimProducer.h:60
EcalEBTrigPrimProducer::theEcalTPGWEightGroup_Token_
edm::ESGetToken< EcalTPGWeightGroup, EcalTPGWeightGroupRcd > theEcalTPGWEightGroup_Token_
Definition: EcalEBTrigPrimProducer.h:69
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:13
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::Handle< EBDigiCollection >
EcalEBTrigPrimProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: EcalEBTrigPrimProducer.cc:138
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalEBTrigPrimProducer::tcpFormat_
bool tcpFormat_
Definition: EcalEBTrigPrimProducer.h:58
EcalEBTrigPrimProducer::theEcalTPGPedestals_Token_
edm::ESGetToken< EcalTPGPedestals, EcalTPGPedestalsRcd > theEcalTPGPedestals_Token_
Definition: EcalEBTrigPrimProducer.h:66
MakerMacros.h
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
EcalEBTrigPrimProducer::theEcalTPGCrystalStatus_Token_
edm::ESGetToken< EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd > theEcalTPGCrystalStatus_Token_
Definition: EcalEBTrigPrimProducer.h:67
EcalEBTrigPrimProducer::theEcalTPGLinearization_Token_
edm::ESGetToken< EcalTPGLinearizationConst, EcalTPGLinearizationConstRcd > theEcalTPGLinearization_Token_
Definition: EcalEBTrigPrimProducer.h:65
Provenance.h
EcalDigiCollections.h
ProductID.h
edm::ESHandle
Definition: DTSurvey.h:22
EcalEBTrigPrimProducer::binOfMaximum_
int binOfMaximum_
Definition: EcalEBTrigPrimProducer.h:76
EcalEBTrigPrimProducer::theEcalTPGWEightIdMap_Token_
edm::ESGetToken< EcalTPGWeightIdMap, EcalTPGWeightIdMapRcd > theEcalTPGWEightIdMap_Token_
Definition: EcalEBTrigPrimProducer.h:68
EcalEBTrigPrimProducer::barrelOnly_
bool barrelOnly_
Definition: EcalEBTrigPrimProducer.h:57
EcalEBTrigPrimProducer::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: EcalEBTrigPrimProducer.cc:74
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EBDigiCollection
Definition: EcalDigiCollections.h:56
createfilelist.int
int
Definition: createfilelist.py:10
EcalEBTrigPrimProducer::debug_
bool debug_
Definition: EcalEBTrigPrimProducer.h:59
edm::EventSetup
Definition: EventSetup.h:57
EcalEBTrigPrimProducer::theEcalTPGSlidingWindow_Token_
edm::ESGetToken< EcalTPGSlidingWindow, EcalTPGSlidingWindowRcd > theEcalTPGSlidingWindow_Token_
Definition: EcalEBTrigPrimProducer.h:70
InputTag.h
EcalEBTrigPrimProducer::theEcalTPGTowerStatus_Token_
edm::ESGetToken< EcalTPGTowerStatus, EcalTPGTowerStatusRcd > theEcalTPGTowerStatus_Token_
Definition: EcalEBTrigPrimProducer.h:73
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Frameworkfwd.h
EcalEBTrigPrimProducer::nSamples_
int nSamples_
Definition: EcalEBTrigPrimProducer.h:61
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalEBTrigPrimProducer::theEcalTPGLutIdMap_Token_
edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > theEcalTPGLutIdMap_Token_
Definition: EcalEBTrigPrimProducer.h:72
ParameterSetID.h
ParameterSet.h
EcalEBTrigPrimProducer::theEcalTPGSpike_Token_
edm::ESGetToken< EcalTPGSpike, EcalTPGSpikeRcd > theEcalTPGSpike_Token_
Definition: EcalEBTrigPrimProducer.h:74
EcalEBTrigPrimProducer.h
EcalEBTrigPrimProducer::EcalEBTrigPrimProducer
EcalEBTrigPrimProducer(const edm::ParameterSet &conf)
Definition: EcalEBTrigPrimProducer.cc:47
edm::Event
Definition: Event.h:73
EcalEBTrigPrimProducer::getRecords
unsigned long long getRecords(edm::EventSetup const &setup)
Definition: EcalEBTrigPrimProducer.cc:85
EcalTPGLinearizationConstRcd
Definition: EcalTPGLinearizationConstRcd.h:5
EcalEBTrigPrimProducer::nEvent_
int nEvent_
Definition: EcalEBTrigPrimProducer.h:62
edm::InputTag
Definition: InputTag.h:15
edm::ProductLabels
Definition: ProductLabels.h:4
EcalEBTrigPrimProducer::tokenEBdigi_
edm::EDGetTokenT< EBDigiCollection > tokenEBdigi_
Definition: EcalEBTrigPrimProducer.h:64
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37