| 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 |
TrkLevel1 *L1 = NULL; |
| 15 |
if (_newTrkL1) { |
| 16 |
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 |
|
| 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 { |
| 64 |
|
| 65 |
event->GetPointerTo("TrkLevel1"); // Internal L1 (create it if it doesn't exist) |
| 66 |
TrkLevel0 *L0 = event->GetTrkLevel0(); |
| 67 |
if (!L0) { |
| 68 |
cout << "Missing TrkLevel0 event " << endl; |
| 69 |
return; |
| 70 |
} |
| 71 |
L0->ProcessEvent(); // re-processing level0->level1 |
| 72 |
L1 = event->GetTrkLevel1(); |
| 73 |
L1->Clear(); |
| 74 |
L1->SetFromLevel1Struct(); |
| 75 |
} |
| 76 |
|
| 77 |
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 |
|
| 84 |
// Reprocess |
| 85 |
_reprocessed++; |
| 86 |
L1->ProcessEvent(); // re-processing level1->level2 |
| 87 |
|
| 88 |
trkl2 = event->GetTrkLevel2(); |
| 89 |
trkl2->Clear(); |
| 90 |
trkl2->SetFromLevel2Struct(); |
| 91 |
|
| 92 |
// 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 |
} |
| 101 |
} |
| 102 |
} |