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 
133 void DTtTrigDBValidation::bookHistos(DQMStore::IBooker &iBooker, int wheel, int sector) {
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 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
DTSuperLayerId
Definition: DTSuperLayerId.h:12
dqm::impl::MonitorElement
Definition: MonitorElement.h:99
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
DTTtrig::version
const std::string & version() const
access version
Definition: DTTtrig.cc:162
ESHandle.h
edm::Run
Definition: Run.h:45
DTtTrigDBValidation::stationFromBin
int stationFromBin(int bin) const
Definition: DTtTrigDBValidation.cc:187
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_splice.entry
entry
Definition: mps_splice.py:68
DTtTrigDBValidation::~DTtTrigDBValidation
~DTtTrigDBValidation() override
Destructor.
Definition: DTtTrigDBValidation.cc:36
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
DTTtrig::end
const_iterator end() const
Definition: DTTtrig.cc:252
DTtTrigDBValidation::DTTtrigRefMap
const DTTtrig * DTTtrigRefMap
Definition: DTtTrigDBValidation.h:43
DTTtrig::const_iterator
std::vector< std::pair< DTTtrigId, DTTtrigData > >::const_iterator const_iterator
Access methods to data.
Definition: DTTtrig.h:139
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTTtrig::begin
const_iterator begin() const
Definition: DTTtrig.cc:250
DTtTrigDBValidation::dtGeom
const DTGeometry * dtGeom
Definition: DTtTrigDBValidation.h:51
DTtTrigDBValidation.h
Service.h
DTTimeUnits::ns
Definition: DTTimeUnits.h:32
DTTtrig::get
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
edm::ParameterSet
Definition: ParameterSet.h:47
DTtTrigDBValidation::DTTtrigMap
const DTTtrig * DTTtrigMap
Definition: DTtTrigDBValidation.h:44
Event.h
DTtTrigDBValidation::tTrigRefMap_
std::map< DTSuperLayerId, std::pair< float, float > > tTrigRefMap_
Definition: DTtTrigDBValidation.h:54
DTtTrigDBValidation::slFromBin
int slFromBin(int bin) const
Definition: DTtTrigDBValidation.cc:189
DTtTrigDBValidation::tTrigDiffHistos_
std::map< std::pair< int, int >, MonitorElement * > tTrigDiffHistos_
Definition: DTtTrigDBValidation.h:58
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DTtTrigDBValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Operations.
Definition: DTtTrigDBValidation.cc:38
DTtTrigDBValidation::tTrigMap_
std::map< DTSuperLayerId, std::pair< float, float > > tTrigMap_
Definition: DTtTrigDBValidation.h:55
edm::EventSetup
Definition: EventSetup.h:58
DTtTrigDBValidation::higherLimit_
int higherLimit_
Definition: DTtTrigDBValidation.h:47
DTtTrigDBValidation::lowerLimit_
int lowerLimit_
Definition: DTtTrigDBValidation.h:46
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
DTtTrigDBValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DTtTrigDBValidation.cc:197
std
Definition: JetResolutionObject.h:76
DTtTrigDBValidation::metname_
std::string metname_
Definition: DTtTrigDBValidation.h:39
dttriganalyzer_cfi.kFactor
kFactor
Definition: dttriganalyzer_cfi.py:7
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
dqm::implementation::IBooker::book2D
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:177
DTtTrigDBValidation::labelDB_
edm::ESGetToken< DTTtrig, DTTtrigRcd > labelDB_
Definition: DTtTrigDBValidation.h:42
DTtTrigDBValidation::bookHistos
void bookHistos(DQMStore::IBooker &, int, int)
Definition: DTtTrigDBValidation.cc:133
DTtTrigDBValidation::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTtTrigDBValidation.h:50
EventSetup.h
DTtTrigDBValidation::tTrigDiffWheel_
std::map< int, MonitorElement * > tTrigDiffWheel_
Definition: DTtTrigDBValidation.h:59
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTtTrigDBValidation::labelDBRef_
edm::ESGetToken< DTTtrig, DTTtrigRcd > labelDBRef_
Definition: DTtTrigDBValidation.h:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
DTSuperLayerId.h
DTtTrigDBValidation::DTtTrigDBValidation
DTtTrigDBValidation(const edm::ParameterSet &pset)
Constructor.
Definition: DTtTrigDBValidation.cc:26
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
DTTopology.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98