Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fdc_covariance_hists/gen_covariance_code.C
Go to the documentation of this file.
1 
2 
3 
4 void gen_covariance_code(const char *fname="hd_root.root")
5 {
6  gROOT->Reset();
7 
8  TFile *f = new TFile(fname);
9  f->cd("TRACKING");
10  TH2D *fdc_cov = (TH2D*)gROOT->FindObject("fdc_cov");
11  TH2D *fdc_cath_cov = (TH2D*)gROOT->FindObject("fdc_cath_cov");
12 
13  // Print C++ routine for returning covariance of drift-time
14  // residuals for FDC due to MULS as a function of two FDC
15  // layers.
16  ostream &mout = cout; // Maybe we want this to go straight to a file?
17 
18  mout<<endl;
19  mout<<endl;
20  mout<<"// The following was auto-generated from the gen_covariance_code.C"<<endl;
21  mout<<"// macro using a ROOT file generated with the fdc_covariance_tree"<<endl;
22  mout<<"// plugin."<<endl;
23  mout<<endl;
24  mout<<endl;
25  mout<<"double GetFDCCovariance(int layer1, int layer2);"<<endl;
26  mout<<"double GetFDCCathodeCovariance(int layer1, int layer2);"<<endl;
27  mout<<endl;
28  mout<<endl;
29  mout<<"//-------------------------"<<endl;
30  mout<<"// GetFDCCovariance"<<endl;
31  mout<<"//-------------------------"<<endl;
32  mout<<"double GetFDCCovariance(int layer1, int layer2)"<<endl;
33  mout<<"{"<<endl;
34  mout<<" if(layer1<1 || layer2>24 || layer2<1 || layer2>24)return 0.0;"<<endl;
35  mout<<" if(layer2<layer1){"<<endl;
36  mout<<" int tmp = layer1;"<<endl;
37  mout<<" layer1 = layer2;"<<endl;
38  mout<<" layer2 = tmp;"<<endl;
39  mout<<" }"<<endl;
40  mout<<endl;
41  mout<<" switch(layer1){"<<endl;
42  for(int layer1=1; layer1<=24; layer1++){
43  mout<<" case "<<layer1<<":"<<endl;
44  for(int layer2=layer1; layer2<=24; layer2++){
45  mout<<" if(layer2=="<<layer2<<")return "<<fdc_cov->GetBinContent(layer1, layer2)<<";"<<endl;
46  }
47  mout<<" break; // layer "<<layer1<<endl;
48  }
49  mout<<" } // switch for layer1 "<<layer1<<endl;
50  mout<<endl;
51  mout<<" return 0.0;"<<endl;
52  mout<<"}"<<endl;
53 
54  mout<<endl;
55  mout<<endl;
56  mout<<"// NOTE: At this point, the following is incorrect. It does not"<<endl;
57  mout<<"// Properly account for the Lorentz deflections that are in the"<<endl;
58  mout<<"// simulated data file. It's better to use the above for the"<<endl;
59  mout<<"// MULS error along the wire as well for the time being."<<endl;
60  mout<<"// April 20, 2009 DL"<<endl;
61  mout<<endl;
62  mout<<endl;
63  mout<<"//-------------------------"<<endl;
64  mout<<"// GetFDCCathodeCovariance"<<endl;
65  mout<<"//-------------------------"<<endl;
66  mout<<"double GetFDCCathodeCovariance(int layer1, int layer2)"<<endl;
67  mout<<"{"<<endl;
68  mout<<" if(layer1<1 || layer2>24 || layer2<1 || layer2>24)return 0.0;"<<endl;
69  mout<<" if(layer2<layer1){"<<endl;
70  mout<<" int tmp = layer1;"<<endl;
71  mout<<" layer1 = layer2;"<<endl;
72  mout<<" layer2 = tmp;"<<endl;
73  mout<<" }"<<endl;
74  mout<<endl;
75  mout<<" switch(layer1){"<<endl;
76  for(int layer1=1; layer1<=24; layer1++){
77  mout<<" case "<<layer1<<":"<<endl;
78  for(int layer2=layer1; layer2<=24; layer2++){
79  mout<<" if(layer2=="<<layer2<<")return "<<fdc_cath_cov->GetBinContent(layer1, layer2)<<";"<<endl;
80  }
81  mout<<" break; // layer "<<layer1<<endl;
82  }
83  mout<<" } // switch for layer1 "<<layer1<<endl;
84  mout<<endl;
85  mout<<" return 0.0;"<<endl;
86  mout<<"}"<<endl;
87 }
88 
89 
90 
TF1 * f
Definition: FitGains.C:21
void gen_covariance_code(const char *fname="hd_root.root")