21 void Usage(
string mess=
"");
27 int main(
int narg,
char *argv[])
34 TFile *
f =
new TFile(
"material.root",
"RECREATE",
"Produced by material2root");
35 cout<<
"Opened ROOT file \""<<
"material.root"<<
"\" ..."<<endl;
41 TH2D *radlen_LL =
new TH2D(
"radlen_LL",
"Radiation Length;z (cm); r(cm); rad. length (cm)", 2500, -100.0, 1170.0, 1000, 0.0, 125.0);
42 TH2D *radlen_table = (TH2D*)radlen_LL->Clone(
"radlen_table");
43 TH2D *radlen_LL_xy =
new TH2D(
"radlen_LL_xy",
"Radiation Length;x (cm); y(cm); rad. length (cm)", 900, -10.0, 10.0, 900, -10.0, 10.0);
44 TH2D *radlen_table_xy = (TH2D*)radlen_LL_xy->Clone(
"radlen_table_xy");
45 TH2D *A_LL = (TH2D*)radlen_LL->Clone(
"A_LL");
46 TH2D *A_table = (TH2D*)radlen_LL->Clone(
"A_table");
47 TH2D *Z_LL = (TH2D*)radlen_LL->Clone(
"Z_LL");
48 TH2D *Z_table = (TH2D*)radlen_LL->Clone(
"Z_table");
49 TH2D *density_LL = (TH2D*)radlen_LL->Clone(
"density_LL");
50 density_LL->SetTitle(
"Density");
51 density_LL->SetXTitle(
"z (cm)");
52 density_LL->SetYTitle(
"r (cm)");
53 density_LL->SetZTitle(
"density (g/cm^3)");
54 TH2D *density_table = (TH2D*)radlen_LL->Clone(
"density_table");
56 for(
int ir = 1; ir<=radlen_LL->GetNbinsY(); ir++){
57 double r = radlen_LL->GetYaxis()->GetBinCenter(ir);
58 for(
int iz = 1; iz<=radlen_LL->GetNbinsX(); iz++){
59 double z = radlen_LL->GetXaxis()->GetBinCenter(iz);
62 double density, A, Z, RadLen;
64 density = A = Z = RadLen = 0.0;
66 rg->
FindMatLL(pos, density, A, Z, RadLen);
67 radlen_LL->Fill(z, r, RadLen);
70 density_LL->Fill(z, r, density);
72 density = A = Z = RadLen = 0.0;
75 geom->
FindMat(pos, density, A, Z, RadLen);
76 radlen_table->Fill(z, r, RadLen);
77 A_table->Fill(z, r, A);
78 Z_table->Fill(z, r, Z);
79 density_table->Fill(z, r, density);
83 for(
int ix = 1; ix<=radlen_LL_xy->GetNbinsX(); ix++){
84 double x = radlen_LL_xy->GetXaxis()->GetBinCenter(ix);
85 for(
int iy = 1; iy<=radlen_LL_xy->GetNbinsX(); iy++){
86 double y = radlen_LL_xy->GetYaxis()->GetBinCenter(iy);
89 double density, A, Z, RadLen;
91 rg->
FindMatLL(pos, density, A, Z, RadLen);
92 radlen_LL_xy->Fill(x, y, RadLen);
95 geom->
FindMat(pos, density, A, Z, RadLen);
96 radlen_table_xy->Fill(x, y, RadLen);
110 if( narg < 2 )
Usage();
112 for(
int i=1; i<narg; i++){
113 string arg = argv[i];
114 string next = (i+1) < narg ? argv[i+1]:
"";
115 bool missing_arg =
false;
117 if( arg ==
"-h" || arg ==
"--help" )
Usage();
119 if( next.find(
"-") != 0){
121 }
else{ missing_arg =
true; }
124 if(missing_arg)
Usage(
"argument " + arg +
" requires and argument!" );
128 Usage(
"Run number MUST be specified with -r option!");
136 void Usage(
string mess)
139 cout <<
"Usage:" << endl;
140 cout <<
" material2root -r RUN" << endl;
142 cout << mess << endl;
jerror_t FindMat(DVector3 &pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const
jerror_t FindMatLL(DVector3 pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const
void ParseCommandLineArguments(int &narg, char *argv[])
DGeometry * GetDGeometry(unsigned int run_number)
static unsigned int RUN_NUMBER
void Usage(JApplication &app)
int main(int argc, char *argv[])