-
Notifications
You must be signed in to change notification settings - Fork 0
/
dircfit.cpp
5078 lines (4467 loc) · 147 KB
/
dircfit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "include/dirc_optical_sim.h"
#include "include/dirc_threesegbox_sim.h"
#include "include/dirc_point.h"
#include "include/dirc_probability_spread.h"
#include "include/dirc_probability_separation.h"
#include "include/dirc_spread_radius.h"
#include "include/dirc_spread_relative.h"
#include "include/dirc_spread_linear_soft.h"
#include "include/dirc_spread_gaussian.h"
#include "include/dirc_digitizer.h"
#include "include/dirc_rect_digitizer.h"
#include "include/dirc_babar_digitizer.h"
#include "include/dirc_babar_sim.h"
#include "include/dirc_progressive_separation.h"
#include "include/dirc_gluex_lut_enum.h"
#include "include/dirc_lut_enum.h"
#include "include/dirc_lut.h"
#include <TFile.h>
#include <TTree.h>
#include <TH3.h>
#include <TH2.h>
#include <TH1.h>
#include <TF1.h>
#include <TRandom3.h>
#include <TMinuit.h>
//#define USE_BABAR_BOX
DircBaseSim* global_calib_model;
DircDigitizer* global_digitizer;
float global_particle_theta;
float global_particle_phi;
float global_particle_x;
float global_particle_y;
float global_particle_t;
float global_particle_energy;
float global_particle_flight_distance;
float global_refrac_index;
float global_ckov_unc;
float global_tracking_unc;
int global_n_sim_phots;
std::vector<dirc_point> global_pion_line;
std::vector<dirc_point> global_kaon_line;
std::vector<std::vector<dirc_point> > global_pion_hits;
std::vector<std::vector<dirc_point> > global_kaon_hits;
void init_global_data()
{
int num_line_points = 5000;
int num_particle_hits = 20000;
float kmass = .4937;
float pimass = .1396;
global_pion_line.clear();
global_kaon_line.clear();
global_pion_hits.clear();
global_kaon_hits.clear();
DircBaseSim* dirc_model = global_calib_model;
DircDigitizer* digitizer = global_digitizer;
float particle_theta = global_particle_theta;
float particle_phi = global_particle_phi;
float particle_x = global_particle_x;
float particle_y = global_particle_y;
float energy = global_particle_energy;
float particle_flight_distance = global_particle_flight_distance;
// float particle_t = global_particle_t;
int n_sim_phots = global_n_sim_phots;
float tracking_unc = global_tracking_unc;
float ckov_unc = global_ckov_unc;
float pion_old_angle = -1;
float kaon_old_angle = -1;
//` printf("%12.04f %12.04f %12.04f %12.04f %12.04f %12.04f %12.04f\n",particle_theta,particle_phi,particle_x,particle_y,energy,particle_flight_distance,ckov_unc);
float refrac_index = global_refrac_index;
// printf("%12.04f\n",refrac_index);
float refrac_split = -.000;
float pion_refrac_mod = 1.000;
float kaon_refrac_mod = 1.000;
pion_refrac_mod += refrac_split;
kaon_refrac_mod -= refrac_split;
float pion_beta = dirc_model->get_beta(energy,pimass);
float kaon_beta = dirc_model->get_beta(energy,kmass);
//ns
float pion_time = particle_flight_distance/(pion_beta*.3);
float kaon_time = particle_flight_distance/(kaon_beta*.3);
float pion_emit_angle = 57.3*acos(1/(pion_beta*pion_refrac_mod*refrac_index));
float kaon_emit_angle = 57.3*acos(1/(kaon_beta*kaon_refrac_mod*refrac_index));
// printf("angles: %12.04f %12.04f Beta: %12.04f %12.04f\n",pion_emit_angle,kaon_emit_angle,pion_beta,kaon_beta);
std::vector<dirc_point> provisional_points_lwn;
std::vector<dirc_point> provisional_points_lwp;
dirc_model->track_all_line_photons(\
provisional_points_lwn,\
provisional_points_lwp,\
num_line_points,\
pion_emit_angle,\
particle_theta,\
particle_phi,\
particle_x,\
particle_y,\
-17.25/2,\
pion_time,\
1);
for (unsigned int i = 0; i < provisional_points_lwn.size(); i++)
{
global_pion_line.push_back(provisional_points_lwn[i]);
}
for (unsigned int i = 0; i < provisional_points_lwp.size(); i++)
{
global_pion_line.push_back(provisional_points_lwp[i]);
}
provisional_points_lwn.clear();
provisional_points_lwp.clear();
dirc_model->track_all_line_photons(\
provisional_points_lwn,\
provisional_points_lwp,\
num_line_points,\
kaon_emit_angle,\
particle_theta,\
particle_phi,\
particle_x,\
particle_y,\
-17.25/2,\
kaon_time,\
1);
for (unsigned int i = 0; i < provisional_points_lwn.size(); i++)
{
global_kaon_line.push_back(provisional_points_lwn[i]);
}
for (unsigned int i = 0; i < provisional_points_lwp.size(); i++)
{
global_kaon_line.push_back(provisional_points_lwp[i]);
}
//Lines are drawn, now simulate data
for (int i = 0; i < num_particle_hits; i++)
{
std::vector<dirc_point> pion_push;
std::vector<dirc_point> kaon_push;
dirc_model->sim_rand_n_photons(\
pion_push,\
n_sim_phots,\
pion_old_angle,\
1,\
particle_x,\
particle_y,\
pion_time,\
particle_theta,\
particle_phi,\
tracking_unc,\
ckov_unc,\
pion_beta);
digitizer->digitize_points(pion_push);
dirc_model->sim_rand_n_photons(\
kaon_push,\
n_sim_phots,\
kaon_old_angle,\
1,\
particle_x,\
particle_y,\
kaon_time,\
particle_theta,\
particle_phi,\
tracking_unc,\
ckov_unc,\
kaon_beta);
digitizer->digitize_points(kaon_push);
//printf("%5u %5u\n",pion_push.size(),kaon_push.size());
//printf("model run: %12.04f %12.04f %12.04f %12.04f %12.04f %12.04f %12.04f %12.04f %12.04f\n",kaon_emit_angle,particle_x,particle_y,kaon_time,particle_theta,particle_phi,tracking_unc,ckov_unc,kaon_beta);
global_pion_hits.push_back(pion_push);
global_kaon_hits.push_back(kaon_push);
}
}
void dirc_calib_line(int &npar, float *gin, float &f, float *par, int iflag)
{
//do not compute gradient, so flag is irrelevant
//pars: pion_x_adj, pion_y_adj, kaon_x_adj, kaon_y_adj
TH1F *ll_diff_pion = new TH1F("ll_diff_pion_tmp","Difference of log likelihood real = pion",60000,-600,600);
TH1F *ll_diff_kaon = new TH1F("ll_diff_kaon_tmp","Difference of log likelihood real = kaon",60000,-600,600);
float time_spread = 1000;
//float dist_spread = 40;
float dist_spread = 50;
float max_dev_sq = 5;
max_dev_sq *= max_dev_sq;
float llc = 0;
float llf = 0;
float mult_params = 1;
float x_shift = par[0];
x_shift = -.6;
float y_shift = par[0];
float y_split = par[1];
float pion_x_adj = x_shift;
float kaon_x_adj = x_shift;
float pion_y_adj = mult_params*(y_shift+y_split);
float kaon_y_adj = mult_params*(y_shift-y_split);
std::vector<dirc_point> pion_line;
std::vector<dirc_point> kaon_line;
for (unsigned int i = 0; i < global_pion_line.size(); i++)
{
dirc_point add_point = global_pion_line[i];
add_point.x += pion_x_adj;
add_point.y += pion_y_adj;
pion_line.push_back(add_point);
// printf("%12.04f %12.04f %12.04f\n",global_pion_line[i].y,global_kaon_line[i].y,global_pion_line[i].y-global_kaon_line[i].y);
}
for (unsigned int i = 0; i < global_kaon_line.size(); i++)
{
dirc_point add_point = global_kaon_line[i];
add_point.x += kaon_x_adj;
add_point.y += kaon_y_adj;
kaon_line.push_back(add_point);
}
std::vector<dirc_point> sim_points;
for (unsigned int k = 0; k < global_pion_hits.size(); k++)
{//global pion hits and global kaon hits should have the same size
//do pion hit first
sim_points = global_pion_hits[k];
llc = 0;
llf = 0;
for (unsigned int i = 0; i < sim_points.size(); i++)
{
float min_dist_sq = 10000;
float cur_dist_sq = -1;
for (unsigned int j = 0; j < pion_line.size(); j++)
{
cur_dist_sq = (sim_points[i].x - pion_line[j].x)*(sim_points[i].x - pion_line[j].x);
cur_dist_sq += (sim_points[i].y - pion_line[j].y)*(sim_points[i].y - pion_line[j].y);
cur_dist_sq /= dist_spread;
cur_dist_sq += (sim_points[i].t - pion_line[j].t)*(sim_points[i].t - pion_line[j].t)/time_spread;
min_dist_sq = std::min(min_dist_sq,cur_dist_sq);
//printf("%12.04f\n",cur_dist_sq);
}
llc += std::min(min_dist_sq,max_dev_sq);
//printf("%4d %12.04f %12.04f\n",i,min_dist_sq,llc);
}
for (unsigned int i = 0; i < sim_points.size(); i++)
{
float min_dist_sq = 10000;
float cur_dist_sq = -1;
for (unsigned int j = 0; j < kaon_line.size(); j++)
{
cur_dist_sq = (sim_points[i].x - kaon_line[j].x)*(sim_points[i].x - kaon_line[j].x);
cur_dist_sq += (sim_points[i].y - kaon_line[j].y)*(sim_points[i].y - kaon_line[j].y);
cur_dist_sq /= dist_spread;
cur_dist_sq += (sim_points[i].t - kaon_line[j].t)*(sim_points[i].t - kaon_line[j].t)/time_spread;
min_dist_sq = std::min(min_dist_sq,cur_dist_sq);
}
//cur_mean_phi /= total_prov_points;
//printf("pion/pion: %12.04f %12.04f\n",cur_mean_phi/total_prov_points,atan2(cur_mean_y,cur_mean_x));
llf += std::min(min_dist_sq,max_dev_sq);
}
ll_diff_pion->Fill(1*(llc-llf));
llc=0;
llf=0;
sim_points = global_kaon_hits[k];
for (unsigned int i = 0; i < sim_points.size(); i++)
{
float min_dist_sq = 10000;
float cur_dist_sq = -1;
for (unsigned int j = 0; j < pion_line.size(); j++)
{
cur_dist_sq = (sim_points[i].x - pion_line[j].x)*(sim_points[i].x - pion_line[j].x);
cur_dist_sq += (sim_points[i].y - pion_line[j].y)*(sim_points[i].y - pion_line[j].y);
cur_dist_sq /= dist_spread;
cur_dist_sq += (sim_points[i].t - pion_line[j].t)*(sim_points[i].t - pion_line[j].t)/time_spread;
min_dist_sq = std::min(min_dist_sq,cur_dist_sq);
}
llc += std::min(min_dist_sq,max_dev_sq);
}
for (unsigned int i = 0; i < sim_points.size(); i++)
{
float min_dist_sq = 10000;
float cur_dist_sq = -1;
for (unsigned int j = 0; j < kaon_line.size(); j++)
{
cur_dist_sq = (sim_points[i].x - kaon_line[j].x)*(sim_points[i].x - kaon_line[j].x);
cur_dist_sq += (sim_points[i].y - kaon_line[j].y)*(sim_points[i].y - kaon_line[j].y);
cur_dist_sq /= dist_spread;
cur_dist_sq += (sim_points[i].t - kaon_line[j].t)*(sim_points[i].t - kaon_line[j].t)/time_spread;
min_dist_sq = std::min(min_dist_sq,cur_dist_sq);
}
llf += std::min(min_dist_sq,max_dev_sq);
}
ll_diff_kaon->Fill(1*(llc-llf));
}
//I feel unclean
//ll_diff_pion->Write();
//ll_diff_kaon->Write();
//ll_diff_pion->Rebin(20);
//ll_diff_kaon->Rebin(20);
std::vector<float> xr;
std::vector<float> yr;
float ival = 0;
float pion_integral = 0;
float kaon_reverse_integral = 1;
float integral_scale = global_pion_hits.size();
for (int i = 0; i < ll_diff_pion->GetNbinsX(); i++)
{
pion_integral += ll_diff_pion->GetBinContent(i)/integral_scale;
kaon_reverse_integral -= ll_diff_kaon->GetBinContent(i)/integral_scale;
xr.push_back(pion_integral);
yr.push_back(kaon_reverse_integral);
if (xr[i] < .001 && xr[i] > .00)
{
//printf("%8d %12.04f %12.04f\n",i,xr[i],yr[i]);
}
if (ll_diff_pion->GetBinContent(i)/integral_scale > 0)
{
//printf("%8d %12.04f\n",i,ll_diff_pion->GetBinContent(i)/integral_scale);
}
}
float last_x = xr[0];
float last_y = yr[0];
for (int i = 0; i < ll_diff_pion->GetNbinsX()-1; i++)
{
ival += (yr[i]+last_y)*(xr[i] - last_x)/2;
//printf("%6d %12.09f %12.04f %12.04f %12.04f %12.04f\n",i,ival,xr[i],yr[i],last_x,last_y);
last_x = xr[i];
last_y = yr[i];
}
// printf("params: %12.04f %12.04f %12.04f %12.04f %12.04f val: %12.04f\n",pion_x_adj,pion_y_adj,kaon_x_adj,kaon_y_adj,dist_spread,-ival);
f = -ival; //return negative ROC integral
delete ll_diff_pion;
delete ll_diff_kaon;
}
std::vector<dirc_point> fold_x(std::vector<dirc_point> inpoints) {
std::vector<dirc_point> outvec;
for (unsigned int i = 0; i < inpoints.size(); i++) {
dirc_point tpoint = inpoints[i];
tpoint.x = fabs(tpoint.x);
outvec.push_back(tpoint);
}
return outvec;
}
int main(int nargs, char* argv[])
{
// printf("%12.04f\n",atan2(0,10)*57.3);
clock_t timing_clock;
const char* in_str;
bool inputfile = false;
bool inputrootfile = false;
bool out_csv = false;
bool slac_run = false;
int output_box_angles_n = -1;
float time_window=-1;//time window for confounded pmt hits, in ns
float energy = 5.0;
float energy_mean = energy;
float energy_spread = 0;
float kmass = .4937;
float pimass = .1396;
float mumass = .1057;
float particle_x = 0;
float particle_y = 0;
float particle_x_mean = particle_x;
float particle_y_mean = particle_y;
float particle_x_spread = 0;
float particle_y_spread = 0;
float particle_theta = 4;
float particle_theta_mean = particle_theta;
float particle_theta_spread = 0;
float particle_phi = 40;
float particle_phi_mean = particle_phi;
float const_track_off = 0;
float particle_flight_distance = 0;
int box_check_n = -1;
float box_check_theta = 0;
float box_check_phi = 0;
float box_check_theta_unc = 0;
float box_check_phi_unc = 0;
float box_check_overall_theta = -15;
int phot_check_n = -1;
float phot_check_max_theta = 4;
bool force_kinematics = false;
bool use_prog_sep = false;
bool kaleidoscope_plot = false;
bool monochrome_plot = false;
bool flatten_time = false;
bool sep_updown = false;
bool output_peak_lambda = false;
bool lut_slac = false;
bool run_minuit_calibration = false;
bool perform_chromatic_correction = true;
bool use_moliere_scattering = false;
int num_runs = 1000;
int max_particles = 60000000;
int phi_phots_reduce = 1;
int refraction_sim_n = -1;
int sparse_sim_n = -1;
int sparse_recon_n = -1;
int line_recon_n = -1;
int line_output_n = -1;
int fill_d_midline_n = -1;
int lut_sim_n = -1;
int gaus_ll_n = -1;
int sim_time_test_n = -1;
int bounces_phot_n = -1;
float gaus_ll_spread = 2;
float mean_n_phot = 40;
float spread_n_phot = 0;
float wedge_uncertainty = 0/57.3;
float refrac_index=1.47;
float mirror_angle_change = 0;
float mirror_angle_change_unc = 0;
float mirror_angle_change_yunc = 0;
float box_rot = 0;
float box_rot_unc = 0;
float bar_box_box_angle = 0/57.3;
float mirror_r_difference = 400;//1200 - 400 = 800. Changed 05/09/2016. Does not affect threeseg mirror reconstruction as far as I can tell - this was known.
// float mirror_r_difference = 0;
float wedge_non_uniformity = 0;
float pmt_offset = 0;
float main_mirror_nonuniformity = 0;
float foc_mirror_size = 288;
float main_mirror_angle_off = 0;
float main_mirror_yangle_off = 0;
float main_mirror_zangle_off = 0;
float main_mirror_yoff = 0;
float main_mirror_zoff = 0;
float bar_box_xoff = 0;
float bar_box_yoff = 0;
float bar_box_zoff = 0;
float pmt_min_z = -1000;
float pmt_max_z = 1000;
float large_mirror_min_z = -1000;
float large_mirror_max_z = 1000;
pmt_min_z = -559;
pmt_max_z = -329;
//pmt_max_z = -338;
large_mirror_min_z = -559;
large_mirror_max_z = -130;
float upper_wedge_yang_spread = 0;
int rseed = 1337;
int broaden_events = 0;
float tracking_unc = .0000*57.3; //mrad
// float ckov_unc = .0077*57.3; //chromatic + optical aberation = 7.7mrad
float ckov_unc = .003*57.3; //transport = 3mrad
float resx = 6;
float resy = 6;
float rest = 1;
// float minx = -8000;
// float maxx = -minx;
// float miny = -800;
// float maxy = -miny;
float minx = -1500;
float maxx = 1500;
float miny = -500;
float maxy = 500;
float mint = 0;
float maxt = 1000;
float t_unc = .27;
float t_bin_size = 1;
float digit_miny = -50;
float digit_maxy = 300;
digit_miny = miny;
digit_maxy = maxy;
//Sets the side boundarys of the distributions
float sm_xl = -10000000;
float sm_xr = -sm_xl;
//float s_func_x = 6;
float s_func_x = 6;
float s_func_y = s_func_x;
//float s_func_t = 2;
float s_func_t = 1.0;
float sfunc_sig = 1;
#ifdef USE_BABAR_BOX
s_func_x = 29;
s_func_y = 29;
#endif
int n_sim_phots = 40;
// float pion_x_adj = -.43;
// float pion_y_adj = -3.6;
// float kaon_x_adj = -.48;
// float kaon_y_adj = 2.87;
float pion_x_adj = 0;
float pion_y_adj = 0;
float kaon_x_adj = 0;
float kaon_y_adj = 0;
//int n_phi_phots = 900000;
int n_phi_phots = 150000;
//n_phi_phots = 75000;
int n_z_phots = 4;
// n_step_phots = n_z_phots*n_phi_phots;
/*
sm_xl = -50;
sm_xr = sm_xl + 440;
*/
// sm_xl = 0;
// sm_xr = sm_xl + 1100;
// float overlap_x = -1;
bool use_quartz_for_liquid = false;
bool three_seg_mirror = true;
bool fill_distributions = false;
bool fill_kinematics_yields = false;
float kinematics_yields_min_theta = 0;
float kinematics_yields_max_theta = 12;
float kinematics_yields_step_theta = .25;
float kinematics_yields_min_phi = 0;
float kinematics_yields_max_phi = 45;
float kinematics_yields_step_phi = 1;
int kinematics_n_phots = 100000;
float liquid_absorbtion = 0*-log(.7)/1000;
float liquid_index = 1.33;
bool coverage_plot = false;
int num_cov = 100000;
char* rootfilename = new char[256];
char* inputrootfilename = new char[256];
sprintf(rootfilename,"fitdirc.root");
printf("Arguments Passed=%d\n",nargs);
if(nargs==2){
in_str = argv[1];
printf("%s\n",in_str);
printf("nargs=2\n");
inputfile = true;
}
else{
for (int i = 1; i < nargs; i++)
{
if (strcmp(argv[i], "-if") == 0)
{
i++;
in_str = argv[i];
inputfile = true;
}
else if (strcmp(argv[i], "-of") == 0)
{
i++;
sprintf(rootfilename,"%s",argv[i]);
}
else if (strcmp(argv[i], "-fill_dist") == 0)
{
fill_distributions = true;
}
else if (strcmp(argv[i], "-cylindrical_mirror") == 0)
{
three_seg_mirror = false;
}
else if (strcmp(argv[i], "-updown") == 0)
{
printf("Up-Down Histogram filling only implemented in loop mode, option currently does nothing in other modes\n");
sep_updown = true;
}
else if (strcmp(argv[i], "-root_input") == 0)
{
i++;
inputrootfile = true;
sprintf(inputrootfilename,"%s",argv[i]);
}
else if (strcmp(argv[i], "-particle_phi") == 0)
{
i++;
particle_phi = atof(argv[i]);
particle_phi_mean = particle_phi;
}
else if (strcmp(argv[i], "-particle_flight_distance") == 0)
{
//meters
i++;
particle_flight_distance = atof(argv[i]);
}
else if (strcmp(argv[i], "-tracking_unc") == 0)
{
i++;
tracking_unc = atof(argv[i]);
}
else if (strcmp(argv[i], "-output_peak_lambda") == 0)
{
output_peak_lambda = true;
}
else if (strcmp(argv[i], "-const_track_off") == 0)
{
i++;
const_track_off = atof(argv[i]);
}
else if (strcmp(argv[i], "-ckov_unc") == 0)
{
i++;
ckov_unc = atof(argv[i]);
}
else if (strcmp(argv[i], "-refraction_sim_n") == 0)
{
i++;
refraction_sim_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-sparse_sim_n") == 0)
{
i++;
sparse_sim_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-line_output_n") == 0)
{
i++;
line_output_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-sparse_recon_n") == 0)
{
i++;
sparse_recon_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-line_recon_n") == 0)
{
i++;
line_recon_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-side_mirror") == 0)
{
i++;
sm_xl = atof(argv[i]);
i++;
sm_xr = atof(argv[i]);
}
else if (strcmp(argv[i], "-line_recon_calib") == 0)
{
//setting line recon calibrations, expects 4 arguements
i++;
pion_x_adj = atof(argv[i]);
i++;
pion_y_adj = atof(argv[i]);
i++;
kaon_x_adj = atof(argv[i]);
i++;
kaon_y_adj = atof(argv[i]);
}
else if (strcmp(argv[i], "-lut_sim_n") == 0)
{
i++;
lut_sim_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-lut_slac") == 0)
{
lut_slac = true;
}
else if (strcmp(argv[i], "-fill_d_midline_n") == 0)
{
i++;
fill_d_midline_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-gaus_ll_n") == 0)
{
i++;
gaus_ll_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-gaus_ll_spread") == 0)
{
i++;
gaus_ll_spread = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_theta") == 0)
{
i++;
particle_theta = atof(argv[i]);
particle_theta_mean = particle_theta;
}
else if (strcmp(argv[i], "-sim_time_test_n") == 0)
{
i++;
sim_time_test_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-bounces_phot_n") == 0)
{
i++;
bounces_phot_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-use_quartz_for_liquid") == 0)
{
use_quartz_for_liquid = true;
}
else if (strcmp(argv[i], "-use_moliere_scattering") == 0)
{
use_moliere_scattering = true;
printf("Enabling Moliere Scattering - only implemented in loop mode\n");
}
else if (strcmp(argv[i], "-force_kinematics") == 0)
{
force_kinematics = true;
}
else if (strcmp(argv[i], "-fill_kinematics_yields") == 0)
{
fill_kinematics_yields = true;
}
else if (strcmp(argv[i], "-out_csv") == 0)
{
out_csv = true;
}
else if (strcmp(argv[i], "-coverage_plot") == 0)
{
coverage_plot = true;
}
else if (strcmp(argv[i], "-kaleidoscope_plot") == 0)
{
kaleidoscope_plot = true;
}
else if (strcmp(argv[i], "-no_chromatic_correction") == 0)
{
perform_chromatic_correction = false;
}
else if (strcmp(argv[i], "-monochrome_light") == 0)
{
monochrome_plot = true;
}
else if (strcmp(argv[i], "-run_minuit_calibration") == 0)
{
run_minuit_calibration = true;
}
else if (strcmp(argv[i], "-output_box_angles_n") == 0)
{
i++;
output_box_angles_n = atoi(argv[i]);
}
else if (strcmp(argv[i], "-prog_sep") == 0)
{
use_prog_sep = true;
}
else if (strcmp(argv[i], "-slac_run") == 0)
{
slac_run = true;
three_seg_mirror = false;
mirror_r_difference = 0;
//mean_n_phot = 31.1;
mean_n_phot = 32.4;
spread_n_phot = 6;
liquid_index = 1.47;
phi_phots_reduce = 10;
}
else if (strcmp(argv[i], "-slac_geometry") == 0)
{
three_seg_mirror = false;
mirror_r_difference = 0;
//mean_n_phot = 31.1;
mean_n_phot = 32.4;
spread_n_phot = 6;
liquid_index = 1.47;
phi_phots_reduce = 10;
// sm_xl = -300;
// sm_xr = sm_xl + 1000;
miny = -1500;
maxy = 1500;
digit_miny = miny;
digit_maxy = maxy;
}
else if (strcmp(argv[i], "-flatten_time") == 0)
{
flatten_time = true;
}
else if (strcmp(argv[i], "-open_image_plane") == 0)
{
pmt_min_z = -1000;
pmt_max_z = 1000;
large_mirror_min_z = -1000;
large_mirror_max_z = 1000;
}
else if (strcmp(argv[i], "-mean_n_phot") == 0)
{
i++;
mean_n_phot = atof(argv[i]);
}
else if (strcmp(argv[i], "-s_func_t") == 0)
{
i++;
s_func_t = atof(argv[i]);
}
else if (strcmp(argv[i], "-t_unc") == 0)
{
i++;
t_unc = atof(argv[i]);
}
else if (strcmp(argv[i], "-t_bin_size") == 0)
{
i++;
t_bin_size = atof(argv[i]);
}
else if (strcmp(argv[i], "-n_phi_phots") == 0)
{
i++;
n_phi_phots = atoi(argv[i]);
}
else if (strcmp(argv[i], "-n_z_phots") == 0)
{
i++;
n_z_phots = atoi(argv[i]);
}
else if (strcmp(argv[i], "-spread_n_phot") == 0)
{
i++;
spread_n_phot = atof(argv[i]);
}
else if (strcmp(argv[i], "-t") == 0)
{
i++;
time_window = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_x_spread") == 0)
{
i++;
particle_x_spread = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_y_spread") == 0)
{
i++;
particle_y_spread = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_y") == 0)
{
i++;
particle_y = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_x") == 0)
{
i++;
particle_x = atof(argv[i]);
}
else if (strcmp(argv[i], "-particle_theta_spread") == 0)
{
i++;
particle_theta_spread = atof(argv[i]);
}
else if (strcmp(argv[i], "-energy_spread") == 0)
{
i++;
energy_spread = atof(argv[i]);
}
else if (strcmp(argv[i], "-E") == 0)
{
i++;
energy = atof(argv[i]);
energy_mean = energy;
}
else if (strcmp(argv[i], "-n") == 0)
{
i++;
num_runs = atoi(argv[i]);
}
else if (strcmp(argv[i], "-max_particles") == 0)
{
i++;
max_particles = atoi(argv[i]);
}
else if (strcmp(argv[i], "-pmt_res") == 0)
{
i++;
resx = atof(argv[i]);
resy = resx;
}
else if (strcmp(argv[i], "-liquid_index") == 0)
{
i++;
liquid_index = atof(argv[i]);
}
else if (strcmp(argv[i], "-broaden_events") == 0)
{
i++;
broaden_events = atoi(argv[i]);
}
else if (strcmp(argv[i], "-wedge_uncertainty") == 0)
{
i++;
wedge_uncertainty = atof(argv[i]);
}
else if (strcmp(argv[i], "-refrac_index") == 0)
{
i++;
refrac_index = atof(argv[i]);
}
else if (strcmp(argv[i], "-mirror_angle_change") == 0)
{
i++;
mirror_angle_change = atof(argv[i]);
}
else if (strcmp(argv[i], "-mirror_angle_change_unc") == 0)
{
i++;
mirror_angle_change_unc = atof(argv[i]);
}
else if (strcmp(argv[i], "-mirror_angle_change_yunc") == 0)
{
i++;
mirror_angle_change_yunc = atof(argv[i]);
}
else if (strcmp(argv[i], "-box_rot") == 0)
{
i++;
box_rot = atof(argv[i]);
}
else if (strcmp(argv[i], "-box_rot_unc") == 0)
{
i++;
box_rot_unc = atof(argv[i]);
}
else if (strcmp(argv[i], "-bar_box_box_angle") == 0)
{
i++;
bar_box_box_angle = atof(argv[i]);
}
else if (strcmp(argv[i], "-mirror_r_difference") == 0)
{
i++;
mirror_r_difference = atof(argv[i]);
}
else if (strcmp(argv[i], "-wedge_non_uniformity") == 0)
{
i++;
wedge_non_uniformity = atof(argv[i]);