/* * SR, 22-04-2005 * New version of the program to count the ACTUAL number of * absorbed particles in the collimators by comparison with * the loss locations in the LPI files. * This program uses the new SixTrack output 'all_absorptions.dat', * which contains already the absorption locations (an not the * full list of impacts...). * The program does the analysis for one file (no loops) and hence * it is suitable for performing the analysis on batch! * * ******************* * FindNabs.cpp * Like in the script style, it takes as input seed numbers, * energy, halo type and optics. * The program compares the LPI files and the impacts files * to count the actual number of absorbed particles by * excluding from the impact files the protons that have * touched the aperture somewhere before impacting on * the collimators. * ************************* */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main (int argc, char* argv[]) { if (argc < 5){ cout<<"Some input is missing!"< CountNabs s1 halo EN optics <-"< NPART, NTURN; vector POS; int Nmax = 50000; vector NPART_lost, NTURN_lost; vector POS_lost; vector NPART_real, NTURN_real; vector POS_real; vector NPART_fake, NTURN_fake; vector POS_fake; int count_ir7, count_ir3; double p; ostringstream ost; ifstream in, inn; ofstream out; char c_str[256]; string input, output; // Set input/output names for the impact files ost<<"all_absorptions."< Reading impact file: \""<>Np_t>>Ntu_t>>S_t; if (!in.good()) break; NPART.push_back(Np_t); NTURN.push_back(Ntu_t); POS.push_back(S_t); } in.close(); // cout< Reading loss file: \""<>Np_t>>Ntu_t>>S_t>>x_t>>xp_t>>y_t>>yp_t>>e_t>>Hflag_t>>Nsurv_t; if (!inn.good()) break; NPART_lost[Np_t] = 1; NTURN_lost[Np_t] = Ntu_t; POS_lost[Np_t] = S_t; } inn.close(); // Compare the positions of loss particles with the impact locations for (int i = 0; i < NPART.size(); i++) { Np_t = NPART[i]; if (NPART_lost[Np_t] == 0) { NPART_real.push_back( Np_t ); NTURN_real.push_back( NTURN[i] ); POS_real.push_back( POS[i] ); } else { if ( NTURN[i] <= NTURN_lost[Np_t] && POS[i] < POS_lost[Np_t] ) { NPART_real.push_back( Np_t ); NTURN_real.push_back( NTURN[i] ); POS_real.push_back( POS[i] ); } else { NPART_fake.push_back( Np_t ); NTURN_fake.push_back( NTURN[i] ); POS_fake.push_back( POS[i] ); } } } cout<<"Number of particles touching the aperture before being lost " <<"in a collimator: "< 6395.8168 && p < 6933.6248 ) count_ir3++; else if ( p > 19725.2584 && p < 20263.0664) count_ir7++; } cout<<"*******************************************************"<