Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:13:39

0001 #include "sPhenixStyle.C"
0002 
0003 
0004 int basic(int num ,int run_number )
0005 {
0006 //SetsPhenixStyle();
0007 //TFile *file = TFile::Open("../test602_v11_20869_all.root");
0008 string File_name= Form("../test602_v%d_%d_all.root",num,run_number);
0009 
0010 string outfile= Form("result/out%d_all_v2_67.root",run_number);
0011 
0012 TFile *file = TFile::Open(File_name.c_str());
0013 TNtuple* tapple = (TNtuple*)file->Get("tapple");
0014 
0015 TFile* tf_out = new TFile( outfile.c_str(), "RECREATE" ) ;
0016 
0017 
0018 TH1D* hist = new TH1D( "hist", "", 120, -12, 12 );
0019 
0020 TH1D* hist_Zsize_all = new TH1D( "hist_Zsize_all", "Z size", 9, 1, 10 );
0021 tapple->Draw("Z_size>>hist_Zsize_all", "" );
0022 tf_out->WriteTObject( hist_Zsize_all, "hist_Zsize_all" );
0023 
0024 TH1D* hist_PHYsize = new TH1D( "hist_PHYsize", "PHY size", 128, 1, 129 );
0025 tapple->Draw("PHY_size>>hist", "" );
0026 tf_out->WriteTObject( hist_PHYsize, "hist_PHYsize" );
0027 
0028 TH1D* hist_X_all = new TH1D( "hist_X_all", "x position", 120, -12, 12 );
0029 tapple->Draw("x>>hist_X_all", "" );
0030 tf_out->WriteTObject( hist_X_all, "hist_X_all" );
0031 
0032 TH1D* hist_Y_all = new TH1D( "hist_Y_all", "y position", 120, -12, 12 );
0033 tapple->Draw("y>>hist_Y_all", "" );
0034 tf_out->WriteTObject( hist_Y_all, "hist_Y_all" );
0035 
0036 
0037 TH1D* hist_Z_all = new TH1D( "hist_Z_all", "Z position", 200, -25, 25 );
0038 tapple->Draw("z>>hist_Z_all", "" );
0039 tf_out->WriteTObject( hist_Z_all, "hist_Z_all" );
0040 
0041 
0042 Double_t event = tapple->GetMaximum("ievt");
0043 
0044 TH1D* hist_Zsize_all_scale = new TH1D( "hist_Zsize_all_scale", "Z size", 9, 1, 10 );
0045 tapple->Draw("Z_size>>hist_Zsize_all_scale", "" );
0046 hist_Zsize_all_scale->Scale(1/event);
0047 tf_out->WriteTObject( hist_Zsize_all_scale, "hist_Zsize_all_scale" );
0048 hist_Zsize_all_scale->Draw("HIST");
0049 
0050 for(int i=1;i<9;i++)
0051 {
0052 
0053 auto hist_name = Form("histx_inner_Zsize_%d", i);
0054 TH1D* hist = new TH1D(hist_name, "xposition", 120, -12, 12);
0055 cout<<"i="<<i<<",hist_name="<<hist_name<<endl;
0056 TString draw_command = Form("x>>%s", hist_name);
0057 TString condition = Form("Z_size==%d && (layer==1 || layer==0)", i);
0058 tapple->Draw(draw_command, condition, "");
0059 
0060 auto hist_nameY = Form("histy_inner_Zsize_%d", i);
0061 TH1D* histY = new TH1D(hist_nameY, "yposition", 120, -12, 12);
0062 cout<<"i="<<i<<",hist_name="<<hist_name<<endl;
0063 TString draw_commandY = Form("y>>%s", hist_nameY);
0064 TString conditionY = Form("Z_size==%d && (layer==1 || layer==0)", i);
0065 tapple->Draw(draw_commandY, conditionY, "");
0066 
0067 
0068 tf_out->WriteTObject( hist, hist_name );
0069 
0070 tf_out->WriteTObject( histY, hist_nameY );
0071 
0072 
0073 
0074 
0075 }
0076 
0077 for(int ladder = 0 ;ladder < 3; ladder++)
0078 {
0079 
0080 auto hist_name_Zsize = Form("hist_Zsize_layyer_0_ladder_%d", ladder);
0081 TH1D* hist_Zsize = new TH1D(hist_name_Zsize, "Zsize", 9, 1, 10);
0082 TString draw_command_Zsize = Form("Z_size>>%s", hist_name_Zsize);
0083 TString condition_Zsize = Form("ladder==%d && layer==0", ladder);
0084 tapple->Draw(draw_command_Zsize, condition_Zsize, "");
0085 
0086 tf_out->WriteTObject( hist_Zsize, hist_name_Zsize );
0087 
0088 
0089 auto hist_name_z = Form("hist_z_layyer_0_ladder_%d", ladder);
0090 TH1D* hist_z = new TH1D(hist_name_z, "z", 200, -25, 25);
0091 TString draw_command_z = Form("z>>%s", hist_name_z);
0092 TString condition_z = Form("ladder==%d && layer==0", ladder);
0093 tapple->Draw(draw_command_z, condition_z, "");
0094 cout<<"ladder="<<ladder<<"comand"<<draw_command_z<<","<<condition_z<<endl;
0095 tf_out->WriteTObject( hist_z, hist_name_z );
0096 
0097 
0098 hist_Zsize->Scale(1/event);
0099 auto hist_name_Zsize_Scale = Form("hist_Zsize_Scale_layyer_0_ladder_%d", ladder);
0100 tf_out->WriteTObject( hist_Zsize, hist_name_Zsize_Scale );
0101 
0102 
0103 }
0104 
0105 
0106 
0107 tf_out->Close() ;
0108 file->Close();
0109 return 0;
0110 
0111 }