Fork me on GitHub

source: git/display/DelphesBranchElement.cc@ 7b720ac

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 7b720ac was 273735d, checked in by Pavel Demin <pavel-demin@…>, 8 years ago

switch MET from TEveArrow to TEveTrack in DelphesBranchElement.cc

  • Property mode set to 100644
File size: 11.1 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 // MissingET as invisible track (like a photon)
90 MissingET *MET;
91 TEveTrack *eveMet;
92 TEveTrackPropagator *trkProp = new TEveTrackPropagator();
93 trkProp->SetMagField(0., 0., -tk_Bz_);
94 trkProp->SetMaxR(tkRadius_);
95 trkProp->SetMaxZ(tkHalfLength_);
96 if(branch_->GetEntriesFast() > 0) {
97 MET = (MissingET*) branch_->At(0);
98 TParticle pb(13, 1, 0, 0, 0, 0,
99 (tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi),
100 (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi),
101 0., MET->MET, 0.0, 0.0, 0.0, 0.0);
102 eveMet = new TEveTrack(&pb, 0, trkProp);
103 eveMet->SetName("Missing Et");
104 eveMet->SetStdTitle();
105 eveMet->SetRnrPoints(0);
106 eveMet->SetMarkerColor(kMagenta);
107 eveMet->SetMarkerStyle(4);
108 eveMet->SetMarkerSize(2.);
109 eveMet->SetLineWidth(2.);
110 eveMet->SetLineStyle(7);
111 data_->AddElement(eveMet);
112 eveMet->SetLineColor(GetColor());
113 eveMet->MakeTrack();
114 }
115 }
116}
117template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
118 std::vector<TLorentzVector> output;
119 if(TString(GetType())=="Jet") {
120 TIter itJet(branch_);
121 Jet *jet;
122 // Loop over all jets
123 while((jet = (Jet *) itJet.Next())) {
124 TLorentzVector v;
125 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
126 output.push_back(v);
127 }
128 } else if(TString(GetType())=="MissingET") {
129 TIter itMet(branch_);
130 MissingET *MET;
131 // Missing Et
132 while((MET = (MissingET*) itMet.Next())) {
133 TLorentzVector v;
134 v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
135 output.push_back(v);
136 }
137 }
138 return output;
139}
140
141// special case for track lists
142template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
143 data_ = new TEveTrackList(name);
144 data_->SetMainColor(color_);
145 data_->SetMarkerColor(color_);
146 data_->SetMarkerStyle(kCircle);
147 data_->SetMarkerSize(0.5);
148}
149template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
150 tkRadius_ = r;
151 tkHalfLength_ = l;
152 tk_Bz_ = Bz;
153 TEveTrackPropagator *trkProp = data_->GetPropagator();
154 trkProp->SetMagField(0., 0., -tk_Bz_);
155 trkProp->SetMaxR(tkRadius_);
156 trkProp->SetMaxZ(tkHalfLength_);
157}
158template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
159template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
160 TString type = GetType();
161 TIter itTrack(branch_);
162 Int_t counter = 0;
163 TEveTrack *eveTrack;
164 TEveTrackPropagator *trkProp = data_->GetPropagator();
165 trkProp->SetMagField(0., 0., -tk_Bz_);
166 trkProp->SetMaxR(tkRadius_);
167 trkProp->SetMaxZ(tkHalfLength_);
168 GenParticle *particle;
169 if(type=="Track") { // CASE 1: TRACKS
170 Track *track;
171 while((track = (Track *) itTrack.Next())) {
172 TParticle pb(track->PID, 1, 0, 0, 0, 0,
173 track->P4().Px(), track->P4().Py(),
174 track->P4().Pz(), track->P4().E(),
175 track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
176 eveTrack = new TEveTrack(&pb, counter, trkProp);
177 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
178 eveTrack->SetStdTitle();
179 eveTrack->SetAttLineAttMarker(data_);
180 data_->AddElement(eveTrack);
181 eveTrack->SetLineColor(GetColor());
182 eveTrack->MakeTrack();
183 }
184 } else if(type=="Electron") { // CASE 2: ELECTRONS
185 Electron *electron;
186 while((electron = (Electron *) itTrack.Next())) {
187 particle = (GenParticle*) electron->Particle.GetObject();
188 TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
189 electron->P4().Px(), electron->P4().Py(),
190 electron->P4().Pz(), electron->P4().E(),
191 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
192 eveTrack = new TEveTrack(&pb, counter, trkProp);
193 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
194 eveTrack->SetStdTitle();
195 eveTrack->SetAttLineAttMarker(data_);
196 data_->AddElement(eveTrack);
197 eveTrack->SetLineColor(GetColor());
198 eveTrack->MakeTrack();
199 }
200 } else if(type=="Muon") { // CASE 3: MUONS
201 Muon *muon;
202 while((muon = (Muon *) itTrack.Next())) {
203 particle = (GenParticle*) muon->Particle.GetObject();
204 TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
205 muon->P4().Px(), muon->P4().Py(),
206 muon->P4().Pz(), muon->P4().E(),
207 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
208 eveTrack = new TEveTrack(&pb, counter, trkProp);
209 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
210 eveTrack->SetStdTitle();
211 eveTrack->SetAttLineAttMarker(data_);
212 data_->AddElement(eveTrack);
213 eveTrack->SetLineColor(GetColor());
214 eveTrack->MakeTrack();
215 }
216 } else if(type=="Photon") { // CASE 4: PHOTONS
217 Photon *photon;
218 while((photon = (Photon *) itTrack.Next())) {
219 TParticle pb(22, 1, 0, 0, 0, 0,
220 photon->P4().Px(), photon->P4().Py(),
221 photon->P4().Pz(), photon->P4().E(),
222 0.0, 0.0, 0.0, 0.0);
223 eveTrack = new TEveTrack(&pb, counter, trkProp);
224 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
225 eveTrack->SetStdTitle();
226 eveTrack->SetAttLineAttMarker(data_);
227 eveTrack->SetLineStyle(7);
228 data_->AddElement(eveTrack);
229 eveTrack->SetLineColor(GetColor());
230 eveTrack->MakeTrack();
231 }
232 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
233 GenParticle *particle;
234 while((particle = (GenParticle *) itTrack.Next())) {
235 if(particle->Status != 1) continue;
236 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
237 particle->P4().Px(), particle->P4().Py(),
238 particle->P4().Pz(), particle->P4().E(),
239 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
240 eveTrack = new TEveTrack(&pb, counter, trkProp);
241 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
242 eveTrack->SetStdTitle();
243 eveTrack->SetAttLineAttMarker(data_);
244 data_->AddElement(eveTrack);
245 eveTrack->SetLineColor(GetColor());
246 if(particle->Charge==0) eveTrack->SetLineStyle(7);
247 eveTrack->MakeTrack();
248 }
249 }
250}
251template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
252 std::vector<TLorentzVector> output;
253 TString type = GetType();
254 TIter itTrack(branch_);
255 if(type=="Track") { // CASE 1: TRACKS
256 Track *track;
257 while((track = (Track *) itTrack.Next())) {
258 output.push_back(track->P4());
259 }
260 } else if(type=="Electron") { // CASE 2: ELECTRONS
261 Electron *electron;
262 while((electron = (Electron *) itTrack.Next())) {
263 output.push_back(electron->P4());
264 }
265 } else if(type=="Muon") { // CASE 3: MUONS
266 Muon *muon;
267 while((muon = (Muon *) itTrack.Next())) {
268 output.push_back(muon->P4());
269 }
270 } else if(type=="Photon") { // CASE 4: PHOTONS
271 Photon *photon;
272 while((photon = (Photon *) itTrack.Next())) {
273 output.push_back(photon->P4());
274 }
275 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
276 GenParticle *particle;
277 while((particle = (GenParticle *) itTrack.Next())) {
278 if(particle->Status != 1) continue;
279 output.push_back(particle->P4());
280 }
281 }
282 return output;
283}
Note: See TracBrowser for help on using the repository browser.