Skip to content

Commit

Permalink
Move EcalDigiSimRecoPhase2 from 11_1_X to 11_2_X
Browse files Browse the repository at this point in the history
  • Loading branch information
dariosol committed Oct 8, 2020
1 parent 396662c commit 09ee5b4
Show file tree
Hide file tree
Showing 56 changed files with 1,506 additions and 175 deletions.
6 changes: 4 additions & 2 deletions CalibFormats/CaloObjects/src/CaloTSamples.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "CalibFormats/CaloObjects/interface/CaloTSamples.icc"
#include "CalibFormats/CaloObjects/interface/CaloTSamplesBase.icc"
#include "CalibFormats/CaloObjects/interface/CaloTSamples.icc"
#include "CondFormats/EcalObjects/interface/EcalConstants.h"

template class CaloTSamplesBase<float>;

template class CaloTSamples<float, 10>;
template class CaloTSamples<float, ecalPh2::sampleSize>;
template class CaloTSamples<float, 3>;
template class CaloTSamples<float, 10>;
6 changes: 6 additions & 0 deletions CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef CondFormats_DataRecord_EcalCATIAGainRatiosRcd_H
#define CondFormats_DataRecord_EcalCATIAGainRatiosRcd_H

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
class EcalCATIAGainRatiosRcd : public edm::eventsetup::EventSetupRecordImplementation<EcalCATIAGainRatiosRcd> {};
#endif
6 changes: 6 additions & 0 deletions CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef CondFormats_DataRecord_EcalLiteDTUPedestalsRcd_h
#define CondFormats_DataRecord_EcalLiteDTUPedestalsRcd_h

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

EVENTSETUP_RECORD_REG(EcalCATIAGainRatiosRcd);
4 changes: 4 additions & 0 deletions CondFormats/DataRecord/src/EcalLiteDTUPedestalsRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(EcalLiteDTUPedestalsRcd);
10 changes: 10 additions & 0 deletions CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef CondFormats_EcalObjects_EcalCATIAGainRatios_h
#define CondFormats_EcalObjects_EcalCATIAGainRatios_h

#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"

typedef float EcalCATIAGainRatio;
typedef EcalFloatCondObjectContainer EcalCATIAGainRatioMap;
typedef EcalCATIAGainRatioMap EcalCATIAGainRatios;

#endif
31 changes: 31 additions & 0 deletions CondFormats/EcalObjects/interface/EcalConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Namespaces for Phase1 and Phase2
#ifndef CondFormats_EcalObject_EcalConstants_h
#define CondFormats_EcalObject_EcalConstants_h

class ecalPh2 {
public:
static constexpr double Samp_Period = 6.25;
static constexpr unsigned int NGAINS = 2;
static constexpr float gains[NGAINS] = {10., 1.};
static constexpr unsigned int gainId1 = 1;
static constexpr unsigned int gainId10 = 0;
static constexpr unsigned int sampleSize = 16;
static constexpr unsigned int NBITS = 12; // number of available bits
static constexpr unsigned int MAXADC = (1 << NBITS) - 1; // 2^12 -1, adc max range
static constexpr unsigned int kEBChannels = 61200;
static constexpr double maxEneEB = 2000.;
static constexpr unsigned int kNOffsets = 2000;
static constexpr unsigned int kAdcMask = 0xFFF;
static constexpr unsigned int kGainIdMask = 0x3;

}; // namespace ecalPh2

class ecalPh1 {
public:
static constexpr double Samp_Period = 25.;
static constexpr unsigned int NGAINS = 4;
static constexpr float gains[NGAINS] = {0., 12., 6., 1.};
static constexpr unsigned int sampleSize = 10;
static constexpr unsigned int kNOffsets = 2000;
}; // namespace ecalPh1
#endif
39 changes: 39 additions & 0 deletions CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef CondFormats_EcalObject_EcalLiteDTUPedestals_h
#define CondFormats_EcalObject_EcalLiteDTUPedestals_h

#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"
#include "CondFormats/EcalObjects/interface/EcalConstants.h"

class EcalLiteDTUPedestals {
public:
int setMean(unsigned int i, float value) {
if (i >= ecalPh2::NGAINS)
return -1;
else
meanarray[i] = value;
return 1;
}

int setRMS(unsigned int i, float value) {
if (i >= ecalPh2::NGAINS)
return -1;
else
rmsarray[i] = value;
return 1;
}

float mean(unsigned int i) const { return meanarray[i]; }

float rms(unsigned int i) const { return rmsarray[i]; }

private:
float meanarray[ecalPh2::NGAINS] = {13., 8.};
float rmsarray[ecalPh2::NGAINS] = {2.8, 1.2};
COND_SERIALIZABLE;
};

