-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSIDISc12rSkimmer.C
2212 lines (1971 loc) · 104 KB
/
SIDISc12rSkimmer.C
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
// last edit June-22, 2023
#ifdef __CINT__
#pragma link C++ class std::vector<TVector3>+;
#pragma link C++ class vector<TVector3>+;
#pragma link C++ class std::vector<TLorentzVector>+;
#pragma link C++ class vector<TLorentzVector>+;
#endif
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <TFile.h>
#include <TTree.h>
#include <TApplication.h>
#include <TROOT.h>
#include <TDatabasePDG.h>
#include <TLorentzVector.h>
#include <TVector3.h>
#include <TH1.h>
#include <TChain.h>
#include <TCanvas.h>
#include <TBenchmark.h>
#include "clas12reader.h"
#include "Auxiliary/DCfid_SIDIS.cpp"
#include "Auxiliary/csv_reader.h"
#include "Auxiliary/SIDISatBAND_auxiliary.cpp"
using namespace clas12;
SIDISatBAND_auxiliary aux;
// Results in CSV file
TString csvheader = ( (TString)"status,runnum,evnum,beam_helicity,"
+(TString)"e_P,e_Theta,e_Phi,e_Vz,"
+(TString)"pi_P,pi_Theta,pi_Phi,pi_Vz,"
+(TString)"Q2,xB,omega,y,"
+(TString)"e_DC_sector,pi_DC_sector,"
+(TString)"e_Theta_qFrame,e_Phi_qFrame,"
+(TString)"pi_qFrame_Theta,pi_qFrame_Phi,"
+(TString)"pi_qFrame_pT,pi_qFrame_pL,"
+(TString)"Zpi,Zpi_LC,"
+(TString)"W,M_x,"
+(TString)"xF,eta_pi,"
+(TString)"W_d,M_x_d,"
+(TString)"q,qStar,"
);
// addition to csv for GEMC simulations
TString csvheader_GEMCaddition = ( (TString)"e_P_g,e_Theta_g,e_Phi_g,e_Vz_g,"
+(TString)"pi_P_g,pi_Theta_g,pi_Phi_g,pi_Vz_g,"
+(TString)"Q2_g,xB_g,omega_g,y_g,"
);
std::vector<int> csvprecisions = {0,0,0,0,9,9,9,9,9,9,9,9,9,9,9,9,0,0,};
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
// start clock
auto start = std::chrono::high_resolution_clock::now();
// declare methods
TVector3 GetParticleVertex (clas12::region_part_ptr rp);
void SetLorentzVector (TLorentzVector &p4, clas12::region_part_ptr rp);
void OpenOutputFiles (TString csvfilename);
void CloseOutputFiles (TString OutDataPath, TString outfilename);
void SetOutputTTrees ();
bool CheckIfElectronPassedSelectionCuts (Double_t e_PCAL_x, Double_t e_PCAL_y,
Double_t e_PCAL_W,Double_t e_PCAL_V,
Double_t e_E_PCAL,
Double_t e_E_ECIN, Double_t e_E_ECOUT,
TLorentzVector e,
TVector3 Ve,
Double_t e_DC_sector,
Double_t e_DC_x[3],
Double_t e_DC_y[3],
Double_t e_DC_z[3],
int torusBending);
bool CheckIfPionPassedSelectionCuts (TString pionCharge, // "pi+" or "pi-"
Double_t DC_sector,
Double_t DC_x[3], Double_t DC_y[3], Double_t DC_z[3],
Double_t chi2PID, Double_t p,
TVector3 Ve, TVector3 Vpi,
int fdebug);
int GetBeamHelicity (event_ptr p_event, int runnum, int fdebug);
double GetBeamEnergy (int fdebug);
void InitializeFileReading (int NeventsMax,int c12Nentries, int fdebug);
void InitializeVariables ();
void OpenResultFiles (TString outfilepath, TString outfilename );
void ExtractElectronInformation (int fdebug);
void ExtractPionsInformation (int fdebug);
void ExtractPipsInformation (int pipsIdx, int fdebug );
void ExtractPimsInformation (int pimsIdx, int fdebug );
void ExtractKpsInformation (int kIdx, int fdebug );
void ExtractKmsInformation (int kIdx, int fdebug );
void ComputeElectronKinematics ();
void ComputePionKinematics (TLorentzVector pi, TLorentzVector pi_qFrame);
void WriteEventToOutput (int fdebug);
void FinishProgram (TString outfilepath, TString outfilename);
void GetParticlesByType (int evnum, int fdebug );
void Stream_e_pi_line_to_CSV (TString pionCharge, int piIdx,
bool passed_cuts_e_pi,
bool passed_cuts_e_pi_kinematics,
int fdebug );
void Stream_e_K_line_to_CSV (TString KCharge, int KIdx,
bool passed_cuts_e_K,
bool passed_cuts_e_K_kinematics,
int fdebug );
TVector3 RotateVectorTo_qFrame (TVector3 V);
void MoveTo_qFrame (int fdebug);
void SetDataPath (TString fDataPath, Double_t fEbeam) ;
void SetSimPi (TString fSimPi);
void SetSkimming (TString fSkimming) ;
void SetInclusive ( int fInclusive );
void SetEbeam ( double fEbeam );
void SetIsMC ( bool fIsMC = false );
void SetVerbosity ( int _fdebug_ = 0 );
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
// globals
TString Skimming = "", DataPath = "", prefix = "", SimPi = "", SimK = "";
TString SpecificFilePath = "", SpecificFilename = "";
auto db = TDatabasePDG::Instance();
double Pe_phi, q_phi, q_theta; // "q-frame" parameters
double Zpi, Zpi_LC;
double ZK, ZK_LC;
bool ePastCutsInEvent = false, EventPassedCuts = false;
bool pipsPastCutsInEvent = false, eepipsPastCutsInEvent = false;
bool pimsPastCutsInEvent = false, eepimsPastCutsInEvent = false;
bool KpsPastCutsInEvent = false, eeKpsPastCutsInEvent = false;
bool KmsPastCutsInEvent = false, eeKmsPastCutsInEvent = false;
bool IsMC = false; // GEMC simulations
// meta-data
int fdebug = 0;
int torusBending = -1; // -1 for In-bending, +1 for Out-bending
int DC_layers[3] = {6,18,36};// Region 1 is denoted at DC detector 6, Region 2 is denoted 18, Region 3 - as 36
int DC_layer, runnum=0, evnum=0, beam_helicity=0;
// helicity of the electron +1 along the beam and -1 opposite to it
int status, NeventsMaxToProcess, Nevents_processed, Nevents_passed_e_cuts;
int Nevents_passed_pips_cuts, Nevents_passed_e_pips_cuts;
int Nevents_passed_e_pips_kinematics_cuts, Nevents_passed_pims_cuts;
int Nevents_passed_e_pims_cuts, Nevents_passed_e_pims_kinematics_cuts;
int Nevents_passed_Kps_cuts, Nevents_passed_e_Kps_cuts;
int Nevents_passed_e_Kps_kinematics_cuts;
int Nevents_passed_Kms_cuts, Nevents_passed_e_Kms_cuts;
int Nevents_passed_e_Kms_kinematics_cuts;
int inclusive; // tag to look at inclusive run - all the events with no selection
// number of particles per event
int Ne, Nn, Np, Npips, Npims, NKps, NKms, Ngammas, Nd;
// leading electron
// electron energy deposit in PCAL [GeV], in ECAL_in [GeV], in ECAL_out [GeV]...
double e_E_PCAL, e_E_ECIN, e_E_ECOUT, e_PCAL_W, e_PCAL_V, e_PCAL_x, e_PCAL_y, e_PCAL_z;
double e_PCAL_sector, e_DC_sector, e_DC_Chi2N, e_DC_x[3], e_DC_y[3], e_DC_z[3];
// positive pions
bool pipsPastSelectionCuts[NMAXPIONS], eepipsPastKinematicalCuts[NMAXPIONS];
int pips_region[NMAXPIONS];
double pips_chi2PID[NMAXPIONS];
double pips_PCAL_W[NMAXPIONS];
double pips_PCAL_V[NMAXPIONS];
double pips_PCAL_x[NMAXPIONS];
double pips_PCAL_y[NMAXPIONS];
double pips_PCAL_z[NMAXPIONS];
double pips_PCAL_sector[NMAXPIONS];
double pips_DC_sector[NMAXPIONS];
double pips_Chi2N[NMAXPIONS];
double pips_DC_x[NMAXPIONS][3];
double pips_DC_y[NMAXPIONS][3];
double pips_DC_z[NMAXPIONS][3];
double pips_E_PCAL[NMAXPIONS];
double pips_E_ECIN[NMAXPIONS];
double pips_E_ECOUT[NMAXPIONS];
double Zpips[NMAXPIONS]; // hadron rest-frame energy
double ZpipsLC[NMAXPIONS]; // hadron z on the light-cone
double piplus_Px[NMAXPIONS];
double piplus_Py[NMAXPIONS];
double piplus_Pz[NMAXPIONS];
double piplus_E[NMAXPIONS];
double Vpiplus_X[NMAXPIONS];
double Vpiplus_Y[NMAXPIONS];
double Vpiplus_Z[NMAXPIONS];
double piplus_qFrame_pT[NMAXPIONS]; // transverse momentum relative to q
double piplus_qFrame_pL[NMAXPIONS]; // longitudinal momentum relative to q
double piplus_qFrame_Theta[NMAXPIONS];
double piplus_qFrame_Phi[NMAXPIONS];
// negative pions
bool pimsPastSelectionCuts[NMAXPIONS];
bool eepimsPastKinematicalCuts[NMAXPIONS];
int pims_region[NMAXPIONS];
double pims_chi2PID[NMAXPIONS];
double pims_PCAL_W[NMAXPIONS];
double pims_PCAL_V[NMAXPIONS];
double pims_PCAL_x[NMAXPIONS];
double pims_PCAL_y[NMAXPIONS];
double pims_PCAL_z[NMAXPIONS];
double pims_PCAL_sector[NMAXPIONS];
double pims_DC_sector[NMAXPIONS];
double pims_Chi2N[NMAXPIONS];
double pims_DC_x[NMAXPIONS][3];
double pims_DC_y[NMAXPIONS][3];
double pims_DC_z[NMAXPIONS][3];
double pims_E_PCAL[NMAXPIONS];
double pims_E_ECIN[NMAXPIONS];
double pims_E_ECOUT[NMAXPIONS];
double Zpims[NMAXPIONS]; // hadron rest-frame energy
double ZpimsLC[NMAXPIONS]; // hadron z on the light-cone
double piminus_Px[NMAXPIONS];
double piminus_Py[NMAXPIONS];
double piminus_Pz[NMAXPIONS];
double piminus_E[NMAXPIONS];
double Vpiminus_X[NMAXPIONS];
double Vpiminus_Y[NMAXPIONS];
double Vpiminus_Z[NMAXPIONS];
double piminus_qFrame_pT[NMAXPIONS]; // transverse momentum relative to q
double piminus_qFrame_pL[NMAXPIONS]; // longitudinal momentum relative to q
double piminus_qFrame_Theta[NMAXPIONS];
double piminus_qFrame_Phi[NMAXPIONS];
// K+
bool KpsPastSelectionCuts[NMAXKAONS], eeKpsPastKinematicalCuts[NMAXKAONS];
int Kps_region[NMAXKAONS];
double Kps_chi2PID[NMAXKAONS];
double Kps_PCAL_W[NMAXKAONS];
double Kps_PCAL_V[NMAXKAONS];
double Kps_PCAL_x[NMAXKAONS];
double Kps_PCAL_y[NMAXKAONS];
double Kps_PCAL_z[NMAXKAONS];
double Kps_PCAL_sector[NMAXKAONS];
double Kps_DC_sector[NMAXKAONS];
double Kps_Chi2N[NMAXKAONS];
double Kps_DC_x[NMAXKAONS][3];
double Kps_DC_y[NMAXKAONS][3];
double Kps_DC_z[NMAXKAONS][3];
double Kps_E_PCAL[NMAXKAONS];
double Kps_E_ECIN[NMAXKAONS];
double Kps_E_ECOUT[NMAXKAONS];
double ZKps[NMAXKAONS]; // hadron rest-frame energy
double ZKpsLC[NMAXKAONS]; // hadron z on the light-cone
double Kplus_Px[NMAXKAONS];
double Kplus_Py[NMAXKAONS];
double Kplus_Pz[NMAXKAONS];
double Kplus_E[NMAXKAONS];
double VKplus_X[NMAXKAONS];
double VKplus_Y[NMAXKAONS];
double VKplus_Z[NMAXKAONS];
double Kplus_qFrame_pT[NMAXKAONS]; // transverse momentum relative to q
double Kplus_qFrame_pL[NMAXKAONS]; // longitudinal momentum relative to q
double Kplus_qFrame_Theta[NMAXKAONS];
double Kplus_qFrame_Phi[NMAXKAONS];
// K-
bool KmsPastSelectionCuts[NMAXKAONS];
bool eeKmsPastKinematicalCuts[NMAXKAONS];
int Kms_region[NMAXKAONS];
double Kms_chi2PID[NMAXKAONS];
double Kms_PCAL_W[NMAXKAONS];
double Kms_PCAL_V[NMAXKAONS];
double Kms_PCAL_x[NMAXKAONS];
double Kms_PCAL_y[NMAXKAONS];
double Kms_PCAL_z[NMAXKAONS];
double Kms_PCAL_sector[NMAXKAONS];
double Kms_DC_sector[NMAXKAONS];
double Kms_Chi2N[NMAXKAONS];
double Kms_DC_x[NMAXKAONS][3];
double Kms_DC_y[NMAXKAONS][3];
double Kms_DC_z[NMAXKAONS][3];
double Kms_E_PCAL[NMAXKAONS];
double Kms_E_ECIN[NMAXKAONS];
double Kms_E_ECOUT[NMAXKAONS];
double ZKms[NMAXKAONS]; // hadron rest-frame energy
double ZKmsLC[NMAXKAONS]; // hadron z on the light-cone
double Kminus_Px[NMAXKAONS];
double Kminus_Py[NMAXKAONS];
double Kminus_Pz[NMAXKAONS];
double Kminus_E[NMAXKAONS];
double VKminus_X[NMAXKAONS];
double VKminus_Y[NMAXKAONS];
double VKminus_Z[NMAXKAONS];
double Kminus_qFrame_pT[NMAXKAONS]; // transverse momentum relative to q
double Kminus_qFrame_pL[NMAXKAONS]; // longitudinal momentum relative to q
double Kminus_qFrame_Theta[NMAXKAONS];
double Kminus_qFrame_Phi[NMAXKAONS];
// Output root file and tree
TFile * outFile_e_piplus, * outFile_e_piminus;
TTree * outTree_e_piplus, * outTree_e_piminus;
TFile * outFile_e_Kplus, * outFile_e_Kminus;
TTree * outTree_e_Kplus, * outTree_e_Kminus;
TFile * outFile_e_piplus_no_cuts, * outFile_e_piminus_no_cuts;
TTree * outTree_e_piplus_no_cuts, * outTree_e_piminus_no_cuts;
// Output CSV file
std::ofstream CSVfile_e_piplus, SelectedEventsCSVfile_e_piplus, SelectedEventsCSVfile_e_piplus_kinematics;
std::ofstream CSVfile_e_piminus, SelectedEventsCSVfile_e_piminus, SelectedEventsCSVfile_e_piminus_kinematics;
std::ofstream CSVfile_e_Kplus, SelectedEventsCSVfile_e_Kplus, SelectedEventsCSVfile_e_Kplus_kinematics;
std::ofstream CSVfile_e_Kminus, SelectedEventsCSVfile_e_Kminus, SelectedEventsCSVfile_e_Kminus_kinematics;
// vectors in lab-frame
TLorentzVector Beam, target, e, q, pi, K;
TLorentzVector d_rest, p_rest;
std::vector<TLorentzVector> piplus; // positive pions
std::vector<TLorentzVector> piminus; // negative pions
std::vector<TLorentzVector> Kplus; // positive Kaons
std::vector<TLorentzVector> Kminus; // negative Kaons
// reconstructed vertex position
TVector3 Ve;
std::vector<TVector3> Vpiplus;
std::vector<TVector3> Vpiminus;
std::vector<TVector3> VKplus;
std::vector<TVector3> VKminus;
// kinematics
Double_t Ebeam, omega, y, xB, Q2, xF, eta_pi;
Double_t W, W2, W_d, W2_d, M_x, M_x_d, qStar;
// MC information,
// generated quantities
TLorentzVector P_mc_particle;
TLorentzVector e_g, pi_g, q_g;
TVector3 V_mc_particle, Ve_g, Vpi_g;
Double_t e_P_g, e_Theta_g, e_Phi_g, e_Vz_g;
Double_t pi_P_g, pi_Theta_g, pi_Phi_g, pi_Vz_g, Q2_g, xB_g, omega_g, y_g;
// vectors in q-frame
TLorentzVector e_qFrame, q_qFrame;
std::vector<TLorentzVector> piplus_qFrame;
std::vector<TLorentzVector> piminus_qFrame;
std::vector<TLorentzVector> Kplus_qFrame;
std::vector<TLorentzVector> Kminus_qFrame;
// auxiliary
DCfid_SIDIS dcfid;
std::vector<region_part_ptr> electrons, neutrons, protons, gammas, deuterons;
std::vector<region_part_ptr> pipluses, piminuses;
std::vector<region_part_ptr> Kpluses, Kminuses;
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetVerbosity( int _fdebug_ ){
fdebug = _fdebug_;
aux.SetVerbosity( fdebug );
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetIsMC( bool fIsMC ){
IsMC = fIsMC;
if (Skimming=="p_uniform_distribution"){
IsMC = true;
}
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetSimPi (TString fSimPi) {
SimPi = fSimPi; // Simulated pion species
SimK = "";
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetSimK (TString fSimK) {
SimPi = "";
SimK = fSimK; // Simulated Kaon species
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetDataPath (TString fDataPath, Double_t fEbeam) {
prefix = "sidisdvcs_"; // default
if (fDataPath=="" || fDataPath=="sidisdvcs" || fDataPath=="sidis dvcs"){
// sidis-dvcs train files, used since July 2022
// (the 'usual' train files)
if (fEbeam==10.2){
DataPath = "/cache/clas12/rg-b/production/recon/spring2019/torus-1/pass1/v0/dst/train/sidisdvcs/";
} else if (fEbeam==10.4){
DataPath = "/cache/clas12/rg-b/production/recon/spring2020/torus-1/pass1/v1/dst/train/sidisdvcs/";
} else if (fEbeam==10.6){
DataPath = "/cache/clas12/rg-b/production/recon/spring2019/torus-1/pass1/v0/dst/train/sidisdvcs/";
}
prefix = "sidisdvcs_";
}
else if (fDataPath=="inclusive" || fDataPath=="inc"){
// inclusive train files, used until July 2022
// (inclusive train files were only generated in the beginning of RGB without any backup)
DataPath = "/volatile/clas12/rg-b/production/recon/spring2019/torus-1/pass1/v0/dst/train_20200610/inc/";
prefix = "inc_";
}
else if (fDataPath=="nSidis" || fDataPath=="nsidis"){
// free-p data from RGA data
// For RGA we use nSidis, they key difference is sidisdvcs has e_p > 1 GeV and nSidis has e_p > 2 GeV.
DataPath = "/cache/clas12/rg-a/production/recon/spring2019/torus-1/pass1/v1/dst/train/nSidis/";
prefix = "nSidis_";
}
else if (fDataPath=="AcceptanceCorrection"){
// GEMC simulations of "white" spectra
// i.e. (e,e'π) events with no physics generator
DataPath = "/volatile/clas12/users/ecohen/GEMC/hipo/10.2/AcceptanceCorrection/";
prefix = "p_uniform_distribution";
}
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetSkimming (TString fSkimming) {
if (fSkimming=="" || fSkimming=="SIDIS_skimming" ){
// d(e,e'π) files from RGB data
Skimming = "SIDIS_skimming";
}
else if (fSkimming=="RGA_Free_proton"){
// p(e,e'π) files from RGA data
Skimming = "RGA_Free_proton";
}
else if (fSkimming=="p_uniform_distribution"){
// (e,e'π) generated uniformly from "white" spectra with no physics
Skimming = "p_uniform_distribution";
}
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetEbeam (double fEbeam) {
// [GeV]
// RGA the enrgy was 10.6
// RGB Spring-2019 the enrgy was 10.2
// RGB Fall-2019 the enrgy was 10.4096
Ebeam = fEbeam;
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
bool CheckIfElectronPassedSelectionCuts(Double_t e_PCAL_x, Double_t e_PCAL_y,
Double_t e_PCAL_W, Double_t e_PCAL_V,
Double_t e_E_PCAL,
Double_t e_E_ECIN, Double_t e_E_ECOUT,
TLorentzVector e,
TVector3 Ve,
Double_t e_DC_sector,
Double_t e_DC_x[3],
Double_t e_DC_y[3],
Double_t e_DC_z[3],
int torusBending){
// decide if electron in event passes event selection cuts
// DC - fiducial cuts on DC
// from bandsoft_tools/skimmers/electrons.cpp,
// where eHit.getDC_x1() - x position in first region of the drift chamber
// same for y1,x2,y2,...
// eHit.getDC_sector() - sector
// checking DC Fiducials
// torusBending torus magnet bending: ( 1 = inbeding, -1 = outbending )
// sometimes the readout-sector is 0. This is funny
// Justin B. Estee (June-21): I also had this issue. I am throwing away sector 0. The way you check is plot the (x,y) coordinates of the sector and you will not see any thing. Double check me but I think it is 0.
if (e_DC_sector == 0) return false;
for (int regionIdx=0; regionIdx<3; regionIdx++) {
// DC_e_fid:
// sector: 1-6
// layer: 1-3
// bending: 0(out)/1(in)
// std::cout << "e_DC_sector: " << e_DC_sector << ", regionIdx: " << regionIdx << std::endl;
int bending = 1 ? (torusBending==-1) : 0;
bool DC_fid = dcfid.DC_fid_xy_sidis(11, // particle PID,
e_DC_x[regionIdx], // x
e_DC_y[regionIdx], // y
e_DC_sector, // sector
regionIdx+1, // layer
bending); // torus bending
if (DC_fid == false) {
return false;
}
}
if(!(true
// fiducial cuts on PCAL
//fabs(e_PCAL_x)>0
//&& fabs(e_PCAL_y)>0
&& e_PCAL_W > aux.cutValue_e_PCAL_W
&& e_PCAL_V > aux.cutValue_e_PCAL_V
// Electron Identification Refinement - PCAL Minimum Energy Deposition Cut
&& e_E_PCAL > aux.cutValue_e_E_PCAL
// Sampling fraction cut
&& ((e_E_PCAL + e_E_ECIN + e_E_ECOUT)/e.P()) > aux.cutValue_SamplingFraction_min
&& (e_E_ECIN/e.P() > aux.cutValue_PCAL_ECIN_SF_min - e_E_PCAL/e.P()) // RGA AN puts "<" here mistakenly
// Cut on z-vertex position: in-bending torus field -13.0 cm < Vz < +12.0 cm
// Spring 19 and Spring 2020 in-bending.
// Fall 2019 (without low-energy-run) was out-bending.
&& ((aux.cutValue_Vz_min < Ve.Z()) && (Ve.Z() < aux.cutValue_Vz_max))
)) return false;
return true;
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
bool CheckIfPionPassedSelectionCuts(TString pionCharge, // "pi+" or "pi-"
Double_t DC_sector,
Double_t DC_x[3], Double_t DC_y[3], Double_t DC_z[3],
Double_t chi2PID, Double_t p,
TVector3 Ve,
TVector3 Vpi,
int fdebug){
// decide if pion (pi+ or pi-) passed event selection cuts
//
// input:
// --------
// DC_x, DC_y pi drift-chamber coordinates
// chi2PID pi chi2PID (pips_chi2PID)
// p pi momentum (pi.P())
//
// comments
// ---------------
// DC - fiducial cuts on DC
if (fdebug>3) {
std::cout << "CheckIfPionPassedSelectionCuts()" << std::endl;
}
if (DC_sector == 0) { if (fdebug>2){std::cout << "DC_sector=0 (funny...)" << std::endl;} return false;}
int PDGcode;
double C;
if (pionCharge=="pi+"){
PDGcode = 211;
C = 0.88;
} else if (pionCharge=="pi-") {
PDGcode = -211;
C = 0.93;
} else {
std::cout << "π charge ill-defined, returning false" << std::endl;
return false;
}
for (int regionIdx=0; regionIdx<3; regionIdx++) {
// DC_e_fid:
// sector: 1-6
// layer: 1-3
// bending: 0(out)/1(in)
int bending = 1 ? (torusBending==-1) : 0;
// new version Aug-11,2021
if (fdebug>3) {
std::cout << "dcfid.DC_fid_th_ph_sidis(): "
<< DC_x[regionIdx] << ","
<< DC_y[regionIdx] << ","
<< DC_z[regionIdx] << ","
<< DC_sector << ","
<< regionIdx+1 << ","
<< bending << ","
<< std::endl;
}
bool DC_fid = dcfid.DC_fid_th_ph_sidis(PDGcode, // particle PID
DC_x[regionIdx], // x
DC_y[regionIdx], // y
DC_z[regionIdx], // z
DC_sector, // sector
regionIdx+1, // layer
bending); // torus bending
if (DC_fid == false) {
return false;
}
}
if (fdebug>3) {
std::cout << "in CheckIfPionPassedSelectionCuts()"<< std::endl
<< "pion charge: " << pionCharge << ","
<< "DC_x[0]: " << DC_x[0] << ","
<< "chi2PID:" << chi2PID << ","
<< "Chi2PID_pion_lowerBound( p="<<p<<", C="<<C<<" ): "
<< aux.Chi2PID_pion_lowerBound( p, C ) << ","
<< "Chi2PID_pion_upperBound( p="<<p<<", C="<<C<<" ): "
<< aux.Chi2PID_pion_upperBound( p, C ) << ","
<< "fabs((Ve-Vpi).Z()): " << fabs((Ve-Vpi).Z()) << ","
<< std::endl;
}
if(!
// pi+ Identification Refinement - chi2PID vs. momentum
(( aux.Chi2PID_pion_lowerBound( p, C ) < chi2PID
&&
chi2PID < aux.Chi2PID_pion_upperBound( p , C ) )
// Cut on the z-Vertex Difference Between Electrons and Hadrons.
&& ( fabs((Ve-Vpi).Z()) < aux.cutValue_Ve_Vpi_dz_max )
)) {
return false;
}
if (fdebug>3) { std::cout << "succesfully passed CheckIfPionPassedSelectionCuts(), return true" << std::endl; }
return true;
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
TVector3 GetParticleVertex(clas12::region_part_ptr rp){
TVector3 V(rp->par()->getVx(),
rp->par()->getVy(),
rp->par()->getVz());
return V;
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void SetLorentzVector (TLorentzVector &p4,clas12::region_part_ptr rp){
p4.SetXYZM(rp->par()->getPx(),
rp->par()->getPy(),
rp->par()->getPz(),
p4.M());
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void OpenOutputFiles (TString outfilename){
// // Create output tree
// outFile_e_piplus_no_cuts = new TFile( outfilename + "_e_piplus_no_cuts.root" ,"RECREATE");
// outTree_e_piplus_no_cuts = new TTree( "tree" , "(e,e'pi+) event information - no cuts");
// outFile_e_piminus_no_cuts = new TFile( outfilename + "_e_piminus_no_cuts.root" ,"RECREATE");
// outTree_e_piminus_no_cuts = new TTree( "tree" , "(e,e'pi+) event information - no cuts");
TString header = csvheader;
if (!IsMC){
outFile_e_piplus = new TFile( outfilename + "_e_piplus.root" ,"RECREATE");
outTree_e_piplus = new TTree( "tree" , "(e,e'pi+) event information");
outFile_e_piminus = new TFile( outfilename + "_e_piminus.root" ,"RECREATE");
outTree_e_piminus = new TTree( "tree" , "(e,e'pi-) event information");
SelectedEventsCSVfile_e_piplus_kinematics.open( outfilename + "_e_piplus_selected_eepi_kinematics.csv" );
SelectedEventsCSVfile_e_piplus_kinematics << header << std::endl;
SelectedEventsCSVfile_e_piminus_kinematics.open( outfilename + "_e_piminus_selected_eepi_kinematics.csv" );
SelectedEventsCSVfile_e_piminus_kinematics << header << std::endl;
} else if (IsMC) {
// GEMC simulation
// Create output csv files
header += csvheader_GEMCaddition;
if (SimPi=="piplus"){
outFile_e_piplus = new TFile( outfilename + "_e_piplus.root" ,"RECREATE");
outTree_e_piplus = new TTree( "tree" , "(e,e'pi+) event information");
SelectedEventsCSVfile_e_piplus_kinematics.open( outfilename + "_e_piplus_selected_eepi_kinematics.csv" );
SelectedEventsCSVfile_e_piplus_kinematics << header << std::endl;
} else if (SimPi=="piminus"){
outFile_e_piminus = new TFile( outfilename + "_e_piminus.root" ,"RECREATE");
outTree_e_piminus = new TTree( "tree" , "(e,e'pi-) event information");
SelectedEventsCSVfile_e_piminus_kinematics.open( outfilename + "_e_piminus_selected_eepi_kinematics.csv" );
SelectedEventsCSVfile_e_piminus_kinematics << header << std::endl;
}
}
if (fdebug>1) std::cout << "Done OpenOutputFiles( " << outfilename << ")" << std::endl;
}
// Oo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
void CloseOutputFiles (TString OutDataPath, TString outfilename){
// close output ROOT and CSV files
std::cout
<< "Done processesing " << Nevents_processed << " events,"
<< std::setprecision(3)
<< (float)Nevents_passed_e_cuts/Nevents_processed << " events passed e cuts,"
<< "output files ready in root/csv formats in "
<< std::endl;
// CSVfile_e_piplus .close();
// SelectedEventsCSVfile_e_piplus .close();
// CSVfile_e_piminus .close();
// SelectedEventsCSVfile_e_piminus .close();
// close output ROOT
// outFile_e_piplus_no_cuts->cd();
// outTree_e_piplus_no_cuts->Write();
// outFile_e_piplus_no_cuts->Close();
//
// outFile_e_piminus_no_cuts->cd();
// outTree_e_piminus_no_cuts->Write();
// outFile_e_piminus_no_cuts->Close();
if ((!IsMC)
||
((IsMC) && (SimPi=="piplus"))
){
SelectedEventsCSVfile_e_piplus_kinematics .close();
int Nentires_e_piplus = outTree_e_piplus -> GetEntries();
outFile_e_piplus->cd();
outTree_e_piplus->Write();
outFile_e_piplus->Close();
std::cout
<< (float)Nevents_passed_pips_cuts/Nevents_processed << " events passed π+ cuts,"
<< std::endl
<< "\t" << (float)Nevents_passed_e_pips_cuts/Nevents_processed << " passed (e,e'π+) cuts,"
<< std::endl
<< "\t\t" << (float)Nevents_passed_e_pips_kinematics_cuts/Nevents_processed << " also passed kinematical cuts,"
<< std::endl;
std::cout << "wrote " << Nentires_e_piplus << " to (e,e'π+) root file, "
<< std::endl << outFile_e_piplus -> GetName()
<< "and " << Nevents_passed_e_pips_kinematics_cuts << " to (e,e'π-) csv file (after kinematical cuts) "
<< std::endl << OutDataPath + outfilename + "_e_piplus_selected_eepi_kinematics.csv"
<< std::endl;
}
if ((!IsMC)
||
((IsMC) && (SimPi=="piminus"))
){
SelectedEventsCSVfile_e_piminus_kinematics .close();
int Nentires_e_piminus = outTree_e_piminus -> GetEntries();
outFile_e_piminus->cd();
outTree_e_piminus->Write();
outFile_e_piminus->Close();
std::cout
<< (float)Nevents_passed_pims_cuts/Nevents_processed << " events passed π- cuts,"
<< std::endl
<< "\t" << (float)Nevents_passed_e_pims_cuts/Nevents_processed << " passed (e,e'π-) cuts,"
<< std::endl
<< "\t\t" << (float)Nevents_passed_e_pims_kinematics_cuts/Nevents_processed << " also passed kinematical cuts,"
<< std::endl;
std::cout << "output files ready in root/csv formats in " << std::endl
<< std::endl
<< "wrote " << Nentires_e_piminus << " to (e,e'π-) root file. "
<< std::endl << outFile_e_piminus -> GetName()
<< "and " << Nevents_passed_e_pims_kinematics_cuts << " to (e,e'π-) csv file (after kinematical cuts) "
<< std::endl << OutDataPath + outfilename + "_e_piminus_selected_eepi_kinematics.csv"
<< std::endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int GetBeamHelicity( event_ptr p_event, int runnum, int fdebug ){
// deprecated as of Aug-11, 2021,
// since
// however we keep it here for more data
// get beam helicity (+1 along the beam and -1 opposite to it)
// [Christopher Dilks <[email protected]>, email from Aug-5, 2021]
// for more items
// [https://github.com/JeffersonLab/clas12root/blob/master/AccesssingBankDataInCpp.txt]
//// helFlip: if true, REC::Event.helicity has opposite sign from reality
//def helFlip
//if(RG=="RGA") helFlip = true
//else if(RG=="RGB") {
// helFlip = true
// if(runnum>=11093 && runnum<=11283) helFlip = false // fall, 10.4 GeV period only
// else if(runnum>=11323 && runnum<=11571) helFlip = false // winter
//};
//else if(RG=="RGK") helFlip = false
//else if(RG=="RGF") helFlip = true
if (fdebug>5) std::cout << "beam_helicity = c12.event()->getHelicity()" << std::endl;
beam_helicity = p_event->getHelicity();
if (fdebug>5) std::cout << "check spin flip" << std::endl;
// we are working here on RGB data
bool helFlip = true;
if (runnum>=11093 && runnum<=11283) helFlip = false; // falls, 10.4 GeV period only
else if (runnum>=11323 && runnum<=11571) helFlip = false; // winter
if (helFlip) {
beam_helicity = -1 * beam_helicity;
}
if (fdebug>5) std::cout << "done GetBeamHelicity() " << std::endl;
return beam_helicity;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetOutputTTrees(){
// pi+
if (fdebug>1) std::cout << "SetOutputTTrees()" << std::endl;
// pi+
if ((!IsMC)
||
(IsMC && SimPi=="piplus")){
outTree_e_piplus->Branch("eventnumber" ,&evnum );
outTree_e_piplus->Branch("runnum" ,&runnum );
outTree_e_piplus->Branch("inclusive" ,&inclusive );
outTree_e_piplus->Branch("e_E_PCAL" ,&e_E_PCAL );
outTree_e_piplus->Branch("e_E_ECIN" ,&e_E_ECIN );
outTree_e_piplus->Branch("e_E_ECOUT" ,&e_E_ECOUT );
outTree_e_piplus->Branch("e_PCAL_W" ,&e_PCAL_W );
outTree_e_piplus->Branch("e_PCAL_V" ,&e_PCAL_V );
outTree_e_piplus->Branch("e_PCAL_x" ,&e_PCAL_x );
outTree_e_piplus->Branch("e_PCAL_y" ,&e_PCAL_y );
outTree_e_piplus->Branch("e_PCAL_z" ,&e_PCAL_z );
outTree_e_piplus->Branch("e_PCAL_sector" ,&e_PCAL_sector );
outTree_e_piplus->Branch("e_DC_sector" ,&e_DC_sector );
outTree_e_piplus->Branch("e_DC_Chi2N" ,&e_DC_Chi2N );
outTree_e_piplus->Branch("e_DC_x" ,&e_DC_x , "e_DC_x[3]/D" );
outTree_e_piplus->Branch("e_DC_y" ,&e_DC_y , "e_DC_y[3]/D" );
outTree_e_piplus->Branch("e_DC_z" ,&e_DC_z , "e_DC_z[3]/D" );
outTree_e_piplus->Branch("Npi" ,&Npips );
outTree_e_piplus->Branch("pi_region" ,&pips_region , "pi_region[Npi]/I" );
outTree_e_piplus->Branch("pi_chi2PID" ,&pips_chi2PID , "pi_chi2PID[Npi]/D" );
outTree_e_piplus->Branch("pi_PCAL_x" ,&pips_PCAL_x , "pi_PCAL_x[Npi]/D" );
outTree_e_piplus->Branch("pi_PCAL_y" ,&pips_PCAL_y , "pi_PCAL_y[Npi]/D" );
outTree_e_piplus->Branch("pi_PCAL_z" ,&pips_PCAL_z , "pi_PCAL_z[Npi]/D" );
outTree_e_piplus->Branch("pi_PCAL_sector" ,&pips_PCAL_sector , "pi_PCAL_sector[Npi]/D");
outTree_e_piplus->Branch("pi_DC_sector" ,&pips_DC_sector , "pi_DC_sector[Npi]/D" );
outTree_e_piplus->Branch("pi_Chi2N" ,&pips_Chi2N , "pi_Chi2N[Npi]/D" );
outTree_e_piplus->Branch("pi_DC_x" ,&pips_DC_x , "pi_DC_x[Npi][3]/D" );
outTree_e_piplus->Branch("pi_DC_y" ,&pips_DC_y , "pi_DC_y[Npi][3]/D" );
outTree_e_piplus->Branch("pi_DC_z" ,&pips_DC_z , "pi_DC_z[Npi][3]/D" );
outTree_e_piplus->Branch("pi_E_PCAL" ,&pips_E_PCAL , "pi_E_PCAL[Npi]/D" );
outTree_e_piplus->Branch("pi_E_ECIN" ,&pips_E_ECIN , "pi_E_ECIN[Npi]/D" );
outTree_e_piplus->Branch("pi_E_ECIN" ,&pips_E_ECIN , "pi_E_ECIN[Npi]/D" );
outTree_e_piplus->Branch("pi_E_ECOUT" ,&pips_E_ECOUT , "pi_E_ECOUT[Npi]/D" );
outTree_e_piplus->Branch("DC_layers" ,&DC_layers , "DC_layers[3]/I" );
outTree_e_piplus->Branch("e" ,&e );
outTree_e_piplus->Branch("Ve" ,&Ve );
outTree_e_piplus->Branch("pi" ,&piplus );
outTree_e_piplus->Branch("Vpi" ,&Vpiplus );
outTree_e_piplus->Branch("Beam" ,&Beam );
outTree_e_piplus->Branch("beam_helicity" ,&beam_helicity );
outTree_e_piplus->Branch("q" ,&q );
outTree_e_piplus->Branch("Ebeam" ,&Ebeam );
outTree_e_piplus->Branch("xB" ,&xB );
outTree_e_piplus->Branch("Q2" ,&Q2 );
outTree_e_piplus->Branch("omega" ,&omega );
outTree_e_piplus->Branch("W_d" ,&W_d );
outTree_e_piplus->Branch("W" ,&W );
outTree_e_piplus->Branch("Z" ,Zpips );
outTree_e_piplus->Branch("Z_LC" ,ZpipsLC );
outTree_e_piplus->Branch("y" ,&y );
outTree_e_piplus->Branch("EventPassedCuts" ,&EventPassedCuts );
outTree_e_piplus->Branch("ePastCutsInEvent" ,&ePastCutsInEvent );
outTree_e_piplus->Branch("eepipsPastKinematicalCuts",&eepipsPastKinematicalCuts ,"eepipsPastKinematicalCuts[Npi]/O" );
outTree_e_piplus->Branch("piPastCutsInEvent" ,&pipsPastCutsInEvent ,"piPastCutsInEvent/O" );
outTree_e_piplus->Branch("eepipsPastCutsInEvent",&eepipsPastCutsInEvent ,"eepipsPastCutsInEvent/O" );
outTree_e_piplus->Branch("Npips" ,&Npips );
outTree_e_piplus->Branch("Npims" ,&Npims );
outTree_e_piplus->Branch("Nelectrons" ,&Ne );
outTree_e_piplus->Branch("Ngammas" ,&Ngammas );
outTree_e_piplus->Branch("Nprotons" ,&Np );
outTree_e_piplus->Branch("Nneutrons" ,&Nn );
outTree_e_piplus->Branch("piplus_Px" ,&piplus_Px , "piplus_Px[Npi]/D" );
outTree_e_piplus->Branch("piplus_Py" ,&piplus_Py , "piplus_Py[Npi]/D" );
outTree_e_piplus->Branch("piplus_Pz" ,&piplus_Pz , "piplus_Pz[Npi]/D" );
outTree_e_piplus->Branch("piplus_E" ,&piplus_E , "piplus_E[Npi]/D" );
outTree_e_piplus->Branch("Vpiplus_X" ,&Vpiplus_X , "Vpiplus_X[Npi]/D" );
outTree_e_piplus->Branch("Vpiplus_Y" ,&Vpiplus_Y , "Vpiplus_Y[Npi]/D" );
outTree_e_piplus->Branch("Vpiplus_Z" ,&Vpiplus_Z , "Vpiplus_Z[Npi]/D" );
outTree_e_piplus->Branch("piplus_qFrame_pT" ,&piplus_qFrame_pT , "piplus_qFrame_pT[Npi]/D");
outTree_e_piplus->Branch("piplus_qFrame_pL" ,&piplus_qFrame_pL , "piplus_qFrame_pL[Npi]/D");
outTree_e_piplus->Branch("piplus_qFrame_Theta" ,&piplus_qFrame_Theta , "piplus_qFrame_Theta[Npi]/D");
outTree_e_piplus->Branch("piplus_qFrame_Phi" ,&piplus_qFrame_Phi , "piplus_qFrame_Phi[Npi]/D");
}
if ((!IsMC)
||
(IsMC && SimPi=="piminus")){
outTree_e_piminus->Branch("eventnumber" ,&evnum );
outTree_e_piminus->Branch("runnum" ,&runnum );
outTree_e_piminus->Branch("inclusive" ,&inclusive );
outTree_e_piminus->Branch("e_E_PCAL" ,&e_E_PCAL );
outTree_e_piminus->Branch("e_E_ECIN" ,&e_E_ECIN );
outTree_e_piminus->Branch("e_E_ECOUT" ,&e_E_ECOUT );
outTree_e_piminus->Branch("e_PCAL_W" ,&e_PCAL_W );
outTree_e_piminus->Branch("e_PCAL_V" ,&e_PCAL_V );
outTree_e_piminus->Branch("e_PCAL_x" ,&e_PCAL_x );
outTree_e_piminus->Branch("e_PCAL_y" ,&e_PCAL_y );
outTree_e_piminus->Branch("e_PCAL_z" ,&e_PCAL_z );
outTree_e_piminus->Branch("e_PCAL_sector" ,&e_PCAL_sector );
outTree_e_piminus->Branch("e_DC_sector" ,&e_DC_sector );
outTree_e_piminus->Branch("e_DC_Chi2N" ,&e_DC_Chi2N );
outTree_e_piminus->Branch("e_DC_x" ,&e_DC_x , "e_DC_x[3]/D" );
outTree_e_piminus->Branch("e_DC_y" ,&e_DC_y , "e_DC_y[3]/D" );
outTree_e_piminus->Branch("e_DC_z" ,&e_DC_z , "e_DC_z[3]/D" );
outTree_e_piminus->Branch("Npi" ,&Npims );
outTree_e_piminus->Branch("pi_region" ,&pims_region , "pi_region[Npi]/I" );
outTree_e_piminus->Branch("pi_chi2PID" ,&pims_chi2PID , "pi_chi2PID[Npi]/D" );
outTree_e_piminus->Branch("pi_PCAL_x" ,&pims_PCAL_x , "pi_PCAL_x[Npi]/D" );
outTree_e_piminus->Branch("pi_PCAL_y" ,&pims_PCAL_y , "pi_PCAL_y[Npi]/D" );
outTree_e_piminus->Branch("pi_PCAL_z" ,&pims_PCAL_z , "pi_PCAL_z[Npi]/D" );
outTree_e_piminus->Branch("pi_PCAL_sector" ,&pims_PCAL_sector , "pi_PCAL_sector[Npi]/D" );
outTree_e_piminus->Branch("pi_DC_sector" ,&pims_DC_sector , "pi_DC_sector[Npi]/D" );
outTree_e_piminus->Branch("pi_Chi2N" ,&pims_Chi2N , "pi_Chi2N[Npi]/D" );
outTree_e_piminus->Branch("pi_DC_x" ,&pims_DC_x , "pi_DC_x[Npi][3]/D" );
outTree_e_piminus->Branch("pi_DC_y" ,&pims_DC_y , "pi_DC_y[Npi][3]/D" );
outTree_e_piminus->Branch("pi_DC_z" ,&pims_DC_z , "pi_DC_z[Npi][3]/D" );
outTree_e_piminus->Branch("pi_E_PCAL" ,&pims_E_PCAL , "pi_E_PCAL[Npi]/D" );
outTree_e_piminus->Branch("pi_E_ECIN" ,&pims_E_ECIN , "pi_E_ECIN[Npi]/D" );
outTree_e_piminus->Branch("pi_E_ECIN" ,&pims_E_ECIN , "pi_E_ECIN[Npi]/D" );
outTree_e_piminus->Branch("pi_E_ECOUT" ,&pims_E_ECOUT , "pi_E_ECOUT[Npi]/D" );
outTree_e_piminus->Branch("DC_layers" ,&DC_layers , "DC_layers[3]" );
outTree_e_piminus->Branch("e" ,&e );
outTree_e_piminus->Branch("pi" ,&piminus );
outTree_e_piminus->Branch("Ve" ,&Ve );
outTree_e_piminus->Branch("Vpi" ,&Vpiminus );
outTree_e_piminus->Branch("Beam" ,&Beam );
outTree_e_piminus->Branch("beam_helicity" ,&beam_helicity );
outTree_e_piminus->Branch("q" ,&q );
outTree_e_piminus->Branch("Ebeam" ,&Ebeam );
outTree_e_piminus->Branch("xB" ,&xB );
outTree_e_piminus->Branch("Q2" ,&Q2 );
outTree_e_piminus->Branch("omega" ,&omega );
outTree_e_piminus->Branch("W_d" ,&W_d );
outTree_e_piminus->Branch("W" ,&W );
outTree_e_piminus->Branch("Z" ,Zpims );
outTree_e_piminus->Branch("Z_LC" ,ZpimsLC );
outTree_e_piminus->Branch("y" ,&y );
outTree_e_piminus->Branch("EventPassedCuts" ,&EventPassedCuts );
outTree_e_piminus->Branch("ePastCutsInEvent" ,&ePastCutsInEvent );
outTree_e_piminus->Branch("eepimsPastKinematicalCuts",&eepimsPastKinematicalCuts ,"eepimsPastKinematicalCuts[Npi]/O" );
outTree_e_piminus->Branch("piPastCutsInEvent" ,&pimsPastCutsInEvent ,"piPastCutsInEvent/O" );
outTree_e_piminus->Branch("eepimsPastCutsInEvent",&eepimsPastCutsInEvent ,"eepimsPastCutsInEvent/O" );
outTree_e_piminus->Branch("Npips" ,&Npips );
outTree_e_piminus->Branch("Npims" ,&Npims );
outTree_e_piminus->Branch("Nelectrons" ,&Ne );
outTree_e_piminus->Branch("Ngammas" ,&Ngammas );
outTree_e_piminus->Branch("Nprotons" ,&Np );
outTree_e_piminus->Branch("Nneutrons" ,&Nn );
outTree_e_piminus->Branch("piminus_Px" ,&piminus_Px , "piminus_Px[Npi]/D" );
outTree_e_piminus->Branch("piminus_Py" ,&piminus_Py , "piminus_Py[Npi]/D" );
outTree_e_piminus->Branch("piminus_Pz" ,&piminus_Pz , "piminus_Pz[Npi]/D" );
outTree_e_piminus->Branch("piminus_E" ,&piminus_E , "piminus_E[Npi]/D" );
outTree_e_piminus->Branch("Vpiminus_X" ,&Vpiminus_X , "Vpiminus_X[Npi]/D" );
outTree_e_piminus->Branch("Vpiminus_Y" ,&Vpiminus_Y , "Vpiminus_Y[Npi]/D" );
outTree_e_piminus->Branch("Vpiminus_Z" ,&Vpiminus_Z , "Vpiminus_Z[Npi]/D" );
outTree_e_piminus->Branch("piminus_qFrame_pT" ,&piminus_qFrame_pT , "piminus_qFrame_pT[Npi]/D");
outTree_e_piminus->Branch("piminus_qFrame_pL" ,&piminus_qFrame_pL , "piminus_qFrame_pL[Npi]/D");
outTree_e_piminus->Branch("piminus_qFrame_Theta" ,&piminus_qFrame_Theta , "piminus_qFrame_Theta[Npi]/D");
outTree_e_piminus->Branch("piminus_qFrame_Phi" ,&piminus_qFrame_Phi , "piminus_qFrame_Phi[Npi]/D");
}
if (fdebug>1) std::cout << "Done SetOutputTTrees()" << std::endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void InitializeFileReading(int NeventsMax, int c12Nentries, int fdebug){
if (fdebug>1) {
std::cout << "InitializeFileReading( " << NeventsMax << " , " << c12Nentries << " , " << fdebug << ")" << std::endl;
}
// Ebeam = GetBeamEnergy ( fdebug );
Beam .SetPxPyPzE (0, 0, Ebeam, Ebeam );
target .SetXYZM (0, 0, 0, aux.Md );
d_rest .SetXYZM (0, 0, 0, aux.Md );
p_rest .SetXYZM (0, 0, 0, aux.Mp );
NeventsMaxToProcess = NeventsMax;
if (NeventsMax<0) NeventsMaxToProcess = c12Nentries;
Nevents_processed = 0;
Nevents_passed_e_cuts = 0;
Nevents_passed_pips_cuts = 0;
Nevents_passed_pims_cuts = 0;
Nevents_passed_e_pips_cuts = 0;
Nevents_passed_e_pims_cuts = 0;
Nevents_passed_e_pips_kinematics_cuts = 0;
Nevents_passed_e_pims_kinematics_cuts = 0;
if (fdebug>1) {
std::cout << "NeventsMaxToProcess = " << NeventsMaxToProcess << "" << std::endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void InitializeVariables(){
e = TLorentzVector(0,0,0,db->GetParticle( 11 )->Mass());
qStar = -9999;
xB = Q2 = omega = -9999;
xF = y = -9999;
xB_g = Q2_g = omega_g = -9999;
y_g = -9999;
W_d = W = -9999;
M_x = M_x_d = -9999;
e_E_ECIN = e_E_ECOUT = e_E_PCAL = -9999;
e_PCAL_W = e_PCAL_V = -9999;
e_PCAL_x = e_PCAL_y = e_PCAL_z = -9999;
e_PCAL_sector = -9999;
e_DC_sector = e_DC_Chi2N = -9999;
for (int regionIdx=0; regionIdx<3; regionIdx++) {
e_DC_x[regionIdx] = -9999;
e_DC_y[regionIdx] = -9999;
e_DC_z[regionIdx] = -9999;
}
Pe_phi = q_phi = q_theta = 0;
Ve = TVector3();
ePastCutsInEvent = false;
electrons .clear();
neutrons .clear();
protons .clear();