Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_cdc_offsets.C
Go to the documentation of this file.
1 // Macro to grab offset data for the cdc from the file cdc_alignment.dat and display the results
2 // for a particular ring.
3 void plot_cdc_offsets(unsigned int ring){
4  unsigned int index=ring-1;
5  gStyle->SetOptStat(0);
6 
7  TCanvas *c1=new TCanvas("c1","Alignment results",1200,800);
8  c1->Divide(2,2);
9  gStyle->SetTitleYOffset(1.5);
10 
11  ifstream cdcfile("cdc_alignment.dat");
12 
13  unsigned int numstraws[28]={42,42,54,54,66,66,80,80,93,93,106,106,123,123,
14  135,135,146,146,158,158,170,170,182,182,197,197,
15  209,209};
16 
17  // Histograms to store offset results
18  TH1F *h1=new TH1F("h1","h1",numstraws[index],0.5,numstraws[index]+0.5);
19  h1->SetMaximum(0.1);
20  h1->SetMinimum(-0.1);
21  h1->SetXTitle("Straw");
22  h1->SetYTitle("#Deltax [cm]");
23  char mytitle[80];
24  sprintf(mytitle,"Offsets at wire center for Ring %d\n",ring);
25  h1->SetTitle(mytitle);
26  h1->SetMarkerStyle(20);
27 
28  TH1F *h2=new TH1F("h2","h2",numstraws[index],0.5,numstraws[index]+0.5);
29  h2->SetMaximum(0.1);
30  h2->SetMinimum(-0.1);
31  h2->SetXTitle("Straw");
32  h2->SetYTitle("#Deltay [cm]");
33  h2->SetTitle(mytitle);
34  h2->SetMarkerStyle(20);
35 
36  TH1F *h3=new TH1F("h3","h3",numstraws[index],0.5,numstraws[index]+0.5);
37  h3->SetMaximum(0.01);
38  h3->SetMinimum(-0.01);
39  h3->SetXTitle("Straw");
40  h3->SetYTitle("dx/dz");
41  char mytitle[80];
42  sprintf(mytitle,"Slopes for Ring %d\n",ring);
43  h3->SetTitle(mytitle);
44  h3->SetMarkerStyle(20);
45 
46  TH1F *h4=new TH1F("h4","h4",numstraws[index],0.5,numstraws[index]+0.5);
47  h4->SetMaximum(0.01);
48  h4->SetMinimum(-0.01);
49  h4->SetXTitle("Straw");
50  h4->SetYTitle("dx/dz");
51  h4->SetTitle(mytitle);
52  h4->SetMarkerStyle(20);
53 
54  // Skip first line, used to indentify columns in file
55  char sdummy[40];
56  cdcfile.getline(sdummy,40);
57  // loop over straws; a bit clumsy, but...
58  for (unsigned int i=0;i<28;i++){
59  for (unsigned int j=0;j<numstraws[i];j++){
60  int myring,mystraw;
61  double dxd,dyd,dxu,dyu;
62  cdcfile >> myring;
63  cdcfile >> mystraw;
64  cdcfile >> dxu;
65  cdcfile >> dyu;
66  cdcfile >> dxd;
67  cdcfile >> dyd;
68 
69  if (myring==ring){
70  h1->Fill(mystraw,0.5*(dxu+dxd));
71  h2->Fill(mystraw,0.5*(dyu+dyd));
72  h3->Fill(mystraw,(dxd-dxu)/150.);
73  h4->Fill(mystraw,(dyd-dyu)/150.);
74  }
75  }
76  }
77 
78  // The following functions were used to mock up the wire deflections
79  TF1 *f1=new TF1("f1","[1]*(-0.05*(sin(0.1*(x-1+[0]))+sin(0.2*(x-1+[0]))))",0,numstraws[index]+1);
80  TF1 *f2=new TF1("f2","[1]*(-0.05*(cos(0.1*(x-1+[0]))+cos(0.2*(x-1+[0]))))",0,numstraws[index]+1);
81 
82  TF1 *f3=new TF1("f3","[1]*(-0.05*(sin(0.1*(x-1+[0]))-sin(0.2*(x-1+[0]))))/75.",0,numstraws[index]+1);
83  TF1 *f4=new TF1("f4","[1]*(-0.05*(cos(0.1*(x-1+[0]))-cos(0.2*(x-1+[0]))))/75.",0,numstraws[index]+1);
84 
85  c1->cd(1);
86 
87  h1->Draw("p");
88  f1->SetParameters(ring,0.);
89  f1->Draw("same");
90 
91  c1->cd(2);
92 
93  h2->Draw("p");
94  f2->SetParameters(ring,0);
95  f2->Draw("same");
96 
97  c1->cd(3);
98 
99  h3->Draw("p");
100  f3->SetParameters(ring,0);
101  f3->Draw("same");
102 
103  c1->cd(4);
104 
105  h4->Draw("p");
106  f4->SetParameters(ring,0);
107  f4->Draw("same");
108 
109  cdcfile.close();
110 }
sprintf(text,"Post KinFit Cut")
static char index(char c)
Definition: base64.cpp:115
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TFile f1(fnam)
void plot_cdc_offsets(unsigned int ring)
TF1 * f2
Definition: FitGains.C:28