Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:53

0001 {
0002   //=== Draw rapidity sector boundaries on picture of tracker in r-z view.
0003 
0004   // WARNING: this script only works on machines where the line:
0005   // OpenGL.CanvasPreferGL: 1
0006   // appears in $ROOTSYS/etc/system.rootrc  (not at RAL).
0007   // Required for semi-transparent plotting.
0008 
0009   // In unnamed scripts, variables not forgotten at end, so must delete them before rerunning script, so ...
0010   gROOT->Reset();
0011 
0012   // Adjust these to line up histogram hisTracker with underlying image of CMS Tracker.
0013   // Then when aligned, comment out line trackerBorder.Draw() below.
0014   const float leftMargin = 23;
0015   const float rightMargin = 33;
0016   const float topMargin = 13;
0017   const float bottomMargin = 14;
0018 
0019   gStyle->SetOptTitle(0);
0020   gStyle->SetOptStat("");
0021   gStyle->SetPadGridX(false);
0022   gStyle->SetPadGridY(false);
0023 
0024   const float trkInRad = 20;
0025   const float trkOutRad = 110;
0026   const float trkLength = 270;
0027   const float beamLen = 15;
0028 
0029   const unsigned int nSec = 9;
0030   const float chosenR = 50;
0031   const unsigned int nSecEdges = nSec + 1;
0032   // Standard eta sectors
0033   const float eta[nSecEdges] = {0, 0.31, 0.61, 0.89, 1.16, 1.43, 1.7, 1.95, 2.16, 2.4};
0034   // Sectors optimised by Ben Gayther to balance GP output data rate (at expense of increased HT tracks).
0035   //const float eta[nSecEdges] = {0.0, 0.19, 0.38, 0.57, 0.77, 1.01, 1.31, 1.66, 2.03, 2.40};
0036   const unsigned int nSubSec = 2;
0037   const unsigned int nSubSecEdges = nSubSec + 1;
0038 
0039   // Optionally draw a stub with the given digitized (r,z) coordinates.
0040   const bool drawStub = true;
0041   const int iDigi_RT = 492;
0042   const int iDigi_Z = -1403;
0043 
0044   TCanvas d1("d1", "d1", 1000, 800);
0045 
0046   // Open picture of CMS tracker
0047   // http://ghugo.web.cern.ch/ghugo/layouts/cabling/OT614_200_IT404_layer2_10G/layout.html
0048   // Adjust the range of trackerBorder below to correspond to the coordinate range shown in this picture.
0049   TImage *img = TImage::Open("TrackerLayout.png");
0050   img->Draw("x");
0051   d1.Update();
0052 
0053   //Create a transparent pad filling the full canvas
0054   TPad p("p", "p", 0, 0, 1, 1);
0055   p.Range(-beamLen - leftMargin, -1 - bottomMargin, trkLength + 30 + rightMargin, trkOutRad + 15 + topMargin);
0056   p.SetFillStyle(4000);
0057   p.SetFrameFillStyle(4000);
0058   p.Draw();
0059   p.cd();
0060 
0061   TPolyLine trackerBorder;
0062 
0063   trackerBorder.SetNextPoint(0., 0.);
0064   trackerBorder.SetNextPoint(295., 0.);
0065   trackerBorder.SetNextPoint(295., 123.);
0066   trackerBorder.SetNextPoint(0., 123.);
0067   trackerBorder.SetNextPoint(0., 0.);
0068   //trackerBorder.Draw();
0069 
0070   /*
0071   TPolyLine subsecBoundary[nSec][nSubSecEdges];
0072 
0073   // Draw sub-sector boundaries.
0074   for (unsigned int i = 0; i < nSec; i++) {
0075     float subsecWidth = (eta[i+1] - eta[i])/float(nSubSec);
0076     for (unsigned int j = 0; j < nSubSecEdges; j++) {
0077       float subsecEtaEdge = eta[i] + subsecWidth * j;
0078       // z at r = chosenR;
0079       float z = chosenR/tan(2 * atan(exp(-subsecEtaEdge)));
0080       // Calculate (r,z) at periphery of Tracker from two ends of beam spot.
0081       // Start by assuming exit through barrel.
0082       float rPeriphNeg = trkOutRad; 
0083       float rPeriphPos = trkOutRad; 
0084       float zPeriphNeg = -beamLen + (z + beamLen)*(rPeriphNeg/chosenR); 
0085       float zPeriphPos =  beamLen + (z - beamLen)*(rPeriphNeg/chosenR); 
0086       // Now check if actual exit through endcap.
0087       if (fabs(zPeriphNeg) > trkLength) {
0088     int whichEndcap = (zPeriphNeg + beamLen > 0)  ?  1  :  -1;
0089     zPeriphNeg = whichEndcap*trkLength;
0090     rPeriphNeg = chosenR*(zPeriphNeg + beamLen)/(z + beamLen);
0091       } 
0092       if (fabs(zPeriphPos) > trkLength) {
0093     int whichEndcap = (zPeriphPos - beamLen > 0)  ?  1  :  -1;
0094     zPeriphPos = whichEndcap*trkLength;
0095     rPeriphPos = chosenR*(zPeriphPos - beamLen)/(z - beamLen);
0096       } 
0097       subsecBoundary[i][j].SetNextPoint(-beamLen,0);
0098       subsecBoundary[i][j].SetNextPoint(zPeriphNeg, rPeriphNeg);
0099       subsecBoundary[i][j].SetNextPoint(zPeriphPos, rPeriphPos);
0100       subsecBoundary[i][j].SetNextPoint(beamLen,0);
0101       subsecBoundary[i][j].SetNextPoint(-beamLen,0);
0102       subsecBoundary[i][j].SetFillColor(kYellow);
0103       unsigned int iHash = 3405+k*10;
0104       subsecBoundary[i][j].SetFillStyle(iHash);
0105       subsecBoundary[i][j].Draw("f");
0106       d1.Update();
0107     }
0108   }
0109   */
0110 
0111   TPolyLine secBoundary[nSecEdges];
0112 
0113   // Draw sector boundaries
0114   for (unsigned int k = 0; k < nSecEdges; k++) {
0115     // z at r = chosenR;
0116     float z = chosenR / tan(2.0 * atan(exp(-eta[k])));
0117     // Calculate (r,z) at periphery of Tracker from two ends of beam spot.
0118     // Start by assuming exit through barrel.
0119     float rPeriphNeg = trkOutRad;
0120     float rPeriphPos = trkOutRad;
0121     float zPeriphNeg = -beamLen + (z + beamLen) * (rPeriphNeg / chosenR);
0122     float zPeriphPos = beamLen + (z - beamLen) * (rPeriphNeg / chosenR);
0123     // Now check if actual exit through endcap.
0124     if (std::abs(zPeriphNeg) > trkLength) {
0125       int whichEndcap = (zPeriphNeg + beamLen > 0) ? 1 : -1;
0126       zPeriphNeg = whichEndcap * trkLength;
0127       rPeriphNeg = chosenR * (zPeriphNeg + beamLen) / (z + beamLen);
0128     }
0129     if (std::abs(zPeriphPos) > trkLength) {
0130       int whichEndcap = (zPeriphPos - beamLen > 0) ? 1 : -1;
0131       zPeriphPos = whichEndcap * trkLength;
0132       rPeriphPos = chosenR * (zPeriphPos - beamLen) / (z - beamLen);
0133     }
0134     secBoundary[k].SetNextPoint(-beamLen, 0);
0135     secBoundary[k].SetNextPoint(zPeriphNeg, rPeriphNeg);
0136     secBoundary[k].SetNextPoint(zPeriphPos, rPeriphPos);
0137     secBoundary[k].SetNextPoint(beamLen, 0);
0138     secBoundary[k].SetNextPoint(-beamLen, 0);
0139     secBoundary[k].SetFillColor(kGreen - 2);
0140     //cout<<k<<" eta "<<eta[k]<<" coords "<<zPeriphNeg<<" "<<rPeriphNeg<<" "<<zPeriphPos<<" "<<rPeriphPos<<endl;
0141     unsigned int iHash = 3405 + k * 9;
0142     secBoundary[k].SetFillStyle(iHash);
0143     secBoundary[k].Draw("f");
0144     d1.Update();
0145   }
0146 
0147   /*
0148   // Draw inner tracker radius.
0149   TLine trkIn(0, trkInRad, trkLength, trkInRad);
0150   trkIn.SetLineWidth(2);
0151   trkIn.Draw();
0152   */
0153   // Draw chosen radius.
0154   TLine chosen(0, chosenR, trkLength, chosenR);
0155   chosen.SetLineWidth(3);
0156   chosen.SetLineStyle(2);
0157   chosen.SetLineColor(kRed);
0158   chosen.Draw();
0159   // Draw beam spot.
0160   TLine beam(-beamLen, 0., beamLen, 0.);
0161   beam.SetLineWidth(5);
0162   beam.SetLineColor(kRed);
0163   beam.Draw();
0164 
0165   // Draw a digitized stub.
0166   /*
0167   if (drawStub) {
0168     float r = 58+103.0382*iDigi_RT/pow(2,10);
0169     float z = 640.*iDigi_Z/pow(2,12);
0170     cout<<"Stub at r = "<<r<<" z = "<<z<<endl;
0171     TMarker stub(z,r,30);
0172     stub.Draw();
0173     d1.Update();
0174   }
0175   */
0176 
0177   d1.Update();
0178 
0179   cout << "Writing EtaSectors.png" << endl;
0180   d1.Print("EtaSectors.png");
0181 
0182   cin.get();
0183 }