35 : histRange_(
pset.getParameter<double>(
"histogramRange")),
37 rootBaseDir_(
pset.getUntrackedParameter<
std::
string>(
"rootBaseDir",
"DT/Residuals")),
38 detailedAnalysis_(
pset.getUntrackedParameter<
bool>(
"detailedAnalysis",
false)) {
42 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Constructor called.";
55 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Destructor called.";
73 for (
auto sl_it : ch_it->superLayers()) {
77 for (
auto layer_it : (sl_it)->
layers()) {
97 for (chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt) {
104 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
105 <<
"\nSegment global pos: " <<
chamber->toGlobal((*segment).localPosition());
114 std::vector<DTRecHit1D> recHits1D_S3;
116 if ((*segment).hasPhi()) {
119 std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
122 if ((*segment).hasZed()) {
125 std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
129 for (std::vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin(); recHit1D != recHits1D_S3.end();
131 const DTWireId wireId = recHit1D->wireId();
134 if (segmDistance > 2.1)
135 LogTrace(
"Calibration") <<
"WARNING: segment-wire distance: " << segmDistance;
137 LogTrace(
"Calibration") <<
"segment-wire distance: " << segmDistance;
140 LogTrace(
"Calibration") <<
"Wire Id " << wireId <<
" residual on distance: " << residualOnDistance;
154 float wireX =
layer->specificTopology().wirePosition(wireId.
wire());
170 float segmDistance = -1;
171 if (sl == 1 || sl == 3)
172 segmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
174 segmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
180 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Writing histos to file.";
202 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for SL: " << slId;
212 std::string slHistoName =
"_STEP" + std::to_string(
step) +
"_W" + wheelStr +
"_St" + stationStr +
"_Sec" + sectorStr +
219 LogDebug(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr);
220 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
222 wheelDir =
baseDir->mkdir((
"Wheel" + wheelStr).c_str());
223 LogDebug(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
224 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
226 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
227 LogDebug(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr);
228 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
230 sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
235 TH1F* histosTH1F =
new TH1F((
"hResDist" + slHistoName).c_str(),
236 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
240 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + slHistoName).c_str(),
241 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
256 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for layer: " << layerId;
267 std::string layerHistoName =
"_STEP" + std::to_string(
step) +
"_W" + wheelStr +
"_St" + stationStr +
"_Sec" +
268 sectorStr +
"_SL" + superLayerStr +
"_Layer" + layerStr;
274 LogDebug(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr);
275 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
277 wheelDir =
baseDir->mkdir((
"Wheel" + wheelStr).c_str());
278 LogDebug(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
279 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
281 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
282 LogDebug(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr);
283 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
285 sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
286 LogDebug(
"Calibration") <<
"Accessing " << (
"SL" + superLayerStr);
287 TDirectory* superLayerDir = sectorDir->GetDirectory((
"SL" + superLayerStr).c_str());
289 superLayerDir = sectorDir->mkdir((
"SL" + superLayerStr).c_str());
293 TH1F* histosTH1F =
new TH1F((
"hResDist" + layerHistoName).c_str(),
294 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
298 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + layerHistoName).c_str(),
299 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",