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)
 
- 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 73 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(), rand(), DetId::rawId(), and edm::EventID::run().

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