typedef EcalCondObjectContainer<EcalLiteDTUPedestals> EcalLiteDTUPedestalsMap;
typedef EcalLiteDTUPedestalsMap::const_iterator EcalLiteDTUPedestalsMapIterator;

#endif
1 change: 1 addition & 0 deletions CondFormats/EcalObjects/src/SerializationManual.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalLaserAPDPNRatios::Eca
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalMappingElement>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalMGPAGainRatio>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalPedestal>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalLiteDTUPedestals>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalPulseShape>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalPulseCovariance>);
COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer<EcalPulseSymmCovariance>);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(EcalLiteDTUPedestalsMap);
11 changes: 9 additions & 2 deletions CondFormats/EcalObjects/src/classes.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#include <cstdint>
#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h"
#include "CondFormats/EcalObjects/interface/EcalCondTowerObjectContainer.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
Expand Down Expand Up @@ -64,7 +64,9 @@
#include "CondFormats/EcalObjects/interface/EcalTPGSpike.h"
#include "CondFormats/EcalObjects/interface/EcalSRSettings.h"
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
#include <cstdint>
//ECAL PH2:
#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h"
#include "CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h"

namespace CondFormats_EcalObjects {
struct dictionary {
Expand Down Expand Up @@ -93,6 +95,11 @@ namespace CondFormats_EcalObjects {
EcalContainer<EBDetId, EcalPedestal> ec_ebDetId_ecalPedestal;
EcalCondObjectContainer<EcalPedestal> pedmap; //typedef EcalPedestals

//ECAL PH2:
std::vector<EcalLiteDTUPedestals> v_ecalDTUPedestals;
EcalContainer<EBDetId, EcalLiteDTUPedestals> ec_ebDetId_ecalLiteDTUPedestals;
EcalCondObjectContainer<EcalLiteDTUPedestals> pedmapDTU; //typedef EcalPedestals

std::vector<EcalTPGCrystalStatusCode> v_ecalTPGCrystalStatusCode;
EcalContainer<EEDetId, EcalTPGCrystalStatusCode> ec_eeDetId_ecalTPGCrystalStatusCode;
EcalContainer<EBDetId, EcalTPGCrystalStatusCode> ec_ebDetId_ecalTPGCrystalStatusCode;
Expand Down
8 changes: 8 additions & 0 deletions CondFormats/EcalObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@
<field name = "ee_" mapping = "blob"/>
</class>

<class name="EcalLiteDTUPedestals"/>
<!-- templates for EcalCondObjectContainer having the class as template parameter -->
<class name="std::vector<EcalLiteDTUPedestals>"/>
<class name="EcalContainer<EBDetId,EcalLiteDTUPedestals>"/>
<class name="EcalCondObjectContainer<EcalLiteDTUPedestals>">
<field name = "eb_" mapping = "blob"/>
</class>

<!-- base class -->
<class name="EcalTPGCrystalStatusCode"/>
<!-- templates for EcalCondObjectContainer having the class as template parameter -->
Expand Down
8 changes: 8 additions & 0 deletions Configuration/Eras/python/Era_Phase2C10_Ecal_Devel_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Phase2C10_cff import Phase2C10
from Configuration.Eras.Modifier_phase2_ecal_devel_cff import phase2_ecal_devel
from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose

Phase2C10_Ecal_Devel = cms.ModifierChain(Phase2C10,phase2_hfnose,phase2_ecal_devel)

4 changes: 4 additions & 0 deletions Configuration/Eras/python/Modifier_phase2_ecal_devel_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import FWCore.ParameterSet.Config as cms

phase2_ecal_devel = cms.Modifier()

3 changes: 3 additions & 0 deletions Configuration/StandardSequences/python/DigiToRaw_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@

from Configuration.Eras.Modifier_fastSim_cff import fastSim
fastSim.toReplaceWith(DigiToRawTask, DigiToRawTask.copyAndExclude([siPixelRawData,SiStripDigiToRaw,castorRawData,ctppsRawData]))

from Configuration.Eras.Modifier_phase2_ecal_devel_cff import phase2_ecal_devel
phase2_ecal_devel.toReplaceWith(DigiToRawTask, DigiToRawTask.copyAndExclude([esDigiToRaw]))
21 changes: 21 additions & 0 deletions Configuration/StandardSequences/python/Digi_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,24 @@ def _modifyEnableHcalHardcode( theProcess ):

from Configuration.Eras.Modifier_hcalHardcodeConditions_cff import hcalHardcodeConditions
modifyEnableHcalHardcode_ = hcalHardcodeConditions.makeProcessModifier( _modifyEnableHcalHardcode )


#phase 2 ecal pedestals
def _modifyEcalPedestals( process ):
process.load("SimCalorimetry.EcalSimProducers.esEcalLiteDTUPedestalsProducer_cfi")

from CondCore.CondDB.CondDB_cfi import CondDB
CondDB.connect = cms.string('sqlite_file:SimCalorimetry/EcalSimProducers/data/simPulseShapePhaseII.db')
process.ecalConditions = cms.ESSource("PoolDBESSource", CondDB,
toGet = cms.VPSet(
cms.PSet(
record = cms.string('EcalSimPulseShapeRcd') ,
tag = cms.string('EcalSimPulseShape_default_mc')
)
)
)
process.es_prefer_ecalPulseShape = cms.ESPrefer("PoolDBESSource","ecalConditions")

from Configuration.Eras.Modifier_phase2_ecal_devel_cff import phase2_ecal_devel
modifyDigi_Phase2EcalPed = phase2_ecal_devel.makeProcessModifier(_modifyEcalPedestals)

3 changes: 2 additions & 1 deletion Configuration/StandardSequences/python/Eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self):
'Phase2C10_dd4hep',
'Phase2C11_dd4hep',
'Phase2C12_dd4hep',
'Phase2C10_Ecal_Devel'
]

internalUseMods = ['run2_common', 'run2_25ns_specific',
Expand All @@ -56,7 +57,7 @@ def __init__(self):
'run2_CSC_2018',
'phase2_common', 'phase2_tracker',
'phase2_hgcal', 'phase2_muon', 'phase2_timing', 'phase2_hfnose', 'phase2_hgcalV10', 'phase2_hgcalV11', 'phase2_hgcalV12',
'phase2_timing_layer', 'phase2_hcal', 'phase2_ecal',
'phase2_timing_layer', 'phase2_hcal', 'phase2_ecal','phase2_ecal_devel',
'phase2_trigger',
'trackingLowPU', 'trackingPhase1', 'ctpps_2016', 'ctpps_2017', 'ctpps_2018', 'ctpps_2021', 'trackingPhase2PU140','highBetaStar_2018',
'tracker_apv_vfp30_2016', 'pf_badHcalMitigation', 'run2_miniAOD_80XLegacy','run2_miniAOD_94XFall17', 'run2_nanoAOD_92X',
Expand Down
1 change: 1 addition & 0 deletions DataFormats/EcalDigi/interface/EBDataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDigi/interface/EcalDataFrame.h"
#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h"
#include <iosfwd>

/** \class EBDataFrame
Expand Down
38 changes: 38 additions & 0 deletions DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef DataFormats_EcalDigi_EcalDataFrame_Ph2_h
#define DataFormats_EcalDigi_EcalDataFrame_Ph2_h
#include "DataFormats/EcalDigi/interface/EcalLiteDTUSample.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/Common/interface/DataFrame.h"
#include "CondFormats/EcalObjects/interface/EcalConstants.h"

/** \class EcalDataFrame_Ph2
*/
class EcalDataFrame_Ph2 {
public:
EcalDataFrame_Ph2() {}
EcalDataFrame_Ph2(edm::DataFrame const& iframe) : m_data(iframe) {}

virtual ~EcalDataFrame_Ph2() {}

DetId id() const { return m_data.id(); }

int size() const { return m_data.size(); }

EcalLiteDTUSample operator[](int i) const { return m_data[i]; }
EcalLiteDTUSample sample(int i) const { return m_data[i]; }

// FIXME (shall we throw??)
void setSize(int) {}
void setSample(int i, EcalLiteDTUSample sam) { m_data[i] = sam; }

static constexpr int MAXSAMPLES = ecalPh2::sampleSize;

edm::DataFrame const& frame() const { return m_data; }
edm::DataFrame& frame() { return m_data; }

private:
edm::DataFrame m_data;
};

#endif
27 changes: 27 additions & 0 deletions DataFormats/EcalDigi/interface/EcalDigiCollections.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
#include "DataFormats/Common/interface/DataFrameContainer.h"
#include "CondFormats/EcalObjects/interface/EcalConstants.h"

class EcalDigiCollectionPh2 : public edm::DataFrameContainer {
public:
typedef edm::DataFrameContainer::size_type size_type;
static const size_type MAXSAMPLES = ecalPh2::sampleSize;
explicit EcalDigiCollectionPh2(size_type istride = MAXSAMPLES, int isubdet = 0)
: edm::DataFrameContainer(istride, isubdet) {}
void swap(DataFrameContainer& other) { this->DataFrameContainer::swap(other); }
};

class EBDigiCollectionPh2 : public EcalDigiCollectionPh2 {
public:
typedef edm::DataFrameContainer::size_type size_type;
typedef EBDataFrame Digi;
typedef Digi::key_type DetId;

EBDigiCollectionPh2(size_type istride = MAXSAMPLES) : EcalDigiCollectionPh2(istride, EcalBarrel) {}
void swap(EBDigiCollectionPh2& other) { this->EcalDigiCollectionPh2::swap(other); }
void push_back(const Digi& digi) { DataFrameContainer::push_back(digi.id(), digi.frame().begin()); }
void push_back(id_type iid) { DataFrameContainer::push_back(iid); }
void push_back(id_type iid, data_type const* idata) { DataFrameContainer::push_back(iid, idata); }
};

class EcalDigiCollection : public edm::DataFrameContainer {
public:
Expand Down Expand Up @@ -89,6 +112,10 @@ inline void swap(EEDigiCollection& lhs, EEDigiCollection& rhs) { lhs.swap(rhs);

inline void swap(ESDigiCollection& lhs, ESDigiCollection& rhs) { lhs.swap(rhs); }

inline void swap(EcalDigiCollectionPh2& lhs, EcalDigiCollectionPh2& rhs) { lhs.swap(rhs); }

inline void swap(EBDigiCollectionPh2& lhs, EBDigiCollectionPh2& rhs) { lhs.swap(rhs); }

typedef edm::SortedCollection<EcalTimeDigi> EcalTimeDigiCollection;
typedef edm::SortedCollection<EcalTriggerPrimitiveDigi> EcalTrigPrimDigiCollection;
typedef edm::SortedCollection<EcalEBTriggerPrimitiveDigi> EcalEBTrigPrimDigiCollection;
Expand Down
47 changes: 47 additions & 0 deletions DataFormats/EcalDigi/interface/EcalLiteDTUSample.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef DataFormats_EcalDigi_EcalLiteDTUSample_h
#define DataFormats_EcalDigi_EcalLiteDTUSample_h

#include <iosfwd>
#include <cstdint>
#include "CondFormats/EcalObjects/interface/EcalConstants.h"

namespace ecalLiteDTU {
typedef uint16_t sample_type;

/// get the ADC sample (12 bits)
constexpr int adc(sample_type sample) { return sample & ecalPh2::kAdcMask; }
/// get the gainId (2 bits)
constexpr int gainId(sample_type sample) { return (sample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
constexpr sample_type pack(int adc, int gainId) {
return (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS);
}
} // namespace ecalLiteDTU

/** \class EcalLiteDTUSample
* Simple container packer/unpacker for a single sample from the Lite_CATIA electronics
*
*
*/
class EcalLiteDTUSample {
public:
EcalLiteDTUSample() { theSample = 0; }
EcalLiteDTUSample(uint16_t data) { theSample = data; }
EcalLiteDTUSample(int adc, int gainId);

/// get the raw word
uint16_t raw() const { return theSample; }
/// get the ADC sample (12 bits)
int adc() const { return theSample & ecalPh2::kAdcMask; }
/// get the gainId (2 bits)
int gainId() const { return (theSample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; }
/// for streaming
uint16_t operator()() const { return theSample; }
operator uint16_t() const { return theSample; }

private:
uint16_t theSample;
};

std::ostream& operator<<(std::ostream&, const EcalLiteDTUSample&);

#endif
11 changes: 11 additions & 0 deletions DataFormats/EcalDigi/src/EcalLiteDTUSample.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "DataFormats/EcalDigi/interface/EcalLiteDTUSample.h"
#include <iostream>

EcalLiteDTUSample::EcalLiteDTUSample(int adc, int gainId) {
theSample = (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS);
}

std::ostream& operator<<(std::ostream& s, const EcalLiteDTUSample& samp) {
s << "ADC=" << samp.adc() << ", gainId=" << samp.gainId();
return s;
}
Loading

0 comments on commit 09ee5b4

Please sign in to comment.