CMS 3D CMS Logo

DTRunConditionVar.cc
Go to the documentation of this file.
1 
2 /******* \class DTRunConditionVar *******
3  *
4  * Description:
5  *
6  * detailed description
7  *
8  * \author : Paolo Bellan, Antonio Branca
9  * $date : 23/09/2011 15:42:04 CET $
10  *
11  * Modification:
12  *
13  *********************************/
14 
15 #include "DTRunConditionVar.h"
16 
21 
23 
25 
28 
30 
32 
34 
38 
39 #include <TMath.h>
40 #include <cmath>
41 
42 using namespace std;
43 using namespace edm;
44 
46  : // Get the debug parameter for verbose output
47  debug(pSet.getUntrackedParameter<bool>("debug", false)),
48  nMinHitsPhi(pSet.getUntrackedParameter<int>("nMinHitsPhi")),
49  maxAnglePhiSegm(pSet.getUntrackedParameter<double>("maxAnglePhiSegm")),
50  dt4DSegmentsToken_(consumes<DTRecSegment4DCollection>(pSet.getParameter<InputTag>("recoSegments"))) {}
51 
53  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: destructor called";
54 
55  // free memory
56 }
57 
59  edm::Run const& iRun,
60  edm::EventSetup const& /* iSetup */) {
61  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar") << "DTRunConditionVar: bookHistograms";
62 
63  for (int wheel = -2; wheel <= 2; wheel++) {
64  for (int sec = 1; sec <= 14; sec++) {
65  for (int stat = 1; stat <= 4; stat++) {
66  bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "VDrift_FromSegm", 100, 0.0043, 0.0065);
67  bookChamberHistos(ibooker, DTChamberId(wheel, stat, sec), "T0_FromSegm", 100, -25., 25.);
68  }
69  }
70  }
71 
72  return;
73 }
74 
76  // Get the DT Geometry
77  setup.get<MuonGeometryRecord>().get(dtGeom);
78 
79  return;
80 }
81 
82 void DTRunConditionVar::analyze(const Event& event, const EventSetup& eventSetup) {
83  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
84  << "--- [DTRunConditionVar] Event analysed #Run: " << event.id().run() << " #Event: " << event.id().event()
85  << endl;
86 
87  // Get the DT Geometry
89  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
90 
91  // Get the map of vdrift from the setup
92  eventSetup.get<DTMtimeRcd>().get(mTime);
93  mTimeMap_ = &*mTime;
94 
95  // Get the segment collection from the event
97  event.getByToken(dt4DSegmentsToken_, all4DSegments);
98 
99  // Loop over the segments
100  for (DTRecSegment4DCollection::const_iterator segment = all4DSegments->begin(); segment != all4DSegments->end();
101  ++segment) {
102  // Get the chamber from the setup
103  DTChamberId DTid = (DTChamberId)segment->chamberId();
104  uint32_t indexCh = DTid.rawId();
105 
106  // Fill v-drift values
107  if ((*segment).hasPhi()) {
108  int nHitsPhi = (*segment).phiSegment()->degreesOfFreedom() + 2;
109  double xdir = (*segment).phiSegment()->localDirection().x();
110  double zdir = (*segment).phiSegment()->localDirection().z();
111 
112  double anglePhiSegm = fabs(atan(xdir / zdir)) * 180. / TMath::Pi();
113 
114  if (nHitsPhi >= nMinHitsPhi && anglePhiSegm <= maxAnglePhiSegm) {
115  double segmentVDrift = segment->phiSegment()->vDrift();
116 
117  DTSuperLayerId indexSLPhi1(DTid, 1);
118  DTSuperLayerId indexSLPhi2(DTid, 3);
119 
120  float vDriftPhi1(0.), vDriftPhi2(0.);
121  float ResPhi1(0.), ResPhi2(0.);
122  int status1 = mTimeMap_->get(indexSLPhi1, vDriftPhi1, ResPhi1, DTVelocityUnits::cm_per_ns);
123  int status2 = mTimeMap_->get(indexSLPhi2, vDriftPhi2, ResPhi2, DTVelocityUnits::cm_per_ns);
124 
125  if (status1 != 0 || status2 != 0) {
126  DTSuperLayerId sl = (status1 != 0) ? indexSLPhi1 : indexSLPhi2;
127  throw cms::Exception("DTRunConditionVarClient") << "Could not find vDrift entry in DB for" << sl << endl;
128  }
129 
130  float vDriftMed = (vDriftPhi1 + vDriftPhi2) / 2.;
131 
132  segmentVDrift = vDriftMed * (1. - segmentVDrift);
133 
134  double segmentT0 = segment->phiSegment()->t0();
135 
136  if (segment->phiSegment()->ist0Valid())
137  (chamberHistos[indexCh])["T0_FromSegm"]->Fill(segmentT0);
138  if (segmentVDrift != vDriftMed)
139  (chamberHistos[indexCh])["VDrift_FromSegm"]->Fill(segmentVDrift);
140  }
141  }
142 
143  } //end loop on segment
144 
145 } //end analyze
146 
148  DQMStore::IBooker& ibooker, const DTChamberId& dtCh, string histoType, int nbins, float min, float max) {
149  int wh = dtCh.wheel();
150  int sc = dtCh.sector();
151  int st = dtCh.station();
152  stringstream wheel;
153  wheel << wh;
154  stringstream station;
155  station << st;
156  stringstream sector;
157  sector << sc;
158 
159  string bookingFolder = "DT/02-Segments/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
160  string histoTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
161 
162  ibooker.setCurrentFolder(bookingFolder);
163 
164  LogTrace("DTDQM|DTMonitorModule|DTRunConditionVar")
165  << "[DTRunConditionVar]: booking histos in " << bookingFolder << endl;
166 
167  string histoName = histoType + histoTag;
168  const string& histoLabel = histoType;
169 
170  (chamberHistos[dtCh.rawId()])[histoType] = ibooker.book1D(histoName, histoLabel, nbins, min, max);
171 }
172 
173 // Local Variables:
174 // show-trailing-whitespace: t
175 // truncate-lines: t
176 // End:
const double Pi
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
edm::ESHandle< DTMtime > mTime
edm::EDGetTokenT< DTRecSegment4DCollection > dt4DSegmentsToken_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
const DTMtime * mTimeMap_
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T min(T a, T b)
Definition: MathUtil.h:58
#define LogTrace(id)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
#define debug
Definition: HDRShower.cc:19
int get(int wheelId, int stationId, int sectorId, int slId, float &mTime, float &mTrms, DTTimeUnits::type unit) const
Definition: DTMtime.cc:56
HLT enums.
int sector() const
Definition: DTChamberId.h:49
T get() const
Definition: EventSetup.h:73
~DTRunConditionVar() override
void bookChamberHistos(DQMStore::IBooker &, const DTChamberId &dtCh, std::string histoType, int, float, float)
int station() const
Return the station number.
Definition: DTChamberId.h:42
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::ESHandle< DTGeometry > dtGeom
Definition: event.py:1
Definition: Run.h:45
DTRunConditionVar(const edm::ParameterSet &pset)