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 | #include "display/DelphesBranchElement.h"
|
---|
20 | #include "classes/DelphesClasses.h"
|
---|
21 | #include "TEveJetCone.h"
|
---|
22 | #include "TEveTrack.h"
|
---|
23 | #include "TEveTrackPropagator.h"
|
---|
24 | #include "TEveArrow.h"
|
---|
25 | #include "TEveVector.h"
|
---|
26 | #include <iostream>
|
---|
27 |
|
---|
28 | // special case for calo towers
|
---|
29 | template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
|
---|
30 | data_ = new DelphesCaloData(2);
|
---|
31 | data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
|
---|
32 | data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
|
---|
33 | data_->IncDenyDestroy();
|
---|
34 | }
|
---|
35 | template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
|
---|
36 | template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
|
---|
37 | if(TString(GetType())=="Tower") {
|
---|
38 | // Loop over all towers
|
---|
39 | TIter itTower(branch_);
|
---|
40 | Tower *tower;
|
---|
41 | while((tower = (Tower *) itTower.Next())) {
|
---|
42 | data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
|
---|
43 | data_->FillSlice(0, tower->Eem);
|
---|
44 | data_->FillSlice(1, tower->Ehad);
|
---|
45 | }
|
---|
46 | data_->DataChanged();
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | // special case for element lists
|
---|
51 | template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
|
---|
52 | data_ = new TEveElementList(name);
|
---|
53 | data_->SetMainColor(color_);
|
---|
54 | }
|
---|
55 | template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
|
---|
56 | template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
|
---|
57 | if(TString(GetType())=="Jet") {
|
---|
58 | TIter itJet(branch_);
|
---|
59 | Jet *jet;
|
---|
60 | TEveJetCone *eveJetCone;
|
---|
61 | // Loop over all jets
|
---|
62 | Int_t counter = 0;
|
---|
63 | while((jet = (Jet *) itJet.Next())) {
|
---|
64 | eveJetCone = new TEveJetCone();
|
---|
65 | eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
|
---|
66 | eveJetCone->SetName(Form("jet [%d]", counter++));
|
---|
67 | eveJetCone->SetMainTransparency(60);
|
---|
68 | eveJetCone->SetLineColor(GetColor());
|
---|
69 | eveJetCone->SetFillColor(GetColor());
|
---|
70 | eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
|
---|
71 | eveJetCone->SetPickable(kTRUE);
|
---|
72 | eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
|
---|
73 | data_->AddElement(eveJetCone);
|
---|
74 | }
|
---|
75 | } else if(TString(GetType())=="MissingET") {
|
---|
76 | TIter itMet(branch_);
|
---|
77 | MissingET *MET;
|
---|
78 | TEveArrow *eveMet;
|
---|
79 | // Missing Et
|
---|
80 | while((MET = (MissingET*) itMet.Next())) {
|
---|
81 | eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi), 0., 0., 0., 0.);
|
---|
82 | eveMet->SetMainColor(GetColor());
|
---|
83 | eveMet->SetTubeR(0.04);
|
---|
84 | eveMet->SetConeR(0.08);
|
---|
85 | eveMet->SetConeL(0.10);
|
---|
86 | eveMet->SetPickable(kTRUE);
|
---|
87 | eveMet->SetName("Missing Et");
|
---|
88 | eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
|
---|
89 | data_->AddElement(eveMet);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | // special case for track lists
|
---|
95 | template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
|
---|
96 | data_ = new TEveTrackList(name);
|
---|
97 | data_->SetMainColor(color_);
|
---|
98 | data_->SetMarkerColor(color_);
|
---|
99 | data_->SetMarkerStyle(kCircle);
|
---|
100 | data_->SetMarkerSize(0.5);
|
---|
101 | }
|
---|
102 | template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
|
---|
103 | tkRadius_ = r;
|
---|
104 | tkHalfLength_ = l;
|
---|
105 | tk_Bz_ = Bz;
|
---|
106 | TEveTrackPropagator *trkProp = data_->GetPropagator();
|
---|
107 | trkProp->SetMagField(0., 0., -tk_Bz_);
|
---|
108 | trkProp->SetMaxR(tkRadius_);
|
---|
109 | trkProp->SetMaxZ(tkHalfLength_);
|
---|
110 | }
|
---|
111 | template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
|
---|
112 | template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
|
---|
113 | TString type = GetType();
|
---|
114 | TIter itTrack(branch_);
|
---|
115 | Int_t counter = 0;
|
---|
116 | TEveTrack *eveTrack;
|
---|
117 | TEveTrackPropagator *trkProp = data_->GetPropagator();
|
---|
118 | trkProp->SetMagField(0., 0., -tk_Bz_);
|
---|
119 | trkProp->SetMaxR(tkRadius_);
|
---|
120 | trkProp->SetMaxZ(tkHalfLength_);
|
---|
121 | if(type=="Track") { // CASE 1: TRACKS
|
---|
122 | Track *track;
|
---|
123 | while((track = (Track *) itTrack.Next())) {
|
---|
124 | TParticle pb(track->PID, 1, 0, 0, 0, 0,
|
---|
125 | track->P4().Px(), track->P4().Py(),
|
---|
126 | track->P4().Pz(), track->P4().E(),
|
---|
127 | track->X, track->Y, track->Z, 0.0);
|
---|
128 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
129 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
130 | eveTrack->SetStdTitle();
|
---|
131 | eveTrack->SetAttLineAttMarker(data_);
|
---|
132 | data_->AddElement(eveTrack);
|
---|
133 | eveTrack->SetLineColor(GetColor());
|
---|
134 | eveTrack->MakeTrack();
|
---|
135 | }
|
---|
136 | } else if(type=="Electron") { // CASE 2: ELECTRONS
|
---|
137 | Electron *electron;
|
---|
138 | while((electron = (Electron *) itTrack.Next())) {
|
---|
139 | TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
|
---|
140 | electron->P4().Px(), electron->P4().Py(),
|
---|
141 | electron->P4().Pz(), electron->P4().E(),
|
---|
142 | 0., 0., 0., 0.);
|
---|
143 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
144 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
145 | eveTrack->SetStdTitle();
|
---|
146 | eveTrack->SetAttLineAttMarker(data_);
|
---|
147 | data_->AddElement(eveTrack);
|
---|
148 | eveTrack->SetLineColor(GetColor());
|
---|
149 | eveTrack->MakeTrack();
|
---|
150 | }
|
---|
151 | } else if(type=="Muon") { // CASE 3: MUONS
|
---|
152 | Muon *muon;
|
---|
153 | while((muon = (Muon *) itTrack.Next())) {
|
---|
154 | TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
|
---|
155 | muon->P4().Px(), muon->P4().Py(),
|
---|
156 | muon->P4().Pz(), muon->P4().E(),
|
---|
157 | 0., 0., 0., 0.);
|
---|
158 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
159 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
160 | eveTrack->SetStdTitle();
|
---|
161 | eveTrack->SetAttLineAttMarker(data_);
|
---|
162 | data_->AddElement(eveTrack);
|
---|
163 | eveTrack->SetLineColor(GetColor());
|
---|
164 | eveTrack->MakeTrack();
|
---|
165 | }
|
---|
166 | } else if(type=="Photon") { // CASE 4: PHOTONS
|
---|
167 | Photon *photon;
|
---|
168 | while((photon = (Photon *) itTrack.Next())) {
|
---|
169 | TParticle pb(22, 1, 0, 0, 0, 0,
|
---|
170 | photon->P4().Px(), photon->P4().Py(),
|
---|
171 | photon->P4().Pz(), photon->P4().E(),
|
---|
172 | 0., 0., 0., 0.);
|
---|
173 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
174 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
175 | eveTrack->SetStdTitle();
|
---|
176 | eveTrack->SetAttLineAttMarker(data_);
|
---|
177 | eveTrack->SetLineStyle(7);
|
---|
178 | data_->AddElement(eveTrack);
|
---|
179 | eveTrack->SetLineColor(GetColor());
|
---|
180 | eveTrack->MakeTrack();
|
---|
181 | }
|
---|
182 | } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
|
---|
183 | GenParticle *particle;
|
---|
184 | while((particle = (GenParticle *) itTrack.Next())) {
|
---|
185 | if(particle->Status != 1) continue;
|
---|
186 | TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
|
---|
187 | particle->P4().Px(), particle->P4().Py(),
|
---|
188 | particle->P4().Pz(), particle->P4().E(),
|
---|
189 | particle->X, particle->Y, particle->Z, particle->T);
|
---|
190 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
191 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
192 | eveTrack->SetStdTitle();
|
---|
193 | eveTrack->SetAttLineAttMarker(data_);
|
---|
194 | data_->AddElement(eveTrack);
|
---|
195 | eveTrack->SetLineColor(GetColor());
|
---|
196 | if(particle->Charge==0) eveTrack->SetLineStyle(7);
|
---|
197 | eveTrack->MakeTrack();
|
---|
198 | }
|
---|
199 | }
|
---|
200 | }
|
---|