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 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
00016 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00017 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00018
00019
00020
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023
00024 using namespace edm;
00025
00026 EcalTrivialConditionRetriever::EcalTrivialConditionRetriever( const edm::ParameterSet& ps)
00027 {
00028
00029
00030 adcToGeVEBConstant_ = ps.getUntrackedParameter<double>("adcToGeVEBConstant",0.035);
00031 adcToGeVEEConstant_ = ps.getUntrackedParameter<double>("adcToGeVEEConstant",0.060);
00032
00033 intercalibConstantMeanMC_ = ps.getUntrackedParameter<double>("intercalibConstantMeanMC",1.0);
00034 intercalibConstantSigmaMC_ = ps.getUntrackedParameter<double>("intercalibConstantSigmaMC",0.0);
00035
00036 intercalibConstantMean_ = ps.getUntrackedParameter<double>("intercalibConstantMean",1.0);
00037 intercalibConstantSigma_ = ps.getUntrackedParameter<double>("intercalibConstantSigma",0.0);
00038 intercalibErrorMean_ = ps.getUntrackedParameter<double>("IntercalibErrorMean",0.0);
00039
00040 timeCalibConstantMean_ = ps.getUntrackedParameter<double>("timeCalibConstantMean",0.0);
00041 timeCalibConstantSigma_ = ps.getUntrackedParameter<double>("timeCalibConstantSigma",0.0);
00042 timeCalibErrorMean_ = ps.getUntrackedParameter<double>("timeCalibErrorMean",0.0);
00043
00044 laserAlphaMean_ = ps.getUntrackedParameter<double>("laserAlphaMean",1.55);
00045 laserAlphaSigma_ = ps.getUntrackedParameter<double>("laserAlphaSigma",0);
00046
00047 laserAPDPNTime1_ = (unsigned long)atoi( ps.getUntrackedParameter<std::string>("laserAPDPNTime1","1").c_str());
00048 laserAPDPNTime2_= (unsigned long)atoi( ps.getUntrackedParameter<std::string>("laserAPDPNTime2","0").c_str());
00049 laserAPDPNTime3_= (unsigned long)atoi( ps.getUntrackedParameter<std::string>("laserAPDPNTime3","0").c_str());
00050
00051 laserAPDPNRefMean_ = ps.getUntrackedParameter<double>("laserAPDPNRefMean",1.0);
00052 laserAPDPNRefSigma_ = ps.getUntrackedParameter<double>("laserAPDPNRefSigma",0.0);
00053
00054 laserAPDPNMean_ = ps.getUntrackedParameter<double>("laserAPDPNMean",1.0);
00055 laserAPDPNSigma_ = ps.getUntrackedParameter<double>("laserAPDPNSigma",0.0);
00056
00057 localContCorrParameters_ = ps.getUntrackedParameter< std::vector<double> >("localContCorrParameters", std::vector<double>(0) );
00058 crackCorrParameters_ = ps.getUntrackedParameter< std::vector<double> >("crackCorrParameters", std::vector<double>(0) );
00059 energyCorrectionParameters_ = ps.getUntrackedParameter< std::vector<double> >("energyCorrectionParameters", std::vector<double>(0) );
00060 energyUncertaintyParameters_ = ps.getUntrackedParameter< std::vector<double> >("energyUncertaintyParameters", std::vector<double>(0) );
00061
00062 EBpedMeanX12_ = ps.getUntrackedParameter<double>("EBpedMeanX12", 200.);
00063 EBpedRMSX12_ = ps.getUntrackedParameter<double>("EBpedRMSX12", 1.10);
00064 EBpedMeanX6_ = ps.getUntrackedParameter<double>("EBpedMeanX6", 200.);
00065 EBpedRMSX6_ = ps.getUntrackedParameter<double>("EBpedRMSX6", 0.90);
00066 EBpedMeanX1_ = ps.getUntrackedParameter<double>("EBpedMeanX1", 200.);
00067 EBpedRMSX1_ = ps.getUntrackedParameter<double>("EBpedRMSX1", 0.62);
00068
00069 EEpedMeanX12_ = ps.getUntrackedParameter<double>("EEpedMeanX12", 200.);
00070 EEpedRMSX12_ = ps.getUntrackedParameter<double>("EEpedRMSX12", 2.50);
00071 EEpedMeanX6_ = ps.getUntrackedParameter<double>("EEpedMeanX6", 200.);
00072 EEpedRMSX6_ = ps.getUntrackedParameter<double>("EEpedRMSX6", 2.00);
00073 EEpedMeanX1_ = ps.getUntrackedParameter<double>("EEpedMeanX1", 200.);
00074 EEpedRMSX1_ = ps.getUntrackedParameter<double>("EEpedRMSX1", 1.40);
00075
00076 gainRatio12over6_ = ps.getUntrackedParameter<double>("gainRatio12over6", 2.0);
00077 gainRatio6over1_ = ps.getUntrackedParameter<double>("gainRatio6over1", 6.0);
00078
00079 getWeightsFromFile_ = ps.getUntrackedParameter<bool>("getWeightsFromFile",false);
00080
00081 nTDCbins_ = 1;
00082
00083 weightsForAsynchronousRunning_ = ps.getUntrackedParameter<bool>("weightsForTB",false);
00084
00085 if (weightsForAsynchronousRunning_)
00086 {
00087 getWeightsFromFile_ = true;
00088
00089 nTDCbins_ = 50;
00090 }
00091
00092 std::string path="CalibCalorimetry/EcalTrivialCondModules/data/";
00093 std::string weightType;
00094 std::ostringstream str;
00095
00096 if (!weightsForAsynchronousRunning_)
00097 str << "_CMS.txt" ;
00098 else
00099 str << "_TB.txt" ;
00100
00101 weightType = str.str();
00102
00103 amplWeightsFile_ = ps.getUntrackedParameter<std::string>("amplWeightsFile",path+"ampWeights"+weightType);
00104 amplWeightsAftFile_ = ps.getUntrackedParameter<std::string>("amplWeightsAftFile",path+"ampWeightsAfterGainSwitch"+weightType);
00105 pedWeightsFile_ = ps.getUntrackedParameter<std::string>("pedWeightsFile",path+"pedWeights"+weightType);
00106 pedWeightsAftFile_ = ps.getUntrackedParameter<std::string>("pedWeightsAftFile",path+"pedWeightsAfterGainSwitch"+weightType);
00107 jittWeightsFile_ = ps.getUntrackedParameter<std::string>("jittWeightsFile",path+"timeWeights"+weightType);
00108 jittWeightsAftFile_ = ps.getUntrackedParameter<std::string>("jittWeightsAftFile",path+"timeWeightsAfterGainSwitch"+weightType);
00109 chi2MatrixFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixFile",path+"chi2Matrix"+weightType);
00110 chi2MatrixAftFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixAftFile",path+"chi2MatrixAfterGainSwitch"+weightType);
00111
00112 amplWeights_.resize(nTDCbins_);
00113 amplWeightsAft_.resize(nTDCbins_);
00114 pedWeights_.resize(nTDCbins_);
00115 pedWeightsAft_.resize(nTDCbins_);
00116 jittWeights_.resize(nTDCbins_);
00117 jittWeightsAft_.resize(nTDCbins_);
00118 chi2Matrix_.resize(nTDCbins_);
00119 chi2MatrixAft_.resize(nTDCbins_);
00120
00121
00122 getWeightsFromConfiguration(ps);
00123
00124 producedEcalPedestals_ = ps.getUntrackedParameter<bool>("producedEcalPedestals",true);
00125 producedEcalWeights_ = ps.getUntrackedParameter<bool>("producedEcalWeights",true);
00126
00127 producedEcalGainRatios_ = ps.getUntrackedParameter<bool>("producedEcalGainRatios",true);
00128 producedEcalADCToGeVConstant_ = ps.getUntrackedParameter<bool>("producedEcalADCToGeVConstant",true);
00129
00130 producedEcalMappingElectronics_ = ps.getUntrackedParameter<bool>("producedEcalMappingElectronics",true);
00131 mappingFile_ = ps.getUntrackedParameter<std::string>("mappingFile","");
00132
00133 if ( producedEcalMappingElectronics_ ) {
00134 if ( mappingFile_ != "" ) {
00135 setWhatProduced( this, &EcalTrivialConditionRetriever::getMappingFromConfiguration );
00136 } else {
00137 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalMappingElectronics );
00138 }
00139 findingRecord<EcalMappingElectronicsRcd>();
00140 }
00141
00142 verbose_ = ps.getUntrackedParameter<int>("verbose", 0);
00143
00144
00145
00146 if (producedEcalPedestals_)
00147 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalPedestals );
00148
00149 if (producedEcalWeights_) {
00150 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalWeightXtalGroups );
00151 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTBWeights );
00152 }
00153
00154 if (producedEcalGainRatios_)
00155 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalGainRatios );
00156
00157 if (producedEcalADCToGeVConstant_)
00158 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalADCToGeVConstant );
00159
00160
00161 producedEcalIntercalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstants",true);
00162 intercalibConstantsFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsFile","") ;
00163
00164 if (producedEcalIntercalibConstants_) {
00165 if(intercalibConstantsFile_ != "") {
00166 setWhatProduced (this, &EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration ) ;
00167 } else {
00168 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalIntercalibConstants ) ;
00169 }
00170 findingRecord<EcalIntercalibConstantsRcd> () ;
00171 }
00172
00173 producedEcalIntercalibConstantsMC_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstantsMC",true);
00174
00175 if (producedEcalIntercalibConstantsMC_) {
00176 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalIntercalibConstantsMC ) ;
00177 findingRecord<EcalIntercalibConstantsMCRcd> () ;
00178 }
00179
00180
00181 producedEcalIntercalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibErrors",true);
00182 intercalibErrorsFile_ = ps.getUntrackedParameter<std::string>("intercalibErrorsFile","") ;
00183
00184 if (producedEcalIntercalibErrors_) {
00185 if(intercalibErrorsFile_ != "") {
00186 setWhatProduced (this, &EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration ) ;
00187 } else {
00188 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalIntercalibErrors ) ;
00189 }
00190 findingRecord<EcalIntercalibErrorsRcd> () ;
00191 }
00192
00193
00194 producedEcalTimeCalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibConstants",true);
00195 timeCalibConstantsFile_ = ps.getUntrackedParameter<std::string>("timeCalibConstantsFile","") ;
00196
00197 if (producedEcalTimeCalibConstants_) {
00198 if(timeCalibConstantsFile_ != "") {
00199 setWhatProduced (this, &EcalTrivialConditionRetriever::getTimeCalibConstantsFromConfiguration ) ;
00200 } else {
00201 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalTimeCalibConstants ) ;
00202 }
00203 findingRecord<EcalTimeCalibConstantsRcd> () ;
00204 }
00205
00206
00207 producedEcalTimeCalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibErrors",true);
00208 timeCalibErrorsFile_ = ps.getUntrackedParameter<std::string>("timeCalibErrorsFile","") ;
00209
00210 if (producedEcalTimeCalibErrors_) {
00211 if(timeCalibErrorsFile_ != "") {
00212 setWhatProduced (this, &EcalTrivialConditionRetriever::getTimeCalibErrorsFromConfiguration ) ;
00213 } else {
00214 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalTimeCalibErrors ) ;
00215 }
00216 findingRecord<EcalTimeCalibErrorsRcd> () ;
00217 }
00218
00219
00220 producedEcalClusterLocalContCorrParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterLocalContCorrParameters", true);
00221 producedEcalClusterCrackCorrParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterCrackCorrParameters", true);
00222 producedEcalClusterEnergyCorrectionParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterEnergyCorrectionParameters", true);
00223 producedEcalClusterEnergyUncertaintyParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterEnergyUncertaintyParameters", true);
00224 if ( producedEcalClusterLocalContCorrParameters_ ) {
00225 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalClusterLocalContCorrParameters );
00226 findingRecord<EcalClusterLocalContCorrParametersRcd>();
00227 }
00228 if ( producedEcalClusterCrackCorrParameters_ ) {
00229 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalClusterCrackCorrParameters );
00230 findingRecord<EcalClusterCrackCorrParametersRcd>();
00231 }
00232 if ( producedEcalClusterEnergyCorrectionParameters_ ) {
00233 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionParameters );
00234 findingRecord<EcalClusterEnergyCorrectionParametersRcd>();
00235 }
00236 if ( producedEcalClusterEnergyUncertaintyParameters_ ) {
00237 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalClusterEnergyUncertaintyParameters );
00238 findingRecord<EcalClusterEnergyUncertaintyParametersRcd>();
00239 }
00240
00241
00242 producedEcalLaserCorrection_ = ps.getUntrackedParameter<bool>("producedEcalLaserCorrection",true);
00243 if (producedEcalLaserCorrection_) {
00244
00245 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAlphas ) ;
00246 findingRecord<EcalLaserAlphasRcd> () ;
00247 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef ) ;
00248 findingRecord<EcalLaserAPDPNRatiosRefRcd> () ;
00249 setWhatProduced (this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios) ;
00250 findingRecord<EcalLaserAPDPNRatiosRcd> () ;
00251 }
00252
00253
00254 producedEcalChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalChannelStatus",true);
00255 channelStatusFile_ = ps.getUntrackedParameter<std::string>("channelStatusFile","");
00256
00257 if ( producedEcalChannelStatus_ ) {
00258 if ( channelStatusFile_ != "" ) {
00259 setWhatProduced( this, &EcalTrivialConditionRetriever::getChannelStatusFromConfiguration );
00260 } else {
00261 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalChannelStatus );
00262 }
00263 findingRecord<EcalChannelStatusRcd>();
00264 }
00265
00266 producedEcalDQMChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMChannelStatus",true);
00267 if ( producedEcalDQMChannelStatus_ ) {
00268 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalDQMChannelStatus );
00269 findingRecord<EcalDQMChannelStatusRcd>();
00270 }
00271
00272 producedEcalDCSTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDCSTowerStatus",true);
00273 if ( producedEcalDCSTowerStatus_ ) {
00274 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalDCSTowerStatus );
00275 findingRecord<EcalDCSTowerStatusRcd>();
00276 }
00277
00278 producedEcalDAQTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDAQTowerStatus",true);
00279 if ( producedEcalDAQTowerStatus_ ) {
00280 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalDAQTowerStatus );
00281 findingRecord<EcalDAQTowerStatusRcd>();
00282 }
00283
00284 producedEcalDQMTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMTowerStatus",true);
00285 if ( producedEcalDQMTowerStatus_ ) {
00286 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalDQMTowerStatus );
00287 findingRecord<EcalDQMTowerStatusRcd>();
00288 }
00289
00290
00291 producedEcalTrgChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalTrgChannelStatus",true);
00292 trgChannelStatusFile_ = ps.getUntrackedParameter<std::string>("trgChannelStatusFile","");
00293
00294 if ( producedEcalTrgChannelStatus_ ) {
00295 if ( trgChannelStatusFile_ != "" ) {
00296 setWhatProduced( this, &EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration );
00297 } else {
00298 setWhatProduced( this, &EcalTrivialConditionRetriever::produceEcalTrgChannelStatus );
00299 }
00300 findingRecord<EcalTPGCrystalStatusRcd>();
00301 }
00302
00303
00304 if (producedEcalPedestals_) findingRecord<EcalPedestalsRcd>();
00305
00306 if (producedEcalWeights_) {
00307 findingRecord<EcalWeightXtalGroupsRcd>();
00308 findingRecord<EcalTBWeightsRcd>();
00309 }
00310
00311 if (producedEcalGainRatios_) findingRecord<EcalGainRatiosRcd>();
00312
00313 if (producedEcalADCToGeVConstant_) findingRecord<EcalADCToGeVConstantRcd>();
00314
00315 }
00316
00317 EcalTrivialConditionRetriever::~EcalTrivialConditionRetriever()
00318 {
00319 }
00320
00321
00322
00323
00324 void
00325 EcalTrivialConditionRetriever::setIntervalFor( const edm::eventsetup::EventSetupRecordKey& rk,
00326 const edm::IOVSyncValue& iTime,
00327 edm::ValidityInterval& oValidity)
00328 {
00329 if(verbose_>=1) std::cout << "EcalTrivialConditionRetriever::setIntervalFor(): record key = " << rk.name() << "\ttime: " << iTime.time().value() << std::endl;
00330
00331 oValidity = edm::ValidityInterval( edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime() );
00332 }
00333
00334
00335 std::auto_ptr<EcalPedestals>
00336 EcalTrivialConditionRetriever::produceEcalPedestals( const EcalPedestalsRcd& ) {
00337 std::auto_ptr<EcalPedestals> peds = std::auto_ptr<EcalPedestals>( new EcalPedestals() );
00338 EcalPedestals::Item EBitem;
00339 EcalPedestals::Item EEitem;
00340
00341 EBitem.mean_x1 = EBpedMeanX1_;
00342 EBitem.rms_x1 = EBpedRMSX1_;
00343 EBitem.mean_x6 = EBpedMeanX6_;
00344 EBitem.rms_x6 = EBpedRMSX6_;
00345 EBitem.mean_x12 = EBpedMeanX12_;
00346 EBitem.rms_x12 = EBpedRMSX12_;
00347
00348 EEitem.mean_x1 = EEpedMeanX1_;
00349 EEitem.rms_x1 = EEpedRMSX1_;
00350 EEitem.mean_x6 = EEpedMeanX6_;
00351 EEitem.rms_x6 = EEpedRMSX6_;
00352 EEitem.mean_x12 = EEpedMeanX12_;
00353 EEitem.rms_x12 = EEpedRMSX12_;
00354
00355 for(int iEta=-EBDetId::MAX_IETA; iEta<=EBDetId::MAX_IETA ;++iEta) {
00356 if(iEta==0) continue;
00357 for(int iPhi=EBDetId::MIN_IPHI; iPhi<=EBDetId::MAX_IPHI; ++iPhi) {
00358
00359 if (EBDetId::validDetId(iEta,iPhi))
00360 {
00361 EBDetId ebdetid(iEta,iPhi);
00362 peds->insert(std::make_pair(ebdetid.rawId(),EBitem));
00363 }
00364 }
00365 }
00366
00367 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00368 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00369
00370 if (EEDetId::validDetId(iX,iY,1))
00371 {
00372 EEDetId eedetidpos(iX,iY,1);
00373 peds->insert(std::make_pair(eedetidpos.rawId(),EEitem));
00374 }
00375 if(EEDetId::validDetId(iX,iY,-1))
00376 {
00377 EEDetId eedetidneg(iX,iY,-1);
00378 peds->insert(std::make_pair(eedetidneg.rawId(),EEitem));
00379 }
00380 }
00381 }
00382
00383
00384 return peds;
00385 }
00386
00387 std::auto_ptr<EcalWeightXtalGroups>
00388 EcalTrivialConditionRetriever::produceEcalWeightXtalGroups( const EcalWeightXtalGroupsRcd& )
00389 {
00390 std::auto_ptr<EcalWeightXtalGroups> xtalGroups = std::auto_ptr<EcalWeightXtalGroups>( new EcalWeightXtalGroups() );
00391 EcalXtalGroupId defaultGroupId(1);
00392 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00393 if(ieta==0) continue;
00394 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00395
00396 if (EBDetId::validDetId(ieta,iphi))
00397 {
00398 EBDetId ebid(ieta,iphi);
00399
00400 xtalGroups->setValue(ebid.rawId(), defaultGroupId );
00401 }
00402 }
00403 }
00404
00405 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00406 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00407
00408 if (EEDetId::validDetId(iX,iY,1))
00409 {
00410 EEDetId eedetidpos(iX,iY,1);
00411 xtalGroups->setValue(eedetidpos.rawId(), defaultGroupId );
00412 }
00413 if(EEDetId::validDetId(iX,iY,-1))
00414 {
00415 EEDetId eedetidneg(iX,iY,-1);
00416 xtalGroups->setValue(eedetidneg.rawId(), defaultGroupId );
00417 }
00418 }
00419 }
00420 return xtalGroups;
00421 }
00422
00423 std::auto_ptr<EcalIntercalibConstants>
00424 EcalTrivialConditionRetriever::produceEcalIntercalibConstants( const EcalIntercalibConstantsRcd& )
00425 {
00426 std::auto_ptr<EcalIntercalibConstants> ical = std::auto_ptr<EcalIntercalibConstants>( new EcalIntercalibConstants() );
00427
00428 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00429 if(ieta==0) continue;
00430 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00431
00432 if (EBDetId::validDetId(ieta,iphi))
00433 {
00434 EBDetId ebid(ieta,iphi);
00435 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00436 ical->setValue( ebid.rawId(), intercalibConstantMean_ + r*intercalibConstantSigma_ );
00437 }
00438 }
00439 }
00440
00441 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00442 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00443
00444 if (EEDetId::validDetId(iX,iY,1))
00445 {
00446 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00447 EEDetId eedetidpos(iX,iY,1);
00448 ical->setValue( eedetidpos.rawId(), intercalibConstantMean_ + r*intercalibConstantSigma_ );
00449 }
00450 if(EEDetId::validDetId(iX,iY,-1))
00451 {
00452 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00453 EEDetId eedetidneg(iX,iY,-1);
00454 ical->setValue( eedetidneg.rawId(), intercalibConstantMean_ + r1*intercalibConstantSigma_ );
00455 }
00456 }
00457 }
00458
00459 return ical;
00460 }
00461
00462 std::auto_ptr<EcalIntercalibConstantsMC>
00463 EcalTrivialConditionRetriever::produceEcalIntercalibConstantsMC( const EcalIntercalibConstantsMCRcd& )
00464 {
00465 std::auto_ptr<EcalIntercalibConstantsMC> ical = std::auto_ptr<EcalIntercalibConstantsMC>( new EcalIntercalibConstantsMC() );
00466
00467 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00468 if(ieta==0) continue;
00469 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00470
00471 if (EBDetId::validDetId(ieta,iphi))
00472 {
00473 EBDetId ebid(ieta,iphi);
00474 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00475 ical->setValue( ebid.rawId(), intercalibConstantMeanMC_ + r*intercalibConstantSigmaMC_ );
00476 }
00477 }
00478 }
00479
00480 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00481 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00482
00483 if (EEDetId::validDetId(iX,iY,1))
00484 {
00485 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00486 EEDetId eedetidpos(iX,iY,1);
00487 ical->setValue( eedetidpos.rawId(), intercalibConstantMeanMC_ + r*intercalibConstantSigmaMC_ );
00488 }
00489 if(EEDetId::validDetId(iX,iY,-1))
00490 {
00491 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00492 EEDetId eedetidneg(iX,iY,-1);
00493 ical->setValue( eedetidneg.rawId(), intercalibConstantMeanMC_ + r1*intercalibConstantSigmaMC_ );
00494 }
00495 }
00496 }
00497
00498 return ical;
00499 }
00500
00501 std::auto_ptr<EcalIntercalibErrors>
00502 EcalTrivialConditionRetriever::produceEcalIntercalibErrors( const EcalIntercalibErrorsRcd& )
00503 {
00504 std::auto_ptr<EcalIntercalibErrors> ical = std::auto_ptr<EcalIntercalibErrors>( new EcalIntercalibErrors() );
00505
00506 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00507 if(ieta==0) continue;
00508 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00509
00510 if (EBDetId::validDetId(ieta,iphi))
00511 {
00512 EBDetId ebid(ieta,iphi);
00513 ical->setValue( ebid.rawId(), intercalibErrorMean_);
00514 }
00515 }
00516 }
00517
00518 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00519 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00520
00521 if (EEDetId::validDetId(iX,iY,1))
00522 {
00523 EEDetId eedetidpos(iX,iY,1);
00524 ical->setValue( eedetidpos.rawId(), intercalibErrorMean_ );
00525 }
00526 if(EEDetId::validDetId(iX,iY,-1))
00527 {
00528 EEDetId eedetidneg(iX,iY,-1);
00529 ical->setValue( eedetidneg.rawId(), intercalibErrorMean_ );
00530 }
00531 }
00532 }
00533
00534 return ical;
00535 }
00536
00537 std::auto_ptr<EcalTimeCalibConstants>
00538 EcalTrivialConditionRetriever::produceEcalTimeCalibConstants( const EcalTimeCalibConstantsRcd& )
00539 {
00540 std::auto_ptr<EcalTimeCalibConstants> ical = std::auto_ptr<EcalTimeCalibConstants>( new EcalTimeCalibConstants() );
00541
00542 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00543 if(ieta==0) continue;
00544 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00545
00546 if (EBDetId::validDetId(ieta,iphi))
00547 {
00548 EBDetId ebid(ieta,iphi);
00549 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00550 ical->setValue( ebid.rawId(), timeCalibConstantMean_ + r*timeCalibConstantSigma_ );
00551 }
00552 }
00553 }
00554
00555 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00556 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00557
00558 if (EEDetId::validDetId(iX,iY,1))
00559 {
00560 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00561 EEDetId eedetidpos(iX,iY,1);
00562 ical->setValue( eedetidpos.rawId(), timeCalibConstantMean_ + r*timeCalibConstantSigma_ );
00563 }
00564 if(EEDetId::validDetId(iX,iY,-1))
00565 {
00566 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00567 EEDetId eedetidneg(iX,iY,-1);
00568 ical->setValue( eedetidneg.rawId(), timeCalibConstantMean_ + r1*timeCalibConstantSigma_ );
00569 }
00570 }
00571 }
00572
00573 return ical;
00574 }
00575
00576 std::auto_ptr<EcalTimeCalibErrors>
00577 EcalTrivialConditionRetriever::produceEcalTimeCalibErrors( const EcalTimeCalibErrorsRcd& )
00578 {
00579 std::auto_ptr<EcalTimeCalibErrors> ical = std::auto_ptr<EcalTimeCalibErrors>( new EcalTimeCalibErrors() );
00580
00581 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA ;++ieta) {
00582 if(ieta==0) continue;
00583 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00584
00585 if (EBDetId::validDetId(ieta,iphi))
00586 {
00587 EBDetId ebid(ieta,iphi);
00588 ical->setValue( ebid.rawId(), timeCalibErrorMean_);
00589 }
00590 }
00591 }
00592
00593 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00594 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00595
00596 if (EEDetId::validDetId(iX,iY,1))
00597 {
00598 EEDetId eedetidpos(iX,iY,1);
00599 ical->setValue( eedetidpos.rawId(), timeCalibErrorMean_ );
00600 }
00601 if(EEDetId::validDetId(iX,iY,-1))
00602 {
00603 EEDetId eedetidneg(iX,iY,-1);
00604 ical->setValue( eedetidneg.rawId(), timeCalibErrorMean_ );
00605 }
00606 }
00607 }
00608
00609 return ical;
00610 }
00611
00612 std::auto_ptr<EcalGainRatios>
00613 EcalTrivialConditionRetriever::produceEcalGainRatios( const EcalGainRatiosRcd& )
00614 {
00615 std::auto_ptr<EcalGainRatios> gratio = std::auto_ptr<EcalGainRatios>( new EcalGainRatios() );
00616 EcalMGPAGainRatio gr;
00617 gr.setGain12Over6( gainRatio12over6_ );
00618 gr.setGain6Over1( gainRatio6over1_ );
00619
00620 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00621 if(ieta==0) continue;
00622 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00623 if (EBDetId::validDetId(ieta,iphi))
00624 {
00625 EBDetId ebid(ieta,iphi);
00626 gratio->setValue( ebid.rawId(), gr );
00627 }
00628 }
00629 }
00630
00631 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00632 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00633
00634 if (EEDetId::validDetId(iX,iY,1))
00635 {
00636 EEDetId eedetidpos(iX,iY,1);
00637 gratio->setValue( eedetidpos.rawId(), gr );
00638 }
00639 if (EEDetId::validDetId(iX,iY,-1))
00640 {
00641 EEDetId eedetidneg(iX,iY,-1);
00642 gratio->setValue( eedetidneg.rawId(), gr );
00643 }
00644 }
00645 }
00646
00647 return gratio;
00648 }
00649
00650 std::auto_ptr<EcalADCToGeVConstant>
00651 EcalTrivialConditionRetriever::produceEcalADCToGeVConstant( const EcalADCToGeVConstantRcd& )
00652 {
00653 return std::auto_ptr<EcalADCToGeVConstant>( new EcalADCToGeVConstant(adcToGeVEBConstant_,adcToGeVEEConstant_) );
00654 }
00655
00656 std::auto_ptr<EcalTBWeights>
00657 EcalTrivialConditionRetriever::produceEcalTBWeights( const EcalTBWeightsRcd& )
00658 {
00659
00660 std::auto_ptr<EcalTBWeights> tbwgt = std::auto_ptr<EcalTBWeights>( new EcalTBWeights() );
00661
00662
00663
00664
00665
00666 int igrp=1;
00667 for(int itdc=1; itdc<=nTDCbins_; ++itdc) {
00668
00669
00670
00671
00672 EcalWeightSet wgt;
00673
00674 EcalWeightSet::EcalWeightMatrix& mat1 = wgt.getWeightsBeforeGainSwitch();
00675 EcalWeightSet::EcalWeightMatrix& mat2 = wgt.getWeightsAfterGainSwitch();
00676
00677
00678
00679
00680
00681
00682
00697
00698 mat1.Place_in_row(amplWeights_[itdc-1],0,0);
00699 mat1.Place_in_row(pedWeights_[itdc-1],1,0);
00700 mat1.Place_in_row(jittWeights_[itdc-1],2,0);
00701
00702
00703 mat2.Place_in_row(amplWeightsAft_[itdc-1],0,0);
00704 mat2.Place_in_row(pedWeightsAft_[itdc-1],1,0);
00705 mat2.Place_in_row(jittWeightsAft_[itdc-1],2,0);
00706
00707
00708
00709 EcalWeightSet::EcalChi2WeightMatrix& mat3 = wgt.getChi2WeightsBeforeGainSwitch();
00710 EcalWeightSet::EcalChi2WeightMatrix& mat4 = wgt.getChi2WeightsAfterGainSwitch();
00711 mat3=chi2Matrix_[itdc-1];
00712 mat4=chi2MatrixAft_[itdc-1];
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737 tbwgt->setValue(std::make_pair(igrp,itdc), wgt);
00738 }
00739
00740 return tbwgt;
00741 }
00742
00743
00744
00745 std::auto_ptr<EcalClusterLocalContCorrParameters>
00746 EcalTrivialConditionRetriever::produceEcalClusterLocalContCorrParameters( const EcalClusterLocalContCorrParametersRcd &)
00747 {
00748 std::auto_ptr<EcalClusterLocalContCorrParameters> ipar = std::auto_ptr<EcalClusterLocalContCorrParameters>( new EcalClusterLocalContCorrParameters() );
00749 for (size_t i = 0; i < localContCorrParameters_.size(); ++i ) {
00750 ipar->params().push_back( localContCorrParameters_[i] );
00751 }
00752 return ipar;
00753 }
00754 std::auto_ptr<EcalClusterCrackCorrParameters>
00755 EcalTrivialConditionRetriever::produceEcalClusterCrackCorrParameters( const EcalClusterCrackCorrParametersRcd &)
00756 {
00757 std::auto_ptr<EcalClusterCrackCorrParameters> ipar = std::auto_ptr<EcalClusterCrackCorrParameters>( new EcalClusterCrackCorrParameters() );
00758 for (size_t i = 0; i < crackCorrParameters_.size(); ++i ) {
00759 ipar->params().push_back( crackCorrParameters_[i] );
00760 }
00761 return ipar;
00762 }
00763 std::auto_ptr<EcalClusterEnergyCorrectionParameters>
00764 EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionParameters( const EcalClusterEnergyCorrectionParametersRcd &)
00765 {
00766 std::auto_ptr<EcalClusterEnergyCorrectionParameters> ipar = std::auto_ptr<EcalClusterEnergyCorrectionParameters>( new EcalClusterEnergyCorrectionParameters() );
00767 for (size_t i = 0; i < energyCorrectionParameters_.size(); ++i ) {
00768 ipar->params().push_back( energyCorrectionParameters_[i] );
00769 }
00770 return ipar;
00771 }
00772 std::auto_ptr<EcalClusterEnergyUncertaintyParameters>
00773 EcalTrivialConditionRetriever::produceEcalClusterEnergyUncertaintyParameters( const EcalClusterEnergyUncertaintyParametersRcd &)
00774 {
00775 std::auto_ptr<EcalClusterEnergyUncertaintyParameters> ipar = std::auto_ptr<EcalClusterEnergyUncertaintyParameters>( new EcalClusterEnergyUncertaintyParameters() );
00776 for (size_t i = 0; i < energyUncertaintyParameters_.size(); ++i ) {
00777 ipar->params().push_back( energyUncertaintyParameters_[i] );
00778 }
00779 return ipar;
00780 }
00781
00782
00783
00784 std::auto_ptr<EcalLaserAlphas>
00785 EcalTrivialConditionRetriever::produceEcalLaserAlphas( const EcalLaserAlphasRcd& )
00786 {
00787 std::auto_ptr<EcalLaserAlphas> ical = std::auto_ptr<EcalLaserAlphas>( new EcalLaserAlphas() );
00788 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00789 if(ieta==0) continue;
00790 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00791 if (EBDetId::validDetId(ieta,iphi)) {
00792 EBDetId ebid(ieta,iphi);
00793 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00794 ical->setValue( ebid, laserAlphaMean_ + r*laserAlphaSigma_ );
00795 }
00796 }
00797 }
00798
00799 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00800 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00801
00802 if (EEDetId::validDetId(iX,iY,1)) {
00803 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00804 EEDetId eedetidpos(iX,iY,1);
00805 ical->setValue( eedetidpos, laserAlphaMean_ + r*laserAlphaSigma_ );
00806 }
00807
00808 if (EEDetId::validDetId(iX,iY,-1)) {
00809 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00810 EEDetId eedetidneg(iX,iY,-1);
00811 ical->setValue( eedetidneg, laserAlphaMean_ + r1*laserAlphaSigma_ );
00812 }
00813 }
00814 }
00815
00816 return ical;
00817 }
00818
00819
00820 std::auto_ptr<EcalLaserAPDPNRatiosRef>
00821 EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef( const EcalLaserAPDPNRatiosRefRcd& )
00822 {
00823 std::auto_ptr<EcalLaserAPDPNRatiosRef> ical = std::auto_ptr<EcalLaserAPDPNRatiosRef>( new EcalLaserAPDPNRatiosRef() );
00824 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00825 if(ieta==0) continue;
00826 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00827 if (EBDetId::validDetId(ieta,iphi)) {
00828 EBDetId ebid(ieta,iphi);
00829 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00830 ical->setValue( ebid, laserAPDPNRefMean_ + r*laserAPDPNRefSigma_ );
00831 }
00832 }
00833 }
00834
00835 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00836 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00837
00838 if (EEDetId::validDetId(iX,iY,1)) {
00839 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00840 EEDetId eedetidpos(iX,iY,1);
00841 ical->setValue( eedetidpos, laserAPDPNRefMean_ + r*laserAPDPNRefSigma_ );
00842 }
00843
00844 if (EEDetId::validDetId(iX,iY,-1)) {
00845 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00846 EEDetId eedetidneg(iX,iY,-1);
00847 ical->setValue( eedetidneg, laserAPDPNRefMean_ + r1*laserAPDPNRefSigma_ );
00848 }
00849 }
00850 }
00851
00852 return ical;
00853 }
00854
00855
00856 std::auto_ptr<EcalLaserAPDPNRatios>
00857 EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios( const EcalLaserAPDPNRatiosRcd& )
00858 {
00859
00860 std::auto_ptr<EcalLaserAPDPNRatios> ical = std::auto_ptr<EcalLaserAPDPNRatios>( new EcalLaserAPDPNRatios() );
00861 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
00862 if(ieta==0) continue;
00863 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
00864 if (EBDetId::validDetId(ieta,iphi)) {
00865 EBDetId ebid(ieta,iphi);
00866 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00867
00868 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00869 pairAPDPN.p1 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00870 pairAPDPN.p2 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00871 pairAPDPN.p3 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00872 ical->setValue( ebid, pairAPDPN );
00873 }
00874 }
00875 }
00876
00877 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
00878 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
00879
00880 if (EEDetId::validDetId(iX,iY,1)) {
00881 double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
00882 EEDetId eedetidpos(iX,iY,1);
00883
00884 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00885 pairAPDPN.p1 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00886 pairAPDPN.p2 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00887 pairAPDPN.p3 = laserAPDPNMean_ + r*laserAPDPNSigma_;
00888 ical->setValue( eedetidpos, pairAPDPN );
00889 }
00890
00891 if (EEDetId::validDetId(iX,iY,-1)) {
00892 double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
00893 EEDetId eedetidneg(iX,iY,-1);
00894
00895 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
00896 pairAPDPN.p1 = laserAPDPNMean_ + r1*laserAPDPNSigma_;
00897 pairAPDPN.p2 = laserAPDPNMean_ + r1*laserAPDPNSigma_;
00898 pairAPDPN.p3 = laserAPDPNMean_ + r1*laserAPDPNSigma_;
00899 ical->setValue( eedetidneg, pairAPDPN );
00900 }
00901 }
00902 }
00903
00904 EcalLaserAPDPNRatios::EcalLaserTimeStamp TimeStamp;
00905
00906 for(int i=0; i<92; i++){
00907 TimeStamp.t1 = Timestamp(laserAPDPNTime1_);
00908 if(laserAPDPNTime2_ == 0 ){
00909 TimeStamp.t2 = Timestamp(edm::Timestamp::endOfTime().value());
00910 } else {
00911 TimeStamp.t2 = Timestamp(laserAPDPNTime2_);
00912 }
00913 if(laserAPDPNTime3_ == 0 ){
00914 TimeStamp.t3 = Timestamp(edm::Timestamp::endOfTime().value());
00915 } else {
00916 TimeStamp.t3 = Timestamp(laserAPDPNTime3_);
00917 }
00918
00919 ical->setTime( i, TimeStamp );
00920 }
00921
00922 return ical;
00923
00924 }
00925
00926
00927 void EcalTrivialConditionRetriever::getWeightsFromConfiguration(const edm::ParameterSet& ps)
00928 {
00929
00930 std::vector < std::vector<double> > amplwgtv(nTDCbins_);
00931
00932 if (!getWeightsFromFile_ && nTDCbins_ == 1)
00933 {
00934 std::vector<double> vampl;
00935
00936 vampl.push_back( -0.33333 );
00937 vampl.push_back( -0.33333 );
00938 vampl.push_back( -0.33333 );
00939 vampl.push_back( 0. );
00940 vampl.push_back( 0. );
00941 vampl.push_back( 1. );
00942 vampl.push_back( 0. );
00943 vampl.push_back( 0. );
00944 vampl.push_back( 0. );
00945 vampl.push_back( 0. );
00946 amplwgtv[0]= ps.getUntrackedParameter< std::vector<double> >("amplWeights", vampl);
00947 }
00948 else if (getWeightsFromFile_)
00949 {
00950 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights from file " << edm::FileInPath(amplWeightsFile_).fullPath().c_str() ;
00951 std::ifstream amplFile(edm::FileInPath(amplWeightsFile_).fullPath().c_str());
00952 int tdcBin=0;
00953 while (!amplFile.eof() && tdcBin < nTDCbins_)
00954 {
00955 for(int j = 0; j < 10; ++j) {
00956 float ww;
00957 amplFile >> ww;
00958 amplwgtv[tdcBin].push_back(ww);
00959 }
00960 ++tdcBin;
00961 }
00962 assert (tdcBin == nTDCbins_);
00963
00964 }
00965 else
00966 {
00967
00968 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
00969 throw cms::Exception("WrongConfig");
00970 }
00971
00972
00973 for (int i=0;i<nTDCbins_;i++)
00974 {
00975 assert(amplwgtv[i].size() == 10);
00976 int j=0;
00977 for(std::vector<double>::const_iterator it = amplwgtv[i].begin(); it != amplwgtv[i].end(); ++it)
00978 {
00979 (amplWeights_[i])[j]=*it;
00980 j++;
00981 }
00982 }
00983
00984
00985 std::vector < std::vector<double> > amplwgtvAftGain(nTDCbins_);
00986
00987 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
00988 {
00989 std::vector<double> vamplAftGain;
00990 vamplAftGain.push_back( 0. );
00991 vamplAftGain.push_back( 0. );
00992 vamplAftGain.push_back( 0. );
00993 vamplAftGain.push_back( 0. );
00994 vamplAftGain.push_back( 0. );
00995 vamplAftGain.push_back( 1. );
00996 vamplAftGain.push_back( 0. );
00997 vamplAftGain.push_back( 0. );
00998 vamplAftGain.push_back( 0. );
00999 vamplAftGain.push_back( 0. );
01000 amplwgtvAftGain[0] = ps.getUntrackedParameter< std::vector<double> >("amplWeightsAftGain", vamplAftGain);
01001 }
01002 else if (getWeightsFromFile_)
01003 {
01004
01005 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights aftre gain switch from file " << edm::FileInPath(amplWeightsAftFile_).fullPath().c_str() ;
01006 std::ifstream amplFile(edm::FileInPath(amplWeightsAftFile_).fullPath().c_str());
01007 int tdcBin=0;
01008 while (!amplFile.eof() && tdcBin < nTDCbins_)
01009 {
01010 for(int j = 0; j < 10; ++j) {
01011 float ww;
01012 amplFile >> ww;
01013 amplwgtvAftGain[tdcBin].push_back(ww);
01014 }
01015 ++tdcBin;
01016 }
01017 assert (tdcBin == nTDCbins_);
01018 }
01019 else
01020 {
01021
01022 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01023 throw cms::Exception("WrongConfig");
01024 }
01025
01026 for (int i=0;i<nTDCbins_;i++)
01027 {
01028 assert(amplwgtvAftGain[i].size() == 10);
01029 int j=0;
01030 for(std::vector<double>::const_iterator it = amplwgtvAftGain[i].begin(); it != amplwgtvAftGain[i].end(); ++it) {
01031 (amplWeightsAft_[i])[j]=*it;
01032 j++;
01033 }
01034 }
01035
01036
01037
01038 std::vector< std::vector<double> > pedwgtv(nTDCbins_);
01039
01040 if (!getWeightsFromFile_ && nTDCbins_ == 1)
01041 {
01042 std::vector<double> vped;
01043 vped.push_back( 0.33333 );
01044 vped.push_back( 0.33333 );
01045 vped.push_back( 0.33333 );
01046 vped.push_back( 0. );
01047 vped.push_back( 0. );
01048 vped.push_back( 0. );
01049 vped.push_back( 0. );
01050 vped.push_back( 0. );
01051 vped.push_back( 0. );
01052 vped.push_back( 0. );
01053 pedwgtv[0] = ps.getUntrackedParameter< std::vector<double> >("pedWeights", vped);
01054 }
01055 else if (getWeightsFromFile_)
01056 {
01057
01058 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal weights from file " << edm::FileInPath(pedWeightsFile_).fullPath().c_str() ;
01059 std::ifstream pedFile(edm::FileInPath(pedWeightsFile_).fullPath().c_str());
01060 int tdcBin=0;
01061 while (!pedFile.eof() && tdcBin < nTDCbins_)
01062 {
01063 for(int j = 0; j < 10; ++j) {
01064 float ww;
01065 pedFile >> ww;
01066 pedwgtv[tdcBin].push_back(ww);
01067 }
01068 ++tdcBin;
01069 }
01070 assert (tdcBin == nTDCbins_);
01071 }
01072 else
01073 {
01074
01075 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01076 throw cms::Exception("WrongConfig");
01077 }
01078
01079 for (int i=0;i<nTDCbins_;i++)
01080 {
01081 assert(pedwgtv[i].size() == 10);
01082 int j=0;
01083 for(std::vector<double>::const_iterator it = pedwgtv[i].begin(); it != pedwgtv[i].end(); ++it) {
01084 (pedWeights_[i])[j] = *it;
01085 j++;
01086 }
01087 }
01088
01089 std::vector< std::vector<double> > pedwgtvaft(nTDCbins_);
01090
01091 if (!getWeightsFromFile_ && nTDCbins_ == 1)
01092 {
01093 std::vector<double> vped;
01094 vped.push_back( 0. );
01095 vped.push_back( 0. );
01096 vped.push_back( 0. );
01097 vped.push_back( 0. );
01098 vped.push_back( 0. );
01099 vped.push_back( 0. );
01100 vped.push_back( 0. );
01101 vped.push_back( 0. );
01102 vped.push_back( 0. );
01103 vped.push_back( 0. );
01104 pedwgtvaft[0] = ps.getUntrackedParameter< std::vector<double> >("pedWeightsAft", vped);
01105 }
01106 else if (getWeightsFromFile_)
01107 {
01108
01109 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal after gain switch weights from file " << edm::FileInPath(pedWeightsAftFile_).fullPath().c_str() ;
01110 std::ifstream pedFile(edm::FileInPath(pedWeightsAftFile_).fullPath().c_str());
01111 int tdcBin=0;
01112 while (!pedFile.eof() && tdcBin < nTDCbins_)
01113 {
01114 for(int j = 0; j < 10; ++j) {
01115 float ww;
01116 pedFile >> ww;
01117 pedwgtvaft[tdcBin].push_back(ww);
01118 }
01119 ++tdcBin;
01120 }
01121 assert (tdcBin == nTDCbins_);
01122 }
01123 else
01124 {
01125
01126 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01127 throw cms::Exception("WrongConfig");
01128 }
01129
01130 for (int i=0;i<nTDCbins_;i++)
01131 {
01132 assert(pedwgtvaft[i].size() == 10);
01133 int j=0;
01134 for(std::vector<double>::const_iterator it = pedwgtvaft[i].begin(); it != pedwgtvaft[i].end(); ++it) {
01135 (pedWeightsAft_[i])[j]=*it;
01136 j++;
01137 }
01138 }
01139
01140
01141
01142
01143
01144 std::vector< std::vector<double> > jittwgtv(nTDCbins_);
01145
01146 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
01147 {
01148 std::vector<double> vjitt;
01149 vjitt.push_back( 0.04066309 );
01150 vjitt.push_back( 0.04066309 );
01151 vjitt.push_back( 0.04066309 );
01152 vjitt.push_back( 0.000 );
01153 vjitt.push_back( 1.325176 );
01154 vjitt.push_back( -0.04997078 );
01155 vjitt.push_back( -0.504338 );
01156 vjitt.push_back( -0.5024844 );
01157 vjitt.push_back( -0.3903718 );
01158 vjitt.push_back( 0.000 );
01159 jittwgtv[0] = ps.getUntrackedParameter< std::vector<double> >("jittWeights", vjitt);
01160 }
01161 else if (getWeightsFromFile_)
01162 {
01163
01164 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter weights from file " << edm::FileInPath(jittWeightsFile_).fullPath().c_str() ;
01165 std::ifstream jittFile(edm::FileInPath(jittWeightsFile_).fullPath().c_str());
01166 int tdcBin=0;
01167 while (!jittFile.eof() && tdcBin < nTDCbins_)
01168 {
01169 for(int j = 0; j < 10; ++j) {
01170 float ww;
01171 jittFile >> ww;
01172 jittwgtv[tdcBin].push_back(ww);
01173 }
01174 ++tdcBin;
01175 }
01176 assert (tdcBin == nTDCbins_);
01177 }
01178 else
01179 {
01180
01181 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01182 throw cms::Exception("WrongConfig");
01183 }
01184
01185 for (int i=0;i<nTDCbins_;i++)
01186 {
01187 assert(jittwgtv[i].size() == 10);
01188 int j=0;
01189 for(std::vector<double>::const_iterator it = jittwgtv[i].begin(); it != jittwgtv[i].end(); ++it) {
01190 (jittWeights_[i])[j]= *it;
01191 j++;
01192 }
01193 }
01194
01195 std::vector< std::vector<double> > jittwgtvaft(nTDCbins_);
01196
01197 if (!getWeightsFromFile_ && nTDCbins_ == 1)
01198 {
01199 std::vector<double> vjitt;
01200 vjitt.push_back( 0. );
01201 vjitt.push_back( 0. );
01202 vjitt.push_back( 0. );
01203 vjitt.push_back( 0. );
01204 vjitt.push_back( 1.097871 );
01205 vjitt.push_back( -0.04551035 );
01206 vjitt.push_back( -0.4159156 );
01207 vjitt.push_back( -0.4185352 );
01208 vjitt.push_back( -0.3367127 );
01209 vjitt.push_back( 0. );
01210 jittwgtvaft[0] = ps.getUntrackedParameter< std::vector<double> >("jittWeightsAft", vjitt);
01211 }
01212 else if (getWeightsFromFile_)
01213 {
01214
01215 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter after gain switch weights from file " << edm::FileInPath(jittWeightsAftFile_).fullPath().c_str() ;
01216 std::ifstream jittFile(edm::FileInPath(jittWeightsAftFile_).fullPath().c_str());
01217 int tdcBin=0;
01218 while (!jittFile.eof() && tdcBin < nTDCbins_)
01219 {
01220 for(int j = 0; j < 10; ++j) {
01221 float ww;
01222 jittFile >> ww;
01223 jittwgtvaft[tdcBin].push_back(ww);
01224 }
01225 ++tdcBin;
01226 }
01227 assert (tdcBin == nTDCbins_);
01228 }
01229 else
01230 {
01231
01232 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01233 throw cms::Exception("WrongConfig");
01234 }
01235
01236 for (int i=0;i<nTDCbins_;i++)
01237 {
01238 assert(jittwgtvaft[i].size() == 10);
01239 int j=0;
01240 for(std::vector<double>::const_iterator it = jittwgtvaft[i].begin(); it != jittwgtvaft[i].end(); ++it) {
01241 (jittWeightsAft_[i])[j]= *it;
01242 j++;
01243 }
01244 }
01245
01246
01247 std::vector< EcalWeightSet::EcalChi2WeightMatrix > chi2Matrix(nTDCbins_);
01248 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
01249 {
01250
01251
01252
01253
01254 chi2Matrix[0](0,0) = 0.694371;
01255 chi2Matrix[0](0,1) = -0.305629;
01256 chi2Matrix[0](0,2) = -0.305629;
01257 chi2Matrix[0](0,3) = 0.;
01258 chi2Matrix[0](0,4) = 0.;
01259 chi2Matrix[0](0,5) = 0.;
01260 chi2Matrix[0](0,6) = 0.;
01261 chi2Matrix[0](0,7) = 0.;
01262 chi2Matrix[0](0,8) = 0.;
01263 chi2Matrix[0](0,9) = 0.;
01264 chi2Matrix[0](1,0) = -0.305629;
01265 chi2Matrix[0](1,1) = 0.694371;
01266 chi2Matrix[0](1,2) = -0.305629;
01267 chi2Matrix[0](1,3) = 0.;
01268 chi2Matrix[0](1,4) = 0.;
01269 chi2Matrix[0](1,5) = 0.;
01270 chi2Matrix[0](1,6) = 0.;
01271 chi2Matrix[0](1,7) = 0.;
01272 chi2Matrix[0](1,8) = 0.;
01273 chi2Matrix[0](1,9) = 0.;
01274 chi2Matrix[0](2,0) = -0.305629;
01275 chi2Matrix[0](2,1) = -0.305629;
01276 chi2Matrix[0](2,2) = 0.694371;
01277 chi2Matrix[0](2,3) = 0.;
01278 chi2Matrix[0](2,4) = 0.;
01279 chi2Matrix[0](2,5) = 0.;
01280 chi2Matrix[0](2,6) = 0.;
01281 chi2Matrix[0](2,7) = 0.;
01282 chi2Matrix[0](2,8) = 0.;
01283 chi2Matrix[0](2,9) = 0.;
01284 chi2Matrix[0](3,0) = 0.;
01285 chi2Matrix[0](3,1) = 0.;
01286 chi2Matrix[0](3,2) = 0.;
01287 chi2Matrix[0](3,3) = 0.;
01288 chi2Matrix[0](3,4) = 0.;
01289 chi2Matrix[0](3,5) = 0.;
01290 chi2Matrix[0](3,6) = 0.;
01291 chi2Matrix[0](3,7) = 0.;
01292 chi2Matrix[0](3,8) = 0.;
01293 chi2Matrix[0](3,9) = 0.;
01294 chi2Matrix[0](4,0) = 0.;
01295 chi2Matrix[0](4,1) = 0.;
01296 chi2Matrix[0](4,2) = 0.;
01297 chi2Matrix[0](4,3) = 0.;
01298 chi2Matrix[0](4,4) = 0.8027116;
01299 chi2Matrix[0](4,5) = -0.2517103;
01300 chi2Matrix[0](4,6) = -0.2232882;
01301 chi2Matrix[0](4,7) = -0.1716192;
01302 chi2Matrix[0](4,8) = -0.1239006;
01303 chi2Matrix[0](4,9) = 0.;
01304 chi2Matrix[0](5,0) = 0.;
01305 chi2Matrix[0](5,1) = 0.;
01306 chi2Matrix[0](5,2) = 0.;
01307 chi2Matrix[0](5,3) = 0.;
01308 chi2Matrix[0](5,4) = -0.2517103;
01309 chi2Matrix[0](5,5) = 0.6528964;
01310 chi2Matrix[0](5,6) = -0.2972839;
01311 chi2Matrix[0](5,7) = -0.2067162;
01312 chi2Matrix[0](5,8) = -0.1230729;
01313 chi2Matrix[0](5,9) = 0.;
01314 chi2Matrix[0](6,0) = 0.;
01315 chi2Matrix[0](6,1) = 0.;
01316 chi2Matrix[0](6,2) = 0.;
01317 chi2Matrix[0](6,3) = 0.;
01318 chi2Matrix[0](6,4) = -0.2232882;
01319 chi2Matrix[0](6,5) = -0.2972839;
01320 chi2Matrix[0](6,6) = 0.7413607;
01321 chi2Matrix[0](6,7) = -0.1883866;
01322 chi2Matrix[0](6,8) = -0.1235052;
01323 chi2Matrix[0](6,9) = 0.;
01324 chi2Matrix[0](7,0) = 0.;
01325 chi2Matrix[0](7,1) = 0.;
01326 chi2Matrix[0](7,2) = 0.;
01327 chi2Matrix[0](7,3) = 0.;
01328 chi2Matrix[0](7,4) = -0.1716192;
01329 chi2Matrix[0](7,5) = -0.2067162;
01330 chi2Matrix[0](7,6) = -0.1883866;
01331 chi2Matrix[0](7,7) = 0.844935;
01332 chi2Matrix[0](7,8) = -0.124291;
01333 chi2Matrix[0](7,9) = 0.;
01334 chi2Matrix[0](8,0) = 0.;
01335 chi2Matrix[0](8,1) = 0.;
01336 chi2Matrix[0](8,2) = 0.;
01337 chi2Matrix[0](8,3) = 0.;
01338 chi2Matrix[0](8,4) = -0.1239006;
01339 chi2Matrix[0](8,5) = -0.1230729;
01340 chi2Matrix[0](8,6) = -0.1235052;
01341 chi2Matrix[0](8,7) = -0.124291;
01342 chi2Matrix[0](8,8) = 0.8749833;
01343 chi2Matrix[0](8,9) = 0.;
01344 chi2Matrix[0](9,0) = 0.;
01345 chi2Matrix[0](9,1) = 0.;
01346 chi2Matrix[0](9,2) = 0.;
01347 chi2Matrix[0](9,3) = 0.;
01348 chi2Matrix[0](9,4) = 0.;
01349 chi2Matrix[0](9,5) = 0.;
01350 chi2Matrix[0](9,6) = 0.;
01351 chi2Matrix[0](9,7) = 0.;
01352 chi2Matrix[0](9,8) = 0.;
01353 chi2Matrix[0](9,9) = 0.;
01354 }
01355 else if (getWeightsFromFile_)
01356 {
01357
01358 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading chi2Matrix from file " << edm::FileInPath(chi2MatrixFile_).fullPath().c_str() ;
01359 std::ifstream chi2MatrixFile(edm::FileInPath(chi2MatrixFile_).fullPath().c_str());
01360 int tdcBin=0;
01361 while (!chi2MatrixFile.eof() && tdcBin < nTDCbins_)
01362 {
01363
01364 for(int j = 0; j < 10; ++j) {
01365 for(int l = 0; l < 10; ++l) {
01366 float ww;
01367 chi2MatrixFile >> ww;
01368 chi2Matrix[tdcBin](j,l)=ww;
01369 }
01370 }
01371 ++tdcBin;
01372 }
01373 assert (tdcBin == nTDCbins_);
01374 }
01375 else
01376 {
01377
01378 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01379 throw cms::Exception("WrongConfig");
01380 }
01381
01382
01383
01384
01385 chi2Matrix_ = chi2Matrix;
01386
01387
01388 std::vector< EcalWeightSet::EcalChi2WeightMatrix > chi2MatrixAft(nTDCbins_);
01389 if (!getWeightsFromFile_ && nTDCbins_ == 1 )
01390 {
01391
01392
01393
01394
01395 chi2MatrixAft[0](0,0) = 0.;
01396 chi2MatrixAft[0](0,1) = 0.;
01397 chi2MatrixAft[0](0,2) = 0.;
01398 chi2MatrixAft[0](0,3) = 0.;
01399 chi2MatrixAft[0](0,4) = 0.;
01400 chi2MatrixAft[0](0,5) = 0.;
01401 chi2MatrixAft[0](0,6) = 0.;
01402 chi2MatrixAft[0](0,7) = 0.;
01403 chi2MatrixAft[0](0,8) = 0.;
01404 chi2MatrixAft[0](0,9) = 0.;
01405 chi2MatrixAft[0](1,0) = 0.;
01406 chi2MatrixAft[0](1,1) = 0.;
01407 chi2MatrixAft[0](1,2) = 0.;
01408 chi2MatrixAft[0](1,3) = 0.;
01409 chi2MatrixAft[0](1,4) = 0.;
01410 chi2MatrixAft[0](1,5) = 0.;
01411 chi2MatrixAft[0](1,6) = 0.;
01412 chi2MatrixAft[0](1,7) = 0.;
01413 chi2MatrixAft[0](1,8) = 0.;
01414 chi2MatrixAft[0](1,9) = 0.;
01415 chi2MatrixAft[0](2,0) = 0.;
01416 chi2MatrixAft[0](2,1) = 0.;
01417 chi2MatrixAft[0](2,2) = 0.;
01418 chi2MatrixAft[0](2,3) = 0.;
01419 chi2MatrixAft[0](2,4) = 0.;
01420 chi2MatrixAft[0](2,5) = 0.;
01421 chi2MatrixAft[0](2,6) = 0.;
01422 chi2MatrixAft[0](2,7) = 0.;
01423 chi2MatrixAft[0](2,8) = 0.;
01424 chi2MatrixAft[0](2,9) = 0.;
01425 chi2MatrixAft[0](3,0) = 0.;
01426 chi2MatrixAft[0](3,1) = 0.;
01427 chi2MatrixAft[0](3,2) = 0.;
01428 chi2MatrixAft[0](3,3) = 0.;
01429 chi2MatrixAft[0](3,4) = 0.;
01430 chi2MatrixAft[0](3,5) = 0.;
01431 chi2MatrixAft[0](3,6) = 0.;
01432 chi2MatrixAft[0](3,7) = 0.;
01433 chi2MatrixAft[0](3,8) = 0.;
01434 chi2MatrixAft[0](3,9) = 0.;
01435 chi2MatrixAft[0](4,0) = 0.;
01436 chi2MatrixAft[0](4,1) = 0.;
01437 chi2MatrixAft[0](4,2) = 0.;
01438 chi2MatrixAft[0](4,3) = 0.;
01439 chi2MatrixAft[0](4,4) = 0.8030884;
01440 chi2MatrixAft[0](4,5) = -0.2543541;
01441 chi2MatrixAft[0](4,6) = -0.2243544;
01442 chi2MatrixAft[0](4,7) = -0.1698177;
01443 chi2MatrixAft[0](4,8) = -0.1194506;
01444 chi2MatrixAft[0](4,9) = 0.;
01445 chi2MatrixAft[0](5,0) = 0.;
01446 chi2MatrixAft[0](5,1) = 0.;
01447 chi2MatrixAft[0](5,2) = 0.;
01448 chi2MatrixAft[0](5,3) = 0.;
01449 chi2MatrixAft[0](5,4) = -0.2543541;
01450 chi2MatrixAft[0](5,5) = 0.6714465;
01451 chi2MatrixAft[0](5,6) = -0.2898025;
01452 chi2MatrixAft[0](5,7) = -0.2193564;
01453 chi2MatrixAft[0](5,8) = -0.1542964;
01454 chi2MatrixAft[0](5,9) = 0.;
01455 chi2MatrixAft[0](6,0) = 0.;
01456 chi2MatrixAft[0](6,1) = 0.;
01457 chi2MatrixAft[0](6,2) = 0.;
01458 chi2MatrixAft[0](6,3) = 0.;
01459 chi2MatrixAft[0](6,4) = -0.2243544;
01460 chi2MatrixAft[0](6,5) = -0.2898025;
01461 chi2MatrixAft[0](6,6) = 0.7443781;
01462 chi2MatrixAft[0](6,7) = -0.1934846;
01463 chi2MatrixAft[0](6,8) = -0.136098;
01464 chi2MatrixAft[0](6,9) = 0.;
01465 chi2MatrixAft[0](7,0) = 0.;
01466 chi2MatrixAft[0](7,1) = 0.;
01467 chi2MatrixAft[0](7,2) = 0.;
01468 chi2MatrixAft[0](7,3) = 0.;
01469 chi2MatrixAft[0](7,4) = -0.1698177;
01470 chi2MatrixAft[0](7,5) = -0.2193564;
01471 chi2MatrixAft[0](7,6) = -0.1934846;
01472 chi2MatrixAft[0](7,7) = 0.8535482;
01473 chi2MatrixAft[0](7,8) = -0.1030149;
01474 chi2MatrixAft[0](7,9) = 0.;
01475 chi2MatrixAft[0](8,0) = 0.;
01476 chi2MatrixAft[0](8,1) = 0.;
01477 chi2MatrixAft[0](8,2) = 0.;
01478 chi2MatrixAft[0](8,3) = 0.;
01479 chi2MatrixAft[0](8,4) = -0.1194506;
01480 chi2MatrixAft[0](8,5) = -0.1542964;
01481 chi2MatrixAft[0](8,6) = -0.136098;
01482 chi2MatrixAft[0](8,7) = -0.1030149;
01483 chi2MatrixAft[0](8,8) = 0.9275388;
01484 chi2MatrixAft[0](8,9) = 0.;
01485 chi2MatrixAft[0](9,0) = 0.;
01486 chi2MatrixAft[0](9,1) = 0.;
01487 chi2MatrixAft[0](9,2) = 0.;
01488 chi2MatrixAft[0](9,3) = 0.;
01489 chi2MatrixAft[0](9,4) = 0.;
01490 chi2MatrixAft[0](9,5) = 0.;
01491 chi2MatrixAft[0](9,6) = 0.;
01492 chi2MatrixAft[0](9,7) = 0.;
01493 chi2MatrixAft[0](9,8) = 0.;
01494 chi2MatrixAft[0](9,9) = 0.;
01495 }
01496 else if (getWeightsFromFile_)
01497 {
01498
01499 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading chi2MatrixAft from file " << edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str() ;
01500 std::ifstream chi2MatrixAftFile(edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str());
01501 int tdcBin=0;
01502 while (!chi2MatrixAftFile.eof() && tdcBin < nTDCbins_)
01503 {
01504
01505 for(int j = 0; j < 10; ++j) {
01506 for(int l = 0; l < 10; ++l) {
01507 float ww;
01508 chi2MatrixAftFile >> ww;
01509 chi2MatrixAft[tdcBin](j,l)=ww;
01510 }
01511 }
01512 ++tdcBin;
01513 }
01514 assert (tdcBin == nTDCbins_);
01515 }
01516 else
01517 {
01518
01519 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
01520 throw cms::Exception("WrongConfig");
01521 }
01522
01523
01524
01525
01526 chi2MatrixAft_ = chi2MatrixAft;
01527
01528
01529 }
01530
01531
01532
01533
01534 std::auto_ptr<EcalChannelStatus>
01535 EcalTrivialConditionRetriever::getChannelStatusFromConfiguration (const EcalChannelStatusRcd&)
01536 {
01537 std::auto_ptr<EcalChannelStatus> ecalStatus = std::auto_ptr<EcalChannelStatus>( new EcalChannelStatus() );
01538
01539
01540
01541
01542
01543 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01544 if(ieta==0) continue;
01545 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01546 if (EBDetId::validDetId(ieta,iphi)) {
01547 EBDetId ebid(ieta,iphi);
01548 ecalStatus->setValue( ebid, 0 );
01549 }
01550 }
01551 }
01552
01553 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01554 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01555
01556 if (EEDetId::validDetId(iX,iY,1)) {
01557 EEDetId eedetidpos(iX,iY,1);
01558 ecalStatus->setValue( eedetidpos, 0 );
01559 }
01560 if (EEDetId::validDetId(iX,iY,-1)) {
01561 EEDetId eedetidneg(iX,iY,-1);
01562 ecalStatus->setValue( eedetidneg, 0 );
01563 }
01564 }
01565 }
01566
01567
01568
01569
01570
01571 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
01572 std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
01573 if ( !statusFile.good() ) {
01574 edm::LogError ("EcalTrivialConditionRetriever")
01575 << "*** Problems opening file: " << channelStatusFile_ ;
01576 throw cms::Exception ("Cannot open ECAL channel status file") ;
01577 }
01578
01579 std::string EcalSubDet;
01580 std::string str;
01581 int hashIndex(0);
01582 int status(0);
01583
01584 while (!statusFile.eof())
01585 {
01586 statusFile >> EcalSubDet;
01587 if (EcalSubDet!=std::string("EB") && EcalSubDet!=std::string("EE"))
01588 {
01589 std::getline(statusFile,str);
01590 continue;
01591 }
01592 else
01593 {
01594 statusFile>> hashIndex >> status;
01595 }
01596
01597
01598 if(EcalSubDet==std::string("EB"))
01599 {
01600 EBDetId ebid = EBDetId::unhashIndex(hashIndex);
01601 ecalStatus->setValue( ebid, status );
01602 }
01603 else if(EcalSubDet==std::string("EE"))
01604 {
01605 EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
01606 ecalStatus->setValue( eedetid, status );
01607 }
01608 else
01609 {
01610 edm::LogError ("EcalTrivialConditionRetriever")
01611 << " *** " << EcalSubDet << " is neither EB nor EE ";
01612 }
01613
01614 }
01615
01616
01617
01618 statusFile.close();
01619 return ecalStatus;
01620 }
01621
01622
01623
01624 std::auto_ptr<EcalChannelStatus>
01625 EcalTrivialConditionRetriever::produceEcalChannelStatus( const EcalChannelStatusRcd& )
01626 {
01627
01628 std::auto_ptr<EcalChannelStatus> ical = std::auto_ptr<EcalChannelStatus>( new EcalChannelStatus() );
01629
01630 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01631 if(ieta==0) continue;
01632 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01633 if (EBDetId::validDetId(ieta,iphi)) {
01634 EBDetId ebid(ieta,iphi);
01635 ical->setValue( ebid, 0 );
01636 }
01637 }
01638 }
01639
01640 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01641 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01642
01643 if (EEDetId::validDetId(iX,iY,1)) {
01644 EEDetId eedetidpos(iX,iY,1);
01645 ical->setValue( eedetidpos, 0 );
01646 }
01647 if (EEDetId::validDetId(iX,iY,-1)) {
01648 EEDetId eedetidneg(iX,iY,-1);
01649 ical->setValue( eedetidneg, 0 );
01650 }
01651 }
01652 }
01653 return ical;
01654 }
01655
01656
01657 std::auto_ptr<EcalDQMChannelStatus>
01658 EcalTrivialConditionRetriever::produceEcalDQMChannelStatus( const EcalDQMChannelStatusRcd& )
01659 {
01660 uint32_t sta(0);
01661
01662 std::auto_ptr<EcalDQMChannelStatus> ical = std::auto_ptr<EcalDQMChannelStatus>( new EcalDQMChannelStatus() );
01663
01664 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01665 if(ieta==0) continue;
01666 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01667 if (EBDetId::validDetId(ieta,iphi)) {
01668 EBDetId ebid(ieta,iphi);
01669 ical->setValue( ebid, sta );
01670 }
01671 }
01672 }
01673
01674 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01675 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01676
01677 if (EEDetId::validDetId(iX,iY,1)) {
01678 EEDetId eedetidpos(iX,iY,1);
01679 ical->setValue( eedetidpos, sta );
01680 }
01681 if (EEDetId::validDetId(iX,iY,-1)) {
01682 EEDetId eedetidneg(iX,iY,-1);
01683 ical->setValue( eedetidneg, sta );
01684 }
01685 }
01686 }
01687 return ical;
01688 }
01689
01690
01691 std::auto_ptr<EcalDQMTowerStatus>
01692 EcalTrivialConditionRetriever::produceEcalDQMTowerStatus( const EcalDQMTowerStatusRcd& )
01693 {
01694
01695 std::auto_ptr<EcalDQMTowerStatus> ical = std::auto_ptr<EcalDQMTowerStatus>( new EcalDQMTowerStatus() );
01696
01697 uint32_t sta(0);
01698
01699
01700 int iz=0;
01701 for(int k=0 ; k<2; k++ ) {
01702 if(k==0) iz=-1;
01703 if(k==1) iz=+1;
01704 for(int i=1 ; i<73; i++) {
01705 for(int j=1 ; j<18; j++) {
01706 if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,j,i )){
01707 EcalTrigTowerDetId ebid(iz,EcalBarrel,j,i);
01708
01709 ical->setValue( ebid, sta );
01710 }
01711 }
01712 }
01713 }
01714
01715
01716
01717 for(int k=0 ; k<2; k++ ) {
01718 if(k==0) iz=-1;
01719 if(k==1) iz=+1;
01720 for(int i=1 ; i<21; i++) {
01721 for(int j=1 ; j<21; j++) {
01722 if (EcalScDetId::validDetId(i,j,iz )){
01723 EcalScDetId eeid(i,j,iz);
01724 ical->setValue( eeid, sta );
01725 }
01726 }
01727 }
01728 }
01729
01730 return ical;
01731 }
01732
01733
01734 std::auto_ptr<EcalDCSTowerStatus>
01735 EcalTrivialConditionRetriever::produceEcalDCSTowerStatus( const EcalDCSTowerStatusRcd& )
01736 {
01737
01738 std::auto_ptr<EcalDCSTowerStatus> ical = std::auto_ptr<EcalDCSTowerStatus>( new EcalDCSTowerStatus() );
01739
01740 int status(0);
01741
01742
01743 int iz=0;
01744 for(int k=0 ; k<2; k++ ) {
01745 if(k==0) iz=-1;
01746 if(k==1) iz=+1;
01747 for(int i=1 ; i<73; i++) {
01748 for(int j=1 ; j<18; j++) {
01749 if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,j,i )){
01750 EcalTrigTowerDetId ebid(iz,EcalBarrel,j,i);
01751
01752 ical->setValue( ebid, status );
01753 }
01754 }
01755 }
01756 }
01757
01758
01759
01760 for(int k=0 ; k<2; k++ ) {
01761 if(k==0) iz=-1;
01762 if(k==1) iz=+1;
01763 for(int i=1 ; i<21; i++) {
01764 for(int j=1 ; j<21; j++) {
01765 if (EcalScDetId::validDetId(i,j,iz )){
01766 EcalScDetId eeid(i,j,iz);
01767 ical->setValue( eeid, status );
01768 }
01769 }
01770 }
01771 }
01772
01773 return ical;
01774 }
01775
01776
01777 std::auto_ptr<EcalDAQTowerStatus>
01778 EcalTrivialConditionRetriever::produceEcalDAQTowerStatus( const EcalDAQTowerStatusRcd& )
01779 {
01780
01781 std::auto_ptr<EcalDAQTowerStatus> ical = std::auto_ptr<EcalDAQTowerStatus>( new EcalDAQTowerStatus() );
01782
01783 int status(0);
01784
01785
01786 int iz=0;
01787 for(int k=0 ; k<2; k++ ) {
01788 if(k==0) iz=-1;
01789 if(k==1) iz=+1;
01790 for(int i=1 ; i<73; i++) {
01791 for(int j=1 ; j<18; j++) {
01792 if (EcalTrigTowerDetId::validDetId(iz,EcalBarrel,j,i )){
01793 EcalTrigTowerDetId ebid(iz,EcalBarrel,j,i);
01794
01795 ical->setValue( ebid, status );
01796 }
01797 }
01798 }
01799 }
01800
01801
01802
01803 for(int k=0 ; k<2; k++ ) {
01804 if(k==0) iz=-1;
01805 if(k==1) iz=+1;
01806 for(int i=1 ; i<21; i++) {
01807 for(int j=1 ; j<21; j++) {
01808 if (EcalScDetId::validDetId(i,j,iz )){
01809 EcalScDetId eeid(i,j,iz);
01810 ical->setValue( eeid, status );
01811 }
01812 }
01813 }
01814 }
01815
01816 return ical;
01817 }
01818
01819
01820 std::auto_ptr<EcalTPGCrystalStatus>
01821 EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration (const EcalTPGCrystalStatusRcd&)
01822 {
01823 std::auto_ptr<EcalTPGCrystalStatus> ecalStatus = std::auto_ptr<EcalTPGCrystalStatus>( new EcalTPGCrystalStatus() );
01824
01825
01826
01827
01828
01829 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01830 if(ieta==0) continue;
01831 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01832 if (EBDetId::validDetId(ieta,iphi)) {
01833 EBDetId ebid(ieta,iphi);
01834 ecalStatus->setValue( ebid, 0 );
01835 }
01836 }
01837 }
01838
01839 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01840 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01841
01842 if (EEDetId::validDetId(iX,iY,1)) {
01843 EEDetId eedetidpos(iX,iY,1);
01844 ecalStatus->setValue( eedetidpos, 0 );
01845 }
01846 if (EEDetId::validDetId(iX,iY,-1)) {
01847 EEDetId eedetidneg(iX,iY,-1);
01848 ecalStatus->setValue( eedetidneg, 0 );
01849 }
01850 }
01851 }
01852
01853
01854
01855
01856
01857 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str() ;
01858 std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
01859 if ( !statusFile.good() ) {
01860 edm::LogError ("EcalTrivialConditionRetriever")
01861 << "*** Problems opening file: " << channelStatusFile_ ;
01862 throw cms::Exception ("Cannot open ECAL channel status file") ;
01863 }
01864
01865 std::string EcalSubDet;
01866 std::string str;
01867 int hashIndex(0);
01868 int status(0);
01869
01870 while (!statusFile.eof())
01871 {
01872 statusFile >> EcalSubDet;
01873 if (EcalSubDet!=std::string("EB") && EcalSubDet!=std::string("EE"))
01874 {
01875 std::getline(statusFile,str);
01876 continue;
01877 }
01878 else
01879 {
01880 statusFile>> hashIndex >> status;
01881 }
01882
01883
01884 if(EcalSubDet==std::string("EB"))
01885 {
01886 EBDetId ebid = EBDetId::unhashIndex(hashIndex);
01887 ecalStatus->setValue( ebid, status );
01888 }
01889 else if(EcalSubDet==std::string("EE"))
01890 {
01891 EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
01892 ecalStatus->setValue( eedetid, status );
01893 }
01894 else
01895 {
01896 edm::LogError ("EcalTrivialConditionRetriever")
01897 << " *** " << EcalSubDet << " is neither EB nor EE ";
01898 }
01899
01900 }
01901
01902
01903
01904 statusFile.close();
01905 return ecalStatus;
01906 }
01907
01908
01909
01910 std::auto_ptr<EcalTPGCrystalStatus>
01911 EcalTrivialConditionRetriever::produceEcalTrgChannelStatus( const EcalTPGCrystalStatusRcd& )
01912 {
01913
01914 std::auto_ptr<EcalTPGCrystalStatus> ical = std::auto_ptr<EcalTPGCrystalStatus>( new EcalTPGCrystalStatus() );
01915
01916 for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
01917 if(ieta==0) continue;
01918 for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
01919 if (EBDetId::validDetId(ieta,iphi)) {
01920 EBDetId ebid(ieta,iphi);
01921 ical->setValue( ebid, 0 );
01922 }
01923 }
01924 }
01925
01926 for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
01927 for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
01928
01929 if (EEDetId::validDetId(iX,iY,1)) {
01930 EEDetId eedetidpos(iX,iY,1);
01931 ical->setValue( eedetidpos, 0 );
01932 }
01933 if (EEDetId::validDetId(iX,iY,-1)) {
01934 EEDetId eedetidneg(iX,iY,-1);
01935 ical->setValue( eedetidneg, 0 );
01936 }
01937 }
01938 }
01939 return ical;
01940 }
01941
01942
01943
01944
01945
01946
01947 std::auto_ptr<EcalIntercalibConstants>
01948 EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration
01949 ( const EcalIntercalibConstantsRcd& )
01950 {
01951 std::auto_ptr<EcalIntercalibConstants> ical =
01952 std::auto_ptr<EcalIntercalibConstants>( new EcalIntercalibConstants() );
01953
01954
01955
01956
01957 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading intercalibration constants from file "
01958 << intercalibConstantsFile_.c_str() ;
01959
01960 FILE *inpFile ;
01961 inpFile = fopen (intercalibConstantsFile_.c_str (),"r") ;
01962 if (!inpFile)
01963 {
01964 edm::LogError ("EcalTrivialConditionRetriever")
01965 << "*** Can not open file: " << intercalibConstantsFile_ ;
01966 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
01967 }
01968
01969 char line[256] ;
01970 std::ostringstream str ;
01971 fgets (line,255,inpFile) ;
01972 int sm_number=atoi (line) ;
01973 str << "sm: " << sm_number ;
01974
01975 fgets (line,255,inpFile) ;
01976
01977
01978 fgets (line,255,inpFile) ;
01979 std::string gen_tag = line ;
01980 str << "gen tag: " << gen_tag ;
01981
01982 fgets (line,255,inpFile) ;
01983 std::string cali_method = line ;
01984 str << "cali method: " << cali_method << std::endl ;
01985
01986 fgets (line,255,inpFile) ;
01987 std::string cali_version = line ;
01988 str << "cali version: " << cali_version << std::endl ;
01989
01990 fgets (line,255,inpFile) ;
01991 std::string cali_type = line ;
01992 str << "cali type: " << cali_type ;
01993
01994 edm::LogInfo("EcalTrivialConditionRetriever")
01995 << "[PIETRO] Intercalibration file - "
01996 << str.str () << std::endl ;
01997
01998 float calib[1700]={1} ;
01999 float calib_rms[1700]={0} ;
02000 int calib_nevents[1700]={0} ;
02001 int calib_status[1700]={0} ;
02002
02003 int ii = 0 ;
02004
02005 while (fgets (line,255,inpFile))
02006 {
02007 ii++;
02008 int dmy_num = 0 ;
02009 float dmy_calib = 0. ;
02010 float dmy_RMS = 0. ;
02011 int dmy_events = 0 ;
02012 int dmy_status = 0 ;
02013 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
02014 &dmy_RMS, &dmy_events,
02015 &dmy_status) ;
02016 assert (dmy_num >= 1) ;
02017 assert (dmy_num <= 1700) ;
02018 calib[dmy_num-1] = dmy_calib ;
02019 calib_rms[dmy_num-1] = dmy_RMS ;
02020 calib_nevents[dmy_num-1] = dmy_events ;
02021 calib_status[dmy_num-1] = dmy_status ;
02022
02023
02024
02025
02026
02027
02028
02029
02030 }
02031
02032 fclose (inpFile) ;
02033 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals " ;
02034 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
02035 << "Some crystals missing, set to 1" << std::endl ;
02036
02037
02038
02039
02040
02041 int sm_db=1 ;
02042
02043 for (int i=0 ; i<1700 ; i++)
02044 {
02045
02046
02047
02048
02049
02050
02051
02052 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
02053 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
02054 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
02055 else ical->setValue (ebid.rawId (), 1.) ;
02056 }
02057
02058 }
02059
02060
02061 return ical;
02062 }
02063
02064
02065 std::auto_ptr<EcalIntercalibErrors>
02066 EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration
02067 ( const EcalIntercalibErrorsRcd& )
02068 {
02069 std::auto_ptr<EcalIntercalibErrors> ical =
02070 std::auto_ptr<EcalIntercalibErrors>( new EcalIntercalibErrors() );
02071
02072
02073
02074
02075 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading intercalibration constants from file "
02076 << intercalibErrorsFile_.c_str() ;
02077
02078 FILE *inpFile ;
02079 inpFile = fopen (intercalibErrorsFile_.c_str (),"r") ;
02080 if (!inpFile)
02081 {
02082 edm::LogError ("EcalTrivialConditionRetriever")
02083 << "*** Can not open file: " << intercalibErrorsFile_ ;
02084 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
02085 }
02086
02087 char line[256] ;
02088 std::ostringstream str ;
02089 fgets (line,255,inpFile) ;
02090 int sm_number=atoi (line) ;
02091 str << "sm: " << sm_number ;
02092
02093 fgets (line,255,inpFile) ;
02094
02095
02096 fgets (line,255,inpFile) ;
02097 std::string gen_tag = line ;
02098 str << "gen tag: " << gen_tag ;
02099
02100 fgets (line,255,inpFile) ;
02101 std::string cali_method = line ;
02102 str << "cali method: " << cali_method << std::endl ;
02103
02104 fgets (line,255,inpFile) ;
02105 std::string cali_version = line ;
02106 str << "cali version: " << cali_version << std::endl ;
02107
02108 fgets (line,255,inpFile) ;
02109 std::string cali_type = line ;
02110 str << "cali type: " << cali_type ;
02111
02112 edm::LogInfo("EcalTrivialConditionRetriever")
02113 << "[PIETRO] Intercalibration file - "
02114 << str.str () << std::endl ;
02115
02116 float calib[1700]={1} ;
02117 float calib_rms[1700]={0} ;
02118 int calib_nevents[1700]={0} ;
02119 int calib_status[1700]={0} ;
02120
02121 int ii = 0 ;
02122
02123 while (fgets (line,255,inpFile))
02124 {
02125 ii++;
02126 int dmy_num = 0 ;
02127 float dmy_calib = 0. ;
02128 float dmy_RMS = 0. ;
02129 int dmy_events = 0 ;
02130 int dmy_status = 0 ;
02131 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
02132 &dmy_RMS, &dmy_events,
02133 &dmy_status) ;
02134 assert (dmy_num >= 1) ;
02135 assert (dmy_num <= 1700) ;
02136 calib[dmy_num-1] = dmy_calib ;
02137 calib_rms[dmy_num-1] = dmy_RMS ;
02138 calib_nevents[dmy_num-1] = dmy_events ;
02139 calib_status[dmy_num-1] = dmy_status ;
02140
02141
02142
02143
02144
02145
02146
02147
02148 }
02149
02150 fclose (inpFile) ;
02151 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals " ;
02152 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
02153 << "Some crystals missing, set to 1" << std::endl ;
02154
02155
02156
02157
02158
02159 int sm_db=1 ;
02160
02161 for (int i=0 ; i<1700 ; i++)
02162 {
02163
02164
02165
02166
02167
02168
02169
02170 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
02171 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
02172 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
02173 else ical->setValue (ebid.rawId (), 1.) ;
02174 }
02175
02176 }
02177
02178
02179 return ical;
02180 }
02181
02182
02183
02184
02185 std::auto_ptr<EcalTimeCalibConstants>
02186 EcalTrivialConditionRetriever::getTimeCalibConstantsFromConfiguration
02187 ( const EcalTimeCalibConstantsRcd& )
02188 {
02189 std::auto_ptr<EcalTimeCalibConstants> ical =
02190 std::auto_ptr<EcalTimeCalibConstants>( new EcalTimeCalibConstants() );
02191
02192
02193
02194
02195 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading time calibration constants from file "
02196 << timeCalibConstantsFile_.c_str() ;
02197
02198 FILE *inpFile ;
02199 inpFile = fopen (timeCalibConstantsFile_.c_str (),"r") ;
02200 if (!inpFile)
02201 {
02202 edm::LogError ("EcalTrivialConditionRetriever")
02203 << "*** Can not open file: " << timeCalibConstantsFile_ ;
02204 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
02205 }
02206
02207 char line[256] ;
02208 std::ostringstream str ;
02209 fgets (line,255,inpFile) ;
02210 int sm_number=atoi (line) ;
02211 str << "sm: " << sm_number ;
02212
02213 fgets (line,255,inpFile) ;
02214
02215
02216 fgets (line,255,inpFile) ;
02217 std::string gen_tag = line ;
02218 str << "gen tag: " << gen_tag ;
02219
02220 fgets (line,255,inpFile) ;
02221 std::string cali_method = line ;
02222 str << "cali method: " << cali_method << std::endl ;
02223
02224 fgets (line,255,inpFile) ;
02225 std::string cali_version = line ;
02226 str << "cali version: " << cali_version << std::endl ;
02227
02228 fgets (line,255,inpFile) ;
02229 std::string cali_type = line ;
02230 str << "cali type: " << cali_type ;
02231
02232 edm::LogInfo("EcalTrivialConditionRetriever")
02233 << "TimeCalibration file - "
02234 << str.str () << std::endl ;
02235
02236 float calib[1700]={1} ;
02237 float calib_rms[1700]={0} ;
02238 int calib_nevents[1700]={0} ;
02239 int calib_status[1700]={0} ;
02240
02241 int ii = 0 ;
02242
02243 while (fgets (line,255,inpFile))
02244 {
02245 ii++;
02246 int dmy_num = 0 ;
02247 float dmy_calib = 0. ;
02248 float dmy_RMS = 0. ;
02249 int dmy_events = 0 ;
02250 int dmy_status = 0 ;
02251 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
02252 &dmy_RMS, &dmy_events,
02253 &dmy_status) ;
02254 assert (dmy_num >= 1) ;
02255 assert (dmy_num <= 1700) ;
02256 calib[dmy_num-1] = dmy_calib ;
02257 calib_rms[dmy_num-1] = dmy_RMS ;
02258 calib_nevents[dmy_num-1] = dmy_events ;
02259 calib_status[dmy_num-1] = dmy_status ;
02260
02261
02262
02263
02264
02265
02266
02267
02268 }
02269
02270 fclose (inpFile) ;
02271 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read timeCalibrations for " << ii << " xtals " ;
02272 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
02273 << "Some crystals missing, set to 1" << std::endl ;
02274
02275
02276
02277
02278
02279 int sm_db=1 ;
02280
02281 for (int i=0 ; i<1700 ; i++)
02282 {
02283
02284
02285
02286
02287
02288
02289
02290 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
02291 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
02292 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
02293 else ical->setValue (ebid.rawId (), 1.) ;
02294 }
02295
02296 }
02297
02298
02299 return ical;
02300 }
02301
02302
02303 std::auto_ptr<EcalTimeCalibErrors>
02304 EcalTrivialConditionRetriever::getTimeCalibErrorsFromConfiguration
02305 ( const EcalTimeCalibErrorsRcd& )
02306 {
02307 std::auto_ptr<EcalTimeCalibErrors> ical =
02308 std::auto_ptr<EcalTimeCalibErrors>( new EcalTimeCalibErrors() );
02309
02310
02311
02312
02313 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading timeCalibration constants from file "
02314 << timeCalibErrorsFile_.c_str() ;
02315
02316 FILE *inpFile ;
02317 inpFile = fopen (timeCalibErrorsFile_.c_str (),"r") ;
02318 if (!inpFile)
02319 {
02320 edm::LogError ("EcalTrivialConditionRetriever")
02321 << "*** Can not open file: " << timeCalibErrorsFile_ ;
02322 throw cms::Exception ("Cannot open inter-calibration coefficients txt file") ;
02323 }
02324
02325 char line[256] ;
02326 std::ostringstream str ;
02327 fgets (line,255,inpFile) ;
02328 int sm_number=atoi (line) ;
02329 str << "sm: " << sm_number ;
02330
02331 fgets (line,255,inpFile) ;
02332
02333
02334 fgets (line,255,inpFile) ;
02335 std::string gen_tag = line ;
02336 str << "gen tag: " << gen_tag ;
02337
02338 fgets (line,255,inpFile) ;
02339 std::string cali_method = line ;
02340 str << "cali method: " << cali_method << std::endl ;
02341
02342 fgets (line,255,inpFile) ;
02343 std::string cali_version = line ;
02344 str << "cali version: " << cali_version << std::endl ;
02345
02346 fgets (line,255,inpFile) ;
02347 std::string cali_type = line ;
02348 str << "cali type: " << cali_type ;
02349
02350 edm::LogInfo("EcalTrivialConditionRetriever")
02351 << "TimeCalibration file - "
02352 << str.str () << std::endl ;
02353
02354 float calib[1700]={1} ;
02355 float calib_rms[1700]={0} ;
02356 int calib_nevents[1700]={0} ;
02357 int calib_status[1700]={0} ;
02358
02359 int ii = 0 ;
02360
02361 while (fgets (line,255,inpFile))
02362 {
02363 ii++;
02364 int dmy_num = 0 ;
02365 float dmy_calib = 0. ;
02366 float dmy_RMS = 0. ;
02367 int dmy_events = 0 ;
02368 int dmy_status = 0 ;
02369 sscanf (line, "%d %f %f %d %d", &dmy_num, &dmy_calib,
02370 &dmy_RMS, &dmy_events,
02371 &dmy_status) ;
02372 assert (dmy_num >= 1) ;
02373 assert (dmy_num <= 1700) ;
02374 calib[dmy_num-1] = dmy_calib ;
02375 calib_rms[dmy_num-1] = dmy_RMS ;
02376 calib_nevents[dmy_num-1] = dmy_events ;
02377 calib_status[dmy_num-1] = dmy_status ;
02378
02379
02380
02381
02382
02383
02384
02385
02386 }
02387
02388 fclose (inpFile) ;
02389 edm::LogInfo ("EcalTrivialConditionRetriever") << "Read time calibrations for " << ii << " xtals " ;
02390 if (ii!=1700) edm::LogWarning ("StoreEcalCondition")
02391 << "Some crystals missing, set to 1" << std::endl ;
02392
02393
02394
02395
02396
02397 int sm_db=1 ;
02398
02399 for (int i=0 ; i<1700 ; i++)
02400 {
02401
02402
02403
02404
02405
02406
02407
02408 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
02409 EBDetId ebid (sm_db,i+1,EBDetId::SMCRYSTALMODE) ;
02410 if (calib_status[i]) ical->setValue (ebid.rawId (), calib[i]) ;
02411 else ical->setValue (ebid.rawId (), 1.) ;
02412 }
02413
02414 }
02415
02416
02417 return ical;
02418 }
02419
02420
02421
02422 std::auto_ptr<EcalMappingElectronics>
02423 EcalTrivialConditionRetriever::getMappingFromConfiguration (const EcalMappingElectronicsRcd&)
02424 {
02425 std::auto_ptr<EcalMappingElectronics> mapping = std::auto_ptr<EcalMappingElectronics>( new EcalMappingElectronics() );
02426 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading mapping from file " << edm::FileInPath(mappingFile_).fullPath().c_str() ;
02427
02428 std::ifstream f(edm::FileInPath(mappingFile_).fullPath().c_str());
02429 if (!f.good())
02430 {
02431 edm::LogError("EcalTrivialConditionRetriever") << "File not found";
02432 throw cms::Exception("FileNotFound");
02433 }
02434
02435
02436
02437 int ix, iy, iz, CL;
02438
02439
02440 int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
02441 int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
02442
02443 while ( ! f.eof())
02444 {
02445
02446 f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >>
02447 pseudostrip_in_TCC >> pseudostrip_in_TT ;
02448
02449
02450
02451
02452 EEDetId detid(ix,iy,iz,EEDetId::XYMODE);
02453
02454 EcalElectronicsId elecid(dccid,towerid, pseudostrip_in_SC, xtal_in_pseudostrip);
02455
02456 EcalTriggerElectronicsId triggerid(tccid, tower, pseudostrip_in_TT, xtal_in_pseudostrip);
02457 EcalMappingElement aElement;
02458 aElement.electronicsid = elecid.rawId();
02459 aElement.triggerid = triggerid.rawId();
02460 (*mapping).setValue(detid, aElement);
02461 }
02462
02463 f.close();
02464 return mapping;
02465 }
02466
02467
02468
02469 std::auto_ptr<EcalMappingElectronics>
02470 EcalTrivialConditionRetriever::produceEcalMappingElectronics( const EcalMappingElectronicsRcd& )
02471 {
02472
02473 std::auto_ptr<EcalMappingElectronics> ical = std::auto_ptr<EcalMappingElectronics>( new EcalMappingElectronics() );
02474 return ical;
02475 }