StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
draw_survey_sim.C
1 // draws boxes representing FMS Pb-glass cells, in units of mm
2 
3 void draw_survey_sim(int opt=0){
4  TFile * infile = new TFile("geotr.root","READ");
5  TTree * tr = (TTree*) infile->Get("geotr");
6  Int_t nstb,row,col;
7  tr->SetBranchAddress("nstb",&nstb);
8  tr->SetBranchAddress("row",&row);
9  tr->SetBranchAddress("col",&col);
10 
11  const double xoff[4]={-0.3, 0.3, -0.93, 0.93};
12  const double yoff[4]={98.8, 98.8, 46.5, 46.5};
13  const double xwid[4]={5.812,5.812,3.822, 3.822};
14  const double ywid[4]={5.812,5.812,3.875, 3.875};
15  const int color[4]={2,4,6,7};
16 
17  Double_t x,y,z,x1,y1,x2,y2;
18  Int_t it=0;
19  TLine * cell[4][1264];
20 
21  for(Int_t i=0; i<tr->GetEntries(); i++){
22  tr->GetEntry(i);
23  //printf("nstb=%2d col=%2d row=%2d\n",nstb,col,row);
24  int det=nstb-1;
25  switch(nstb){
26  case 1: case 3: x = xoff[det] - xwid[det]*(col+0.5); break;
27  case 2: case 4: x = xoff[det] + xwid[det]*(col+0.5); break;
28  }
29  y = yoff[det] - ywid[det]*(row+0.5);
30  x1 = x - xwid[det]/2.0;
31  x2 = x + xwid[det]/2.0;
32  y1 = y - ywid[det]/2.0;
33  y2 = y + ywid[det]/2.0;
34 
35  cell[0][it] = new TLine(x1,y1,x2,y1); //t
36  cell[1][it] = new TLine(x1,y2,x2,y2); //b
37  cell[2][it] = new TLine(x1,y1,x1,y2); //l
38  cell[3][it] = new TLine(x2,y1,x2,y2); //r
39  for(Int_t j=0; j<4; j++) cell[j][it]->SetLineColor(color[det]);
40  it++;
41  };
42 
43  if(opt==0){
44  Double_t md = 120;
45  Int_t factor = 1; // bins per millimeter... set this too high and you'll get a memory leak!
46  factor *= 2;
47  TH2D * bg = new TH2D("survey","FMS cells survey [mm]",factor*md,-1*md,md,factor*md,-1*md,md);
48  TCanvas * survey = new TCanvas("survey","survey",700,700);
49  gStyle->SetOptStat(0);
50  bg->Draw();
51  }
52  for(Int_t i=0; i<1264; i++) for(Int_t j=0; j<4; j++) cell[j][i]->Draw();
53 };