35 : histRange_(
pset.getParameter<double>(
"histogramRange")),
37 rootBaseDir_(
pset.getUntrackedParameter<
std::
string>(
"rootBaseDir",
"DT/Residuals")),
38 detailedAnalysis_(
pset.getUntrackedParameter<
bool>(
"detailedAnalysis",
false)),
43 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()) {
96 for (chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt) {
103 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
104 <<
"\nSegment global pos: " <<
chamber->toGlobal((*segment).localPosition());
113 std::vector<DTRecHit1D> recHits1D_S3;
115 if ((*segment).hasPhi()) {
118 std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
121 if ((*segment).hasZed()) {
124 std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
128 for (std::vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin(); recHit1D != recHits1D_S3.end();
130 const DTWireId wireId = recHit1D->wireId();
133 if (segmDistance > 2.1)
134 LogTrace(
"Calibration") <<
"WARNING: segment-wire distance: " << segmDistance;
136 LogTrace(
"Calibration") <<
"segment-wire distance: " << segmDistance;
139 LogTrace(
"Calibration") <<
"Wire Id " << wireId <<
" residual on distance: " << residualOnDistance;
153 float wireX =
layer->specificTopology().wirePosition(wireId.
wire());
169 float segmDistance = -1;
170 if (sl == 1 || sl == 3)
171 segmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
173 segmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
179 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Writing histos to file.";
201 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for SL: " << slId;
219 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" +
wheelStr).c_str());
223 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" +
stationStr).c_str());
225 stationDir = wheelDir->mkdir((
"Station" +
stationStr).c_str());
227 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" +
sectorStr).c_str());
229 sectorDir = stationDir->mkdir((
"Sector" +
sectorStr).c_str());
234 TH1F* histosTH1F =
new TH1F((
"hResDist" + slHistoName).c_str(),
235 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
239 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + slHistoName).c_str(),
240 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
255 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for layer: " << layerId;
267 sectorStr +
"_SL" + superLayerStr +
"_Layer" + layerStr;
274 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" +
wheelStr).c_str());
278 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" +
stationStr).c_str());
280 stationDir = wheelDir->mkdir((
"Station" +
stationStr).c_str());
282 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" +
sectorStr).c_str());
284 sectorDir = stationDir->mkdir((
"Sector" +
sectorStr).c_str());
285 LogDebug(
"Calibration") <<
"Accessing " << (
"SL" + superLayerStr);
286 TDirectory* superLayerDir = sectorDir->GetDirectory((
"SL" + superLayerStr).c_str());
288 superLayerDir = sectorDir->mkdir((
"SL" + superLayerStr).c_str());
292 TH1F* histosTH1F =
new TH1F((
"hResDist" + layerHistoName).c_str(),
293 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
297 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + layerHistoName).c_str(),
298 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
std::map< DTSuperLayerId, TH1F * > histoMapTH1F_
std::map< DTLayerId, TH2F * > histoMapPerLayerTH2F_
DTSegmentSelector * select_
std::pair< const_iterator, const_iterator > range
iterator range
int wire() const
Return the wire number.
void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance)
void bookHistos(DTSuperLayerId slId)
DTResidualCalibration(const edm::ParameterSet &pset)
Constructor.
LocalVector localDirection() const override
Local direction in Chamber frame.
LocalPoint localPosition() const override
Local position in Chamber frame.
static std::string to_string(const XMLCh *ch)
C::const_iterator const_iterator
constant access iterator type
T const * product() const
DTChamberId chamberId() const
Return the corresponding ChamberId.
const edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomToken_
void beginRun(const edm::Run &, const edm::EventSetup &) override
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const std::string rootBaseDir_
Cos< T >::type cos(const T &t)
~DTResidualCalibration() override
Destructor.
const bool detailedAnalysis_
std::map< DTSuperLayerId, TH2F * > histoMapTH2F_
int superlayer() const
Return the superlayer number (deprecated method name)
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
float compute(const DTGeometry *, const DTRecHit1D &, const DTRecSegment4D &)
int layer() const
Return the layer number.
const DTGeometry * dtGeom_
int wheel() const
Return the wheel number.
DTWireId wireId() const
Return the wireId.
const edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
float segmentToWireDistance(const DTRecHit1D &recHit1D, const DTRecSegment4D &segment)
DTLayerId layerId() const
Return the corresponding LayerId.
std::map< DTLayerId, TH1F * > histoMapPerLayerTH1F_
LocalPoint localPosition() const override
Return the 3-dimensional local position.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Geom::Theta< T > theta() const
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.