35 : histRange_(pset.getParameter<double>(
"histogramRange")),
36 segment4DLabel_(pset.getParameter<edm::
InputTag>(
"segment4DLabel")),
37 rootBaseDir_(pset.getUntrackedParameter<std::
string>(
"rootBaseDir",
"DT/Residuals")),
38 detailedAnalysis_(pset.getUntrackedParameter<bool>(
"detailedAnalysis",
false)),
43 LogDebug(
"Calibration") <<
"[DTResidualCalibration] Constructor called.";
46 rootFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
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;
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;
213 std::string slHistoName =
"_STEP" + std::to_string(step) +
"_W" + wheelStr +
"_St" + stationStr +
"_Sec" + sectorStr +
217 TDirectory* baseDir =
rootFile_->GetDirectory(rootBaseDir_.c_str());
219 baseDir =
rootFile_->mkdir(rootBaseDir_.c_str());
221 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
223 wheelDir = baseDir->mkdir((
"Wheel" + wheelStr).c_str());
225 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
227 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
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;
268 std::string layerHistoName =
"_STEP" + std::to_string(step) +
"_W" + wheelStr +
"_St" + stationStr +
"_Sec" +
269 sectorStr +
"_SL" + superLayerStr +
"_Layer" + layerStr;
276 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
278 wheelDir = baseDir->mkdir((
"Wheel" + wheelStr).c_str());
280 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
282 stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
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
std::map< DTSuperLayerId, TH1F * > histoMapTH1F_
T getUntrackedParameter(std::string const &, T const &) const
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
std::map< DTLayerId, TH2F * > histoMapPerLayerTH2F_
DTSegmentSelector * select_
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
std::pair< const_iterator, const_iterator > range
iterator range
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
edm::InputTag segment4DLabel_
void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance)
void bookHistos(DTSuperLayerId slId)
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
DTResidualCalibration(const edm::ParameterSet &pset)
Constructor.
DTChamberId chamberId() const
Return the corresponding ChamberId.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
LocalVector localDirection() const override
Local direction in Chamber frame.
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
int layer() const
Return the layer number.
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
LocalPoint localPosition() const override
Local position in Chamber frame.
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
Geom::Theta< T > theta() const
C::const_iterator const_iterator
constant access iterator type
const DTTopology & specificTopology() const
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)
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
~DTResidualCalibration() override
Destructor.
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
std::map< DTSuperLayerId, TH2F * > histoMapTH2F_
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
float compute(const DTGeometry *, const DTRecHit1D &, const DTRecSegment4D &)
T const * product() const
const DTGeometry * dtGeom_
DTLayerId layerId() const
Return the corresponding LayerId.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
float segmentToWireDistance(const DTRecHit1D &recHit1D, const DTRecSegment4D &segment)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::map< DTLayerId, TH1F * > histoMapPerLayerTH1F_
int station() const
Return the station number.
int wheel() const
Return the wheel number.
LocalPoint localPosition() const override
Return the 3-dimensional local position.
DTWireId wireId() const
Return the wireId.