Fork me on GitHub

source: git/display/DelphesBranchElement.cc@ 584e2e9

Timing
Last change on this file since 584e2e9 was 341014c, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

apply .clang-format to all .h, .cc and .cpp files

  • Property mode set to 100644
File size: 11.1 KB
RevLine 
[4d999a57]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 *
[4d999a57]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 *
[4d999a57]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 *
[4d999a57]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"
[341014c]20#include "TEveArrow.h"
[4fd37d4]21#include "TEveJetCone.h"
22#include "TEveTrack.h"
23#include "TEveTrackPropagator.h"
24#include "TEveVector.h"
[341014c]25#include "classes/DelphesClasses.h"
[4fd37d4]26#include <iostream>
[4d999a57]27
28// special case for calo towers
[341014c]29template <>
30DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
31 DelphesBranchBase(name, branch, color, maxPt)
32{
33 data_ = new DelphesCaloData(2);
34 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
35 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
36 data_->IncDenyDestroy();
[4fd37d4]37}
[341014c]38template <>
39void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
40template <>
41void DelphesBranchElement<DelphesCaloData>::ReadBranch()
42{
43 if(TString(GetType()) == "Tower")
44 {
[4fd37d4]45 // Loop over all towers
46 TIter itTower(branch_);
47 Tower *tower;
[341014c]48 while((tower = (Tower *)itTower.Next()))
49 {
[4fd37d4]50 data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
51 data_->FillSlice(0, tower->Eem);
52 data_->FillSlice(1, tower->Ehad);
53 }
54 data_->DataChanged();
55 }
56}
[341014c]57template <>
58std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors()
59{
[3f51314]60 std::vector<TLorentzVector> output;
[341014c]61 if(TString(GetType()) == "Tower")
62 {
[3f51314]63 TIter itTower(branch_);
64 Tower *tower;
[341014c]65 while((tower = (Tower *)itTower.Next()))
66 {
[3f51314]67 TLorentzVector v;
[341014c]68 v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.);
[3f51314]69 output.push_back(v);
70 }
71 }
72 return output;
73}
[4d999a57]74
75// special case for element lists
[341014c]76template <>
77DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
78 DelphesBranchBase(name, branch, color, maxPt)
79{
80 data_ = new TEveElementList(name);
81 data_->SetMainColor(color_);
[4fd37d4]82}
[341014c]83template <>
84void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
85template <>
86void DelphesBranchElement<TEveElementList>::ReadBranch()
87{
88 if(TString(GetType()) == "Jet")
89 {
[4fd37d4]90 TIter itJet(branch_);
91 Jet *jet;
92 TEveJetCone *eveJetCone;
93 // Loop over all jets
94 Int_t counter = 0;
[341014c]95 while((jet = (Jet *)itJet.Next()))
96 {
[4fd37d4]97 eveJetCone = new TEveJetCone();
[341014c]98 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass));
[4fd37d4]99 eveJetCone->SetName(Form("jet [%d]", counter++));
100 eveJetCone->SetMainTransparency(60);
101 eveJetCone->SetLineColor(GetColor());
102 eveJetCone->SetFillColor(GetColor());
103 eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
104 eveJetCone->SetPickable(kTRUE);
105 eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
106 data_->AddElement(eveJetCone);
107 }
[341014c]108 }
109 else if(TString(GetType()) == "MissingET")
110 {
[273735d]111 // MissingET as invisible track (like a photon)
[4fd37d4]112 MissingET *MET;
[273735d]113 TEveTrack *eveMet;
114 TEveTrackPropagator *trkProp = new TEveTrackPropagator();
115 trkProp->SetMagField(0., 0., -tk_Bz_);
116 trkProp->SetMaxR(tkRadius_);
117 trkProp->SetMaxZ(tkHalfLength_);
[341014c]118 if(branch_->GetEntriesFast() > 0)
119 {
120 MET = (MissingET *)branch_->At(0);
[273735d]121 TParticle pb(13, 1, 0, 0, 0, 0,
[341014c]122 (tkRadius_ * MET->MET / maxPt_) * cos(MET->Phi),
123 (tkRadius_ * MET->MET / maxPt_) * sin(MET->Phi),
124 0., MET->MET, 0.0, 0.0, 0.0, 0.0);
[273735d]125 eveMet = new TEveTrack(&pb, 0, trkProp);
[4fd37d4]126 eveMet->SetName("Missing Et");
[273735d]127 eveMet->SetStdTitle();
128 eveMet->SetRnrPoints(0);
129 eveMet->SetMarkerColor(kMagenta);
130 eveMet->SetMarkerStyle(4);
131 eveMet->SetMarkerSize(2.);
132 eveMet->SetLineWidth(2.);
133 eveMet->SetLineStyle(7);
[4fd37d4]134 data_->AddElement(eveMet);
[273735d]135 eveMet->SetLineColor(GetColor());
136 eveMet->MakeTrack();
[4fd37d4]137 }
138 }
139}
[341014c]140template <>
141std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors()
142{
[3f51314]143 std::vector<TLorentzVector> output;
[341014c]144 if(TString(GetType()) == "Jet")
145 {
[3f51314]146 TIter itJet(branch_);
147 Jet *jet;
148 // Loop over all jets
[341014c]149 while((jet = (Jet *)itJet.Next()))
150 {
[3f51314]151 TLorentzVector v;
152 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
153 output.push_back(v);
154 }
[341014c]155 }
156 else if(TString(GetType()) == "MissingET")
157 {
[3f51314]158 TIter itMet(branch_);
159 MissingET *MET;
160 // Missing Et
[341014c]161 while((MET = (MissingET *)itMet.Next()))
162 {
[3f51314]163 TLorentzVector v;
[341014c]164 v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.);
[3f51314]165 output.push_back(v);
166 }
167 }
168 return output;
169}
[4d999a57]170
171// special case for track lists
[341014c]172template <>
173DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
174 DelphesBranchBase(name, branch, color, maxPt)
175{
[4fd37d4]176 data_ = new TEveTrackList(name);
177 data_->SetMainColor(color_);
178 data_->SetMarkerColor(color_);
179 data_->SetMarkerStyle(kCircle);
180 data_->SetMarkerSize(0.5);
181}
[341014c]182template <>
183void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz)
184{
185 tkRadius_ = r;
[4fd37d4]186 tkHalfLength_ = l;
187 tk_Bz_ = Bz;
188 TEveTrackPropagator *trkProp = data_->GetPropagator();
189 trkProp->SetMagField(0., 0., -tk_Bz_);
190 trkProp->SetMaxR(tkRadius_);
191 trkProp->SetMaxZ(tkHalfLength_);
192}
[341014c]193template <>
194void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
195template <>
196void DelphesBranchElement<TEveTrackList>::ReadBranch()
197{
[4fd37d4]198 TString type = GetType();
199 TIter itTrack(branch_);
200 Int_t counter = 0;
201 TEveTrack *eveTrack;
202 TEveTrackPropagator *trkProp = data_->GetPropagator();
203 trkProp->SetMagField(0., 0., -tk_Bz_);
204 trkProp->SetMaxR(tkRadius_);
205 trkProp->SetMaxZ(tkHalfLength_);
[486c4c3]206 GenParticle *particle;
[341014c]207 if(type == "Track")
208 { // CASE 1: TRACKS
[4fd37d4]209 Track *track;
[341014c]210 while((track = (Track *)itTrack.Next()))
211 {
[4fd37d4]212 TParticle pb(track->PID, 1, 0, 0, 0, 0,
[341014c]213 track->P4().Px(), track->P4().Py(),
214 track->P4().Pz(), track->P4().E(),
215 track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0);
[4fd37d4]216 eveTrack = new TEveTrack(&pb, counter, trkProp);
217 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
218 eveTrack->SetStdTitle();
219 eveTrack->SetAttLineAttMarker(data_);
220 data_->AddElement(eveTrack);
221 eveTrack->SetLineColor(GetColor());
222 eveTrack->MakeTrack();
223 }
[341014c]224 }
225 else if(type == "Electron")
226 { // CASE 2: ELECTRONS
[4fd37d4]227 Electron *electron;
[341014c]228 while((electron = (Electron *)itTrack.Next()))
229 {
230 particle = (GenParticle *)electron->Particle.GetObject();
231 TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0,
232 electron->P4().Px(), electron->P4().Py(),
233 electron->P4().Pz(), electron->P4().E(),
234 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
[4fd37d4]235 eveTrack = new TEveTrack(&pb, counter, trkProp);
236 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
237 eveTrack->SetStdTitle();
238 eveTrack->SetAttLineAttMarker(data_);
239 data_->AddElement(eveTrack);
240 eveTrack->SetLineColor(GetColor());
241 eveTrack->MakeTrack();
242 }
[341014c]243 }
244 else if(type == "Muon")
245 { // CASE 3: MUONS
[4fd37d4]246 Muon *muon;
[341014c]247 while((muon = (Muon *)itTrack.Next()))
248 {
249 particle = (GenParticle *)muon->Particle.GetObject();
250 TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0,
251 muon->P4().Px(), muon->P4().Py(),
252 muon->P4().Pz(), muon->P4().E(),
253 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
[4fd37d4]254 eveTrack = new TEveTrack(&pb, counter, trkProp);
255 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
256 eveTrack->SetStdTitle();
257 eveTrack->SetAttLineAttMarker(data_);
258 data_->AddElement(eveTrack);
259 eveTrack->SetLineColor(GetColor());
260 eveTrack->MakeTrack();
261 }
[341014c]262 }
263 else if(type == "Photon")
264 { // CASE 4: PHOTONS
[4fd37d4]265 Photon *photon;
[341014c]266 while((photon = (Photon *)itTrack.Next()))
267 {
[4fd37d4]268 TParticle pb(22, 1, 0, 0, 0, 0,
[341014c]269 photon->P4().Px(), photon->P4().Py(),
270 photon->P4().Pz(), photon->P4().E(),
271 0.0, 0.0, 0.0, 0.0);
[4fd37d4]272 eveTrack = new TEveTrack(&pb, counter, trkProp);
273 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
274 eveTrack->SetStdTitle();
275 eveTrack->SetAttLineAttMarker(data_);
276 eveTrack->SetLineStyle(7);
277 data_->AddElement(eveTrack);
278 eveTrack->SetLineColor(GetColor());
279 eveTrack->MakeTrack();
280 }
[341014c]281 }
282 else if(type == "GenParticle")
283 { // CASE 5: GENPARTICLES
[4fd37d4]284 GenParticle *particle;
[341014c]285 while((particle = (GenParticle *)itTrack.Next()))
286 {
[2ca23b5]287 if(particle->Status != 1) continue;
[4fd37d4]288 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
[341014c]289 particle->P4().Px(), particle->P4().Py(),
290 particle->P4().Pz(), particle->P4().E(),
291 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
[4fd37d4]292 eveTrack = new TEveTrack(&pb, counter, trkProp);
293 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
294 eveTrack->SetStdTitle();
295 eveTrack->SetAttLineAttMarker(data_);
296 data_->AddElement(eveTrack);
297 eveTrack->SetLineColor(GetColor());
[341014c]298 if(particle->Charge == 0) eveTrack->SetLineStyle(7);
[4fd37d4]299 eveTrack->MakeTrack();
300 }
301 }
302}
[341014c]303template <>
304std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors()
305{
[3f51314]306 std::vector<TLorentzVector> output;
307 TString type = GetType();
308 TIter itTrack(branch_);
[341014c]309 if(type == "Track")
310 { // CASE 1: TRACKS
[3f51314]311 Track *track;
[341014c]312 while((track = (Track *)itTrack.Next()))
313 {
[3f51314]314 output.push_back(track->P4());
315 }
[341014c]316 }
317 else if(type == "Electron")
318 { // CASE 2: ELECTRONS
[3f51314]319 Electron *electron;
[341014c]320 while((electron = (Electron *)itTrack.Next()))
321 {
[3f51314]322 output.push_back(electron->P4());
323 }
[341014c]324 }
325 else if(type == "Muon")
326 { // CASE 3: MUONS
[3f51314]327 Muon *muon;
[341014c]328 while((muon = (Muon *)itTrack.Next()))
329 {
[3f51314]330 output.push_back(muon->P4());
331 }
[341014c]332 }
333 else if(type == "Photon")
334 { // CASE 4: PHOTONS
[3f51314]335 Photon *photon;
[341014c]336 while((photon = (Photon *)itTrack.Next()))
337 {
[3f51314]338 output.push_back(photon->P4());
339 }
[341014c]340 }
341 else if(type == "GenParticle")
342 { // CASE 5: GENPARTICLES
[3f51314]343 GenParticle *particle;
[341014c]344 while((particle = (GenParticle *)itTrack.Next()))
345 {
[3f51314]346 if(particle->Status != 1) continue;
[341014c]347 output.push_back(particle->P4());
[3f51314]348 }
349 }
350 return output;
351}
Note: See TracBrowser for help on using the repository browser.