Back to home page

sPhenix code displayed by LXR

 
 

    


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