Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:11

0001 /*
0002  * \file DTTrigGeomUtils.cc
0003  *
0004  * \author C. Battilana - CIEMAT
0005  *
0006 */
0007 
0008 #include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h"
0009 
0010 // Framework
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 
0013 // Trigger
0014 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
0015 
0016 // Geometry & Segment
0017 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0018 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0019 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0020 #include "Geometry/DTGeometry/interface/DTChamber.h"
0021 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
0022 #include "Geometry/DTGeometry/interface/DTLayer.h"
0023 #include "Geometry/DTGeometry/interface/DTTopology.h"
0024 
0025 #include <iostream>
0026 
0027 using namespace edm;
0028 using namespace std;
0029 
0030 DTTrigGeomUtils::DTTrigGeomUtils(ESHandle<DTGeometry> muonGeom, bool dirInDeg) : muonGeom_(muonGeom) {
0031   radToDeg_ = dirInDeg ? 180. / Geom::pi() : 1;
0032 
0033   for (int ist = 1; ist <= 4; ++ist) {
0034     const DTChamberId chId(-2, ist, 4);
0035     const DTChamber* chamb = muonGeom_->chamber(chId);
0036     const DTSuperLayer* sl1 = chamb->superLayer(DTSuperLayerId(chId, 1));
0037     const DTSuperLayer* sl3 = chamb->superLayer(DTSuperLayerId(chId, 3));
0038     zcn_[ist - 1] =
0039         .5 * (chamb->surface().toLocal(sl1->position()).z() + chamb->surface().toLocal(sl3->position()).z());
0040   }
0041 
0042   const DTChamber* chamb = muonGeom_->chamber(DTChamberId(-2, 4, 13));
0043   const DTChamber* scchamb = muonGeom_->chamber(DTChamberId(-2, 4, 4));
0044   xCenter_[0] = scchamb->toLocal(chamb->position()).x() * .5;
0045   chamb = muonGeom_->chamber(DTChamberId(-2, 4, 14));
0046   scchamb = muonGeom_->chamber(DTChamberId(-2, 4, 10));
0047   xCenter_[1] = scchamb->toLocal(chamb->position()).x() * .5;
0048 }
0049 
0050 DTTrigGeomUtils::~DTTrigGeomUtils() {}
0051 
0052 void DTTrigGeomUtils::computeSCCoordinates(
0053     const DTRecSegment4D* track, int& scsec, float& x, float& xdir, float& y, float& ydir) {
0054   int sector = track->chamberId().sector();
0055   int station = track->chamberId().station();
0056   xdir = atan(track->localDirection().x() / track->localDirection().z()) * radToDeg_;
0057   ydir = atan(track->localDirection().y() / track->localDirection().z()) * radToDeg_;
0058 
0059   scsec = sector > 12 ? sector == 13 ? 4 : 10 : sector;
0060   float xcenter = (scsec == 4 || scsec == 10)
0061                       ? (sector - 12.9) / abs(sector - 12.9) * xCenter_[(sector == 10 || sector == 14)]
0062                       : 0.;
0063   x = track->localPosition().x() + xcenter * (station == 4);
0064   y = track->localPosition().y();
0065 }
0066 
0067 void DTTrigGeomUtils::phiRange(const DTChamberId& id, float& min, float& max, int& nbins, float step) {
0068   int station = id.station();
0069   int sector = id.sector();
0070 
0071   const DTLayer* layer = muonGeom_->layer(DTLayerId(id, 1, 1));
0072   const DTTopology& topo = layer->specificTopology();
0073   double range = topo.channels() * topo.cellWidth();
0074   min = -range * .5;
0075   max = range * .5;
0076 
0077   if (station == 4 && (sector == 4 || sector == 10)) {
0078     min = -range - 10;
0079     max = range + 10;
0080   }
0081   nbins = static_cast<int>((max - min) / step);
0082 
0083   return;
0084 }
0085 
0086 void DTTrigGeomUtils::thetaRange(const DTChamberId& id, float& min, float& max, int& nbins, float step) {
0087   const DTLayer* layer = muonGeom_->layer(DTLayerId(id, 2, 1));
0088   const DTTopology& topo = layer->specificTopology();
0089   double range = topo.channels() * topo.cellWidth();
0090   min = -range * .5;
0091   max = range * .5;
0092 
0093   nbins = static_cast<int>((max - min) / step);
0094 
0095   return;
0096 }
0097 
0098 float DTTrigGeomUtils::trigPos(const L1MuDTChambPhDigi* trig) {
0099   int wh = trig->whNum();
0100   int sec = trig->scNum() + 1;
0101   int st = trig->stNum();
0102   int phi = trig->phi();
0103 
0104   float phin = (sec - 1) * Geom::pi() / 6;
0105   float phicenter = 0;
0106   float r = 0;
0107   float xcenter = 0;
0108 
0109   if (sec == 4 && st == 4) {
0110     GlobalPoint gpos = phi > 0 ? muonGeom_->chamber(DTChamberId(wh, st, 13))->position()
0111                                : muonGeom_->chamber(DTChamberId(wh, st, 4))->position();
0112     xcenter = phi > 0 ? xCenter_[0] : -xCenter_[0];
0113     phicenter = gpos.phi();
0114     r = gpos.perp();
0115   } else if (sec == 10 && st == 4) {
0116     GlobalPoint gpos = phi > 0 ? muonGeom_->chamber(DTChamberId(wh, st, 14))->position()
0117                                : muonGeom_->chamber(DTChamberId(wh, st, 10))->position();
0118     xcenter = phi > 0 ? xCenter_[1] : -xCenter_[1];
0119     phicenter = gpos.phi();
0120     r = gpos.perp();
0121   } else {
0122     GlobalPoint gpos = muonGeom_->chamber(DTChamberId(wh, st, sec))->position();
0123     phicenter = gpos.phi();
0124     r = gpos.perp();
0125   }
0126 
0127   float deltaphi = phicenter - phin;
0128   float x = (tan(phi / 4096.) - tan(deltaphi)) *
0129             (r * cos(deltaphi) - zcn_[st - 1]);  //zcn is in local coordinates -> z invreases approching to vertex
0130   if (hasPosRF(wh, sec)) {
0131     x = -x;
0132   }  // change sign in case of positive wheels
0133   x += xcenter;
0134 
0135   return x;
0136 }
0137 
0138 float DTTrigGeomUtils::trigDir(const L1MuDTChambPhDigi* trig) {
0139   int wh = trig->whNum();
0140   int sec = trig->scNum() + 1;
0141   int phi = trig->phi();
0142   int phib = trig->phiB();
0143 
0144   float dir = (phib / 512. + phi / 4096.) * radToDeg_;
0145 
0146   // change sign in case of negative wheels
0147   if (!hasPosRF(wh, sec)) {
0148     dir = -dir;
0149   }
0150 
0151   return dir;
0152 }
0153 
0154 // Local Variables:
0155 // show-trailing-whitespace: t
0156 // truncate-lines: t
0157 // End: