Changeset 4fd37d4 in git for display/DelphesBranchElement.cc
- Timestamp:
- Oct 18, 2014, 12:27:15 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 5fbcfe8
- Parents:
- 400597a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
display/DelphesBranchElement.cc
r400597a r4fd37d4 18 18 19 19 #include "display/DelphesBranchElement.h" 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> 20 27 21 28 // special case for calo towers 22 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 23 if(TString(type)=="tower") { 24 data_ = new DelphesCaloData(2); 25 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 26 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 27 data_->IncDenyDestroy(); 28 } else { 29 throw std::exception(); 30 } 31 } 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 } 32 35 template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 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 } 33 49 34 50 // special case for element lists 35 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 36 if(TString(type)=="vector" || TString(type)=="jet") { 37 data_ = new TEveElementList(name); 38 data_->SetMainColor(color_); 39 } else { 40 throw std::exception(); 41 } 42 } 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 } 43 55 template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 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 } 44 95 45 96 // special case for track lists 46 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 47 data_ = new TEveTrackList(name); 48 data_->SetMainColor(color_); 49 data_->SetMarkerColor(color_); 50 data_->SetMarkerStyle(kCircle); 51 data_->SetMarkerSize(0.5); 52 } 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 } 53 113 template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 54 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 }
Note:
See TracChangeset
for help on using the changeset viewer.