Fork me on GitHub

source: git/display/DelphesBranchElement.cc@ 6a8f6b8

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 6a8f6b8 was 1fa50c2, checked in by Pavel Demin <pavel.demin@…>, 10 years ago

fix GPLv3 header

  • 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
[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"
[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
28// special case for calo towers
[2ca23b5]29template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
[4fd37d4]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}
[4d999a57]35template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
[4fd37d4]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}
[3f51314]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}
[4d999a57]62
63// special case for element lists
[2ca23b5]64template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
[4fd37d4]65 data_ = new TEveElementList(name);
66 data_->SetMainColor(color_);
67}
[4d999a57]68template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
[4fd37d4]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())) {
[2ca23b5]94 eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi), 0., 0., 0., 0.);
[4fd37d4]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}
[3f51314]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}
[4d999a57]129
130// special case for track lists
[2ca23b5]131template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
[4fd37d4]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}
[4d999a57]147template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
[4fd37d4]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 if(type=="Track") { // CASE 1: TRACKS
158 Track *track;
159 while((track = (Track *) itTrack.Next())) {
160 TParticle pb(track->PID, 1, 0, 0, 0, 0,
161 track->P4().Px(), track->P4().Py(),
162 track->P4().Pz(), track->P4().E(),
163 track->X, track->Y, track->Z, 0.0);
164 eveTrack = new TEveTrack(&pb, counter, trkProp);
165 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
166 eveTrack->SetStdTitle();
167 eveTrack->SetAttLineAttMarker(data_);
168 data_->AddElement(eveTrack);
169 eveTrack->SetLineColor(GetColor());
170 eveTrack->MakeTrack();
171 }
172 } else if(type=="Electron") { // CASE 2: ELECTRONS
173 Electron *electron;
174 while((electron = (Electron *) itTrack.Next())) {
175 TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
176 electron->P4().Px(), electron->P4().Py(),
177 electron->P4().Pz(), electron->P4().E(),
178 0., 0., 0., 0.);
179 eveTrack = new TEveTrack(&pb, counter, trkProp);
180 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
181 eveTrack->SetStdTitle();
182 eveTrack->SetAttLineAttMarker(data_);
183 data_->AddElement(eveTrack);
184 eveTrack->SetLineColor(GetColor());
185 eveTrack->MakeTrack();
186 }
187 } else if(type=="Muon") { // CASE 3: MUONS
188 Muon *muon;
189 while((muon = (Muon *) itTrack.Next())) {
190 TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
191 muon->P4().Px(), muon->P4().Py(),
192 muon->P4().Pz(), muon->P4().E(),
193 0., 0., 0., 0.);
194 eveTrack = new TEveTrack(&pb, counter, trkProp);
195 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
196 eveTrack->SetStdTitle();
197 eveTrack->SetAttLineAttMarker(data_);
198 data_->AddElement(eveTrack);
199 eveTrack->SetLineColor(GetColor());
200 eveTrack->MakeTrack();
201 }
202 } else if(type=="Photon") { // CASE 4: PHOTONS
203 Photon *photon;
204 while((photon = (Photon *) itTrack.Next())) {
205 TParticle pb(22, 1, 0, 0, 0, 0,
206 photon->P4().Px(), photon->P4().Py(),
207 photon->P4().Pz(), photon->P4().E(),
208 0., 0., 0., 0.);
209 eveTrack = new TEveTrack(&pb, counter, trkProp);
210 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
211 eveTrack->SetStdTitle();
212 eveTrack->SetAttLineAttMarker(data_);
213 eveTrack->SetLineStyle(7);
214 data_->AddElement(eveTrack);
215 eveTrack->SetLineColor(GetColor());
216 eveTrack->MakeTrack();
217 }
218 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
219 GenParticle *particle;
220 while((particle = (GenParticle *) itTrack.Next())) {
[2ca23b5]221 if(particle->Status != 1) continue;
[4fd37d4]222 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
223 particle->P4().Px(), particle->P4().Py(),
224 particle->P4().Pz(), particle->P4().E(),
225 particle->X, particle->Y, particle->Z, particle->T);
226 eveTrack = new TEveTrack(&pb, counter, trkProp);
227 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
228 eveTrack->SetStdTitle();
229 eveTrack->SetAttLineAttMarker(data_);
230 data_->AddElement(eveTrack);
231 eveTrack->SetLineColor(GetColor());
232 if(particle->Charge==0) eveTrack->SetLineStyle(7);
233 eveTrack->MakeTrack();
234 }
235 }
236}
[3f51314]237template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
238 std::vector<TLorentzVector> output;
239 TString type = GetType();
240 TIter itTrack(branch_);
241 if(type=="Track") { // CASE 1: TRACKS
242 Track *track;
243 while((track = (Track *) itTrack.Next())) {
244 output.push_back(track->P4());
245 }
246 } else if(type=="Electron") { // CASE 2: ELECTRONS
247 Electron *electron;
248 while((electron = (Electron *) itTrack.Next())) {
249 output.push_back(electron->P4());
250 }
251 } else if(type=="Muon") { // CASE 3: MUONS
252 Muon *muon;
253 while((muon = (Muon *) itTrack.Next())) {
254 output.push_back(muon->P4());
255 }
256 } else if(type=="Photon") { // CASE 4: PHOTONS
257 Photon *photon;
258 while((photon = (Photon *) itTrack.Next())) {
259 output.push_back(photon->P4());
260 }
261 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
262 GenParticle *particle;
263 while((particle = (GenParticle *) itTrack.Next())) {
264 if(particle->Status != 1) continue;
265 output.push_back(particle->P4());
266 }
267 }
268 return output;
269}
Note: See TracBrowser for help on using the repository browser.