Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialObjectAnalyzer.h"
00007
00008 #include <stdexcept>
00009 #include <string>
00010 #include <iostream>
00011 #include <iomanip>
00012 #include <map>
00013 #include <vector>
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015
00016 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00017
00018 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
00019 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
00020
00021 #include "CondFormats/EcalObjects/interface/EcalXtalGroupId.h"
00022 #include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
00023 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
00024
00025 #include "CondFormats/EcalObjects/interface/EcalWeightSet.h"
00026 #include "CondFormats/EcalObjects/interface/EcalTBWeights.h"
00027 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
00028
00029 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00030 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00031
00032 #include "CondFormats/EcalObjects/interface/EcalIntercalibErrors.h"
00033 #include "CondFormats/DataRecord/interface/EcalIntercalibErrorsRcd.h"
00034
00035 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
00036 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
00037
00038 #include "CondFormats/EcalObjects/interface/EcalTimeCalibErrors.h"
00039 #include "CondFormats/DataRecord/interface/EcalTimeCalibErrorsRcd.h"
00040
00041 #include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h"
00042 #include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h"
00043
00044 #include "CondFormats/EcalObjects/interface/EcalMGPAGainRatio.h"
00045 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00046 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
00047
00048 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
00049 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00050
00051 #include "CondFormats/EcalObjects/interface/EcalLaserAlphas.h"
00052 #include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
00053
00054 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatiosRef.h"
00055 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
00056
00057 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatios.h"
00058 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
00059
00060 #include "CondFormats/EcalObjects/interface/EcalClusterLocalContCorrParameters.h"
00061 #include "CondFormats/DataRecord/interface/EcalClusterLocalContCorrParametersRcd.h"
00062 #include "CondFormats/EcalObjects/interface/EcalClusterCrackCorrParameters.h"
00063 #include "CondFormats/DataRecord/interface/EcalClusterCrackCorrParametersRcd.h"
00064 #include "CondFormats/EcalObjects/interface/EcalClusterEnergyCorrectionParameters.h"
00065 #include "CondFormats/DataRecord/interface/EcalClusterEnergyCorrectionParametersRcd.h"
00066 #include "CondFormats/EcalObjects/interface/EcalClusterEnergyUncertaintyParameters.h"
00067 #include "CondFormats/DataRecord/interface/EcalClusterEnergyUncertaintyParametersRcd.h"
00068 #include "CondFormats/EcalObjects/interface/EcalClusterEnergyCorrectionObjectSpecificParameters.h"
00069 #include "CondFormats/DataRecord/interface/EcalClusterEnergyCorrectionObjectSpecificParametersRcd.h"
00070
00071 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00072 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00073
00074 #include "CondFormats/EcalObjects/interface/EcalSampleMask.h"
00075 #include "CondFormats/DataRecord/interface/EcalSampleMaskRcd.h"
00076
00077 #include "CLHEP/Matrix/Matrix.h"
00078
00079 using namespace std;
00080
00081 void EcalTrivialObjectAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context)
00082 {
00083 using namespace edm::eventsetup;
00084
00085 std::cout <<">>> EcalTrivialObjectAnalyzer: processing run "<<e.id().run() << " event: " << e.id().event() << std::endl;
00086
00087 edm::ESHandle<EcalPedestals> pPeds;
00088 context.get<EcalPedestalsRcd>().get(pPeds);
00089
00090
00091 edm::ESHandle<EcalADCToGeVConstant> pAgc;
00092 context.get<EcalADCToGeVConstantRcd>().get(pAgc);
00093 const EcalADCToGeVConstant* agc = pAgc.product();
00094 std::cout << "Global ADC->GeV scale: EB " << std::setprecision(6) << agc->getEBValue() << " GeV/ADC count"
00095 " EE " << std::setprecision(6) << agc->getEEValue() << " GeV/ADC count" << std::endl;
00096
00097
00098 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00099 int ieta = int( 1 + r1*85 );
00100 r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00101 int iphi = int( 1 + r1*20 );
00102
00103 EBDetId ebid(ieta,iphi);
00104 std::cout << "EcalTrivialObjectAnalyzer: using EBDetId: " << ebid << std::endl;
00105
00106 const EcalPedestals* myped=pPeds.product();
00107 EcalPedestals::const_iterator it = myped->find(ebid.rawId());
00108 if( it!=myped->end() ){
00109 std::cout << "EcalPedestal: "
00110 << " mean_x1: " << std::setprecision(8) << (*it).mean_x1 << " rms_x1: " << (*it).rms_x1
00111 << " mean_x6: " <<(*it).mean_x6 << " rms_x6: " << (*it).rms_x6
00112 << " mean_x12: " <<(*it).mean_x12 << " rms_x12: " << (*it).rms_x12
00113 << std::endl;
00114 } else {
00115 std::cout << "No pedestal found for this xtal! something wrong with EcalPedestals in your DB? "
00116 << std::endl;
00117 }
00118
00119
00120 edm::ESHandle<EcalWeightXtalGroups> pGrp;
00121 context.get<EcalWeightXtalGroupsRcd>().get(pGrp);
00122 const EcalWeightXtalGroups* grp = pGrp.product();
00123
00124 EcalXtalGroupsMap::const_iterator git = grp->getMap().find( ebid.rawId() );
00125 EcalXtalGroupId gid;
00126 if( git != grp->getMap().end() ) {
00127 std::cout << "XtalGroupId.id() = " << std::setprecision(3) << (*git).id() << std:: endl;
00128 gid = (*git);
00129 } else {
00130 std::cout << "No group id found for this crystal. something wrong with EcalWeightXtalGroups in your DB?"
00131 << std::endl;
00132 }
00133
00134
00135 edm::ESHandle<EcalGainRatios> pRatio;
00136 context.get<EcalGainRatiosRcd>().get(pRatio);
00137 const EcalGainRatios* gr = pRatio.product();
00138
00139 EcalGainRatioMap::const_iterator grit=gr->getMap().find(ebid.rawId());
00140 EcalMGPAGainRatio mgpa;
00141 if( grit!=gr->getMap().end() ){
00142 mgpa = (*grit);
00143
00144 std::cout << "EcalMGPAGainRatio: "
00145 << "gain 12/6 : " << std::setprecision(4) << mgpa.gain12Over6() << " gain 6/1: " << mgpa.gain6Over1()
00146 << std::endl;
00147 } else {
00148 std::cout << "No MGPA Gain Ratio found for this xtal! something wrong with EcalGainRatios in your DB? "
00149 << std::endl;
00150 }
00151
00152
00153 edm::ESHandle<EcalIntercalibConstants> pIcal;
00154 context.get<EcalIntercalibConstantsRcd>().get(pIcal);
00155 const EcalIntercalibConstants* ical = pIcal.product();
00156
00157 EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(ebid.rawId());
00158 EcalIntercalibConstant icalconst;
00159 if( icalit!=ical->getMap().end() ){
00160 icalconst = (*icalit);
00161
00162 std::cout << "EcalIntercalibConstant: "
00163 <<std::setprecision(6)
00164 << icalconst
00165 << std::endl;
00166 } else {
00167 std::cout << "No intercalib const found for this xtal! something wrong with EcalIntercalibConstants in your DB? "
00168 << std::endl;
00169 }
00170
00171
00172 edm::ESHandle<EcalIntercalibErrors> pIcalErr;
00173 context.get<EcalIntercalibErrorsRcd>().get(pIcalErr);
00174 const EcalIntercalibErrors* icalErr = pIcalErr.product();
00175
00176 EcalIntercalibErrorMap::const_iterator icalitErr=icalErr->getMap().find(ebid.rawId());
00177 EcalIntercalibError icalconstErr;
00178 if( icalitErr!=icalErr->getMap().end() ){
00179 icalconstErr = (*icalitErr);
00180
00181 std::cout << "EcalIntercalibError: "
00182 <<std::setprecision(6)
00183 << icalconstErr
00184 << std::endl;
00185 } else {
00186 std::cout << "No intercalib const found for this xtal! something wrong with EcalIntercalibErrors in your DB? "
00187 << std::endl;
00188 }
00189
00190
00191
00192 {
00193
00194 edm::ESHandle<EcalTimeCalibConstants> pIcal;
00195 context.get<EcalTimeCalibConstantsRcd>().get(pIcal);
00196 const EcalTimeCalibConstants* ical = pIcal.product();
00197
00198 EcalTimeCalibConstantMap::const_iterator icalit=ical->getMap().find(ebid.rawId());
00199 EcalTimeCalibConstant icalconst;
00200 if( icalit!=ical->getMap().end() ){
00201 icalconst = (*icalit);
00202
00203 std::cout << "EcalTimeCalibConstant: "
00204 <<std::setprecision(6)
00205 << icalconst
00206 << std::endl;
00207 } else {
00208 std::cout << "No intercalib const found for this xtal! something wrong with EcalTimeCalibConstants in your DB? "
00209 << std::endl;
00210 }
00211
00212
00213 edm::ESHandle<EcalTimeCalibErrors> pIcalErr;
00214 context.get<EcalTimeCalibErrorsRcd>().get(pIcalErr);
00215 const EcalTimeCalibErrors* icalErr = pIcalErr.product();
00216
00217 EcalTimeCalibErrorMap::const_iterator icalitErr=icalErr->getMap().find(ebid.rawId());
00218 EcalTimeCalibError icalconstErr;
00219 if( icalitErr!=icalErr->getMap().end() ){
00220 icalconstErr = (*icalitErr);
00221
00222 std::cout << "EcalTimeCalibError: "
00223 <<std::setprecision(6)
00224 << icalconstErr
00225 << std::endl;
00226 } else {
00227 std::cout << "No intercalib const found for this xtal! something wrong with EcalTimeCalibErrors in your DB? "
00228 << std::endl;
00229 }
00230 }
00231
00232
00233
00234
00235
00236 edm::ESHandle<EcalTimeOffsetConstant> pTOff;
00237 context.get<EcalTimeOffsetConstantRcd>().get(pTOff);
00238 const EcalTimeOffsetConstant* TOff = pTOff.product();
00239
00240 std::cout << "EcalTimeOffsetConstant: "
00241 << " EB " << TOff->getEBValue()
00242 << " EE " << TOff->getEEValue()
00243 << std::endl;
00244
00245
00246 std::cout <<"Fetching EcalTBWeights from DB " << std::endl;
00247 edm::ESHandle<EcalTBWeights> pWgts;
00248 context.get<EcalTBWeightsRcd>().get(pWgts);
00249 const EcalTBWeights* wgts = pWgts.product();
00250 std::cout << "EcalTBWeightMap.size(): " << std::setprecision(3) << wgts->getMap().size() << std::endl;
00251
00252
00253
00254
00255 EcalTBWeights::EcalTDCId tdcid(1);
00256
00257 std::cout << "Lookup EcalWeightSet for groupid: " << std::setprecision(3)
00258 << gid.id() << " and TDC id " << tdcid << std::endl;
00259 EcalTBWeights::EcalTBWeightMap::const_iterator wit = wgts->getMap().find( std::make_pair(gid,tdcid) );
00260 EcalWeightSet wset;
00261 if( wit != wgts->getMap().end() ) {
00262 wset = wit->second;
00263 std::cout << "check size of data members in EcalWeightSet" << std::endl;
00264
00265
00266
00267
00268 const EcalWeightSet::EcalWeightMatrix& mat1 = wit->second.getWeightsBeforeGainSwitch();
00269 const EcalWeightSet::EcalWeightMatrix& mat2 = wit->second.getWeightsAfterGainSwitch();
00270
00271
00272
00273
00274
00275 CLHEP::HepMatrix clmat1(3,10,0);
00276 CLHEP::HepMatrix clmat2(3,10,0);
00277 for(int irow=0; irow<3; irow++) {
00278 for(int icol=0; icol<10; icol++) {
00279 clmat1[irow][icol] = mat1(irow,icol);
00280 clmat2[irow][icol] = mat2(irow,icol);
00281 }
00282 }
00283 std::cout << "weight matrix before gain switch:" << std::endl;
00284 std::cout << clmat1 << std::endl;
00285 std::cout << "weight matrix after gain switch:" << std::endl;
00286 std::cout << clmat2 << std::endl;
00287
00288 } else {
00289 std::cout << "No weights found for EcalGroupId: " << gid.id() << " and EcalTDCId: " << tdcid << std::endl;
00290 }
00291
00292
00293 edm::ESHandle<EcalClusterLocalContCorrParameters> pLocalCont;
00294 context.get<EcalClusterLocalContCorrParametersRcd>().get(pLocalCont);
00295 const EcalClusterLocalContCorrParameters* paramLocalCont = pLocalCont.product();
00296 std::cout << "LocalContCorrParameters:";
00297 for ( EcalFunctionParameters::const_iterator it = paramLocalCont->params().begin(); it != paramLocalCont->params().end(); ++it ) {
00298 std::cout << " " << *it;
00299 }
00300 std::cout << "\n";
00301 edm::ESHandle<EcalClusterCrackCorrParameters> pCrack;
00302 context.get<EcalClusterCrackCorrParametersRcd>().get(pCrack);
00303 const EcalClusterCrackCorrParameters* paramCrack = pCrack.product();
00304 std::cout << "CrackCorrParameters:";
00305 for ( EcalFunctionParameters::const_iterator it = paramCrack->params().begin(); it != paramCrack->params().end(); ++it ) {
00306 std::cout << " " << *it;
00307 }
00308 std::cout << "\n";
00309 edm::ESHandle<EcalClusterEnergyCorrectionParameters> pEnergyCorrection;
00310 context.get<EcalClusterEnergyCorrectionParametersRcd>().get(pEnergyCorrection);
00311 const EcalClusterEnergyCorrectionParameters* paramEnergyCorrection = pEnergyCorrection.product();
00312 std::cout << "EnergyCorrectionParameters:";
00313 for ( EcalFunctionParameters::const_iterator it = paramEnergyCorrection->params().begin(); it != paramEnergyCorrection->params().end(); ++it ) {
00314 std::cout << " " << *it;
00315 }
00316 std::cout << "\n";
00317 edm::ESHandle<EcalClusterEnergyUncertaintyParameters> pEnergyUncertainty;
00318 context.get<EcalClusterEnergyUncertaintyParametersRcd>().get(pEnergyUncertainty);
00319 const EcalClusterEnergyUncertaintyParameters* paramEnergyUncertainty = pEnergyUncertainty.product();
00320 std::cout << "EnergyCorrectionParameters:";
00321 for ( EcalFunctionParameters::const_iterator it = paramEnergyUncertainty->params().begin(); it != paramEnergyUncertainty->params().end(); ++it ) {
00322 std::cout << " " << *it;
00323 }
00324 std::cout << "\n";
00325 edm::ESHandle<EcalClusterEnergyCorrectionObjectSpecificParameters> pEnergyCorrectionObjectSpecific;
00326 context.get<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>().get(pEnergyCorrectionObjectSpecific);
00327 const EcalClusterEnergyCorrectionObjectSpecificParameters* paramEnergyCorrectionObjectSpecific = pEnergyCorrectionObjectSpecific.product();
00328 std::cout << "EnergyCorrectionObjectSpecificParameters:";
00329 for ( EcalFunctionParameters::const_iterator it = paramEnergyCorrectionObjectSpecific->params().begin(); it != paramEnergyCorrectionObjectSpecific->params().end(); ++it ) {
00330 std::cout << " " << *it;
00331 }
00332 std::cout << "\n";
00333
00334
00335
00336
00337
00338 edm::ESHandle<EcalLaserAlphas> pAlpha;
00339 context.get<EcalLaserAlphasRcd>().get(pAlpha);
00340 const EcalLaserAlphas* lalpha = pAlpha.product();
00341
00342 EcalLaserAlphaMap::const_iterator lalphait;
00343 lalphait = lalpha->getMap().find(ebid.rawId());
00344 if( lalphait!=lalpha->getMap().end() ){
00345 std::cout << "EcalLaserAlpha: "
00346 <<std::setprecision(6)
00347 << (*lalphait)
00348 << std::endl;
00349 } else {
00350 std::cout << "No laser alpha found for this xtal! something wrong with EcalLaserAlphas in your DB? "
00351 << std::endl;
00352 }
00353
00354
00355 edm::ESHandle<EcalLaserAPDPNRatiosRef> pAPDPNRatiosRef;
00356 context.get<EcalLaserAPDPNRatiosRefRcd>().get(pAPDPNRatiosRef);
00357 const EcalLaserAPDPNRatiosRef* lref = pAPDPNRatiosRef.product();
00358
00359 EcalLaserAPDPNRatiosRef::const_iterator lrefit;
00360 lrefit = lref->getMap().find(ebid.rawId());
00361 if( lrefit!=lref->getMap().end() ){
00362 std::cout << "EcalLaserAPDPNRatiosRef: "
00363 <<std::setprecision(6)
00364 << (*lrefit)
00365 << std::endl;
00366 } else {
00367 std::cout << "No laser apd/pn ref found for this xtal! something wrong with EcalLaserAPDPNRatiosRef in your DB? "
00368 << std::endl;
00369 }
00370
00371
00372 edm::ESHandle<EcalLaserAPDPNRatios> pAPDPNRatios;
00373 context.get<EcalLaserAPDPNRatiosRcd>().get(pAPDPNRatios);
00374 const EcalLaserAPDPNRatios* lratio = pAPDPNRatios.product();
00375
00376 EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator lratioit;
00377 lratioit = lratio->getLaserMap().find(ebid.rawId());
00378 EcalLaserAPDPNRatios::EcalLaserAPDPNpair lratioconst;
00379
00380 if( lratioit!=lratio->getLaserMap().end() ){
00381 lratioconst = (*lratioit);
00382
00383 std::cout << "EcalLaserAPDPNRatios: "
00384
00385 << std::setprecision(6)
00386 << lratioconst.p1 << " " << lratioconst.p2
00387 << std::endl;
00388 } else {
00389 std::cout << "No laser apd/pn ratio found for this xtal! something wrong with EcalLaserAPDPNRatios in your DB? "
00390 << std::endl;
00391 }
00392
00393
00394 EcalLaserAPDPNRatios::EcalLaserTimeStamp ltimestamp;
00395 EcalLaserAPDPNRatios::EcalLaserTimeStampMap::const_iterator ltimeit;
00396 for (int i=1; i<=92; i++) {
00397 ltimestamp = lratio->getTimeMap()[i];
00398 std::cout << "i = " << std::setprecision(6) << i
00399 << ltimestamp.t1.value() << " " << ltimestamp.t2.value() << " : " ;
00400 }
00401 std::cout << "Tests finished." << std::endl;
00402
00403
00404 edm::ESHandle<EcalChannelStatus> pChannelStatus;
00405 context.get<EcalChannelStatusRcd>().get(pChannelStatus);
00406 const EcalChannelStatus *ch_status = pChannelStatus.product();
00407
00408 EcalChannelStatusMap::const_iterator chit;
00409 chit = ch_status->getMap().find(ebid.rawId());
00410 if( chit != ch_status->getMap().end() ){
00411 EcalChannelStatusCode ch_code = (*chit);
00412 std::cout << "EcalChannelStatus: "
00413 <<std::setprecision(6)
00414 << ch_code.getStatusCode()
00415 << std::endl;
00416 } else {
00417 std::cout << "No channel status found for this xtal! something wrong with EcalChannelStatus in your DB? "
00418 << std::endl;
00419 }
00420
00421
00422
00423
00424
00425 edm::ESHandle<EcalSampleMask> pSMask;
00426 context.get<EcalSampleMaskRcd>().get(pSMask);
00427 const EcalSampleMask* smask = pSMask.product();
00428 std::cout << "Sample Mask EB " << std::hex << smask->getEcalSampleMaskRecordEB()
00429 << " EE " << std::hex << smask->getEcalSampleMaskRecordEE() << std::endl;
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 }
00447