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  if (not barrelOnly_) {
73  eTTmapToken_ = esConsumes<edm::Transition::BeginRun>();
74  theGeometryToken_ = esConsumes<edm::Transition::BeginRun>();
75  }
76 }
77 
79  //ProcessHistory is guaranteed to be constant for an entire Run
80  //binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_,binOfMaximum_,run.processHistory());
81 
82  if (barrelOnly_) {
83  algo_ = std::make_unique<EcalEBTrigPrimTestAlgo>(nSamples_, binOfMaximum_, tcpFormat_, debug_, famos_);
84  } else {
85  auto const& theGeometry = setup.getData(theGeometryToken_);
86  auto const& eTTmap = setup.getData(eTTmapToken_);
87  algo_ = std::make_unique<EcalEBTrigPrimTestAlgo>(
88  &eTTmap, &theGeometry, nSamples_, binOfMaximum_, tcpFormat_, debug_, famos_);
89  }
90  // get a first version of the records
91  cacheID_ = this->getRecords(setup);
92  nEvent_ = 0;
93 }
94 
96  // get parameter records for xtals
97  auto theEcalTPGLinearization_handle = setup.getHandle(theEcalTPGLinearization_Token_);
98  const EcalTPGLinearizationConst* ecaltpLin = theEcalTPGLinearization_handle.product();
99  //
100  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle = setup.getHandle(theEcalTPGPedestals_Token_);
101  const EcalTPGPedestals* ecaltpPed = theEcalTPGPedestals_handle.product();
102  //
103  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle = setup.getHandle(theEcalTPGCrystalStatus_Token_);
104  const EcalTPGCrystalStatus* ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
105  //
106  //for strips
107  //
108  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle = setup.getHandle(theEcalTPGWEightIdMap_Token_);
109  const EcalTPGWeightIdMap* ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
110  //
111  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle = setup.getHandle(theEcalTPGWEightGroup_Token_);
112  const EcalTPGWeightGroup* ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
113  //
114  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle = setup.getHandle(theEcalTPGSlidingWindow_Token_);
115  const EcalTPGSlidingWindow* ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
116  // TCP
117  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle = setup.getHandle(theEcalTPGLutGroup_Token_);
118  const EcalTPGLutGroup* ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
119  //
120  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle = setup.getHandle(theEcalTPGLutIdMap_Token_);
121  const EcalTPGLutIdMap* ecaltpgLut = theEcalTPGLutIdMap_handle.product();
122  //
123  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle = setup.getHandle(theEcalTPGTowerStatus_Token_);
124  const EcalTPGTowerStatus* ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
125  //
126  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle = setup.getHandle(theEcalTPGSpike_Token_);
127  const EcalTPGSpike* ecaltpgSpike = theEcalTPGSpike_handle.product();
128 
130  algo_->setPointers(ecaltpLin,
131  ecaltpPed,
132  ecaltpgBadX,
133  ecaltpgWeightMap,
134  ecaltpgWeightGroup,
135  ecaltpgSlidW,
136  ecaltpgLutGroup,
137  ecaltpgLut,
138  ecaltpgBadTT,
139  ecaltpgSpike);
140  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
141 }
142 
144 
146 
147 // ------------ method called to produce the data ------------
149  nEvent_++;
150 
151  // get input collections
152  edm::Handle<EBDigiCollection> barrelDigiHandle;
153 
154  if (!e.getByToken(tokenEBdigi_, barrelDigiHandle)) {
156  labelsForToken(tokenEBdigi_, labels);
157  edm::LogWarning("EcalTPG") << " Couldnt find Barrel digis " << labels.module << " and label "
158  << labels.productInstance << "!!!";
159  }
160 
161  if (debug_)
162  std::cout << "EcalTPG"
163  << " =================> Treating event " << nEvent_ << ", Number of EB digis "
164  << barrelDigiHandle.product()->size() << std::endl;
165 
166  auto pOut = std::make_unique<EcalEBTrigPrimDigiCollection>();
167  auto pOutTcp = std::make_unique<EcalEBTrigPrimDigiCollection>();
168 
169  // if ( e.id().event() != 648 ) return;
170 
171  //std::cout << " Event number " << e.id().event() << std::endl;
172 
173  // invoke algorithm
174 
175  const EBDigiCollection* ebdigi = nullptr;
176  ebdigi = barrelDigiHandle.product();
177  algo_->run(ebdigi, *pOut, *pOutTcp);
178 
179  if (debug_)
180  std::cout << "produce"
181  << " For Barrel " << pOut->size() << " TP Digis were produced" << std::endl;
182 
183  // debug prints if TP >0
184 
185  int nonZeroTP = 0;
186  for (unsigned int i = 0; i < pOut->size(); ++i) {
187  if (debug_) {
188  std::cout << "EcalTPG Printing only non zero TP "
189  << " For tower " << (((*pOut)[i])).id() << ", TP is " << (*pOut)[i];
190  for (int isam = 0; isam < (*pOut)[i].size(); ++isam) {
191  if ((*pOut)[i][isam].encodedEt() > 0) {
192  nonZeroTP++;
193  std::cout << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() "
194  << (*pOut)[i][isam].encodedEt() << std::endl;
195  }
196  }
197  }
198  }
199  if (debug_)
200  std::cout << "EcalTPG"
201  << "\n =================> For Barrel , " << pOut->size()
202  << " TP Digis were produced (including zero ones)"
203  << " Non zero primitives were " << nonZeroTP << std::endl;
204 
205  // put result into the Event
206  e.put(std::move(pOut));
207  if (tcpFormat_)
208  e.put(std::move(pOutTcp), "formatTCP");
209 }
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:59
EcalTPGWeightIdMap
Definition: EcalTPGWeightIdMap.h:10
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
EcalEBTrigPrimProducer::~EcalEBTrigPrimProducer
~EcalEBTrigPrimProducer() override
Definition: EcalEBTrigPrimProducer.cc:145
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalEBTrigPrimProducer::cacheID_
unsigned long long cacheID_
Definition: EcalEBTrigPrimProducer.h:86
EcalEBTrigPrimProducer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition: EcalEBTrigPrimProducer.cc:143
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:74
L1TrackObjectNtupleMaker_cfg.pOut
pOut
Definition: L1TrackObjectNtupleMaker_cfg.py:172
EcalEBTrigPrimProducer::famos_
bool famos_
Definition: EcalEBTrigPrimProducer.h:63
EcalEBTrigPrimProducer::theEcalTPGWEightGroup_Token_
edm::ESGetToken< EcalTPGWeightGroup, EcalTPGWeightGroupRcd > theEcalTPGWEightGroup_Token_
Definition: EcalEBTrigPrimProducer.h:72
EcalTPGWeightGroup
Definition: EcalTPGWeightGroup.h:8
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::Handle< EBDigiCollection >
EcalEBTrigPrimProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: EcalEBTrigPrimProducer.cc:148
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:61
EcalEBTrigPrimProducer::theEcalTPGPedestals_Token_
edm::ESGetToken< EcalTPGPedestals, EcalTPGPedestalsRcd > theEcalTPGPedestals_Token_
Definition: EcalEBTrigPrimProducer.h:69
MakerMacros.h
EcalTPGSlidingWindow
Definition: EcalTPGSlidingWindow.h:9
EcalEBTrigPrimProducer::theEcalTPGCrystalStatus_Token_
edm::ESGetToken< EcalTPGCrystalStatus, EcalTPGCrystalStatusRcd > theEcalTPGCrystalStatus_Token_
Definition: EcalEBTrigPrimProducer.h:70
EcalEBTrigPrimProducer::theEcalTPGLinearization_Token_
edm::ESGetToken< EcalTPGLinearizationConst, EcalTPGLinearizationConstRcd > theEcalTPGLinearization_Token_
Definition: EcalEBTrigPrimProducer.h:68
Provenance.h
EcalDigiCollections.h
ProductID.h
edm::ESHandle
Definition: DTSurvey.h:22
EcalEBTrigPrimProducer::binOfMaximum_
int binOfMaximum_
Definition: EcalEBTrigPrimProducer.h:82
EcalEBTrigPrimProducer::theEcalTPGWEightIdMap_Token_
edm::ESGetToken< EcalTPGWeightIdMap, EcalTPGWeightIdMapRcd > theEcalTPGWEightIdMap_Token_
Definition: EcalEBTrigPrimProducer.h:71
EcalEBTrigPrimProducer::barrelOnly_
bool barrelOnly_
Definition: EcalEBTrigPrimProducer.h:60
EcalEBTrigPrimProducer::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: EcalEBTrigPrimProducer.cc:78
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:62
edm::EventSetup
Definition: EventSetup.h:58
EcalEBTrigPrimProducer::theEcalTPGSlidingWindow_Token_
edm::ESGetToken< EcalTPGSlidingWindow, EcalTPGSlidingWindowRcd > theEcalTPGSlidingWindow_Token_
Definition: EcalEBTrigPrimProducer.h:73
InputTag.h
EcalEBTrigPrimProducer::theEcalTPGTowerStatus_Token_
edm::ESGetToken< EcalTPGTowerStatus, EcalTPGTowerStatusRcd > theEcalTPGTowerStatus_Token_
Definition: EcalEBTrigPrimProducer.h:76
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:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalEBTrigPrimProducer::theGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > theGeometryToken_
Definition: EcalEBTrigPrimProducer.h:80
EcalEBTrigPrimProducer::theEcalTPGLutIdMap_Token_
edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > theEcalTPGLutIdMap_Token_
Definition: EcalEBTrigPrimProducer.h:75
ParameterSetID.h
ParameterSet.h
EcalEBTrigPrimProducer::theEcalTPGSpike_Token_
edm::ESGetToken< EcalTPGSpike, EcalTPGSpikeRcd > theEcalTPGSpike_Token_
Definition: EcalEBTrigPrimProducer.h:77
EcalEBTrigPrimProducer.h
EcalEBTrigPrimProducer::eTTmapToken_
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmapToken_
Definition: EcalEBTrigPrimProducer.h:79
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:95
EcalTPGLinearizationConstRcd
Definition: EcalTPGLinearizationConstRcd.h:5
EcalEBTrigPrimProducer::nEvent_
int nEvent_
Definition: EcalEBTrigPrimProducer.h:65
edm::InputTag
Definition: InputTag.h:15
edm::ProductLabels
Definition: ProductLabels.h:4
EcalEBTrigPrimProducer::tokenEBdigi_
edm::EDGetTokenT< EBDigiCollection > tokenEBdigi_
Definition: EcalEBTrigPrimProducer.h:67
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37