Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecal shape db #23600

Merged
merged 10 commits into from
Jul 24, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class EcalDccWeightBuilder: public edm::EDAnalyzer {
int iFirst0, int nWeights, int iSkip0,
std::vector<double>& result);

void computeAllWeights(bool withIntercalib);
void computeAllWeights(bool withIntercalib, const edm::EventSetup& es);

int encodeWeight(double w);

Expand Down
9 changes: 5 additions & 4 deletions CalibCalorimetry/EcalSRTools/src/EcalDccWeightBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ EcalDccWeightBuilder::analyze(const edm::Event& event,


//computes the weights:
computeAllWeights(dccWeightsWithIntercalib_);
computeAllWeights(dccWeightsWithIntercalib_, es);

//Writing out weights.
if(writeToAsciiFile_) writeWeightToAsciiFile();
if(writeToRootFile_) writeWeightToRootFile();
if(writeToDB_) writeWeightToDB();
}

void EcalDccWeightBuilder::computeAllWeights(bool withIntercalib){
void EcalDccWeightBuilder::computeAllWeights(bool withIntercalib, const edm::EventSetup& es){
const int nw = nDccWeights_;
int iSkip0_ = sampleToSkip_>=0?(sampleToSkip_-dcc1stSample_):-1;

Expand Down Expand Up @@ -169,8 +169,9 @@ void EcalDccWeightBuilder::computeAllWeights(bool withIntercalib){
#endif

try{
EBShape ebShape;
EEShape eeShape;
bool useDBShape = false;
EBShape ebShape(useDBShape);
EEShape eeShape(useDBShape);
EcalShapeBase* pShape;

if(it->subdetId()==EcalBarrel){
Expand Down
7 changes: 4 additions & 3 deletions CalibCalorimetry/EcalTPGTools/plugins/EcalTPGParamBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ double oneOverEtResolEt(double *x, double *par) {
}

EcalTPGParamBuilder::EcalTPGParamBuilder(edm::ParameterSet const& pSet)
: xtal_LSB_EB_(0), xtal_LSB_EE_(0), nSample_(5), complement2_(7)
: xtal_LSB_EB_(0), xtal_LSB_EE_(0), nSample_(5), complement2_(7), useDBShape_(false)
{
ped_conf_id_=0;
lin_conf_id_=0;
Expand Down Expand Up @@ -1450,8 +1450,9 @@ void EcalTPGParamBuilder::analyze(const edm::Event& evt, const edm::EventSetup&
const int NWEIGROUPS = 2 ;
std::vector<unsigned int> weights[NWEIGROUPS] ;

EBShape shapeEB ;
EEShape shapeEE ;
bool useDBShape = useDBShape_;
EBShape shapeEB(useDBShape) ; shapeEB.setEventSetup(evtSetup); // EBShape, EEShape are fetched now from DB (2018.05.22 K. Theofilatos)
EEShape shapeEE(useDBShape) ; shapeEE.setEventSetup(evtSetup); //
weights[0] = computeWeights(shapeEB, hshapeEB) ;
weights[1] = computeWeights(shapeEE, hshapeEE) ;

Expand Down
2 changes: 2 additions & 0 deletions CalibCalorimetry/EcalTPGTools/plugins/EcalTPGParamBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class EcalTPGParamBuilder : public edm::EDAnalyzer {
Int_t * ntupleInts_ ;
Char_t ntupleDet_[10] ;
Char_t ntupleCrate_[10] ;

bool useDBShape_;

};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
#include "CondFormats/EcalObjects/interface/EcalSamplesCorrelation.h"
#include "CondFormats/DataRecord/interface/EcalSamplesCorrelationRcd.h"

#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
#include "CondFormats/DataRecord/interface/EcalSimPulseShapeRcd.h"

#include "SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h"
#include "SimG4CMS/Calo/interface/EvolutionECAL.h"

Expand Down Expand Up @@ -137,6 +140,7 @@ class EcalTrivialConditionRetriever : public edm::ESProducer,
virtual std::unique_ptr<EcalTBWeights> produceEcalTBWeights( const EcalTBWeightsRcd& );
virtual std::unique_ptr<EcalIntercalibConstants> getIntercalibConstantsFromConfiguration ( const EcalIntercalibConstantsRcd& ) ;
virtual std::unique_ptr<EcalIntercalibConstantsMC> getIntercalibConstantsMCFromConfiguration ( const EcalIntercalibConstantsMCRcd& ) ;
virtual std::unique_ptr<EcalSimPulseShape> getEcalSimPulseShapeFromConfiguration ( const EcalSimPulseShapeRcd& ) ;
virtual std::unique_ptr<EcalIntercalibErrors> getIntercalibErrorsFromConfiguration ( const EcalIntercalibErrorsRcd& ) ;
virtual std::unique_ptr<EcalTimeCalibConstants> getTimeCalibConstantsFromConfiguration ( const EcalTimeCalibConstantsRcd& ) ;
virtual std::unique_ptr<EcalTimeCalibErrors> getTimeCalibErrorsFromConfiguration ( const EcalTimeCalibErrorsRcd& ) ;
Expand All @@ -153,6 +157,7 @@ class EcalTrivialConditionRetriever : public edm::ESProducer,
virtual std::unique_ptr<EcalClusterEnergyUncertaintyParameters> produceEcalClusterEnergyUncertaintyParameters( const EcalClusterEnergyUncertaintyParametersRcd& );
virtual std::unique_ptr<EcalClusterEnergyCorrectionObjectSpecificParameters> produceEcalClusterEnergyCorrectionObjectSpecificParameters( const EcalClusterEnergyCorrectionObjectSpecificParametersRcd& );


virtual std::unique_ptr<EcalChannelStatus> produceEcalChannelStatus( const EcalChannelStatusRcd& );
virtual std::unique_ptr<EcalChannelStatus> getChannelStatusFromConfiguration( const EcalChannelStatusRcd& );

Expand Down Expand Up @@ -219,6 +224,12 @@ class EcalTrivialConditionRetriever : public edm::ESProducer,
std::vector<double> energyUncertaintyParameters_;
std::vector<double> energyCorrectionObjectSpecificParameters_;

double sim_pulse_shape_EB_thresh_;
double sim_pulse_shape_EE_thresh_;
double sim_pulse_shape_APD_thresh_;
float sim_pulse_shape_TI_;


// ageing parameters
double totLumi_;
double instLumi_;
Expand Down Expand Up @@ -311,6 +322,10 @@ class EcalTrivialConditionRetriever : public edm::ESProducer,
std::vector<double> EEG6samplesCorrelation_;
std::vector<double> EEG1samplesCorrelation_;
std::string SamplesCorrelationFile_;
std::string EBSimPulseShapeFile_;
std::string EESimPulseShapeFile_;
std::string APDSimPulseShapeFile_;


int nTDCbins_;

Expand Down Expand Up @@ -343,10 +358,13 @@ class EcalTrivialConditionRetriever : public edm::ESProducer,
bool producedEcalAlignmentEB_;
bool producedEcalAlignmentEE_;
bool producedEcalAlignmentES_;
bool producedEcalSimPulseShape_;
bool getEBAlignmentFromFile_;
bool getEEAlignmentFromFile_;
bool getESAlignmentFromFile_;

bool getSimPulseShapeFromFile_;

bool getLaserAlphaFromFileEB_;
bool getLaserAlphaFromFileEE_;
bool getLaserAlphaFromTypeEB_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ EcalTrivialConditionRetriever::EcalTrivialConditionRetriever( const edm::Paramet
EEG6samplesCorrelation_ = ps.getUntrackedParameter< std::vector<double> >("EEG6samplesCorrelation", std::vector<double>() );
EEG1samplesCorrelation_ = ps.getUntrackedParameter< std::vector<double> >("EEG1samplesCorrelation", std::vector<double>() );


sim_pulse_shape_EB_thresh_ = ps.getParameter<double>("sim_pulse_shape_EB_thresh" );
sim_pulse_shape_EE_thresh_ = ps.getParameter<double>("sim_pulse_shape_EE_thresh" );
sim_pulse_shape_APD_thresh_ = ps.getParameter<double>("sim_pulse_shape_APD_thresh");

sim_pulse_shape_TI_ = ps.getUntrackedParameter<double>("sim_pulse_shape_TI", 1.0);

nTDCbins_ = 1;

weightsForAsynchronousRunning_ = ps.getUntrackedParameter<bool>("weightsForTB",false);
Expand Down Expand Up @@ -304,6 +311,19 @@ EcalTrivialConditionRetriever::EcalTrivialConditionRetriever( const edm::Paramet
findingRecord<EcalTimeCalibErrorsRcd> () ;
}

// sim pulse shape
getSimPulseShapeFromFile_ = ps.getUntrackedParameter<bool>("getSimPulseShapeFromFile",false);
producedEcalSimPulseShape_ = ps.getUntrackedParameter<bool>("producedEcalSimPulseShape",true);
EBSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EBSimPulseShapeFile","") ;
EESimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EESimPulseShapeFile","") ;
APDSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("APDSimPulseShapeFile","") ;

if (producedEcalSimPulseShape_) { // user asks to produce constants
setWhatProduced (this, &EcalTrivialConditionRetriever::getEcalSimPulseShapeFromConfiguration ) ;
findingRecord<EcalSimPulseShapeRcd> () ;
}


// cluster corrections
producedEcalClusterLocalContCorrParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterLocalContCorrParameters", false);
producedEcalClusterCrackCorrParameters_ = ps.getUntrackedParameter<bool>("producedEcalClusterCrackCorrParameters", false);
Expand Down Expand Up @@ -1001,6 +1021,7 @@ EcalTrivialConditionRetriever::produceEcalTBWeights( const EcalTBWeightsRcd& )
}



// cluster functions/corrections
std::unique_ptr<EcalClusterLocalContCorrParameters>
EcalTrivialConditionRetriever::produceEcalClusterLocalContCorrParameters( const EcalClusterLocalContCorrParametersRcd &)
Expand Down Expand Up @@ -3271,3 +3292,62 @@ EcalTrivialConditionRetriever::produceEcalSamplesCorrelation( const EcalSamplesC
back_inserter(ipar->EEG1SamplesCorrelation));
return ipar;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary white space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

std::unique_ptr<EcalSimPulseShape>
EcalTrivialConditionRetriever::getEcalSimPulseShapeFromConfiguration
( const EcalSimPulseShapeRcd& )
{
auto result = std::make_unique<EcalSimPulseShape>();

// save time interval to be used for the pulse shape
result->time_interval = sim_pulse_shape_TI_;

// containers to store the shape info
std::vector<double> EBshape;
std::vector<double> EEshape;
std::vector<double> APDshape;

// --- get the 3 shapes from the user provided txt files
if (!EBSimPulseShapeFile_.empty() )
{
std::ifstream shapeEBFile;
shapeEBFile.open(EBSimPulseShapeFile_.c_str());
double ww;
while (shapeEBFile >> ww) EBshape.push_back(ww);
shapeEBFile.close();
}
if (!EESimPulseShapeFile_.empty() )
{
std::ifstream shapeEEFile;
shapeEEFile.open(EESimPulseShapeFile_.c_str());
double ww;
while (shapeEEFile >> ww) EEshape.push_back(ww);
shapeEEFile.close();
}
if (!APDSimPulseShapeFile_.empty()) {
std::ifstream shapeAPDFile;
shapeAPDFile.open(APDSimPulseShapeFile_.c_str());
double ww;
while (shapeAPDFile >> ww) APDshape.push_back(ww);
shapeAPDFile.close();
}

// --- save threshold
result->barrel_thresh = sim_pulse_shape_EB_thresh_;
result->endcap_thresh = sim_pulse_shape_EE_thresh_;
result->apd_thresh = sim_pulse_shape_APD_thresh_;

// --- copy
copy(EBshape.begin(), EBshape.end(),
back_inserter(result->barrel_shape));
copy(EEshape.begin(), EEshape.end(),
back_inserter(result->endcap_shape));
copy(APDshape.begin(), APDshape.end(),
back_inserter(result->apd_shape));

return result;
}




5 changes: 4 additions & 1 deletion CondCore/EcalPlugins/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@
#include "CondFormats/DataRecord/interface/EcalPulseCovariancesRcd.h"
#include "CondFormats/EcalObjects/interface/EcalPulseSymmCovariances.h"
#include "CondFormats/DataRecord/interface/EcalPulseSymmCovariancesRcd.h"

#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
#include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
#include "CondFormats/DataRecord/interface/EcalSimPulseShapeRcd.h"


REGISTER_PLUGIN(EcalPedestalsRcd,EcalCondObjectContainer<EcalPedestal>);
Expand Down Expand Up @@ -185,6 +186,8 @@ REGISTER_PLUGIN(EcalClusterEnergyUncertaintyParametersRcd,EcalFunParams);
REGISTER_PLUGIN(EcalClusterEnergyCorrectionParametersRcd,EcalFunParams);
REGISTER_PLUGIN(EcalClusterEnergyCorrectionObjectSpecificParametersRcd,EcalFunParams);

REGISTER_PLUGIN(EcalSimPulseShapeRcd,EcalSimPulseShape);


REGISTER_PLUGIN(EcalMappingElectronicsRcd,EcalCondObjectContainer<EcalMappingElement>);

Expand Down
6 changes: 6 additions & 0 deletions CondFormats/DataRecord/interface/EcalSimPulseShapeRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef ECALSIMPULSESHAPESRCD_H
#define ECALSIMPULSESHAPESRCD_H

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
class EcalSimPulseShapeRcd : public edm::eventsetup::EventSetupRecordImplementation<EcalSimPulseShapeRcd> {};
#endif
4 changes: 4 additions & 0 deletions CondFormats/DataRecord/src/EcalSimPulseShapeRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/DataRecord/interface/EcalSimPulseShapeRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(EcalSimPulseShapeRcd);
27 changes: 27 additions & 0 deletions CondFormats/EcalObjects/interface/EcalSimPulseShape.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CondFormats_EcalObjects_EcalSimPulseShape_hh
#define CondFormats_EcalObjects_EcalSimPulseShape_hh

#include "CondFormats/Serialization/interface/Serializable.h"
#include <vector>

class EcalSimPulseShape{

public:
EcalSimPulseShape(){};
~EcalSimPulseShape(){};
void setTimeInterval(float x){time_interval=x;};
float getTimeInterval(){return time_interval;};


std::vector<double> barrel_shape; // there is no need to getters/setters, just access data directly
std::vector<double> endcap_shape; // there is no need to getters/setters, just access data directly
std::vector<double> apd_shape; // there is no need to getters/setters, just access data directly

double barrel_thresh;
double endcap_thresh;
double apd_thresh;
float time_interval; // time interval of the shape

COND_SERIALIZABLE;
};
#endif
1 change: 1 addition & 0 deletions CondFormats/EcalObjects/src/EcalSimPulseShape.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
4 changes: 4 additions & 0 deletions CondFormats/EcalObjects/src/T_EventSetup_EcalSimPulseShape.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
#include "FWCore/Utilities/interface/typelookup.h"
TYPELOOKUP_DATA_REG(EcalSimPulseShape);

6 changes: 2 additions & 4 deletions CondFormats/EcalObjects/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "CondFormats/EcalObjects/interface/EcalTPGStripStatus.h"
#include "CondFormats/EcalObjects/interface/EcalTPGSpike.h"
#include "CondFormats/EcalObjects/interface/EcalSRSettings.h"
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"

namespace CondFormats_EcalObjects {
struct dictionary {
Expand Down Expand Up @@ -198,10 +199,6 @@ namespace CondFormats_EcalObjects {
EcalTPGTowerStatus spike;

EcalSRSettings ecalSRSettings;
// std::vector<std::vector<short> > ecalSRSettings_srpMasksFromConfig;
// std::vector<std::vector<float> > ecalSRSettings_dccNormalizedWeights_0;
// std::vector<float> ecalSRSettings_dccNormalizedWeights_1;
// float ecalSRSettings_dccNormalizedWeights_elt_2;

EcalTimeBiasCorrections timeBiasCorrections;

Expand All @@ -222,5 +219,6 @@ namespace CondFormats_EcalObjects {
EcalContainer<EBDetId,EcalPulseSymmCovariance> ec_ebDetId_ecalPulseSymmCovariance;
EcalCondObjectContainer<EcalPulseSymmCovariance> ecalSPCmap; //typedef EcalPulseSymmCovariance

EcalSimPulseShape ecal_sim_pulse_shapes;
};
}
10 changes: 10 additions & 0 deletions CondFormats/EcalObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,14 @@
<field name = "ee_" mapping = "blob"/>
</class>

<class name="EcalSimPulseShape">
<field name = "barrel_shape" mapping = "blob"/>
<field name = "endcap_shape" mapping = "blob"/>
<field name = "apd_shape" mapping = "blob"/>
<field name = "barrel_thresh" mapping = "blob"/>
<field name = "endcap_thresh" mapping = "blob"/>
<field name = "apd_thresh" mapping = "blob"/>
<field name = "time_interval" mapping = "blob"/>
</class>

</lcgdict>
1 change: 1 addition & 0 deletions CondFormats/EcalObjects/src/headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "CondFormats/EcalObjects/interface/EcalPulseCovariances.h"
#include "CondFormats/EcalObjects/interface/EcalPulseSymmCovariances.h"
#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"

#include "CondFormats/External/interface/EcalDetID.h"
#include "CondFormats/External/interface/SMatrix.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ int main()
testSerialization<EcalPedestal>();
testSerialization<EcalPedestals>();
testSerialization<EcalSRSettings>();
testSerialization<EcalSimPulseShape>();
testSerialization<EcalSampleMask>();
testSerialization<EcalTBWeights>();
testSerialization<EcalTPGCrystalStatus>();
Expand Down
Loading