/[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 by pam-fi, Tue May 11 15:16:16 2010 UTC revision 1.1.2.2 by pam-fi, Tue May 11 15:32:09 2010 UTC
# Line 0  Line 1 
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    void RefitTrackAction::OnGood(PamLevel2 *event) {
15    
16      // Reload the TRK parameters only if they have been changed (ie., if another instance of
17      // this class used a different set of parameters.
18      if (_trkParamsFile != _currTrkParamsFile) {
19        TrkParams::Set(_trkParamsFile, 5);
20        _currTrkParamsFile = _trkParamsFile;
21      }
22    
23      TrkTrack *trkTrack = event->GetTrack(0)->GetTrkTrack();
24      if (!trkTrack)
25        return;
26    
27      if (_currEvent != event->GetReadEntry()) {
28        // Saves the original track data if the current event (recorded in the static member _currEvent) is
29        // different from the actually processed event. This way, multiple instances of the class
30        // can run in the same analysis, the backup being done only by the first of them.
31        _currEvent = event->GetReadEntry();
32        // Save the original cluster status and measured positions
33        for (int i = 0; i < 6; i++) {
34          _layerXBackup[i] = trkTrack->xgood[0];
35          _layerYBackup[i] = trkTrack->ygood[0];
36          _xmBackup[i] = trkTrack->xm[i];
37          _ymBackup[i] = trkTrack->ym[i];
38        }
39      }
40      else {
41        // Current event matches the actually analyzed event, this meaning that another instance of the class
42        // has already done a refit. In this case, cluster status and positions must be restored before fitting again.
43        for (int i = 0; i < 6; i++) {
44          trkTrack->xm[i] = _xmBackup[i];
45          trkTrack->ym[i] = _ymBackup[i];
46          _layerXBackup[i] = trkTrack->xgood[0];
47          _layerYBackup[i] = trkTrack->ygood[0];
48        }
49    
50      }
51    
52      // Apply the gaussian spread
53      for (Int_t ip = 0; ip < 6; ip++) {
54        // gaussian distributed random number Gauss(mean,sigma) (in cm)
55        trkTrack->xm[ip] += _r3->Gaus(0., _spreadX);
56        trkTrack->ym[ip] += _r3->Gaus(0., _spreadY);
57      }
58    
59      // Mask the layers
60      if (_maskedViews) {
61        if ((_maskedViews & T1X) == T1X)
62          trkTrack->xgood[0] = 0;
63        if ((_maskedViews & T2X) == T2X)
64          trkTrack->xgood[1] = 0;
65        if ((_maskedViews & T3X) == T3X)
66          trkTrack->xgood[2] = 0;
67        if ((_maskedViews & T4X) == T4X)
68          trkTrack->xgood[3] = 0;
69        if ((_maskedViews & T5X) == T5X)
70          trkTrack->xgood[4] = 0;
71        if ((_maskedViews & T6X) == T6X)
72          trkTrack->xgood[5] = 0;
73    
74        if ((_maskedViews & T1Y) == T1Y)
75          trkTrack->ygood[0] = 0;
76        if ((_maskedViews & T2Y) == T2Y)
77          trkTrack->ygood[1] = 0;
78        if ((_maskedViews & T3Y) == T3Y)
79          trkTrack->ygood[2] = 0;
80        if ((_maskedViews & T4Y) == T4Y)
81          trkTrack->ygood[3] = 0;
82        if ((_maskedViews & T5Y) == T5Y)
83          trkTrack->ygood[4] = 0;
84        if ((_maskedViews & T6Y) == T6Y)
85          trkTrack->ygood[5] = 0;
86      }
87    
88      trkTrack->FitReset();
89      int fail = 0;
90      trkTrack->Fit(0, fail, 0);
91    }

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

  ViewVC Help
Powered by ViewVC 1.1.23