CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DTVDriftWriter Class Reference

#include <DTVDriftWriter.h>

Inheritance diagram for DTVDriftWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 DTVDriftWriter (const edm::ParameterSet &pset)
 
void endJob () override
 
 ~DTVDriftWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::ESHandle< DTGeometrydtGeom_
 
std::string granularity_
 
const DTMtimemTimeMap_
 
bool readLegacyVDriftDB
 
std::unique_ptr< dtCalibration::DTVDriftBaseAlgovDriftAlgo_
 
const DTRecoConditionsvDriftMap_
 
bool writeLegacyVDriftDB
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 25 of file DTVDriftWriter.h.

Constructor & Destructor Documentation

◆ DTVDriftWriter()

DTVDriftWriter::DTVDriftWriter ( const edm::ParameterSet pset)

Definition at line 35 of file DTVDriftWriter.cc.

36  : granularity_(pset.getUntrackedParameter<string>("calibGranularity", "bySL")),
37  mTimeMap_(nullptr),
38  vDriftMap_(nullptr),
39  vDriftAlgo_{DTVDriftPluginFactory::get()->create(pset.getParameter<string>("vDriftAlgo"),
40  pset.getParameter<ParameterSet>("vDriftAlgoConfig"))} {
41  LogVerbatim("Calibration") << "[DTVDriftWriter]Constructor called!";
42 
43  if (granularity_ != "bySL")
44  throw cms::Exception("Configuration")
45  << "[DTVDriftWriter] Check parameter calibGranularity: " << granularity_ << " option not available.";
46 
47  readLegacyVDriftDB = pset.getParameter<bool>("readLegacyVDriftDB");
48  writeLegacyVDriftDB = pset.getParameter<bool>("writeLegacyVDriftDB");
49 }

References get, and muonDTDigis_cfi::pset.

◆ ~DTVDriftWriter()

DTVDriftWriter::~DTVDriftWriter ( )
override

Definition at line 51 of file DTVDriftWriter.cc.

51 { LogVerbatim("Calibration") << "[DTVDriftWriter]Destructor called!"; }

Member Function Documentation

◆ analyze()

void DTVDriftWriter::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
inlineoverridevirtual

Implements edm::EDAnalyzer.

Definition at line 32 of file DTVDriftWriter.h.

32 {}

◆ beginRun()

void DTVDriftWriter::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file DTVDriftWriter.cc.

53  {
54  // Get the map of vdrift from the Setup
55  if (readLegacyVDriftDB) {
56  ESHandle<DTMtime> mTime;
57  setup.get<DTMtimeRcd>().get(mTime);
58  mTimeMap_ = &*mTime;
59  } else {
61  setup.get<DTRecoConditionsVdriftRcd>().get(hVdrift);
62  vDriftMap_ = &*hVdrift;
63  // Consistency check: no parametrization is implemented for the time being
64  int version = vDriftMap_->version();
65  if (version != 1) {
66  throw cms::Exception("Configuration") << "only version 1 is presently supported for VDriftDB";
67  }
68  }
69 
70  // Get geometry from Event Setup
72  // Pass EventSetup to concrete implementation
73  vDriftAlgo_->setES(setup);
74 }

References dtGeom_, Exception, get, mTimeMap_, readLegacyVDriftDB, singleTopDQM_cfi::setup, vDriftAlgo_, vDriftMap_, DTRecoConditions::version(), and BeamSplash_cfg::version.

◆ endJob()

void DTVDriftWriter::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 76 of file DTVDriftWriter.cc.

