CalibMuon
DTCalibration
plugins
DTVDriftWriter.cc
Go to the documentation of this file.
1
2
/*
3
* See header file for a description of this class.
4
*
5
* Author of original version: M. Giunta
6
* \author A. Vilela Pereira
7
*/
8
9
#include "
DTVDriftWriter.h
"
10
11
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
12
#include "
FWCore/Framework/interface/ESHandle.h
"
13
#include "
FWCore/Framework/interface/EventSetup.h
"
14
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
15
16
#include "
Geometry/DTGeometry/interface/DTGeometry.h
"
17
#include "
Geometry/Records/interface/MuonGeometryRecord.h
"
18
#include "
Geometry/DTGeometry/interface/DTSuperLayer.h
"
19
20
#include "
CondFormats/DTObjects/interface/DTMtime.h
"
21
#include "
CondFormats/DataRecord/interface/DTMtimeRcd.h
"
22
23
#include "
CalibMuon/DTCalibration/interface/DTCalibDBUtils.h
"
24
#include "
CalibMuon/DTCalibration/interface/DTVDriftPluginFactory.h
"
25
#include "
CalibMuon/DTCalibration/interface/DTVDriftBaseAlgo.h
"
26
27
#include <string>
28
#include <vector>
29
30
using namespace
std
;
31
using namespace
edm
;
32
33
DTVDriftWriter::DTVDriftWriter
(
const
ParameterSet
&
pset
)
34
: granularity_(
pset
.getUntrackedParameter<
string
>(
"calibGranularity"
,
"bySL"
)),
35
vDriftAlgo_{
DTVDriftPluginFactory::get
()->create(
pset
.getParameter<
string
>(
"vDriftAlgo"
),
36
pset
.getParameter<
ParameterSet
>(
"vDriftAlgoConfig"
))} {
37
LogVerbatim
(
"Calibration"
) <<
"[DTVDriftWriter]Constructor called!"
;
38
39
if
(granularity_ !=
"bySL"
)
40
throw
cms::Exception
(
"Configuration"
)
41
<<
"[DTVDriftWriter] Check parameter calibGranularity: "
<< granularity_ <<
" option not available."
;
42
}
43
44
DTVDriftWriter::~DTVDriftWriter
() {
LogVerbatim
(
"Calibration"
) <<
"[DTVDriftWriter]Destructor called!"
; }
45
46
void
DTVDriftWriter::beginRun
(
const
edm::Run
&
run
,
const
edm::EventSetup
&
setup
) {
47
// Get the map of ttrig from the Setup
48
ESHandle<DTMtime>
mTime;
49
setup
.get<
DTMtimeRcd
>().
get
(mTime);
50
mTimeMap_
= &*mTime;
51
52
// Get geometry from Event Setup
53
setup
.get<
MuonGeometryRecord
>().
get
(
dtGeom_
);
54
// Pass EventSetup to concrete implementation
55
vDriftAlgo_
->setES(
setup
);
56
}
57
58
void
DTVDriftWriter::endJob
() {
59
// Create the object to be written to DB
60
DTMtime
* mTimeNewMap =
new
DTMtime
();
61
62
if
(
granularity_
==
"bySL"
) {
63
// Get all the sls from the geometry
64
const
vector<const DTSuperLayer*>& superLayers =
dtGeom_
->
superLayers
();
65
auto
sl = superLayers.begin();
66
auto
sl_end = superLayers.end();
67
for
(; sl != sl_end; ++sl) {
68
DTSuperLayerId
slId = (*sl)->id();
69
// Get original value from DB
70
float
vDrift = 0.,
resolution
= 0.;
71
// vdrift is cm/ns , resolution is cm
72
int
status
=
mTimeMap_
->
get
(slId, vDrift,
resolution
,
DTVelocityUnits::cm_per_ns
);
73
74
// Compute vDrift
75
try
{
76
dtCalibration::DTVDriftData
vDriftData =
vDriftAlgo_
->compute(slId);
77
float
vDriftNew = vDriftData.
vdrift
;
78
float
resolutionNew = vDriftData.
resolution
;
79
// vdrift is cm/ns , resolution is cm
80
mTimeNewMap->
set
(slId, vDriftNew, resolutionNew,
DTVelocityUnits::cm_per_ns
);
81
LogVerbatim
(
"Calibration"
) <<
"vDrift for: "
<< slId <<
" Mean "
<< vDriftNew <<
" Resolution "
82
<< resolutionNew;
83
}
catch
(
cms::Exception
&
e
) {
84
LogError
(
"Calibration"
) <<
e
.explainSelf();
85
// Go back to original value in case of error
86
if
(!
status
) {
87
mTimeNewMap->
set
(slId, vDrift,
resolution
,
DTVelocityUnits::cm_per_ns
);
88
LogVerbatim
(
"Calibration"
) <<
"Keep original vDrift for: "
<< slId <<
" Mean "
<< vDrift <<
" Resolution "
89
<<
resolution
;
90
}
91
}
92
}
// End of loop on superlayers
93
}
94
95
// Write the vDrift object to DB
96
LogVerbatim
(
"Calibration"
) <<
"[DTVDriftWriter]Writing vdrift object to DB!"
;
97
string
record
=
"DTMtimeRcd"
;
98
DTCalibDBUtils::writeToDB<DTMtime>(
record
, mTimeNewMap);
99
}
DTSuperLayerId
Definition:
DTSuperLayerId.h:12
DTVDriftWriter::dtGeom_
edm::ESHandle< DTGeometry > dtGeom_
Definition:
DTVDriftWriter.h:38
DTVDriftWriter::mTimeMap_
const DTMtime * mTimeMap_
Definition:
DTVDriftWriter.h:37
MessageLogger.h
DTMtime.h
DTVDriftWriter::DTVDriftWriter
DTVDriftWriter(const edm::ParameterSet &pset)
Definition:
DTVDriftWriter.cc:33
ESHandle.h
mps_update.status
status
Definition:
mps_update.py:69
edm::Run
Definition:
Run.h:45
edm
HLT enums.
Definition:
AlignableModifier.h:19
dtCalibration::DTVDriftData::vdrift
double vdrift
Definition:
DTVDriftBaseAlgo.h:23
DTVDriftWriter::endJob
void endJob() override
Definition:
DTVDriftWriter.cc:58
GlobalPosition_Frontier_DevDB_cff.record
record
Definition:
GlobalPosition_Frontier_DevDB_cff.py:10
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
DTVDriftWriter.h
dtCalibration::DTVDriftData::resolution
double resolution
Definition:
DTVDriftBaseAlgo.h:24
DTVDriftWriter::vDriftAlgo_
std::unique_ptr< dtCalibration::DTVDriftBaseAlgo > vDriftAlgo_
Definition:
DTVDriftWriter.h:40
edm::ESHandle< DTMtime >
L1TObjectsTimingClient_cff.resolution
resolution
Definition:
L1TObjectsTimingClient_cff.py:52
DTVDriftPluginFactory.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
edm::ParameterSet
Definition:
ParameterSet.h:36
edm::LogError
Definition:
MessageLogger.h:183
DTVelocityUnits::cm_per_ns
Definition:
DTVelocityUnits.h:32
DTMtimeRcd.h
DTCalibDBUtils.h
DTGeometry::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return a vector of all SuperLayer.
Definition:
DTGeometry.cc:86
edm::LogVerbatim
Definition:
MessageLogger.h:297
edm::EventSetup
Definition:
EventSetup.h:57
get
#define get
DTVDriftBaseAlgo.h
std
Definition:
JetResolutionObject.h:76
writedatasetfile.run
run
Definition:
writedatasetfile.py:27
Exception
Definition:
hltDiff.cc:246
EventSetup.h
cms::Exception
Definition:
Exception.h:70
ParameterSet.h
MuonGeometryRecord.h
dtCalibration::DTVDriftData
Definition:
DTVDriftBaseAlgo.h:19
DTVDriftWriter::granularity_
std::string granularity_
Definition:
DTVDriftWriter.h:35
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
DTSuperLayer.h
muonDTDigis_cfi.pset
pset
Definition:
muonDTDigis_cfi.py:27
DTVDriftWriter::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
Definition:
DTVDriftWriter.cc:46
DTVDriftWriter::~DTVDriftWriter
~DTVDriftWriter() override
Definition:
DTVDriftWriter.cc:44
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
DTMtimeRcd
Definition:
DTMtimeRcd.h:5
Generated for CMSSW Reference Manual by
1.8.16