Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TrackClones.cxx
1/*
2 * TrackClonesTemplate.cxx
3 *
4 * Created on: 12 lip 2019
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TrackClones.h"
11
12#include "Cout.h"
13#include "DataManager.h"
14#include "IOManager.h"
15
16namespace Hal {
17 TrackClones::TrackClones(TString className, TString branchname, TString dirname) :
18 fBranchName(branchname), fDirName(dirname), fClones(NULL) {
19 if (className != "") { fClones = new TClonesArray(className); }
20 }
21
22 void TrackClones::Register(Bool_t write) {
23 DataManager* mngr = DataManager::Instance();
24 mngr->Register(fBranchName, fDirName, fClones, write);
25 }
26
27 void TrackClones::GetFromTree() {
28 if (fClones) { delete fClones; }
29 fClones = NULL;
30 fClones = (TClonesArray*) DataManager::Instance()->GetObject(fBranchName);
31 if (fClones == NULL) { Cout::PrintInfo(Form("Branch %s not found!", fBranchName.Data()), EInfo::kError); }
32 }
33
34 TrackClones::~TrackClones() {
35 if (fClones) delete fClones;
36 }
37
38 Bool_t TrackClones::ExistInTree() const {
39 DataManager* mngr = DataManager::Instance();
40 return mngr->CheckBranch(fBranchName);
41 }
42
43 void TrackClones::Compress(Int_t* map, Int_t /*map_size*/) {
44 Int_t good_pos = 0;
45 for (int i = 0; i < fClones->GetEntriesFast(); i++) {
46 if (i == map[good_pos]) {
47 good_pos++;
48 continue;
49 }
50 fClones->RemoveAt(i);
51 }
52 fClones->Compress();
53 }
54
55 void TrackClones::DeleteClones() {
56 if (fClones) delete fClones;
57 fClones = NULL;
58 }
59} // namespace Hal