/
PndPidCorrelator.cxx
1534 lines (1389 loc) · 47 KB
/
PndPidCorrelator.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
using namespace std;
#include "PndDetectorList.h"
#include "PndPidCorrelator.h"
#include "PndTrackID.h"
#include "PndMCTrack.h"
//#include <EicIdealTrackingCode.h>
#if _TODAY_
#include "PndTrack.h"
#include "PndSciTPoint.h"
#include "PndSciTHit.h"
#include "PndEmcBump.h"
#include "PndEmcDigi.h"
#include "PndEmcStructure.h"
#include "PndEmcXtal.h"
#include "PndEmcErrorMatrix.h"
#include "PndEmcClusterCalibrator.h"
#include "PndEmcClusterEnergySums.h"
#include "PndMdtPoint.h"
#include "PndMdtHit.h"
#include "PndMdtTrk.h"
#include "PndDrcBarPoint.h"
#include "PndDrcHit.h"
#include "PndDskParticle.h"
#include "FairTrackParH.h"
#include "FairMCApplication.h"
#include "FairRunAna.h"
#include "FairRootManager.h"
#include "FairRuntimeDb.h"
#include "TObjArray.h"
#include "TVector3.h"
#include "TGeoMatrix.h"
#include "TGeoManager.h"
#include "TSystem.h"
#include <cmath>
#endif
// ----------------------------------------------------------
// --- Interface with PidMaker and output ---
//___________________________________________________________
PndPidCorrelator::~PndPidCorrelator()
{
//
FairRootManager *fManager =FairRootManager::Instance();
fManager->Write();
#if _TODAY_
delete fEmcErrorMatrix;
#endif
}
//___________________________________________________________
PndPidCorrelator::PndPidCorrelator(/*EicIdealTrackingCode *ideal*/) :
FairTask(),
fTrackBranch("EicIdealGenTrack"),
fTrackIDBranch("EicIdealGenTrackID"),
fTrack(new TClonesArray()),
fTrackOutBranch(""),
fIdealHyp(kFALSE),
fCorrErrorProp(kTRUE),
fGeanePro(kTRUE),
fMcTrack(new TClonesArray()),
fPidHyp(0)/*,
fIdeal(ideal)*/
#if _TODAY_
, ,, fTrackID(new TClonesArray()), fTrack2(new TClonesArray()), fTrackID2(new TClonesArray()), fPidChargedCand(new TClonesArray()), fPidNeutralCand(new TClonesArray()), fMdtTrack(new TClonesArray()), fMvdHitsStrip(new TClonesArray()), fMvdHitsPixel(new TClonesArray()), fTofHit(new TClonesArray()), fTofPoint(new TClonesArray()), fFtofHit(new TClonesArray()), fFtofPoint(new TClonesArray()), fEmcCluster(new TClonesArray()), fEmcBump(new TClonesArray()), fEmcDigi(new TClonesArray()), fMdtPoint(new TClonesArray()), fMdtHit(new TClonesArray()), fMdtTrk(new TClonesArray()), fDrcPoint(new TClonesArray()), fDrcHit(new TClonesArray()), fDskParticle(new TClonesArray()), fSttHit(new TClonesArray()), fFtsHit(new TClonesArray()),
fCorrPar(new PndPidCorrPar()), fEmcGeoPar(new PndEmcGeoPar()), fEmcErrorMatrixPar(new PndEmcErrorMatrixPar()), fEmcErrorMatrix(new PndEmcErrorMatrix()), fSttParameters(new PndGeoSttPar()), fEmcCalibrator(NULL), fEmcClstCount(0), fFscClstCount(0),
fDebugMode(kFALSE),
fMdtRefit(kFALSE),
fMvdMode(-1),
fSttMode(-1),
fFtsMode(-1),
fTofMode(-1),
fFtofMode(-1),
fEmcMode(-1),
fMdtMode(-1),
fDrcMode(-1),
fDskMode(-1),
fMixMode(kFALSE),
fFast(kFALSE),
fSimulation(kFALSE),
fIdeal(kFALSE),
tofCorr(0),
emcCorr(0),
fscCorr(0),
drcCorr(0),
dskCorr(0),
fTrackBranch2(""),
fTrackIDBranch2(""),
sDir(""),
sFile(""),
fGeoH(NULL),
fClusterList(),
fClusterQ(),
mapMdtBarrel(),
mapMdtEndcap(),
mapMdtForward()
#endif
{
fPidChargedCand = new TClonesArray("PndPidCandidate");
sDir = "./";
sFile = "./pidcorrelator.root";
fGeoH = PndGeoHandling::Instance();
#if _TODAY_
//---
fPidNeutralCand = new TClonesArray("PndPidCandidate");
// Resetting MDT geometry parameters
for (Int_t mm=0; mm<3; mm++)
for (Int_t ll=0; ll<20;ll++)
{
mdtLayerPos[mm][ll] = -1;
mdtIronThickness[mm][ll] = -1;
}
#endif
Reset();
}
#if _TODAY_
//___________________________________________________________
PndPidCorrelator::PndPidCorrelator(const char *name, const char *title) :
FairTask(name),
fMcTrack(new TClonesArray()), fTrack(new TClonesArray()), fTrackID(new TClonesArray()), fTrack2(new TClonesArray()), fTrackID2(new TClonesArray()), fPidChargedCand(new TClonesArray()), fPidNeutralCand(new TClonesArray()), fMdtTrack(new TClonesArray()), fMvdHitsStrip(new TClonesArray()), fMvdHitsPixel(new TClonesArray()), fTofHit(new TClonesArray()), fTofPoint(new TClonesArray()), fFtofHit(new TClonesArray()), fFtofPoint(new TClonesArray()), fEmcCluster(new TClonesArray()), fEmcBump(new TClonesArray()), fEmcDigi(new TClonesArray()), fMdtPoint(new TClonesArray()), fMdtHit(new TClonesArray()), fMdtTrk(new TClonesArray()), fDrcPoint(new TClonesArray()), fDrcHit(new TClonesArray()), fDskParticle(new TClonesArray()), fSttHit(new TClonesArray()), fFtsHit(new TClonesArray()),
fCorrPar(new PndPidCorrPar()), fEmcGeoPar(new PndEmcGeoPar()), fEmcErrorMatrixPar(new PndEmcErrorMatrixPar()), fEmcErrorMatrix(new PndEmcErrorMatrix()), fSttParameters(new PndGeoSttPar()), fEmcCalibrator(NULL), fEmcClstCount(0), fFscClstCount(0),
fDebugMode(kFALSE),
fGeanePro(kTRUE),
fMdtRefit(kFALSE),
fMvdMode(-1),
fSttMode(-1),
fFtsMode(-1),
fTofMode(-1),
fFtofMode(-1),
fEmcMode(-1),
fMdtMode(-1),
fDrcMode(-1),
fDskMode(-1),
fMixMode(kFALSE),
fPidHyp(0),
fIdealHyp(kFALSE),
fFast(kFALSE),
fSimulation(kFALSE),
fIdeal(kFALSE),
fCorrErrorProp(kTRUE),
tofCorr(0),
emcCorr(0),
fscCorr(0),
drcCorr(0),
dskCorr(0),
fTrackBranch(""),
fTrackIDBranch(""),
fTrackBranch2(""),
fTrackIDBranch2(""),
fTrackOutBranch(""),
sDir(""),
sFile(""),
fGeoH(NULL),
fClusterList(),
fClusterQ(),
mapMdtBarrel(),
mapMdtEndcap(),
mapMdtForward()
{
//---
fPidChargedCand = new TClonesArray("PndPidCandidate");
fPidNeutralCand = new TClonesArray("PndPidCandidate");
sDir = "./";
sFile = "./pidcorrelator.root";
fGeoH = PndGeoHandling::Instance();
// Resetting MDT geometry parameters
for (Int_t mm=0; mm<3; mm++)
for (Int_t ll=0; ll<20;ll++)
{
mdtLayerPos[mm][ll] = -1;
mdtIronThickness[mm][ll] = -1;
}
Reset();
}
#endif
//___________________________________________________________
InitStatus PndPidCorrelator::Init() {
// cout << "InitStatus PndPidCorrelator::Init()" << endl;
FairRootManager *fManager =FairRootManager::Instance();
fTrack = (TClonesArray *)fManager->GetObject(fTrackBranch);
if ( ! fTrack ) {
cout << "-I- PndPidCorrelator::Init: No PndTrack array!" << endl;
return kERROR;
}
if (fTrackIDBranch!="")
{
fTrackID = (TClonesArray *)fManager->GetObject(fTrackIDBranch);
if ( ! fTrackID ) {
cout << "-I- PndPidCorrelator::Init: No PndTrackID array! Switching MC propagation OFF" << endl;
fTrackIDBranch = "";
}
}
#if _TODAY_
if (fTrackBranch2!="")
{
fTrack2 = (TClonesArray *)fManager->GetObject(fTrackBranch2);
if ( ! fTrack2 ) {
cout << "-I- PndPidCorrelator::Init: No 2nd PndTrack array!" << endl;
return kERROR;
}
}
if (fTrackIDBranch2!="")
{
fTrackID2 = (TClonesArray *)fManager->GetObject(fTrackIDBranch2);
if ( ! fTrackID2 ) {
cout << "-I- PndPidCorrelator::Init: No 2nd PndTrackID array! Switching MC propagation OFF" << endl;
fTrackIDBranch2 = "";
}
}
// *** STT ***
if (fSttMode)
{
if (fMixMode==kFALSE)
{
fSttHit = (TClonesArray*) fManager->GetObject("STTHit");
if ( fSttHit )
{
cout << "-I- PndPidCorrelator::Init: Using STTHit" << endl;
fSttMode = 2;
}
else
{
cout << "-W- PndPidCorrelator::Init: No STT hits array! Switching STT OFF" << endl;
fSttMode = 0;
}
}
else
{
fSttHit = (TClonesArray*) fManager->GetObject("STTHitMix");
if ( fSttHit )
{
cout << "-I- PndPidCorrelator::Init: Using STTHitMix" << endl;
fSttMode = 2;
}
else
{
cout << "-W- PndPidCorrelator::Init: No STT hits mix array! Switching STT OFF" << endl;
fSttMode = 0;
}
}
}
// *** FTS ***
if (fFtsMode)
{
if (fMixMode==kFALSE)
{
fFtsHit = (TClonesArray*) fManager->GetObject("FTSHit");
if ( fFtsHit )
{
cout << "-I- PndPidCorrelator::Init: Using FTSHit" << endl;
fFtsMode = 2;
}
else
{
cout << "-W- PndPidCorrelator::Init: No FTS hits array! Switching FTS OFF" << endl;
fFtsMode = 0;
}
}
else
{
fFtsHit = (TClonesArray*) fManager->GetObject("FTSHitMix");
if ( fFtsHit )
{
cout << "-I- PndPidCorrelator::Init: Using FTSHitMix" << endl;
fFtsMode = 2;
}
else
{
cout << "-W- PndPidCorrelator::Init: No FTS hits mix array! Switching FTS OFF" << endl;
fFtsMode = 0;
}
}
}
// *** MVD ***
if (fMvdMode)
{
if (fMixMode==kFALSE)
{
fMvdHitsStrip = (TClonesArray*) fManager->GetObject("MVDHitsStrip");
if ( ! fMvdHitsStrip )
{
cout << "-W- PndPidCorrelator::Init: No MVDHitsStrip array!" << endl;
}
else fMvdMode = 2;
fMvdHitsPixel = (TClonesArray*) fManager->GetObject("MVDHitsPixel");
if ( ! fMvdHitsPixel )
{
cout << "-W- PndPidCorrelator::Init: No MVDHitsPixel array!" << endl;
}
else fMvdMode = 2;
}
else
{
fMvdHitsStrip = (TClonesArray*) fManager->GetObject("MVDHitsStripMix");
if ( ! fMvdHitsStrip )
{
cout << "-W- PndPidCorrelator::Init: No MVDHitsStripMix array!" << endl;
}
else fMvdMode = 2;
fMvdHitsPixel = (TClonesArray*) fManager->GetObject("MVDHitsPixelMix");
if ( ! fMvdHitsPixel )
{
cout << "-W- PndPidCorrelator::Init: No MVDHitsPixelMix array!" << endl;
}
else fMvdMode = 2;
}
if (( ! fMvdHitsStrip ) && ( ! fMvdHitsPixel ))
{
cout << "-W- PndPidCorrelator::Init: No MVD hits array! Switching MVD OFF" << endl;
fMvdMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using MVDHit" << endl;
}
}
// *** TOF ***
if (fTofMode)
{
fTofHit = (TClonesArray*) fManager->GetObject("SciTHit");
if ( ! fTofHit )
{
cout << "-W- PndPidCorrelator::Init: No SciTHit array!" << endl;
fTofMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using SciTHit" << endl;
fTofMode = 2;
}
if (fIdeal)
{
fTofPoint = (TClonesArray*) fManager->GetObject("SciTPoint");
if ( ! fTofPoint )
{
cout << "-W- PndPidCorrelator::Init: No SciTPoint array!" << endl;
fTofMode = 0;
}
}
}
// *** FTOF ***
if (fFtofMode)
{
fFtofHit = (TClonesArray*) fManager->GetObject("FtofHit");
if ( ! fFtofHit )
{
cout << "-W- PndPidCorrelator::Init: No FtofHit array!" << endl;
fFtofMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using FtofHit" << endl;
fFtofMode = 2;
}
if (fIdeal)
{
fFtofPoint = (TClonesArray*) fManager->GetObject("FtofPoint");
if ( ! fFtofPoint )
{
cout << "-W- PndPidCorrelator::Init: No FtofPoint array!" << endl;
fFtofMode = 0;
}
}
}
// *** EMC ***
if (fEmcMode)
{
fEmcCluster = (TClonesArray*) fManager->GetObject("EmcCluster");
if ( ! fEmcCluster )
{
cout << "-W- PndPidCorrelator::Init: No EmcCluster array!" << endl;
fEmcMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using EmcCluster" << endl;
fEmcMode = 2;
}
fEmcBump = (TClonesArray*) fManager->GetObject("EmcBump");
if ( ! fEmcBump )
{
cout << "-W- PndPidCorrelator::Init: No EmcBump array!" << endl;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using EmcBump" << endl;
fEmcMode = 3;
}
fEmcDigi = (TClonesArray*) fManager->GetObject("EmcDigi");
if ( ! fEmcDigi)
{
cout << "-W- PndPidCorrelator::Init: No EmcDigi array! No EMC E1/E9/E25 information is propagated!" << endl;
}
}
// *** DRC ***
if (fDrcMode)
{
fDrcHit = (TClonesArray*) fManager->GetObject("DrcHit");
if ( ! fDrcHit )
{
cout << "-W- PndPidCorrelator::Init: No DrcHit array!" << endl;
fDrcMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using DrcHit" << endl;
fDrcMode = 2;
}
}
// *** DSK ***
if (fDskMode)
{
fDskParticle = (TClonesArray*) fManager->GetObject("DskParticle");
if ( ! fDskParticle )
{
cout << "-W- PndPidCorrelator::Init: No DskParticle array!" << endl;
fDskMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using DskParticle" << endl;
fDskMode = 2;
}
}
// *** MDT ***
if (fMdtMode)
{
fMdtHit = (TClonesArray*) fManager->GetObject("MdtHit");
if ( ! fMdtHit )
{
cout << "-W- PndPidCorrelator::Init: No MdtHit array!" << endl;
fMdtMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using MdtHit" << endl;
fMdtMode = 2;
}
fMdtTrk = (TClonesArray*) fManager->GetObject("MdtTrk");
if ( ! fMdtTrk )
{
cout << "-W- PndPidCorrelator::Init: No MdtTrk array!" << endl;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using MdtTrk" << endl;
fMdtMode = 3;
}
}
if (fIdeal)
{
cout << "-I- PndPidCorrelator::Init: Using MonteCarlo correlation" << endl;
fTofPoint = (TClonesArray*) fManager->GetObject("TofPoint");
if ( ! fTofPoint )
{
cout << "-W- PndPidCorrelator::Init: No TofPoint array!" << endl;
fTofMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using TofPoint" << endl;
}
fDrcPoint = (TClonesArray*) fManager->GetObject("DrcBarPoint");
if ( ! fDrcPoint )
{
cout << "-W- PndPidCorrelator::Init: No DrcBarPoint array!" << endl;
fDrcMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using DrcPoint" << endl;
}
fMdtPoint = (TClonesArray*) fManager->GetObject("MdtPoint");
if ( ! fMdtPoint )
{
cout << "-W- PndPidCorrelator::Init: No MdtPoint array!" << endl;
fMdtMode = 0;
}
else
{
cout << "-I- PndPidCorrelator::Init: Using MdtPoint" << endl;
}
}
#endif
Register();
#if _TODAY_
fCorrPar->printParams();
#endif
if (fGeanePro)
{
cout << "-I- PndPidCorrelator::Init: Using Geane for Track propagation" << endl;
if (!fCorrErrorProp)
{
cout << "-I- PndPidCorrelator::Init: Switching OFF Geane error propagation" << endl;
}
if (fIdealHyp)
{
fMcTrack = (TClonesArray *)fManager->GetObject("MCTrack");
if ( ! fMcTrack ) {
cout << "-I- PndPidCorrelator::Init: No PndMcTrack array! No ideal pid hypothesis is possible!" << endl;
return kERROR;
}
if (fTrackIDBranch=="") {
cout << "-I- PndPidCorrelator::Init: No TrackID Branch name! No ideal pid hypothesis is possible!" << endl;
return kERROR;
}
}
else
{
switch (abs(fPidHyp))
{
case 0:
cout << "-I- PndPidCorrelator::Init: No PID set -> Using default PION hypothesis" << endl;
fPidHyp = 211;
break;
case 11:
cout << "-I- PndPidCorrelator::Init: Using ELECTRON hypothesis" << endl;
fPidHyp = -11;
break;
case 13:
cout << "-I- PndPidCorrelator::Init: Using MUON hypothesis" << endl;
fPidHyp = -13;
break;
case 211:
cout << "-I- PndPidCorrelator::Init: Using PION hypothesis" << endl;
fPidHyp = 211;
break;
case 321:
cout << "-I- PndPidCorrelator::Init: Using KAON hypothesis" << endl;
fPidHyp = 321;
break;
case 2212:
cout << "-I- PndPidCorrelator::Init: Using PROTON hypothesis" << endl;
fPidHyp = 2212;
break;
default:
cout << "-I- PndPidCorrelator::Init: Not recognised PID set -> Using default PION hypothesis" << endl;
fPidHyp = 211;
break;
}
}
}
else
{
return kFATAL;
}
#if _TODAY_
if (fMdtMode>0)
{
if (!MdtGeometry())
{
cout << "-W- PndPidCorrelator::Init: No MDT geometry ???" << endl;
fMdtMode = 0;
}
}
if (fMdtRefit)
{
fFitter = new PndRecoKalmanFit();
fFitter->SetGeane(fGeanePro);
fFitter->SetNumIterations(1);
if (!fFitter->Init()) return kFATAL;
}
if (fDebugMode)
{
r = TFile::Open(sDir+sFile,"RECREATE");
tofCorr = new TNtuple("tofCorr","TRACK-TOF Correlation",
"track_x:track_y:track_z:track_phi:track_p:track_charge:track_theta:track_z0:tof_x:tof_y:tof_z:tof_phi:chi2:dphi:len:glen");
ftofCorr = new TNtuple("ftofCorr","TRACK-FTOF Correlation",
"track_x:track_y:track_z:ver_x:ver_y:ver_z:ver_px:ver_py:ver_pz:track_p:track_charge:track_theta:track_z0:tof_x:tof_y:tof_z:chi2:len:glen:tlen");
emcCorr = new TNtuple("emcCorr","TRACK-EMC Correlation",
"track_x:track_y:track_z:track_phi:track_p:track_charge:track_theta:track_z0:emc_x:emc_y:emc_z:emc_phi:chi2:dphi:emc_ene:glen:emc_mod");
fscCorr = new TNtuple("fscCorr","TRACK-FSC Correlation",
"track_x:track_y:track_z:track_phi:track_p:track_charge:track_theta:track_z0:emc_x:emc_y:emc_z:emc_phi:chi2:dphi:emc_ene:glen:emc_mod");
mdtCorr = new TNtuple("mdtCorr","TRACK-MDT Correlation",
"track_x:track_y:track_z:track_dx:track_dy:track_dz:track_phi:track_p:track_charge:track_theta:track_z0:mdt_x:mdt_y:mdt_z:mdt_phi:mdt_p:chi2:mdt_mod:dphi:glen:mdt_count:nhits");
drcCorr = new TNtuple("drcCorr","TRACK-DRC Correlation",
"track_x:track_y:track_z:track_phi:track_p:track_charge:track_theta:track_z0:drc_x:drc_y:drc_phi:chi2:drc_thetac:drc_nphot:dphi:glen:flag");
dskCorr = new TNtuple("dskCorr","TRACK-DSK Correlation",
"track_x:track_y:track_z:track_phi:track_p:track_charge:track_theta:track_z0:dsk_x:dsk_y:dsk_z:dsk_phi:chi2:dsk_thetac:dsk_nphot:dphi:glen:track_lx:track_ly:track_lz:track_xp:flag");
cout << "-I- PndPidCorrelator::Init: Filling Debug histograms" << endl;
}
// Set Parameters for Emc error matrix
if (fEmcMode>0)
{
if (fEmcErrorMatrixPar->IsValid())
{
fEmcErrorMatrix->Init(fEmcErrorMatrixPar->GetParObject());
//std::cout<<"PndPidCorrelator: Emc error matrix is read from RTDB"<<std::endl;
} else
{
Int_t emcGeomVersion=fEmcGeoPar->GetGeometryVersion();
fEmcErrorMatrix->InitFromFile(emcGeomVersion);
fEmcErrorMatrixPar->SetErrorMatrixObject(fEmcErrorMatrix->GetParObject());
//std::cout<<"PndPidCorrelator: Emc error matrix is read from file"<<std::endl;
}
fEmcCalibrator= PndEmcClusterCalibrator::MakeEmcClusterCalibrator(2, 1);
}
if (fFast) cout << "-W- PndPidCorrelator::Init: Using fast correlator!!" << endl;
#endif
cout << "-I- PndPidCorrelator::Init: Success!" << endl;
fEventCounter = 1;
return kSUCCESS;
}
//______________________________________________________
void PndPidCorrelator::SetParContainers() {
#if _TODAY_
// Get run and runtime database
FairRun* run = FairRun::Instance();
if ( ! run ) Fatal("PndPidCorrelator:: SetParContainers", "No analysis run");
FairRuntimeDb* db = run->GetRuntimeDb();
if ( ! db ) Fatal("PndPidCorrelator:: SetParContainers", "No runtime database");
// Get PID Correlation parameter container
fCorrPar = (PndPidCorrPar*) db->getContainer("PndPidCorrPar");
// Get Emc geometry parameter container
fEmcGeoPar = (PndEmcGeoPar*) db->getContainer("PndEmcGeoPar");
// Get Emc error matrix parameter container
fEmcErrorMatrixPar = (PndEmcErrorMatrixPar*) db->getContainer("PndEmcErrorMatrixPar");
// Get Stt parameter
fSttParameters = (PndGeoSttPar*) db->getContainer("PndGeoSttPar");
fFtsParameters = (PndGeoFtsPar*) db->getContainer("PndGeoFtsPar");
#endif
}
//______________________________________________________
void PndPidCorrelator::Exec(Option_t * option) {
//-
Reset();
cout << " ===== PndPidCorrelator - Event: " << fEventCounter;
Int_t nTracksTot=0;
if (fTrack)
{
nTracksTot += fTrack->GetEntriesFast();
}
#if _TODAY_
if (fTrack2)
{
nTracksTot += fTrack2->GetEntriesFast();
}
#endif
cout << " - Number of tracks for pid " << nTracksTot;
#if _TODAY_
if (fEmcMode>0)
{
PndEmcCluster *tmp_cluster;
for(Int_t i=0; i < fEmcCluster->GetEntriesFast();i++)
{
tmp_cluster = (PndEmcCluster*)fEmcCluster->At(i);
if(tmp_cluster->GetModule() < 5 && tmp_cluster->GetModule() >0)
{
fEmcClstCount++;
}
if(tmp_cluster->GetModule() == 5)
{
fFscClstCount++;
}
}
ResetEmcQ();
cout << " - Number of Clusters for pid: ";
cout << " EMC: " << fEmcClstCount;
cout << " FSC: " << fFscClstCount;
}
#endif
cout<<endl;
if (fTrack) ConstructChargedCandidate();
#if _TODAY_
if ((fEmcMode>0) && (!fFast)) ConstructNeutralCandidate();
#endif
fEventCounter++;
}
//______________________________________________________
void PndPidCorrelator::ConstructChargedCandidate() {
//-
//FIXME: Use Clear() to save time.
//Call Delete() only for too busy events to save Memory
fPidChargedCand->Delete();
#if _TODAY_
if (fMdtRefit) fMdtTrack->Delete();
if (fMdtMode>0) MdtMapping();
#endif
Int_t nTracks = fTrack->GetEntriesFast();
for (Int_t i = 0; i < nTracks; i++) {
PndTrack* track = (PndTrack*) fTrack->At(i);
Int_t ierr = 0;
FairTrackParP par = track->GetParamLast();
cout << par.GetMomentum().Mag() << endl;
if ((par.GetMomentum().Mag()<0.1) /*|| (par.GetMomentum().Mag()>100.)*/ )continue;
FairTrackParH *helix = new FairTrackParH(&par, ierr);
PndPidCandidate* pidCand = new PndPidCandidate();
//for(unsigned iq=0; iq<track->mSmoothedValues.size(); iq++)
//pidCand->mSmoothedValues.push_back(track->mSmoothedValues[iq]);
if (fTrackIDBranch!="")
{
PndTrackID* trackID = (PndTrackID*) fTrackID->At(i);
if (trackID->GetNCorrTrackId()>0)
{
pidCand->SetMcIndex(trackID->GetCorrTrackID());
if (fIdealHyp)
{
PndMCTrack *mcTrack = (PndMCTrack*)fMcTrack->At(trackID->GetCorrTrackID());
if ( ! mcTrack )
{
fPidHyp = 211;
cout << "-I- PndPidCorrelator::ConstructChargedCandidate: PndMCTrack does not exist!! (why?) -> let's try with pion hyp " << endl;
}
else
{
fPidHyp = abs(mcTrack->GetPdgCode());
}
if (fPidHyp>=100000000)
{
fPidHyp = 211;
std::cout << "-I- PndPidCorrelator::ConstructChargedCandidate: Track is an ion (PDGCode>100000000) -> let's try with pion hyp" << std::endl;
}
if ( abs(fPidHyp)==13 ) fPidHyp = -13;
if ( abs(fPidHyp)==11 ) fPidHyp = -11;
}
}
} else { // added for PndAnalysis, TODO: remove after Fairlinks work with Associators
PndTrackCand trackCand = track->GetTrackCand();
pidCand->SetMcIndex(trackCand.getMcTrackId());
}
pidCand->SetTrackIndex(i);
pidCand->SetTrackBranch(FairRootManager::Instance()->GetBranchId(fTrackBranch));
pidCand->AddLink(FairLink(fTrackBranch, i));
if (!GetTrackInfo(track, pidCand)) continue;
#if _TODAY_
if ( (fMvdMode==2) && ((fMvdHitsStrip->GetEntriesFast()+fMvdHitsPixel->GetEntriesFast())>0) ) GetMvdInfo(track, pidCand);
if ( (fSttMode == 2) && (fSttHit ->GetEntriesFast()>0) ) GetSttInfo(track, pidCand);
GetGemInfo(track, pidCand);
if (!fFast)
{
if ( (fTofMode==2) && (fTofHit ->GetEntriesFast()>0) ) GetTofInfo(helix, pidCand);
if ( (fEmcMode>0) && (fEmcClstCount>0) ) GetEmcInfo(helix, pidCand);
if ( (fMdtMode>0) && (fMdtHit ->GetEntriesFast()>0) ) GetMdtInfo(track, pidCand);
if ( (fDrcMode>0) && (fDrcHit ->GetEntriesFast()>0) ) GetDrcInfo(helix, pidCand);
if ( (fDskMode>0) && (fDskParticle->GetEntriesFast()>0)) GetDskInfo(helix, pidCand);
}
#endif
// Add charged track candidate and copy over parameterizations at the hit locations;
PndPidCandidate *cand = AddChargedCandidate(pidCand);
cand->mParameterizations = track->mParameterizations;
}
#if _TODAY_
if (fTrackBranch2!="")
{
Int_t nTracks2 = fTrack2->GetEntriesFast();
for (Int_t i = 0; i < nTracks2; i++) {
PndTrack* track = (PndTrack*) fTrack2->At(i);
Int_t ierr = 0;
FairTrackParP par = track->GetParamLast();
if ((par.GetMomentum().Mag()<0.1) || (par.GetMomentum().Mag()>20.) )continue;
FairTrackParH *helix = new FairTrackParH(&par, ierr);
PndPidCandidate* pidCand = new PndPidCandidate();
if (fTrackIDBranch2!="")
{
PndTrackID* trackID = (PndTrackID*) fTrackID2->At(i);
if (trackID->GetNCorrTrackId()>0)
{
pidCand->SetMcIndex(trackID->GetCorrTrackID());
if (fIdealHyp)
{
PndMCTrack *mcTrack = (PndMCTrack*)fMcTrack->At(trackID->GetCorrTrackID());
if ( ! mcTrack )
{
fPidHyp = 211;
cout << "-I- PndPidCorrelator::ConstructChargedCandidate: PndMCTrack does not exist!! (why?) -> let's try with pion hyp " << endl;
}
else
{
fPidHyp = abs(mcTrack->GetPdgCode());
}
if (fPidHyp>=100000000)
{
fPidHyp = 211;
std::cout << "-I- PndPidCorrelator::ConstructChargedCandidate: Track is an ion (PDGCode>100000000) -> let's try with pion hyp" << std::endl;
}
if ( abs(fPidHyp)==13 ) fPidHyp = -13;
if ( abs(fPidHyp)==11 ) fPidHyp = -11;
}
}
} else { // added for PndAnalysis, TODO: remove after Fairlinks work with Associators
PndTrackCand trackCand = track->GetTrackCand();
pidCand->SetMcIndex(trackCand.getMcTrackId());
}
pidCand->SetTrackIndex(i);
pidCand->SetTrackBranch(FairRootManager::Instance()->GetBranchId(fTrackBranch2));
pidCand->AddLink(FairLink("PndTrack", i));
if (!GetTrackInfo(track, pidCand)) continue;
if ( (fMvdMode==2) && ((fMvdHitsStrip->GetEntriesFast()+fMvdHitsPixel->GetEntriesFast())>0) ) GetMvdInfo(track, pidCand);
if ( (fFtsMode == 2) && (fFtsHit ->GetEntriesFast()>0) ) GetFtsInfo(track, pidCand);
GetGemInfo(track, pidCand);
if (!fFast)
{
if ( (fFtofMode==2) && (fFtofHit->GetEntriesFast()>0) ) GetFtofInfo(helix, pidCand);
if ( (fEmcMode>0) && (fFscClstCount>0) ) GetFscInfo(helix, pidCand);
//if ( (fMdtMode>0) && (fMdtHit ->GetEntriesFast()>0) ) GetMdtInfo(track, pidCand);
if (mapMdtForward.size()>0) GetFMdtInfo(&par, pidCand);
} // end of fast mode
AddChargedCandidate(pidCand);
}
}
#endif
}
#if _TODAY_
//______________________________________________________
void PndPidCorrelator::ConstructNeutralCandidate() {
//-
fPidNeutralCand->Delete();
TString emcType;
Int_t nBumps = 0;
if (fEmcMode == 2)
{
nBumps = fEmcCluster->GetEntriesFast();
emcType = "EmcCluster";
}
else if(fEmcMode == 3)
{
nBumps = fEmcBump->GetEntriesFast();
emcType = "EmcBump";
}
for (Int_t i = 0; i < nBumps; i++)
{
PndEmcBump* bump;
PndEmcCluster *clu;
Float_t quality = -1.;
if (fEmcMode==2)
{
if (fClusterList[i]) continue;
bump = (PndEmcBump*) fEmcCluster->At(i);
clu = (PndEmcBump*) fEmcCluster->At(i);
quality = fClusterQ[i];
}
else if(fEmcMode == 3)
{
bump = (PndEmcBump*) fEmcBump->At(i);
if (fClusterList[bump->GetClusterIndex()]) continue; // skip correlated clusters
clu = (PndEmcCluster*)fEmcCluster->At(bump->GetClusterIndex());
quality = fClusterQ[bump->GetClusterIndex()];
}
TVector3 vtx(0,0,0);
TVector3 v1=bump->where();
TVector3 p3;
p3.SetMagThetaPhi(fEmcCalibrator->Energy(bump), v1.Theta(), v1.Phi());
TLorentzVector lv(p3,p3.Mag());
TMatrixD covP4=fEmcErrorMatrix->Get4MomentumErrorMatrix(*clu);
PndPidCandidate* pidCand = new PndPidCandidate(0, vtx, lv);
pidCand->SetP4Cov(covP4);
pidCand->SetEmcRawEnergy(bump->energy());
pidCand->SetEmcCalEnergy(fEmcCalibrator->Energy(bump));
pidCand->SetEmcIndex(i);
pidCand->SetEmcModule(bump->GetModule());
pidCand->SetEmcNumberOfCrystals(bump->NumberOfDigis());
pidCand->SetEmcNumberOfBumps(clu->NBumps());
pidCand->SetEmcQuality(quality);
pidCand->SetEmcClusterZ20(bump->Z20());
pidCand->SetEmcClusterZ53(bump->Z53());
pidCand->SetEmcClusterLat(bump->LatMom());
if (fEmcDigi)
{
PndEmcClusterEnergySums esum(*clu, fEmcDigi);
pidCand->SetEmcClusterE1(esum.E1());
pidCand->SetEmcClusterE9(esum.E9());
pidCand->SetEmcClusterE25(esum.E25());
}
pidCand->SetLink(FairLink(emcType, i));
std::vector<Int_t> mclist = clu->GetMcList();
if (mclist.size()>0)
{
pidCand->SetMcIndex(mclist[0]);
}
AddNeutralCandidate(pidCand);
}
}
//_________________________________________________________________
Bool_t PndPidCorrelator::GetTofInfo(FairTrackParH* helix, PndPidCandidate* pidCand) {
if (!fIdeal)
{
if ((helix->GetMomentum().Theta()*TMath::RadToDeg())<20.) return kFALSE;
if ((helix->GetMomentum().Theta()*TMath::RadToDeg())>150.) return kFALSE;
}
FairGeanePro *fProTof = new FairGeanePro();
if (!fCorrErrorProp) fProTof->PropagateOnlyParameters();
FairGeanePro *fProVertex = new FairGeanePro();
if (!fCorrErrorProp) fProVertex->PropagateOnlyParameters();
//---
PndSciTHit *tofHit = NULL;
Int_t tofEntries = fTofHit->GetEntriesFast();
Int_t tofIndex = -1;
Float_t tofTof = 0., tofLength = -1000, tofGLength = -1000, tofLengthTemp = -1000;
Float_t tofQuality = 1000000;
Float_t chi2 = 0;
TVector3 vertex(0., 0., 0.);
TVector3 tofPos(0., 0., 0.);
TVector3 momentum(0., 0., 0.);
for (Int_t tt = 0; tt<tofEntries; tt++)
{
tofHit = (PndSciTHit*)fTofHit->At(tt);
if ( fIdeal && ( ((PndSciTPoint*)fTofPoint->At(tofHit->GetRefIndex()))->GetTrackID() !=pidCand->GetMcIndex()) ) continue;
tofHit->Position(tofPos);
if (fGeanePro) // Overwrites vertex if Geane is used
{
fProTof->SetPoint(tofPos);
fProTof->PropagateToPCA(1, 1);
FairTrackParH *fRes= new FairTrackParH();
Bool_t rc = fProTof->Propagate(helix, fRes, fPidHyp*pidCand->GetCharge());
if (!rc) continue;
vertex.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ());
fProVertex->SetPoint(TVector3(0,0,0));
fProVertex->PropagateToPCA(1, -1);
FairTrackParH *fRes2= new FairTrackParH();
Bool_t rc2 = fProVertex->Propagate(fRes, fRes2, fPidHyp*pidCand->GetCharge());
if (rc2) tofLengthTemp = fProVertex->GetLengthAtPCA();