CMS 3D CMS Logo

DTtTrigDBValidation.cc
Go to the documentation of this file.
2 
3 // Framework
8 
11 
12 // Geometry
14 
15 // DataFormats
17 
18 #include "TFile.h"
19 #include <cmath>
20 #include <cstdio>
21 #include <sstream>
22 
23 using namespace edm;
24 using namespace std;
25 
27  : metname_("TTrigDBValidation"),
28  labelDBRef_(esConsumes(edm::ESInputTag("", pset.getParameter<string>("labelDBRef")))),
29  labelDB_(esConsumes(edm::ESInputTag("", pset.getParameter<string>("labelDB")))),
30  lowerLimit_(pset.getUntrackedParameter<int>("lowerLimit", 1)),
31  higherLimit_(pset.getUntrackedParameter<int>("higherLimit", 3)),
32  muonGeomToken_(esConsumes()) {
33  LogVerbatim(metname_) << "[DTtTrigDBValidation] Constructor called!";
34 }
35 
37 
39  LogVerbatim(metname_) << "[DTtTrigDBValidation] Parameters initialization";
40  iBooker.setCurrentFolder("DT/DtCalib/TTrigDBValidation");
41 
42  DTTtrigRefMap = &setup.getData(labelDBRef_);
43  LogVerbatim(metname_) << "[DTtTrigDBValidation] reference Ttrig version: " << DTTtrigRefMap->version();
44 
45  DTTtrigMap = &setup.getData(labelDB_);
46  LogVerbatim(metname_) << "[DTtTrigDBValidation] Ttrig to validate version: " << DTTtrigMap->version();
47 
48  // book&reset the summary histos
49  for (int wheel = -2; wheel <= 2; wheel++) {
50  bookHistos(iBooker, wheel);
51  tTrigDiffWheel_[wheel]->Reset();
52  }
53 
54  // Get the geometry
55  dtGeom = &setup.getData(muonGeomToken_);
56 
57  // Loop over Ref DB entries
58  for (DTTtrig::const_iterator it = DTTtrigRefMap->begin(); it != DTTtrigRefMap->end(); ++it) {
59  DTSuperLayerId slId((*it).first.wheelId, (*it).first.stationId, (*it).first.sectorId, (*it).first.slId);
60  float tTrigMean;
61  float tTrigRms;
62  float kFactor;
63  DTTtrigRefMap->get(slId, tTrigMean, tTrigRms, kFactor, DTTimeUnits::ns);
64  float tTrigCorr = tTrigMean + kFactor * tTrigRms;
65  LogTrace(metname_) << "Ref Superlayer: " << slId << "\n"
66  << " Ttrig mean (ns): " << tTrigMean << " Ttrig rms (ns): " << tTrigRms
67  << " Ttrig k-Factor: " << kFactor << " Ttrig value (ns): " << tTrigCorr;
68 
69  // tTrigRefMap[slId] = std::pair<float,float>(tTrigmean,tTrigrms);
70  tTrigRefMap_[slId] = pair<float, float>(tTrigCorr, tTrigRms);
71  }
72 
73  // Loop over Ref DB entries
74  for (DTTtrig::const_iterator it = DTTtrigMap->begin(); it != DTTtrigMap->end(); ++it) {
75  DTSuperLayerId slId((*it).first.wheelId, (*it).first.stationId, (*it).first.sectorId, (*it).first.slId);
76  float tTrigMean;
77  float tTrigRms;
78  float kFactor;
79  DTTtrigMap->get(slId, tTrigMean, tTrigRms, kFactor, DTTimeUnits::ns);
80  float tTrigCorr = tTrigMean + kFactor * tTrigRms;
81  LogTrace(metname_) << "Superlayer: " << slId << "\n"
82  << " Ttrig mean (ns): " << tTrigMean << " Ttrig rms (ns): " << tTrigRms
83  << " Ttrig k-Factor: " << kFactor << " Ttrig value (ns): " << tTrigCorr;
84 
85  // tTrigMap[slId] = std::pair<float,float>(tTrigmean,tTrigrms);
86  tTrigMap_[slId] = pair<float, float>(tTrigCorr, tTrigRms);
87  }
88 
89  for (map<DTSuperLayerId, pair<float, float>>::const_iterator it = tTrigRefMap_.begin(); it != tTrigRefMap_.end();
90  ++it) {
91  if (tTrigMap_.find((*it).first) == tTrigMap_.end())
92  continue;
93 
94  // compute the difference
95  float difference = tTrigMap_[(*it).first].first - (*it).second.first;
96 
97  // book histo
98  int wheel = (*it).first.chamberId().wheel();
99  int sector = (*it).first.chamberId().sector();
100  if (tTrigDiffHistos_.find(make_pair(wheel, sector)) == tTrigDiffHistos_.end())
101  bookHistos(iBooker, wheel, sector);
102 
103  LogTrace(metname_) << "Filling histos for super-layer: " << (*it).first << " difference: " << difference;
104 
105  // Fill the test histos
106  int entry = -1;
107  int station = (*it).first.chamberId().station();
108  if (station == 1)
109  entry = 0;
110  if (station == 2)
111  entry = 3;
112  if (station == 3)
113  entry = 6;
114  if (station == 4)
115  entry = 9;
116 
117  int slBin = entry + (*it).first.superLayer();
118  if (slBin == 12)
119  slBin = 11;
120 
121  tTrigDiffHistos_[make_pair(wheel, sector)]->setBinContent(slBin, difference);
122  if (abs(difference) < lowerLimit_) {
123  tTrigDiffWheel_[wheel]->setBinContent(slBin, sector, 1);
124  } else if (abs(difference) < higherLimit_) {
125  tTrigDiffWheel_[wheel]->setBinContent(slBin, sector, 2);
126  } else {
127  tTrigDiffWheel_[wheel]->setBinContent(slBin, sector, 3);
128  }
129 
130  } // Loop over the tTrig map reference
131 }
132 
134  LogTrace(metname_) << " Booking histos for Wheel, Sector: " << wheel << ", " << sector;
135 
136  // Compose the chamber name
137  stringstream str_wheel;
138  str_wheel << wheel;
139  stringstream str_sector;
140  str_sector << sector;
141 
142  string lHistoName = "_W" + str_wheel.str() + "_Sec" + str_sector.str();
143 
144  iBooker.setCurrentFolder("DT/DtCalib/TTrigDBValidation/Wheel" + str_wheel.str());
145 
146  // Create the monitor elements
147  MonitorElement *hDifference;
148  hDifference = iBooker.book1D("TTrigDifference" + lHistoName, "difference between the two tTrig values", 11, 0, 11);
149 
150  pair<int, int> mypair(wheel, sector);
151  tTrigDiffHistos_[mypair] = hDifference;
152 
153  (tTrigDiffHistos_[mypair])->setBinLabel(1, "MB1_SL1", 1);
154  (tTrigDiffHistos_[mypair])->setBinLabel(2, "MB1_SL2", 1);
155  (tTrigDiffHistos_[mypair])->setBinLabel(3, "MB1_SL3", 1);
156  (tTrigDiffHistos_[mypair])->setBinLabel(4, "MB2_SL1", 1);
157  (tTrigDiffHistos_[mypair])->setBinLabel(5, "MB2_SL2", 1);
158  (tTrigDiffHistos_[mypair])->setBinLabel(6, "MB2_SL3", 1);
159  (tTrigDiffHistos_[mypair])->setBinLabel(7, "MB3_SL1", 1);
160  (tTrigDiffHistos_[mypair])->setBinLabel(8, "MB3_SL2", 1);
161  (tTrigDiffHistos_[mypair])->setBinLabel(9, "MB3_SL3", 1);
162  (tTrigDiffHistos_[mypair])->setBinLabel(10, "MB4_SL1", 1);
163  (tTrigDiffHistos_[mypair])->setBinLabel(11, "MB4_SL3", 1);
164 }
165 
166 // Book the summary histos
168  stringstream wh;
169  wh << wheel;
170 
171  iBooker.setCurrentFolder("DT/DtCalib/TTrigDBValidation");
172  tTrigDiffWheel_[wheel] = iBooker.book2D(
173  "TTrigDifference_W" + wh.str(), "W" + wh.str() + ": summary of tTrig differences", 11, 1, 12, 14, 1, 15);
174  tTrigDiffWheel_[wheel]->setBinLabel(1, "MB1_SL1", 1);
175  tTrigDiffWheel_[wheel]->setBinLabel(2, "MB1_SL2", 1);
176  tTrigDiffWheel_[wheel]->setBinLabel(3, "MB1_SL3", 1);
177  tTrigDiffWheel_[wheel]->setBinLabel(4, "MB2_SL1", 1);
178  tTrigDiffWheel_[wheel]->setBinLabel(5, "MB2_SL2", 1);
179  tTrigDiffWheel_[wheel]->setBinLabel(6, "MB2_SL3", 1);
180  tTrigDiffWheel_[wheel]->setBinLabel(7, "MB3_SL1", 1);
181  tTrigDiffWheel_[wheel]->setBinLabel(8, "MB3_SL2", 1);
182  tTrigDiffWheel_[wheel]->setBinLabel(9, "MB3_SL3", 1);
183  tTrigDiffWheel_[wheel]->setBinLabel(10, "MB4_SL1", 1);
184  tTrigDiffWheel_[wheel]->setBinLabel(11, "MB4_SL3", 1);
185 }
186 
187 int DTtTrigDBValidation::stationFromBin(int bin) const { return (int)(bin / 3.1) + 1; }
188 
190  int ret = bin % 3;
191  if (ret == 0 || bin == 11)
192  ret = 3;
193 
194  return ret;
195 }
196 
Log< level::Info, true > LogVerbatim
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< std::pair< DTTtrigId, DTTtrigData > >::const_iterator const_iterator
Access methods to data.
Definition: DTTtrig.h:141
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Operations.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
ret
prodAgent to be discontinued
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::string & version() const
access version
Definition: DTTtrig.cc:162
std::map< std::pair< int, int >, MonitorElement * > tTrigDiffHistos_
edm::ESGetToken< DTTtrig, DTTtrigRcd > labelDB_
std::map< DTSuperLayerId, std::pair< float, float > > tTrigRefMap_
#define LogTrace(id)
const_iterator begin() const
Definition: DTTtrig.cc:250
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int slFromBin(int bin) const
edm::ESGetToken< DTTtrig, DTTtrigRcd > labelDBRef_
const DTTtrig * DTTtrigRefMap
DTtTrigDBValidation(const edm::ParameterSet &pset)
Constructor.
~DTtTrigDBValidation() override
Destructor.
const DTTtrig * DTTtrigMap
std::map< int, MonitorElement * > tTrigDiffWheel_
void bookHistos(DQMStore::IBooker &, int, int)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
std::map< DTSuperLayerId, std::pair< float, float > > tTrigMap_
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59
int stationFromBin(int bin) const
HLT enums.
const DTGeometry * dtGeom
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
const_iterator end() const
Definition: DTTtrig.cc:252
Definition: Run.h:45