36 histRange_(pset.getParameter<double>(
"histogramRange")),
37 segment4DLabel_(pset.getParameter<
edm::InputTag>(
"segment4DLabel")),
38 rootBaseDir_(pset.getUntrackedParameter<
std::
string>(
"rootBaseDir",
"DT/Residuals")),
39 detailedAnalysis_(pset.getUntrackedParameter<
bool>(
"detailedAnalysis",
false)) {
41 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Constructor called.";
44 rootFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
53 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Destructor called.";
60 TH1::SetDefaultSumw2(
true);
74 for (
auto sl_it : ch_it->superLayers()) {
78 for (
auto layer_it : (sl_it)->
layers()) {
97 DTRecSegment4DCollection::id_iterator chamberIdIt;
98 for(chamberIdIt = segments4D->id_begin(); chamberIdIt != segments4D->id_end(); ++chamberIdIt){
106 segment != range.second; ++segment){
108 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
109 <<
"\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();
131 recHit1D != recHits1D_S3.end(); ++recHit1D) {
132 const DTWireId wireId = recHit1D->wireId();
135 if(segmDistance > 2.1)
LogTrace(
"Calibration") <<
"WARNING: segment-wire distance: " << segmDistance;
136 else LogTrace(
"Calibration") <<
"segment-wire distance: " << segmDistance;
139 LogTrace(
"Calibration") <<
"Wire Id " << wireId <<
" residual on distance: " << residualOnDistance;
168 float segmDistance = -1;
169 if(sl == 1 || sl == 3) segmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
170 else if(sl == 2) segmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
177 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Writing histos to file.";
200 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Booking histos for SL: " << slId;
211 "_STEP" + std::to_string(step) +
218 TDirectory* baseDir =
rootFile_->GetDirectory(rootBaseDir_.c_str());
219 if(!baseDir) baseDir =
rootFile_->mkdir(rootBaseDir_.c_str());
221 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
222 if(!wheelDir) wheelDir = baseDir->mkdir((
"Wheel" + wheelStr).c_str());
223 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
224 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
225 if(!stationDir) stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
227 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
228 if(!sectorDir) sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
233 std::vector<TH1F*> histosTH1F;
234 histosTH1F.push_back(
new TH1F((
"hResDist"+slHistoName).c_str(),
235 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
237 std::vector<TH2F*> histosTH2F;
238 histosTH2F.push_back(
new TH2F((
"hResDistVsDist"+slHistoName).c_str(),
239 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
249 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Booking histos for layer: " << layerId;
261 "_STEP" + std::to_string(step) +
265 "_SL" + superLayerStr +
272 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr).c_str());
273 if(!wheelDir) wheelDir = baseDir->mkdir((
"Wheel" + wheelStr).c_str());
274 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Station" + stationStr);
275 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr).c_str());
276 if(!stationDir) stationDir = wheelDir->mkdir((
"Station" + stationStr).c_str());
278 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr).c_str());
279 if(!sectorDir) sectorDir = stationDir->mkdir((
"Sector" + sectorStr).c_str());
281 TDirectory* superLayerDir = sectorDir->GetDirectory((
"SL" + superLayerStr).c_str());
282 if(!superLayerDir) superLayerDir = sectorDir->mkdir((
"SL" + superLayerStr).c_str());
286 std::vector<TH1F*> histosTH1F;
287 histosTH1F.push_back(
new TH1F((
"hResDist"+layerHistoName).c_str(),
288 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
290 std::vector<TH2F*> histosTH2F;
291 histosTH2F.push_back(
new TH2F((
"hResDistVsDist"+layerHistoName).c_str(),
292 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
301 float residualOnDistance) {
304 histosTH1F[0]->Fill(residualOnDistance);
305 histosTH2F[0]->Fill(distance, residualOnDistance);
311 float residualOnDistance) {
314 histosTH1F[0]->Fill(residualOnDistance);
315 histosTH2F[0]->Fill(distance, residualOnDistance);
LocalPoint localPosition() const override
Return the 3-dimensional local position.
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.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
LocalPoint localPosition() const override
Local position in Chamber frame.
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.
std::map< DTLayerId, std::vector< TH1F * > > histoMapPerLayerTH1F_
LocalVector localDirection() const override
Local direction in Chamber frame.
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.
def setup(process, global_tag, zero_tesla=False)
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.
Geom::Theta< T > theta() const
const DTTopology & specificTopology() const
std::map< DTSuperLayerId, std::vector< TH1F * > > histoMapTH1F_
void beginRun(const edm::Run &, const edm::EventSetup &) override
std::map< DTLayerId, std::vector< TH2F * > > histoMapPerLayerTH2F_
Cos< T >::type cos(const T &t)
std::map< DTSuperLayerId, std::vector< TH2F * > > histoMapTH2F_
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)
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
float compute(const DTGeometry *, const DTRecHit1D &, const DTRecSegment4D &)
const DTGeometry * dtGeom_
DTSegmentSelector select_
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)
int station() const
Return the station number.
int wheel() const
Return the wheel number.
T const * product() const
DTWireId wireId() const
Return the wireId.