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

Diff of /PamCut/CollectionActions/ReprocessTrackAction/ReprocessTrackAction.cpp

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

revision 1.1 by pam-fi, Tue Mar 23 10:18:35 2010 UTC revision 1.2.2.3 by pam-fi, Wed Nov 30 16:57:49 2011 UTC
# Line 11  void ReprocessTrackAction::OnGood(PamLev Line 11  void ReprocessTrackAction::OnGood(PamLev
11    
12    _allEvents++;    _allEvents++;
13    
14    TrkLevel1 *L1;    TrkLevel1 *L1 = NULL;
15    if (_newTrkL1)    if (_newTrkL1) {
16      if (_externalFlag)      if (_externalFlag)
17        if (!(*_externalFlag))        if (!(*_externalFlag))
18          return;          return;
# Line 20  void ReprocessTrackAction::OnGood(PamLev Line 20  void ReprocessTrackAction::OnGood(PamLev
20          L1 = *_newTrkL1; // External L1 plus flag=true          L1 = *_newTrkL1; // External L1 plus flag=true
21      else      else
22        L1 = *_newTrkL1; // External L1 plus no external flag        L1 = *_newTrkL1; // External L1 plus no external flag
23    
24        // Set the new L1 inside PamLevel2 event
25        TrkLevel1 *oldTrkL1 = event->GetTrkLevel1();
26    
27        // Sadly, there's no copy constructor for TrkLevel1. We have to copy manually...
28        // TODO: replace the following with TrkLevel1 copy constructor (if there will ever be one...)
29        // 1. Clean the structure
30        oldTrkL1->Set(); // Creates Cluster array if it doesn't exist
31        Int_t nClus = oldTrkL1->Cluster->GetEntries();
32        for (Int_t i = 0; i < nClus; i++) {
33          TrkCluster *clstrPtr = (TrkCluster*) (oldTrkL1->Cluster->UncheckedAt(i));
34          if (clstrPtr) {
35            delete[] clstrPtr->clsignal;
36            clstrPtr->clsignal = NULL;
37            delete[] clstrPtr->clsigma;
38            clstrPtr->clsigma = NULL;
39            delete[] clstrPtr->cladc;
40            clstrPtr->cladc = NULL;
41            delete[] clstrPtr->clbad;
42            clstrPtr->clbad = NULL;
43          }
44        }
45        oldTrkL1->Cluster->Clear("C");
46    
47        // 2. Copy the new L1 into the old one
48        // 2.1 Fixed size public arrays
49        for (int i = 0; i < 12; i++) {
50          oldTrkL1->good[i] = (*_newTrkL1)->good[i];
51          for (int j = 0; j < 24; j++) {
52            oldTrkL1->cn[j][i] = (*_newTrkL1)->cn[j][i];
53            oldTrkL1->cnn[j][i] = (*_newTrkL1)->cnn[j][i];
54          }
55        }
56        // 2.2 TClonesArray of TrkCluster objects
57        int nClusters = (*_newTrkL1)->Cluster->GetEntries();
58        for (int i = 0; i < nClusters; i++) {
59          TrkCluster *currCluster = (TrkCluster*) ((*_newTrkL1)->Cluster->At(i));
60          new ((*(oldTrkL1->Cluster))[i]) TrkCluster(*currCluster);
61        }
62      }
63    else {    else {
64      L1 = (TrkLevel1*) event->GetPointerTo("TrkLevel1"); // Internal L1  
65        event->GetPointerTo("TrkLevel1"); // Internal L1 (create it if it doesn't exist)
66      TrkLevel0 *L0 = event->GetTrkLevel0();      TrkLevel0 *L0 = event->GetTrkLevel0();
67      if (!L0) {      if (!L0) {
68        cout << "Missing TrkLevel0 event " << endl;        cout << "Missing TrkLevel0 event " << endl;
69        return;        return;
70      }      }
71      L0->ProcessEvent();// re-processing level0->level1      L0->ProcessEvent(); // re-processing level0->level1
72      L1 = event->GetTrkLevel1();      L1 = event->GetTrkLevel1();
73      L1->Clear();      L1->Clear();
74      L1->SetFromLevel1Struct();      L1->SetFromLevel1Struct();
75    }    }
76    
77    // See if the event has a track before reprocessing    if (_reprocL2) {
78    TrkLevel2 *trkl2 = event->GetTrkLevel2();      // See if the event has a track before reprocessing
79    bool hadTrack = false;      TrkLevel2 *trkl2 = event->GetTrkLevel2();
80    if (trkl2->GetTrkLevel2()->GetNTracks() > 0)      bool hadTrack = false;
81      hadTrack = true;      if (trkl2->GetTrkLevel2()->GetNTracks() > 0)
82          hadTrack = true;
83    // Reprocess  
84    _reprocessed++;      // Reprocess
85    L1->ProcessEvent();// re-processing level1->level2      _reprocessed++;
86        L1->ProcessEvent(); // re-processing level1->level2
87    trkl2 = event->GetTrkLevel2();  
88    trkl2->Clear();      trkl2 = event->GetTrkLevel2();
89    trkl2->SetFromLevel2Struct();      trkl2->Clear();
90        trkl2->SetFromLevel2Struct();
91    // See if we gained or lost a track;  
92    if (trkl2->GetTrkLevel2()->GetNTracks() > 0) {      // See if we gained or lost a track;
93      if (!hadTrack) {      if (trkl2->GetNTracks() > 0) {
94        _recoveredTracks++;        if (!hadTrack) {
95            _recoveredTracks++;
96          }
97        }
98        else if (hadTrack) {
99          _lostTracks++;
100      }      }
   }  
   else if (hadTrack) {  
     cout << event->GetOrbitalInfo()->OBT << "  " << event->GetOrbitalInfo()->pkt_num << endl;  
     _lostTracks++;  
101    }    }
102  }  }
   

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

  ViewVC Help
Powered by ViewVC 1.1.23