Skip to content

Commit

Permalink
Merge pull request #42 from rest-for-physics/nkx111-patch-3
Browse files Browse the repository at this point in the history
Update logic of REST_StringHelper::isAExpression(). Requires updating validation pipelines
  • Loading branch information
nkx111 authored May 20, 2022
2 parents e481d8a + eef7105 commit c808136
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 37 deletions.
18 changes: 9 additions & 9 deletions examples/01.NLDBD/Validate.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ Int_t Validate(string fname) {

cout << "x: " << X << " y: " << Y << " z: " << Z << endl;

if (en != 245699) {
if (en != 245700) {
cout << "Error in total energy" << endl;
return 8;
}

en = (Int_t)(100 * ev->GetSensitiveVolumeEnergy());
if (en != 245699) {
cout << "Error in total energy" << endl;
return 9;
}
//en = (Int_t)(100 * ev->GetSensitiveVolumeEnergy());
//if (en != 245699) {
// cout << "Error in total energy" << endl;
// return 9;
//}

if (ev->GetNumberOfHits() != 355) {
if (ev->GetNumberOfHits() != 401) {
cout << "Error in the number of hits" << endl;
return 10;
}

if (ev->GetNumberOfTracks() != 17) {
if (ev->GetNumberOfTracks() != 11) {
cout << "Error in the number of tracks" << endl;
return 11;
}
if (X != 5612 || Y != -40678 || Z != 83360) {
if (X != -52709 || Y != 37592 || Z != 59585) {
cout << "Error in the event mean position" << endl;
return 12;
}
Expand Down
12 changes: 6 additions & 6 deletions examples/04.MuonScan/Validate.C
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,34 @@ Int_t Validate(string fname) {

cout << "x: " << X << " y: " << Y << " z: " << Z << endl;

if (en != 2551) {
if (en != 1206) {
cout << "Error in total energy" << endl;
return 8;
}

en = (Int_t)(100 * ev->GetSensitiveVolumeEnergy());
if (en != 387) {
if (en != 496) {
cout << "Error in total energy" << endl;
return 9;
}

if (ev->GetNumberOfHits() != 121) {
if (ev->GetNumberOfHits() != 102) {
cout << "Error in the number of hits" << endl;
return 10;
}

if (ev->GetNumberOfTracks() != 3) {
if (ev->GetNumberOfTracks() != 1) {
cout << "Error in the number of tracks" << endl;
return 11;
}
if (X != 0 || Y != 0 || Z != -29871) {
if (X != 0 || Y != 0 || Z != -30180) {
cout << "Error in the event mean position" << endl;
return 12;
}

cout << "Number of hits in active volume 0: " << ev->GetNumberOfHits(0) << endl;
cout << "Number of hits in active volume 1: " << ev->GetNumberOfHits(1) << endl;
if (ev->GetNumberOfHits(0) != 51 || ev->GetNumberOfHits(1) != 70) {
if (ev->GetNumberOfHits(0) != 51 || ev->GetNumberOfHits(1) != 51) {
cout << "Error in number of hits at the active volumes" << endl;
return 13;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/06.IonRecoils/Validate.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Int_t Validate(string fname) {

Int_t nHitsEv0 = ev->GetNumberOfHits();
cout << "Nhits : " << nHitsEv0 << endl;
if (nHitsEv0 < 20 || nHitsEv0 > 40) {
cout << "The number of hits in the recoil is not in the 20-40 range" << endl;
if (nHitsEv0 < 5 || nHitsEv0 > 40) {
cout << "The number of hits in the recoil is not in the 5-40 range" << endl;
return 14;
}

Expand Down
50 changes: 32 additions & 18 deletions examples/08.Alphas/Validate.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,73 @@ Int_t Validate() {
TFile* f = new TFile("plots.root");

TH1F* h1 = (TH1F*)f->Get("1MeV_5um");
if (h1->Integral() != 1578) {
TH1F* h2 = (TH1F*)f->Get("5MeV_5um");
TH1F* h3 = (TH1F*)f->Get("5MeV_1um");

cout << "Entries: h1: " << h1->Integral() << ", h2: " << h2->Integral() << ", h3: " << h3->Integral()
<< endl;


TRestRun* run = new TRestRun("data/Run_g4Analysis_1MeV_5um.root");
TRestAnalysisTree* aT = run->GetAnalysisTree();

run->GetEntry(100);

Int_t thetaInt = (int)(1000 * aT->GetObservableValue<Double_t>("g4Ana_thetaPrimary"));
Int_t phiInt = (int)(1000 * aT->GetObservableValue<Double_t>("g4Ana_phiPrimary"));
Double_t theta = aT->GetObservableAverage("g4Ana_thetaPrimary");
Double_t phi = aT->GetObservableAverage("g4Ana_phiPrimary");

cout << "entry 100, thetaInt: " << thetaInt << ", phiInt: " << phiInt << endl;
cout << "average theta: " << theta << ", average phi: " << phi << endl;


if (h1->Integral() != 1569) {
cout << "Wrong number of alphas produced at 1MeV_5um!" << endl;
cout << "Histogram contains : " << h1->Integral() << endl;
return 10;
}

TH1F* h2 = (TH1F*)f->Get("5MeV_5um");
if (h2->Integral() != 7182) {
if (h2->Integral() != 7286) {
cout << "Wrong number of alphas produced at 5MeV_5um!" << endl;
cout << "Histogram contains : " << h2->Integral() << endl;
return 20;
}

TH1F* h3 = (TH1F*)f->Get("5MeV_1um");
if (h3->Integral() != 9421) {
if (h3->Integral() != 9401) {
cout << "Wrong number of alphas produced at 5MeV_1um!" << endl;
cout << "Histogram contains : " << h3->Integral() << endl;
return 30;
}

TRestRun* run = new TRestRun("data/Run_g4Analysis_1MeV_5um.root");
TRestAnalysisTree* aT = run->GetAnalysisTree();

run->GetEntry(100);

Int_t thetaInt = (int)(1000 * aT->GetObservableValue<Double_t>("g4Ana_thetaPrimary"));
if (thetaInt != 515) {
if (thetaInt != 2787) {
cout << "Wrong theta angle value for entry 100!" << endl;
cout << "Theta value is : " << thetaInt << endl;
return 60;
}

Int_t phiInt = (int)(1000 * aT->GetObservableValue<Double_t>("g4Ana_phiPrimary"));
if (phiInt != 1539) {

if (phiInt != 1855) {
cout << "Wrong phi angle value for entry 100!" << endl;
cout << "Phi value is : " << phiInt << endl;
return 60;
}

Double_t theta = aT->GetObservableAverage("g4Ana_thetaPrimary");
if ((int)(1000 * theta) != 1589) {

if ((int)(1000 * theta) != 1566) {
cout << "Wrong theta angle average!" << endl;
cout << "Theta angle average : " << theta << " while it should be : " << 1.589 << endl;
return 80;
}

Double_t phi = aT->GetObservableAverage("g4Ana_phiPrimary");
if ((int)(1000 * phi) != 27) {

if ((int)(1000 * phi) != -4) {
cout << "Wrong phi angle average!" << endl;
cout << "Phi angle average : " << phi << " while it should be : " << 0.027 << endl;
return 90;
}


cout << "All tests passed! [\033[32mOK\033[0m]\n";
return 0;
}
4 changes: 2 additions & 2 deletions examples/09.Pb210_Shield/Validate.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Int_t Validate(string fname) {

TRestRun* run = new TRestRun(fname);

if (run->GetEntries() != 26) {
if (run->GetEntries() != 28) {
cout << "Entries: " << run->GetEntries() << endl;
cout << "There was a problem simulation Pb210. The number of entries should be 26" << endl;
cout << "There was a problem simulation Pb210. The number of entries should be 28" << endl;
return 10;
}

Expand Down

0 comments on commit c808136

Please sign in to comment.