Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cdc_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 *cdc_cov = (TH2D*)gROOT->FindObject("cdc_cov");
11 
12  // Print C++ routine for returning covariance of drift-time
13  // residuals for FDC due to MULS as a function of two FDC
14  // layers.
15  ostream &mout = cout; // Maybe we want this to go straight to a file?
16 
17  mout<<endl;
18  mout<<endl;
19  mout<<"// The following was auto-generated from the gen_covariance_code.C"<<endl;
20  mout<<"// macro using a ROOT file generated with the cdc_covariance_tree"<<endl;
21  mout<<"// plugin."<<endl;
22  mout<<endl;
23  mout<<endl;
24  mout<<"double GetCDCCovariance(int layer1, int layer2);"<<endl;
25  mout<<endl;
26  mout<<endl;
27  mout<<"//-------------------------"<<endl;
28  mout<<"// GetCDCCovariance"<<endl;
29  mout<<"//-------------------------"<<endl;
30  mout<<"double GetCDCCovariance(int layer1, int layer2)"<<endl;
31  mout<<"{"<<endl;
32  mout<<" if(layer1<1 || layer2>27 || layer2<1 || layer2>27)return 0.0;"<<endl;
33  mout<<" if(layer2<layer1){"<<endl;
34  mout<<" int tmp = layer1;"<<endl;
35  mout<<" layer1 = layer2;"<<endl;
36  mout<<" layer2 = tmp;"<<endl;
37  mout<<" }"<<endl;
38  mout<<endl;
39  mout<<" switch(layer1){"<<endl;
40  for(int layer1=1; layer1<=24; layer1++){
41  mout<<" case "<<layer1<<":"<<endl;
42  for(int layer2=layer1; layer2<=24; layer2++){
43  mout<<" if(layer2=="<<layer2<<")return "<<cdc_cov->GetBinContent(layer1, layer2)<<";"<<endl;
44  }
45  mout<<" break; // layer "<<layer1<<endl;
46  }
47  mout<<" } // switch for layer1 "<<layer1<<endl;
48  mout<<endl;
49  mout<<" return 0.0;"<<endl;
50  mout<<"}"<<endl;
51  mout<<endl;
52  mout<<endl;
53 }
54 
55 
56 
TF1 * f
Definition: FitGains.C:21
void gen_covariance_code(const char *fname="hd_root.root")