CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
EcalTrivialObjectAnalyzer Class Reference

#include <EcalTrivialObjectAnalyzer.h>

Inheritance diagram for EcalTrivialObjectAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
 
 EcalTrivialObjectAnalyzer (edm::ParameterSet const &p)
 
 EcalTrivialObjectAnalyzer (int i)
 
virtual ~EcalTrivialObjectAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 10 of file EcalTrivialObjectAnalyzer.h.

Constructor & Destructor Documentation

EcalTrivialObjectAnalyzer::EcalTrivialObjectAnalyzer ( edm::ParameterSet const &  p)
inlineexplicit

Definition at line 13 of file EcalTrivialObjectAnalyzer.h.

14  { }
EcalTrivialObjectAnalyzer::EcalTrivialObjectAnalyzer ( int  i)
inlineexplicit

Definition at line 15 of file EcalTrivialObjectAnalyzer.h.

16  { }
virtual EcalTrivialObjectAnalyzer::~EcalTrivialObjectAnalyzer ( )
inlinevirtual

Definition at line 17 of file EcalTrivialObjectAnalyzer.h.

17 { }

Member Function Documentation

void EcalTrivialObjectAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 80 of file EcalTrivialObjectAnalyzer.cc.

References gather_cfg::cout, EcalCondObjectContainer< T >::end(), edm::EventID::event(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), EcalLaserAPDPNRatios::getLaserMap(), EcalCondObjectContainer< T >::getMap(), EcalChannelStatusCode::getStatusCode(), i, edm::EventBase::id(), edm::ESHandle< class >::product(), diffTwoXMLs::r1, rand(), DetId::rawId(), and edm::EventID::run().

