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

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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 11 of file EcalTrivialObjectAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file EcalTrivialObjectAnalyzer.h.

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

Definition at line 16 of file EcalTrivialObjectAnalyzer.h.

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

Definition at line 18 of file EcalTrivialObjectAnalyzer.h.

18 { }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 78 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().

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