76  {
77  // Create the object to be written to DB
78  DTMtime* mTimeNewMap = nullptr;
79  DTRecoConditions* vDriftNewMap = nullptr;
80  if (writeLegacyVDriftDB) {
81  mTimeNewMap = new DTMtime();
82  } else {
83  vDriftNewMap = new DTRecoConditions();
84  vDriftNewMap->setFormulaExpr("[0]");
85  //vDriftNewMap->setFormulaExpr("[0]*(1-[1]*x)"); // add parametrization for dependency along Y
86  vDriftNewMap->setVersion(1);
87  }
88 
89  if (granularity_ == "bySL") {
90  // Get all the sls from the geometry
91  const vector<const DTSuperLayer*>& superLayers = dtGeom_->superLayers();
92  auto sl = superLayers.begin();
93  auto sl_end = superLayers.end();
94  for (; sl != sl_end; ++sl) {
95  DTSuperLayerId slId = (*sl)->id();
96 
97  // Compute vDrift
98  float vDriftNew = -1.;
99  float resolutionNew = -1;
100  try {
101  dtCalibration::DTVDriftData vDriftData = vDriftAlgo_->compute(slId);
102  vDriftNew = vDriftData.vdrift;
103  resolutionNew = vDriftData.resolution;
104  LogVerbatim("Calibration") << "vDrift for: " << slId << " Mean " << vDriftNew << " Resolution "
105  << resolutionNew;
106  } catch (cms::Exception& e) { // Failure to compute new value, fall back to old table
107  LogError("Calibration") << e.explainSelf();
108  if (readLegacyVDriftDB) { //...reading old db format...
109  int status = mTimeMap_->get(slId, vDriftNew, resolutionNew, DTVelocityUnits::cm_per_ns);
110  if (status == 0) { // not found; silently skip this SL
111  continue;
112  }
113  } else { //...reading new db format
114  try {
115  vDriftNew = vDriftMap_->get(DTWireId(slId.rawId()));
116  } catch (cms::Exception& e2) {
117  // not found; silently skip this SL
118  continue;
119  }
120  }
121  LogVerbatim("Calibration") << "Keep original vDrift for: " << slId << " Mean " << vDriftNew << " Resolution "
122  << resolutionNew;
123  }
124 
125  // Add value to the vdrift table
126  if (writeLegacyVDriftDB) {
127  mTimeNewMap->set(slId, vDriftNew, resolutionNew, DTVelocityUnits::cm_per_ns);
128  } else {
129  vector<double> params = {vDriftNew};
130  vDriftNewMap->set(DTWireId(slId.rawId()), params);
131  }
132  } // End of loop on superlayers
133  }
134 
135  // Write the vDrift object to DB
136  LogVerbatim("Calibration") << "[DTVDriftWriter]Writing vdrift object to DB!";
137  if (writeLegacyVDriftDB) {
138  string record = "DTMtimeRcd";
139  DTCalibDBUtils::writeToDB<DTMtime>(record, mTimeNewMap);
140  } else {
141  DTCalibDBUtils::writeToDB<DTRecoConditions>("DTRecoConditionsVdriftRcd", vDriftNewMap);
142  }
143 }

References DTVelocityUnits::cm_per_ns, dtGeom_, MillePedeFileConverter_cfg::e, DTRecoConditions::get(), DTMtime::get(), granularity_, mTimeMap_, CalibrationSummaryClient_cfi::params, DetId::rawId(), readLegacyVDriftDB, AlCaHarvesting_cff::record, dtCalibration::DTVDriftData::resolution, DTRecoConditions::set(), DTMtime::set(), DTRecoConditions::setFormulaExpr(), DTRecoConditions::setVersion(), mps_update::status, DTGeometry::superLayers(), dtCalibration::DTVDriftData::vdrift, vDriftAlgo_, vDriftMap_, and writeLegacyVDriftDB.

Referenced by o2olib.O2ORunMgr::executeJob().

Member Data Documentation

◆ dtGeom_

edm::ESHandle<DTGeometry> DTVDriftWriter::dtGeom_
private

Definition at line 43 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ granularity_

std::string DTVDriftWriter::granularity_
private

Definition at line 36 of file DTVDriftWriter.h.

Referenced by endJob().

