[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
|
---|
| 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"
|
---|
[4fd37d4] | 24 | #include "TClonesArray.h"
|
---|
| 25 | #include "TClass.h"
|
---|
[5bb66c9] | 26 | #include <exception>
|
---|
[4fd37d4] | 27 | #include <iostream>
|
---|
[5bb66c9] | 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:
|
---|
[4fd37d4] | 36 | DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):name_(name),branch_(branch),color_(color) {}
|
---|
| 37 | virtual ~DelphesBranchBase() {}
|
---|
[5bb66c9] | 38 | const char* GetName() const { return (const char*)name_; }
|
---|
[4fd37d4] | 39 | const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
|
---|
[5bb66c9] | 40 | virtual const char* GetClassName() = 0;
|
---|
[4fd37d4] | 41 | enum EColor GetColor() const { return color_; }
|
---|
[5bb66c9] | 42 | virtual void Reset() = 0;
|
---|
[4fd37d4] | 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;
|
---|
[5bb66c9] | 45 |
|
---|
| 46 | protected:
|
---|
| 47 | TString name_;
|
---|
[4fd37d4] | 48 | TClonesArray* branch_;
|
---|
[5bb66c9] | 49 | const enum EColor color_;
|
---|
[4fd37d4] | 50 | Float_t tkRadius_,tkHalfLength_, tk_Bz_;
|
---|
[5bb66c9] | 51 | };
|
---|
| 52 |
|
---|
| 53 | // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
|
---|
| 54 | template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase
|
---|
| 55 | {
|
---|
| 56 | public:
|
---|
| 57 | // constructor
|
---|
[4fd37d4] | 58 | DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):DelphesBranchBase(name, branch, color) {
|
---|
[4d999a57] | 59 | throw std::exception();
|
---|
| 60 | }
|
---|
[5bb66c9] | 61 |
|
---|
| 62 | // destructor
|
---|
| 63 | virtual ~DelphesBranchElement() { delete data_; }
|
---|
| 64 |
|
---|
| 65 | // get the container (ElementList, TrackList, or CaloData)
|
---|
| 66 | EveContainer* GetContainer() { return data_; }
|
---|
| 67 |
|
---|
[4fd37d4] | 68 | // tracking volume
|
---|
| 69 | virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
|
---|
| 70 |
|
---|
[5bb66c9] | 71 | // resets the collection (before moving to the next event)
|
---|
[4d999a57] | 72 | virtual void Reset() {};
|
---|
[5bb66c9] | 73 |
|
---|
| 74 | // template class name
|
---|
| 75 | virtual const char* GetClassName() { return data_->ClassName(); }
|
---|
| 76 |
|
---|
[4fd37d4] | 77 | // read the branch and fill elements for display
|
---|
| 78 | virtual void ReadBranch() {}
|
---|
| 79 |
|
---|
[5bb66c9] | 80 | private:
|
---|
| 81 | EveContainer* data_;
|
---|
| 82 | };
|
---|
| 83 |
|
---|
[4d999a57] | 84 | #if !defined(__CINT__) && !defined(__CLING__)
|
---|
[115298d] | 85 |
|
---|
[4d999a57] | 86 | // special case for calo towers
|
---|
[4fd37d4] | 87 | template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
|
---|
[4d999a57] | 88 | template<> void DelphesBranchElement<DelphesCaloData>::Reset();
|
---|
[4fd37d4] | 89 | template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
|
---|
[5bb66c9] | 90 |
|
---|
| 91 | // special case for element lists
|
---|
[4fd37d4] | 92 | template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
|
---|
[4d999a57] | 93 | template<> void DelphesBranchElement<TEveElementList>::Reset();
|
---|
[4fd37d4] | 94 | template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
|
---|
[5bb66c9] | 95 |
|
---|
| 96 | // special case for track lists
|
---|
[4fd37d4] | 97 | template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color);
|
---|
| 98 | template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
|
---|
[4d999a57] | 99 | template<> void DelphesBranchElement<TEveTrackList>::Reset();
|
---|
[4fd37d4] | 100 | template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
|
---|
[115298d] | 101 |
|
---|
[4d999a57] | 102 | #endif // CINT, CLING
|
---|
[5bb66c9] | 103 |
|
---|
| 104 | #endif //DelphesBranchElement_h
|
---|