part of retouched *.dat file (and its structure)
6 4 2 4 390.0 -280.0 -4800. 0 0 0 0 0 - 0 379.9 -279.8 -4812. 3.9609E-02 1 0 0 0 382.2 -334.4 -4795. 0.2326 1 0 0 0 398.0 -268.9 -4793. 6.6264E-02 0 0 0 0 395.7 -271.3 -4786. 0.1862 0 0 0 0 392.0 -276.9 -4794. 0.1738 0 0 0 0 390.3 -278.1 -4792. 1.042 0 0 0 0 404.9 -294.2 -4850. 0.1131 0 0 0 0 0 0 0 0 0 0 0 0 0.2722
6 4 2 4 398.4 -273.8 -4787. 0 0 0 0 0 - 0 379.9 -279.8 -4812. 3.9609E-02 0 0 0 0 382.2 -334.4 -4795. 0.2326 0 0 0 0 398.0 -268.9 -4793. 6.6264E-02 1 0 0 0 395.7 -271.3 -4786. 0.1862 1 0 0 0 392.0 -276.9 -4794. 0.1738 0 0 0 0 390.3 -278.1 -4792. 1.042 0 0 0 0 404.9 -294.2 -4850. 0.1131 0 0 0 0 0 0 0 0 0 0 0 0 0.2525
6 6 2 3 390.0 -280.0 -4800. 0 0 0 0 0 - 0 392.0 -276.9 -4794. 0.1738 1 0 0 0 390.3 -278.1 -4792. 1.042 1 0 0 0 404.9 -294.2 -4850. 0.1131 0 0 0 0 0 0 0 0 0 0 0 0 382.1 -276.6 -4799. 0.5690 0 0 0 0 383.3 -278.9 -4803. 0.1044 0 0 0 0 428.1 -268.0 -4765. 0.1155 0 0 0 0 369.5 -280.6 -4783. 6.8702E-02 0 0 0 0 1.215
6 6 2 3 390.0 -280.0 -4800. 0 0 0 0 0 - 0 392.0 -276.9 -4794. 0.1738 0 0 0 0 390.3 -278.1 -4792. 1.042 0 0 0 0 404.9 -294.2 -4850. 0.1131 1 0 0 0 0 0 0 0 1 0 0 0 382.1 -276.6 -4799. 0.5690 0 0 0 0 383.3 -278.9 -4803. 0.1044 0 0 0 0 428.1 -268.0 -4765. 0.1155 0 0 0 0 369.5 -280.6 -4783. 6.8702E-02 0 0 0 0 0.1730
6 10 4 8 390.0 -280.0 -4800. 0 0 0 0 0 - 0 382.1 -276.6 -4799. 0.5690 1 0 0 0 383.3 -278.9 -4803. 0.1044 1 0 0 0 428.1 -268.0 -4765. 0.1155 0 0 0 0 369.5 -280.6 -4783. 6.8702E-02 0 0 0 0 390.2 -280.5 -4799. 5.7801E-02 0 0 0 0 413.3 -272.8 -4757. 0.5043 0 0 0 0 371.8 -280.9 -4774. 9.9699E-02 0 0 0 0 390.7 -281.2 -4796. 0.2919 0 0 0 0 0.6734
6 10 4 8 390.0 -280.0 -4800. 0 0 0 0 0 - 0 382.1 -276.6 -4799. 0.5690 0 0 0 0 383.3 -278.9 -4803. 0.1044 0 0 0 0 428.1 -268.0 -4765. 0.1155 1 0 0 0 369.5 -280.6 -4783. 6.8702E-02 1 0 0 0 390.2 -280.5 -4799. 5.7801E-02 0 0 0 0 413.3 -272.8 -4757. 0.5043 0 0 0 0 371.8 -280.9 -4774. 9.9699E-02 0 0 0 0 390.7 -281.2 -4796. 0.2919 0 0 0 0 0.1842
6 10 4 8 390.0 -280.0 -4800. 0 0 0 0 0 - 0 382.1 -276.6 -4799. 0.5690 0 0 0 0 383.3 -278.9 -4803. 0.1044 0 0 0 0 428.1 -268.0 -4765. 0.1155 0 0 0 0 369.5 -280.6 -4783. 6.8702E-02 0 0 0 0 390.2 -280.5 -4799. 5.7801E-02 1 0 0 0 413.3 -272.8 -4757. 0.5043 1 0 0 0 371.8 -280.9 -4774. 9.9699E-02 0 0 0 0 390.7 -281.2 -4796. 0.2919 0 0 0 0 0.5621
6 10 4 8 390.0 -280.0 -4800. 0 0 0 0 0 - 0 382.1 -276.6 -4799. 0.5690 0 0 0 0 383.3 -278.9 -4803. 0.1044 0 0 0 0 428.1 -268.0 -4765. 0.1155 0 0 0 0 369.5 -280.6 -4783. 6.8702E-02 0 0 0 0 390.2 -280.5 -4799. 5.7801E-02 0 0 0 0 413.3 -272.8 -4757. 0.5043 0 0 0 0 371.8 -280.9 -4774. 9.9699E-02 1 0 0 0 390.7 -281.2 -4796. 0.2919 1 0 0 0 0.3916
7 1 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 349.8 -244.4 -4822. 0.2308 1 0 0 0 372.9 -284.0 -4796. 7.1410E-02 1 0 0 0 388.5 -272.9 -4797. 0.1569 0 0 0 0 389.7 -279.1 -4796. 0.1372 0 0 0 0 439.8 -285.0 -4813. 0.1098 0 0 0 0 388.5 -274.0 -4800. 6.2875E-02 0 0 0 0 399.5 -267.8 -4737. 0.1475 0 0 0 0 0 0 0 0 0 0 0 0 0.3022
7 3 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 388.5 -272.9 -4797. 0.1569 1 0 0 0 389.7 -279.1 -4796. 0.1372 1 0 0 0 439.8 -285.0 -4813. 0.1098 0 0 0 0 388.5 -274.0 -4800. 6.2875E-02 0 0 0 0 399.5 -267.8 -4737. 0.1475 0 0 0 0 0 0 0 0 0 0 0 0 383.4 -275.9 -4797. 0.2291 0 0 0 0 381.6 -279.6 -4800. 8.3463E-02 0 0 0 0 0.2941
7 6 3 5 390.0 -280.0 -4800. 0 0 0 0 0 - 0 439.8 -285.0 -4813. 0.1098 1 0 0 0 388.5 -274.0 -4800. 6.2875E-02 1 0 0 0 399.5 -267.8 -4737. 0.1475 0 0 0 0 0 0 0 0 0 0 0 0 383.4 -275.9 -4797. 0.2291 0 0 0 0 381.6 -279.6 -4800. 8.3463E-02 0 0 0 0 387.5 -290.1 -4797. 7.1324E-02 0 0 0 0 396.4 -294.8 -4772. 0.3412 0 0 0 0 0.1727
7 6 3 5 400.8 -265.7 -4737. 0 0 0 0 0 - 0 439.8 -285.0 -4813. 0.1098 0 0 0 0 388.5 -274.0 -4800. 6.2875E-02 0 0 0 0 399.5 -267.8 -4737. 0.1475 1 0 0 0 0 0 0 0 1 0 0 0 383.4 -275.9 -4797. 0.2291 0 0 0 0 381.6 -279.6 -4800. 8.3463E-02 0 0 0 0 387.5 -290.1 -4797. 7.1324E-02 0 0 0 0 396.4 -294.8 -4772. 0.3412 0 0 0 0 0.1860
7 6 3 5 383.5 -275.8 -4797. 0 0 0 0 0 - 0 439.8 -285.0 -4813. 0.1098 0 0 0 0 388.5 -274.0 -4800. 6.2875E-02 0 0 0 0 399.5 -267.8 -4737. 0.1475 0 0 0 0 0 0 0 0 0 0 0 0 383.4 -275.9 -4797. 0.2291 1 0 0 0 381.6 -279.6 -4800. 8.3463E-02 1 0 0 0 387.5 -290.1 -4797. 7.1324E-02 0 0 0 0 396.4 -294.8 -4772. 0.3412 0 0 0 0 0.3126
7 8 3 6 390.0 -280.0 -4800. 0 0 0 0 0 - 0 387.5 -290.1 -4797. 7.1324E-02 1 0 0 0 396.4 -294.8 -4772. 0.3412 1 0 0 0 389.7 -279.7 -4797. 0.4817 0 0 0 0 380.3 -260.6 -4767. 0.1865 0 0 0 0 399.0 -282.4 -4764. 1.686 0 0 0 0 391.3 -280.8 -4797. 0.1835 0 0 0 0 384.4 -300.4 -4761. 0.1517 0 0 0 0 393.5 -280.5 -4800. 5.7460E-02 0 0 0 0 0.4125
7 8 3 6 390.0 -280.0 -4800. 0 0 0 0 0 - 0 387.5 -290.1 -4797. 7.1324E-02 0 0 0 0 396.4 -294.8 -4772. 0.3412 0 0 0 0 389.7 -279.7 -4797. 0.4817 1 0 0 0 380.3 -260.6 -4767. 0.1865 1 0 0 0 399.0 -282.4 -4764. 1.686 0 0 0 0 391.3 -280.8 -4797. 0.1835 0 0 0 0 384.4 -300.4 -4761. 0.1517 0 0 0 0 393.5 -280.5 -4800. 5.7460E-02 0 0 0 0 0.6682
7 8 3 6 390.0 -280.0 -4800. 0 0 0 0 0 - 0 387.5 -290.1 -4797. 7.1324E-02 0 0 0 0 396.4 -294.8 -4772. 0.3412 0 0 0 0 389.7 -279.7 -4797. 0.4817 0 0 0 0 380.3 -260.6 -4767. 0.1865 0 0 0 0 399.0 -282.4 -4764. 1.686 1 0 0 0 391.3 -280.8 -4797. 0.1835 1 0 0 0 384.4 -300.4 -4761. 0.1517 0 0 0 0 393.5 -280.5 -4800. 5.7460E-02 0 0 0 0 1.870
7 9 2 4 390.0 -280.0 -4800. 0 0 0 0 0 - 0 384.4 -300.4 -4761. 0.1517 1 0 0 0 393.5 -280.5 -4800. 5.7460E-02 1 0 0 0 386.2 -280.6 -4785. 0.2281 0 0 0 0 381.6 -270.3 -4782. 0.1003 0 0 0 0 440.4 -297.1 -4666. 0.4277 0 0 0 0 486.7 -362.9 -4656. 5.9495E-02 0 0 0 0 553.1 -367.5 -4648. 0.1688 0 0 0 0 583.3 -347.3 -4619. 0.1017 0 0 0 0 0.2092
7 9 2 4 387.6 -280.7 -4785. 0 0 0 0 0 - 0 384.4 -300.4 -4761. 0.1517 0 0 0 0 393.5 -280.5 -4800. 5.7460E-02 0 0 0 0 386.2 -280.6 -4785. 0.2281 1 0 0 0 381.6 -270.3 -4782. 0.1003 1 0 0 0 440.4 -297.1 -4666. 0.4277 0 0 0 0 486.7 -362.9 -4656. 5.9495E-02 0 0 0 0 553.1 -367.5 -4648. 0.1688 0 0 0 0 583.3 -347.3 -4619. 0.1017 0 0 0 0 0.3284
7 10 2 4 440.4 -296.2 -4667. 0 0 0 0 0 - 0 440.4 -297.1 -4666. 0.4277 1 0 0 0 486.7 -362.9 -4656. 5.9495E-02 1 0 0 0 553.1 -367.5 -4648. 0.1688 0 0 0 0 583.3 -347.3 -4619. 0.1017 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.4871
7 10 2 4 548.1 -363.2 -4649. 0 0 0 0 0 - 0 440.4 -297.1 -4666. 0.4277 0 0 0 0 486.7 -362.9 -4656. 5.9495E-02 0 0 0 0 553.1 -367.5 -4648. 0.1688 1 0 0 0 583.3 -347.3 -4619. 0.1017 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2705
8 3 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 390.3 -281.3 -4803. 6.5002E-02 1 0 0 0 389.7 -280.7 -4799. 0.1119 1 0 0 0 392.0 -279.7 -4775. 0.4995 0 0 0 0 392.0 -278.4 -4790. 1.053 0 0 0 0 393.4 -279.5 -4799. 0.1837 0 0 0 0 393.0 -279.3 -4796. 0.2579 0 0 0 0 390.9 -271.5 -4774. 0.1609 0 0 0 0 388.4 -278.7 -4774. 1.400 0 0 0 0 0.1769
8 4 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 392.0 -279.7 -4775. 0.4995 1 0 0 0 392.0 -278.4 -4790. 1.053 1 0 0 0 393.4 -279.5 -4799. 0.1837 0 0 0 0 393.0 -279.3 -4796. 0.2579 0 0 0 0 390.9 -271.5 -4774. 0.1609 0 0 0 0 388.4 -278.7 -4774. 1.400 0 0 0 0 443.9 -323.4 -4631. 6.5038E-02 0 0 0 0 448.7 -357.4 -4650. 0.2340 0 0 0 0 1.552
8 7 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 393.4 -279.5 -4799. 0.1837 1 0 0 0 393.0 -279.3 -4796. 0.2579 1 0 0 0 390.9 -271.5 -4774. 0.1609 0 0 0 0 388.4 -278.7 -4774. 1.400 0 0 0 0 443.9 -323.4 -4631. 6.5038E-02 0 0 0 0 448.7 -357.4 -4650. 0.2340 0 0 0 0 414.4 -293.6 -4722. 0.2343 0 0 0 0 395.4 -298.3 -4757. 6.0815E-02 0 0 0 0 0.4416
8 8 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 390.9 -271.5 -4774. 0.1609 1 0 0 0 388.4 -278.7 -4774. 1.400 1 0 0 0 443.9 -323.4 -4631. 6.5038E-02 0 0 0 0 448.7 -357.4 -4650. 0.2340 0 0 0 0 414.4 -293.6 -4722. 0.2343 0 0 0 0 395.4 -298.3 -4757. 6.0815E-02 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.561
8 9 1 2 445.4 -323.5 -4629. 0 0 0 0 0 - 0 443.9 -323.4 -4631. 6.5038E-02 1 0 0 0 448.7 -357.4 -4650. 0.2340 1 0 0 0 414.4 -293.6 -4722. 0.2343 0 0 0 0 395.4 -298.3 -4757. 6.0815E-02 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2991
8 10 1 2 387.3 -280.9 -4752. 0 0 0 0 0 - 0 414.4 -293.6 -4722. 0.2343 1 0 0 0 395.4 -298.3 -4757. 6.0815E-02 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2951
9 1 1 2 390.0 -280.0 -4800. 0 0 0 0 0 - 0 411.9 -253.1 -4793. 3.3065E-02 1 0 0 0 351.8 -264.4 -4799. 0.2152 1 0 0 0 389.0 -279.0 -4797. 0.1031 0 0 0 0 393.0 -276.1 -4778. 0.6230 0 0 0 0 379.2 -288.8 -4782. 0.3773 0 0 0 0 380.5 -293.5 -4772. 9.9582E-02 0 0 0 0 395.0 -264.3 -4701. 0.1756 0 0 0 0 394.4 -252.0 -4694. 8.2975E-02 0 0 0 0 0.2483
code (working) I wrote for “retouched” *.dat file
#include
#include
#include
#include
#include
using namespace std;
void Tokenize(const string& str,
vector& tokens,
const string& delimiters = "\t ")
{
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
string::size_type pos = str.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos)
{
tokens.push_back(str.substr(lastPos, pos - lastPos));
lastPos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastPos);
}
}
int hist2()
{
c1 = new TCanvas(“c1”,"",200,10,700,500);
c1->SetFillColor(10);
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(6);
c1->GetFrame()->SetBorderMode(-1);
c1->Divide(1,3);
TH1D *hist = new TH1D(“hist”,“effective mass”,500,0.0,0.3);
hist->SetFillColor(11);
TH1D *hist1 = new TH1D(“hist”,“cosA”,500,-1.0,1.0);
hist1->SetFillColor(12);
TH1D *hist2 = new TH1D(“hist”,“fotons energy”,500,0.0,3.0);
hist2->SetFillColor(13);
TH1D *hist3 = new TH1D(“hist”,“distance”,500,0.0,3.0);
hist3->SetFillColor(15);
string line;
vector<string> tokens;
ifstream myfile ("mcpizero1.txt");
int i = 0;
string x0;
string y0;
string z0;
string E0,E1,E2,E3,E4,E5,E6,E7,E8,run,event,pi0n,fotn;
string x1;
string y1;
string z1;
string x2;
string y2;
string z2;
string x3;
string y3;
string z3;
string x4;
string y4;
string z4;
string x5;
string y5;
string z5;
string x6;
string y6;
string z6;
string x7;
string y7;
string z7;
string x8;
string y8;
string z8;
if (myfile.is_open())
{
ofstream output;
output.open("out1.txt");
while (! myfile.eof() )
{
getline(myfile,line);
Tokenize(line, tokens);
if(tokens.size() > 0)
{
run = tokens.at(0);
event = tokens.at(1);
fotn = tokens.at(3);
pi0n = tokens.at(2);
x0 = tokens.at(4);
y0 = tokens.at(5);
z0 = tokens.at(6);
E0 = tokens.at(78);
x1 = tokens.at(14);
y1 = tokens.at(15);
z1 = tokens.at(16);
E1 = tokens.at(17);
x2 = tokens.at(22);
y2 = tokens.at(23);
z2 = tokens.at(24);
E2 = tokens.at(25);
x3 = tokens.at(30);
y3 = tokens.at(31);
z3 = tokens.at(32);
E3 = tokens.at(33);
x4 = tokens.at(38);
y4 = tokens.at(39);
z4 = tokens.at(40);
E4 = tokens.at(41);
x5 = tokens.at(46);
y5 = tokens.at(47);
z5 = tokens.at(48);
E5 = tokens.at(49);
x6 = tokens.at(54);
y6 = tokens.at(55);
z6 = tokens.at(56);
E6 = tokens.at(57);
x7 = tokens.at(62);
y7 = tokens.at(63);
z7 = tokens.at(64);
E7 = tokens.at(65);
x8 = tokens.at(70);
y8 = tokens.at(71);
z8 = tokens.at(72);
E8 = tokens.at(73);
output << "\t" << run << "\t" << event << "\t" << pi0n << "\t" << fotn << "\t" << x0 << "\t" << y0 << "\t" << z0 << "\t" << E0 << "\t\t"
<< x1 << "\t" << y1 << "\t" << z1 << "\t" << E1 << "\t\t"
<< x2 << "\t" << y2 << "\t" << z2 << "\t" << E2 << "\t\t"
<< x3 << "\t" << y3 << "\t" << z3 << "\t" << E3 << "\t\t"
<< x4 << "\t" << y4 << "\t" << z4 << "\t" << E4 << "\t\t"
<< x5 << "\t" << y5 << "\t" << z5 << "\t" << E5 << "\t\t"
<< x6 << "\t" << y6 << "\t" << z6 << "\t" << E6 << "\t\t"
<< x7 << "\t" << y7 << "\t" << z7 << "\t" << E7 << "\t\t"
<< x8 << "\t" << y8 << "\t" << z8 << "\t" << E8 <<endl> Fill( M );
hist1->Fill( cosA );
hist2->Fill( Ez );
hist3->Fill( ab );
}
else continue;
c1->cd(1);
hist->Draw();
c1->cd(2);
hist1->Draw();
c1->cd(3);
hist2->Draw();
c1->cd(4);
hist3->Draw();
c1->Update();
TImage *img = TImage::Create();
img->FromPad(c1);
img->WriteImage(“canvas.png”);
tokens.clear();
}
myfile.close();
}
else
{
cout << "File cannot be opened";
}
printf ("case: %d \n", i);
return 0;
}