forked from AlexDeMoor/DeepJet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpostprocessor_2d.cpp
More file actions
998 lines (879 loc) · 49.3 KB
/
postprocessor_2d.cpp
File metadata and controls
998 lines (879 loc) · 49.3 KB
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
// Remember that to compile w/ g++ you need -> g++ postprocessor_2d.cpp -o postprocessor_2d.exe `root-config --cflags --glibs`
// Note: This should be compiled after sourcing FCCAnalyses' setup.sh so it can be run directly after without having to reset the env.
// This code is a barbaric way of reshaping <vectors>, I expect it to be (much) slower than coffea, but let's have a look -> it's actually much faster, go figure!
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TRandom.h"
#include "TTree.h"
#include "TInterpreter.h"
#include <iostream>
#include <string>
#include <limits.h>
//gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");
//int main(){
//char *defaults[] = { "chunk0.root"};
int main(int argc, char** argv){
//TCHAR NPath[MAX_PATH];
//GetCurrentDirectory(MAX_PATH, NPath);
char buffer[PATH_MAX-1];
getcwd(buffer, PATH_MAX-1);
std::string pwd(buffer);
std::cout<<pwd<<std::endl;
//TInterpreter *ggInterpreter;
gInterpreter->GenerateDictionary("vector<vector<float>>", "vector");
gInterpreter->GenerateDictionary("vector<vector<double>>", "vector");
gInterpreter->GenerateDictionary("vector<vector<int>>", "vector");
std::string fname = "placeholder";
std::string flav_type = "";
if(argc<2){
//std::cout<<"Please input file and flav type (uds, cc, bb)!"<<std::endl;
std::cout<<"Please input file!"<<std::endl;
return 1;
}
//if(argc=2) fname = argv[1];
//fname = "/afs/cern.ch/user/e/eploerer/private/FCCAna_01122021/FCCAnalyses/outputs/FCCee/TNtupler/p8_ee_Zuds_ecm91.root";//argv[1];
fname = argv[1];
//////////flav_type = argv[2];
//std::cout<<fname[fname.size()-2]<<fname[fname.size()-1]<<fname[fname.size()]<<std::endl;
TFile *f = new TFile(fname.c_str()); // new moves object to heap as described here: https://stackoverflow.com/questions/655065/when-should-i-use-the-new-keyword-in-c
//TTree *t1 = (TTree*)f->Get("deepntuplizer/tree");
TTree *t1 = (TTree*)f->Get("events");
Int_t nentries = (Int_t)t1->GetEntries();
std::cout<<"The number of events is "<<nentries<<std::endl;
//Jet Flavour
std::vector<int> *isU = new std::vector<int>;
std::vector<int> *isD = new std::vector<int>;
std::vector<int> *isS = new std::vector<int>;
std::vector<int> *isC = new std::vector<int>;
std::vector<int> *isB = new std::vector<int>;
std::vector<int> *isUndefined = new std::vector<int>;
std::vector<int> *isU_ghost = new std::vector<int>;
std::vector<int> *isD_ghost = new std::vector<int>;
std::vector<int> *isS_ghost = new std::vector<int>;
std::vector<int> *isC_ghost = new std::vector<int>;
std::vector<int> *isB_ghost = new std::vector<int>;
std::vector<int> *isUndefined_ghost = new std::vector<int>;
std::vector<int> *isU_Z = new std::vector<int>;
std::vector<int> *isD_Z = new std::vector<int>;
std::vector<int> *isS_Z = new std::vector<int>;
std::vector<int> *isC_Z = new std::vector<int>;
std::vector<int> *isB_Z = new std::vector<int>;
std::vector<int> *isUndefined_Z = new std::vector<int>;
std::vector<int> *isU_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isD_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isS_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isC_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isB_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isUndefined_ghost_angle03status70 = new std::vector<int>;
std::vector<int> *isU_ghost_angle03status20 = new std::vector<int>;
std::vector<int> *isD_ghost_angle03status20 = new std::vector<int>;
std::vector<int> *isS_ghost_angle03status20 = new std::vector<int>;
std::vector<int> *isC_ghost_angle03status20 = new std::vector<int>;
std::vector<int> *isB_ghost_angle03status20 = new std::vector<int>;
std::vector<int> *isUndefined_ghost_angle03status20 = new std::vector<int>;
//std::vector<int> *Z_flavour = new std::vector<int>;
//Jet-level variables
std::vector<float> *jets_p = new std::vector<float>;
std::vector<float> *jets_px = new std::vector<float>;
std::vector<float> *jets_py = new std::vector<float>;
std::vector<float> *jets_pz = new std::vector<float>;
std::vector<float> *jets_theta = new std::vector<float>;
std::vector<float> *jets_phi = new std::vector<float>;
std::vector<float> *jets_m = new std::vector<float>;
std::vector<float> *jets_e = new std::vector<float>;
std::vector<float> *jets_nRP_charged = new std::vector<float>;
std::vector<float> *jets_nRP_neutral = new std::vector<float>;
std::vector<float> *jets_pt = new std::vector<float>;
std::vector<float> *jets_eta = new std::vector<float>;
std::vector<float> *jets_angularity_00 = new std::vector<float>;
std::vector<float> *jets_angularity_105 = new std::vector<float>;
std::vector<float> *jets_angularity_11 = new std::vector<float>;
std::vector<float> *jets_angularity_12 = new std::vector<float>;
std::vector<float> *jets_angularity_20 = new std::vector<float>;
//Charged-constituent variables
std::vector<std::vector<float>> *RPj_charged_p = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_theta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_phi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_mass = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_charge = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_Z0 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_D0 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_Z0_sig = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_D0_sig = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_Curv = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_pRel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_eRel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_dTheta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_dPhi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_dR = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_p_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_pRel_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_e_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_eRel_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_dAngle = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_isMuon = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_isElectron = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_isPion = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_isProton = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_PID = new std::vector<std::vector<float>>;
//Charged-constituent PID variables
std::vector<std::vector<float>> *RPj_charged_is_S = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform080 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform090 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform095 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform060 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform040 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform020 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform000 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_charged_is_Kaon_smearedUniform100 = new std::vector<std::vector<float>>;
//Neutral-constituent variables
std::vector<std::vector<float>> *RPj_neutral_p = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_theta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_phi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_mass = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_pRel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_eRel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_dTheta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_dPhi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_dR = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_p_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_pRel_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_e_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_eRel_log = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_dAngle = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_isPhoton = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_isKlong = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_isNeutron = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *RPj_neutral_isNPion = new std::vector<std::vector<float>>;
//SV variables
std::vector<std::vector<float>> *sv_mass = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_p = new std::vector<std::vector<float>>;
std::vector<std::vector<int>> *sv_ntracks = new std::vector<std::vector<int>>;
std::vector<std::vector<float>> *sv_chi2 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_normchi2 = new std::vector<std::vector<float>>;
std::vector<std::vector<int>> *sv_ndf = new std::vector<std::vector<int>>;
std::vector<std::vector<float>> *sv_theta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_phi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_thetarel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_phirel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_costhetasvpv = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_dxy = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *sv_d3d = new std::vector<std::vector<float>>;
//V0 variables
std::vector<std::vector<float>> *v0_pid = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_mass = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_p = new std::vector<std::vector<float>>;
std::vector<std::vector<int>> *v0_ntracks = new std::vector<std::vector<int>>;
std::vector<std::vector<float>> *v0_chi2 = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_normchi2 = new std::vector<std::vector<float>>;
std::vector<std::vector<int>> *v0_ndf = new std::vector<std::vector<int>>;
std::vector<std::vector<float>> *v0_theta = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_phi = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_thetarel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_phirel = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_costhetasvpv = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_dxy = new std::vector<std::vector<float>>;
std::vector<std::vector<float>> *v0_d3d = new std::vector<std::vector<float>>;
//std::vector<std::vector<float>> *Cpfcan_BtagPf_trackPtRel = new std::vector<std::vector<float>>;
//std::vector<float,ROOT::Detail::VecOps::RAdoptAllocator<float>> jets_p;
t1->SetEntries(nentries);
//t1->SetBranchAddress("jets_p",&jets_p);
t1->SetBranchAddress("isU",&isU);
t1->SetBranchAddress("isD",&isD);
t1->SetBranchAddress("isS",&isS);
t1->SetBranchAddress("isC",&isC);
t1->SetBranchAddress("isB",&isB);
t1->SetBranchAddress("isUndefined",&isUndefined);
t1->SetBranchAddress("isU_ghost",&isU_ghost);
t1->SetBranchAddress("isD_ghost",&isD_ghost);
t1->SetBranchAddress("isS_ghost",&isS_ghost);
t1->SetBranchAddress("isC_ghost",&isC_ghost);
t1->SetBranchAddress("isB_ghost",&isB_ghost);
t1->SetBranchAddress("isUndefined_ghost",&isUndefined_ghost);
t1->SetBranchAddress("isU_Z",&isU_Z);
t1->SetBranchAddress("isD_Z",&isD_Z);
t1->SetBranchAddress("isS_Z",&isS_Z);
t1->SetBranchAddress("isC_Z",&isC_Z);
t1->SetBranchAddress("isB_Z",&isB_Z);
t1->SetBranchAddress("isUndefined_Z",&isUndefined_Z);
t1->SetBranchAddress("isU_ghost_angle03status70",&isU_ghost_angle03status70);
t1->SetBranchAddress("isD_ghost_angle03status70",&isD_ghost_angle03status70);
t1->SetBranchAddress("isS_ghost_angle03status70",&isS_ghost_angle03status70);
t1->SetBranchAddress("isC_ghost_angle03status70",&isC_ghost_angle03status70);
t1->SetBranchAddress("isB_ghost_angle03status70",&isB_ghost_angle03status70);
t1->SetBranchAddress("isUndefined_ghost_angle03status70",&isUndefined_ghost_angle03status70);
t1->SetBranchAddress("isU_ghost_angle03status20",&isU_ghost_angle03status20);
t1->SetBranchAddress("isD_ghost_angle03status20",&isD_ghost_angle03status20);
t1->SetBranchAddress("isS_ghost_angle03status20",&isS_ghost_angle03status20);
t1->SetBranchAddress("isC_ghost_angle03status20",&isC_ghost_angle03status20);
t1->SetBranchAddress("isB_ghost_angle03status20",&isB_ghost_angle03status20);
t1->SetBranchAddress("isUndefined_ghost_angle03status20",&isUndefined_ghost_angle03status20);
//t1->SetBranchAddress("Z_flavour",&Z_flavour);
t1->SetBranchAddress("jets_p",&jets_p);
t1->SetBranchAddress("jets_px",&jets_px);
t1->SetBranchAddress("jets_py",&jets_py);
t1->SetBranchAddress("jets_pz",&jets_pz);
t1->SetBranchAddress("jets_theta",&jets_theta);
t1->SetBranchAddress("jets_phi",&jets_phi);
t1->SetBranchAddress("jets_m",&jets_m);
t1->SetBranchAddress("jets_e",&jets_e);
t1->SetBranchAddress("jets_nRP_charged",&jets_nRP_charged);
t1->SetBranchAddress("jets_nRP_neutral",&jets_nRP_neutral);
t1->SetBranchAddress("jets_pt",&jets_pt);
t1->SetBranchAddress("jets_eta",&jets_eta);
t1->SetBranchAddress("jets_angularity_00",&jets_angularity_00);
t1->SetBranchAddress("jets_angularity_105",&jets_angularity_105);
t1->SetBranchAddress("jets_angularity_11",&jets_angularity_11);
t1->SetBranchAddress("jets_angularity_12",&jets_angularity_12);
t1->SetBranchAddress("jets_angularity_20",&jets_angularity_20);
t1->SetBranchAddress("RPj_charged_p",&RPj_charged_p);
t1->SetBranchAddress("RPj_charged_theta",&RPj_charged_theta);
t1->SetBranchAddress("RPj_charged_phi",&RPj_charged_phi);
t1->SetBranchAddress("RPj_charged_mass",&RPj_charged_mass);
t1->SetBranchAddress("RPj_charged_charge",&RPj_charged_charge);
t1->SetBranchAddress("RPj_charged_Z0",&RPj_charged_Z0);
t1->SetBranchAddress("RPj_charged_D0",&RPj_charged_D0);
t1->SetBranchAddress("RPj_charged_Z0_sig",&RPj_charged_Z0_sig);
t1->SetBranchAddress("RPj_charged_D0_sig",&RPj_charged_D0_sig);
t1->SetBranchAddress("RPj_charged_Curv",&RPj_charged_Curv);
t1->SetBranchAddress("RPj_charged_pRel",&RPj_charged_pRel);
t1->SetBranchAddress("RPj_charged_eRel",&RPj_charged_eRel);
t1->SetBranchAddress("RPj_charged_dTheta",&RPj_charged_dTheta);
t1->SetBranchAddress("RPj_charged_dPhi",&RPj_charged_dPhi);
t1->SetBranchAddress("RPj_charged_dR",&RPj_charged_dR);
t1->SetBranchAddress("RPj_charged_p_log",&RPj_charged_p_log);
t1->SetBranchAddress("RPj_charged_pRel_log",&RPj_charged_pRel_log);
t1->SetBranchAddress("RPj_charged_e_log",&RPj_charged_e_log);
t1->SetBranchAddress("RPj_charged_eRel_log",&RPj_charged_eRel_log);
t1->SetBranchAddress("RPj_charged_dAngle",&RPj_charged_dAngle);
t1->SetBranchAddress("RPj_charged_isMuon",&RPj_charged_isMuon);
t1->SetBranchAddress("RPj_charged_isElectron",&RPj_charged_isElectron);
t1->SetBranchAddress("RPj_charged_isPion",&RPj_charged_isPion);
t1->SetBranchAddress("RPj_charged_isProton",&RPj_charged_isProton);
t1->SetBranchAddress("RPj_charged_PID",&RPj_charged_PID);
t1->SetBranchAddress("RPj_charged_is_S",&RPj_charged_is_S);
t1->SetBranchAddress("RPj_charged_is_Kaon",&RPj_charged_is_Kaon);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform080",&RPj_charged_is_Kaon_smearedUniform080);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform090",&RPj_charged_is_Kaon_smearedUniform090);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform095",&RPj_charged_is_Kaon_smearedUniform095);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform060",&RPj_charged_is_Kaon_smearedUniform060);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform040",&RPj_charged_is_Kaon_smearedUniform040);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform020",&RPj_charged_is_Kaon_smearedUniform020);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform000",&RPj_charged_is_Kaon_smearedUniform000);
t1->SetBranchAddress("RPj_charged_is_Kaon_smearedUniform100",&RPj_charged_is_Kaon_smearedUniform100);
t1->SetBranchAddress("RPj_neutral_p",&RPj_neutral_p);
t1->SetBranchAddress("RPj_neutral_theta",&RPj_neutral_theta);
t1->SetBranchAddress("RPj_neutral_phi",&RPj_neutral_phi);
t1->SetBranchAddress("RPj_neutral_mass",&RPj_neutral_mass);
t1->SetBranchAddress("RPj_neutral_pRel",&RPj_neutral_pRel);
t1->SetBranchAddress("RPj_neutral_eRel",&RPj_neutral_eRel);
t1->SetBranchAddress("RPj_neutral_dTheta",&RPj_neutral_dTheta);
t1->SetBranchAddress("RPj_neutral_dPhi",&RPj_neutral_dPhi);
t1->SetBranchAddress("RPj_neutral_dR",&RPj_neutral_dR);
t1->SetBranchAddress("RPj_neutral_p_log",&RPj_neutral_p_log);
t1->SetBranchAddress("RPj_neutral_pRel_log",&RPj_neutral_pRel_log);
t1->SetBranchAddress("RPj_neutral_e_log",&RPj_neutral_e_log);
t1->SetBranchAddress("RPj_neutral_eRel_log",&RPj_neutral_eRel_log);
t1->SetBranchAddress("RPj_neutral_dAngle",&RPj_neutral_dAngle);
t1->SetBranchAddress("RPj_neutral_isPhoton",&RPj_neutral_isPhoton);
t1->SetBranchAddress("RPj_neutral_isKlong",&RPj_neutral_isKlong);
t1->SetBranchAddress("RPj_neutral_isNeutron",&RPj_neutral_isNeutron);
t1->SetBranchAddress("RPj_neutral_isNPion",&RPj_neutral_isNPion);
t1->SetBranchAddress("sv_mass",&sv_mass);
t1->SetBranchAddress("sv_p",&sv_p);
t1->SetBranchAddress("sv_ntracks",&sv_ntracks);
t1->SetBranchAddress("sv_chi2",&sv_chi2);
t1->SetBranchAddress("sv_normchi2",&sv_normchi2);
t1->SetBranchAddress("sv_ndf",&sv_ndf);
t1->SetBranchAddress("sv_theta",&sv_theta);
t1->SetBranchAddress("sv_phi",&sv_phi);
t1->SetBranchAddress("sv_thetarel",&sv_thetarel);
t1->SetBranchAddress("sv_phirel",&sv_phirel);
t1->SetBranchAddress("sv_costhetasvpv",&sv_costhetasvpv);
t1->SetBranchAddress("sv_dxy",&sv_dxy);
t1->SetBranchAddress("sv_d3d",&sv_d3d);
t1->SetBranchAddress("v0_pid",&v0_pid);
t1->SetBranchAddress("v0_mass",&v0_mass);
t1->SetBranchAddress("v0_p",&v0_p);
t1->SetBranchAddress("v0_ntracks",&v0_ntracks);
t1->SetBranchAddress("v0_chi2",&v0_chi2);
t1->SetBranchAddress("v0_normchi2",&v0_normchi2);
t1->SetBranchAddress("v0_ndf",&v0_ndf);
t1->SetBranchAddress("v0_theta",&v0_theta);
t1->SetBranchAddress("v0_phi",&v0_phi);
t1->SetBranchAddress("v0_thetarel",&v0_thetarel);
t1->SetBranchAddress("v0_phirel",&v0_phirel);
t1->SetBranchAddress("v0_costhetasvpv",&v0_costhetasvpv);
t1->SetBranchAddress("v0_dxy",&v0_dxy);
t1->SetBranchAddress("v0_d3d",&v0_d3d);
//Not sure why but this has to stay here or the code fails...
t1->GetEntry(10);
fname.resize(fname.size()-5);
//fname=fname+"_"+flav_type+".root";//+"_uds.root";
fname=fname+".root";//+"_uds.root";
std::string fname_buffer;
for(auto& i : fname){
if(i=='/') {fname_buffer = {}; continue;}
fname_buffer.push_back(i);
}
// SOME NASTY EOS HARDCODING
pwd = "/eos/user/e/eploerer/DeepJet_sourceFiles/tmp/";
if (argc==3) pwd = argv[2];
fname_buffer = pwd+fname_buffer;
//TFile newfile("ntuple_short.root", "recreate");
TFile *ntuple = new TFile(fname_buffer.c_str(),"recreate");
TDirectory *deepntuplizer = ntuple->mkdir("deepntuplizer");
deepntuplizer->cd(); // make the "tof" directory the current directory
Int_t lenVar;
Int_t event_index, jet_index;
Int_t isU_;
Int_t isD_;
Int_t isS_;
Int_t isC_;
Int_t isB_;
Int_t isUndefined_;
Int_t isU_ghost_;
Int_t isD_ghost_;
Int_t isS_ghost_;
Int_t isC_ghost_;
Int_t isB_ghost_;
Int_t isUndefined_ghost_;
Int_t isU_Z_;
Int_t isD_Z_;
Int_t isS_Z_;
Int_t isC_Z_;
Int_t isB_Z_;
Int_t isUndefined_Z_;
Int_t isU_ghost_angle03status70_;
Int_t isD_ghost_angle03status70_;
Int_t isS_ghost_angle03status70_;
Int_t isC_ghost_angle03status70_;
Int_t isB_ghost_angle03status70_;
Int_t isUndefined_ghost_angle03status70_;
Int_t isU_ghost_angle03status20_;
Int_t isD_ghost_angle03status20_;
Int_t isS_ghost_angle03status20_;
Int_t isC_ghost_angle03status20_;
Int_t isB_ghost_angle03status20_;
Int_t isUndefined_ghost_angle03status20_;
//Int_t Z_flavour_;
Float_t jets_p_;
Float_t jets_px_;
Float_t jets_py_;
Float_t jets_pz_;
Float_t jets_theta_;
Float_t jets_phi_;
Float_t jets_m_;
Float_t jets_e_;
Float_t jets_nRP_charged_;
Float_t jets_nRP_neutral_;
Float_t jets_angularity_00_;
Float_t jets_angularity_105_;
Float_t jets_angularity_11_;
Float_t jets_angularity_12_;
Float_t jets_angularity_20_;
Int_t nCRP;
Int_t nNRP;
Int_t nSV;
Int_t nV0;
Float_t jets_pt_;
Float_t jets_eta_;
//Note that the below version was me trying to convert vectors to arrays cleverly. I gave up pretty quickly because the code is already fast...
//std::vector<float> RPj_charged_p_;
Float_t RPj_charged_p_[100];
Float_t RPj_charged_theta_[100];
Float_t RPj_charged_phi_[100];
Float_t RPj_charged_mass_[100];
Float_t RPj_charged_charge_[100];
Float_t RPj_charged_Z0_[100];
Float_t RPj_charged_D0_[100];
Float_t RPj_charged_Z0_sig_[100];
Float_t RPj_charged_D0_sig_[100];
Float_t RPj_charged_Curv_[100];
Float_t RPj_charged_pRel_[100];
Float_t RPj_charged_eRel_[100];
Float_t RPj_charged_dTheta_[100];
Float_t RPj_charged_dPhi_[100];
Float_t RPj_charged_dR_[100];
Float_t RPj_charged_p_log_[100];
Float_t RPj_charged_pRel_log_[100];
Float_t RPj_charged_e_log_[100];
Float_t RPj_charged_eRel_log_[100];
Float_t RPj_charged_dAngle_[100];
Float_t RPj_charged_isMuon_[100];
Float_t RPj_charged_isElectron_[100];
Float_t RPj_charged_isPion_[100];
Float_t RPj_charged_isProton_[100];
Float_t RPj_charged_PID_[100];
Float_t RPj_charged_is_S_[100];
Float_t RPj_charged_is_Kaon_[100];
Float_t RPj_charged_is_Kaon_smearedUniform080_[100];
Float_t RPj_charged_is_Kaon_smearedUniform090_[100];
Float_t RPj_charged_is_Kaon_smearedUniform095_[100];
Float_t RPj_charged_is_Kaon_smearedUniform060_[100];
Float_t RPj_charged_is_Kaon_smearedUniform040_[100];
Float_t RPj_charged_is_Kaon_smearedUniform020_[100];
Float_t RPj_charged_is_Kaon_smearedUniform000_[100];
Float_t RPj_charged_is_Kaon_smearedUniform100_[100];
Float_t RPj_neutral_p_[100];
Float_t RPj_neutral_theta_[100];
Float_t RPj_neutral_phi_[100];
Float_t RPj_neutral_mass_[100];
Float_t RPj_neutral_pRel_[100];
Float_t RPj_neutral_eRel_[100];
Float_t RPj_neutral_dTheta_[100];
Float_t RPj_neutral_dPhi_[100];
Float_t RPj_neutral_dR_[100];
Float_t RPj_neutral_p_log_[100];
Float_t RPj_neutral_pRel_log_[100];
Float_t RPj_neutral_e_log_[100];
Float_t RPj_neutral_eRel_log_[100];
Float_t RPj_neutral_dAngle_[100];
Float_t RPj_neutral_isPhoton_[100];
Float_t RPj_neutral_isKlong_[100];
Float_t RPj_neutral_isNeutron_[100];
Float_t RPj_neutral_isNPion_[100];
Float_t sv_mass_[100];
Float_t sv_p_[100];
Int_t sv_ntracks_[100];
Float_t sv_chi2_[100];
Float_t sv_normchi2_[100];
Int_t sv_ndf_[100];
Float_t sv_theta_[100];
Float_t sv_phi_[100];
Float_t sv_thetarel_[100];
Float_t sv_phirel_[100];
Float_t sv_costhetasvpv_[100];
Float_t sv_dxy_[100];
Float_t sv_d3d_[100];
Float_t v0_pid_[100];
Float_t v0_mass_[100];
Float_t v0_p_[100];
Int_t v0_ntracks_[100];
Float_t v0_chi2_[100];
Float_t v0_normchi2_[100];
Int_t v0_ndf_[100];
Float_t v0_theta_[100];
Float_t v0_phi_[100];
Float_t v0_thetarel_[100];
Float_t v0_phirel_[100];
Float_t v0_costhetasvpv_[100];
Float_t v0_dxy_[100];
Float_t v0_d3d_[100];
TTree *newtree = new TTree("tree", "flattened tree of source");
newtree->Branch("event_index", &event_index);//, "std::vector<float>");
newtree->Branch("jet_index", &jet_index);//, "std::vector<float>");
newtree->Branch("isU", &isU_);
newtree->Branch("isD", &isD_);
newtree->Branch("isS", &isS_);
newtree->Branch("isC", &isC_);
newtree->Branch("isB", &isB_);
newtree->Branch("isUndefined", &isUndefined_);
newtree->Branch("isU_ghost", &isU_ghost_);
newtree->Branch("isD_ghost", &isD_ghost_);
newtree->Branch("isS_ghost", &isS_ghost_);
newtree->Branch("isC_ghost", &isC_ghost_);
newtree->Branch("isB_ghost", &isB_ghost_);
newtree->Branch("isUndefined_ghost", &isUndefined_ghost_);
newtree->Branch("isU_Z", &isU_Z_);
newtree->Branch("isD_Z", &isD_Z_);
newtree->Branch("isS_Z", &isS_Z_);
newtree->Branch("isC_Z", &isC_Z_);
newtree->Branch("isB_Z", &isB_Z_);
newtree->Branch("isUndefined_Z", &isUndefined_Z_);
newtree->Branch("isU_ghost_angle03status70", &isU_ghost_angle03status70_);
newtree->Branch("isD_ghost_angle03status70", &isD_ghost_angle03status70_);
newtree->Branch("isS_ghost_angle03status70", &isS_ghost_angle03status70_);
newtree->Branch("isC_ghost_angle03status70", &isC_ghost_angle03status70_);
newtree->Branch("isB_ghost_angle03status70", &isB_ghost_angle03status70_);
newtree->Branch("isUndefined_ghost_angle03status70", &isUndefined_ghost_angle03status70_);
newtree->Branch("isU_ghost_angle03status20", &isU_ghost_angle03status20_);
newtree->Branch("isD_ghost_angle03status20", &isD_ghost_angle03status20_);
newtree->Branch("isS_ghost_angle03status20", &isS_ghost_angle03status20_);
newtree->Branch("isC_ghost_angle03status20", &isC_ghost_angle03status20_);
newtree->Branch("isB_ghost_angle03status20", &isB_ghost_angle03status20_);
newtree->Branch("isUndefined_ghost_angle03status20", &isUndefined_ghost_angle03status20_);
//newtree->Branch("Z_flavour", &Z_flavour_);
newtree->Branch("jets_p", &jets_p_);
newtree->Branch("jets_px", &jets_px_);
newtree->Branch("jets_py", &jets_py_);
newtree->Branch("jets_pz", &jets_pz_);
newtree->Branch("jets_theta", &jets_theta_);
newtree->Branch("jets_phi", &jets_phi_);
newtree->Branch("jets_m", &jets_m_);
newtree->Branch("jets_e", &jets_e_);
newtree->Branch("jets_nRP_charged", &jets_nRP_charged_);
newtree->Branch("jets_nRP_neutral", &jets_nRP_neutral_);
newtree->Branch("jets_angularity_00", &jets_angularity_00_);
newtree->Branch("jets_angularity_105", &jets_angularity_105_);
newtree->Branch("jets_angularity_11", &jets_angularity_11_);
newtree->Branch("jets_angularity_12", &jets_angularity_12_);
newtree->Branch("jets_angularity_20", &jets_angularity_20_);
newtree->Branch("nCRP", &nCRP, "nCRP/I");
newtree->Branch("nNRP", &nNRP, "nNRP/I");
newtree->Branch("nSV", &nSV, "nSV/I");
newtree->Branch("nV0", &nV0, "nV0/I");
newtree->Branch("jets_pt", &jets_pt_);
newtree->Branch("jets_eta", &jets_eta_);
newtree->Branch("RPj_charged_p", &RPj_charged_p_, "RPj_charged_p[nCRP]/F");
newtree->Branch("RPj_charged_theta", &RPj_charged_theta_, "RPj_charged_theta[nCRP]/F");
newtree->Branch("RPj_charged_phi", &RPj_charged_phi_, "RPj_charged_phi[nCRP]/F");
newtree->Branch("RPj_charged_mass", &RPj_charged_mass_, "RPj_charged_mass[nCRP]/F");
newtree->Branch("RPj_charged_charge", &RPj_charged_charge_, "RPj_charged_charge[nCRP]/F");
newtree->Branch("RPj_charged_Z0", &RPj_charged_Z0_, "RPj_charged_Z0[nCRP]/F");
newtree->Branch("RPj_charged_D0", &RPj_charged_D0_, "RPj_charged_D0[nCRP]/F");
newtree->Branch("RPj_charged_Z0_sig", &RPj_charged_Z0_sig_, "RPj_charged_Z0_sig[nCRP]/F");
newtree->Branch("RPj_charged_D0_sig", &RPj_charged_D0_sig_, "RPj_charged_D0_sig[nCRP]/F");
newtree->Branch("RPj_charged_Curv", &RPj_charged_Curv_, "RPj_charged_Curv[nCRP]/F");
newtree->Branch("RPj_charged_pRel", &RPj_charged_pRel_, "RPj_charged_pRel[nCRP]/F");
newtree->Branch("RPj_charged_eRel", &RPj_charged_eRel_, "RPj_charged_eRel[nCRP]/F");
newtree->Branch("RPj_charged_dTheta", &RPj_charged_dTheta_, "RPj_charged_dTheta[nCRP]/F");
newtree->Branch("RPj_charged_dPhi", &RPj_charged_dPhi_, "RPj_charged_dPhi[nCRP]/F");
newtree->Branch("RPj_charged_dR", &RPj_charged_dR_, "RPj_charged_dR[nCRP]/F");
newtree->Branch("RPj_charged_p_log", &RPj_charged_p_log_, "RPj_charged_p_log[nCRP]/F");
newtree->Branch("RPj_charged_pRel_log", &RPj_charged_pRel_log_, "RPj_charged_pRel_log[nCRP]/F");
newtree->Branch("RPj_charged_e_log", &RPj_charged_e_log_, "RPj_charged_e_log[nCRP]/F");
newtree->Branch("RPj_charged_eRel_log", &RPj_charged_eRel_log_, "RPj_charged_eRel_log[nCRP]/F");
newtree->Branch("RPj_charged_dAngle", &RPj_charged_dAngle_, "RPj_charged_dAngle[nCRP]/F");
newtree->Branch("RPj_charged_isMuon", &RPj_charged_isMuon_, "RPj_charged_isMuon[nCRP]/F");
newtree->Branch("RPj_charged_isElectron", &RPj_charged_isElectron_, "RPj_charged_isElectron[nCRP]/F");
newtree->Branch("RPj_charged_isPion", &RPj_charged_isPion_, "RPj_charged_isPion[nCRP]/F");
newtree->Branch("RPj_charged_isProton", &RPj_charged_isProton_, "RPj_charged_isProton[nCRP]/F");
newtree->Branch("RPj_charged_PID", &RPj_charged_PID_, "RPj_charged_PID[nCRP]/F");
newtree->Branch("RPj_charged_is_S", &RPj_charged_is_S_, "RPj_charged_is_S[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon", &RPj_charged_is_Kaon_, "RPj_charged_is_Kaon[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform080", &RPj_charged_is_Kaon_smearedUniform080_, "RPj_charged_is_Kaon_smearedUniform080[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform090", &RPj_charged_is_Kaon_smearedUniform090_, "RPj_charged_is_Kaon_smearedUniform090[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform095", &RPj_charged_is_Kaon_smearedUniform095_, "RPj_charged_is_Kaon_smearedUniform095[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform060", &RPj_charged_is_Kaon_smearedUniform060_, "RPj_charged_is_Kaon_smearedUniform060[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform040", &RPj_charged_is_Kaon_smearedUniform040_, "RPj_charged_is_Kaon_smearedUniform040[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform020", &RPj_charged_is_Kaon_smearedUniform020_, "RPj_charged_is_Kaon_smearedUniform020[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform000", &RPj_charged_is_Kaon_smearedUniform000_, "RPj_charged_is_Kaon_smearedUniform000[nCRP]/F");
newtree->Branch("RPj_charged_is_Kaon_smearedUniform100", &RPj_charged_is_Kaon_smearedUniform100_, "RPj_charged_is_Kaon_smearedUniform100[nCRP]/F");
newtree->Branch("RPj_neutral_p", &RPj_neutral_p_, "RPj_neutral_p[nNRP]/F");
newtree->Branch("RPj_neutral_theta", &RPj_neutral_theta_, "RPj_neutral_theta[nNRP]/F");
newtree->Branch("RPj_neutral_phi", &RPj_neutral_phi_, "RPj_neutral_phi[nNRP]/F");
newtree->Branch("RPj_neutral_mass", &RPj_neutral_mass_, "RPj_neutral_mass[nNRP]/F");
newtree->Branch("RPj_neutral_pRel", &RPj_neutral_pRel_, "RPj_neutral_pRel[nNRP]/F");
newtree->Branch("RPj_neutral_eRel", &RPj_neutral_eRel_, "RPj_neutral_eRel[nNRP]/F");
newtree->Branch("RPj_neutral_dTheta", &RPj_neutral_dTheta_, "RPj_neutral_dTheta[nNRP]/F");
newtree->Branch("RPj_neutral_dPhi", &RPj_neutral_dPhi_, "RPj_neutral_dPhi[nNRP]/F");
newtree->Branch("RPj_neutral_dR", &RPj_neutral_dR_, "RPj_neutral_dR[nNRP]/F");
newtree->Branch("RPj_neutral_p_log", &RPj_neutral_p_log_, "RPj_neutral_p_log[nNRP]/F");
newtree->Branch("RPj_neutral_pRel_log", &RPj_neutral_pRel_log_, "RPj_neutral_pRel_log[nNRP]/F");
newtree->Branch("RPj_neutral_e_log", &RPj_neutral_e_log_, "RPj_neutral_e_log[nNRP]/F");
newtree->Branch("RPj_neutral_eRel_log", &RPj_neutral_eRel_log_, "RPj_neutral_eRel_log[nNRP]/F");
newtree->Branch("RPj_neutral_dAngle", &RPj_neutral_dAngle_, "RPj_neutral_dAngle[nNRP]/F");
newtree->Branch("RPj_neutral_isPhoton", &RPj_neutral_isPhoton_, "RPj_neutral_isPhoton[nNRP]/F");
newtree->Branch("RPj_neutral_isKlong", &RPj_neutral_isKlong_, "RPj_neutral_isKlong[nNRP]/F");
newtree->Branch("RPj_neutral_isNeutron", &RPj_neutral_isNeutron_, "RPj_neutral_isNeutron[nNRP]/F");
newtree->Branch("RPj_neutral_isNPion", &RPj_neutral_isNPion_, "RPj_neutral_isNPion[nNRP]/F");
newtree->Branch("sv_mass", &sv_mass_, "sv_mass[nSV]/F");
newtree->Branch("sv_p", &sv_p_, "sv_p[nSV]/F");
newtree->Branch("sv_ntracks", &sv_ntracks_, "sv_ntracks[nSV]/F");
newtree->Branch("sv_chi2", &sv_chi2_, "sv_chi2[nSV]/F");
newtree->Branch("sv_normchi2", &sv_normchi2_, "sv_normchi2[nSV]/F");
newtree->Branch("sv_ndf", &sv_ndf_, "sv_ndf[nSV]/F");
newtree->Branch("sv_theta", &sv_theta_, "sv_theta[nSV]/F");
newtree->Branch("sv_phi", &sv_phi_, "sv_phi[nSV]/F");
newtree->Branch("sv_thetarel", &sv_thetarel_, "sv_thetarel[nSV]/F");
newtree->Branch("sv_phirel", &sv_phirel_, "sv_phirel[nSV]/F");
newtree->Branch("sv_costhetasvpv", &sv_costhetasvpv_, "sv_costhetasvpv[nSV]/F");
newtree->Branch("sv_dxy", &sv_dxy_, "sv_dxy[nSV]/F");
newtree->Branch("sv_d3d", &sv_d3d_, "sv_d3d[nSV]/F");
newtree->Branch("v0_pid", &v0_pid_, "v0_pid[nV0]/F");
newtree->Branch("v0_mass", &v0_mass_, "v0_mass[nV0]/F");
newtree->Branch("v0_p", &v0_p_, "v0_p[nV0]/F");
newtree->Branch("v0_ntracks", &v0_ntracks_, "v0_ntracks[nV0]/F");
newtree->Branch("v0_chi2", &v0_chi2_, "v0_chi2[nV0]/F");
newtree->Branch("v0_normchi2", &v0_normchi2_, "v0_normchi2[nV0]/F");
newtree->Branch("v0_ndf", &v0_ndf_, "v0_ndf[nV0]/F");
newtree->Branch("v0_theta", &v0_theta_, "v0_theta[nV0]/F");
newtree->Branch("v0_phi", &v0_phi_, "v0_phi[nV0]/F");
newtree->Branch("v0_thetarel", &v0_thetarel_, "v0_thetarel[nV0]/F");
newtree->Branch("v0_phirel", &v0_phirel_, "v0_phirel[nV0]/F");
newtree->Branch("v0_costhetasvpv", &v0_costhetasvpv_, "v0_costhetasvpv[nV0]/F");
newtree->Branch("v0_dxy", &v0_dxy_, "v0_dxy[nV0]/F");
newtree->Branch("v0_d3d", &v0_d3d_, "v0_d3d[nV0]/F");
for(int i=0; i<nentries; ++i){
t1->GetEntry(i);
if((*jets_p).size()!=2) std::cout<<"ANOMALY : nJets="<<((*jets_p).size())<<std::endl;
for(int j=0; j<(*jets_p).size(); ++j){
//for(int j=0; j<2; ++j){
event_index = i;
jet_index = j;
//std::cout<<" "<<" with size "<<(*isU).size()<<std::endl;
isU_ = (*isU)[j];
isD_ = (*isD)[j];
isS_ = (*isS)[j];
isC_ = (*isC)[j];
isB_ = (*isB)[j];
isUndefined_ = (*isUndefined)[j];
isU_ghost_ = (*isU_ghost)[j];
isD_ghost_ = (*isD_ghost)[j];
isS_ghost_ = (*isS_ghost)[j];
isC_ghost_ = (*isC_ghost)[j];
isB_ghost_ = (*isB_ghost)[j];
isUndefined_ghost_ = (*isUndefined_ghost)[j];
isU_Z_ = (*isU_Z)[j];
isD_Z_ = (*isD_Z)[j];
isS_Z_ = (*isS_Z)[j];
isC_Z_ = (*isC_Z)[j];
isB_Z_ = (*isB_Z)[j];
isUndefined_Z_ = (*isUndefined_Z)[j];
isU_ghost_angle03status70_ = (*isU_ghost_angle03status70)[j];
isD_ghost_angle03status70_ = (*isD_ghost_angle03status70)[j];
isS_ghost_angle03status70_ = (*isS_ghost_angle03status70)[j];
isC_ghost_angle03status70_ = (*isC_ghost_angle03status70)[j];
isB_ghost_angle03status70_ = (*isB_ghost_angle03status70)[j];
isUndefined_ghost_angle03status70_ = (*isUndefined_ghost_angle03status70)[j];
isU_ghost_angle03status20_ = (*isU_ghost_angle03status20)[j];
isD_ghost_angle03status20_ = (*isD_ghost_angle03status20)[j];
isS_ghost_angle03status20_ = (*isS_ghost_angle03status20)[j];
isC_ghost_angle03status20_ = (*isC_ghost_angle03status20)[j];
isB_ghost_angle03status20_ = (*isB_ghost_angle03status20)[j];
isUndefined_ghost_angle03status20_ = (*isUndefined_ghost_angle03status20)[j];
//Z_flavour_ = (*Z_flavour)[j];
jets_p_ = (*jets_p)[j];
jets_px_ = (*jets_px)[j];
jets_py_ = (*jets_py)[j];
jets_pz_ = (*jets_pz)[j];
jets_theta_ = (*jets_theta)[j];
jets_phi_ = (*jets_phi)[j];
jets_m_ = (*jets_m)[j];
jets_e_ = (*jets_e)[j];
jets_nRP_charged_ = (*jets_nRP_charged)[j];
jets_nRP_neutral_ = (*jets_nRP_neutral)[j];
jets_angularity_00_ = (*jets_angularity_00)[j];
jets_angularity_105_ = (*jets_angularity_105)[j];
jets_angularity_11_ = (*jets_angularity_11)[j];
jets_angularity_12_ = (*jets_angularity_12)[j];
jets_angularity_20_ = (*jets_angularity_20)[j];
nCRP = (*jets_nRP_charged)[j];
nNRP = (*jets_nRP_neutral)[j];
nSV = (*sv_p)[j].size();
nV0 = (*v0_p)[j].size();
//std::cout<<"nSV, nV0 = "<<nSV<<", "<<nV0<<std::endl;
jets_pt_ = (*jets_pt)[j];
jets_eta_ = (*jets_eta)[j];
std::copy((*RPj_charged_p)[j].begin(), (*RPj_charged_p)[j].end(), RPj_charged_p_);
std::copy((*RPj_charged_theta)[j].begin(), (*RPj_charged_theta)[j].end(), RPj_charged_theta_);
std::copy((*RPj_charged_phi)[j].begin(), (*RPj_charged_phi)[j].end(), RPj_charged_phi_);
std::copy((*RPj_charged_mass)[j].begin(), (*RPj_charged_mass)[j].end(), RPj_charged_mass_);
std::copy((*RPj_charged_charge)[j].begin(), (*RPj_charged_charge)[j].end(), RPj_charged_charge_);
std::copy((*RPj_charged_Z0)[j].begin(), (*RPj_charged_Z0)[j].end(), RPj_charged_Z0_);
std::copy((*RPj_charged_D0)[j].begin(), (*RPj_charged_D0)[j].end(), RPj_charged_D0_);
std::copy((*RPj_charged_Z0_sig)[j].begin(), (*RPj_charged_Z0_sig)[j].end(), RPj_charged_Z0_sig_);
std::copy((*RPj_charged_D0_sig)[j].begin(), (*RPj_charged_D0_sig)[j].end(), RPj_charged_D0_sig_);
std::copy((*RPj_charged_Curv)[j].begin(), (*RPj_charged_Curv)[j].end(), RPj_charged_Curv_);
std::copy((*RPj_charged_pRel)[j].begin(), (*RPj_charged_pRel)[j].end(), RPj_charged_pRel_);
std::copy((*RPj_charged_eRel)[j].begin(), (*RPj_charged_eRel)[j].end(), RPj_charged_eRel_);
std::copy((*RPj_charged_dTheta)[j].begin(), (*RPj_charged_dTheta)[j].end(), RPj_charged_dTheta_);
std::copy((*RPj_charged_dPhi)[j].begin(), (*RPj_charged_dPhi)[j].end(), RPj_charged_dPhi_);
std::copy((*RPj_charged_dR)[j].begin(), (*RPj_charged_dR)[j].end(), RPj_charged_dR_);
std::copy((*RPj_charged_p_log)[j].begin(), (*RPj_charged_p_log)[j].end(), RPj_charged_p_log_);
std::copy((*RPj_charged_pRel_log)[j].begin(), (*RPj_charged_pRel_log)[j].end(), RPj_charged_pRel_log_);
std::copy((*RPj_charged_e_log)[j].begin(), (*RPj_charged_e_log)[j].end(), RPj_charged_e_log_);
std::copy((*RPj_charged_eRel_log)[j].begin(), (*RPj_charged_eRel_log)[j].end(), RPj_charged_eRel_log_);
std::copy((*RPj_charged_dAngle)[j].begin(), (*RPj_charged_dAngle)[j].end(), RPj_charged_dAngle_);
std::copy((*RPj_charged_isMuon)[j].begin(), (*RPj_charged_isMuon)[j].end(), RPj_charged_isMuon_);
std::copy((*RPj_charged_isElectron)[j].begin(), (*RPj_charged_isElectron)[j].end(), RPj_charged_isElectron_);
std::copy((*RPj_charged_isPion)[j].begin(), (*RPj_charged_isPion)[j].end(), RPj_charged_isPion_);
std::copy((*RPj_charged_isProton)[j].begin(), (*RPj_charged_isProton)[j].end(), RPj_charged_isProton_);
std::copy((*RPj_charged_PID)[j].begin(), (*RPj_charged_PID)[j].end(), RPj_charged_PID_);
std::copy((*RPj_charged_is_S)[j].begin(), (*RPj_charged_is_S)[j].end(), RPj_charged_is_S_);
std::copy((*RPj_charged_is_Kaon)[j].begin(), (*RPj_charged_is_Kaon)[j].end(), RPj_charged_is_Kaon_);
std::copy((*RPj_charged_is_Kaon_smearedUniform080)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform080)[j].end(), RPj_charged_is_Kaon_smearedUniform080_);
std::copy((*RPj_charged_is_Kaon_smearedUniform090)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform090)[j].end(), RPj_charged_is_Kaon_smearedUniform090_);
std::copy((*RPj_charged_is_Kaon_smearedUniform095)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform095)[j].end(), RPj_charged_is_Kaon_smearedUniform095_);
std::copy((*RPj_charged_is_Kaon_smearedUniform060)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform060)[j].end(), RPj_charged_is_Kaon_smearedUniform060_);
std::copy((*RPj_charged_is_Kaon_smearedUniform040)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform040)[j].end(), RPj_charged_is_Kaon_smearedUniform040_);
std::copy((*RPj_charged_is_Kaon_smearedUniform020)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform020)[j].end(), RPj_charged_is_Kaon_smearedUniform020_);
std::copy((*RPj_charged_is_Kaon_smearedUniform000)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform000)[j].end(), RPj_charged_is_Kaon_smearedUniform000_);
std::copy((*RPj_charged_is_Kaon_smearedUniform100)[j].begin(), (*RPj_charged_is_Kaon_smearedUniform100)[j].end(), RPj_charged_is_Kaon_smearedUniform100_);
std::copy((*RPj_neutral_p)[j].begin(), (*RPj_neutral_p)[j].end(), RPj_neutral_p_);
std::copy((*RPj_neutral_theta)[j].begin(), (*RPj_neutral_theta)[j].end(), RPj_neutral_theta_);
std::copy((*RPj_neutral_phi)[j].begin(), (*RPj_neutral_phi)[j].end(), RPj_neutral_phi_);
std::copy((*RPj_neutral_mass)[j].begin(), (*RPj_neutral_mass)[j].end(), RPj_neutral_mass_);
std::copy((*RPj_neutral_pRel)[j].begin(), (*RPj_neutral_pRel)[j].end(), RPj_neutral_pRel_);
std::copy((*RPj_neutral_eRel)[j].begin(), (*RPj_neutral_eRel)[j].end(), RPj_neutral_eRel_);
std::copy((*RPj_neutral_dTheta)[j].begin(), (*RPj_neutral_dTheta)[j].end(), RPj_neutral_dTheta_);
std::copy((*RPj_neutral_dPhi)[j].begin(), (*RPj_neutral_dPhi)[j].end(), RPj_neutral_dPhi_);
std::copy((*RPj_neutral_dR)[j].begin(), (*RPj_neutral_dR)[j].end(), RPj_neutral_dR_);
std::copy((*RPj_neutral_p_log)[j].begin(), (*RPj_neutral_p_log)[j].end(), RPj_neutral_p_log_);
std::copy((*RPj_neutral_pRel_log)[j].begin(), (*RPj_neutral_pRel_log)[j].end(), RPj_neutral_pRel_log_);
std::copy((*RPj_neutral_e_log)[j].begin(), (*RPj_neutral_e_log)[j].end(), RPj_neutral_e_log_);
std::copy((*RPj_neutral_eRel_log)[j].begin(), (*RPj_neutral_eRel_log)[j].end(), RPj_neutral_eRel_log_);
std::copy((*RPj_neutral_dAngle)[j].begin(), (*RPj_neutral_dAngle)[j].end(), RPj_neutral_dAngle_);
std::copy((*RPj_neutral_isPhoton)[j].begin(), (*RPj_neutral_isPhoton)[j].end(), RPj_neutral_isPhoton_);
std::copy((*RPj_neutral_isKlong)[j].begin(), (*RPj_neutral_isKlong)[j].end(), RPj_neutral_isKlong_);
std::copy((*RPj_neutral_isNeutron)[j].begin(), (*RPj_neutral_isNeutron)[j].end(), RPj_neutral_isNeutron_);
std::copy((*RPj_neutral_isNPion)[j].begin(), (*RPj_neutral_isNPion)[j].end(), RPj_neutral_isNPion_);
std::copy((*sv_mass)[j].begin(), (*sv_mass)[j].end(), sv_mass_);
std::copy((*sv_p)[j].begin(), (*sv_p)[j].end(), sv_p_);
std::copy((*sv_ntracks)[j].begin(), (*sv_ntracks)[j].end(), sv_ntracks_);
std::copy((*sv_chi2)[j].begin(), (*sv_chi2)[j].end(), sv_chi2_);
std::copy((*sv_normchi2)[j].begin(), (*sv_normchi2)[j].end(), sv_normchi2_);
std::copy((*sv_ndf)[j].begin(), (*sv_ndf)[j].end(), sv_ndf_);
std::copy((*sv_theta)[j].begin(), (*sv_theta)[j].end(), sv_theta_);
std::copy((*sv_phi)[j].begin(), (*sv_phi)[j].end(), sv_phi_);
std::copy((*sv_thetarel)[j].begin(), (*sv_thetarel)[j].end(), sv_thetarel_);
std::copy((*sv_phirel)[j].begin(), (*sv_phirel)[j].end(), sv_phirel_);
std::copy((*sv_costhetasvpv)[j].begin(), (*sv_costhetasvpv)[j].end(), sv_costhetasvpv_);
std::copy((*sv_dxy)[j].begin(), (*sv_dxy)[j].end(), sv_dxy_);
std::copy((*sv_d3d)[j].begin(), (*sv_d3d)[j].end(), sv_d3d_);
std::copy((*v0_pid)[j].begin(), (*v0_pid)[j].end(), v0_pid_);
std::copy((*v0_mass)[j].begin(), (*v0_mass)[j].end(), v0_mass_);
std::copy((*v0_p)[j].begin(), (*v0_p)[j].end(), v0_p_);
std::copy((*v0_ntracks)[j].begin(), (*v0_ntracks)[j].end(), v0_ntracks_);
std::copy((*v0_chi2)[j].begin(), (*v0_chi2)[j].end(), v0_chi2_);
std::copy((*v0_normchi2)[j].begin(), (*v0_normchi2)[j].end(), v0_normchi2_);
std::copy((*v0_ndf)[j].begin(), (*v0_ndf)[j].end(), v0_ndf_);
std::copy((*v0_theta)[j].begin(), (*v0_theta)[j].end(), v0_theta_);
std::copy((*v0_phi)[j].begin(), (*v0_phi)[j].end(), v0_phi_);
std::copy((*v0_thetarel)[j].begin(), (*v0_thetarel)[j].end(), v0_thetarel_);
std::copy((*v0_phirel)[j].begin(), (*v0_phirel)[j].end(), v0_phirel_);
std::copy((*v0_costhetasvpv)[j].begin(), (*v0_costhetasvpv)[j].end(), v0_costhetasvpv_);
std::copy((*v0_dxy)[j].begin(), (*v0_dxy)[j].end(), v0_dxy_);
std::copy((*v0_d3d)[j].begin(), (*v0_d3d)[j].end(), v0_d3d_);
newtree->Fill();
}
}
//newtree->Scan("RPj_charged_p");
ntuple->Write();
delete f;
delete ntuple;
//Deleting pointers to heap vars
delete isU;
delete isD;
delete isS;
delete isC;
delete isB;
delete isUndefined;
delete isU_ghost;
delete isD_ghost;
delete isS_ghost;
delete isC_ghost;
delete isB_ghost;
delete isUndefined_ghost;
delete isU_Z;
delete isD_Z;
delete isS_Z;
delete isC_Z;
delete isB_Z;
delete isUndefined_Z;
delete isU_ghost_angle03status70;
delete isD_ghost_angle03status70;
delete isS_ghost_angle03status70;
delete isC_ghost_angle03status70;
delete isB_ghost_angle03status70;
delete isUndefined_ghost_angle03status70;
delete isU_ghost_angle03status20;
delete isD_ghost_angle03status20;
delete isS_ghost_angle03status20;
delete isC_ghost_angle03status20;
delete isB_ghost_angle03status20;
delete isUndefined_ghost_angle03status20;
//delete Z_flavour;
delete jets_p;
delete jets_px;
delete jets_py;
delete jets_pz;
delete jets_theta;
delete jets_phi;
delete jets_m;
delete jets_e;
delete jets_nRP_charged;
delete jets_nRP_neutral;
delete jets_angularity_00;
delete jets_angularity_105;
delete jets_angularity_11;
delete jets_angularity_12;
delete jets_angularity_20;
delete jets_pt;
delete jets_eta;
delete RPj_charged_p;
delete RPj_charged_theta;
delete RPj_charged_phi;
delete RPj_charged_mass;
delete RPj_charged_charge;
delete RPj_charged_Z0;
delete RPj_charged_D0;
delete RPj_charged_Z0_sig;
delete RPj_charged_D0_sig;
delete RPj_charged_Curv;
delete RPj_charged_pRel;
delete RPj_charged_eRel;
delete RPj_charged_dTheta;
delete RPj_charged_dPhi;
delete RPj_charged_dR;
delete RPj_charged_p_log;
delete RPj_charged_pRel_log;
delete RPj_charged_e_log;
delete RPj_charged_eRel_log;
delete RPj_charged_dAngle;
delete RPj_charged_isMuon;
delete RPj_charged_isElectron;
delete RPj_charged_isPion;
delete RPj_charged_isProton;
delete RPj_charged_PID;
delete RPj_charged_is_S;
delete RPj_charged_is_Kaon;
delete RPj_charged_is_Kaon_smearedUniform080;
delete RPj_charged_is_Kaon_smearedUniform090;
delete RPj_charged_is_Kaon_smearedUniform095;
delete RPj_charged_is_Kaon_smearedUniform060;
delete RPj_charged_is_Kaon_smearedUniform040;
delete RPj_charged_is_Kaon_smearedUniform020;
delete RPj_charged_is_Kaon_smearedUniform000;
delete RPj_charged_is_Kaon_smearedUniform100;
delete RPj_neutral_p;
delete RPj_neutral_theta;
delete RPj_neutral_phi;
delete RPj_neutral_mass;
delete RPj_neutral_pRel;
delete RPj_neutral_eRel;
delete RPj_neutral_dTheta;
delete RPj_neutral_dPhi;
delete RPj_neutral_dR;
delete RPj_neutral_p_log;
delete RPj_neutral_pRel_log;
delete RPj_neutral_e_log;
delete RPj_neutral_eRel_log;
delete RPj_neutral_dAngle;
delete RPj_neutral_isPhoton;
delete RPj_neutral_isKlong;
delete RPj_neutral_isNeutron;
delete RPj_neutral_isNPion;
delete sv_mass;
delete sv_p;
delete sv_ntracks;
delete sv_chi2;
delete sv_normchi2;
delete sv_ndf;
delete sv_theta;
delete sv_phi;
delete sv_thetarel;
delete sv_phirel;
delete sv_costhetasvpv;
delete sv_dxy;
delete sv_d3d;
delete v0_pid;
delete v0_mass;
delete v0_p;
delete v0_ntracks;
delete v0_chi2;
delete v0_normchi2;
delete v0_ndf;
delete v0_theta;
delete v0_phi;
delete v0_thetarel;
delete v0_phirel;
delete v0_costhetasvpv;
delete v0_dxy;
delete v0_d3d;
return 0;
}