Fork me on GitHub

source: git/display/DelphesBranchElement.cc@ 239e1d0

ImprovedOutputFile Timing dual_readout llp 3.3.3pre11
Last change on this file since 239e1d0 was 486c4c3, checked in by Michele Selvaggi <michele.selvaggi@…>, 10 years ago

fix particle vertices in Event Display

  • Property mode set to 100644
File size: 10.7 KB
Line 
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
29template<> 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}
35template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
36template<> 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}
49template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() {
50 std::vector<TLorentzVector> output;
51 if(TString(GetType())=="Tower") {
52 TIter itTower(branch_);
53 Tower *tower;
54 while((tower = (Tower *) itTower.Next())) {
55 TLorentzVector v;
56 v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);
57 output.push_back(v);
58 }
59 }
60 return output;
61}
62
63// special case for element lists
64template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
65 data_ = new TEveElementList(name);
66 data_->SetMainColor(color_);
67}
68template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
69template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
70 if(TString(GetType())=="Jet") {
71 TIter itJet(branch_);
72 Jet *jet;
73 TEveJetCone *eveJetCone;
74 // Loop over all jets
75 Int_t counter = 0;
76 while((jet = (Jet *) itJet.Next())) {
77 eveJetCone = new TEveJetCone();
78 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
79 eveJetCone->SetName(Form("jet [%d]", counter++));
80 eveJetCone->SetMainTransparency(60);
81 eveJetCone->SetLineColor(GetColor());
82 eveJetCone->SetFillColor(GetColor());
83 eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
84 eveJetCone->SetPickable(kTRUE);
85 eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
86 data_->AddElement(eveJetCone);
87 }
88 } else if(TString(GetType())=="MissingET") {
89 TIter itMet(branch_);
90 MissingET *MET;
91 TEveArrow *eveMet;
92 // Missing Et
93 while((MET = (MissingET*) itMet.Next())) {
94 eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi), 0., 0., 0., 0.);
95 eveMet->SetMainColor(GetColor());
96 eveMet->SetTubeR(0.04);
97 eveMet->SetConeR(0.08);
98 eveMet->SetConeL(0.10);
99 eveMet->SetPickable(kTRUE);
100 eveMet->SetName("Missing Et");
101 eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
102 data_->AddElement(eveMet);
103 }
104 }
105}
106template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
107 std::vector<TLorentzVector> output;
108 if(TString(GetType())=="Jet") {
109 TIter itJet(branch_);
110 Jet *jet;
111 // Loop over all jets
112 while((jet = (Jet *) itJet.Next())) {
113 TLorentzVector v;
114 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
115 output.push_back(v);
116 }
117 } else if(TString(GetType())=="MissingET") {
118 TIter itMet(branch_);
119 MissingET *MET;
120 // Missing Et
121 while((MET = (MissingET*) itMet.Next())) {
122 TLorentzVector v;
123 v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
124 output.push_back(v);
125 }
126 }
127 return output;
128}
129
130// special case for track lists
131template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
132 data_ = new TEveTrackList(name);
133 data_->SetMainColor(color_);
134 data_->SetMarkerColor(color_);
135 data_->SetMarkerStyle(kCircle);
136 data_->SetMarkerSize(0.5);
137}
138template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
139 tkRadius_ = r;
140 tkHalfLength_ = l;
141 tk_Bz_ = Bz;
142 TEveTrackPropagator *trkProp = data_->GetPropagator();
143 trkProp->SetMagField(0., 0., -tk_Bz_);
144 trkProp->SetMaxR(tkRadius_);
145 trkProp->SetMaxZ(tkHalfLength_);
146}
147template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
148template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
149 TString type = GetType();
150 TIter itTrack(branch_);
151 Int_t counter = 0;
152 TEveTrack *eveTrack;
153 TEveTrackPropagator *trkProp = data_->GetPropagator();
154 trkProp->SetMagField(0., 0., -tk_Bz_);
155 trkProp->SetMaxR(tkRadius_);
156 trkProp->SetMaxZ(tkHalfLength_);
157 GenParticle *particle;
158 if(type=="Track") { // CASE 1: TRACKS
159 Track *track;
160 while((track = (Track *) itTrack.Next())) {
161 TParticle pb(track->PID, 1, 0, 0, 0, 0,
162 track->P4().Px(), track->P4().Py(),
163 track->P4().Pz(), track->P4().E(),
164 track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
165 eveTrack = new TEveTrack(&pb, counter, trkProp);
166 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
167 eveTrack->SetStdTitle();
168 eveTrack->SetAttLineAttMarker(data_);
169 data_->AddElement(eveTrack);
170 eveTrack->SetLineColor(GetColor());
171 eveTrack->MakeTrack();
172 }
173 } else if(type=="Electron") { // CASE 2: ELECTRONS
174 Electron *electron;
175 while((electron = (Electron *) itTrack.Next())) {
176 particle = (GenParticle*) electron->Particle.GetObject();
177 TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
178 electron->P4().Px(), electron->P4().Py(),
179 electron->P4().Pz(), electron->P4().E(),
180 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
181 eveTrack = new TEveTrack(&pb, counter, trkProp);
182 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
183 eveTrack->SetStdTitle();
184 eveTrack->SetAttLineAttMarker(data_);
185 data_->AddElement(eveTrack);
186 eveTrack->SetLineColor(GetColor());
187 eveTrack->MakeTrack();
188 }
189 } else if(type=="Muon") { // CASE 3: MUONS
190 Muon *muon;
191 while((muon = (Muon *) itTrack.Next())) {
192 particle = (GenParticle*) muon->Particle.GetObject();
193 TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
194 muon->P4().Px(), muon->P4().Py(),
195 muon->P4().Pz(), muon->P4().E(),
196 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
197 eveTrack = new TEveTrack(&pb, counter, trkProp);
198 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
199 eveTrack->SetStdTitle();
200 eveTrack->SetAttLineAttMarker(data_);
201 data_->AddElement(eveTrack);
202 eveTrack->SetLineColor(GetColor());
203 eveTrack->MakeTrack();
204 }
205 } else if(type=="Photon") { // CASE 4: PHOTONS
206 Photon *photon;
207 while((photon = (Photon *) itTrack.Next())) {
208 TParticle pb(22, 1, 0, 0, 0, 0,
209 photon->P4().Px(), photon->P4().Py(),
210 photon->P4().Pz(), photon->P4().E(),
211 0.0, 0.0, 0.0, 0.0);
212 eveTrack = new TEveTrack(&pb, counter, trkProp);
213 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
214 eveTrack->SetStdTitle();
215 eveTrack->SetAttLineAttMarker(data_);
216 eveTrack->SetLineStyle(7);
217 data_->AddElement(eveTrack);
218 eveTrack->SetLineColor(GetColor());
219 eveTrack->MakeTrack();
220 }
221 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
222 GenParticle *particle;
223 while((particle = (GenParticle *) itTrack.Next())) {
224 if(particle->Status != 1) continue;
225 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
226 particle->P4().Px(), particle->P4().Py(),
227 particle->P4().Pz(), particle->P4().E(),
228 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
229 eveTrack = new TEveTrack(&pb, counter, trkProp);
230 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
231 eveTrack->SetStdTitle();
232 eveTrack->SetAttLineAttMarker(data_);
233 data_->AddElement(eveTrack);
234 eveTrack->SetLineColor(GetColor());
235 if(particle->Charge==0) eveTrack->SetLineStyle(7);
236 eveTrack->MakeTrack();
237 }
238 }
239}
240template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
241 std::vector<TLorentzVector> output;
242 TString type = GetType();
243 TIter itTrack(branch_);
244 if(type=="Track") { // CASE 1: TRACKS
245 Track *track;
246 while((track = (Track *) itTrack.Next())) {
247 output.push_back(track->P4());
248 }
249 } else if(type=="Electron") { // CASE 2: ELECTRONS
250 Electron *electron;
251 while((electron = (Electron *) itTrack.Next())) {
252 output.push_back(electron->P4());
253 }
254 } else if(type=="Muon") { // CASE 3: MUONS
255 Muon *muon;
256 while((muon = (Muon *) itTrack.Next())) {
257 output.push_back(muon->P4());
258 }
259 } else if(type=="Photon") { // CASE 4: PHOTONS
260 Photon *photon;
261 while((photon = (Photon *) itTrack.Next())) {
262 output.push_back(photon->P4());
263 }
264 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
265 GenParticle *particle;
266 while((particle = (GenParticle *) itTrack.Next())) {
267 if(particle->Status != 1) continue;
268 output.push_back(particle->P4());
269 }
270 }
271 return output;
272}
Note: See TracBrowser for help on using the repository browser.