Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TrackClones.h
1/*
2 * TrackClonesTemplate.h
3 *
4 * Created on: 04-05-2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HALTRACKCLONES_H_
10#define HALTRACKCLONES_H_
11
12#include <TClonesArray.h>
13#include <TObjArray.h>
14#include <TString.h>
15namespace Hal {
16 class TrackClones : public TObject {
17 TString fBranchName;
18 TString fDirName;
19 TClonesArray* fClones;
20
21 public:
22 TrackClones(TString ClassName = "", TString branchname = "", TString dirname = "");
23 void Register(Bool_t write);
24 void GetFromTree();
25 void Compress(Int_t* map, Int_t map_size);
26 void DeleteClones();
27 template<class T>
28 void CopyFrom(const TClonesArray* from) {
29 fClones->Clear();
30 Int_t size = from->GetEntriesFast();
31 fClones->ExpandCreateFast(size);
32 for (int i = 0; i < size; i++) {
33 const T* obj_from = (T*) from->UncheckedAt(i);
34 T* obj_to = (T*) fClones->UncheckedAt(i);
35 *obj_to = *obj_from;
36 }
37 }
38 template<class T>
39 void CopyTo(TClonesArray* to) {
40 fClones->Clear();
41 Int_t size = to->GetEntriesFast();
42 to->ExpandCreateFast(size);
43 for (int i = 0; i < size; i++) {
44 T* obj_from = (T*) fClones->UncheckedAt(i);
45 T* obj_to = (T*) to->UncheckedAt(i);
46 *obj_to = *obj_from;
47 }
48 }
49 template<class T>
50 void CopyCompress(TClonesArray* from, Int_t* map, Int_t map_size) {
51 fClones->Clear();
52 fClones->ExpandCreateFast(map_size);
53 for (int i = 0; i < map_size; i++) {
54 T* obj_from = (T*) from->UncheckedAt(map[i]);
55 T* obj_to = (T*) fClones->UncheckedAt(i);
56 *obj_to = *obj_from;
57 }
58 }
59 Int_t GetEntriesFast() const { return fClones->GetEntriesFast(); };
60 Bool_t ExistInTree() const;
61 TString GetBranchName() const { return fBranchName; }
62 TObject* UncheckedAt(Int_t i) const { return fClones->UncheckedAt(i); }
63 TClonesArray* GetArray() const { return fClones; };
64 virtual ~TrackClones();
65 ClassDef(TrackClones, 1)
66 };
67} // namespace Hal
68#endif /* HALTRACKCLONES_H_ */