CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/DTMonitorModule/src/DTTrigGeomUtils.cc

Go to the documentation of this file.
00001 /*
00002  * \file DTTrigGeomUtils.cc
00003  * 
00004  * $Date: 2009/08/03 16:08:38 $
00005  * $Revision: 1.2 $
00006  * \author C. Battilana - CIEMAT
00007  *
00008 */
00009 
00010 #include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h"
00011 
00012 // Framework
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 
00015 // Trigger
00016 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
00017 
00018 // Geometry & Segment
00019 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00020 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00021 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00022 #include "Geometry/DTGeometry/interface/DTChamber.h"
00023 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
00024 #include "Geometry/DTGeometry/interface/DTLayer.h"
00025 #include "Geometry/DTGeometry/interface/DTTopology.h"
00026 
00027 #include <iostream>
00028 
00029 using namespace edm;
00030 using namespace std;
00031 
00032 
00033 DTTrigGeomUtils::DTTrigGeomUtils(ESHandle<DTGeometry> muonGeom, bool dirInDeg) : muonGeom_(muonGeom) {
00034 
00035   radToDeg_ = dirInDeg ? 180./Geom::pi() : 1;
00036 
00037   for (int ist=1; ist<=4; ++ist) {
00038     const DTChamberId chId(-2,ist,4);
00039     const DTChamber *chamb = muonGeom_->chamber(chId);
00040     const DTSuperLayer *sl1 = chamb->superLayer(DTSuperLayerId(chId,1));
00041     const DTSuperLayer *sl3 = chamb->superLayer(DTSuperLayerId(chId,3));
00042     zcn_[ist-1] = .5*(chamb->surface().toLocal(sl1->position()).z() + chamb->surface().toLocal(sl3->position()).z());
00043   }
00044   
00045   const DTChamber* chamb   = muonGeom_->chamber(DTChamberId(-2,4,13));
00046   const DTChamber* scchamb = muonGeom_->chamber(DTChamberId(-2,4,4));
00047   xCenter_[0] = scchamb->toLocal(chamb->position()).x()*.5;
00048   chamb   = muonGeom_->chamber(DTChamberId(-2,4,14));
00049   scchamb = muonGeom_->chamber(DTChamberId(-2,4,10));
00050   xCenter_[1] = scchamb->toLocal(chamb->position()).x()*.5;
00051       
00052   
00053 }
00054 
00055 
00056 DTTrigGeomUtils::~DTTrigGeomUtils() {
00057 
00058 }
00059 
00060 
00061 void DTTrigGeomUtils::computeSCCoordinates(const DTRecSegment4D* track, int& scsec, float& x, float& xdir, float& y, float& ydir){
00062 
00063   int sector = track->chamberId().sector();
00064   int station = track->chamberId().station();
00065   xdir = atan(track->localDirection().x()/ track->localDirection().z())*radToDeg_;
00066   ydir = atan(track->localDirection().y()/ track->localDirection().z())*radToDeg_;
00067 
00068 
00069   scsec = sector>12 ? sector==13 ? 4 : 10 : sector;
00070   float xcenter = (scsec==4||scsec==10) ? (sector-12.9)/abs(sector-12.9)*xCenter_[(sector==10||sector==14)] : 0.;
00071   x = track->localPosition().x()+xcenter*(station==4);
00072   y = track->localPosition().y();
00073 
00074 }
00075 
00076 
00077 void DTTrigGeomUtils::phiRange(const DTChamberId& id, float& min, float& max, int& nbins, float step){
00078 
00079   int station = id.station();
00080   int sector  = id.sector(); 
00081   
00082   const DTLayer  *layer = muonGeom_->layer(DTLayerId(id,1,1));
00083   DTTopology topo = layer->specificTopology();
00084   double range = topo.channels()*topo.cellWidth();
00085   min = -range*.5;
00086   max =  range*.5;
00087 
00088   if (station==4 && (sector==4 || sector == 10)){
00089     min = -range-10;
00090     max =  range+10;
00091   }
00092   nbins = static_cast<int>((max-min)/step);
00093 
00094   return;
00095  
00096 }
00097 
00098 
00099 void DTTrigGeomUtils::thetaRange(const DTChamberId& id, float& min, float& max, int& nbins, float step){
00100 
00101   const DTLayer  *layer = muonGeom_->layer(DTLayerId(id,2,1));
00102   DTTopology topo = layer->specificTopology();
00103   double range = topo.channels()*topo.cellWidth();
00104   min = -range*.5;
00105   max =  range*.5;
00106 
00107   nbins = static_cast<int>((max-min)/step);
00108 
00109   return;
00110  
00111 }
00112 
00113 
00114 float DTTrigGeomUtils::trigPos(const L1MuDTChambPhDigi* trig){
00115 
00116   
00117   int wh   = trig->whNum();
00118   int sec  = trig->scNum()+1;
00119   int st   = trig->stNum();
00120   int phi  = trig->phi();
00121 
00122   float phin = (sec-1)*Geom::pi()/6;
00123   float phicenter = 0;
00124   float r = 0;
00125   float xcenter = 0;
00126 
00127   if (sec==4 && st==4) {
00128     GlobalPoint gpos = phi>0 ? muonGeom_->chamber(DTChamberId(wh,st,13))->position() : muonGeom_->chamber(DTChamberId(wh,st,4))->position();
00129     xcenter = phi>0 ? xCenter_[0] : -xCenter_[0];
00130     phicenter =  gpos.phi();
00131     r = gpos.perp();
00132   } else if (sec==10 && st==4) {
00133     GlobalPoint gpos = phi>0 ? muonGeom_->chamber(DTChamberId(wh,st,14))->position() : muonGeom_->chamber(DTChamberId(wh,st,10))->position();
00134     xcenter = phi>0 ? xCenter_[1] : -xCenter_[1];  
00135     phicenter =  gpos.phi();
00136     r = gpos.perp();
00137   } else {
00138     GlobalPoint gpos = muonGeom_->chamber(DTChamberId(wh,st,sec))->position();
00139     phicenter =  gpos.phi();
00140     r = gpos.perp();
00141   }  
00142 
00143   float deltaphi = phicenter-phin;
00144   float x = (tan(phi/4096.)-tan(deltaphi))*(r*cos(deltaphi) - zcn_[st-1]); //zcn is in local coordinates -> z invreases approching to vertex
00145   if (hasPosRF(wh,sec)){ x = -x; } // change sign in case of positive wheels
00146   x+=xcenter;
00147 
00148   return x;
00149 
00150 }
00151 
00152 
00153 float DTTrigGeomUtils::trigDir(const L1MuDTChambPhDigi* trig){
00154 
00155 
00156   int wh   = trig->whNum();
00157   int sec  = trig->scNum()+1;
00158   int phi  = trig->phi();
00159   int phib = trig->phiB();
00160 
00161   float dir = (phib/512.+phi/4096.)*radToDeg_;
00162 
00163   // change sign in case of negative wheels
00164   if (!hasPosRF(wh,sec)) { dir = -dir; }
00165 
00166   return dir;
00167 
00168 }
00169