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.";
56 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Destructor called.";
74 for (
auto sl_it : ch_it->superLayers()) {
78 for (
auto layer_it : (sl_it)->
layers()) {
98 for (chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt) {
105 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
106 <<
"\nSegment global pos: " <<
chamber->toGlobal((*segment).localPosition());
115 std::vector<DTRecHit1D> recHits1D_S3;
117 if ((*segment).hasPhi()) {
120 std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
123 if ((*segment).hasZed()) {
126 std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
130 for (std::vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin(); recHit1D != recHits1D_S3.end();
132 const DTWireId wireId = recHit1D->wireId();
135 if (segmDistance > 2.1)
136 LogTrace(
"Calibration") <<
"WARNING: segment-wire distance: " << segmDistance;
138 LogTrace(
"Calibration") <<
"segment-wire distance: " << segmDistance;
141 LogTrace(
"Calibration") <<
"Wire Id " << wireId <<
" residual on distance: " << residualOnDistance;
155 float wireX =
layer->specificTopology().wirePosition(wireId.
wire());
171 float segmDistance = -1;
172 if (sl == 1 || sl == 3)
173 segmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
175 segmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
181 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Writing histos to file.";
203 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for SL: " << slId;
220 LogDebug(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr);
221 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
223 wheelDir =
baseDir->mkdir((
"Wheel" + wheelStr).c_str());
224 LogDebug(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
225 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
227 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
228 LogDebug(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr);
229 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
231 sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
236 TH1F* histosTH1F =
new TH1F((
"hResDist" + slHistoName).c_str(),
237 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
241 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + slHistoName).c_str(),
242 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
257 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Booking histos for layer: " << layerId;
269 sectorStr +
"_SL" + superLayerStr +
"_Layer" + layerStr;
275 LogDebug(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr);
276 TDirectory* wheelDir =
baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
278 wheelDir =
baseDir->mkdir((
"Wheel" + wheelStr).c_str());
279 LogDebug(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
280 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
282 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
283 LogDebug(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr);
284 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
286 sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
287 LogDebug(
"Calibration") <<
"Accessing " << (
"SL" + superLayerStr);
288 TDirectory* superLayerDir = sectorDir->GetDirectory((
"SL" + superLayerStr).c_str());
290 superLayerDir = sectorDir->mkdir((
"SL" + superLayerStr).c_str());
294 TH1F* histosTH1F =
new TH1F((
"hResDist" + layerHistoName).c_str(),
295 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
299 TH2F* histosTH2F =
new TH2F((
"hResDistVsDist" + layerHistoName).c_str(),
300 "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.
edm::InputTag segment4DLabel_
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.
std::string to_string(const V &value)
LocalPoint localPosition() const override
Local position in Chamber frame.
constexpr std::array< uint8_t, layerIndexSize > layer
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.
Cos< T >::type cos(const T &t)
~DTResidualCalibration() override
Destructor.
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.
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.