74 JMultipleFileScanner<Evt> inputFile;
84 JParser<> zap(
"Program to histogram event-by-event data of shower light for making PDFs.");
94 if (zap.read(argc, argv) != 0)
97 catch(
const exception &error) {
98 FATAL(error.what() << endl);
104 sort(particles.begin(), particles.end());
105 string prefix_t =
"";
106 for(vector<int>::iterator ptype = particles.begin(); ptype != particles.end(); ptype++){
107 prefix_t +=
to_string((
long long int)*ptype) +
"_";
109 prefix_t.erase(prefix_t.size() - 1);
110 string::size_type pos_1 =
outputFile.find(
'%');
123 NOTICE(
"Apply detector offset " << center << endl);
133 const JDispersion dispersion(P_atm);
135 const double ng[] = { dispersion.getIndexOfRefractionGroup(wmax),
136 dispersion.getIndexOfRefractionGroup(wmin) };
141 JMAPLIST<JHistogramMap_t,
145 JHistogramGridMap_t>::maplist> JMultiHistogram_t;
147 typedef JPDFTransformer<5, abscissa_type> JFunction5DTransformer_t;
149 JMultiHistogram_t h0;
150 JMultiHistogram_t h1;
156 JQuadrature qeant(-1.0, 1.0, 30, JGeanx(1.00, -2.2));
158 for (JQuadrature::const_iterator i = qeant.begin(); i != qeant.end(); ++i) {
167 const double E_b[] = {0.01, 0.2, 0.4, 0.6, 0.8, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 25.0, 30.0, 40.0, 55.0, 70.0, 85.0, 100.0};
169 const double R[] = {0.0, 1.0, 2.5, 5.0, 7.5, 10.0, 12.5, 15.0, 17.5, 20.0, 25.0, 30.0, 35.0, 40.0, 50.0, 65.0, 80.0};
170 const double Dmax_m = R[
sizeof(R)/
sizeof(R[0]) - 1];
172 for (
int iE = 0; iE !=
sizeof(E_b)/
sizeof(E_b[0]); ++iE) {
174 const double E_m = E_b[iE];
176 for (
int i = 0; i !=
sizeof(R)/
sizeof(R[0]); ++i) {
178 const double R_m = R[i];
182 const double cd = *c;
184 const double grid = 10.0 + 0.0 * R_m/100.0;
185 const double alpha = 2.0 * sqrt(1.0 - cos(grid *
PI / 180.0));
187 const int number_of_theta_points = (max(2, (
int) (180.0/(1.4 * grid))));
188 const double theta_step =
PI / (number_of_theta_points + 1);
190 for (
double theta = -0.5*theta_step; theta <
PI + theta_step; theta += theta_step) {
191 const int number_of_phi_points = (max(2, (
int) (
PI * sin(theta) / alpha)));
192 const double phi_step =
PI / (number_of_phi_points + 1);
194 for (
double phi = -0.5*phi_step; phi <
PI + phi_step; phi += phi_step) {
196 for (JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **histogram = buffer; *histogram != NULL; ++histogram) {
197 (**histogram)[E_m][R_m][cd][theta][phi];
205 double buffer[] = {-15.0,-10.0,-7.5,-5,-4,-3,-2,-1.5,-1.0,-0.5,-0.1, 0.0,0.1, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 7.5, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 85.0, 100.0 };
206 for (JMultiHistogram_t::super_iterator
207 i1 = h1.super_begin(); i1 != h1.super_end(); ++i1) {
208 for (
int j = 0; j !=
sizeof(buffer)/
sizeof(buffer[0]); ++j) {
209 i1.getValue()[buffer[j]];
214 long long int h0_fillcount = 0;
215 long long int h1_fillcount = 0;
217 while (inputFile.hasNext()) {
222 const Evt*
event = inputFile.next();
223 const vector<Trk>* mc_tracks = &(
event->mc_trks);
233 for (vector<Trk>::const_iterator i = mc_tracks->begin(); i != mc_tracks->end(); ++i) {
234 hit_remap.push_back(i->id);
238 double t0 = (*mc_tracks)[1].t;
240 for (vector<Hit>::const_iterator hit =
event->mc_hits.begin(); hit !=
event->mc_hits.end(); ++hit) {
244 if(hit->origin >= (
int)(*mc_tracks).size()){
245 std::out_of_range err(
"Hit origin not in tracklist. Avoided segfault");
249 Int_t corr_origin = hit_remap[hit->origin];
250 Trk curr_track = (*mc_tracks)[corr_origin];
253 JAxis3D axis = pmtRouter.getPMT(hit->pmt_id);
256 const double E = curr_track.E;
259 const double cd = axis.
getZ()/D_m;
260 const double theta = axis.
getTheta();
261 const double phi = fabs(axis.
getPhi());
262 const double dt =
getTime(*hit) - t1;
263 const double npe =
getNPE(*hit);
266 h1.fill(E, D_m, cd, theta, phi, dt, npe);
270 catch(
const exception& error) {
271 std::cout <<
"Fatal error for event: " << inputFile.getCounter() << std::endl;
272 FATAL(error.what() << endl);
277 for (vector<Trk>::const_iterator tr =
event->mc_trks.begin() + 1; tr !=
event->mc_trks.end(); ++tr) {
279 if(find(particles.begin(), particles.end(), tr->type) == particles.end()){
289 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
299 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
311 if(h1_fillcount > h0_fillcount){
312 std::cout <<
"WARNING: recorded hits in normalization histogram that were not recorded in normalization histogram. This should not happen." << std::endl;
313 std::cout <<
"h1_fillcount: " << h1_fillcount <<
", h0_fillcount: " << h0_fillcount << std::endl;
318 for (JMultiHistogram_t::super_iterator i = h0.super_begin(); i != h0.super_end(); ++i) {
319 integral+=i.getValue().getIntegral();
321 DEBUG(
"Integral:\t" << integral << endl);
329 for (
const JMultiHistogram_t* buffer[] = { &h0, &h1, NULL }, **i = buffer; *i != NULL; ++i) {
334 NOTICE(
"JHistHDE done. " << endl);
Router for direct addressing of PMT data in detector data structure.
Utility class to parse command line options.
Data structure for direction in three dimensions.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
double getMinimalWavelength()
Get minimal wavelength for PDF evaluations.
double getTime(const Hit &hit)
Get true time of hit.
double getPhi() const
Get phi angle.
void transform(const JAxis3D &axis)
Transform axis to reference frame of given axis.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
double getMaximalWavelength()
Get maximal wavelength for PDF evaluations.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getTheta() const
Get theta angle.
double getAmbientPressure()
Get ambient pressure.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
const JPosition3D & getPosition() const
Get position.
double getLength() const
Get length.
vector< Int_t > getHitRemapping(const vector< Trk > *tracklist)
std::string to_string(const T &value)
Convert value to string.
JDirection3D getDirection(const Vec &v)
Get direction.
double getNPE(const Hit &hit)
Get true charge of hit.
Data structure for position in three dimensions.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
double getZ() const
Get z position.
#define DEBUG(A)
Message macros.
JPosition3D getPosition(const Vec &v)
Get position.
double getAngularAcceptance(const double x)
Angular acceptence of PMT.