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

Annotation of /PamCut/CollectionActions/ReprocessTrackAction/ReprocessTrackAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2.2.3 - (hide annotations) (download)
Wed Nov 30 16:57:49 2011 UTC (13 years ago) by pam-fi
Branch: V8
CVS Tags: nuclei_reproc
Changes since 1.2.2.2: +46 -5 lines
Substitute the standard Trk level1 in PamLevel2 with the (eventual) external one.
This way, the external level1 (which has been actually used to compute new level2) will be saved by SaveEventsAction, instead of the standard and unused level1.

1 pam-fi 1.1 /*
2     * ReprocessTrackAction.cpp
3     *
4     * Created on: 23/dic/2009
5     * Author: C. De Santis, N. Mori
6     */
7    
8     #include "ReprocessTrackAction.h"
9    
10     void ReprocessTrackAction::OnGood(PamLevel2 *event) {
11    
12     _allEvents++;
13    
14 pam-fi 1.2.2.3 TrkLevel1 *L1 = NULL;
15     if (_newTrkL1) {
16 pam-fi 1.1 if (_externalFlag)
17     if (!(*_externalFlag))
18     return;
19     else
20     L1 = *_newTrkL1; // External L1 plus flag=true
21     else
22     L1 = *_newTrkL1; // External L1 plus no external flag
23 pam-fi 1.2.2.3
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 pam-fi 1.1 else {
64 pam-fi 1.2.2.3
65     event->GetPointerTo("TrkLevel1"); // Internal L1 (create it if it doesn't exist)
66 pam-fi 1.1 TrkLevel0 *L0 = event->GetTrkLevel0();
67     if (!L0) {
68     cout << "Missing TrkLevel0 event " << endl;
69     return;
70     }
71 pam-fi 1.2.2.3 L0->ProcessEvent(); // re-processing level0->level1
72 pam-fi 1.1 L1 = event->GetTrkLevel1();
73     L1->Clear();
74     L1->SetFromLevel1Struct();
75     }
76    
77 pam-fi 1.2.2.2 if (_reprocL2) {
78     // See if the event has a track before reprocessing
79     TrkLevel2 *trkl2 = event->GetTrkLevel2();
80     bool hadTrack = false;
81     if (trkl2->GetTrkLevel2()->GetNTracks() > 0)
82     hadTrack = true;
83 pam-fi 1.1
84 pam-fi 1.2.2.2 // Reprocess
85     _reprocessed++;
86 pam-fi 1.2.2.3 L1->ProcessEvent(); // re-processing level1->level2
87 pam-fi 1.1
88 pam-fi 1.2.2.2 trkl2 = event->GetTrkLevel2();
89     trkl2->Clear();
90     trkl2->SetFromLevel2Struct();
91 pam-fi 1.1
92 pam-fi 1.2.2.2 // See if we gained or lost a track;
93     if (trkl2->GetNTracks() > 0) {
94     if (!hadTrack) {
95     _recoveredTracks++;
96     }
97     }
98     else if (hadTrack) {
99     _lostTracks++;
100 pam-fi 1.1 }
101     }
102     }

  ViewVC Help
Powered by ViewVC 1.1.23