Fork me on GitHub

source: git/display/DelphesBranchElement.cc@ ad015db

ImprovedOutputFile Timing dual_readout llp
Last change on this file since ad015db was 3f51314, checked in by Christophe Delaere <christophe.delaere@…>, 10 years ago

First incomplete version with summary plots

Most of the functionalities are there, but it is not yet properly
integrated in the GUI.
Known issues:

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