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