Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extract_photon_energy_spectrum.C
Go to the documentation of this file.
1 
2 //
3 // This ROOT macro orginally created as a skelton using the
4 // "mkrootmacro" script. (davidl@jlab.org)
5 //
6 // Run this for an amorphous radiator run using the following.
7 // Ideally, one would use an entire EVIO file's worth of data.
8 //
9 // ssh hdops@gluonraid2
10 // cd ~/work/2018.10.05.amorphous_normalization
11 //
12 // setenv run 50770
13 // hd_ana --config=AmorphousNormalization/jana.conf /gluonraid2/rawdata/volatile/RunPeriod*/rawdata/Run0${run}/hd_rawdata_0${run}_000.evio
14 // mv janaroot.root janaroot_0${run}.root
15 // root -l -q "AmorphousNormalization/extract_photon_energy_spectrum.C(${run})"
16 //
17 //
18 //
19 
20 #include "StandardLabels.C"
21 
22 #include <TColor.h>
23 #include <TGraph.h>
24 #include <TFile.h>
25 #include <TTree.h>
26 #include <TF1.h>
27 
29 {
30  TColor::CreateColorWheel();
31 
32  char tmp[256];
33  sprintf(tmp, "janaroot_%06d.root", run);
34  string fname = tmp;
35  string source = "<unknown>";
36 
37  // Option to extract spectrum from online monitoring
38  // ROOT file produced from highlevel_online plugin or
39  // one produced by janaroot plugin
40  TH1I *h = NULL;
41  TFile *f = new TFile(fname.c_str());
42  if(fname.find("hdmon_online") == 0){
43  gDirectory->cd("rootspy");
44  gDirectory->cd("highlevel");
45  h = (TH1I*)gDirectory->Get("BeamEnergy");
46  source = "BeamEnergy histogram from the online monitoring root file";
47  }else{
48  TTree *t = (TTree*)gDirectory->Get("DBeamPhoton");
49  if(t){
50  h = new TH1I("EbeamPhoton", "" , 240, 0.0, 12.0);
51  t->Project("EbeamPhoton", "E");
52  }
53  source = "DBeamPhoton::E of a janaroot file";
54  }
55 
56  if(!h){
57  cout << "Problem getting histogram!" << endl;
58  return;
59  }
60 
61  cout << endl;
62  cout << "Please cut and paste the following into:" << endl;
63  cout << endl;
64  cout << "$HALLD_RECON_HOME/src/plugins/monitoring/highlevel_online/HistMacro_Beam.C" << endl;
65  cout << endl;
66  cout << "//--------------------------------------------------------------------" << endl;
67  cout << "// This taken from the bin contents of: " << source << endl;
68  cout << "// for run " << run << ", an amorphous target run." << endl;
69  cout << "// The data in the table below was created with a macro in:" << endl;
70  cout << "// $HALLD_RECON_HOME/src/plugins/monitoring/highlevel_online/AmorphousNormalization" << endl;
71  cout << "//" << endl;
72  cout << "// The working directory used was:" << endl;
73  cout << "// ~hdops/2018.10.05.amorphous_normalization" << endl;
74  cout << "//" << endl;
75  cout << "string amorphous_label = \"Normalized to Amorphous run " << run << "\";" << endl;
76  cout << endl;
77  cout << " Double_t amorphous_data[] = {" << endl;
78  for(int ibin=1; ibin<=h->GetNbinsX(); ibin++){
79 
80  Int_t v = h->GetBinContent(ibin);
81 
82  char str[256];
83  sprintf(str, "%9d.0", v);
84 
85  if(ibin%10 == 1) cout << "\t\t" ;
86 
87  cout << str << ", ";
88  if(ibin%10 == 0) cout << endl;
89  }
90  cout << " 0.0};" << endl;
91  cout << "//--------------------------------------------------------------------" << endl;
92 
93 }
94 
char str[256]
sprintf(text,"Post KinFit Cut")
TF1 * f
Definition: FitGains.C:21
void extract_photon_energy_spectrum(int run=40859)