81 {
82  using namespace edm::eventsetup;
83  // Context is not used.
84  std::cout <<">>> EcalTrivialObjectAnalyzer: processing run "<<e.id().run() << " event: " << e.id().event() << std::endl;
85 
87  context.get<EcalPedestalsRcd>().get(pPeds);
88 
89  // ADC -> GeV Scale
91  context.get<EcalADCToGeVConstantRcd>().get(pAgc);
92  const EcalADCToGeVConstant* agc = pAgc.product();
93  std::cout << "Global ADC->GeV scale: EB " << std::setprecision(6) << agc->getEBValue() << " GeV/ADC count"
94  " EE " << std::setprecision(6) << agc->getEEValue() << " GeV/ADC count" << std::endl;
95 
96  // use a channel to fetch values from DB
97  double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
98  int ieta = int( 1 + r1*85 );
99  r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
100  int iphi = int( 1 + r1*20 );
101 
102  EBDetId ebid(ieta,iphi); //eta,phi
103  std::cout << "EcalTrivialObjectAnalyzer: using EBDetId: " << ebid << std::endl;
104 
105  const EcalPedestals* myped=pPeds.product();
106  EcalPedestals::const_iterator it = myped->find(ebid.rawId());
107  if( it!=myped->end() ){
108  std::cout << "EcalPedestal: "
109  << " mean_x1: " << std::setprecision(8) << (*it).mean_x1 << " rms_x1: " << (*it).rms_x1
110  << " mean_x6: " <<(*it).mean_x6 << " rms_x6: " << (*it).rms_x6
111  << " mean_x12: " <<(*it).mean_x12 << " rms_x12: " << (*it).rms_x12
112  << std::endl;
113  } else {
114  std::cout << "No pedestal found for this xtal! something wrong with EcalPedestals in your DB? "
115  << std::endl;
116  }
117 
118  // fetch map of groups of xtals
120  context.get<EcalWeightXtalGroupsRcd>().get(pGrp);
121  const EcalWeightXtalGroups* grp = pGrp.product();
122 
123  EcalXtalGroupsMap::const_iterator git = grp->getMap().find( ebid.rawId() );
124  EcalXtalGroupId gid;
125  if( git != grp->getMap().end() ) {
126  std::cout << "XtalGroupId.id() = " << std::setprecision(3) << (*git).id() << std:: endl;
127  gid = (*git);
128  } else {
129  std::cout << "No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
130  << std::endl;
131  }
132 
133  // Gain Ratios
135  context.get<EcalGainRatiosRcd>().get(pRatio);
136  const EcalGainRatios* gr = pRatio.product();
137 
138  EcalGainRatioMap::const_iterator grit=gr->getMap().find(ebid.rawId());
139  EcalMGPAGainRatio mgpa;
140  if( grit!=gr->getMap().end() ){
141  mgpa = (*grit);
142 
143  std::cout << "EcalMGPAGainRatio: "
144  << "gain 12/6 : " << std::setprecision(4) << mgpa.gain12Over6() << " gain 6/1: " << mgpa.gain6Over1()
145  << std::endl;
146  } else {
147  std::cout << "No MGPA Gain Ratio found for this xtal! something wrong with EcalGainRatios in your DB? "
148  << std::endl;
149  }
150 
151  // Intercalib constants
153  context.get<EcalIntercalibConstantsRcd>().get(pIcal);
154  const EcalIntercalibConstants* ical = pIcal.product();
155 
156  EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(ebid.rawId());
157  EcalIntercalibConstant icalconst;
158  if( icalit!=ical->getMap().end() ){
159  icalconst = (*icalit);
160 
161  std::cout << "EcalIntercalibConstant: "
162  <<std::setprecision(6)
163  << icalconst
164  << std::endl;
165  } else {
166  std::cout << "No intercalib const found for this xtal! something wrong with EcalIntercalibConstants in your DB? "
167  << std::endl;
168  }
169 
170  // Intercalib errors
172  context.get<EcalIntercalibErrorsRcd>().get(pIcalErr);
173  const EcalIntercalibErrors* icalErr = pIcalErr.product();
174 
175  EcalIntercalibErrorMap::const_iterator icalitErr=icalErr->getMap().find(ebid.rawId());
176  EcalIntercalibError icalconstErr;
177  if( icalitErr!=icalErr->getMap().end() ){
178  icalconstErr = (*icalitErr);
179 
180  std::cout << "EcalIntercalibError: "
181  <<std::setprecision(6)
182  << icalconstErr
183  << std::endl;
184  } else {
185  std::cout << "No intercalib const found for this xtal! something wrong with EcalIntercalibErrors in your DB? "
186  << std::endl;
187  }
188 
189 
190 
191  { // quick and dirty for cut and paste ;) it is a test program...
192  // TimeCalib constants
194  context.get<EcalTimeCalibConstantsRcd>().get(pIcal);
195  const EcalTimeCalibConstants* ical = pIcal.product();
196 
197  EcalTimeCalibConstantMap::const_iterator icalit=ical->getMap().find(ebid.rawId());
198  EcalTimeCalibConstant icalconst;
199  if( icalit!=ical->getMap().end() ){
200  icalconst = (*icalit);
201 
202  std::cout << "EcalTimeCalibConstant: "
203  <<std::setprecision(6)
204  << icalconst
205  << std::endl;
206  } else {
207  std::cout << "No intercalib const found for this xtal! something wrong with EcalTimeCalibConstants in your DB? "
208  << std::endl;
209  }
210 
211  // TimeCalib errors
213  context.get<EcalTimeCalibErrorsRcd>().get(pIcalErr);
214  const EcalTimeCalibErrors* icalErr = pIcalErr.product();
215 
216  EcalTimeCalibErrorMap::const_iterator icalitErr=icalErr->getMap().find(ebid.rawId());
217  EcalTimeCalibError icalconstErr;
218  if( icalitErr!=icalErr->getMap().end() ){
219  icalconstErr = (*icalitErr);
220 
221  std::cout << "EcalTimeCalibError: "
222  <<std::setprecision(6)
223  << icalconstErr
224  << std::endl;
225  } else {
226  std::cout << "No intercalib const found for this xtal! something wrong with EcalTimeCalibErrors in your DB? "
227  << std::endl;
228  }
229  }
230 
231  // fetch Time Offset
232  //std::cout <<"Fetching TimeOffsetConstant from DB " << std::endl;
233 
234  // Time Offset constants
236  context.get<EcalTimeOffsetConstantRcd>().get(pTOff);
237  const EcalTimeOffsetConstant* TOff = pTOff.product();
238 
239  std::cout << "EcalTimeOffsetConstant: "
240  << " EB " << TOff->getEBValue()
241  << " EE " << TOff->getEEValue()
242  << std::endl;
243 
244  // fetch TB weights
245  std::cout <<"Fetching EcalTBWeights from DB " << std::endl;
247  context.get<EcalTBWeightsRcd>().get(pWgts);
248  const EcalTBWeights* wgts = pWgts.product();
249  std::cout << "EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size() << std::endl;
250 
251 
252  // look up the correct weights for this xtal
253  //EcalXtalGroupId gid( (*git) );
254  EcalTBWeights::EcalTDCId tdcid(1);
255 
256  std::cout << "Lookup EcalWeightSet for groupid: " << std::setprecision(3)
257  << gid.id() << " and TDC id " << tdcid << std::endl;
258  EcalTBWeights::EcalTBWeightMap::const_iterator wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
259  EcalWeightSet wset;
260  if( wit != wgts->getMap().end() ) {
261  wset = wit->second;
262  std::cout << "check size of data members in EcalWeightSet" << std::endl;
263  //wit->second.print(std::cout);
264 
265 
266  //typedef std::vector< std::vector<EcalWeight> > EcalWeightMatrix;
267  const EcalWeightSet::EcalWeightMatrix& mat1 = wit->second.getWeightsBeforeGainSwitch();
268  const EcalWeightSet::EcalWeightMatrix& mat2 = wit->second.getWeightsAfterGainSwitch();
269 
270 // std::cout << "WeightsBeforeGainSwitch.size: " << mat1.size()
271 // << ", WeightsAfterGainSwitch.size: " << mat2.size() << std::endl;
272 
273 
274  CLHEP::HepMatrix clmat1(3,10,0);
275  CLHEP::HepMatrix clmat2(3,10,0);
276  for(int irow=0; irow<3; irow++) {
277  for(int icol=0; icol<10; icol++) {
278  clmat1[irow][icol] = mat1(irow,icol);
279  clmat2[irow][icol] = mat2(irow,icol);
280  }
281  }
282  std::cout << "weight matrix before gain switch:" << std::endl;
283  std::cout << clmat1 << std::endl;
284  std::cout << "weight matrix after gain switch:" << std::endl;
285  std::cout << clmat2 << std::endl;
286 
287  } else {
288  std::cout << "No weights found for EcalGroupId: " << gid.id() << " and EcalTDCId: " << tdcid << std::endl;
289  }
290 
291  // cluster functions/corrections
293  context.get<EcalClusterLocalContCorrParametersRcd>().get(pLocalCont);
294  const EcalClusterLocalContCorrParameters* paramLocalCont = pLocalCont.product();
295  std::cout << "LocalContCorrParameters:";
296  for ( EcalFunctionParameters::const_iterator it = paramLocalCont->params().begin(); it != paramLocalCont->params().end(); ++it ) {
297  std::cout << " " << *it;
298  }
299  std::cout << "\n";
301  context.get<EcalClusterCrackCorrParametersRcd>().get(pCrack);
302  const EcalClusterCrackCorrParameters* paramCrack = pCrack.product();
303  std::cout << "CrackCorrParameters:";
304  for ( EcalFunctionParameters::const_iterator it = paramCrack->params().begin(); it != paramCrack->params().end(); ++it ) {
305  std::cout << " " << *it;
306  }
307  std::cout << "\n";
309  context.get<EcalClusterEnergyCorrectionParametersRcd>().get(pEnergyCorrection);
310  const EcalClusterEnergyCorrectionParameters* paramEnergyCorrection = pEnergyCorrection.product();
311  std::cout << "EnergyCorrectionParameters:";
312  for ( EcalFunctionParameters::const_iterator it = paramEnergyCorrection->params().begin(); it != paramEnergyCorrection->params().end(); ++it ) {
313  std::cout << " " << *it;
314  }
315  std::cout << "\n";
317  context.get<EcalClusterEnergyUncertaintyParametersRcd>().get(pEnergyUncertainty);
318  const EcalClusterEnergyUncertaintyParameters* paramEnergyUncertainty = pEnergyUncertainty.product();
319  std::cout << "EnergyCorrectionParameters:";
320  for ( EcalFunctionParameters::const_iterator it = paramEnergyUncertainty->params().begin(); it != paramEnergyUncertainty->params().end(); ++it ) {
321  std::cout << " " << *it;
322  }
323  std::cout << "\n";
325  context.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().get(pEnergyCorrectionObjectSpecific);
326  const EcalClusterEnergyCorrectionObjectSpecificParameters* paramEnergyCorrectionObjectSpecific = pEnergyCorrectionObjectSpecific.product();
327  std::cout << "EnergyCorrectionObjectSpecificParameters:";
328  for ( EcalFunctionParameters::const_iterator it = paramEnergyCorrectionObjectSpecific->params().begin(); it != paramEnergyCorrectionObjectSpecific->params().end(); ++it ) {
329  std::cout << " " << *it;
330  }
331  std::cout << "\n";
332 
333 
334  // laser correction
335 
336  // laser alphas
338  context.get<EcalLaserAlphasRcd>().get(pAlpha);
339  const EcalLaserAlphas* lalpha = pAlpha.product();
340 
342  lalphait = lalpha->getMap().find(ebid.rawId());
343  if( lalphait!=lalpha->getMap().end() ){
344  std::cout << "EcalLaserAlpha: "
345  <<std::setprecision(6)
346  << (*lalphait)
347  << std::endl;
348  } else {
349  std::cout << "No laser alpha found for this xtal! something wrong with EcalLaserAlphas in your DB? "
350  << std::endl;
351  }
352 
353  // laser apdpnref
355  context.get<EcalLaserAPDPNRatiosRefRcd>().get(pAPDPNRatiosRef);
356  const EcalLaserAPDPNRatiosRef* lref = pAPDPNRatiosRef.product();
357 
359  lrefit = lref->getMap().find(ebid.rawId());
360  if( lrefit!=lref->getMap().end() ){
361  std::cout << "EcalLaserAPDPNRatiosRef: "
362  <<std::setprecision(6)
363  << (*lrefit)
364  << std::endl;
365  } else {
366  std::cout << "No laser apd/pn ref found for this xtal! something wrong with EcalLaserAPDPNRatiosRef in your DB? "
367  << std::endl;
368  }
369 
370  // laser apdpn ratios
372  context.get<EcalLaserAPDPNRatiosRcd>().get(pAPDPNRatios);
373  const EcalLaserAPDPNRatios* lratio = pAPDPNRatios.product();
374 
376  lratioit = lratio->getLaserMap().find(ebid.rawId());
378 
379  if( lratioit!=lratio->getLaserMap().end() ){
380  lratioconst = (*lratioit);
381 
382  std::cout << "EcalLaserAPDPNRatios: "
383  // <<e.id().run() << " " << e.id().event() << " "
384  << std::setprecision(6)
385  << lratioconst.p1 << " " << lratioconst.p2
386  << std::endl;
387  } else {
388  std::cout << "No laser apd/pn ratio found for this xtal! something wrong with EcalLaserAPDPNRatios in your DB? "
389  << std::endl;
390  }
391 
392  // laser timestamps
394  EcalLaserAPDPNRatios::EcalLaserTimeStampMap::const_iterator ltimeit;
395  for (int i=1; i<=92; i++) {
396  ltimestamp = lratio->getTimeMap()[i];
397  std::cout << "i = " << std::setprecision(6) << i
398  << ltimestamp.t1.value() << " " << ltimestamp.t2.value() << " : " ;
399  }
400  std::cout << "Tests finished." << std::endl;
401 
402  // channel status
403  edm::ESHandle<EcalChannelStatus> pChannelStatus;
404  context.get<EcalChannelStatusRcd>().get(pChannelStatus);
405  const EcalChannelStatus *ch_status = pChannelStatus.product();
406 
408  chit = ch_status->getMap().find(ebid.rawId());
409  if( chit != ch_status->getMap().end() ){
410  EcalChannelStatusCode ch_code = (*chit);
411  std::cout << "EcalChannelStatus: "
412  <<std::setprecision(6)
413  << ch_code.getStatusCode()
414  << std::endl;
415  } else {
416  std::cout << "No channel status found for this xtal! something wrong with EcalChannelStatus in your DB? "
417  << std::endl;
418  }
419 
420 
421  // laser transparency correction
422 
423  // Mask to ignore sample
425  context.get<EcalSampleMaskRcd>().get(pSMask);
426  const EcalSampleMask* smask = pSMask.product();
427  std::cout << "Sample Mask EB " << std::hex << smask->getEcalSampleMaskRecordEB()
428  << " EE " << std::hex << smask->getEcalSampleMaskRecordEE() << std::endl;
429 
430 
431 /*
432  std::cout << "make CLHEP matrices from vector<vector<Ecalweight>>" << std::endl;
433  CLHEP::HepMatrix clmat1(3,8,0);
434  CLHEP::HepMatrix clmat2(3,8,0);
435  for(int irow=0; irow<3; irow++) {
436  for(int icol=0; icol<8; icol++) {
437  clmat1[irow][icol] = (mat1[irow])[icol]();
438  clmat2[irow][icol] = (mat2[irow])[icol]();
439  }
440  }
441  std::cout << clmat1 << std::endl;
442  std::cout << clmat2 << std::endl;
443 */
444 
445 } //end of ::Analyze()
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
const self & getMap() const
float EcalTimeCalibError
const EcalLaserAPDPNRatiosMap & getLaserMap() const
uint16_t getStatusCode() const
float EcalIntercalibError
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
edm::EventID id() const
Definition: EventBase.h:56
float EcalTimeCalibConstant
Signal rand(Signal arg)
Definition: vlib.cc:442
const_iterator find(uint32_t rawId) const
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
float EcalIntercalibConstant