Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:56

0001 void EdepPercentSmall ()//const char *part="e")//,int nevent = 1000)
0002 {
0003   char infile[100];
0004   int pz[9] = {1,2,4,8,12,16,32,40,50};
0005   double x[9];
0006   double means[9] = {0};
0007   double y[9];
0008   double mval = 0;
0009   int lastbincont = 0;
0010   bool lastbin = false;
0011   int var = 11;
0012   double intnum[1000]  = {0};
0013   double varnum[1000] = {0};
0014   int i = 0;
0015 
0016   // for (int i=0; i<9; i++)
0017   //{
0018   //x[i] = pz[i];
0019   //y[i] = means[i];
0020   sprintf(infile, "/sphenix/user/jpinkenburg/ShowerSize/ntuple/anti_neutron_eta0_50GeV.root");
0021   char hname [100];
0022   sprintf(hname, "anti_neutron50");
0023   TH1F *h1 = new TH1F(hname, hname, 8000, 0, 2);
0024   TFile *f = TFile::Open(infile);
0025   gROOT->cd();
0026   TNtuple *nt = (TNtuple *)f->Get("de");
0027   nt->Project(hname,"dtotal","(ID<=2)*edep","",100000);
0028   //h1->Draw();
0029   /*           for (int j = 1000; j>0; j--)
0030            {
0031            if (lastbin == false)
0032            {
0033            if (h1->GetBinContent(j) == 0)
0034            {
0035            cout << j << endl;
0036            }
0037            else
0038            {
0039            lastbin = true;
0040            lastbincont = (j/1000)*3.5;
0041            }
0042            }
0043            else
0044            {
0045            j=0;
0046            }
0047            }
0048            char revhname[100];
0049            sprintf(revhname,"%s%dGeV",part,pz[i]);
0050            
0051            TH1F *h4 = new TH1F(revhname,revhname,10000,0,lastbincont);
0052            nt->Project(revhname,"dtotal","(ID<=2)*edep","");
0053   */f->Close();
0054   h1->Draw();
0055            
0056   while (var <= 8001)
0057     {
0058       intnum[i] = h1->Integral(1,var);
0059       varnum[i] = .005*(i+1);
0060       var+=11;
0061       i++;
0062     }
0063           
0064   /* mval = h1->Integral();
0065   // cout << "mval " << mval << endl;
0066   cout << "mval_supposed_to_be " << h4->Integral() << endl;
0067   means[i] += mval;
0068   mval = 0;
0069   cout << "6" << endl;
0070   */
0071   char fname [100];
0072   sprintf(fname, "anti_neutron_ThinBins.root");
0073   TFile *fout = TFile::Open(fname,"UPDATE");
0074   h1->Write();
0075   fout->Write();
0076   // cout << h1->Integral() << " "  <<  hname << " " << pz[i] << endl;
0077   TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,4,1,0,50);
0078   gStyle->SetOptStat(0);
0079   TMarker *mean = new TMarker();
0080   mean->SetMarkerStyle(20);
0081   mean->SetMarkerColor(3);
0082   TCanvas *c2 = new TCanvas("c2","stupid graph",1);
0083   //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; 
0084   TGraph *gr = new TGraph((i+1),varnum,intnum);
0085   gr->Draw("AC*");
0086   fout->Write();
0087   fout->Close();
0088   // }
0089   /* TFile *f1 = TFile::Open("anti_neutronShowerEdepPercent.root");
0090      gROOT->cd();
0091      TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,1,1,0,.01);
0092      gStyle->SetOptStat(0);
0093      TMarker *mean = new TMarker();
0094      mean->SetMarkerStyle(20);
0095      mean->SetMarkerColor(3);
0096      TMarker *test = new TMarker();
0097      test->SetMarkerStyle(20);
0098      test->SetMarkerColor(5);
0099      TCanvas *c2 = new TCanvas("c2","stupid graph",1);
0100      double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
0101      TGraph *gr = new TGraph(9,dtot,means);
0102      gr->Draw("AC*");
0103   
0104      h2->Draw();
0105 
0106      test->DrawMarker(0.5,0.005);
0107      mean->DrawMarker(0,0);
0108      double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
0109      double z[9];
0110      //  cout << "bflmv" << meanval[0] << endl;
0111      for (int i=0;i<9;i++)
0112      {
0113      //    sprintf(
0114      cout << "coming" << endl;
0115      z[i] = dtot[i];
0116      // mean->DrawMarker(0,0);
0117      // test->DrawMarker(dtot[i],.005);
0118      cout << "meanval"  << " " << dtot[i] << endl;
0119      cout << "means" << " " << means[i] << endl;
0120      // cout << means[i] << endl;
0121      }
0122      char fname [100];
0123      sprintf(fname, "%sShowerEdepPercent.root",part);
0124      TFile *fout = TFile::Open(fname,"UPDATE");
0125      h2->Draw();
0126      // h2->Write();
0127      // fout->Write();
0128      fout->Close();
0129      f1->Close();
0130   */
0131 }
0132 void EdepSmall(const char *calo="HOe", const char *part = "e")
0133 {
0134    int pz[9] = {1,2,4,8,12,16,32,40,50};
0135    double x[9];
0136    double y[9];
0137    double xer[9] = {0};
0138    double yer[9];
0139    char hname[100];
0140    char fname[100];
0141    sprintf(fname,"%sShowerEdepPercent.root",part);
0142    char area[100];
0143    sprintf(area,"%s",calo);
0144   TFile *fin = TFile::Open(fname);
0145   gROOT->cd();
0146    for (int i=0; i<9; i++)
0147      {
0148        x[i] = pz[i];
0149        sprintf(hname,"%s%s%dd",calo,part,pz[i]);
0150 TH1 *h1 = (TH1F *) fin->Get(hname);
0151      y[i] = h1->GetMean(1);
0152    yer[i] = h1->GetRMS(1);
0153      }
0154    gr = new TGraphErrors(9,x,y,xer,yer);
0155    gr->SetTitle(area);
0156    gr->Draw("ALP");
0157    gr->SetMarkerStyle(20);
0158    gr->SetMarkerColor(2);
0159    fin->Close();
0160 }