[5bb66c9] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
[1fa50c2] | 4 | *
|
---|
[5bb66c9] | 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.
|
---|
[1fa50c2] | 9 | *
|
---|
[5bb66c9] | 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.
|
---|
[1fa50c2] | 14 | *
|
---|
[5bb66c9] | 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 |
|
---|
[341014c] | 22 | #include "TClass.h"
|
---|
| 23 | #include "TClonesArray.h"
|
---|
[5bb66c9] | 24 | #include "TColor.h"
|
---|
[341014c] | 25 | #include "TEveElement.h"
|
---|
| 26 | #include "TEveTrack.h"
|
---|
[5bb66c9] | 27 | #include "TString.h"
|
---|
[341014c] | 28 | #include "display/DelphesCaloData.h"
|
---|
[5bb66c9] | 29 | #include <exception>
|
---|
[4fd37d4] | 30 | #include <iostream>
|
---|
[5bb66c9] | 31 |
|
---|
| 32 | // virtual class to represent objects from a Delphes-tree branch
|
---|
| 33 | class DelphesBranchBase
|
---|
| 34 | {
|
---|
[341014c] | 35 | public:
|
---|
| 36 | DelphesBranchBase(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
|
---|
| 37 | name_(name), maxPt_(maxPt), branch_(branch), color_(color) {}
|
---|
| 38 | virtual ~DelphesBranchBase() {}
|
---|
| 39 | const char *GetName() const { return (const char *)name_; }
|
---|
| 40 | const char *GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
|
---|
| 41 | virtual const char *GetClassName() = 0;
|
---|
| 42 | enum EColor GetColor() const { return color_; }
|
---|
| 43 | virtual void Reset() = 0;
|
---|
| 44 | virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
|
---|
| 45 | {
|
---|
| 46 | tkRadius_ = r;
|
---|
| 47 | tkHalfLength_ = l;
|
---|
| 48 | tk_Bz_ = Bz;
|
---|
| 49 | }
|
---|
| 50 | virtual void ReadBranch() = 0;
|
---|
| 51 | virtual std::vector<TLorentzVector> GetVectors() = 0;
|
---|
| 52 |
|
---|
| 53 | protected:
|
---|
| 54 | TString name_;
|
---|
| 55 | Float_t maxPt_;
|
---|
| 56 | TClonesArray *branch_;
|
---|
| 57 | const enum EColor color_;
|
---|
| 58 | Float_t tkRadius_, tkHalfLength_, tk_Bz_;
|
---|
[5bb66c9] | 59 | };
|
---|
| 60 |
|
---|
| 61 | // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
|
---|
[341014c] | 62 | template <typename EveContainer>
|
---|
| 63 | class DelphesBranchElement: public DelphesBranchBase
|
---|
[5bb66c9] | 64 | {
|
---|
[341014c] | 65 | public:
|
---|
| 66 | // constructor
|
---|
| 67 | DelphesBranchElement(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
|
---|
| 68 | DelphesBranchBase(name, branch, color, maxPt)
|
---|
| 69 | {
|
---|
| 70 | throw std::exception();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | // destructor
|
---|
| 74 | virtual ~DelphesBranchElement() { delete data_; }
|
---|
| 75 |
|
---|
| 76 | // get the container (ElementList, TrackList, or CaloData)
|
---|
| 77 | EveContainer *GetContainer() { return data_; }
|
---|
| 78 |
|
---|
| 79 | // tracking volume
|
---|
| 80 | virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
|
---|
| 81 | {
|
---|
| 82 | tkRadius_ = r;
|
---|
| 83 | tkHalfLength_ = l;
|
---|
| 84 | tk_Bz_ = Bz;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | // resets the collection (before moving to the next event)
|
---|
| 88 | virtual void Reset(){};
|
---|
| 89 |
|
---|
| 90 | // template class name
|
---|
| 91 | virtual const char *GetClassName() { return data_->ClassName(); }
|
---|
| 92 |
|
---|
| 93 | // read the branch and fill elements for display
|
---|
| 94 | virtual void ReadBranch() {}
|
---|
| 95 |
|
---|
| 96 | // return the vector for all elements
|
---|
| 97 | virtual std::vector<TLorentzVector> GetVectors()
|
---|
| 98 | {
|
---|
| 99 | std::vector<TLorentzVector> v;
|
---|
| 100 | return v;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | private:
|
---|
| 104 | EveContainer *data_;
|
---|
[5bb66c9] | 105 | };
|
---|
| 106 |
|
---|
[4d999a57] | 107 | #if !defined(__CINT__) && !defined(__CLING__)
|
---|
[115298d] | 108 |
|
---|
[4d999a57] | 109 | // special case for calo towers
|
---|
[341014c] | 110 | template <>
|
---|
| 111 | DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
|
---|
| 112 | template <>
|
---|
| 113 | void DelphesBranchElement<DelphesCaloData>::Reset();
|
---|
| 114 | template <>
|
---|
| 115 | void DelphesBranchElement<DelphesCaloData>::ReadBranch();
|
---|
| 116 | template <>
|
---|
| 117 | std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
|
---|
[5bb66c9] | 118 |
|
---|
| 119 | // special case for element lists
|
---|
[341014c] | 120 | template <>
|
---|
| 121 | DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
|
---|
| 122 | template <>
|
---|
| 123 | void DelphesBranchElement<TEveElementList>::Reset();
|
---|
| 124 | template <>
|
---|
| 125 | void DelphesBranchElement<TEveElementList>::ReadBranch();
|
---|
| 126 | template <>
|
---|
| 127 | std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
|
---|
[5bb66c9] | 128 |
|
---|
| 129 | // special case for track lists
|
---|
[341014c] | 130 | template <>
|
---|
| 131 | DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
|
---|
| 132 | template <>
|
---|
| 133 | void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
|
---|
| 134 | template <>
|
---|
| 135 | void DelphesBranchElement<TEveTrackList>::Reset();
|
---|
| 136 | template <>
|
---|
| 137 | void DelphesBranchElement<TEveTrackList>::ReadBranch();
|
---|
| 138 | template <>
|
---|
| 139 | std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
|
---|
[115298d] | 140 |
|
---|
[4d999a57] | 141 | #endif // CINT, CLING
|
---|
[5bb66c9] | 142 |
|
---|
| 143 | #endif //DelphesBranchElement_h
|
---|