[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] | 29 | template<> 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] | 35 | template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
|
---|
[4fd37d4] | 36 | template<> 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] | 49 | template<> 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] | 64 | template<> 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] | 68 | template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
|
---|
[4fd37d4] | 69 | template<> 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") {
|
---|
[273735d] | 89 | // MissingET as invisible track (like a photon)
|
---|
[4fd37d4] | 90 | MissingET *MET;
|
---|
[273735d] | 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);
|
---|
[4fd37d4] | 103 | eveMet->SetName("Missing Et");
|
---|
[273735d] | 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);
|
---|
[4fd37d4] | 111 | data_->AddElement(eveMet);
|
---|
[273735d] | 112 | eveMet->SetLineColor(GetColor());
|
---|
| 113 | eveMet->MakeTrack();
|
---|
[4fd37d4] | 114 | }
|
---|
| 115 | }
|
---|
| 116 | }
|
---|
[3f51314] | 117 | template<> 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 | }
|
---|
[4d999a57] | 140 |
|
---|
| 141 | // special case for track lists
|
---|
[2ca23b5] | 142 | template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
|
---|
[4fd37d4] | 143 | data_ = new TEveTrackList(name);
|
---|
| 144 | data_->SetMainColor(color_);
|
---|
| 145 | data_->SetMarkerColor(color_);
|
---|
| 146 | data_->SetMarkerStyle(kCircle);
|
---|
| 147 | data_->SetMarkerSize(0.5);
|
---|
| 148 | }
|
---|
| 149 | template<> 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 | }
|
---|
[4d999a57] | 158 | template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
|
---|
[4fd37d4] | 159 | template<> 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_);
|
---|
[486c4c3] | 168 | GenParticle *particle;
|
---|
[4fd37d4] | 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(),
|
---|
[486c4c3] | 175 | track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
|
---|
[4fd37d4] | 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())) {
|
---|
[486c4c3] | 187 | particle = (GenParticle*) electron->Particle.GetObject();
|
---|
[4fd37d4] | 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(),
|
---|
[486c4c3] | 191 | particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
|
---|
[4fd37d4] | 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())) {
|
---|
[486c4c3] | 203 | particle = (GenParticle*) muon->Particle.GetObject();
|
---|
[4fd37d4] | 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(),
|
---|
[486c4c3] | 207 | particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
|
---|
[4fd37d4] | 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(),
|
---|
[486c4c3] | 222 | 0.0, 0.0, 0.0, 0.0);
|
---|
[4fd37d4] | 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())) {
|
---|
[2ca23b5] | 235 | if(particle->Status != 1) continue;
|
---|
[4fd37d4] | 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(),
|
---|
[486c4c3] | 239 | particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
|
---|
[4fd37d4] | 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 | }
|
---|
[3f51314] | 251 | template<> 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 | }
|
---|