CMS 3D CMS Logo

DTt0DBValidation.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
9 
10 // Framework
15 
18 
19 // Geometry
24 
25 // t0
28 
29 #include "TFile.h"
30 
31 #include <iomanip>
32 #include <sstream>
33 
34 using namespace edm;
35 using namespace std;
36 
38  metname_ = "InterChannelSynchDBValidation";
39  LogVerbatim(metname_) << "[DTt0DBValidation] Constructor called!";
40 
41  // Get the DQM needed services
42  dbe_ = edm::Service<DQMStore>().operator->();
43  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation");
44 
45  // Get dataBase label
46  labelDBRef_ = pset.getParameter<string>("labelDBRef");
47  labelDB_ = pset.getParameter<string>("labelDB");
48 
49  t0TestName_ = "t0DifferenceInRange";
50  if (pset.exists("t0TestName"))
51  t0TestName_ = pset.getParameter<string>("t0TestName");
52 
53  outputMEsInRootFile_ = false;
54  if (pset.exists("OutputFileName")) {
55  outputMEsInRootFile_ = true;
56  outputFileName_ = pset.getParameter<std::string>("OutputFileName");
57  }
58 }
59 
61 
63  metname_ = "InterChannelSynchDBValidation";
64  LogVerbatim(metname_) << "[DTt0DBValidation] Parameters initialization";
65 
66  ESHandle<DTT0> t0_Ref;
67  setup.get<DTT0Rcd>().get(labelDBRef_, t0_Ref);
68  tZeroRefMap_ = &*t0_Ref;
69  LogVerbatim(metname_) << "[DTt0DBValidation] reference T0 version: " << t0_Ref->version();
70 
72  setup.get<DTT0Rcd>().get(labelDB_, t0);
73  tZeroMap_ = &*t0;
74  LogVerbatim(metname_) << "[DTt0DBValidation] T0 to validate version: " << t0->version();
75 
76  // book&reset the summary histos
77  for (int wheel = -2; wheel <= 2; wheel++) {
79  wheelSummary_[wheel]->Reset();
80  }
81 
82  // Get the geometry
83  setup.get<MuonGeometryRecord>().get(dtGeom_);
84 
85  // Loop over Ref DB entries
86  for (DTT0::const_iterator tzero = tZeroRefMap_->begin(); tzero != tZeroRefMap_->end(); tzero++) {
87  // t0s and rms are TDC counts
88  // @@@ NEW DTT0 FORMAT
89  // DTWireId wireId((*tzero).first.wheelId,
90  // (*tzero).first.stationId,
91  // (*tzero).first.sectorId,
92  // (*tzero).first.slId,
93  // (*tzero).first.layerId,
94  // (*tzero).first.cellId);
95  int channelId = tzero->channelId;
96  if (channelId == 0)
97  continue;
98  DTWireId wireId(channelId);
99  // @@@ NEW DTT0 END
100  float t0mean;
101  float t0rms;
102  tZeroRefMap_->get(wireId, t0mean, t0rms, DTTimeUnits::counts);
103  LogTrace(metname_) << "Ref Wire: " << wireId << endl
104  << " T0 mean (TDC counts): " << t0mean << " T0_rms (TDC counts): " << t0rms;
105 
106  t0RefMap_[wireId].push_back(t0mean);
107  t0RefMap_[wireId].push_back(t0rms);
108  }
109 
110  // Loop over Ref DB entries
111  for (DTT0::const_iterator tzero = tZeroMap_->begin(); tzero != tZeroMap_->end(); tzero++) {
112  // t0s and rms are TDC counts
113  // @@@ NEW DTT0 FORMAT
114  // DTWireId wireId((*tzero).first.wheelId,
115  // (*tzero).first.stationId,
116  // (*tzero).first.sectorId,
117  // (*tzero).first.slId,
118  // (*tzero).first.layerId,
119  // (*tzero).first.cellId);
120  int channelId = tzero->channelId;
121  if (channelId == 0)
122  continue;
123  DTWireId wireId(channelId);
124  // @@@ NEW DTT0 END
125  float t0mean;
126  float t0rms;
127  tZeroMap_->get(wireId, t0mean, t0rms, DTTimeUnits::counts);
128  LogTrace(metname_) << "Wire: " << wireId << endl
129  << " T0 mean (TDC counts): " << t0mean << " T0_rms (TDC counts): " << t0rms;
130 
131  t0Map_[wireId].push_back(t0mean);
132  t0Map_[wireId].push_back(t0rms);
133  }
134 
135  double difference = 0;
136  for (map<DTWireId, vector<float>>::const_iterator theMap = t0RefMap_.begin(); theMap != t0RefMap_.end(); theMap++) {
137  if (t0Map_.find((*theMap).first) != t0Map_.end()) {
138  // Compute the difference
139  difference = t0Map_[(*theMap).first][0] - (*theMap).second[0];
140 
141  // book histo
142  DTLayerId layerId = (*theMap).first.layerId();
143  if (t0DiffHistos_.find(layerId) == t0DiffHistos_.end()) {
144  const DTTopology &dtTopo = dtGeom_->layer(layerId)->specificTopology();
145  const int firstWire = dtTopo.firstChannel();
146  const int lastWire = dtTopo.lastChannel();
147  bookHistos(layerId, firstWire, lastWire);
148  }
149 
150  LogTrace(metname_) << "Filling the histo for wire: " << (*theMap).first << " difference: " << difference;
151  t0DiffHistos_[layerId]->Fill((*theMap).first.wire(), difference);
152  }
153  } // Loop over the t0 map reference
154 }
155 
157  // Check the histos
158  string testCriterionName = t0TestName_;
159  for (map<DTLayerId, MonitorElement *>::const_iterator hDiff = t0DiffHistos_.begin(); hDiff != t0DiffHistos_.end();
160  hDiff++) {
161  const QReport *theDiffQReport = (*hDiff).second->getQReport(testCriterionName);
162  if (theDiffQReport) {
163  int xBin = ((*hDiff).first.station() - 1) * 12 + (*hDiff).first.layer() + 4 * ((*hDiff).first.superlayer() - 1);
164  if ((*hDiff).first.station() == 4 && (*hDiff).first.superlayer() == 3)
165  xBin = ((*hDiff).first.station() - 1) * 12 + (*hDiff).first.layer() + 4 * ((*hDiff).first.superlayer() - 2);
166 
167  int qReportStatus = theDiffQReport->getStatus() / 100;
168  wheelSummary_[(*hDiff).first.wheel()]->setBinContent(xBin, (*hDiff).first.sector(), qReportStatus);
169 
170  LogVerbatim(metname_) << "-------- layer: " << (*hDiff).first << " " << theDiffQReport->getMessage()
171  << " ------- " << theDiffQReport->getStatus() << " ------- " << setprecision(3)
172  << theDiffQReport->getQTresult();
173  vector<dqm::me_util::Channel> badChannels = theDiffQReport->getBadChannels();
174  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
175  channel++) {
176  LogVerbatim(metname_) << "layer: " << (*hDiff).first << " Bad channel: " << (*channel).getBin()
177  << " Contents : " << (*channel).getContents();
178 
179  // wheelSummary_[(*hDiff).first.wheel()]->Fill(xBin,(*hDiff).first.sector());
180  }
181  }
182  }
183 }
184 
186  // Write the histos on a file
187  if (outputMEsInRootFile_)
188  dbe_->save(outputFileName_);
189 }
190 
191 // Book a set of histograms for a given Layer
192 void DTt0DBValidation::bookHistos(DTLayerId lId, int firstWire, int lastWire) {
193  LogTrace(metname_) << " Booking histos for L: " << lId;
194 
195  // Compose the chamber name
196  stringstream wheel;
197  wheel << lId.superlayerId().chamberId().wheel();
198  stringstream station;
199  station << lId.superlayerId().chamberId().station();
200  stringstream sector;
201  sector << lId.superlayerId().chamberId().sector();
202  stringstream superLayer;
203  superLayer << lId.superlayerId().superlayer();
204  stringstream layer;
205  layer << lId.layer();
206 
207  string lHistoName = "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() +
208  "_L" + layer.str();
209 
210  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation/Wheel" + wheel.str() + "/Station" + station.str() +
211  "/Sector" + sector.str() + "/SuperLayer" + superLayer.str());
212  // Create the monitor elements
213  MonitorElement *hDifference;
214  hDifference = dbe_->book1D("T0Difference" + lHistoName,
215  "difference between the two t0 values",
216  lastWire - firstWire + 1,
217  firstWire - 0.5,
218  lastWire + 0.5);
219 
220  t0DiffHistos_[lId] = hDifference;
221 }
222 
223 // Book the summary histos
225  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation");
226  stringstream wh;
227  wh << wheel;
228  wheelSummary_[wheel] = dbe_->book2D(
229  "SummaryWrongT0_W" + wh.str(), "W" + wh.str() + ": summary of wrong t0 differences", 44, 1, 45, 14, 1, 15);
230  wheelSummary_[wheel]->setBinLabel(1, "M1L1", 1);
231  wheelSummary_[wheel]->setBinLabel(2, "M1L2", 1);
232  wheelSummary_[wheel]->setBinLabel(3, "M1L3", 1);
233  wheelSummary_[wheel]->setBinLabel(4, "M1L4", 1);
234  wheelSummary_[wheel]->setBinLabel(5, "M1L5", 1);
235  wheelSummary_[wheel]->setBinLabel(6, "M1L6", 1);
236  wheelSummary_[wheel]->setBinLabel(7, "M1L7", 1);
237  wheelSummary_[wheel]->setBinLabel(8, "M1L8", 1);
238  wheelSummary_[wheel]->setBinLabel(9, "M1L9", 1);
239  wheelSummary_[wheel]->setBinLabel(10, "M1L10", 1);
240  wheelSummary_[wheel]->setBinLabel(11, "M1L11", 1);
241  wheelSummary_[wheel]->setBinLabel(12, "M1L12", 1);
242  wheelSummary_[wheel]->setBinLabel(13, "M2L1", 1);
243  wheelSummary_[wheel]->setBinLabel(14, "M2L2", 1);
244  wheelSummary_[wheel]->setBinLabel(15, "M2L3", 1);
245  wheelSummary_[wheel]->setBinLabel(16, "M2L4", 1);
246  wheelSummary_[wheel]->setBinLabel(17, "M2L5", 1);
247  wheelSummary_[wheel]->setBinLabel(18, "M2L6", 1);
248  wheelSummary_[wheel]->setBinLabel(19, "M2L7", 1);
249  wheelSummary_[wheel]->setBinLabel(20, "M2L8", 1);
250  wheelSummary_[wheel]->setBinLabel(21, "M2L9", 1);
251  wheelSummary_[wheel]->setBinLabel(22, "M2L10", 1);
252  wheelSummary_[wheel]->setBinLabel(23, "M2L11", 1);
253  wheelSummary_[wheel]->setBinLabel(24, "M2L12", 1);
254  wheelSummary_[wheel]->setBinLabel(25, "M3L1", 1);
255  wheelSummary_[wheel]->setBinLabel(26, "M3L2", 1);
256  wheelSummary_[wheel]->setBinLabel(27, "M3L3", 1);
257  wheelSummary_[wheel]->setBinLabel(28, "M3L4", 1);
258  wheelSummary_[wheel]->setBinLabel(29, "M3L5", 1);
259  wheelSummary_[wheel]->setBinLabel(30, "M3L6", 1);
260  wheelSummary_[wheel]->setBinLabel(31, "M3L7", 1);
261  wheelSummary_[wheel]->setBinLabel(32, "M3L8", 1);
262  wheelSummary_[wheel]->setBinLabel(33, "M3L9", 1);
263  wheelSummary_[wheel]->setBinLabel(34, "M3L10", 1);
264  wheelSummary_[wheel]->setBinLabel(35, "M3L11", 1);
265  wheelSummary_[wheel]->setBinLabel(36, "M3L12", 1);
266  wheelSummary_[wheel]->setBinLabel(37, "M4L1", 1);
267  wheelSummary_[wheel]->setBinLabel(38, "M4L2", 1);
268  wheelSummary_[wheel]->setBinLabel(39, "M4L3", 1);
269  wheelSummary_[wheel]->setBinLabel(40, "M4L4", 1);
270  wheelSummary_[wheel]->setBinLabel(41, "M4L5", 1);
271  wheelSummary_[wheel]->setBinLabel(42, "M4L6", 1);
272  wheelSummary_[wheel]->setBinLabel(43, "M4L7", 1);
273  wheelSummary_[wheel]->setBinLabel(44, "M4L8", 1);
274 }
MessageLogger.h
DTt0DBValidation::DTt0DBValidation
DTt0DBValidation(const edm::ParameterSet &pset)
Constructor.
Definition: DTt0DBValidation.cc:37
photonAnalyzer_cfi.xBin
xBin
Definition: photonAnalyzer_cfi.py:81
ESHandle.h
edm::Run
Definition: Run.h:45
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTT0.h
DTt0DBValidation::~DTt0DBValidation
~DTt0DBValidation() override
Destructor.
Definition: DTt0DBValidation.cc:60
DQMStore.h
DTT0::version
const std::string & version() const
access version
Definition: DTT0.cc:82
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
DTSuperLayerId::superlayer
int superlayer() const
Return the superlayer number (deprecated method name)
Definition: DTSuperLayerId.h:42
DTT0Rcd
Definition: DTT0Rcd.h:9
DTt0DBValidation::bookHistos
void bookHistos(DTLayerId lId, int firstWire, int lastWire)
Definition: DTt0DBValidation.cc:192
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTTopology
Definition: DTTopology.h:28
DTTopology::firstChannel
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
DTWireId
Definition: DTWireId.h:12
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
Service.h
MonitorElementData::QReport::getQTresult
float getQTresult() const
get test result i.e. prob value
Definition: MonitorElementCollection.h:103
edm::ESHandle< DTT0 >
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
bookHistos
void bookHistos()
Definition: Histogram.h:33
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
MonitorElementData::QReport::getBadChannels
const std::vector< DQMChannel > & getBadChannels() const
Definition: MonitorElementCollection.h:116
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:760
tzero
static const double tzero[3]
Definition: CastorTimeSlew.cc:5
DTLayerId
Definition: DTLayerId.h:12
DTLayer.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
DTT0Rcd.h
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
MonitorElementData::QReport
Definition: MonitorElementCollection.h:55
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
edm::Service
Definition: Service.h:30
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:771
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
DTt0DBValidation.h
DTTopology::lastChannel
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
MonitorElementData::QReport::getStatus
int getStatus() const
get test status
Definition: MonitorElementCollection.h:100
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTTimeUnits::counts
Definition: DTTimeUnits.h:32
DTt0DBValidation::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: DTt0DBValidation.cc:156
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
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
MonitorElementData::QReport::getMessage
const std::string & getMessage() const
get message attached to test
Definition: MonitorElementCollection.h:106
EventSetup.h
DTt0DBValidation::endJob
void endJob() override
Definition: DTt0DBValidation.cc:185
genParticles_cff.map
map
Definition: genParticles_cff.py:11
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
MuonGeometryRecord.h
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
DTTopology.h
DTt0DBValidation::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
Operations.
Definition: DTt0DBValidation.cc:62
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
DTT0::const_iterator
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
Definition: DTT0.h:122
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