1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/******* \class DTRunConditionVar *******
*
* Description:
*
* detailed description
*
* \author : Paolo Bellan, Antonio Branca
* $date : 23/09/2011 15:42:04 CET $
*
* Modification:
*
*********************************/
#include "DTRunConditionVar.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "RecoMuon/Navigation/interface/DirectMuonNavigation.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "TrackingTools/DetLayers/interface/DetLayer.h"
#include "DataFormats/Common/interface/RefToBase.h"
#include "TMath.h"
#include <cmath>
using namespace std;
using namespace edm;
DTRunConditionVar::DTRunConditionVar(const ParameterSet& pSet)
: // Get the debug parameter for verbose output
debug(pSet.getUntrackedParameter<bool>("debug", false)),
nMinHitsPhi(pSet.getUntrackedParameter<int>("nMinHitsPhi")),
maxAnglePhiSegm(pSet.getUntrackedParameter<double>("maxAnglePhiSegm")),
dt4DSegmentsToken_(consumes<DTRecSegment4DCollection>(pSet.getUntrackedParameter<InputTag>("recoSegments"))),
muonGeomToken_(esConsumes<edm::Transition::BeginRun>()),
readLegacyVDriftDB(pSet.getParameter<bool>("readLegacyVDriftDB")) {
if (readLegacyVDriftDB) {
mTimeToken_ = esConsumes();
} else {
vDriftToken_ = esConsumes();
}
}
DTRunConditionVar::~DTRunConditionVar() {
LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: destructor called";
// free memory
}
void DTRunConditionVar::bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const& iRun,
edm::EventSetup const& /* iSetup */) {
LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: bookHistograms";
for (int wheel = -2; wheel <= 2; wheel++) {
for (int sec = 1; sec <= 14; sec++) {
for (int stat = 1; stat <= 4; stat++) {
bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "VDrift_FromSegm", 100, 0.0043, 0.0065);
bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "T0_FromSegm", 100, -25., 25.);
}
}
}
return;
}
void DTRunConditionVar::dqmBeginRun(const Run& run, const EventSetup& setup) {
// Get the DT Geometry
dtGeom = &setup.getData(muonGeomToken_);
return;
}
void DTRunConditionVar::analyze(const Event& event, const EventSetup& eventSetup) {
LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
<< "--- [DTRunConditionVar] Event analysed #Run: " << event.id().run() << " #Event: " << event.id().event()
<< endl;
// Get the map of vdrift from the setup
if (readLegacyVDriftDB) {
mTimeMap_ = &eventSetup.getData(mTimeToken_);
vDriftMap_ = nullptr;
} else {
vDriftMap_ = &eventSetup.getData(vDriftToken_);
mTimeMap_ = nullptr;
// Consistency check: no parametrization is implemented for the time being
int version = vDriftMap_->version();
if (version != 1) {
throw cms::Exception("Configuration") << "only version 1 is presently supported for VDriftDB";
}
}
// Get the segment collection from the event
Handle<DTRecSegment4DCollection> all4DSegments;
event.getByToken(dt4DSegmentsToken_, all4DSegments);
// Loop over the segments
for (DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin(); segment != all4DSegments->end();
++segment) {
// Get the chamber from the setup
DTChamberId DTid = (DTChamberId)segment->chamberId();
uint32_t indexCh = DTid.rawId();
// Fill v-drift values
if ((*segment).hasPhi()) {
int nHitsPhi = (*segment).phiSegment()->degreesOfFreedom() + 2;
double xdir = (*segment).phiSegment()->localDirection().x();
double zdir = (*segment).phiSegment()->localDirection().z();
double anglePhiSegm = fabs(atan(xdir / zdir)) * 180. / TMath::Pi();
if (nHitsPhi >= nMinHitsPhi && anglePhiSegm <= maxAnglePhiSegm) {
double segmentVDrift = segment->phiSegment()->vDrift();
DTSuperLayerId indexSLPhi1(DTid, 1);
DTSuperLayerId indexSLPhi2(DTid, 3);
float vDriftPhi1(0.), vDriftPhi2(0.);
float ResPhi1(0.), ResPhi2(0.);
if (readLegacyVDriftDB) { // Legacy format
int status1 = mTimeMap_->get(indexSLPhi1, vDriftPhi1, ResPhi1, DTVelocityUnits::cm_per_ns);
int status2 = mTimeMap_->get(indexSLPhi2, vDriftPhi2, ResPhi2, DTVelocityUnits::cm_per_ns);
if (status1 != 0 || status2 != 0) {
DTSuperLayerId sl = (status1 != 0) ? indexSLPhi1 : indexSLPhi2;
throw cms::Exception("DTRunConditionVarClient") << "Could not find vDrift entry in DB for" << sl << endl;
}
} else {
vDriftPhi1 = vDriftMap_->get(DTWireId(indexSLPhi1.rawId()));
vDriftPhi2 = vDriftMap_->get(DTWireId(indexSLPhi2.rawId()));
}
float vDriftMed = (vDriftPhi1 + vDriftPhi2) / 2.;
segmentVDrift = vDriftMed * (1. - segmentVDrift);
double segmentT0 = segment->phiSegment()->t0();
if (segment->phiSegment()->ist0Valid())
(chamberHistos[indexCh])["T0_FromSegm"]->Fill(segmentT0);
if (segmentVDrift != vDriftMed)
(chamberHistos[indexCh])["VDrift_FromSegm"]->Fill(segmentVDrift);
}
}
} //end loop on segment
} //end analyze
void DTRunConditionVar::bookChamberHistos(
DQMStore::IBooker& ibooker, const DTChamberId& dtCh, string histoType, int nbins, float min, float max) {
int wh = dtCh.wheel();
int sc = dtCh.sector();
int st = dtCh.station();
stringstream wheel;
wheel << wh;
stringstream station;
station << st;
stringstream sector;
sector << sc;
string bookingFolder = "DT/02-Segments/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
string histoTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
ibooker.setCurrentFolder(bookingFolder);
LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
<< "[DTRunConditionVar]: booking histos in " << bookingFolder << endl;
string histoName = histoType + histoTag;
const string& histoLabel = histoType;
(chamberHistos[dtCh.rawId()])[histoType] = ibooker.book1D(histoName, histoLabel, nbins, min, max);
}
// Local Variables:
// show-trailing-whitespace: t
// truncate-lines: t
// End:
|