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

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

  ViewVC Help
Powered by ViewVC 1.1.23