00001
00002
00003
00004
00005
00006 #include <iostream>
00007 #include <fstream>
00008
00009 #include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Utilities/interface/Exception.h"
00012
00013 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00014 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00015
00016
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019
00020 using namespace edm;
00021
00022 EcalTrivialConditionRetriever::EcalTrivialConditionRetriever( const edm::ParameterSet& ps)
00023 {
00024
00025
00026 adcToGeVEBConstant_ = ps.getUntrackedParameter<double>("adcToGeVEBConstant",0.035);
00027 adcToGeVEEConstant_ = ps.getUntrackedParameter<double>("adcToGeVEEConstant",0.060);
00028
00029 intercalibConstantMean_ = ps.getUntrackedParameter<double>("intercalibConstantMean",1.0);
00030 intercalibConstantSigma_ = ps.getUntrackedParameter<double>("intercalibConstantSigma",0.0);
00031
00032 intercalibErrorMean_ = ps.getUntrackedParameter<double>("IntercalibErrorMean",0.0);
00033
00034 laserAlphaMean_ = ps.getUntrackedParameter<double>("laserAlphaMean",1.55);
00035 laserAlphaSigma_ = ps.getUntrackedParameter<double>("laserAlphaSigma",0);
00036
00037 laserAPDPNRefMean_ = ps.getUntrackedParameter<double>("laserAPDPNRefMean",1.0);
00038 laserAPDPNRefSigma_ = ps.getUntrackedParameter<double>("laserAPDPNRefSigma",0.0);
00039
00040 laserAPDPNMean_ = ps.getUntrackedParameter<double>("laserAPDPNMean",1.0);
00041 laserAPDPNSigma_ = ps.getUntrackedParameter<double>("laserAPDPNSigma",0.0);
00042
00043 EBpedMeanX12_ = ps.getUntrackedParameter<double>("EBpedMeanX12", 200.);
00044 EBpedRMSX12_ = ps.getUntrackedParameter<double>("EBpedRMSX12", 1.10);
00045 EBpedMeanX6_ = ps.getUntrackedParameter<double>("EBpedMeanX6", 200.);
00046 EBpedRMSX6_ = ps.getUntrackedParameter<double>("EBpedRMSX6", 0.90);
00047 EBpedMeanX1_ = ps.getUntrackedParameter<double>("EBpedMeanX1", 200.);
00048 EBpedRMSX1_ = ps.getUntrackedParameter<double>("EBpedRMSX1", 0.62);
00049
00050 EEpedMeanX12_ = ps.getUntrackedParameter<double>("EEpedMeanX12", 200.);
00051 EEpedRMSX12_ = ps.getUntrackedParameter<double>("EEpedRMSX12", 2.50);
00052 EEpedMeanX6_ = ps.getUntrackedParameter<double>("EEpedMeanX6", 200.);
00053 EEpedRMSX6_ = ps.getUntrackedParameter<double>("EEpedRMSX6", 2.00);
00054 EEpedMeanX1_ = ps.getUntrackedParameter<double>("EEpedMeanX1", 200.);
00055 EEpedRMSX1_ = ps.getUntrackedParameter<double>("EEpedRMSX1", 1.40);
00056
00057 gainRatio12over6_ = ps.getUntrackedParameter<double>("gainRatio12over6", 2.0);
00058 gainRatio6over1_ = ps.getUntrackedParameter<double>("gainRatio6over1", 6.0);
00059
00060 getWeightsFromFile_ = ps.getUntrackedParameter<bool>("getWeightsFromFile",false);
00061
00062 nTDCbins_ = 1;
00063
00064 weightsForAsynchronousRunning_ = ps.getUntrackedParameter<bool>("weightsForTB",false);
00065
00066 if (weightsForAsynchronousRunning_)
00067 {
00068 getWeightsFromFile_ = true;
00069
00070 nTDCbins_ = 50;
00071 }
00072
00073 std::string path="CalibCalorimetry/EcalTrivialCondModules/data/";
00074 std::string weightType;
00075 std::ostringstream str;
00076
00077 if (!weightsForAsynchronousRunning_)
00078 str << "_CMS.txt" ;
00079 else
00080 str << "_TB.txt" ;
00081
00082 weightType = str.str();
00083
00084 amplWeightsFile_ = ps.getUntrackedParameter<std::string>("amplWeightsFile",path+"ampWeights"+weightType);
00085 amplWeightsAftFile_ = ps.getUntrackedParameter<std::string>("amplWeightsAftFile",path+"ampWeightsAfterGainSwitch"+weightType);
00086 pedWeightsFile_ = ps.getUntrackedParameter<std::string>("pedWeightsFile",path+"pedWeights"+weightType);
00087 pedWeightsAftFile_ = ps.getUntrackedParameter<std::string>("pedWeightsAftFile",path+"pedWeightsAfterGainSwitch"+weightType);
00088 jittWeightsFile_ = ps.getUntrackedParameter<std::string>("jittWeightsFile",path+"timeWeights"+weightType);
00089 jittWeightsAftFile_ = ps.getUntrackedParameter<std::string>("jittWeightsAftFile",path+"timeWeightsAfterGainSwitch"+weightType);
00090 chi2MatrixFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixFile",path+"chi2Matrix"+weightType);
00091 chi2MatrixAftFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixAftFile",path+"chi2MatrixAfterGainSwitch"+weightType);
00092
00093 amplWeights_.resize(nTDCbins_);
00094 amplWeightsAft_.resize(nTDCbins_);
00095 pedWeights_.resize(nTDCbins_);
00096 pedWeightsAft_.resize(nTDCbins_);
00097 jittWeights_.resize(nTDCbins_);
00098 jittWeightsAft_.resize(nTDCbins_);
00099 chi2Matrix_.resize(nTDCbins_);
00100 chi2MatrixAft_.resize(nTDCbins_);
00101
00102
00103 getWeightsFromConfiguration(ps);
00104
00105 producedEcalPedestals_ = ps.getUntrackedParameter<bool>("producedEcalPedestals",true);
00106 producedEcalWeights_ = ps.getUntrackedParameter<bool>("producedEcalWeights",true);
00107
00108 producedEcalGainRatios_ = ps.getUntrackedParameter<bool>("producedEcalGainRatios",true);
00109 producedEcalADCToGeVConstant_ = ps.getUntrackedParameter<bool>("producedEcalADCToGeVConstant",true);
00110
00111 verbose_ = ps.getUntrackedParameter<int>("verbose", 0);
00112
00113
00114
00115 if (producedEcalPedestals_)
00116 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalPedestals );
00117
00118 if (producedEcalWeights_) {
00119 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalWeightXtalGroups );
00120 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTBWeights );
00121 }
00122
00123 if (producedEcalGainRatios_)
00124 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalGainRatios );
00125
00126 if (producedEcalADCToGeVConstant_)
00127 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalADCToGeVConstant );
00128
00129
00130 producedEcalIntercalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstants",true);
00131 intercalibConstantsFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsFile","") ;
00132
00133 if (producedEcalIntercalibConstants_) {
00134 if(intercalibConstantsFile_ != "") {
00135 setWhatProduced (this, &EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration ) ;
00136 } else {
00137 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalIntercalibConstants ) ;
00138 }
00139 findingRecord<EcalIntercalibConstantsRcd> () ;
00140 }
00141
00142
00143 producedEcalIntercalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibErrors",true);
00144 intercalibErrorsFile_ = ps.getUntrackedParameter<std::string>("intercalibErrorsFile","") ;
00145
00146 if (producedEcalIntercalibErrors_) {
00147 if(intercalibErrorsFile_ != "") {
00148 setWhatProduced (this, &EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration ) ;
00149 } else {
00150 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalIntercalibErrors ) ;
00151 }
00152 findingRecord<EcalIntercalibErrorsRcd> () ;
00153 }
00154
00155
00156 producedEcalLaserCorrection_ = ps.getUntrackedParameter<bool>("producedEcalLaserCorrection",true);
00157 if (producedEcalLaserCorrection_) {
00158
00159 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAlphas ) ;
00160 findingRecord<EcalLaserAlphasRcd> () ;
00161 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef ) ;
00162 findingRecord<EcalLaserAPDPNRatiosRefRcd> () ;
00163 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios) ;
00164 findingRecord<EcalLaserAPDPNRatiosRcd> () ;
00165 }
00166
00167
00168 producedEcalChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalChannelStatus",true);
00169 channelStatusFile_ = ps.getUntrackedParameter<std::string>("channelStatusFile","");
00170
00171 if ( producedEcalChannelStatus_ ) {
00172 if ( channelStatusFile_ != "" ) {
00173 setWhatProduced( this, &EcalTrivialConditionRetriever::getChannelStatusFromConfiguration );
00174 } else {
00175 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalChannelStatus );
00176 }
00177 findingRecord<EcalChannelStatusRcd>();
00178 }
00179
00180
00181 if (producedEcalPedestals_) findingRecord<EcalPedestalsRcd>();
00182
00183 if (producedEcalWeights_) {
00184 findingRecord<EcalWeightXtalGroupsRcd>();
00185 findingRecord<EcalTBWeightsRcd>();
00186 }
00187
00188 if (producedEcalGainRatios_) findingRecord<EcalGainRatiosRcd>();
00189
00190 if (producedEcalADCToGeVConstant_) findingRecord<EcalADCToGeVConstantRcd>();
00191
00192 }
00193
00194 EcalTrivialConditionRetriever::~EcalTrivialConditionRetriever()
00195 {
00196 }
00197
00198
00199
00200
00201 void
00202 EcalTrivialConditionRetriever::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& rk,
00203 const edm::IOVSyncValue& iTime,
00204 edm::ValidityInterval& oValidity)
00205 {
00206 if(verbose_>=1) std::cout << "EcalTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
00207
00208 oValidity = edm::ValidityInterval( edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime() );
00209 }
00210
00211
00212 std::auto_ptr<EcalPedestals>
00213 EcalTrivialConditionRetriever::produceEcalPedestals( const EcalPedestalsRcd& ) {
00214 std::auto_ptr<EcalPedestals> peds = std::auto_ptr<EcalPedestals>( new EcalPedestals() );
00215 EcalPedestals::Item EBitem;
00216 EcalPedestals::Item EEitem;
00217
00218 EBitem.mean_x1 = EBpedMeanX1_;
00219 EBitem.rms_x1 = EBpedRMSX1_;
00220 EBitem.mean_x6 = EBpedMeanX6_;
00221 EBitem.rms_x6 = EBpedRMSX6_;
00222 EBitem.mean_x12 = EBpedMeanX12_;
00223 EBitem.rms_x12 = EBpedRMSX12_;
00224
00225 EEitem.mean_x1 = EEpedMeanX1_;
00226 EEitem.rms_x1 = EEpedRMSX1_;
00227 EEitem.mean_x6 = EEpedMeanX6_;
00228 EEitem.rms_x6 = EEpedRMSX6_;
00229 EEitem.mean_x12 = EEpedMeanX12_;
00230 EEitem.rms_x12 = EEpedRMSX12_;
00231
00232 for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
00233 if(iEta==0) continue;
00234 for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
00235
00236 if (EBDetId::validDetId(iEta,iPhi))
00237 {
00238 EBDetId ebdetid(iEta,iPhi);
00239 peds->insert(std::make_pair(ebdetid.rawId(),EBitem));
00240 }
00241 }
00242 }
00243
00244 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00245 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00246
00247 if (EEDetId::validDetId(iX,iY,1))
00248 {
00249 EEDetId eedetidpos(iX,iY,1);
00250 peds->insert(std::make_pair(eedetidpos.rawId(),EEitem));
00251 }
00252 if(EEDetId::validDetId(iX,iY,-1))
00253 {
00254 EEDetId eedetidneg(iX,iY,-1);
00255 peds->insert(std::make_pair(eedetidneg.rawId(),EEitem));
00256 }
00257 }
00258 }
00259
00260
00261 return peds;
00262 }
00263
00264 std::auto_ptr<EcalWeightXtalGroups>
00265 EcalTrivialConditionRetriever::produceEcalWeightXtalGroups( const EcalWeightXtalGroupsRcd& )
00266 {
00267 std::auto_ptr<EcalWeightXtalGroups> xtalGroups = std::auto_ptr<EcalWeightXtalGroups>( new EcalWeightXtalGroups() );
00268 EcalXtalGroupId defaultGroupId(1);
00269 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00270 if(ieta==0) continue;
00271 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00272
00273 if (EBDetId::validDetId(ieta,iphi))
00274 {
00275 EBDetId ebid(ieta,iphi);
00276
00277 xtalGroups->setValue(ebid.rawId(), defaultGroupId );
00278 }
00279 }
00280 }
00281
00282 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00283 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00284
00285 if (EEDetId::validDetId(iX,iY,1))
00286 {
00287 EEDetId eedetidpos(iX,iY,1);
00288 xtalGroups->setValue(eedetidpos.rawId(), defaultGroupId );
00289 }
00290 if(EEDetId::validDetId(iX,iY,-1))
00291 {
00292 EEDetId eedetidneg(iX,iY,-1);
00293 xtalGroups->setValue(eedetidneg.rawId(), defaultGroupId );
00294 }
00295 }
00296 }
00297 return xtalGroups;
00298 }
00299
00300 std::auto_ptr<EcalIntercalibConstants>
00301 EcalTrivialConditionRetriever::produceEcalIntercalibConstants( const EcalIntercalibConstantsRcd& )
00302 {
00303 std::auto_ptr<EcalIntercalibConstants> ical = std::auto_ptr<EcalIntercalibConstants>( new EcalIntercalibConstants() );
00304
00305 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00306 if(ieta==0) continue;
00307 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00308
00309 if (EBDetId::validDetId(ieta,iphi))
00310 {
00311 EBDetId ebid(ieta,iphi);
00312 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00313 ical->setValue( ebid.rawId(), intercalibConstantMean_ + r*intercalibConstantSigma_ );
00314 }
00315 }
00316 }
00317
00318 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00319 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00320
00321 if (EEDetId::validDetId(iX,iY,1))
00322 {
00323 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00324 EEDetId eedetidpos(iX,iY,1);
00325 ical->setValue( eedetidpos.rawId(), intercalibConstantMean_ + r*intercalibConstantSigma_ );
00326 }
00327 if(EEDetId::validDetId(iX,iY,-1))
00328 {
00329 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00330 EEDetId eedetidneg(iX,iY,-1);
00331 ical->setValue( eedetidneg.rawId(), intercalibConstantMean_ + r1*intercalibConstantSigma_ );
00332 }
00333 }
00334 }
00335
00336 return ical;
00337 }
00338
00339 std::auto_ptr<EcalIntercalibErrors>
00340 EcalTrivialConditionRetriever::produceEcalIntercalibErrors( const EcalIntercalibErrorsRcd& )
00341 {
00342 std::auto_ptr<EcalIntercalibErrors> ical = std::auto_ptr<EcalIntercalibErrors>( new EcalIntercalibErrors() );
00343
00344 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00345 if(ieta==0) continue;
00346 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00347
00348 if (EBDetId::validDetId(ieta,iphi))
00349 {
00350 EBDetId ebid(ieta,iphi);
00351 ical->setValue( ebid.rawId(), intercalibErrorMean_);
00352 }
00353 }
00354 }
00355
00356 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00357 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00358
00359 if (EEDetId::validDetId(iX,iY,1))
00360 {
00361 EEDetId eedetidpos(iX,iY,1);
00362 ical->setValue( eedetidpos.rawId(), intercalibErrorMean_ );
00363 }
00364 if(EEDetId::validDetId(iX,iY,-1))
00365 {
00366 EEDetId eedetidneg(iX,iY,-1);
00367 ical->setValue( eedetidneg.rawId(), intercalibErrorMean_ );
00368 }
00369 }
00370 }
00371
00372 return ical;
00373 }
00374
00375 std::auto_ptr<EcalGainRatios>
00376 EcalTrivialConditionRetriever::produceEcalGainRatios( const EcalGainRatiosRcd& )
00377 {
00378 std::auto_ptr<EcalGainRatios> gratio = std::auto_ptr<EcalGainRatios>( new EcalGainRatios() );
00379 EcalMGPAGainRatio gr;
00380 gr.setGain12Over6( gainRatio12over6_ );
00381 gr.setGain6Over1( gainRatio6over1_ );
00382
00383 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00384 if(ieta==0) continue;
00385 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00386 if (EBDetId::validDetId(ieta,iphi))
00387 {
00388 EBDetId ebid(ieta,iphi);
00389 gratio->setValue( ebid.rawId(), gr );
00390 }
00391 }
00392 }
00393
00394 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00395 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00396
00397 if (EEDetId::validDetId(iX,iY,1))
00398 {
00399 EEDetId eedetidpos(iX,iY,1);
00400 gratio->setValue( eedetidpos.rawId(), gr );
00401 }
00402 if (EEDetId::validDetId(iX,iY,-1))
00403 {
00404 EEDetId eedetidneg(iX,iY,-1);
00405 gratio->setValue( eedetidneg.rawId(), gr );
00406 }
00407 }
00408 }
00409
00410 return gratio;
00411 }
00412
00413 std::auto_ptr<EcalADCToGeVConstant>
00414 EcalTrivialConditionRetriever::produceEcalADCToGeVConstant( const EcalADCToGeVConstantRcd& )
00415 {
00416 return std::auto_ptr<EcalADCToGeVConstant>( new EcalADCToGeVConstant(adcToGeVEBConstant_,adcToGeVEEConstant_) );
00417 }
00418
00419 std::auto_ptr<EcalTBWeights>
00420 EcalTrivialConditionRetriever::produceEcalTBWeights( const EcalTBWeightsRcd& )
00421 {
00422
00423 std::auto_ptr<EcalTBWeights> tbwgt = std::auto_ptr<EcalTBWeights>( new EcalTBWeights() );
00424
00425
00426
00427
00428
00429 int igrp=1;
00430 for(int itdc=1; itdc<=nTDCbins_; ++itdc) {
00431
00432
00433
00434
00435 EcalWeightSet wgt;
00436
00437 EcalWeightSet::EcalWeightMatrix& mat1 = wgt.getWeightsBeforeGainSwitch();
00438 EcalWeightSet::EcalWeightMatrix& mat2 = wgt.getWeightsAfterGainSwitch();
00439
00440
00441
00442
00443
00444
00445
00460
00461 mat1.Place_in_row(amplWeights_[itdc-1],0,0);
00462 mat1.Place_in_row(pedWeights_[itdc-1],1,0);
00463 mat1.Place_in_row(jittWeights_[itdc-1],2,0);
00464
00465
00466 mat2.Place_in_row(amplWeightsAft_[itdc-1],0,0);
00467 mat2.Place_in_row(pedWeightsAft_[itdc-1],1,0);
00468 mat2.Place_in_row(jittWeightsAft_[itdc-1],2,0);
00469
00470
00471
00472 EcalWeightSet::EcalChi2WeightMatrix& mat3 = wgt.getChi2WeightsBeforeGainSwitch();
00473 EcalWeightSet::EcalChi2WeightMatrix& mat4 = wgt.getChi2WeightsAfterGainSwitch();
00474 mat3=chi2Matrix_[itdc-1];
00475 mat4=chi2MatrixAft_[itdc-1];
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500 tbwgt->setValue(std::make_pair(igrp,itdc), wgt);
00501 }
00502
00503 return tbwgt;
00504 }
00505
00506
00507
00508 std::auto_ptr<EcalLaserAlphas>
00509 EcalTrivialConditionRetriever::produceEcalLaserAlphas( const EcalLaserAlphasRcd& )
00510 {
00511 std::auto_ptr<EcalLaserAlphas> ical = std::auto_ptr<EcalLaserAlphas>( new EcalLaserAlphas() );
00512 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00513 if(ieta==0) continue;
00514 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00515 if (EBDetId::validDetId(ieta,iphi)) {
00516 EBDetId ebid(ieta,iphi);
00517 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00518 ical->setValue( ebid, laserAlphaMean_ + r*laserAlphaSigma_ );
00519 }
00520 }
00521 }
00522
00523 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00524 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00525
00526 if (EEDetId::validDetId(iX,iY,1)) {
00527 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00528 EEDetId eedetidpos(iX,iY,1);
00529 ical->setValue( eedetidpos, laserAlphaMean_ + r*laserAlphaSigma_ );
00530 }
00531
00532 if (EEDetId::validDetId(iX,iY,-1)) {
00533 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00534 EEDetId eedetidneg(iX,iY,-1);
00535 ical->setValue( eedetidneg, laserAlphaMean_ + r1*laserAlphaSigma_ );
00536 }
00537 }
00538 }
00539
00540 return ical;
00541 }
00542
00543
00544 std::auto_ptr<EcalLaserAPDPNRatiosRef>
00545 EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef( const EcalLaserAPDPNRatiosRefRcd& )
00546 {
00547 std::auto_ptr<EcalLaserAPDPNRatiosRef> ical = std::auto_ptr<EcalLaserAPDPNRatiosRef>( new EcalLaserAPDPNRatiosRef() );
00548 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00549 if(ieta==0) continue;
00550 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00551 if (EBDetId::validDetId(ieta,iphi)) {
00552 EBDetId ebid(ieta,iphi);
00553 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00554 ical->setValue( ebid, laserAPDPNRefMean_ + r*laserAPDPNRefSigma_ );
00555 }
00556 }
00557 }
00558
00559 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00560 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00561
00562 if (EEDetId::validDetId(iX,iY,1)) {
00563 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00564 EEDetId eedetidpos(iX,iY,1);
00565 ical->setValue( eedetidpos, laserAPDPNRefMean_ + r*laserAPDPNRefSigma_ );
00566 }
00567
00568 if (EEDetId::validDetId(iX,iY,-1)) {
00569 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00570 EEDetId eedetidneg(iX,iY,-1);
00571 ical->setValue( eedetidneg, laserAPDPNRefMean_ + r1*laserAPDPNRefSigma_ );
00572 }
00573 }
00574 }
00575
00576 return ical;
00577 }
00578
00579
00580 std::auto_ptr<EcalLaserAPDPNRatios>
00581 EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios( const EcalLaserAPDPNRatiosRcd& )
00582 {
00583
00584 std::auto_ptr<EcalLaserAPDPNRatios> ical = std::auto_ptr<EcalLaserAPDPNRatios>( new EcalLaserAPDPNRatios() );
00585 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00586 if(ieta==0) continue;
00587 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00588 if (EBDetId::validDetId(ieta,iphi)) {
00589 EBDetId ebid(ieta,iphi);
00590 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00591
00592 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00593 pairAPDPN.p1 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00594 pairAPDPN.p2 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00595 ical->setValue( ebid, pairAPDPN );
00596 }
00597 }
00598 }
00599
00600 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00601 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00602
00603 if (EEDetId::validDetId(iX,iY,1)) {
00604 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00605 EEDetId eedetidpos(iX,iY,1);
00606
00607 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00608 pairAPDPN.p1 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00609 pairAPDPN.p2 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00610 ical->setValue( eedetidpos, pairAPDPN );
00611 }
00612
00613 if (EEDetId::validDetId(iX,iY,-1)) {
00614 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00615 EEDetId eedetidneg(iX,iY,-1);
00616
00617 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00618 pairAPDPN.p1 = laserAPDPNMean_ + r1*laserAPDPNSigma_;
00619 pairAPDPN.p2 = laserAPDPNMean_ + r1*laserAPDPNSigma_;
00620 ical->setValue( eedetidneg, pairAPDPN );
00621 }
00622 }
00623 }
00624
00625 EcalLaserAPDPNRatios::EcalLaserTimeStamp TimeStamp;
00626
00627 for(int i=0; i<92; i++){
00628 TimeStamp.t1 = 1;
00629 TimeStamp.t2 = edm::Timestamp::endOfTime().value();
00630 ical->setTime( i, TimeStamp );
00631 }
00632
00633 return ical;
00634
00635 }
00636
00637
00638 void EcalTrivialConditionRetriever::getWeightsFromConfiguration(const edm::ParameterSet& ps)
00639 {
00640
00641 std::vector < std::vector<double> > amplwgtv(nTDCbins_);
00642
00643 if (!getWeightsFromFile_ && nTDCbins_ == 1)
00644 {
00645 std::vector<double> vampl;
00646
00647 vampl.push_back( -0.33333 );
00648 vampl.push_back( -0.33333 );
00649 vampl.push_back( -0.33333 );
00650 vampl.push_back( 0. );
00651 vampl.push_back( 0. );
00652 vampl.push_back( 1. );
00653 vampl.push_back( 0. );
00654 vampl.push_back( 0. );
00655 vampl.push_back( 0. );
00656 vampl.push_back( 0. );
00657 amplwgtv[0]= ps.getUntrackedParameter< std::vector<double> >("amplWeights", vampl);
00658 }
00659 else if (getWeightsFromFile_)
00660 {
00661 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights from file " << edm::FileInPath(amplWeightsFile_).fullPath().c_str() ;
00662 std::ifstream amplFile(edm::FileInPath(amplWeightsFile_).fullPath().c_str());
00663 int tdcBin=0;
00664 while (!amplFile.eof() && tdcBin < nTDCbins_)
00665 {
00666 for(int j = 0; j < 10; ++j) {
00667 float ww;
00668 amplFile >> ww;
00669 amplwgtv[tdcBin].push_back(ww);
00670 }
00671 ++tdcBin;
00672 }
00673 assert (tdcBin == nTDCbins_);
00674
00675 }
00676 else
00677 {
00678
00679 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00680 throw cms::Exception("WrongConfig");
00681 }
00682
00683
00684 for (int i=0;i<nTDCbins_;i++)
00685 {
00686 assert(amplwgtv[i].size() == 10);
00687 int j=0;
00688 for(std::vector<double>::const_iterator it = amplwgtv[i].begin(); it != amplwgtv[i].end(); ++it)
00689 {
00690 (amplWeights_[i])[j]=*it;
00691 j++;
00692 }
00693 }
00694
00695
00696 std::vector < std::vector<double> > amplwgtvAftGain(nTDCbins_);
00697
00698 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
00699 {
00700 std::vector<double> vamplAftGain;
00701 vamplAftGain.push_back( 0. );
00702 vamplAftGain.push_back( 0. );
00703 vamplAftGain.push_back( 0. );
00704 vamplAftGain.push_back( 0. );
00705 vamplAftGain.push_back( 0. );
00706 vamplAftGain.push_back( 1. );
00707 vamplAftGain.push_back( 0. );
00708 vamplAftGain.push_back( 0. );
00709 vamplAftGain.push_back( 0. );
00710 vamplAftGain.push_back( 0. );
00711 amplwgtvAftGain[0] = ps.getUntrackedParameter< std::vector<double> >("amplWeightsAftGain", vamplAftGain);
00712 }
00713 else if (getWeightsFromFile_)
00714 {
00715
00716 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights aftre gain switch from file " << edm::FileInPath(amplWeightsAftFile_).fullPath().c_str() ;
00717 std::ifstream amplFile(edm::FileInPath(amplWeightsAftFile_).fullPath().c_str());
00718 int tdcBin=0;
00719 while (!amplFile.eof() && tdcBin < nTDCbins_)
00720 {
00721 for(int j = 0; j < 10; ++j) {
00722 float ww;
00723 amplFile >> ww;
00724 amplwgtvAftGain[tdcBin].push_back(ww);
00725 }
00726 ++tdcBin;
00727 }
00728 assert (tdcBin == nTDCbins_);
00729 }
00730 else
00731 {
00732
00733 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00734 throw cms::Exception("WrongConfig");
00735 }
00736
00737 for (int i=0;i<nTDCbins_;i++)
00738 {
00739 assert(amplwgtvAftGain[i].size() == 10);
00740 int j=0;
00741 for(std::vector<double>::const_iterator it = amplwgtvAftGain[i].begin(); it != amplwgtvAftGain[i].end(); ++it) {
00742 (amplWeightsAft_[i])[j]=*it;
00743 j++;
00744 }
00745 }
00746
00747
00748
00749 std::vector< std::vector<double> > pedwgtv(nTDCbins_);
00750
00751 if (!getWeightsFromFile_ && nTDCbins_ == 1)
00752 {
00753 std::vector<double> vped;
00754 vped.push_back( 0.33333 );
00755 vped.push_back( 0.33333 );
00756 vped.push_back( 0.33333 );
00757 vped.push_back( 0. );
00758 vped.push_back( 0. );
00759 vped.push_back( 0. );
00760 vped.push_back( 0. );
00761 vped.push_back( 0. );
00762 vped.push_back( 0. );
00763 vped.push_back( 0. );
00764 pedwgtv[0] = ps.getUntrackedParameter< std::vector<double> >("pedWeights", vped);
00765 }
00766 else if (getWeightsFromFile_)
00767 {
00768
00769 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal weights from file " << edm::FileInPath(pedWeightsFile_).fullPath().c_str() ;
00770 std::ifstream pedFile(edm::FileInPath(pedWeightsFile_).fullPath().c_str());
00771 int tdcBin=0;
00772 while (!pedFile.eof() && tdcBin < nTDCbins_)
00773 {
00774 for(int j = 0; j < 10; ++j) {
00775 float ww;
00776 pedFile >> ww;
00777 pedwgtv[tdcBin].push_back(ww);
00778 }
00779 ++tdcBin;
00780 }
00781 assert (tdcBin == nTDCbins_);
00782 }
00783 else
00784 {
00785
00786 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00787 throw cms::Exception("WrongConfig");
00788 }
00789
00790 for (int i=0;i<nTDCbins_;i++)
00791 {
00792 assert(pedwgtv[i].size() == 10);
00793 int j=0;
00794 for(std::vector<double>::const_iterator it = pedwgtv[i].begin(); it != pedwgtv[i].end(); ++it) {
00795 (pedWeights_[i])[j] = *it;
00796 j++;
00797 }
00798 }
00799
00800 std::vector< std::vector<double> > pedwgtvaft(nTDCbins_);
00801
00802 if (!getWeightsFromFile_ && nTDCbins_ == 1)
00803 {
00804 std::vector<double> vped;
00805 vped.push_back( 0. );
00806 vped.push_back( 0. );
00807 vped.push_back( 0. );
00808 vped.push_back( 0. );
00809 vped.push_back( 0. );
00810 vped.push_back( 0. );
00811 vped.push_back( 0. );
00812 vped.push_back( 0. );
00813 vped.push_back( 0. );
00814 vped.push_back( 0. );
00815 pedwgtvaft[0] = ps.getUntrackedParameter< std::vector<double> >("pedWeightsAft", vped);
00816 }
00817 else if (getWeightsFromFile_)
00818 {
00819
00820 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal after gain switch weights from file " << edm::FileInPath(pedWeightsAftFile_).fullPath().c_str() ;
00821 std::ifstream pedFile(edm::FileInPath(pedWeightsAftFile_).fullPath().c_str());
00822 int tdcBin=0;
00823 while (!pedFile.eof() && tdcBin < nTDCbins_)
00824 {
00825 for(int j = 0; j < 10; ++j) {
00826 float ww;
00827 pedFile >> ww;
00828 pedwgtvaft[tdcBin].push_back(ww);
00829 }
00830 ++tdcBin;
00831 }
00832 assert (tdcBin == nTDCbins_);
00833 }
00834 else
00835 {
00836
00837 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00838 throw cms::Exception("WrongConfig");
00839 }
00840
00841 for (int i=0;i<nTDCbins_;i++)
00842 {
00843 assert(pedwgtvaft[i].size() == 10);
00844 int j=0;
00845 for(std::vector<double>::const_iterator it = pedwgtvaft[i].begin(); it != pedwgtvaft[i].end(); ++it) {
00846 (pedWeightsAft_[i])[j]=*it;
00847 j++;
00848 }
00849 }
00850
00851
00852
00853
00854
00855 std::vector< std::vector<double> > jittwgtv(nTDCbins_);
00856
00857 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
00858 {
00859 std::vector<double> vjitt;
00860 vjitt.push_back( 0.04066309 );
00861 vjitt.push_back( 0.04066309 );
00862 vjitt.push_back( 0.04066309 );
00863 vjitt.push_back( 0.000 );
00864 vjitt.push_back( 1.325176 );
00865 vjitt.push_back( -0.04997078 );
00866 vjitt.push_back( -0.504338 );
00867 vjitt.push_back( -0.5024844 );
00868 vjitt.push_back( -0.3903718 );
00869 vjitt.push_back( 0.000 );
00870 jittwgtv[0] = ps.getUntrackedParameter< std::vector<double> >("jittWeights", vjitt);
00871 }
00872 else if (getWeightsFromFile_)
00873 {
00874
00875 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter weights from file " << edm::FileInPath(jittWeightsFile_).fullPath().c_str() ;
00876 std::ifstream jittFile(edm::FileInPath(jittWeightsFile_).fullPath().c_str());
00877 int tdcBin=0;
00878 while (!jittFile.eof() && tdcBin < nTDCbins_)
00879 {
00880 for(int j = 0; j < 10; ++j) {
00881 float ww;
00882 jittFile >> ww;
00883 jittwgtv[tdcBin].push_back(ww);
00884 }
00885 ++tdcBin;
00886 }
00887 assert (tdcBin == nTDCbins_);
00888 }
00889 else
00890 {
00891
00892 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00893 throw cms::Exception("WrongConfig");
00894 }
00895
00896 for (int i=0;i<nTDCbins_;i++)
00897 {
00898 assert(jittwgtv[i].size() == 10);
00899 int j=0;
00900 for(std::vector<double>::const_iterator it = jittwgtv[i].begin(); it != jittwgtv[i].end(); ++it) {
00901 (jittWeights_[i])[j]= *it;
00902 j++;
00903 }
00904 }
00905
00906 std::vector< std::vector<double> > jittwgtvaft(nTDCbins_);
00907
00908 if (!getWeightsFromFile_ && nTDCbins_ == 1)
00909 {
00910 std::vector<double> vjitt;
00911 vjitt.push_back( 0. );
00912 vjitt.push_back( 0. );
00913 vjitt.push_back( 0. );
00914 vjitt.push_back( 0. );
00915 vjitt.push_back( 1.097871 );
00916 vjitt.push_back( -0.04551035 );
00917 vjitt.push_back( -0.4159156 );
00918 vjitt.push_back( -0.4185352 );
00919 vjitt.push_back( -0.3367127 );
00920 vjitt.push_back( 0. );
00921 jittwgtvaft[0] = ps.getUntrackedParameter< std::vector<double> >("jittWeightsAft", vjitt);
00922 }
00923 else if (getWeightsFromFile_)
00924 {
00925
00926 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter after gain switch weights from file " << edm::FileInPath(jittWeightsAftFile_).fullPath().c_str() ;
00927 std::ifstream jittFile(edm::FileInPath(jittWeightsAftFile_).fullPath().c_str());
00928 int tdcBin=0;
00929 while (!jittFile.eof() && tdcBin < nTDCbins_)
00930 {
00931 for(int j = 0; j < 10; ++j) {
00932 float ww;
00933 jittFile >> ww;
00934 jittwgtvaft[tdcBin].push_back(ww);
00935 }
00936 ++tdcBin;
00937 }
00938 assert (tdcBin == nTDCbins_);
00939 }
00940 else
00941 {
00942
00943 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00944 throw cms::Exception("WrongConfig");
00945 }
00946
00947 for (int i=0;i<nTDCbins_;i++)
00948 {
00949 assert(jittwgtvaft[i].size() == 10);
00950 int j=0;
00951 for(std::vector<double>::const_iterator it = jittwgtvaft[i].begin(); it != jittwgtvaft[i].end(); ++it) {
00952 (jittWeightsAft_[i])[j]= *it;
00953 j++;
00954 }
00955 }
00956
00957
00958 std::vector< EcalWeightSet::EcalChi2WeightMatrix > chi2Matrix(nTDCbins_);
00959 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
00960 {
00961
00962
00963
00964
00965 chi2Matrix[0](0,0) = 0.694371;
00966 chi2Matrix[0](0,1) = -0.305629;
00967 chi2Matrix[0](0,2) = -0.305629;
00968 chi2Matrix[0](0,3) = 0.;
00969 chi2Matrix[0](0,4) = 0.;
00970 chi2Matrix[0](0,5) = 0.;
00971 chi2Matrix[0](0,6) = 0.;
00972 chi2Matrix[0](0,7) = 0.;
00973 chi2Matrix[0](0,8) = 0.;
00974 chi2Matrix[0](0,9) = 0.;
00975 chi2Matrix[0](1,0) = -0.305629;
00976 chi2Matrix[0](1,1) = 0.694371;
00977 chi2Matrix[0](1,2) = -0.305629;
00978 chi2Matrix[0](1,3) = 0.;
00979 chi2Matrix[0](1,4) = 0.;
00980 chi2Matrix[0](1,5) = 0.;
00981 chi2Matrix[0](1,6) = 0.;
00982 chi2Matrix[0](1,7) = 0.;
00983 chi2Matrix[0](1,8) = 0.;
00984 chi2Matrix[0](1,9) = 0.;
00985 chi2Matrix[0](2,0) = -0.305629;
00986 chi2Matrix[0](2,1) = -0.305629;
00987 chi2Matrix[0](2,2) = 0.694371;
00988 chi2Matrix[0](2,3) = 0.;
00989 chi2Matrix[0](2,4) = 0.;
00990 chi2Matrix[0](2,5) = 0.;
00991 chi2Matrix[0](2,6) = 0.;
00992 chi2Matrix[0](2,7) = 0.;
00993 chi2Matrix[0](2,8) = 0.;
00994 chi2Matrix[0](2,9) = 0.;
00995 chi2Matrix[0](3,0) = 0.;
00996 chi2Matrix[0](3,1) = 0.;
00997 chi2Matrix[0](3,2) = 0.;
00998 chi2Matrix[0](3,3) = 0.;
00999 chi2Matrix[0](3,4) = 0.;
01000 chi2Matrix[0](3,5) = 0.;
01001 chi2Matrix[0](3,6) = 0.;
01002 chi2Matrix[0](3,7) = 0.;
01003 chi2Matrix[0](3,8) = 0.;
01004 chi2Matrix[0](3,9) = 0.;
01005 chi2Matrix[0](4,0) = 0.;
01006 chi2Matrix[0](4,1) = 0.;
01007 chi2Matrix[0](4,2) = 0.;
01008 chi2Matrix[0](4,3) = 0.;
01009 chi2Matrix[0](4,4) = 0.8027116;
01010 chi2Matrix[0](4,5) = -0.2517103;
01011 chi2Matrix[0](4,6) = -0.2232882;
01012 chi2Matrix[0](4,7) = -0.1716192;
01013 chi2Matrix[0](4,8) = -0.1239006;
01014 chi2Matrix[0](4,9) = 0.;
01015 chi2Matrix[0](5,0) = 0.;
01016 chi2Matrix[0](5,1) = 0.;
01017 chi2Matrix[0](5,2) = 0.;
01018 chi2Matrix[0](5,3) = 0.;
01019 chi2Matrix[0](5,4) = -0.2517103;
01020 chi2Matrix[0](5,5) = 0.6528964;
01021 chi2Matrix[0](5,6) = -0.2972839;
01022 chi2Matrix[0](5,7) = -0.2067162;
01023 chi2Matrix[0](5,8) = -0.1230729;
01024 chi2Matrix[0](5,9) = 0.;
01025 chi2Matrix[0](6,0) = 0.;
01026 chi2Matrix[0](6,1) = 0.;
01027 chi2Matrix[0](6,2) = 0.;
01028 chi2Matrix[0](6,3) = 0.;
01029 chi2Matrix[0](6,4) = -0.2232882;
01030 chi2Matrix[0](6,5) = -0.2972839;
01031 chi2Matrix[0](6,6) = 0.7413607;
01032 chi2Matrix[0](6,7) = -0.1883866;
01033 chi2Matrix[0](6,8) = -0.1235052;
01034 chi2Matrix[0](6,9) = 0.;
01035 chi2Matrix[0](7,0) = 0.;
01036 chi2Matrix[0](7,1) = 0.;
01037 chi2Matrix[0](7,2) = 0.;
01038 chi2Matrix[0](7,3) = 0.;
01039 chi2Matrix[0](7,4) = -0.1716192;
01040 chi2Matrix[0](7,5) = -0.2067162;
01041 chi2Matrix[0](7,6) = -0.1883866;
01042 chi2Matrix[0](7,7) = 0.844935;
01043 chi2Matrix[0](7,8) = -0.124291;
01044 chi2Matrix[0](7,9) = 0.;
01045 chi2Matrix[0](8,0) = 0.;
01046 chi2Matrix[0](8,1) = 0.;
01047 chi2Matrix[0](8,2) = 0.;
01048 chi2Matrix[0](8,3) = 0.;
01049 chi2Matrix[0](8,4) = -0.1239006;
01050 chi2Matrix[0](8,5) = -0.1230729;
01051 chi2Matrix[0](8,6) = -0.1235052;
01052 chi2Matrix[0](8,7) = -0.124291;
01053 chi2Matrix[0](8,8) = 0.8749833;
01054 chi2Matrix[0](8,9) = 0.;
01055 chi2Matrix[0](9,0) = 0.;
01056 chi2Matrix[0](9,1) = 0.;
01057 chi2Matrix[0](9,2) = 0.;
01058 chi2Matrix[0](9,3) = 0.;
01059 chi2Matrix[0](9,4) = 0.;
01060 chi2Matrix[0](9,5) = 0.;
01061 chi2Matrix[0](9,6) = 0.;
01062 chi2Matrix[0](9,7) = 0.;
01063 chi2Matrix[0](9,8) = 0.;
01064 chi2Matrix[0](9,9) = 0.;
01065 }
01066 else if (getWeightsFromFile_)
01067 {
01068
01069 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading chi2Matrix from file " << edm::FileInPath(chi2MatrixFile_).fullPath().c_str() ;
01070 std::ifstream chi2MatrixFile(edm::FileInPath(chi2MatrixFile_).fullPath().c_str());
01071 int tdcBin=0;
01072 while (!chi2MatrixFile.eof() && tdcBin < nTDCbins_)
01073 {
01074
01075 for(int j = 0; j < 10; ++j) {
01076 for(int l = 0; l < 10; ++l) {
01077 float ww;
01078 chi2MatrixFile >> ww;
01079 chi2Matrix[tdcBin](j,l)=ww;
01080 }
01081 }
01082 ++tdcBin;
01083 }
01084 assert (tdcBin == nTDCbins_);
01085 }
01086 else
01087 {
01088
01089 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01090 throw cms::Exception("WrongConfig");
01091 }
01092
01093
01094
01095
01096 chi2Matrix_ = chi2Matrix;
01097
01098
01099 std::vector< EcalWeightSet::EcalChi2WeightMatrix > chi2MatrixAft(nTDCbins_);
01100 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
01101 {
01102
01103
01104
01105
01106 chi2MatrixAft[0](0,0) = 0.;
01107 chi2MatrixAft[0](0,1) = 0.;
01108 chi2MatrixAft[0](0,2) = 0.;
01109 chi2MatrixAft[0](0,3) = 0.;
01110 chi2MatrixAft[0](0,4) = 0.;
01111 chi2MatrixAft[0](0,5) = 0.;
01112 chi2MatrixAft[0](0,6) = 0.;
01113 chi2MatrixAft[0](0,7) = 0.;
01114 chi2MatrixAft[0](0,8) = 0.;
01115 chi2MatrixAft[0](0,9) = 0.;
01116 chi2MatrixAft[0](1,0) = 0.;
01117 chi2MatrixAft[0](1,1) = 0.;
01118 chi2MatrixAft[0](1,2) = 0.;
01119 chi2MatrixAft[0](1,3) = 0.;
01120 chi2MatrixAft[0](1,4) = 0.;
01121 chi2MatrixAft[0](1,5) = 0.;
01122 chi2MatrixAft[0](1,6) = 0.;
01123 chi2MatrixAft[0](1,7) = 0.;
01124 chi2MatrixAft[0](1,8) = 0.;
01125 chi2MatrixAft[0](1,9) = 0.;
01126 chi2MatrixAft[0](2,0) = 0.;
01127 chi2MatrixAft[0](2,1) = 0.;
01128 chi2MatrixAft[0](2,2) = 0.;
01129 chi2MatrixAft[0](2,3) = 0.;
01130 chi2MatrixAft[0](2,4) = 0.;
01131 chi2MatrixAft[0](2,5) = 0.;
01132 chi2MatrixAft[0](2,6) = 0.;
01133 chi2MatrixAft[0](2,7) = 0.;
01134 chi2MatrixAft[0](2,8) = 0.;
01135 chi2MatrixAft[0](2,9) = 0.;
01136 chi2MatrixAft[0](3,0) = 0.;
01137 chi2MatrixAft[0](3,1) = 0.;
01138 chi2MatrixAft[0](3,2) = 0.;
01139 chi2MatrixAft[0](3,3) = 0.;
01140 chi2MatrixAft[0](3,4) = 0.;
01141 chi2MatrixAft[0](3,5) = 0.;
01142 chi2MatrixAft[0](3,6) = 0.;
01143 chi2MatrixAft[0](3,7) = 0.;
01144 chi2MatrixAft[0](3,8) = 0.;
01145 chi2MatrixAft[0](3,9) = 0.;
01146 chi2MatrixAft[0](4,0) = 0.;
01147 chi2MatrixAft[0](4,1) = 0.;
01148 chi2MatrixAft[0](4,2) = 0.;
01149 chi2MatrixAft[0](4,3) = 0.;
01150 chi2MatrixAft[0](4,4) = 0.8030884;
01151 chi2MatrixAft[0](4,5) = -0.2543541;
01152 chi2MatrixAft[0](4,6) = -0.2243544;
01153 chi2MatrixAft[0](4,7) = -0.1698177;
01154 chi2MatrixAft[0](4,8) = -0.1194506;
01155 chi2MatrixAft[0](4,9) = 0.;
01156 chi2MatrixAft[0](5,0) = 0.;
01157 chi2MatrixAft[0](5,1) = 0.;
01158 chi2MatrixAft[0](5,2) = 0.;
01159 chi2MatrixAft[0](5,3) = 0.;
01160 chi2MatrixAft[0](5,4) = -0.2543541;
01161 chi2MatrixAft[0](5,5) = 0.6714465;
01162 chi2MatrixAft[0](5,6) = -0.2898025;
01163 chi2MatrixAft[0](5,7) = -0.2193564;
01164 chi2MatrixAft[0](5,8) = -0.1542964;
01165 chi2MatrixAft[0](5,9) = 0.;
01166 chi2MatrixAft[0](6,0) = 0.;
01167 chi2MatrixAft[0](6,1) = 0.;
01168 chi2MatrixAft[0](6,2) = 0.;
01169 chi2MatrixAft[0](6,3) = 0.;
01170 chi2MatrixAft[0](6,4) = -0.2243544;
01171 chi2MatrixAft[0](6,5) = -0.2898025;
01172 chi2MatrixAft[0](6,6) = 0.7443781;
01173 chi2MatrixAft[0](6,7) = -0.1934846;
01174 chi2MatrixAft[0](6,8) = -0.136098;
01175 chi2MatrixAft[0](6,9) = 0.;
01176 chi2MatrixAft[0](7,0) = 0.;
01177 chi2MatrixAft[0](7,1) = 0.;
01178 chi2MatrixAft[0](7,2) = 0.;
01179 chi2MatrixAft[0](7,3) = 0.;
01180 chi2MatrixAft[0](7,4) = -0.1698177;
01181 chi2MatrixAft[0](7,5) = -0.2193564;
01182 chi2MatrixAft[0](7,6) = -0.1934846;
01183 chi2MatrixAft[0](7,7) = 0.8535482;
01184 chi2MatrixAft[0](7,8) = -0.1030149;
01185 chi2MatrixAft[0](7,9) = 0.;
01186 chi2MatrixAft[0](8,0) = 0.;
01187 chi2MatrixAft[0](8,1) = 0.;
01188 chi2MatrixAft[0](8,2) = 0.;
01189 chi2MatrixAft[0](8,3) = 0.;
01190 chi2MatrixAft[0](8,4) = -0.1194506;
01191 chi2MatrixAft[0](8,5) = -0.1542964;
01192 chi2MatrixAft[0](8,6) = -0.136098;
01193 chi2MatrixAft[0](8,7) = -0.1030149;
01194 chi2MatrixAft[0](8,8) = 0.9275388;
01195 chi2MatrixAft[0](8,9) = 0.;
01196 chi2MatrixAft[0](9,0) = 0.;
01197 chi2MatrixAft[0](9,1) = 0.;
01198 chi2MatrixAft[0](9,2) = 0.;
01199 chi2MatrixAft[0](9,3) = 0.;
01200 chi2MatrixAft[0](9,4) = 0.;
01201 chi2MatrixAft[0](9,5) = 0.;
01202 chi2MatrixAft[0](9,6) = 0.;
01203 chi2MatrixAft[0](9,7) = 0.;
01204 chi2MatrixAft[0](9,8) = 0.;
01205 chi2MatrixAft[0](9,9) = 0.;
01206 }
01207 else if (getWeightsFromFile_)
01208 {
01209
01210 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading chi2MatrixAft from file " << edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str() ;
01211 std::ifstream chi2MatrixAftFile(edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str());
01212 int tdcBin=0;
01213 while (!chi2MatrixAftFile.eof() && tdcBin < nTDCbins_)
01214 {
01215
01216 for(int j = 0; j < 10; ++j) {
01217 for(int l = 0; l < 10; ++l) {
01218 float ww;
01219 chi2MatrixAftFile >> ww;
01220 chi2MatrixAft[tdcBin](j,l)=ww;
01221 }
01222 }
01223 ++tdcBin;
01224 }
01225 assert (tdcBin == nTDCbins_);
01226 }
01227 else
01228 {
01229
01230 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01231 throw cms::Exception("WrongConfig");
01232 }
01233
01234
01235
01236
01237 chi2MatrixAft_ = chi2MatrixAft;
01238
01239
01240 }
01241
01242
01243
01244
01245 std::auto_ptr<EcalChannelStatus>
01246 EcalTrivialConditionRetriever::getChannelStatusFromConfiguration (const EcalChannelStatusRcd&)
01247 {
01248
01249 std::auto_ptr<EcalChannelStatus> ecalStatus = std::auto_ptr<EcalChannelStatus>( new EcalChannelStatus() );
01250
01251
01252
01253
01254
01255 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01256 if(ieta==0) continue;
01257 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01258 if (EBDetId::validDetId(ieta,iphi)) {
01259 EBDetId ebid(ieta,iphi);
01260 ecalStatus->setValue( ebid, 0 );
01261 }
01262 }
01263 }
01264
01265 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01266 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01267
01268 if (EEDetId::validDetId(iX,iY,1)) {
01269 EEDetId eedetidpos(iX,iY,1);
01270 ecalStatus->setValue( eedetidpos, 0 );
01271 }
01272 if (EEDetId::validDetId(iX,iY,-1)) {
01273 EEDetId eedetidneg(iX,iY,-1);
01274 ecalStatus->setValue( eedetidneg, 0 );
01275 }
01276 }
01277 }
01278
01279
01280
01281
01282
01283 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
01284 std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
01285 if ( !statusFile.good() ) {
01286 edm::LogError ("EcalTrivialConditionRetriever")
01287 << "*** Problems opening file: " << channelStatusFile_ ;
01288 throw cms::Exception ("Cannot open ECAL channel status file") ;
01289 }
01290
01291 std::string EcalSubDet;
01292 std::string str;
01293 int hashIndex(0);
01294 int status(0);
01295
01296 while (!statusFile.eof())
01297 {
01298 statusFile >> EcalSubDet;
01299 if (EcalSubDet!=std::string("EB") && EcalSubDet!=std::string("EE"))
01300 {
01301 std::getline(statusFile,str);
01302 continue;
01303 }
01304 else
01305 {
01306 statusFile>> hashIndex >> status;
01307 }
01308
01309
01310 if(EcalSubDet==std::string("EB"))
01311 {
01312 EBDetId ebid = EBDetId::unhashIndex(hashIndex);
01313 ecalStatus->setValue( ebid, status );
01314 }
01315 else if(EcalSubDet==std::string("EE"))
01316 {
01317 EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
01318 ecalStatus->setValue( eedetid, status );
01319 }
01320 else
01321 {
01322 edm::LogError ("EcalTrivialConditionRetriever")
01323 << " *** " << EcalSubDet << " is neither EB nor EE ";
01324 }
01325
01326 }
01327
01328
01329
01330 statusFile.close();
01331 return ecalStatus;
01332 }
01333
01334
01335
01336 std::auto_ptr<EcalChannelStatus>
01337 EcalTrivialConditionRetriever::produceEcalChannelStatus( const EcalChannelStatusRcd& )
01338 {
01339
01340 std::auto_ptr<EcalChannelStatus> ical = std::auto_ptr<EcalChannelStatus>( new EcalChannelStatus() );
01341
01342 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01343 if(ieta==0) continue;
01344 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01345 if (EBDetId::validDetId(ieta,iphi)) {
01346 EBDetId ebid(ieta,iphi);
01347 ical->setValue( ebid, 0 );
01348 }
01349 }
01350 }
01351
01352 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01353 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01354
01355 if (EEDetId::validDetId(iX,iY,1)) {
01356 EEDetId eedetidpos(iX,iY,1);
01357 ical->setValue( eedetidpos, 0 );
01358 }
01359 if (EEDetId::validDetId(iX,iY,-1)) {
01360 EEDetId eedetidneg(iX,iY,-1);
01361 ical->setValue( eedetidneg, 0 );
01362 }
01363 }
01364 }
01365 return ical;
01366 }
01367
01368
01369
01370
01371
01372
01373 std::auto_ptr<EcalIntercalibConstants>
01374 EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration
01375 ( const EcalIntercalibConstantsRcd& )
01376 {
01377 std::auto_ptr<EcalIntercalibConstants> ical =
01378 std::auto_ptr<EcalIntercalibConstants>( new EcalIntercalibConstants() );
01379
01380
01381
01382
01383 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading intercalibration constants from file "
01384 << intercalibConstantsFile_.c_str() ;
01385
01386 FILE *inpFile ;
01387 inpFile = fopen (intercalibConstantsFile_.c_str (),"r") ;
01388 if (!inpFile)
01389 {
01390 edm::LogError ("EcalTrivialConditionRetriever")
01391 << "*** Can not open file: " << intercalibConstantsFile_ ;
01392 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
01393 }
01394
01395 char line[256] ;
01396 std::ostringstream str ;
01397 fgets (line,255,inpFile) ;
01398 int sm_number=atoi (line) ;
01399 str << "sm: " << sm_number ;
01400
01401 fgets (line,255,inpFile) ;
01402
01403
01404 fgets (line,255,inpFile) ;
01405 std::string gen_tag = line ;
01406 str << "gen tag: " << gen_tag ;
01407
01408 fgets (line,255,inpFile) ;
01409 std::string cali_method = line ;
01410 str << "cali method: " << cali_method << std::endl ;
01411
01412 fgets (line,255,inpFile) ;
01413 std::string cali_version = line ;
01414 str << "cali version: " << cali_version << std::endl ;
01415
01416 fgets (line,255,inpFile) ;
01417 std::string cali_type = line ;
01418 str << "cali type: " << cali_type ;
01419
01420 edm::LogInfo("EcalTrivialConditionRetriever")
01421 << "[PIETRO] Intercalibration file - "
01422 << str.str () << std::endl ;
01423
01424 float calib[1700]={1} ;
01425 float calib_rms[1700]={0} ;
01426 int calib_nevents[1700]={0} ;
01427 int calib_status[1700]={0} ;
01428
01429 int ii = 0 ;
01430
01431 while (fgets (line,255,inpFile))
01432 {
01433 ii++;
01434 int dmy_num = 0 ;
01435 float dmy_calib = 0. ;
01436 float dmy_RMS = 0. ;
01437 int dmy_events = 0 ;
01438 int dmy_status = 0 ;
01439 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
01440 &dmy_RMS, &dmy_events,
01441 &dmy_status) ;
01442 assert (dmy_num >= 1) ;
01443 assert (dmy_num <= 1700) ;
01444 calib[dmy_num-1] = dmy_calib ;
01445 calib_rms[dmy_num-1] = dmy_RMS ;
01446 calib_nevents[dmy_num-1] = dmy_events ;
01447 calib_status[dmy_num-1] = dmy_status ;
01448
01449
01450
01451
01452
01453
01454
01455
01456 }
01457
01458 fclose (inpFile) ;
01459 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals " ;
01460 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
01461 << "Some crystals missing, set to 1" << std::endl ;
01462
01463
01464
01465
01466
01467 int sm_db=1 ;
01468
01469 for (int i=0 ; i<1700 ; i++)
01470 {
01471
01472
01473
01474
01475
01476
01477
01478 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
01479 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
01480 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
01481 else ical->setValue (ebid.rawId (), 1.) ;
01482 }
01483
01484 }
01485
01486
01487 return ical;
01488 }
01489
01490
01491 std::auto_ptr<EcalIntercalibErrors>
01492 EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration
01493 ( const EcalIntercalibErrorsRcd& )
01494 {
01495 std::auto_ptr<EcalIntercalibErrors> ical =
01496 std::auto_ptr<EcalIntercalibErrors>( new EcalIntercalibErrors() );
01497
01498
01499
01500
01501 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading intercalibration constants from file "
01502 << intercalibErrorsFile_.c_str() ;
01503
01504 FILE *inpFile ;
01505 inpFile = fopen (intercalibErrorsFile_.c_str (),"r") ;
01506 if (!inpFile)
01507 {
01508 edm::LogError ("EcalTrivialConditionRetriever")
01509 << "*** Can not open file: " << intercalibErrorsFile_ ;
01510 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
01511 }
01512
01513 char line[256] ;
01514 std::ostringstream str ;
01515 fgets (line,255,inpFile) ;
01516 int sm_number=atoi (line) ;
01517 str << "sm: " << sm_number ;
01518
01519 fgets (line,255,inpFile) ;
01520
01521
01522 fgets (line,255,inpFile) ;
01523 std::string gen_tag = line ;
01524 str << "gen tag: " << gen_tag ;
01525
01526 fgets (line,255,inpFile) ;
01527 std::string cali_method = line ;
01528 str << "cali method: " << cali_method << std::endl ;
01529
01530 fgets (line,255,inpFile) ;
01531 std::string cali_version = line ;
01532 str << "cali version: " << cali_version << std::endl ;
01533
01534 fgets (line,255,inpFile) ;
01535 std::string cali_type = line ;
01536 str << "cali type: " << cali_type ;
01537
01538 edm::LogInfo("EcalTrivialConditionRetriever")
01539 << "[PIETRO] Intercalibration file - "
01540 << str.str () << std::endl ;
01541
01542 float calib[1700]={1} ;
01543 float calib_rms[1700]={0} ;
01544 int calib_nevents[1700]={0} ;
01545 int calib_status[1700]={0} ;
01546
01547 int ii = 0 ;
01548
01549 while (fgets (line,255,inpFile))
01550 {
01551 ii++;
01552 int dmy_num = 0 ;
01553 float dmy_calib = 0. ;
01554 float dmy_RMS = 0. ;
01555 int dmy_events = 0 ;
01556 int dmy_status = 0 ;
01557 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
01558 &dmy_RMS, &dmy_events,
01559 &dmy_status) ;
01560 assert (dmy_num >= 1) ;
01561 assert (dmy_num <= 1700) ;
01562 calib[dmy_num-1] = dmy_calib ;
01563 calib_rms[dmy_num-1] = dmy_RMS ;
01564 calib_nevents[dmy_num-1] = dmy_events ;
01565 calib_status[dmy_num-1] = dmy_status ;
01566
01567
01568
01569
01570
01571
01572
01573
01574 }
01575
01576 fclose (inpFile) ;
01577 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals " ;
01578 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
01579 << "Some crystals missing, set to 1" << std::endl ;
01580
01581
01582
01583
01584
01585 int sm_db=1 ;
01586
01587 for (int i=0 ; i<1700 ; i++)
01588 {
01589
01590
01591
01592
01593
01594
01595
01596 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
01597 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
01598 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
01599 else ical->setValue (ebid.rawId (), 1.) ;
01600 }
01601
01602 }
01603
01604
01605 return ical;
01606 }