CMS 3D CMS Logo

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

#include <DTVDriftWriter.h>

Inheritance diagram for DTVDriftWriter:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase 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
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
 ~DTVDriftWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, 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::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::ESHandle< DTGeometrydtGeom_
 
const edm::ESGetToken< DTGeometry, MuonGeometryRecorddtGeomToken_
 
std::string granularity_
 
const DTMtimemTimeMap_
 
const edm::ESGetToken< DTMtime, DTMtimeRcdmTimeMapToken_
 
bool readLegacyVDriftDB
 
std::unique_ptr< dtCalibration::DTVDriftBaseAlgovDriftAlgo_
 
const DTRecoConditionsvDriftMap_
 
const edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcdvDriftMapToken_
 
bool writeLegacyVDriftDB
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 29 of file DTVDriftWriter.h.

Constructor & Destructor Documentation

◆ DTVDriftWriter()

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

Definition at line 35 of file DTVDriftWriter.cc.

References edm::BeginRun, edm::EDConsumerBase::consumesCollector(), get, and muonDTDigis_cfi::pset.

36  : mTimeMapToken_(esConsumes<edm::Transition::BeginRun>()),
37  vDriftMapToken_(esConsumes<edm::Transition::BeginRun>()),
38  dtGeomToken_(esConsumes<edm::Transition::BeginRun>()),
39  granularity_(pset.getUntrackedParameter<string>("calibGranularity", "bySL")),
40  mTimeMap_(nullptr),
41  vDriftMap_(nullptr),
42  vDriftAlgo_{DTVDriftPluginFactory::get()->create(pset.getParameter<string>("vDriftAlgo"),
43  pset.getParameter<ParameterSet>("vDriftAlgoConfig"),
44  consumesCollector())} {
45  LogVerbatim("Calibration") << "[DTVDriftWriter]Constructor called!";
46 
47  if (granularity_ != "bySL")
48  throw cms::Exception("Configuration")
49  << "[DTVDriftWriter] Check parameter calibGranularity: " << granularity_ << " option not available.";
50 
51  readLegacyVDriftDB = pset.getParameter<bool>("readLegacyVDriftDB");
52  writeLegacyVDriftDB = pset.getParameter<bool>("writeLegacyVDriftDB");
53 }
const edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcd > vDriftMapToken_
Log< level::Info, true > LogVerbatim
const DTRecoConditions * vDriftMap_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const edm::ESGetToken< DTMtime, DTMtimeRcd > mTimeMapToken_
std::unique_ptr< dtCalibration::DTVDriftBaseAlgo > vDriftAlgo_
bool writeLegacyVDriftDB
const DTMtime * mTimeMap_
#define get
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
std::string granularity_

◆ ~DTVDriftWriter()

DTVDriftWriter::~DTVDriftWriter ( )
override

Definition at line 55 of file DTVDriftWriter.cc.

55 { LogVerbatim("Calibration") << "[DTVDriftWriter]Destructor called!"; }
Log< level::Info, true > LogVerbatim

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 36 of file DTVDriftWriter.h.

36 {}

◆ beginRun()

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

Definition at line 57 of file DTVDriftWriter.cc.

References dtGeom_, dtGeomToken_, Exception, mTimeMap_, mTimeMapToken_, readLegacyVDriftDB, singleTopDQM_cfi::setup, vDriftAlgo_, vDriftMap_, vDriftMapToken_, DTRecoConditions::version(), and relval_steps::version.

57  {
58  // Get the map of vdrift from the Setup
59  if (readLegacyVDriftDB) {
60  mTimeMap_ = &setup.getData(mTimeMapToken_);
61  } else {
62  vDriftMap_ = &setup.getData(vDriftMapToken_);
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
71  dtGeom_ = setup.getHandle(dtGeomToken_);
72 
73  // Pass EventSetup to concrete implementation
74  vDriftAlgo_->setES(setup);
75 }
const edm::ESGetToken< DTRecoConditions, DTRecoConditionsVdriftRcd > vDriftMapToken_
edm::ESHandle< DTGeometry > dtGeom_
const DTRecoConditions * vDriftMap_
int version() const
Version numer specifying the structure of the payload. See .cc file for details.
const edm::ESGetToken< DTMtime, DTMtimeRcd > mTimeMapToken_
std::unique_ptr< dtCalibration::DTVDriftBaseAlgo > vDriftAlgo_
const DTMtime * mTimeMap_
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_

◆ endJob()

void DTVDriftWriter::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 77 of file DTVDriftWriter.cc.

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

Referenced by o2olib.O2ORunMgr::executeJob().

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

◆ endRun()

void DTVDriftWriter::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
inlineoverride

Definition at line 37 of file DTVDriftWriter.h.

37 {}

Member Data Documentation

◆ dtGeom_

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

Definition at line 50 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ dtGeomToken_

const edm::ESGetToken<DTGeometry, MuonGeometryRecord> DTVDriftWriter::dtGeomToken_
private

Definition at line 43 of file DTVDriftWriter.h.

Referenced by beginRun().

◆ granularity_

std::string DTVDriftWriter::granularity_
private

Definition at line 44 of file DTVDriftWriter.h.

Referenced by endJob().

◆ mTimeMap_

const DTMtime* DTVDriftWriter::mTimeMap_
private

Definition at line 45 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ mTimeMapToken_

const edm::ESGetToken<DTMtime, DTMtimeRcd> DTVDriftWriter::mTimeMapToken_
private

Definition at line 41 of file DTVDriftWriter.h.

Referenced by beginRun().

◆ readLegacyVDriftDB

bool DTVDriftWriter::readLegacyVDriftDB
private

Definition at line 47 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ vDriftAlgo_

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

Definition at line 52 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ vDriftMap_

const DTRecoConditions* DTVDriftWriter::vDriftMap_
private

Definition at line 46 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

◆ vDriftMapToken_

const edm::ESGetToken<DTRecoConditions, DTRecoConditionsVdriftRcd> DTVDriftWriter::vDriftMapToken_
private

Definition at line 42 of file DTVDriftWriter.h.

Referenced by beginRun().

◆ writeLegacyVDriftDB

bool DTVDriftWriter::writeLegacyVDriftDB
private

Definition at line 48 of file DTVDriftWriter.h.

Referenced by endJob().