]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/testITSU/drawLr.C
Removing printout (Davide)
[u/mrichter/AliRoot.git] / ITS / UPGRADE / testITSU / drawLr.C
1 // draw the 1st sensor of every ladder of requested layers (axis directions - thin arrows) 
2 // and the tracking frame of each sensor (axis directions - thick arrows)
3
4 void drawLr(int layMin=1,int layMax=1) 
5 {
6
7   gSystem->Load("libITSUpgradeBase.so");
8   gSystem->Load("libITSUpgradeSim.so");
9   gSystem->Load("libITSUpgradeRec.so");
10
11   AliGeomManager::LoadGeometry("geometry.root");
12
13
14   // Apply misaligment ... ;-)
15   const char *ocdb="local://$ALICE_ROOT/OCDB";
16   AliCDBManager::Instance()->SetDefaultStorage(ocdb);
17   Int_t run = 1;
18   AliCDBManager::Instance()->SetRun(run); 
19   AliCDBManager::Instance()->SetSpecificStorage("ITS/Align/Data", Form("local://%s",gSystem->pwd()));
20   AliCDBEntry *entry = AliCDBManager::Instance()->Get("ITS/Align/Data");
21   TClonesArray *array = (TClonesArray*)entry->GetObject();
22   AliGeomManager::ApplyAlignObjsToGeom(*array);
23   gGeoManager->LockGeometry();
24
25   AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE,kTRUE);
26   TObjArray* segmArr = gm->GetSegmentations();  
27   //
28   int nlr = gm->GetNLayers();
29   if (layMin<0) layMin = 0;
30   if (layMax<0) layMax = nlr-1;
31   else if (layMax>=nlr) layMax = nlr-1;
32   //
33   TH2* hh = new TH2F("hh","hh",100,-70,70,100,-70,70);
34   hh->Draw();
35   gStyle->SetOptStat(0);
36   //
37   double rmax = 0;
38   TGeoHMatrix *msens=0, *mttr=0;
39   double  loc[3]={0,0,0},gloC[3],glo[3],glo1[3],glo2[3],trk[3];
40   //
41   Int_t mod=0;
42
43   for (Int_t lay=layMin;lay<=layMax;lay++) {
44     //
45     AliITSUSegmentationPix* segm = (AliITSUSegmentationPix*)segmArr->At(gm->GetLayerChipTypeID(lay));
46     for (int ild=0;ild<gm->GetNLadders(lay);ild++) {
47     
48       // Sensor Matrices
49       printf("Layer %d Ladder %d\n",lay,ild);
50       msens = gm->GetMatrixSens(lay,ild,mod);
51       printf("Sensor Matrix: ");
52       msens->Print();
53       mttr = gm->GetMatrixT2L(lay,ild,mod);
54       printf("T2L Matrix: ");
55       mttr->Print();
56       //
57       loc[0]=loc[1]=loc[2] = 0;
58       msens->LocalToMaster(loc,gloC);
59       mttr->MasterToLocal(loc,trk);  
60       printf("SensorCenter in Lab: ");
61       for (int i=0;i<3;i++) printf("%+9.4f ",gloC[i]); printf("\n");
62       printf("SensorCenter in TRK: ");
63       for (int i=0;i<3;i++) printf("%+9.4f ",trk[i]); printf("\n");
64       //
65       double r = TMath::Sqrt(gloC[0]*gloC[0]+gloC[1]*gloC[1]);
66       if (rmax<r) rmax = r;
67       //
68       loc[0]=-segm->Dx()/2;
69       msens->LocalToMaster(loc,glo);
70       loc[0]= segm->Dx()/2;;
71       msens->LocalToMaster(loc,glo1);
72       TArrow* linS = new TArrow(glo[0],glo[1],glo1[0],glo1[1],0.012);  // sensor with pos local X direction 
73       linS->SetLineColor((ild+1)%4+1); linS->Draw(); 
74       //
75       loc[0]=0;
76       loc[1]=rmax*0.1;
77       msens->LocalToMaster(loc,glo2);
78       //
79       //lin->Print(); 
80       linS = new TArrow(gloC[0],gloC[1],glo2[0],glo2[1],0.012);  // pos local Y axis
81       linS->SetLineColor((ild+1)%4+1); linS->Draw(); 
82       //
83       TMarker* mrk = new TMarker(gloC[0],gloC[1],31);
84       mrk->SetMarkerColor((ild+1)%4+1);
85       mrk->Draw();
86       //
87       TLatex *latx = new TLatex( gloC[0]*1.2,gloC[1]*1.2,Form("%d",ild));
88       latx->SetTextColor((ild+1)%4+1);
89       latx->SetTextSize(0.02);
90       latx->Draw();
91       //
92       // Check Tracking to Local Matrix -------
93       //
94       // Draw sensors tracking frame
95       trk[0]=trk[1]=0;
96       mttr->LocalToMaster(trk,loc); 
97       msens->LocalToMaster(loc,glo1);
98       TMarker* mrk = new TMarker(glo1[0],glo1[1],24);
99       mrk->SetMarkerColor((ild+1)%4+1);
100       mrk->Draw();
101       //
102       // normal to sensor plane
103       TLine* linN = new TLine(0,0,glo1[0],glo1[1]); 
104       linN->SetLineWidth(1);
105       linN->SetLineStyle(2);
106       linN->SetLineColor((ild+1)%4+1); 
107       linN->Draw(); 
108       //
109       // connect tracking and local frame
110       TLine* linNP = new TLine(gloC[0],gloC[1],glo1[0],glo1[1]); 
111       linNP->SetLineWidth(1);
112       linNP->SetLineStyle(2);
113       linNP->SetLineColor((ild+1)%4+1); 
114       linNP->Draw(); 
115       //
116        // direction of X axis of the tracking plane
117       trk[0]=rmax*0.1;
118       mttr->LocalToMaster(trk,loc); 
119       msens->LocalToMaster(loc,glo); 
120       TArrow* linX = new TArrow(glo1[0],glo1[1],glo[0],glo[1],0.012);
121       linX->SetLineWidth(2);
122       linX->SetLineStyle(1);
123       linX->SetLineColor((ild+1)%4+1); 
124       linX->Draw(); 
125       //
126       trk[0] = 0;
127       // direction of tracking Y axis
128       double dx = glo[0]-glo1[0];
129       double dy = glo[1]-glo1[1];
130       double dst = TMath::Sqrt(dx*dx+dy*dy);
131       trk[1]=-dst;
132       mttr->LocalToMaster(trk,loc); 
133       msens->LocalToMaster(loc,glo);
134       trk[1]= dst;
135       mttr->LocalToMaster(trk,loc); 
136       msens->LocalToMaster(loc,glo1);
137       //
138       TArrow* linT = new TArrow(glo[0],glo[1],glo1[0],glo1[1],0.012); // normal to sensor plane, pox Y of tracking frame
139       linT->SetLineWidth(2);
140       linT->SetLineStyle(1);
141       linT->SetLineColor((ild+1)%4+1); 
142       linT->Draw(); 
143       //
144       printf("Layer %d Ladder %d\n",lay,ild);
145       mttr->Print();
146     }
147   }
148   //
149   rmax = 1.3*rmax;
150   hh->GetXaxis()->SetRangeUser(-rmax,rmax);
151   hh->GetYaxis()->SetRangeUser(-rmax,rmax);
152   gPad->Modified();
153   gPad->Update();
154 }