◆ mTimeMap_

const DTMtime* DTVDriftWriter::mTimeMap_
private

Definition at line 38 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ readLegacyVDriftDB

bool DTVDriftWriter::readLegacyVDriftDB
private

Definition at line 40 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ vDriftAlgo_

std::unique_ptr<dtCalibration::DTVDriftBaseAlgo> DTVDriftWriter::vDriftAlgo_
private

Definition at line 45 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ vDriftMap_

const DTRecoConditions* DTVDriftWriter::vDriftMap_
private

Definition at line 39 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ writeLegacyVDriftDB

bool DTVDriftWriter::writeLegacyVDriftDB
private

Definition at line 41 of file DTVDriftWriter.h.

Referenced by endJob().

DTRecoConditionsVdriftRcd
Definition: DTRecoConditionsVdriftRcd.h:5
DTSuperLayerId
Definition: DTSuperLayerId.h:12
DTVDriftWriter::readLegacyVDriftDB
bool readLegacyVDriftDB
Definition: DTVDriftWriter.h:40
DTVDriftWriter::dtGeom_
edm::ESHandle< DTGeometry > dtGeom_
Definition: DTVDriftWriter.h:43
DTVDriftWriter::mTimeMap_
const DTMtime * mTimeMap_
Definition: DTVDriftWriter.h:38
mps_update.status
status
Definition: mps_update.py:68
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
dtCalibration::DTVDriftData::vdrift
double vdrift
Definition: DTVDriftBaseAlgo.h:23
DTMtime
Definition: DTMtime.h:68
DTMtime::set
int set(int wheelId, int stationId, int sectorId, int slId, float mTime, float mTrms, DTTimeUnits::type unit)
Definition: DTMtime.cc:168
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTRecoConditions::get
float get(const DTWireId &wireid, double *x=nullptr) const
Get the value correspoding to the given WireId, / using x[] as parameters of the parametrization when...
Definition: DTRecoConditions.cc:42
DTRecoConditions::setFormulaExpr
void setFormulaExpr(const std::string &expr)
Set the expression representing the formula used for parametrization.
Definition: DTRecoConditions.h:50
DTRecoConditions::version
int version() const
Version numer specifying the structure of the payload. See .cc file for details.
Definition: DTRecoConditions.h:43
dtCalibration::DTVDriftData::resolution
double resolution
Definition: DTVDriftBaseAlgo.h:24
DTVDriftWriter::vDriftAlgo_
std::unique_ptr< dtCalibration::DTVDriftBaseAlgo > vDriftAlgo_
Definition: DTVDriftWriter.h:45
DTWireId
Definition: DTWireId.h:12
edm::ESHandle
Definition: DTSurvey.h:22
DTRecoConditions::setVersion
void setVersion(int version)
Definition: DTRecoConditions.h:40
edm::ParameterSet
Definition: ParameterSet.h:47
DTVDriftWriter::vDriftMap_
const DTRecoConditions * vDriftMap_
Definition: DTVDriftWriter.h:39
DTVelocityUnits::cm_per_ns
Definition: DTVelocityUnits.h:32
DTVDriftWriter::writeLegacyVDriftDB
bool writeLegacyVDriftDB
Definition: DTVDriftWriter.h:41
DTGeometry::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:86
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTRecoConditions::set
void set(const DTWireId &wireid, const std::vector< double > &values)
Fill the payload.
Definition: DTRecoConditions.cc:78
Exception
Definition: hltDiff.cc:245
DTRecoConditions
Definition: DTRecoConditions.h:28
cms::Exception
Definition: Exception.h:70
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
dtCalibration::DTVDriftData
Definition: DTVDriftBaseAlgo.h:19
DTVDriftWriter::granularity_
std::string granularity_
Definition: DTVDriftWriter.h:36
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTMtime::get
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DTMtimeRcd
Definition: DTMtimeRcd.h:5