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

Diff of /PamCut/CollectionActions/RefitTrackAction/RefitTrackAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.2 by pam-fi, Tue May 11 15:32:09 2010 UTC revision 1.1.2.8 by pam-fi, Wed Nov 30 16:59:03 2011 UTC
# Line 11  TRandom3* RefitTrackAction::_r3 = new TR Line 11  TRandom3* RefitTrackAction::_r3 = new TR
11  long int RefitTrackAction::_currEvent = -1;  long int RefitTrackAction::_currEvent = -1;
12  TString RefitTrackAction::_currTrkParamsFile = "";  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) {  void RefitTrackAction::OnGood(PamLevel2 *event) {
18    
19    // Reload the TRK parameters only if they have been changed (ie., if another instance of    // Do something only if at least one track exists
20    // this class used a different set of parameters.    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) {    if (_trkParamsFile != _currTrkParamsFile) {
26      TrkParams::Set(_trkParamsFile, 5);      TrkParams::Set(_trkParamsFile, 5);
27      _currTrkParamsFile = _trkParamsFile;      _currTrkParamsFile = _trkParamsFile;
28    }    }
29    
30      if (_sortingMethod)
31        event->SetSortingMethod(_sortingMethod);
32    TrkTrack *trkTrack = event->GetTrack(0)->GetTrkTrack();    TrkTrack *trkTrack = event->GetTrack(0)->GetTrkTrack();
33    if (!trkTrack)    if (!trkTrack)
34      return;      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()) {    if (_currEvent != event->GetReadEntry()) {
45      // Saves the original track data if the current event (recorded in the static member _currEvent) is      // 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      // different from the actually processed event. This way, multiple instances of the class
# Line 31  void RefitTrackAction::OnGood(PamLevel2 Line 48  void RefitTrackAction::OnGood(PamLevel2
48      _currEvent = event->GetReadEntry();      _currEvent = event->GetReadEntry();
49      // Save the original cluster status and measured positions      // Save the original cluster status and measured positions
50      for (int i = 0; i < 6; i++) {      for (int i = 0; i < 6; i++) {
51        _layerXBackup[i] = trkTrack->xgood[0];        _layerXBackup[i] = trkTrack->xgood[i];
52        _layerYBackup[i] = trkTrack->ygood[0];        _layerYBackup[i] = trkTrack->ygood[i];
53        _xmBackup[i] = trkTrack->xm[i];        _xmBackup[i] = trkTrack->xm[i];
54        _ymBackup[i] = trkTrack->ym[i];        _ymBackup[i] = trkTrack->ym[i];
55      }      }
# Line 43  void RefitTrackAction::OnGood(PamLevel2 Line 60  void RefitTrackAction::OnGood(PamLevel2
60      for (int i = 0; i < 6; i++) {      for (int i = 0; i < 6; i++) {
61        trkTrack->xm[i] = _xmBackup[i];        trkTrack->xm[i] = _xmBackup[i];
62        trkTrack->ym[i] = _ymBackup[i];        trkTrack->ym[i] = _ymBackup[i];
63        _layerXBackup[i] = trkTrack->xgood[0];        trkTrack->xgood[i] = _layerXBackup[i];
64        _layerYBackup[i] = trkTrack->ygood[0];        trkTrack->ygood[i] = _layerYBackup[i];
65      }      }
66    
67    }    }
68    
69    // Apply the gaussian spread    // Apply the gaussian spread
70    for (Int_t ip = 0; ip < 6; ip++) {  
71      // gaussian distributed random number Gauss(mean,sigma) (in cm)    if (_spreadX != 0.) {
72      trkTrack->xm[ip] += _r3->Gaus(0., _spreadX);      for (Int_t ip = 0; ip < 6; ip++) {
73      trkTrack->ym[ip] += _r3->Gaus(0., _spreadY);        // 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    // Mask the layers
# Line 88  void RefitTrackAction::OnGood(PamLevel2 Line 112  void RefitTrackAction::OnGood(PamLevel2
112    trkTrack->FitReset();    trkTrack->FitReset();
113    int fail = 0;    int fail = 0;
114    trkTrack->Fit(0, fail, 0);    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  }  }

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.8

  ViewVC Help
Powered by ViewVC 1.1.23