[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 |
|
---|
| 28 | // special case for calo towers
|
---|
[4fd37d4] | 29 | template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
|
---|
| 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 | }
|
---|
[4d999a57] | 49 |
|
---|
| 50 | // special case for element lists
|
---|
[4fd37d4] | 51 | template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
|
---|
| 52 | data_ = new TEveElementList(name);
|
---|
| 53 | data_->SetMainColor(color_);
|
---|
| 54 | }
|
---|
[4d999a57] | 55 | template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
|
---|
[4fd37d4] | 56 | template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
|
---|
| 57 | if(TString(GetType())=="Jet") {
|
---|
| 58 | TIter itJet(branch_);
|
---|
| 59 | Jet *jet;
|
---|
| 60 | TEveJetCone *eveJetCone;
|
---|
| 61 | // Loop over all jets
|
---|
| 62 | Int_t counter = 0;
|
---|
| 63 | while((jet = (Jet *) itJet.Next())) {
|
---|
| 64 | eveJetCone = new TEveJetCone();
|
---|
| 65 | eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
|
---|
| 66 | eveJetCone->SetName(Form("jet [%d]", counter++));
|
---|
| 67 | eveJetCone->SetMainTransparency(60);
|
---|
| 68 | eveJetCone->SetLineColor(GetColor());
|
---|
| 69 | eveJetCone->SetFillColor(GetColor());
|
---|
| 70 | eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);
|
---|
| 71 | eveJetCone->SetPickable(kTRUE);
|
---|
| 72 | eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);
|
---|
| 73 | data_->AddElement(eveJetCone);
|
---|
| 74 | }
|
---|
| 75 | } else if(TString(GetType())=="MissingET") {
|
---|
| 76 | TIter itMet(branch_);
|
---|
| 77 | MissingET *MET;
|
---|
| 78 | TEveArrow *eveMet;
|
---|
| 79 | // Missing Et
|
---|
| 80 | Double_t maxPt = 50.;
|
---|
| 81 | // TODO to be changed as we don't have access to maxPt anymore. MET scale could be a general parameter set in GUI
|
---|
| 82 | while((MET = (MissingET*) itMet.Next())) {
|
---|
| 83 | eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);
|
---|
| 84 | eveMet->SetMainColor(GetColor());
|
---|
| 85 | eveMet->SetTubeR(0.04);
|
---|
| 86 | eveMet->SetConeR(0.08);
|
---|
| 87 | eveMet->SetConeL(0.10);
|
---|
| 88 | eveMet->SetPickable(kTRUE);
|
---|
| 89 | eveMet->SetName("Missing Et");
|
---|
| 90 | eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));
|
---|
| 91 | data_->AddElement(eveMet);
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[4d999a57] | 95 |
|
---|
| 96 | // special case for track lists
|
---|
[4fd37d4] | 97 | template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color):DelphesBranchBase(name, branch, color) {
|
---|
| 98 | data_ = new TEveTrackList(name);
|
---|
| 99 | data_->SetMainColor(color_);
|
---|
| 100 | data_->SetMarkerColor(color_);
|
---|
| 101 | data_->SetMarkerStyle(kCircle);
|
---|
| 102 | data_->SetMarkerSize(0.5);
|
---|
| 103 | }
|
---|
| 104 | template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
|
---|
| 105 | tkRadius_ = r;
|
---|
| 106 | tkHalfLength_ = l;
|
---|
| 107 | tk_Bz_ = Bz;
|
---|
| 108 | TEveTrackPropagator *trkProp = data_->GetPropagator();
|
---|
| 109 | trkProp->SetMagField(0., 0., -tk_Bz_);
|
---|
| 110 | trkProp->SetMaxR(tkRadius_);
|
---|
| 111 | trkProp->SetMaxZ(tkHalfLength_);
|
---|
| 112 | }
|
---|
[4d999a57] | 113 | template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
|
---|
[4fd37d4] | 114 | template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
|
---|
| 115 | TString type = GetType();
|
---|
| 116 | TIter itTrack(branch_);
|
---|
| 117 | Int_t counter = 0;
|
---|
| 118 | TEveTrack *eveTrack;
|
---|
| 119 | TEveTrackPropagator *trkProp = data_->GetPropagator();
|
---|
| 120 | trkProp->SetMagField(0., 0., -tk_Bz_);
|
---|
| 121 | trkProp->SetMaxR(tkRadius_);
|
---|
| 122 | trkProp->SetMaxZ(tkHalfLength_);
|
---|
| 123 | if(type=="Track") { // CASE 1: TRACKS
|
---|
| 124 | Track *track;
|
---|
| 125 | while((track = (Track *) itTrack.Next())) {
|
---|
| 126 | TParticle pb(track->PID, 1, 0, 0, 0, 0,
|
---|
| 127 | track->P4().Px(), track->P4().Py(),
|
---|
| 128 | track->P4().Pz(), track->P4().E(),
|
---|
| 129 | track->X, track->Y, track->Z, 0.0);
|
---|
| 130 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 131 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 132 | eveTrack->SetStdTitle();
|
---|
| 133 | eveTrack->SetAttLineAttMarker(data_);
|
---|
| 134 | data_->AddElement(eveTrack);
|
---|
| 135 | eveTrack->SetLineColor(GetColor());
|
---|
| 136 | eveTrack->MakeTrack();
|
---|
| 137 | }
|
---|
| 138 | } else if(type=="Electron") { // CASE 2: ELECTRONS
|
---|
| 139 | Electron *electron;
|
---|
| 140 | while((electron = (Electron *) itTrack.Next())) {
|
---|
| 141 | TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
|
---|
| 142 | electron->P4().Px(), electron->P4().Py(),
|
---|
| 143 | electron->P4().Pz(), electron->P4().E(),
|
---|
| 144 | 0., 0., 0., 0.);
|
---|
| 145 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 146 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 147 | eveTrack->SetStdTitle();
|
---|
| 148 | eveTrack->SetAttLineAttMarker(data_);
|
---|
| 149 | data_->AddElement(eveTrack);
|
---|
| 150 | eveTrack->SetLineColor(GetColor());
|
---|
| 151 | eveTrack->MakeTrack();
|
---|
| 152 | }
|
---|
| 153 | } else if(type=="Muon") { // CASE 3: MUONS
|
---|
| 154 | Muon *muon;
|
---|
| 155 | while((muon = (Muon *) itTrack.Next())) {
|
---|
| 156 | TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
|
---|
| 157 | muon->P4().Px(), muon->P4().Py(),
|
---|
| 158 | muon->P4().Pz(), muon->P4().E(),
|
---|
| 159 | 0., 0., 0., 0.);
|
---|
| 160 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 161 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 162 | eveTrack->SetStdTitle();
|
---|
| 163 | eveTrack->SetAttLineAttMarker(data_);
|
---|
| 164 | data_->AddElement(eveTrack);
|
---|
| 165 | eveTrack->SetLineColor(GetColor());
|
---|
| 166 | eveTrack->MakeTrack();
|
---|
| 167 | }
|
---|
| 168 | } else if(type=="Photon") { // CASE 4: PHOTONS
|
---|
| 169 | Photon *photon;
|
---|
| 170 | while((photon = (Photon *) itTrack.Next())) {
|
---|
| 171 | TParticle pb(22, 1, 0, 0, 0, 0,
|
---|
| 172 | photon->P4().Px(), photon->P4().Py(),
|
---|
| 173 | photon->P4().Pz(), photon->P4().E(),
|
---|
| 174 | 0., 0., 0., 0.);
|
---|
| 175 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 176 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 177 | eveTrack->SetStdTitle();
|
---|
| 178 | eveTrack->SetAttLineAttMarker(data_);
|
---|
| 179 | eveTrack->SetLineStyle(7);
|
---|
| 180 | data_->AddElement(eveTrack);
|
---|
| 181 | eveTrack->SetLineColor(GetColor());
|
---|
| 182 | eveTrack->MakeTrack();
|
---|
| 183 | }
|
---|
| 184 | } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
|
---|
| 185 | GenParticle *particle;
|
---|
| 186 | while((particle = (GenParticle *) itTrack.Next())) {
|
---|
| 187 | TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
|
---|
| 188 | particle->P4().Px(), particle->P4().Py(),
|
---|
| 189 | particle->P4().Pz(), particle->P4().E(),
|
---|
| 190 | particle->X, particle->Y, particle->Z, particle->T);
|
---|
| 191 | eveTrack = new TEveTrack(&pb, counter, trkProp);
|
---|
| 192 | eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
|
---|
| 193 | eveTrack->SetStdTitle();
|
---|
| 194 | eveTrack->SetAttLineAttMarker(data_);
|
---|
| 195 | data_->AddElement(eveTrack);
|
---|
| 196 | eveTrack->SetLineColor(GetColor());
|
---|
| 197 | if(particle->Charge==0) eveTrack->SetLineStyle(7);
|
---|
| 198 | eveTrack->MakeTrack();
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 | }
|
---|