1 |
pam-fi |
1.1.2.1 |
/* |
2 |
|
|
* RefitTrackAction.cpp |
3 |
|
|
* |
4 |
|
|
* Created on: 10/may/2010 |
5 |
|
|
* Author: M. Bongi, N. Mori |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "RefitTrackAction.h" |
9 |
|
|
|
10 |
|
|
TRandom3* RefitTrackAction::_r3 = new TRandom3(0); |
11 |
|
|
long int RefitTrackAction::_currEvent = -1; |
12 |
pam-fi |
1.1.2.2 |
TString RefitTrackAction::_currTrkParamsFile = ""; |
13 |
pam-fi |
1.1.2.1 |
|
14 |
pam-fi |
1.1.2.4 |
float RefitTrackAction::_xmBackup[6], RefitTrackAction::_ymBackup[6]; |
15 |
|
|
int RefitTrackAction::_layerXBackup[6], RefitTrackAction::_layerYBackup[6]; |
16 |
|
|
|
17 |
pam-fi |
1.1.2.1 |
void RefitTrackAction::OnGood(PamLevel2 *event) { |
18 |
|
|
|
19 |
pam-fi |
1.1.2.3 |
// Do something only if at least one track exists |
20 |
|
|
if (event->GetTrkLevel2()->GetNTracks() == 0) |
21 |
|
|
return; |
22 |
|
|
|
23 |
pam-fi |
1.1.2.2 |
// Reload the TRK parameters only if they have been changed (ie., if another instance of |
24 |
pam-fi |
1.1.2.3 |
// this class used a different set of parameters). |
25 |
pam-fi |
1.1.2.2 |
if (_trkParamsFile != _currTrkParamsFile) { |
26 |
|
|
TrkParams::Set(_trkParamsFile, 5); |
27 |
|
|
_currTrkParamsFile = _trkParamsFile; |
28 |
|
|
} |
29 |
pam-fi |
1.1.2.1 |
|
30 |
pam-fi |
1.1.2.3 |
if (_sortingMethod) |
31 |
|
|
event->SetSortingMethod(_sortingMethod); |
32 |
pam-fi |
1.1.2.1 |
TrkTrack *trkTrack = event->GetTrack(0)->GetTrkTrack(); |
33 |
|
|
if (!trkTrack) |
34 |
|
|
return; |
35 |
|
|
|
36 |
|
|
if (_currEvent != event->GetReadEntry()) { |
37 |
|
|
// Saves the original track data if the current event (recorded in the static member _currEvent) is |
38 |
|
|
// different from the actually processed event. This way, multiple instances of the class |
39 |
|
|
// can run in the same analysis, the backup being done only by the first of them. |
40 |
|
|
_currEvent = event->GetReadEntry(); |
41 |
|
|
// Save the original cluster status and measured positions |
42 |
|
|
for (int i = 0; i < 6; i++) { |
43 |
|
|
_layerXBackup[i] = trkTrack->xgood[0]; |
44 |
|
|
_layerYBackup[i] = trkTrack->ygood[0]; |
45 |
|
|
_xmBackup[i] = trkTrack->xm[i]; |
46 |
|
|
_ymBackup[i] = trkTrack->ym[i]; |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
else { |
50 |
|
|
// Current event matches the actually analyzed event, this meaning that another instance of the class |
51 |
|
|
// has already done a refit. In this case, cluster status and positions must be restored before fitting again. |
52 |
|
|
for (int i = 0; i < 6; i++) { |
53 |
|
|
trkTrack->xm[i] = _xmBackup[i]; |
54 |
|
|
trkTrack->ym[i] = _ymBackup[i]; |
55 |
|
|
_layerXBackup[i] = trkTrack->xgood[0]; |
56 |
|
|
_layerYBackup[i] = trkTrack->ygood[0]; |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
// Apply the gaussian spread |
62 |
pam-fi |
1.1.2.4 |
|
63 |
pam-fi |
1.1.2.1 |
for (Int_t ip = 0; ip < 6; ip++) { |
64 |
|
|
// gaussian distributed random number Gauss(mean,sigma) (in cm) |
65 |
|
|
trkTrack->xm[ip] += _r3->Gaus(0., _spreadX); |
66 |
|
|
trkTrack->ym[ip] += _r3->Gaus(0., _spreadY); |
67 |
|
|
} |
68 |
pam-fi |
1.1.2.5 |
|
69 |
pam-fi |
1.1.2.1 |
// Mask the layers |
70 |
|
|
if (_maskedViews) { |
71 |
|
|
if ((_maskedViews & T1X) == T1X) |
72 |
|
|
trkTrack->xgood[0] = 0; |
73 |
|
|
if ((_maskedViews & T2X) == T2X) |
74 |
|
|
trkTrack->xgood[1] = 0; |
75 |
|
|
if ((_maskedViews & T3X) == T3X) |
76 |
|
|
trkTrack->xgood[2] = 0; |
77 |
|
|
if ((_maskedViews & T4X) == T4X) |
78 |
|
|
trkTrack->xgood[3] = 0; |
79 |
|
|
if ((_maskedViews & T5X) == T5X) |
80 |
|
|
trkTrack->xgood[4] = 0; |
81 |
|
|
if ((_maskedViews & T6X) == T6X) |
82 |
|
|
trkTrack->xgood[5] = 0; |
83 |
|
|
|
84 |
|
|
if ((_maskedViews & T1Y) == T1Y) |
85 |
|
|
trkTrack->ygood[0] = 0; |
86 |
|
|
if ((_maskedViews & T2Y) == T2Y) |
87 |
|
|
trkTrack->ygood[1] = 0; |
88 |
|
|
if ((_maskedViews & T3Y) == T3Y) |
89 |
|
|
trkTrack->ygood[2] = 0; |
90 |
|
|
if ((_maskedViews & T4Y) == T4Y) |
91 |
|
|
trkTrack->ygood[3] = 0; |
92 |
|
|
if ((_maskedViews & T5Y) == T5Y) |
93 |
|
|
trkTrack->ygood[4] = 0; |
94 |
|
|
if ((_maskedViews & T6Y) == T6Y) |
95 |
|
|
trkTrack->ygood[5] = 0; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
trkTrack->FitReset(); |
99 |
|
|
int fail = 0; |
100 |
|
|
trkTrack->Fit(0, fail, 0); |
101 |
pam-fi |
1.1.2.3 |
|
102 |
|
|
if (fail) { |
103 |
|
|
// Set a flag for the badly-refitted tracks: chi2 < 0 |
104 |
|
|
if (trkTrack->chi2 >= 0.) |
105 |
|
|
trkTrack->chi2 = -1.; |
106 |
|
|
} |
107 |
pam-fi |
1.1.2.1 |
} |