Back to home page

sPhenix code displayed by LXR

 
 

    


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

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, "an1out.root");
0015           char hname [100];
0016           sprintf(hname, "Ean1d");
0017           TH1F *h1 = new TH1F(hname, "Ean1d", 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("anpercent.root","UPDATE");
0025           h1->Write();
0026           fout->Write();
0027           cout << h1->Integral() << " "  <<  hname << endl;
0028           //fout->Write();
0029           fout->Close();
0030           
0031           sprintf(infile, "an2out.root");
0032           char hname [100];
0033           sprintf(hname, "Ean2d");
0034           TH1F *h1 = new TH1F(hname, "Ean2d", 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("anpercent.root","UPDATE");
0042           h1->Write();
0043           fout->Write();
0044           cout << h1->Integral() << " "  <<  hname << endl;
0045           //fout->Write();
0046           fout->Close();
0047           
0048           sprintf(infile, "an4out.root");
0049           char hname [100];
0050           sprintf(hname, "Ean4d");
0051           TH1F *h1 = new TH1F(hname, "Ean4d", 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("anpercent.root","UPDATE");
0059           h1->Write();
0060           fout->Write();
0061           cout << h1->Integral() << " "  <<  hname << endl;
0062           //fout->Write();
0063           fout->Close();
0064           
0065           sprintf(infile, "an8out.root");
0066           char hname [100];
0067           sprintf(hname, "Ean8d");
0068           TH1F *h1 = new TH1F(hname, "Ean8d", 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("anpercent.root","UPDATE");
0076           h1->Write();
0077           fout->Write();
0078           cout << h1->Integral() << " "  <<  hname << endl;
0079           //fout->Write();
0080           fout->Close();
0081           
0082           sprintf(infile, "an12out.root");
0083           char hname [100];
0084           sprintf(hname, "Ean12d");
0085           TH1F *h1 = new TH1F(hname, "Ean12d", 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("anpercent.root","UPDATE");
0093           h1->Write();
0094           fout->Write();
0095           cout << h1->Integral() << " "  <<  hname << endl;
0096           //fout->Write();
0097           fout->Close();
0098           
0099           sprintf(infile, "an16out.root");
0100           char hname [100];
0101           sprintf(hname, "Ean16d");
0102           TH1F *h1 = new TH1F(hname, "Ean16d", 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("anpercent.root","UPDATE");
0110           h1->Write();
0111           fout->Write();
0112           cout << h1->Integral() << " "  <<  hname << endl;
0113           //fout->Write();
0114           fout->Close();
0115           
0116           sprintf(infile, "an32out.root");
0117           char hname [100];
0118           sprintf(hname, "Ean32d");
0119           TH1F *h1 = new TH1F(hname, "Ean32d", 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("anpercent.root","UPDATE");
0127           h1->Write();
0128           fout->Write();
0129           cout << h1->Integral() << " "  <<  hname << endl;
0130           //fout->Write();
0131           fout->Close();
0132           
0133           sprintf(infile, "an40out.root");
0134           char hname [100];
0135           sprintf(hname, "Ean40d");
0136           TH1F *h1 = new TH1F(hname, "Ean40d", 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("anpercent.root","UPDATE");
0144           h1->Write();
0145           fout->Write();
0146           cout << h1->Integral() << " "  <<  hname << endl;
0147           //fout->Write();
0148           fout->Close();
0149           
0150           sprintf(infile, "an0out.root");
0151           char hname [100];
0152           sprintf(hname, "an50d");
0153           TH1F *h1 = new TH1F(hname, "an50d", 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("anpercent.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("anpercent.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("anpercent.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, "an1d");
0214   TH1 *h1 = (TH1F *) fin->Get(hname);
0215   spf->DrawMarker(1, h1->GetMean(1));
0216   
0217    char hname[100];
0218   sprintf(hname, "an2d");
0219   TH1 *h1 = (TH1F *) fin->Get(hname);
0220   spf->DrawMarker(2, h1->GetMean(1));
0221   
0222    char hname[100];
0223   sprintf(hname, "an4d");
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, "an8d");
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, "an12d");
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, "an16d");
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, "an32d");
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, "an40d");
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, "an50d");
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, "an1out.root");
0341           char hname [100];
0342           sprintf(hname, "HIan1d");
0343           TH1F *h1 = new TH1F(hname, "HIan1d", 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("anpercent.root","UPDATE");
0351           h1->Write();
0352           fout->Write();
0353           cout << h1->Integral() << " "  <<  hname << endl;
0354           //fout->Write();
0355           fout->Close();
0356           
0357           sprintf(infile, "an2out.root");
0358           char hname [100];
0359           sprintf(hname, "HIan2d");
0360           TH1F *h1 = new TH1F(hname, "HIan2d", 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("anpercent.root","UPDATE");
0368           h1->Write();
0369           fout->Write();
0370           cout << h1->Integral() << " "  <<  hname << endl;
0371           //fout->Write();
0372           fout->Close();
0373           
0374           sprintf(infile, "an4out.root");
0375           char hname [100];
0376           sprintf(hname, "HIan4d");
0377           TH1F *h1 = new TH1F(hname, "HIan4d", 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("anpercent.root","UPDATE");
0385           h1->Write();
0386           fout->Write();
0387           cout << h1->Integral() << " "  <<  hname << endl;
0388           //fout->Write();
0389           fout->Close();
0390           
0391           sprintf(infile, "an8out.root");
0392           char hname [100];
0393           sprintf(hname, "HIan8d");
0394           TH1F *h1 = new TH1F(hname, "HIan8d", 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("anpercent.root","UPDATE");
0402           h1->Write();
0403           fout->Write();
0404           cout << h1->Integral() << " "  <<  hname << endl;
0405           //fout->Write();
0406           fout->Close();
0407           
0408           sprintf(infile, "an12out.root");
0409           char hname [100];
0410           sprintf(hname, "HIan12d");
0411           TH1F *h1 = new TH1F(hname, "HIan12d", 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("anpercent.root","UPDATE");
0419           h1->Write();
0420           fout->Write();
0421           cout << h1->Integral() << " "  <<  hname << endl;
0422           //fout->Write();
0423           fout->Close();
0424           
0425           sprintf(infile, "an16out.root");
0426           char hname [100];
0427           sprintf(hname, "HIan16d");
0428           TH1F *h1 = new TH1F(hname, "HIan16d", 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("anpercent.root","UPDATE");
0436           h1->Write();
0437           fout->Write();
0438           cout << h1->Integral() << " "  <<  hname << endl;
0439           //fout->Write();
0440           fout->Close();
0441           
0442           sprintf(infile, "an32out.root");
0443           char hname [100];
0444           sprintf(hname, "HIan32d");
0445           TH1F *h1 = new TH1F(hname, "HIan32d", 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("anpercent.root","UPDATE");
0453           h1->Write();
0454           fout->Write();
0455           cout << h1->Integral() << " "  <<  hname << endl;
0456           //fout->Write();
0457           fout->Close();
0458           
0459           sprintf(infile, "an40out.root");
0460           char hname [100];
0461           sprintf(hname, "HIan40d");
0462           TH1F *h1 = new TH1F(hname, "HIan40d", 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("anpercent.root","UPDATE");
0470           h1->Write();
0471           fout->Write();
0472           cout << h1->Integral() << " "  <<  hname << endl;
0473           //fout->Write();
0474           fout->Close();
0475           
0476           sprintf(infile, "an50out.root");
0477           char hname [100];
0478           sprintf(hname, "HIan50d");
0479           TH1F *h1 = new TH1F(hname, "HIan50d", 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("anpercent.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("anpercent.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("anpercent.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, "HIan1d");
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, "HIan2d");
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, "HIan4d");
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, "HIan8d");
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, "HIan12d");
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, "HIan16d");
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, "HIan32d");
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, "HIan40d");
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, "HIan50d");
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 
0660 void EdepPercentOH()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
0661 {
0662   char infile[100];
0663   //char *particles[2] = {"pi-","e-"};
0664   int pz[10] = {1,2,4,8,12,16,32,40,50,90};
0665   //int th[3] = {5,10,18};
0666   int h1int[36];
0667   // for (int i=0; i<10;i++)
0668     //  {
0669   //  for (int j=0; j<5; j++)
0670   //    {
0671   //      for (int k=0; k<3; k++)
0672   //        {
0673           sprintf(infile, "an1out.root");
0674           char hname [100];
0675           sprintf(hname, "HOan1d");
0676           TH1F *h1 = new TH1F(hname, "HOan1d", 100, 0, 1);
0677           TFile *f = TFile::Open(infile);
0678           gROOT->cd();
0679           TNtuple *nt = (TNtuple *)f->Get("ed");
0680           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0681           f->Close();
0682           h1->Draw();
0683           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0684           h1->Write();
0685           fout->Write();
0686           cout << h1->Integral() << " "  <<  hname << endl;
0687           //fout->Write();
0688           fout->Close();
0689           
0690           sprintf(infile, "an2out.root");
0691           char hname [100];
0692           sprintf(hname, "HOan2d");
0693           TH1F *h1 = new TH1F(hname, "HOan2d", 100, 0, 1);
0694           TFile *f = TFile::Open(infile);
0695           gROOT->cd();
0696           TNtuple *nt = (TNtuple *)f->Get("ed");
0697           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0698           f->Close();
0699           h1->Draw();
0700           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0701           h1->Write();
0702           fout->Write();
0703           cout << h1->Integral() << " "  <<  hname << endl;
0704           //fout->Write();
0705           fout->Close();
0706           
0707           sprintf(infile, "an4out.root");
0708           char hname [100];
0709           sprintf(hname, "HOan4d");
0710           TH1F *h1 = new TH1F(hname, "HOan4d", 100, 0, 1);
0711           TFile *f = TFile::Open(infile);
0712           gROOT->cd();
0713           TNtuple *nt = (TNtuple *)f->Get("ed");
0714           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0715           f->Close();
0716           h1->Draw();
0717           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0718           h1->Write();
0719           fout->Write();
0720           cout << h1->Integral() << " "  <<  hname << endl;
0721           //fout->Write();
0722           fout->Close();
0723           
0724           sprintf(infile, "an8out.root");
0725           char hname [100];
0726           sprintf(hname, "HOan8d");
0727           TH1F *h1 = new TH1F(hname, "HOan8d", 100, 0, 1);
0728           TFile *f = TFile::Open(infile);
0729           gROOT->cd();
0730           TNtuple *nt = (TNtuple *)f->Get("ed");
0731           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0732           f->Close();
0733           h1->Draw();
0734           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0735           h1->Write();
0736           fout->Write();
0737           cout << h1->Integral() << " "  <<  hname << endl;
0738           //fout->Write();
0739           fout->Close();
0740           
0741           sprintf(infile, "an12out.root");
0742           char hname [100];
0743           sprintf(hname, "HOan12d");
0744           TH1F *h1 = new TH1F(hname, "HOan12d", 100, 0, 1);
0745           TFile *f = TFile::Open(infile);
0746           gROOT->cd();
0747           TNtuple *nt = (TNtuple *)f->Get("ed");
0748           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0749           f->Close();
0750           h1->Draw();
0751           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0752           h1->Write();
0753           fout->Write();
0754           cout << h1->Integral() << " "  <<  hname << endl;
0755           //fout->Write();
0756           fout->Close();
0757           
0758           sprintf(infile, "an16out.root");
0759           char hname [100];
0760           sprintf(hname, "HOan16d");
0761           TH1F *h1 = new TH1F(hname, "HOan16d", 100, 0, 1);
0762           TFile *f = TFile::Open(infile);
0763           gROOT->cd();
0764           TNtuple *nt = (TNtuple *)f->Get("ed");
0765           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0766           f->Close();
0767           h1->Draw();
0768           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0769           h1->Write();
0770           fout->Write();
0771           cout << h1->Integral() << " "  <<  hname << endl;
0772           //fout->Write();
0773           fout->Close();
0774           
0775           sprintf(infile, "an32out.root");
0776           char hname [100];
0777           sprintf(hname, "HOan32d");
0778           TH1F *h1 = new TH1F(hname, "HOan32d", 100, 0, 1);
0779           TFile *f = TFile::Open(infile);
0780           gROOT->cd();
0781           TNtuple *nt = (TNtuple *)f->Get("ed");
0782           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0783           f->Close();
0784           h1->Draw();
0785           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0786           h1->Write();
0787           fout->Write();
0788           cout << h1->Integral() << " "  <<  hname << endl;
0789           //fout->Write();
0790           fout->Close();
0791           
0792           sprintf(infile, "an40out.root");
0793           char hname [100];
0794           sprintf(hname, "HOan40d");
0795           TH1F *h1 = new TH1F(hname, "HOan40d", 100, 0, 1);
0796           TFile *f = TFile::Open(infile);
0797           gROOT->cd();
0798           TNtuple *nt = (TNtuple *)f->Get("ed");
0799           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0800           f->Close();
0801           h1->Draw();
0802           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0803           h1->Write();
0804           fout->Write();
0805           cout << h1->Integral() << " "  <<  hname << endl;
0806           //fout->Write();
0807           fout->Close();
0808           
0809           sprintf(infile, "an50out.root");
0810           char hname [100];
0811           sprintf(hname, "HOan50d");
0812           TH1F *h1 = new TH1F(hname, "HOan50d", 100, 0, 1);
0813           TFile *f = TFile::Open(infile);
0814           gROOT->cd();
0815           TNtuple *nt = (TNtuple *)f->Get("ed");
0816           nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
0817           f->Close();
0818           h1->Draw();
0819           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0820           h1->Write();
0821           fout->Write();
0822           cout << h1->Integral() << " "  <<  hname << endl;
0823           //fout->Write();
0824           fout->Close();
0825           
0826           /*    sprintf(infile, "e90out.root");
0827           char hname [100];
0828           sprintf(hname, "e90d");
0829           TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
0830           TFile *f = TFile::Open(infile);
0831           gROOT->cd();
0832           TNtuple *nt = (TNtuple *)f->Get("ed");
0833           nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
0834           f->Close();
0835           h1->Draw();
0836           TFile *fout = TFile::Open("anpercent.root","UPDATE");
0837           h1->Write();
0838           fout->Write();
0839           cout << h1->Integral() << " "  <<  hname << endl;
0840           //fout->Write();
0841           fout->Close();
0842           */
0843 
0844 
0845 
0846 
0847 //      }
0848           //}
0849 //   }
0850 }
0851 
0852 
0853 
0854 
0855 void EdepPercentAnalyzerOH()
0856 {  
0857   TFile *fin = TFile::Open("anpercent.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, "HOan1d");
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, "HOan2d");
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, "HOan4d");
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, "HOan8d");
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, "HOan12d");
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, "HOan16d");
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, "HOan40d");
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, "an50d");
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 
1031 
1032 
1033 
1034 
1035 
1036 
1037 
1038 
1039 void EdepSmall(const char *calo="HOan")
1040 {
1041    int pz[9] = {1,2,4,8,12,16,32,40,50};
1042    double x[9];
1043    double y[9];
1044    double xer[9] = {0};
1045    double yer[9];
1046    char hname[100];
1047   TFile *fin = TFile::Open("anpercent.root");
1048   gROOT->cd();
1049    for (int i=0; i<9; i++)
1050      {
1051        x[i] = pz[i];
1052        sprintf(hname,"%s%dd",calo,pz[i]);
1053 TH1 *h1 = (TH1F *) fin->Get(hname);
1054      y[i] = h1->GetMean(1);
1055    yer[i] = h1->GetRMS(1);
1056      }
1057    gr = new TGraphErrors(9,x,y,xer,yer);
1058    gr->Draw("ALP");
1059    gr->SetMarkerStyle(20);
1060    gr->SetMarkerColor(2);
1061    fin->Close();
1062 }
1063