/[PAMELA software]/PamCut/CollectionActions/RefitTrackAction/RefitTrackAction.cpp
ViewVC logotype

Contents of /PamCut/CollectionActions/RefitTrackAction/RefitTrackAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.2.8 - (show annotations) (download)
Wed Nov 30 16:59:03 2011 UTC (13 years ago) by pam-fi
Branch: V8
CVS Tags: nuclei_reproc
Changes since 1.1.2.7: +14 -8 lines
Fix to improve robustness of multiple refits.

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

  ViewVC Help
Powered by ViewVC 1.1.23