Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 void EdepPercentSmall (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
0002 {
0003   cout << "TEST VII" << endl; 
0004   char infile[100];
0005   int pz[9] = {1,2,4,8,12,16,32,40,50};
0006   double x[9];
0007   double means[9] = {0};
0008   double y[9];
0009   double mval = 0;
0010   int lastbincont = 0;
0011   bool lastbin = false;
0012   int var = 11;
0013   double intnum[1000]  = {0};
0014   double varnum[1000] = {0};
0015   char *part[] = {"anti_neutron"};
0016   int i = 0;
0017   int w =4;
0018   //TCanvas *c3 = new TCanvas("TresGraphitos","stupid graph",1);
0019   // TH1F *h4 = new TH1F("histo","histo",1000,0,.5);
0020   //TH2F *h3 = new TH2F("HistoGraph","HistoGraph",1000,0,.55,1000,0,1.2);
0021   // TMarker *grmark = new TMarker();
0022   //      TCanvas *c19 = new TCanvas();
0023   // h3->Draw();
0024   for (int q=0; q<1; q++) 
0025   {
0026       for (int w=0; w<9;w++)
0027         {
0028       cout << "TEST VI" << endl;
0029       char ffile[100];
0030       sprintf(ffile,"/phenix/u/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/HistoBaseFiles/%s_ThinBins.root", part[q]);
0031       TFile *f = TFile::Open(ffile);
0032       char hname[100];
0033       sprintf(hname,"%s%dd",part[q],pz[w]);
0034       TH1F *h1 = (TH1F *)f->Get(hname);
0035       var = 11;
0036       i = 0;
0037       while (var <= 8001)
0038         {
0039 
0040           if (i<1000)
0041         {
0042           varnum[i] = .005*(i);
0043           intnum[i] = (h1->Integral(1,var))/(h1->Integral());
0044           i++;
0045         }
0046           var+=10;
0047         }   
0048       varnum[0] = 0;
0049       intnum[0] = 0;
0050       char fname [100];
0051       sprintf(fname, "Gamma_Neutron_Energy_Graphs.root");
0052       TFile *fout = TFile::Open(fname,"UPDATE");
0053       // h1->Write();
0054       //fout->Write();
0055       f->Close();
0056       //char hname[100];
0057       //sprintf(hname,"%s%dGeV",part[q],pz[w]);
0058       // cout << h1->Integral() << " "  <<  hname << " " << pz[i] << endl;
0059       //TH2 *h2 = new TH2F("hname","hname",1,0,5,1,0,1.2);
0060       gStyle->SetOptStat(0);
0061 
0062       
0063       TMarker *mean = new TMarker();
0064       mean->SetMarkerStyle(20);
0065       mean->SetMarkerColor(3);
0066       char canvname[100];
0067       sprintf(canvname,"%s%d",part[q],pz[w]);
0068       //TCanvas *c3 = new TCanvas(canvname,"stupid graph",1);
0069       //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; 
0070       cout << "TEST V" << endl;
0071       TGraph *gr = new TGraph((i-2),varnum,intnum);
0072           char gtitle[100];
0073       sprintf(gtitle,"%s%dGeV;ConeSize;Percentage of Energy Deposited",part[q],pz[w]);
0074       char gname[100];
0075       sprintf(gname,"%s%dGeV",part[q],pz[w]);
0076       cout << intnum[50] << " " << varnum[50] << endl;
0077       gr->SetTitle(gtitle);
0078       gr->SetName(gname);
0079       gr->SetMarkerStyle(20);
0080       if (part[q] == "anti_neutron")
0081         {
0082           gr->SetMarkerColor(4);
0083         }
0084       else if (part[q] == "neutron")
0085         {
0086           gr->SetMarkerColor(2);
0087         }
0088       else if (part[q] == "gamma")
0089         {
0090           gr->SetMarkerColor(3);
0091         }
0092       else 
0093         {
0094           cout << "idiot" << endl;
0095         }
0096       gr->SetMaximum(1.2);
0097       //h2->Draw();
0098       //gr->Draw("A*");
0099       //gr->Draw("ALP")
0100       //c3->DrawFrame(0,0,0.5,1.2);
0101       // gr->PaintGrapHist((i-1),varnum,intnum,"chopt");
0102       //      gr->SetHistogram(h4);
0103       //h4->Write();
0104       gr->Write();
0105       cout << "TEST 1" << endl;
0106       //  TH2F *h3 = (TH2F *) "HistoGraph";
0107       cout << "TEST II" << endl;
0108 
0109       cout << "TEST III" << endl;
0110       //h3->Write();
0111       cout << "TEST IV" << endl;
0112       //double x;
0113       //double y;
0114       //gr()->GetPoint(
0115 
0116       fout->Write();
0117       fout->Close();
0118       //      gr->Close();
0119       for (int a=0;a<1000;a++)
0120         {
0121           intnum[a] = 0;
0122           varnum[a] = 0;
0123         }
0124       
0125     }
0126        }
0127   
0128   /*  int engy[2] = {2,50};
0129   for (int j=2;j<2;j++)
0130   {
0131       cout << "TEST VIII" << endl;
0132       TFile *fhist = TFile::Open("PosterHistos.root");
0133       cout << "TEST IX" << endl;
0134       // char anhtotname[300];
0135       //sprintf(anhtotname,"anti_neutron%dGeV;ConeSize;Percentage of Energy Deposited",pz[j]);
0136       // auto h32 = (TH2F*)fhist->Get(anhtotname);
0137       char nhtotname[300];
0138       sprintf(nhtotname,"neutron%dGeV;ConeSize;Percentage of Energy Deposited",engy[j]);
0139       auto h12 = (TH2F*)fhist->Get(nhtotname);
0140       cout << "TEST X" << endl;
0141       char ghtotname[300];
0142       sprintf(ghtotname,"gamma%dGeV;ConeSize;Percentage of Energy Deposited",engy[j]);
0143       auto h22 = (TH2F*)fhist->Get(ghtotname);
0144       cout << "TEST XI" << endl;
0145       TCanvas *c12 = new TCanvas();
0146       cout << "TEST XII" << endl;
0147       // h32->Draw();
0148       cout << "TEST XIII" << endl;
0149       h12->Draw();
0150       h22->Draw("PMC same");
0151       cout <<"TEST XIV" << endl;
0152       fhist->Close();
0153       cout << "DONE" << endl;
0154     }
0155   TCanvas *c123 = new TCanvas();
0156   TFile *ff = TFile::Open("PosterHistos.root");
0157   auto h101 = (TH2F*)ff->Get("gamma1GeV;ConeSize;Percentage of Energy Deposited");
0158   h101->Draw();
0159   ff->Close();
0160   for (int o=0;o<8;o++)
0161     { 
0162       TFile *f_all = TFile::Open("PosterHistos.root");
0163       char aname[200];
0164       sprintf(aname,"gamma%dGeV;ConeSize;Percentage of Energy Deposited",pz[(o+1)]);
0165       auto h100 = (TH2F*)f_all->Get(aname);
0166       h100->Draw("PMC same");
0167       f_all->Close();
0168     
0169       }
0170   */
0171 }
0172 
0173 
0174 void ThreeGraphs (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
0175 {
0176 
0177   char infile[100];
0178   int pz[9] = {1,2,4,8,12,16,32,40,50};
0179   double x[9];
0180   double means[9] = {0};
0181   double y[9];
0182   double mval = 0;
0183   int lastbincont = 0;
0184   bool lastbin = false;
0185   int var = 11;
0186   double intnum[1000]  = {0};
0187   double varnum[1000] = {0};
0188   char *part[] = {"gamma","neutron","anti_neutron"};
0189    int i = 0;          
0190 TGraph *gr = new TGraph();
0191  
0192   for (int q=0; q<3; q++) 
0193     {
0194       //          for (int w=0; w<9;w++)
0195       //    {
0196       char ffile[100];
0197       sprintf(ffile,"%s_ThinBins.root", part[q]);
0198       TFile *f = TFile::Open(ffile);
0199       char hname[100];
0200       sprintf(hname,"%s12d",part[q]/*,pz[w]*/);
0201       TH1F *h1 = (TH1F *)f->Get(hname);
0202       var = 11;
0203       i = 0;
0204       while (var <= 8001)
0205         {
0206 
0207           if (i<100)
0208         {
0209           varnum[i] = .005*(i+1);
0210           intnum[i] = (h1->Integral(1,var))/(h1->Integral());
0211         }
0212           var+=10;
0213           i++;
0214         }         
0215   /* mval = h1->Integral();
0216   // cout << "mval " << mval << endl;
0217   cout << "mval_supposed_to_be " << h4->Integral() << endl;
0218   means[i] += mval;
0219   mval = 0;
0220   cout << "6" << endl;
0221   */
0222   
0223       char fname [100];
0224       sprintf(fname, "PosterHistos.root");
0225 y     TFile *fout = TFile::Open(fname,"UPDATE");
0226       h1->Write();
0227       //fout->Write();
0228       f->Close();
0229       // cout << h1->Integral() << " "  <<  hname << " " << pz[i] << endl;
0230       //char canvname[100];
0231       // sprintf(canvname,"%s12",part[q]/*,pz[w]*/);
0232       
0233       //      TCanvas *c3 = new TCanvas("3Graphs","stupid graph",1);
0234       TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,4,1,0,50);
0235       gStyle->SetOptStat(0);
0236       TMarker *mean = new TMarker();
0237       mean->SetMarkerStyle(20);
0238       mean->SetMarkerColor(3);
0239   //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9}; 
0240       // TGraph *gr = TGraph((i-1),varnum,intnum);
0241       gr->TGraph((i-1),varnum,intnum);
0242           char gname[100];
0243       sprintf(gname,"12GeV;xtitle;ytitle"/*,part[q]/*,pz[w]*/);
0244       gr->SetTitle(gname);
0245       gr->SetName(gname);
0246       gr->Draw("A*");
0247       //      gr->Write();
0248       //      c3->Update();
0249       //c3->Modified();
0250       //      fout->Write();
0251       //      fout->Close();
0252       //      gr->Close();
0253       for (int a=0;a<1000;a++)
0254         {
0255           intnum[a] = 0;
0256           varnum[a] = 0;
0257         }
0258   // }
0259       //    }
0260     }
0261   fout->Write();
0262   fout->Close();
0263 }
0264 
0265 
0266 
0267 
0268 
0269 void StupidGraphs (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
0270 {
0271   TFile *fin = TFile::Open("PosterHistos.root");
0272   gROOT->cd();
0273   TH2 *h2 = new TH2F("DumbGraph","TresLines",1,0,10,1,0,50);
0274   gStyle->SetOptStat(0);
0275   TMarker *spf = new TMarker();
0276   spf->SetMarkerStyle(20);
0277   spf->SetMarkerColor(4);
0278   TCanvas *c1 = new TCanvas();
0279   h2->Draw();
0280   double x;
0281   double y;
0282   
0283   char hname[100];
0284   sprintf(hname, "meanvals");
0285   TH2 *gr = (TH2F *) fin->Get(hname);
0286   cout << "herro" << endl;
0287   cout << gr()->GetPoint(1,x,y) << endl;
0288 //spf->DrawMarker();
0289       
0290 }
0291 
0292