Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 void EdepPercentE()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
0002 {
0003   char infile[100];
0004   //char *particles[2] = {"pi-","e-"};
0005   int pz[10] = {1,2,4,8,12,16,32,40,50,90};
0006   //int th[3] = {5,10,18};
0007   int h1int[36];
0008   // for (int i=0; i<10;i++)
0009     //  {
0010   //  for (int j=0; j<5; j++)
0011   //    {
0012   //      for (int k=0; k<3; k++)
0013   //        {
0014           sprintf(infile, "e1out.root");
0015           char hname [100];
0016           sprintf(hname, "e1d");
0017           TH1F *h1 = new TH1F(hname, "e1d", 100, 0, 1);
0018           TFile *f = TFile::Open(infile);
0019           gROOT->cd();
0020           TNtuple *nt = (TNtuple *)f->Get("ed");
0021           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0022           f->Close();
0023           h1->Draw();
0024           TFile *fout = TFile::Open("epercent.root","UPDATE");
0025           h1->Write();
0026           fout->Write();
0027           cout << h1->Integral() << " "  <<  hname << endl;
0028           //fout->Write();
0029           fout->Close();
0030           
0031           sprintf(infile, "e2out.root");
0032           char hname [100];
0033           sprintf(hname, "e2d");
0034           TH1F *h1 = new TH1F(hname, "e2d", 100, 0, 1);
0035           TFile *f = TFile::Open(infile);
0036           gROOT->cd();
0037           TNtuple *nt = (TNtuple *)f->Get("ed");
0038           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0039           f->Close();
0040           h1->Draw();
0041           TFile *fout = TFile::Open("epercent.root","UPDATE");
0042           h1->Write();
0043           fout->Write();
0044           cout << h1->Integral() << " "  <<  hname << endl;
0045           //fout->Write();
0046           fout->Close();
0047           
0048           sprintf(infile, "e4out.root");
0049           char hname [100];
0050           sprintf(hname, "e4d");
0051           TH1F *h1 = new TH1F(hname, "e4d", 100, 0, 1);
0052           TFile *f = TFile::Open(infile);
0053           gROOT->cd();
0054           TNtuple *nt = (TNtuple *)f->Get("ed");
0055           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG");
0056           f->Close();
0057           h1->Draw();
0058           TFile *fout = TFile::Open("epercent.root","UPDATE");
0059           h1->Write();
0060           fout->Write();
0061           cout << h1->Integral() << " "  <<  hname << endl;
0062           //fout->Write();
0063           fout->Close();
0064           
0065           sprintf(infile, "e8out.root");
0066           char hname [100];
0067           sprintf(hname, "e8d");
0068           TH1F *h1 = new TH1F(hname, "e8d", 100, 0, 1);
0069           TFile *f = TFile::Open(infile);
0070           gROOT->cd();
0071           TNtuple *nt = (TNtuple *)f->Get("ed");
0072           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0073           f->Close();
0074           h1->Draw();
0075           TFile *fout = TFile::Open("epercent.root","UPDATE");
0076           h1->Write();
0077           fout->Write();
0078           cout << h1->Integral() << " "  <<  hname << endl;
0079           //fout->Write();
0080           fout->Close();
0081           
0082           sprintf(infile, "e12out.root");
0083           char hname [100];
0084           sprintf(hname, "e12d");
0085           TH1F *h1 = new TH1F(hname, "e12d", 100, 0, 1);
0086           TFile *f = TFile::Open(infile);
0087           gROOT->cd();
0088           TNtuple *nt = (TNtuple *)f->Get("ed");
0089           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0090           f->Close();
0091           h1->Draw();
0092           TFile *fout = TFile::Open("epercent.root","UPDATE");
0093           h1->Write();
0094           fout->Write();
0095           cout << h1->Integral() << " "  <<  hname << endl;
0096           //fout->Write();
0097           fout->Close();
0098           
0099           sprintf(infile, "e16out.root");
0100           char hname [100];
0101           sprintf(hname, "e16d");
0102           TH1F *h1 = new TH1F(hname, "e16d", 100, 0, 1);
0103           TFile *f = TFile::Open(infile);
0104           gROOT->cd();
0105           TNtuple *nt = (TNtuple *)f->Get("ed");
0106           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0107           f->Close();
0108           h1->Draw();
0109           TFile *fout = TFile::Open("epercent.root","UPDATE");
0110           h1->Write();
0111           fout->Write();
0112           cout << h1->Integral() << " "  <<  hname << endl;
0113           //fout->Write();
0114           fout->Close();
0115           
0116           sprintf(infile, "e32out.root");
0117           char hname [100];
0118           sprintf(hname, "e32d");
0119           TH1F *h1 = new TH1F(hname, "e32d", 100, 0, 1);
0120           TFile *f = TFile::Open(infile);
0121           gROOT->cd();
0122           TNtuple *nt = (TNtuple *)f->Get("ed");
0123           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0124           f->Close();
0125           h1->Draw();
0126           TFile *fout = TFile::Open("epercent.root","UPDATE");
0127           h1->Write();
0128           fout->Write();
0129           cout << h1->Integral() << " "  <<  hname << endl;
0130           //fout->Write();
0131           fout->Close();
0132           
0133           sprintf(infile, "e40out.root");
0134           char hname [100];
0135           sprintf(hname, "e40d");
0136           TH1F *h1 = new TH1F(hname, "e40d", 100, 0, 1);
0137           TFile *f = TFile::Open(infile);
0138           gROOT->cd();
0139           TNtuple *nt = (TNtuple *)f->Get("ed");
0140           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0141           f->Close();
0142           h1->Draw();
0143           TFile *fout = TFile::Open("epercent.root","UPDATE");
0144           h1->Write();
0145           fout->Write();
0146           cout << h1->Integral() << " "  <<  hname << endl;
0147           //fout->Write();
0148           fout->Close();
0149           
0150           sprintf(infile, "e50out.root");
0151           char hname [100];
0152           sprintf(hname, "e50d");
0153           TH1F *h1 = new TH1F(hname, "e50d", 100, 0, 1);
0154           TFile *f = TFile::Open(infile);
0155           gROOT->cd();
0156           TNtuple *nt = (TNtuple *)f->Get("ed");
0157           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0158           f->Close();
0159           h1->Draw();
0160           TFile *fout = TFile::Open("epercent.root","UPDATE");
0161           h1->Write();
0162           fout->Write();
0163           cout << h1->Integral() << " "  <<  hname << endl;
0164           //fout->Write();
0165           fout->Close();
0166           
0167           /*    sprintf(infile, "e90out.root");
0168           char hname [100];
0169           sprintf(hname, "e90d");
0170           TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
0171           TFile *f = TFile::Open(infile);
0172           gROOT->cd();
0173           TNtuple *nt = (TNtuple *)f->Get("ed");
0174           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0175           f->Close();
0176           h1->Draw();
0177           TFile *fout = TFile::Open("epercent.root","UPDATE");
0178           h1->Write();
0179           fout->Write();
0180           cout << h1->Integral() << " "  <<  hname << endl;
0181           //fout->Write();
0182           fout->Close();
0183           */
0184 
0185 
0186 
0187 
0188 //      }
0189           //}
0190 //   }
0191 }
0192 
0193 
0194 
0195 
0196 
0197 
0198 
0199 
0200 void EdepPercentAnalyzerE()
0201 {  
0202   TFile *fin = TFile::Open("epercent.root");
0203   gROOT->cd();
0204   TH2 *h2 = new TH2F("htot","EMCAL",1,0,50,1,0,1);
0205   gStyle->SetOptStat(0);
0206   TMarker *spf = new TMarker();
0207   spf->SetMarkerStyle(20);
0208   spf->SetMarkerColor(4);
0209   TCanvas *c1 = new TCanvas();
0210   h2->Draw();
0211   
0212   char hname[100];
0213   sprintf(hname, "e1d");
0214   TH1 *h1 = (TH1F *) fin->Get(hname);
0215   spf->DrawMarker(1, h1->GetMean(1));
0216   
0217    char hname[100];
0218   sprintf(hname, "e2d");
0219   TH1 *h1 = (TH1F *) fin->Get(hname);
0220   spf->DrawMarker(2, h1->GetMean(1));
0221   
0222    char hname[100];
0223   sprintf(hname, "e4d");
0224   TH1 *h1 = (TH1F *) fin->Get(hname);
0225   //int meanval = h1->GetMean(1);
0226   spf->DrawMarker(4, h1->GetMean(1));
0227   
0228    char hname[100];
0229   sprintf(hname, "e8d");
0230   TH1 *h1 = (TH1F *) fin->Get(hname);
0231   // int meanval = h1->GetMean(1);
0232   spf->DrawMarker(8, h1->GetMean(1));
0233   
0234    char hname[100];
0235   sprintf(hname, "e12d");
0236   TH1 *h1 = (TH1F *) fin->Get(hname);
0237   //int meanval = h1->GetMean(1);
0238   spf->DrawMarker(12, h1->GetMean(1));
0239   
0240    char hname[100];
0241   sprintf(hname, "e16d");
0242   TH1 *h1 = (TH1F *) fin->Get(hname);
0243   //int meanval = h1->GetMean(1);
0244   spf->DrawMarker(16, h1->GetMean(1));
0245   
0246    char hname[100];
0247   sprintf(hname, "e32d");
0248   TH1 *h1 = (TH1F *) fin->Get(hname);
0249   // int meanval = h1->GetMean(1);
0250   spf->DrawMarker(32, h1->GetMean(1));
0251   
0252    char hname[100];
0253   sprintf(hname, "e40d");
0254   TH1 *h1 = (TH1F *) fin->Get(hname);
0255   //int meanval = h1->GetMean(1);
0256   spf->DrawMarker(40, h1->GetMean(1));
0257   
0258    char hname[100];
0259   sprintf(hname, "e50d");
0260   TH1 *h1 = (TH1F *) fin->Get(hname);
0261   //int meanval = h1->GetMean(1);
0262   spf->DrawMarker(50, h1->GetMean(1));
0263   
0264   /* char hname[100];
0265   sprintf(hname, "e90d");
0266   TH1 *h1 = (TH1F *) fin->Get(hname);
0267   int meanval = h1->GetMean();
0268   spf->DrawMarker(90, h1->GetMean(1));
0269   */
0270   fin->Close();
0271 
0272   
0273  
0274 
0275 
0276   /* //const int N = 50;
0277   //int count = 0;
0278   //int i1 = 1;
0279   double temp1, temp2, temp3;
0280   //double arr1[N];
0281   //double arr2[N];
0282   //double arr3[N];
0283 char filename1[350], filename2[350], filename3[350];
0284   // open the files
0285 // while (i1<50) {
0286     temp1 = 0.; temp2 = 0.; temp3 = 0.;
0287     sprintf(filename1,"e8out.root");
0288     TFile* f1 = new TFile(filename1,"READONLY");
0289     if (!f1 || f1->IsZombie()) {
0290        printf("Cannot open %s!", filename1);
0291        return;
0292     }
0293     //f1->cd("folder1");
0294     TH1D* h1 = (TH1D*)gDirectory->Get("histo");
0295     if (!h1) {
0296        printf("Cannot read histo!");
0297        return;
0298     }
0299     h1->GetXaxis()->SetRangeUser(0.45,2);
0300     temp1 = h1->Integral();
0301     // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
0302     // so just don't delete it, will be done by delete f1.
0303     sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
0304     TFile* f2 = new TFile(filename2,"READONLY");
0305     if (!f2 || f2->IsZombie()) {
0306        printf("Cannot open %s!", filename2);
0307        return;
0308     }
0309     //f2->cd("folder1");
0310     TH1D* h2 = (TH1D*)gDirectory->Get("histo");
0311     h2->GetXaxis()->SetRangeUser(0.45,2);
0312     temp2 = h2->Integral();
0313     // h2->Delete(); - NO, see above
0314     arr1[count] = temp1;
0315     arr2[count] = temp2;
0316     arr3[count] = temp3;
0317     cout << temp1 << " " << temp2 << endl;
0318     i1 += 5;
0319 count += 1;
0320  
0321 delete f1;
0322 delete f2;
0323   */
0324  }
0325 
0326 
0327 void EdepPercentIH()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
0328 {
0329   char infile[100];
0330   //char *particles[2] = {"pi-","e-"};
0331   int pz[10] = {1,2,4,8,12,16,32,40,50,90};
0332   //int th[3] = {5,10,18};
0333   int h1int[36];
0334   // for (int i=0; i<10;i++)
0335     //  {
0336   //  for (int j=0; j<5; j++)
0337   //    {
0338   //      for (int k=0; k<3; k++)
0339   //        {
0340           sprintf(infile, "e1out.root");
0341           char hname [100];
0342           sprintf(hname, "HIe1d");
0343           TH1F *h1 = new TH1F(hname, "HIe1d", 100, 0, 1);
0344           TFile *f = TFile::Open(infile);
0345           gROOT->cd();
0346           TNtuple *nt = (TNtuple *)f->Get("ed");
0347           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0348           f->Close();
0349           h1->Draw();
0350           TFile *fout = TFile::Open("epercent.root","UPDATE");
0351           h1->Write();
0352           fout->Write();
0353           cout << h1->Integral() << " "  <<  hname << endl;
0354           //fout->Write();
0355           fout->Close();
0356           
0357           sprintf(infile, "e2out.root");
0358           char hname [100];
0359           sprintf(hname, "HIe2d");
0360           TH1F *h1 = new TH1F(hname, "HIe2d", 100, 0, 1);
0361           TFile *f = TFile::Open(infile);
0362           gROOT->cd();
0363           TNtuple *nt = (TNtuple *)f->Get("ed");
0364           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0365           f->Close();
0366           h1->Draw();
0367           TFile *fout = TFile::Open("epercent.root","UPDATE");
0368           h1->Write();
0369           fout->Write();
0370           cout << h1->Integral() << " "  <<  hname << endl;
0371           //fout->Write();
0372           fout->Close();
0373           
0374           sprintf(infile, "e4out.root");
0375           char hname [100];
0376           sprintf(hname, "HIe4d");
0377           TH1F *h1 = new TH1F(hname, "HIe4d", 100, 0, 1);
0378           TFile *f = TFile::Open(infile);
0379           gROOT->cd();
0380           TNtuple *nt = (TNtuple *)f->Get("ed");
0381           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0382           f->Close();
0383           h1->Draw();
0384           TFile *fout = TFile::Open("epercent.root","UPDATE");
0385           h1->Write();
0386           fout->Write();
0387           cout << h1->Integral() << " "  <<  hname << endl;
0388           //fout->Write();
0389           fout->Close();
0390           
0391           sprintf(infile, "e8out.root");
0392           char hname [100];
0393           sprintf(hname, "HIe8d");
0394           TH1F *h1 = new TH1F(hname, "HIe8d", 100, 0, 1);
0395           TFile *f = TFile::Open(infile);
0396           gROOT->cd();
0397           TNtuple *nt = (TNtuple *)f->Get("ed");
0398           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0399           f->Close();
0400           h1->Draw();
0401           TFile *fout = TFile::Open("epercent.root","UPDATE");
0402           h1->Write();
0403           fout->Write();
0404           cout << h1->Integral() << " "  <<  hname << endl;
0405           //fout->Write();
0406           fout->Close();
0407           
0408           sprintf(infile, "e12out.root");
0409           char hname [100];
0410           sprintf(hname, "HIe12d");
0411           TH1F *h1 = new TH1F(hname, "HIe12d", 100, 0, 1);
0412           TFile *f = TFile::Open(infile);
0413           gROOT->cd();
0414           TNtuple *nt = (TNtuple *)f->Get("ed");
0415           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0416           f->Close();
0417           h1->Draw();
0418           TFile *fout = TFile::Open("epercent.root","UPDATE");
0419           h1->Write();
0420           fout->Write();
0421           cout << h1->Integral() << " "  <<  hname << endl;
0422           //fout->Write();
0423           fout->Close();
0424           
0425           sprintf(infile, "e16out.root");
0426           char hname [100];
0427           sprintf(hname, "HIe16d");
0428           TH1F *h1 = new TH1F(hname, "HIe16d", 100, 0, 1);
0429           TFile *f = TFile::Open(infile);
0430           gROOT->cd();
0431           TNtuple *nt = (TNtuple *)f->Get("ed");
0432           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0433           f->Close();
0434           h1->Draw();
0435           TFile *fout = TFile::Open("epercent.root","UPDATE");
0436           h1->Write();
0437           fout->Write();
0438           cout << h1->Integral() << " "  <<  hname << endl;
0439           //fout->Write();
0440           fout->Close();
0441           
0442           sprintf(infile, "e32out.root");
0443           char hname [100];
0444           sprintf(hname, "HIe32d");
0445           TH1F *h1 = new TH1F(hname, "HIe32d", 100, 0, 1);
0446           TFile *f = TFile::Open(infile);
0447           gROOT->cd();
0448           TNtuple *nt = (TNtuple *)f->Get("ed");
0449           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0450           f->Close();
0451           h1->Draw();
0452           TFile *fout = TFile::Open("epercent.root","UPDATE");
0453           h1->Write();
0454           fout->Write();
0455           cout << h1->Integral() << " "  <<  hname << endl;
0456           //fout->Write();
0457           fout->Close();
0458           
0459           sprintf(infile, "e40out.root");
0460           char hname [100];
0461           sprintf(hname, "HIe40d");
0462           TH1F *h1 = new TH1F(hname, "HIe40d", 100, 0, 1);
0463           TFile *f = TFile::Open(infile);
0464           gROOT->cd();
0465           TNtuple *nt = (TNtuple *)f->Get("ed");
0466           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0467           f->Close();
0468           h1->Draw();
0469           TFile *fout = TFile::Open("epercent.root","UPDATE");
0470           h1->Write();
0471           fout->Write();
0472           cout << h1->Integral() << " "  <<  hname << endl;
0473           //fout->Write();
0474           fout->Close();
0475           
0476           sprintf(infile, "e50out.root");
0477           char hname [100];
0478           sprintf(hname, "HIe50d");
0479           TH1F *h1 = new TH1F(hname, "HIe50d", 100, 0, 1);
0480           TFile *f = TFile::Open(infile);
0481           gROOT->cd();
0482           TNtuple *nt = (TNtuple *)f->Get("ed");
0483           nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0484           f->Close();
0485           h1->Draw();
0486           TFile *fout = TFile::Open("epercent.root","UPDATE");
0487           h1->Write();
0488           fout->Write();
0489           cout << h1->Integral() << " "  <<  hname << endl;
0490           //fout->Write();
0491           fout->Close();
0492           
0493           /*    sprintf(infile, "e90out.root");
0494           char hname [100];
0495           sprintf(hname, "e90d");
0496           TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
0497           TFile *f = TFile::Open(infile);
0498           gROOT->cd();
0499           TNtuple *nt = (TNtuple *)f->Get("ed");
0500           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0501           f->Close();
0502           h1->Draw();
0503           TFile *fout = TFile::Open("epercent.root","UPDATE");
0504           h1->Write();
0505           fout->Write();
0506           cout << h1->Integral() << " "  <<  hname << endl;
0507           //fout->Write();
0508           fout->Close();
0509           */
0510 
0511 
0512 
0513 
0514 //      }
0515           //}
0516 //   }
0517 }
0518 
0519 
0520 
0521 
0522 
0523 
0524 
0525 
0526 void EdepPercentAnalyzerIH()
0527 {  
0528   TFile *fin = TFile::Open("epercent.root");
0529   gROOT->cd();
0530   TH2 *h2 = new TH2F("htot","Inner_HCAL",1,0,50,1,0,.1);
0531   gStyle->SetOptStat(0);
0532   TMarker *spf = new TMarker();
0533   spf->SetMarkerStyle(20);
0534   spf->SetMarkerColor(8);
0535   TLine *rlin = new TLine();
0536   rlin->SetLineColor(8);
0537   rlin->SetLineStyle(1);
0538   rlin->SetLineWidth(1);
0539   TCanvas *c2 = new TCanvas();
0540   h2->Draw();
0541   
0542   char hname[100];
0543   sprintf(hname, "HIe1d");
0544   TH1 *h1 = (TH1F *) fin->Get(hname);
0545   spf->DrawMarker(1, h1->GetMean(1));
0546       rlin->DrawLine(1,(h1->GetMean(1)-h1->GetRMS(1)),1,(h1->GetMean(1) + h1->GetRMS(1)));
0547    char hname[100];
0548   sprintf(hname, "HIe2d");
0549   TH1 *h1 = (TH1F *) fin->Get(hname);
0550   spf->DrawMarker(2, h1->GetMean(1));
0551       rlin->DrawLine(2,(h1->GetMean(1)-h1->GetRMS(1)),2,(h1->GetMean(1) + h1->GetRMS(1)));
0552    char hname[100];
0553   sprintf(hname, "HIe4d");
0554   TH1 *h1 = (TH1F *) fin->Get(hname);
0555   //int meanval = h1->GetMean(1);
0556   spf->DrawMarker(4, h1->GetMean(1));
0557       rlin->DrawLine(4,(h1->GetMean(1)-h1->GetRMS(1)),4,(h1->GetMean(1) + h1->GetRMS(1)));
0558    char hname[100];
0559   sprintf(hname, "HIe8d");
0560   TH1 *h1 = (TH1F *) fin->Get(hname);
0561   // int meanval = h1->GetMean(1);
0562   spf->DrawMarker(8, h1->GetMean(1));
0563       rlin->DrawLine(8,(h1->GetMean(1)-h1->GetRMS(1)),8,(h1->GetMean(1) + h1->GetRMS(1)));
0564    char hname[100];
0565   sprintf(hname, "HIe12d");
0566   TH1 *h1 = (TH1F *) fin->Get(hname);
0567   //int meanval = h1->GetMean(1);
0568   spf->DrawMarker(12, h1->GetMean(1));
0569      rlin->DrawLine(12,(h1->GetMean(1)-h1->GetRMS(1)),12,(h1->GetMean(1) + h1->GetRMS(1)));
0570    char hname[100];
0571   sprintf(hname, "HIe16d");
0572   TH1 *h1 = (TH1F *) fin->Get(hname);
0573   //int meanval = h1->GetMean(1);
0574   spf->DrawMarker(16, h1->GetMean(1));
0575     rlin->DrawLine(16,(h1->GetMean(1)-h1->GetRMS(1)),16,(h1->GetMean(1) + h1->GetRMS(1)));
0576 
0577    char hname[100];
0578   sprintf(hname, "HIe32d");
0579   TH1 *h1 = (TH1F *) fin->Get(hname);
0580   // int meanval = h1->GetMean(1);
0581   spf->DrawMarker(32, h1->GetMean(1));
0582     rlin->DrawLine(32,(h1->GetMean(1)-h1->GetRMS(1)),32,(h1->GetMean(1) + h1->GetRMS(1)));
0583    char hname[100];
0584   sprintf(hname, "HIe40d");
0585   TH1 *h1 = (TH1F *) fin->Get(hname);
0586   //int meanval = h1->GetMean(1);
0587   spf->DrawMarker(40, h1->GetMean(1));
0588   rlin->DrawLine(40,(h1->GetMean(1)-h1->GetRMS(1)),40,(h1->GetMean(1) + h1->GetRMS(1)));
0589   
0590    char hname[100];
0591   sprintf(hname, "HIe50d");
0592   TH1 *h1 = (TH1F *) fin->Get(hname);
0593   //int meanval = h1->GetMean(1);
0594   spf->DrawMarker(50, h1->GetMean(1));
0595    rlin->DrawLine(50,(h1->GetMean(1)-h1->GetRMS(1)),50,(h1->GetMean(1) + h1->GetRMS(1)));
0596   
0597   /* char hname[100];
0598   sprintf(hname, "e90d");
0599   TH1 *h1 = (TH1F *) fin->Get(hname);
0600   int meanval = h1->GetMean();
0601   spf->DrawMarker(90, h1->GetMean(1));
0602   */
0603   fin->Close();
0604 
0605   
0606  
0607 
0608 
0609   /* //const int N = 50;
0610   //int count = 0;
0611   //int i1 = 1;
0612   double temp1, temp2, temp3;
0613   //double arr1[N];
0614   //double arr2[N];
0615   //double arr3[N];
0616 char filename1[350], filename2[350], filename3[350];
0617   // open the files
0618 // while (i1<50) {
0619     temp1 = 0.; temp2 = 0.; temp3 = 0.;
0620     sprintf(filename1,"e8out.root");
0621     TFile* f1 = new TFile(filename1,"READONLY");
0622     if (!f1 || f1->IsZombie()) {
0623        printf("Cannot open %s!", filename1);
0624        return;
0625     }
0626     //f1->cd("folder1");
0627     TH1D* h1 = (TH1D*)gDirectory->Get("histo");
0628     if (!h1) {
0629        printf("Cannot read histo!");
0630        return;
0631     }
0632     h1->GetXaxis()->SetRangeUser(0.45,2);
0633     temp1 = h1->Integral();
0634     // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
0635     // so just don't delete it, will be done by delete f1.
0636     sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
0637     TFile* f2 = new TFile(filename2,"READONLY");
0638     if (!f2 || f2->IsZombie()) {
0639        printf("Cannot open %s!", filename2);
0640        return;
0641     }
0642     //f2->cd("folder1");
0643     TH1D* h2 = (TH1D*)gDirectory->Get("histo");
0644     h2->GetXaxis()->SetRangeUser(0.45,2);
0645     temp2 = h2->Integral();
0646     // h2->Delete(); - NO, see above
0647     arr1[count] = temp1;
0648     arr2[count] = temp2;
0649     arr3[count] = temp3;
0650     cout << temp1 << " " << temp2 << endl;
0651     i1 += 5;
0652 count += 1;
0653  
0654 delete f1;
0655 delete f2;
0656   */
0657  }
0658 
0659 void EdepPercentOH()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
0660 {
0661   char infile[100];
0662   //char *particles[2] = {"pi-","e-"};
0663   int pz[10] = {1,2,4,8,12,16,32,40,50,90};
0664   //int th[3] = {5,10,18};
0665   int h1int[36];
0666   // for (int i=0; i<10;i++)
0667     //  {
0668   //  for (int j=0; j<5; j++)
0669   //    {
0670   //      for (int k=0; k<3; k++)
0671   //        {
0672           sprintf(infile, "e1out.root");
0673           char hname [100];
0674           sprintf(hname, "HOe1d");
0675           TH1F *h1 = new TH1F(hname, "HOe1d", 100, 0, 1);
0676           TFile *f = TFile::Open(infile);
0677           gROOT->cd();
0678           TNtuple *nt = (TNtuple *)f->Get("ed");
0679           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0680           f->Close();
0681           h1->Draw();
0682           TFile *fout = TFile::Open("epercent.root","UPDATE");
0683           h1->Write();
0684           fout->Write();
0685           cout << h1->Integral() << " "  <<  hname << endl;
0686           //fout->Write();
0687           fout->Close();
0688           
0689           sprintf(infile, "e2out.root");
0690           char hname [100];
0691           sprintf(hname, "HOe2d");
0692           TH1F *h1 = new TH1F(hname, "HOe2d", 100, 0, 1);
0693           TFile *f = TFile::Open(infile);
0694           gROOT->cd();
0695           TNtuple *nt = (TNtuple *)f->Get("ed");
0696           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0697           f->Close();
0698           h1->Draw();
0699           TFile *fout = TFile::Open("epercent.root","UPDATE");
0700           h1->Write();
0701           fout->Write();
0702           cout << h1->Integral() << " "  <<  hname << endl;
0703           //fout->Write();
0704           fout->Close();
0705           
0706           sprintf(infile, "e4out.root");
0707           char hname [100];
0708           sprintf(hname, "HOe4d");
0709           TH1F *h1 = new TH1F(hname, "HOe4d", 100, 0, 1);
0710           TFile *f = TFile::Open(infile);
0711           gROOT->cd();
0712           TNtuple *nt = (TNtuple *)f->Get("ed");
0713           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0714           f->Close();
0715           h1->Draw();
0716           TFile *fout = TFile::Open("epercent.root","UPDATE");
0717           h1->Write();
0718           fout->Write();
0719           cout << h1->Integral() << " "  <<  hname << endl;
0720           //fout->Write();
0721           fout->Close();
0722           
0723           sprintf(infile, "e8out.root");
0724           char hname [100];
0725           sprintf(hname, "HOe8d");
0726           TH1F *h1 = new TH1F(hname, "HOe8d", 100, 0, 1);
0727           TFile *f = TFile::Open(infile);
0728           gROOT->cd();
0729           TNtuple *nt = (TNtuple *)f->Get("ed");
0730           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0731           f->Close();
0732           h1->Draw();
0733           TFile *fout = TFile::Open("epercent.root","UPDATE");
0734           h1->Write();
0735           fout->Write();
0736           cout << h1->Integral() << " "  <<  hname << endl;
0737           //fout->Write();
0738           fout->Close();
0739           
0740           sprintf(infile, "e12out.root");
0741           char hname [100];
0742           sprintf(hname, "HOe12d");
0743           TH1F *h1 = new TH1F(hname, "HOe12d", 100, 0, 1);
0744           TFile *f = TFile::Open(infile);
0745           gROOT->cd();
0746           TNtuple *nt = (TNtuple *)f->Get("ed");
0747           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0748           f->Close();
0749           h1->Draw();
0750           TFile *fout = TFile::Open("epercent.root","UPDATE");
0751           h1->Write();
0752           fout->Write();
0753           cout << h1->Integral() << " "  <<  hname << endl;
0754           //fout->Write();
0755           fout->Close();
0756           
0757           sprintf(infile, "e16out.root");
0758           char hname [100];
0759           sprintf(hname, "HOe16d");
0760           TH1F *h1 = new TH1F(hname, "HOe16d", 100, 0, 1);
0761           TFile *f = TFile::Open(infile);
0762           gROOT->cd();
0763           TNtuple *nt = (TNtuple *)f->Get("ed");
0764           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0765           f->Close();
0766           h1->Draw();
0767           TFile *fout = TFile::Open("epercent.root","UPDATE");
0768           h1->Write();
0769           fout->Write();
0770           cout << h1->Integral() << " "  <<  hname << endl;
0771           //fout->Write();
0772           fout->Close();
0773           
0774           sprintf(infile, "e32out.root");
0775           char hname [100];
0776           sprintf(hname, "HOe32d");
0777           TH1F *h1 = new TH1F(hname, "HOe32d", 100, 0, 1);
0778           TFile *f = TFile::Open(infile);
0779           gROOT->cd();
0780           TNtuple *nt = (TNtuple *)f->Get("ed");
0781           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0782           f->Close();
0783           h1->Draw();
0784           TFile *fout = TFile::Open("epercent.root","UPDATE");
0785           h1->Write();
0786           fout->Write();
0787           cout << h1->Integral() << " "  <<  hname << endl;
0788           //fout->Write();
0789           fout->Close();
0790           
0791           sprintf(infile, "e40out.root");
0792           char hname [100];
0793           sprintf(hname, "HOe40d");
0794           TH1F *h1 = new TH1F(hname, "HOe40d", 100, 0, 1);
0795           TFile *f = TFile::Open(infile);
0796           gROOT->cd();
0797           TNtuple *nt = (TNtuple *)f->Get("ed");
0798           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0799           f->Close();
0800           h1->Draw();
0801           TFile *fout = TFile::Open("epercent.root","UPDATE");
0802           h1->Write();
0803           fout->Write();
0804           cout << h1->Integral() << " "  <<  hname << endl;
0805           //fout->Write();
0806           fout->Close();
0807           
0808           sprintf(infile, "e50out.root");
0809           char hname [100];
0810           sprintf(hname, "HOe50d");
0811           TH1F *h1 = new TH1F(hname, "HOe50d", 100, 0, 1);
0812           TFile *f = TFile::Open(infile);
0813           gROOT->cd();
0814           TNtuple *nt = (TNtuple *)f->Get("ed");
0815           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0816           f->Close();
0817           h1->Draw();
0818           TFile *fout = TFile::Open("epercent.root","UPDATE");
0819           h1->Write();
0820           fout->Write();
0821           cout << h1->Integral() << " "  <<  hname << endl;
0822           //fout->Write();
0823           fout->Close();
0824           
0825           /*    sprintf(infile, "e90out.root");
0826           char hname [100];
0827           sprintf(hname, "e90d");
0828           TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
0829           TFile *f = TFile::Open(infile);
0830           gROOT->cd();
0831           TNtuple *nt = (TNtuple *)f->Get("ed");
0832           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0833           f->Close();
0834           h1->Draw();
0835           TFile *fout = TFile::Open("epercent.root","UPDATE");
0836           h1->Write();
0837           fout->Write();
0838           cout << h1->Integral() << " "  <<  hname << endl;
0839           //fout->Write();
0840           fout->Close();
0841           */
0842 
0843 
0844 
0845 
0846 //      }
0847           //}
0848 //   }
0849 }
0850 
0851 
0852 
0853 
0854 
0855 void EdepPercentAnalyzerOH(const char *calo="HOe")
0856 {  
0857   TFile *fin = TFile::Open("epercent.root");
0858   gROOT->cd();
0859   TH2 *h2 = new TH2F("htot","Outer_HCAL",1,0,50,1,0,.1);
0860   gStyle->SetOptStat(0);
0861   TMarker *spf = new TMarker();
0862   spf->SetMarkerStyle(20);
0863   spf->SetMarkerColor(11);
0864   TLine *rlin = new TLine();
0865   rlin->SetLineColor(3);
0866   rlin->SetLineStyle(1);
0867   rlin->SetLineWidth(1);
0868   TCanvas *c3 = new TCanvas();
0869    h2->Draw();
0870   
0871   char hname[100];
0872   sprintf(hname, "HOe1d");
0873   TH1 *h1 = (TH1F *) fin->Get(hname);
0874   spf->DrawMarker(1, h1->GetMean(1));
0875    rlin->DrawLine(1,(h1->GetMean(1)-h1->GetRMS(1)),1,(h1->GetMean(1) + h1->GetRMS(1)));
0876    double hom1 = h1->GetMean(1);
0877    double hor1 = h1->GetRMS(1);
0878   
0879    char hname[100];
0880   sprintf(hname, "HOe2d");
0881   TH1 *h1 = (TH1F *) fin->Get(hname);
0882   spf->DrawMarker(2, h1->GetMean(1));
0883    rlin->DrawLine(2,(h1->GetMean(1)-h1->GetRMS(1)),2,(h1->GetMean(1) + h1->GetRMS(1)));
0884    double hom2 = h1->GetMean(1);
0885    double hor2 = h1->GetRMS(1);
0886 
0887    char hname[100];
0888   sprintf(hname, "HOe4d");
0889   TH1 *h1 = (TH1F *) fin->Get(hname);
0890   //int meanval = h1->GetMean(1);
0891   spf->DrawMarker(4, h1->GetMean(1));
0892   rlin->DrawLine(4,(h1->GetMean(1)-h1->GetRMS(1)),4,(h1->GetMean(1) + h1->GetRMS(1)));
0893      double hom4 = h1->GetMean(1);
0894    double hor4 = h1->GetRMS(1);
0895 
0896  
0897    char hname[100];
0898   sprintf(hname, "HOe8d");
0899   TH1 *h1 = (TH1F *) fin->Get(hname);
0900   // int meanval = h1->GetMean(1);
0901   spf->DrawMarker(8, h1->GetMean(1));
0902   rlin->DrawLine(8,(h1->GetMean(1)-h1->GetRMS(1)),8,(h1->GetMean(1) + h1->GetRMS(1)));
0903      double hom8 = h1->GetMean(1);
0904    double hor8 = h1->GetRMS(1);
0905 
0906  
0907    char hname[100];
0908   sprintf(hname, "HOe12d");
0909   TH1 *h1 = (TH1F *) fin->Get(hname);
0910   //int meanval = h1->GetMean(1);
0911   spf->DrawMarker(12, h1->GetMean(1));
0912   rlin->DrawLine(12,(h1->GetMean(1)-h1->GetRMS(1)),12,(h1->GetMean(1) + h1->GetRMS(1)));
0913      double hom12 = h1->GetMean(1);
0914    double hor12 = h1->GetRMS(1);
0915 
0916  
0917    char hname[100];
0918   sprintf(hname, "HOe16d");
0919   TH1 *h1 = (TH1F *) fin->Get(hname);
0920   //int meanval = h1->GetMean(1);
0921   spf->DrawMarker(16, h1->GetMean(1));
0922   rlin->DrawLine(16,(h1->GetMean(1)-h1->GetRMS(1)),16,(h1->GetMean(1) + h1->GetRMS(1)));
0923      double hom16 = h1->GetMean(1);
0924    double hor16 = h1->GetRMS(1);
0925 
0926  
0927    char hname[100];
0928   sprintf(hname, "HOe32d");
0929   TH1 *h1 = (TH1F *) fin->Get(hname);
0930   // int meanval = h1->GetMean(1);
0931   spf->DrawMarker(32, h1->GetMean(1));
0932   rlin->DrawLine(32,(h1->GetMean(1)-h1->GetRMS(1)),32,(h1->GetMean(1) + h1->GetRMS(1)));
0933      double hom32 = h1->GetMean(1);
0934    double hor32 = h1->GetRMS(1);
0935 
0936  
0937    char hname[100];
0938   sprintf(hname, "HOe40d");
0939   TH1 *h1 = (TH1F *) fin->Get(hname);
0940   //int meanval = h1->GetMean(1);
0941   spf->DrawMarker(40, h1->GetMean(1));
0942   rlin->DrawLine(40,(h1->GetMean(1)-h1->GetRMS(1)),40,(h1->GetMean(1) + h1->GetRMS(1)));
0943      double hom40 = h1->GetMean(1);
0944    double hor40 = h1->GetRMS(1);
0945 
0946  
0947    char hname[100];
0948    sprintf(hname, "%s50d",calo);
0949   TH1 *h1 = (TH1F *) fin->Get(hname);
0950   //int meanval = h1->GetMean(1);
0951   spf->DrawMarker(50, h1->GetMean(1));
0952   rlin->DrawLine(50,(h1->GetMean(1)-h1->GetRMS(1)),50,(h1->GetMean(1) + h1->GetRMS(1)));
0953      double hom50 = h1->GetMean(1);
0954    double hor50 = h1->GetRMS(1);
0955 
0956 
0957    double x[9] = {1,2,4,8,12,16,32,40,50};
0958    double y[9] = {hom1,hom2,hom4,hom8,hom12,hom16,hom32,hom40,hom50};
0959    double xer[9] = {0};
0960    double yer[9] = {hor1,hor2,hor4,hor8,hor12,hor16,hor32,hor40,hor50};
0961    gr = new TGraphErrors(9,x,y,xer,yer);
0962    gr->Draw("ALP");
0963    gr->SetMarkerStyle(20);
0964    gr->SetMarkerColor(2);
0965  
0966   /* char hname[100];
0967   sprintf(hname, "e90d");
0968   TH1 *h1 = (TH1F *) fin->Get(hname);
0969   int meanval = h1->GetMean();
0970   spf->DrawMarker(90, h1->GetMean(1));
0971   */
0972   fin->Close();
0973 
0974   
0975  
0976 
0977 
0978   /* //const int N = 50;
0979   //int count = 0;
0980   //int i1 = 1;
0981   double temp1, temp2, temp3;
0982   //double arr1[N];
0983   //double arr2[N];
0984   //double arr3[N];
0985 char filename1[350], filename2[350], filename3[350];
0986   // open the files
0987 // while (i1<50) {
0988     temp1 = 0.; temp2 = 0.; temp3 = 0.;
0989     sprintf(filename1,"e8out.root");
0990     TFile* f1 = new TFile(filename1,"READONLY");
0991     if (!f1 || f1->IsZombie()) {
0992        printf("Cannot open %s!", filename1);
0993        return;
0994     }
0995     //f1->cd("folder1");
0996     TH1D* h1 = (TH1D*)gDirectory->Get("histo");
0997     if (!h1) {
0998        printf("Cannot read histo!");
0999        return;
1000     }
1001     h1->GetXaxis()->SetRangeUser(0.45,2);
1002     temp1 = h1->Integral();
1003     // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
1004     // so just don't delete it, will be done by delete f1.
1005     sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
1006     TFile* f2 = new TFile(filename2,"READONLY");
1007     if (!f2 || f2->IsZombie()) {
1008        printf("Cannot open %s!", filename2);
1009        return;
1010     }
1011     //f2->cd("folder1");
1012     TH1D* h2 = (TH1D*)gDirectory->Get("histo");
1013     h2->GetXaxis()->SetRangeUser(0.45,2);
1014     temp2 = h2->Integral();
1015     // h2->Delete(); - NO, see above
1016     arr1[count] = temp1;
1017     arr2[count] = temp2;
1018     arr3[count] = temp3;
1019     cout << temp1 << " " << temp2 << endl;
1020     i1 += 5;
1021 count += 1;
1022  
1023 delete f1;
1024 delete f2;
1025   */
1026  }
1027 
1028 
1029 
1030 void EdepPercentSmall (const char *calo="HO", const char *part="e")
1031 {
1032   char infile[100];
1033   int pz[9] = {1,2,4,8,12,16,32,40,50};
1034   double x[9];
1035 
1036   for (int i=0; i<9; i++)
1037 {
1038   //x[i] = pz[i];
1039     sprintf(infile, "%s%dout.root",part, pz[i]);
1040           char hname [100];
1041           sprintf(hname, "%s%s%dd",calo,part,pz[i]);
1042           TH1F *h1 = new TH1F(hname, "", 100, 0, 1);
1043           TFile *f = TFile::Open(infile);
1044           gROOT->cd();
1045           TNtuple *nt = (TNtuple *)f->Get("ed");
1046           // char cal [100];
1047           // sprintf(cal,"%s",calo);
1048           if (calo == "HO")
1049         {
1050           nt->Project(hname,"(EA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1051         }
1052           else if(calo == "HI")
1053         {
1054           nt->Project(hname,"(EA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1055         }
1056           else if(calo == "E")
1057         { 
1058           nt->Project(hname,"(EA+ES)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1059         }
1060           else if (calo == "MAG") 
1061         {
1062           nt->Project(hname,"(MAG)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1063         }
1064           else if (calo == "BH")
1065         {
1066       nt->Project(hname,"(MAG)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1067         }
1068           else 
1069         {
1070           cout << "ERROR" << endl;
1071         }
1072           f->Close();
1073           h1->Draw();
1074           char fname [100];
1075           sprintf(fname, "%spercent.root",part);
1076           TFile *fout = TFile::Open(fname,"UPDATE");
1077           h1->Write();
1078           fout->Write();
1079           cout << h1->Integral() << " "  <<  hname << " " << pz[i] << endl;
1080           //fout->Write();
1081           fout->Close();
1082   }
1083 
1084 }
1085 
1086 
1087 
1088 
1089 
1090 
1091 
1092 
1093 void EdepSmall(const char *calo="HOe")
1094 {
1095    int pz[9] = {1,2,4,8,12,16,32,40,50};
1096    double x[9];
1097    double y[9];
1098    double xer[9] = {0};
1099    double yer[9];
1100    char hname[100];
1101   TFile *fin = TFile::Open("epercent.root");
1102   gROOT->cd();
1103    for (int i=0; i<9; i++)
1104      {
1105        x[i] = pz[i];
1106        sprintf(hname,"%s%dd",calo,pz[i]);
1107 TH1 *h1 = (TH1F *) fin->Get(hname);
1108      y[i] = h1->GetMean(1);
1109    yer[i] = h1->GetRMS(1);
1110      }
1111    gr = new TGraphErrors(9,x,y,xer,yer);
1112    gr->Draw("ALP");
1113    gr->SetMarkerStyle(20);
1114    gr->SetMarkerColor(2);
1115    fin->Close();
1116 }
1117