1 | /*
|
---|
2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef DelphesBranchElement_h
|
---|
20 | #define DelphesBranchElement_h
|
---|
21 |
|
---|
22 | #include "TColor.h"
|
---|
23 | #include "TString.h"
|
---|
24 | #include "TClonesArray.h"
|
---|
25 | #include "TClass.h"
|
---|
26 | #include <exception>
|
---|
27 | #include <iostream>
|
---|
28 | #include "display/DelphesCaloData.h"
|
---|
29 | #include "TEveElement.h"
|
---|
30 | #include "TEveTrack.h"
|
---|
31 |
|
---|
32 | // virtual class to represent objects from a Delphes-tree branch
|
---|
33 | class DelphesBranchBase
|
---|
34 | {
|
---|
35 | public:
|
---|
36 | DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):name_(name),branch_(branch),color_(color) {}
|
---|
37 | virtual ~DelphesBranchBase() {}
|
---|
38 | const char* GetName() const { return (const char*)name_; }
|
---|
39 | const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
|
---|
40 | virtual const char* GetClassName() = 0;
|
---|
41 | enum EColor GetColor() const { return color_; }
|
---|
42 | virtual void Reset() = 0;
|
---|
43 | virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
|
---|
44 | virtual void ReadBranch() = 0;
|
---|
45 | virtual std::vector<TLorentzVector> GetVectors() = 0;
|
---|
46 |
|
---|
47 | protected:
|
---|
48 | TString name_;
|
---|
49 | Float_t maxPt_;
|
---|
50 | TClonesArray* branch_;
|
---|
51 | const enum EColor color_;
|
---|
52 | Float_t tkRadius_,tkHalfLength_, tk_Bz_;
|
---|
53 | };
|
---|
54 |
|
---|
55 | // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
|
---|
56 | template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase
|
---|
57 | {
|
---|
58 | public:
|
---|
59 | // constructor
|
---|
60 | DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):DelphesBranchBase(name, branch, color, maxPt) {
|
---|
61 | throw std::exception();
|
---|
62 | }
|
---|
63 |
|
---|
64 | // destructor
|
---|
65 | virtual ~DelphesBranchElement() { delete data_; }
|
---|
66 |
|
---|
67 | // get the container (ElementList, TrackList, or CaloData)
|
---|
68 | EveContainer* GetContainer() { return data_; }
|
---|
69 |
|
---|
70 | // tracking volume
|
---|
71 | virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
|
---|
72 |
|
---|
73 | // resets the collection (before moving to the next event)
|
---|
74 | virtual void Reset() {};
|
---|
75 |
|
---|
76 | // template class name
|
---|
77 | virtual const char* GetClassName() { return data_->ClassName(); }
|
---|
78 |
|
---|
79 | // read the branch and fill elements for display
|
---|
80 | virtual void ReadBranch() {}
|
---|
81 |
|
---|
82 | // return the vector for all elements
|
---|
83 | virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; }
|
---|
84 |
|
---|
85 | private:
|
---|
86 | EveContainer* data_;
|
---|
87 | };
|
---|
88 |
|
---|
89 | #if !defined(__CINT__) && !defined(__CLING__)
|
---|
90 |
|
---|
91 | // special case for calo towers
|
---|
92 | template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
|
---|
93 | template<> void DelphesBranchElement<DelphesCaloData>::Reset();
|
---|
94 | template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
|
---|
95 | template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
|
---|
96 |
|
---|
97 | // special case for element lists
|
---|
98 | template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
|
---|
99 | template<> void DelphesBranchElement<TEveElementList>::Reset();
|
---|
100 | template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
|
---|
101 | template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
|
---|
102 |
|
---|
103 | // special case for track lists
|
---|
104 | template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
|
---|
105 | template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
|
---|
106 | template<> void DelphesBranchElement<TEveTrackList>::Reset();
|
---|
107 | template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
|
---|
108 | template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
|
---|
109 |
|
---|
110 | #endif // CINT, CLING
|
---|
111 |
|
---|
112 | #endif //DelphesBranchElement_h
|
---|