36 segment4DLabel_(pset.getParameter<
edm::InputTag>(
"segment4DLabel")),
37 rootBaseDir_(pset.getUntrackedParameter<
std::
string>(
"rootBaseDir",
"DT/Residuals")),
38 detailedAnalysis_(pset.getUntrackedParameter<bool>(
"detailedAnalysis",
false)) {
40 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Constructor called.";
43 rootFile_ =
new TFile(rootFileName.c_str(),
"RECREATE");
48 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Destructor called.";
52 TH1::SetDefaultSumw2(
true);
66 for (; ch_it != ch_end; ++ch_it) {
67 std::vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
68 std::vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
70 for(; sl_it != sl_end; ++sl_it) {
74 std::vector<const DTLayer*>::const_iterator layer_it = (*sl_it)->layers().begin();
75 std::vector<const DTLayer*>::const_iterator layer_end = (*sl_it)->layers().end();
76 for(; layer_it != layer_end; ++layer_it) {
94 DTRecSegment4DCollection::id_iterator chamberIdIt;
95 for(chamberIdIt = segment4Ds->id_begin(); chamberIdIt != segment4Ds->id_end(); ++chamberIdIt){
103 segment != range.second; ++segment){
105 LogTrace(
"Calibration") <<
"Segment local pos (in chamber RF): " << (*segment).localPosition()
106 <<
"\nSegment global pos: " << chamber->
toGlobal((*segment).localPosition());
108 if( !
select_(*segment, event, setup) )
continue;
111 std::vector<DTRecHit1D> recHits1D_S3;
113 if( (*segment).hasPhi() ){
116 std::copy(phiRecHits.begin(), phiRecHits.end(), back_inserter(recHits1D_S3));
119 if( (*segment).hasZed() ){
122 std::copy(zRecHits.begin(), zRecHits.end(), back_inserter(recHits1D_S3));
126 for(std::vector<DTRecHit1D>::const_iterator recHit1D = recHits1D_S3.begin();
127 recHit1D != recHits1D_S3.end(); ++recHit1D) {
128 const DTWireId wireId = recHit1D->wireId();
131 if(segmDistance > 2.1)
LogTrace(
"Calibration") <<
"WARNING: segment-wire distance: " << segmDistance;
132 else LogTrace(
"Calibration") <<
"segment-wire distance: " << segmDistance;
135 LogTrace(
"Calibration") <<
"Wire Id " << wireId <<
" residual on distance: " << residualOnDistance;
165 float segmDistance = -1;
166 if(sl == 1 || sl == 3) segmDistance = fabs(wirePosInChamber.
x() - segPosAtZWire.
x());
167 else if(sl == 2) segmDistance = fabs(segPosAtZWire.
y() - wirePosInChamber.
y());
174 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Writing histos to file.";
197 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Booking histos for SL: " << slId;
200 std::stringstream wheelStr; wheelStr << slId.
wheel();
201 std::stringstream stationStr; stationStr << slId.
station();
202 std::stringstream sectorStr; sectorStr << slId.
sector();
203 std::stringstream superLayerStr; superLayerStr << slId.
superlayer();
206 std::stringstream stepStr; stepStr <<
step;
209 "_STEP" + stepStr.str() +
210 "_W" + wheelStr.str() +
211 "_St" + stationStr.str() +
212 "_Sec" + sectorStr.str() +
213 "_SL" + superLayerStr.str();
218 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr.str());
219 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr.str()).c_str());
220 if(!wheelDir) wheelDir = baseDir->mkdir((
"Wheel" + wheelStr.str()).c_str());
221 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Station" + stationStr.str());
222 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr.str()).c_str());
223 if(!stationDir) stationDir = wheelDir->mkdir((
"Station" + stationStr.str()).c_str());
224 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr.str());
225 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr.str()).c_str());
226 if(!sectorDir) sectorDir = stationDir->mkdir((
"Sector" + sectorStr.str()).c_str());
237 std::vector<TH1F*> histosTH1F;
238 histosTH1F.push_back(
new TH1F((
"hResDist"+slHistoName).c_str(),
239 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
241 std::vector<TH2F*> histosTH2F;
242 histosTH2F.push_back(
new TH2F((
"hResDistVsDist"+slHistoName).c_str(),
243 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
244 100, 0, 2.5, 200, -0.4, 0.4));
253 edm::LogVerbatim(
"Calibration") <<
"[DTResidualCalibration] Booking histos for layer: " << layerId;
256 std::stringstream wheelStr; wheelStr << layerId.
wheel();
257 std::stringstream stationStr; stationStr << layerId.
station();
258 std::stringstream sectorStr; sectorStr << layerId.
sector();
259 std::stringstream superLayerStr; superLayerStr << layerId.
superlayer();
260 std::stringstream layerStr; layerStr << layerId.
layer();
263 std::stringstream stepStr; stepStr <<
step;
266 "_STEP" + stepStr.str() +
267 "_W" + wheelStr.str() +
268 "_St" + stationStr.str() +
269 "_Sec" + sectorStr.str() +
270 "_SL" + superLayerStr.str() +
271 "_Layer" + layerStr.str();
276 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Wheel" + wheelStr.str());
277 TDirectory* wheelDir = baseDir->GetDirectory((
"Wheel" + wheelStr.str()).c_str());
278 if(!wheelDir) wheelDir = baseDir->mkdir((
"Wheel" + wheelStr.str()).c_str());
279 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Station" + stationStr.str());
280 TDirectory* stationDir = wheelDir->GetDirectory((
"Station" + stationStr.str()).c_str());
281 if(!stationDir) stationDir = wheelDir->mkdir((
"Station" + stationStr.str()).c_str());
282 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"Sector" + sectorStr.str());
283 TDirectory* sectorDir = stationDir->GetDirectory((
"Sector" + sectorStr.str()).c_str());
284 if(!sectorDir) sectorDir = stationDir->mkdir((
"Sector" + sectorStr.str()).c_str());
285 edm::LogVerbatim(
"Calibration") <<
"Accessing " << (
"SL" + superLayerStr.str());
286 TDirectory* superLayerDir = sectorDir->GetDirectory((
"SL" + superLayerStr.str()).c_str());
287 if(!superLayerDir) superLayerDir = sectorDir->mkdir((
"SL" + superLayerStr.str()).c_str());
291 std::vector<TH1F*> histosTH1F;
292 histosTH1F.push_back(
new TH1F((
"hResDist"+layerHistoName).c_str(),
293 "Residuals on the distance from wire (rec_hit - segm_extr) (cm)",
295 std::vector<TH2F*> histosTH2F;
296 histosTH2F.push_back(
new TH2F((
"hResDistVsDist"+layerHistoName).c_str(),
297 "Residuals on the dist. (cm) from wire (rec_hit - segm_extr) vs dist. (cm)",
298 100, 0, 2.5, 200, -0.4, 0.4));
306 float residualOnDistance) {
309 histosTH1F[0]->Fill(residualOnDistance);
310 histosTH2F[0]->Fill(distance, residualOnDistance);
316 float residualOnDistance) {
319 histosTH1F[0]->Fill(residualOnDistance);
320 histosTH2F[0]->Fill(distance, residualOnDistance);
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.
std::pair< const_iterator, const_iterator > range
iterator range
edm::InputTag segment4DLabel_
void fillHistos(DTSuperLayerId slId, float distance, float residualOnDistance)
void bookHistos(DTSuperLayerId slId)
std::map< DTLayerId, std::vector< TH1F * > > histoMapPerLayerTH1F_
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.
virtual ~DTResidualCalibration()
Destructor.
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
void analyze(const edm::Event &event, const edm::EventSetup &setup)
const DTLayer * layer(DTLayerId id) const
Return a layer given its id.
virtual LocalVector localDirection() const
Local direction in Chamber frame.
void beginRun(const edm::Run &, const edm::EventSetup &)
const DTTopology & specificTopology() const
std::map< DTSuperLayerId, std::vector< TH1F * > > histoMapTH1F_
std::map< DTLayerId, std::vector< TH2F * > > histoMapPerLayerTH2F_
Cos< T >::type cos(const T &t)
std::map< DTSuperLayerId, std::vector< TH2F * > > histoMapTH2F_
virtual LocalPoint localPosition() const
Local position in Chamber frame.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
virtual LocalPoint localPosition() const
Return the 3-dimensional local position.
int wire() const
Return the wire number.
int superlayer() const
Return the superlayer number (deprecated method name)
float compute(const DTGeometry *, const DTRecHit1D &, const DTRecSegment4D &)
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
const DTGeometry * dtGeom_
DTSegmentSelector select_
DTLayerId layerId() const
Return the corresponding LayerId.
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.