CMS 3D CMS Logo

EcalEBTrigPrimProducer.cc
Go to the documentation of this file.
1 
11 
17 
22 //
26 
41 
42 
43 /*
44 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBGroupRcd.h"
45 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBIdMapRcd.h"
46 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainTowerEERcd.h"
47 
48 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h"
49 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBIdMap.h"
50 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainTowerEE.h"
51 #include "CondFormats/DataRecord/interface/EcalTPGFineGrainStripEERcd.h"
52 #include "CondFormats/EcalObjects/interface/EcalTPGWeightIdMap.h"
53 #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h"
54 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainStripEE.h"
55 #include "CondFormats/EcalObjects/interface/EcalTPGTowerStatus.h"
56 #include "CondFormats/DataRecord/interface/EcalTPGStripStatusRcd.h"
57 #include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h"
58 */
59 
60 #include "EcalEBTrigPrimProducer.h"
62 
64  barrelOnly_(iConfig.getParameter<bool>("BarrelOnly")),
65  tcpFormat_(iConfig.getParameter<bool>("TcpOutput")),
66  debug_(iConfig.getParameter<bool>("Debug")),
67  famos_(iConfig.getParameter<bool>("Famos")),
68  nSamples_(iConfig.getParameter<int>("nOfSamples")),
69  binOfMaximum_(iConfig.getParameter<int>("binOfMaximum"))
70 {
71  tokenEBdigi_=consumes<EBDigiCollection>(iConfig.getParameter<edm::InputTag>("barrelEcalDigis"));
72  //register your products
73  produces <EcalEBTrigPrimDigiCollection >();
74  if (tcpFormat_) produces <EcalEBTrigPrimDigiCollection >("formatTCP");
75 }
76 
77 
78 
80  //ProcessHistory is guaranteed to be constant for an entire Run
81  //binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_,binOfMaximum_,run.processHistory());
82 
84  // get a first version of the records
85  cacheID_=this->getRecords(setup);
86  nEvent_=0;
87 }
88 
90 
91  // get parameter records for xtals
92  edm::ESHandle<EcalTPGLinearizationConst> theEcalTPGLinearization_handle;
93  setup.get<EcalTPGLinearizationConstRcd>().get(theEcalTPGLinearization_handle);
94  const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product();
95  //
96  edm::ESHandle<EcalTPGPedestals> theEcalTPGPedestals_handle;
97  setup.get<EcalTPGPedestalsRcd>().get(theEcalTPGPedestals_handle);
98  const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product();
99  //
100  edm::ESHandle<EcalTPGCrystalStatus> theEcalTPGCrystalStatus_handle;
101  setup.get<EcalTPGCrystalStatusRcd>().get(theEcalTPGCrystalStatus_handle);
102  const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product();
103  //
104  //for strips
105  //
106  edm::ESHandle<EcalTPGWeightIdMap> theEcalTPGWEightIdMap_handle;
107  setup.get<EcalTPGWeightIdMapRcd>().get(theEcalTPGWEightIdMap_handle);
108  const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product();
109  //
110  edm::ESHandle<EcalTPGWeightGroup> theEcalTPGWEightGroup_handle;
111  setup.get<EcalTPGWeightGroupRcd>().get(theEcalTPGWEightGroup_handle);
112  const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product();
113  //
114  edm::ESHandle<EcalTPGSlidingWindow> theEcalTPGSlidingWindow_handle;
115  setup.get<EcalTPGSlidingWindowRcd>().get(theEcalTPGSlidingWindow_handle);
116  const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product();
117  // TCP
118  edm::ESHandle<EcalTPGLutGroup> theEcalTPGLutGroup_handle;
119  setup.get<EcalTPGLutGroupRcd>().get(theEcalTPGLutGroup_handle);
120  const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product();
121  //
122  edm::ESHandle<EcalTPGLutIdMap> theEcalTPGLutIdMap_handle;
123  setup.get<EcalTPGLutIdMapRcd>().get(theEcalTPGLutIdMap_handle);
124  const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product();
125  //
126  edm::ESHandle<EcalTPGTowerStatus> theEcalTPGTowerStatus_handle;
127  setup.get<EcalTPGTowerStatusRcd>().get(theEcalTPGTowerStatus_handle);
128  const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product();
129  //
130  edm::ESHandle<EcalTPGSpike> theEcalTPGSpike_handle;
131  setup.get<EcalTPGSpikeRcd>().get(theEcalTPGSpike_handle);
132  const EcalTPGSpike * ecaltpgSpike = theEcalTPGSpike_handle.product();
133 
134 
135 
137  algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgBadX,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgSlidW,ecaltpgLutGroup,ecaltpgLut,ecaltpgBadTT, ecaltpgSpike);
138  return setup.get<EcalTPGLinearizationConstRcd>().cacheIdentifier();
139 
140 
141 
142 
143 }
144 
145 
146 
148  algo_.reset();
149 }
150 
151 
153 {}
154 
155 
156 // ------------ method called to produce the data ------------
157 void
159 {
160 
161  nEvent_++;
162 
163  // get input collections
164  edm::Handle<EBDigiCollection> barrelDigiHandle;
165 
166 
167  if (! e.getByToken(tokenEBdigi_,barrelDigiHandle)) {
169  labelsForToken(tokenEBdigi_, labels);
170  edm::LogWarning("EcalTPG") <<" Couldnt find Barrel digis "<<labels.module<<" and label "<<labels.productInstance<<"!!!";
171  }
172 
173 
174 
175 
176 
177  if (debug_) std::cout << "EcalTPG" <<" =================> Treating event "<< nEvent_<<", Number of EB digis "<<barrelDigiHandle.product()->size() << std::endl;
178 
179 
180  auto pOut = std::make_unique<EcalEBTrigPrimDigiCollection>();
181  auto pOutTcp = std::make_unique<EcalEBTrigPrimDigiCollection>();
182 
183  // if ( e.id().event() != 648 ) return;
184 
185  //std::cout << " Event number " << e.id().event() << std::endl;
186 
187  // invoke algorithm
188 
189 
190  const EBDigiCollection *ebdigi=nullptr;
191  ebdigi=barrelDigiHandle.product();
192  algo_->run(iSetup,ebdigi,*pOut,*pOutTcp);
193 
194 
195  if (debug_ ) std::cout << "produce" << " For Barrel "<<pOut->size()<<" TP Digis were produced" << std::endl;
196 
197  // debug prints if TP >0
198 
199  int nonZeroTP=0;
200  for (unsigned int i=0;i<pOut->size();++i) {
201 
202  if (debug_ ) {
203  std::cout << "EcalTPG Printing only non zero TP " <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i];
204  for (int isam=0;isam<(*pOut)[i].size();++isam) {
205 
206  if ( (*pOut)[i][isam].encodedEt() > 0) {
207  nonZeroTP++;
208  std::cout << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() " << (*pOut)[i][isam].encodedEt() << std::endl;
209  }
210  }
211  }
212  }
213  if (debug_ ) std::cout << "EcalTPG" <<"\n =================> For Barrel , "<<pOut->size()<<" TP Digis were produced (including zero ones)" << " Non zero primitives were " << nonZeroTP << std::endl;
214 
215 
216 
217  // put result into the Event
218  e.put(std::move(pOut));
219  if (tcpFormat_) e.put(std::move(pOutTcp),"formatTCP");
220 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
EcalEBTrigPrimProducer(const edm::ParameterSet &conf)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
edm::EDGetTokenT< EBDigiCollection > tokenEBdigi_
unsigned long long getRecords(edm::EventSetup const &setup)
std::unique_ptr< EcalEBTrigPrimTestAlgo > algo_
char const * module
Definition: ProductLabels.h:5
void produce(edm::Event &e, const edm::EventSetup &c) override
T const * product() const
Definition: Handle.h:81
char const * productInstance
Definition: ProductLabels.h:6
T get() const
Definition: EventSetup.h:62
void endRun(const edm::Run &, const edm::EventSetup &) override
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:44