Skip to content
Snippets Groups Projects
Commit edaeef54 authored by Kosuke Kinoshita's avatar Kosuke Kinoshita
Browse files

solve conflict

parents f985e37e b0c3fce2
Branches kinoshita
No related tags found
No related merge requests found
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <fstream> #include <fstream>
...@@ -166,10 +165,14 @@ class EventList { ...@@ -166,10 +165,14 @@ class EventList {
f_detectorpos = pos; f_detectorpos = pos;
} }
int ReadFile(const string filename); int ReadFile(const string filename);
<<<<<<< HEAD
int WriteResults(const string filename, bool fileseparation, int event_limit, bool verbosity); int WriteResults(const string filename, bool fileseparation, int event_limit, bool verbosity);
bool CheckParticleSeparation(int nparticle, vector<vector<double>> pos_Tower);
=======
>>>>>>> kinoshita
int ApplyEventSelection_AnyHit(); int ApplyEventSelection_AnyHit();
int ApplyEventSelection_K0Short(); int ApplyEventSelection_K0Short();
private: private:
int cut_beampipe(double x, double y) { int cut_beampipe(double x, double y) {
double r2; double r2;
...@@ -406,11 +409,11 @@ int EventList::ApplyEventSelection_AnyHit() { ...@@ -406,11 +409,11 @@ int EventList::ApplyEventSelection_AnyHit() {
nhit++; nhit++;
} }
} }
if (nhit == 0) { if (nhit == 0) {
f_events[iev]->Clear(); f_events[iev]->Clear();
continue; continue;
} }
nev_sel++; nev_sel++;
} }
cout << "EVENT SELECTION ----------------------------------\n" cout << "EVENT SELECTION ----------------------------------\n"
...@@ -418,31 +421,86 @@ int EventList::ApplyEventSelection_AnyHit() { ...@@ -418,31 +421,86 @@ int EventList::ApplyEventSelection_AnyHit() {
<< "Number of selected events = " << nev_sel << endl; << "Number of selected events = " << nev_sel << endl;
return 0; return 0;
} }
// 25,Apr,2024 added member function "K0ShortSelection" by Kosuke Kinoshita. // 21,Jun,2024 member function "5mmApartSelection" is added by Kosuke Kinoshita.
// This function select event where the x (or y) in the calorimeter coordinates is
// more distant than the variable "dist_thr".
bool EventList::CheckParticleSeparation(int nparticle, vector<vector<double>> pos_Tower){
bool flag_x = true;
bool flag_y = true;
int count_x = 0;
int count_y = 0;
int count_ip = 0;
double dist_thr = 0.3;
for (int ip = 0; ip < nparticle; ip++){
if(pos_Tower[ip][0] > -1)count_ip++;
}
if (count_ip == 1 || count_ip == 0) {
return true;
} else{
int ncomb = count_ip * (count_ip - 1)/2; // Number of combination of each particle
// prepare the incident position of each particle on TS or TL.
for (int ip = 0; ip < nparticle; ip++){
if (flag_x == false || flag_y == false) break;
if(pos_Tower.at(ip).at(0) < 0)continue;
for (int jp = ip + 1; jp < nparticle; jp++){
if(pos_Tower.at(jp).at(0) < 0)continue;
double x1 = pos_Tower.at(ip).at(1);
double y1 = pos_Tower.at(ip).at(2);
double x2 = pos_Tower.at(jp).at(1);
double y2 = pos_Tower.at(jp).at(2);
double dist_x = abs(x2 - x1);
double dist_y = abs(y2 - y1);
if (dist_x >= dist_thr) count_x++;
else flag_x = false;
if (dist_y >= dist_thr) count_y++;
else flag_y = false;
if (flag_x == false && flag_y == false) break;
}// jp loop
}// ip loop
if (count_x == ncomb || count_y == ncomb) return true;
else return false;
}
}
// 25,Apr,2024 member function "K0ShortSelection" is added by Kosuke Kinoshita.
// use with the pure K0s MC. // use with the pure K0s MC.
int EventList::ApplyEventSelection_K0Short() { int EventList::ApplyEventSelection_K0Short() {
const double distance = const double distance =
14050. - 13980; // distance from TAN to Detector in cm. 14050. - 13980.; // distance from TAN to Detector in cm.
const double sqrt2 = sqrt(2.); const double sqrt2 = sqrt(2.);
const double margin = 0.1; const double margin = 0.1;
// bool is_overlap = false; // bool is_overlap = false;
int nev = 0; int nev = 0;
int nev_sel = 0; int nev_sel = 0;
double initvalue = -10000.0;
for (int iev = 0; iev < f_nevents; iev++) { for (int iev = 0; iev < f_nevents; iev++) {
nev++; nev++;
vector<vector<double> > pos_vec;
int n_cols = 3;
vector<vector<double>> pos_TS(f_events[iev]->fNparticle, vector<double>(n_cols, initvalue));
vector<vector<double>> pos_TL(f_events[iev]->fNparticle, vector<double>(n_cols, initvalue));
//vector<vector<double>> pos_TS(f_events[iev]->fNparticle, vector<double>(2, initvalue));
//vector<vector<double>> pos_TL(f_events[iev]->fNparticle, vector<double>(2, initvalue));
int nhit = 0; int nhit = 0;
for (int ip = 0; ip < f_events[iev]->fNparticle; ip++) { for (int ip = 0; ip < f_events[iev]->fNparticle; ip++) {
double x, y; // pos on the LHCf plain double x, y; // pos on the LHCf plain
double tmpx, tmpy, x2, y2; double tmpx, tmpy, x2, y2;
if (f_events[iev]->fParticleList[ip].pcode == 1 && // event selection if (f_events[iev]->fParticleList[ip].pcode == 1 && // event selection
f_events[iev]->fParticleList[ip].psubcode == 2 && f_events[iev]->fParticleList[ip].psubcode == 2 &&
f_events[iev]->fParticleList[ip].ke > 100) { f_events[iev]->fParticleList[ip].ke > 100) {
x = f_events[iev]->fParticleList[ip].x + x = f_events[iev]->fParticleList[ip].x +
distance * f_events[iev]->fParticleList[ip].wx; distance * f_events[iev]->fParticleList[ip].wx;
y = f_events[iev]->fParticleList[ip].y + y = f_events[iev]->fParticleList[ip].y +
...@@ -451,15 +509,18 @@ int EventList::ApplyEventSelection_K0Short() { ...@@ -451,15 +509,18 @@ int EventList::ApplyEventSelection_K0Short() {
// correction of detector position in y // correction of detector position in y
y -= f_detectorpos; y -= f_detectorpos;
// Arm1 // Arm1
// Arm1
if (f_detector == 1) { if (f_detector == 1) {
// check hit in TS // check hit in TS
tmpx = x / sqrt2 - y / sqrt2; tmpx = x / sqrt2 - y / sqrt2;
tmpy = x / sqrt2 + y / sqrt2; tmpy = x / sqrt2 + y / sqrt2;
if (fabs(tmpx) < 1.0 + margin && fabs(tmpy) < 1.0 + margin) nhit++; if (fabs(tmpx) < 1.0 + margin && fabs(tmpy) < 1.0 + margin) {
nhit++;
pos_TS.at(ip).at(0) = (double)ip;
pos_TS.at(ip).at(1) = tmpx;
pos_TS.at(ip).at(2) = tmpx;
}
// check hit in TL // check hit in TL
x2 = x; x2 = x;
...@@ -467,31 +528,52 @@ int EventList::ApplyEventSelection_K0Short() { ...@@ -467,31 +528,52 @@ int EventList::ApplyEventSelection_K0Short() {
tmpx = x2 / sqrt2 - y2 / sqrt2; tmpx = x2 / sqrt2 - y2 / sqrt2;
tmpy = x2 / sqrt2 + y2 / sqrt2; tmpy = x2 / sqrt2 + y2 / sqrt2;
if (fabs(tmpx) < 2.0 + margin && fabs(tmpy) < 2.0 + margin) nhit++; if (fabs(tmpx) < 2.0 + margin && fabs(tmpy) < 2.0 + margin) {
nhit++;
pos_TL.at(ip).at(0) = (double)ip;
pos_TL.at(ip).at(1) = tmpx;
pos_TL.at(ip).at(2) = tmpy;
}
} }
// Arm2 (Work only for the upgraded detector. > 2015) // Arm2 (Work only for the upgraded detector. > 2015)
else if (f_detector == 2) { else if (f_detector == 2) {
// check hit in TS // check hit in TS
tmpx = x + 0.80; tmpx = x + 0.80;
tmpy = y + 1.25; tmpy = y + 1.25;
if ((tmpx > 0.00 - margin && tmpx < 2.50 + margin) && if ((tmpx > 0.00 - margin && tmpx < 2.50 + margin) &&
(tmpy > 0.00 - margin && tmpy < 2.50 + margin)) (tmpy > 0.00 - margin && tmpy < 2.50 + margin)) {
nhit++; nhit++;
pos_TS.at(ip).at(0) = (double)ip;
pos_TS.at(ip).at(1) = tmpx;
pos_TS.at(ip).at(2) = tmpx;
}
// check hit in TL // check hit in TL
tmpx = x + 0.80 + 0.18 + 3.20; tmpx = x + 0.80 + 0.18 + 3.20;
tmpy = y - 1.25 - 0.18; tmpy = y - 1.25 - 0.18;
if ((tmpx > 0.00 - margin && tmpx < 3.20 + margin) && if ((tmpx > 0.00 - margin && tmpx < 3.20 + margin) &&
(tmpy > 0.00 - margin && tmpy < 3.20 + margin)) (tmpy > 0.00 - margin && tmpy < 3.20 + margin)) {
nhit++; nhit++;
pos_TS.at(ip).at(0) = (double)ip;
pos_TS.at(ip).at(1) = tmpx;
pos_TS.at(ip).at(2) = tmpx;
}
} }
} }
if (nhit != 4) {
f_events[iev]->Clear();
continue;
}
} }
if (nhit != 4) {
f_events[iev]->Clear();
continue;
}
bool flag_TS = CheckParticleSeparation(f_events[iev]->fNparticle, pos_TS);
bool flag_TL = CheckParticleSeparation(f_events[iev]->fNparticle, pos_TL);
if (flag_TS == false || flag_TL == false){
f_events[iev]->Clear();
continue;
}
nev_sel++; nev_sel++;
} }
cout << "K0s EVENT SELECTION ----------------------------------\n" cout << "K0s EVENT SELECTION ----------------------------------\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment