CMS 3D CMS Logo

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