Changes in display/DelphesBranchElement.cc [341014c:273735d] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
display/DelphesBranchElement.cc
r341014c r273735d 18 18 19 19 #include "display/DelphesBranchElement.h" 20 #include " TEveArrow.h"20 #include "classes/DelphesClasses.h" 21 21 #include "TEveJetCone.h" 22 22 #include "TEveTrack.h" 23 23 #include "TEveTrackPropagator.h" 24 #include "TEveArrow.h" 24 25 #include "TEveVector.h" 25 #include "classes/DelphesClasses.h"26 26 #include <iostream> 27 27 28 28 // special case for calo towers 29 template <> 30 DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 31 DelphesBranchBase(name, branch, color, maxPt) 32 { 33 data_ = new DelphesCaloData(2); 34 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 35 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 36 data_->IncDenyDestroy(); 37 } 38 template <> 39 void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 40 template <> 41 void DelphesBranchElement<DelphesCaloData>::ReadBranch() 42 { 43 if(TString(GetType()) == "Tower") 44 { 29 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 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 } 35 template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 36 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() { 37 if(TString(GetType())=="Tower") { 45 38 // Loop over all towers 46 39 TIter itTower(branch_); 47 40 Tower *tower; 48 while((tower = (Tower *)itTower.Next())) 49 { 41 while((tower = (Tower *) itTower.Next())) { 50 42 data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]); 51 43 data_->FillSlice(0, tower->Eem); … … 55 47 } 56 48 } 57 template <> 58 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() 59 { 49 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() { 60 50 std::vector<TLorentzVector> output; 61 if(TString(GetType()) == "Tower") 62 { 51 if(TString(GetType())=="Tower") { 63 52 TIter itTower(branch_); 64 53 Tower *tower; 65 while((tower = (Tower *)itTower.Next())) 66 { 54 while((tower = (Tower *) itTower.Next())) { 67 55 TLorentzVector v; 68 v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2.,0.);56 v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.); 69 57 output.push_back(v); 70 58 } … … 74 62 75 63 // special case for element lists 76 template <> 77 DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 78 DelphesBranchBase(name, branch, color, maxPt) 79 { 80 data_ = new TEveElementList(name); 81 data_->SetMainColor(color_); 82 } 83 template <> 84 void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 85 template <> 86 void DelphesBranchElement<TEveElementList>::ReadBranch() 87 { 88 if(TString(GetType()) == "Jet") 89 { 64 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 65 data_ = new TEveElementList(name); 66 data_->SetMainColor(color_); 67 } 68 template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 69 template<> void DelphesBranchElement<TEveElementList>::ReadBranch() { 70 if(TString(GetType())=="Jet") { 90 71 TIter itJet(branch_); 91 72 Jet *jet; … … 93 74 // Loop over all jets 94 75 Int_t counter = 0; 95 while((jet = (Jet *)itJet.Next())) 96 { 76 while((jet = (Jet *) itJet.Next())) { 97 77 eveJetCone = new TEveJetCone(); 98 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));78 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass)); 99 79 eveJetCone->SetName(Form("jet [%d]", counter++)); 100 80 eveJetCone->SetMainTransparency(60); … … 106 86 data_->AddElement(eveJetCone); 107 87 } 108 } 109 else if(TString(GetType()) == "MissingET") 110 { 88 } else if(TString(GetType())=="MissingET") { 111 89 // MissingET as invisible track (like a photon) 112 90 MissingET *MET; … … 116 94 trkProp->SetMaxR(tkRadius_); 117 95 trkProp->SetMaxZ(tkHalfLength_); 118 if(branch_->GetEntriesFast() > 0) 119 { 120 MET = (MissingET *)branch_->At(0); 96 if(branch_->GetEntriesFast() > 0) { 97 MET = (MissingET*) branch_->At(0); 121 98 TParticle pb(13, 1, 0, 0, 0, 0, 122 (tkRadius_ * MET->MET / maxPt_) *cos(MET->Phi),123 (tkRadius_ * MET->MET / maxPt_) *sin(MET->Phi),124 0., MET->MET, 0.0, 0.0, 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); 125 102 eveMet = new TEveTrack(&pb, 0, trkProp); 126 103 eveMet->SetName("Missing Et"); … … 138 115 } 139 116 } 140 template <> 141 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() 142 { 117 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() { 143 118 std::vector<TLorentzVector> output; 144 if(TString(GetType()) == "Jet") 145 { 119 if(TString(GetType())=="Jet") { 146 120 TIter itJet(branch_); 147 121 Jet *jet; 148 122 // Loop over all jets 149 while((jet = (Jet *)itJet.Next())) 150 { 123 while((jet = (Jet *) itJet.Next())) { 151 124 TLorentzVector v; 152 125 v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass); 153 126 output.push_back(v); 154 127 } 155 } 156 else if(TString(GetType()) == "MissingET") 157 { 128 } else if(TString(GetType())=="MissingET") { 158 129 TIter itMet(branch_); 159 130 MissingET *MET; 160 131 // Missing Et 161 while((MET = (MissingET *)itMet.Next())) 162 { 132 while((MET = (MissingET*) itMet.Next())) { 163 133 TLorentzVector v; 164 v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi,0.);134 v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.); 165 135 output.push_back(v); 166 136 } … … 170 140 171 141 // special case for track lists 172 template <> 173 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) : 174 DelphesBranchBase(name, branch, color, maxPt) 175 { 142 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) { 176 143 data_ = new TEveTrackList(name); 177 144 data_->SetMainColor(color_); … … 180 147 data_->SetMarkerSize(0.5); 181 148 } 182 template <> 183 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) 184 { 185 tkRadius_ = r; 149 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) { 150 tkRadius_ = r; 186 151 tkHalfLength_ = l; 187 152 tk_Bz_ = Bz; … … 191 156 trkProp->SetMaxZ(tkHalfLength_); 192 157 } 193 template <> 194 void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 195 template <> 196 void DelphesBranchElement<TEveTrackList>::ReadBranch() 197 { 158 template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 159 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() { 198 160 TString type = GetType(); 199 161 TIter itTrack(branch_); … … 205 167 trkProp->SetMaxZ(tkHalfLength_); 206 168 GenParticle *particle; 207 if(type == "Track") 208 { // CASE 1: TRACKS 169 if(type=="Track") { // CASE 1: TRACKS 209 170 Track *track; 210 while((track = (Track *)itTrack.Next())) 211 { 171 while((track = (Track *) itTrack.Next())) { 212 172 TParticle pb(track->PID, 1, 0, 0, 0, 0, 213 track->P4().Px(), track->P4().Py(), 214 track->P4().Pz(), track->P4().E(), 215 track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0); 216 eveTrack = new TEveTrack(&pb, counter, trkProp); 217 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 218 eveTrack->SetStdTitle(); 219 eveTrack->SetAttLineAttMarker(data_); 220 data_->AddElement(eveTrack); 221 eveTrack->SetLineColor(GetColor()); 222 eveTrack->MakeTrack(); 223 } 224 } 225 else if(type == "Electron") 226 { // CASE 2: ELECTRONS 173 track->P4().Px(), track->P4().Py(), 174 track->P4().Pz(), track->P4().E(), 175 track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0); 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 227 185 Electron *electron; 228 while((electron = (Electron *)itTrack.Next())) 229 { 230 particle = (GenParticle *)electron->Particle.GetObject(); 231 TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0, 232 electron->P4().Px(), electron->P4().Py(), 233 electron->P4().Pz(), electron->P4().E(), 234 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 235 eveTrack = new TEveTrack(&pb, counter, trkProp); 236 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 237 eveTrack->SetStdTitle(); 238 eveTrack->SetAttLineAttMarker(data_); 239 data_->AddElement(eveTrack); 240 eveTrack->SetLineColor(GetColor()); 241 eveTrack->MakeTrack(); 242 } 243 } 244 else if(type == "Muon") 245 { // CASE 3: MUONS 186 while((electron = (Electron *) itTrack.Next())) { 187 particle = (GenParticle*) electron->Particle.GetObject(); 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(), 191 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 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 246 201 Muon *muon; 247 while((muon = (Muon *)itTrack.Next())) 248 { 249 particle = (GenParticle *)muon->Particle.GetObject(); 250 TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0, 251 muon->P4().Px(), muon->P4().Py(), 252 muon->P4().Pz(), muon->P4().E(), 253 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 254 eveTrack = new TEveTrack(&pb, counter, trkProp); 255 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 256 eveTrack->SetStdTitle(); 257 eveTrack->SetAttLineAttMarker(data_); 258 data_->AddElement(eveTrack); 259 eveTrack->SetLineColor(GetColor()); 260 eveTrack->MakeTrack(); 261 } 262 } 263 else if(type == "Photon") 264 { // CASE 4: PHOTONS 202 while((muon = (Muon *) itTrack.Next())) { 203 particle = (GenParticle*) muon->Particle.GetObject(); 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(), 207 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 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 265 217 Photon *photon; 266 while((photon = (Photon *)itTrack.Next())) 267 { 218 while((photon = (Photon *) itTrack.Next())) { 268 219 TParticle pb(22, 1, 0, 0, 0, 0, 269 photon->P4().Px(), photon->P4().Py(),270 photon->P4().Pz(), photon->P4().E(),271 0.0, 0.0, 0.0, 0.0);220 photon->P4().Px(), photon->P4().Py(), 221 photon->P4().Pz(), photon->P4().E(), 222 0.0, 0.0, 0.0, 0.0); 272 223 eveTrack = new TEveTrack(&pb, counter, trkProp); 273 224 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); … … 279 230 eveTrack->MakeTrack(); 280 231 } 281 } 282 else if(type == "GenParticle") 283 { // CASE 5: GENPARTICLES 232 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES 284 233 GenParticle *particle; 285 while((particle = (GenParticle *)itTrack.Next())) 286 { 234 while((particle = (GenParticle *) itTrack.Next())) { 287 235 if(particle->Status != 1) continue; 288 236 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2, 289 particle->P4().Px(), particle->P4().Py(), 290 particle->P4().Pz(), particle->P4().E(), 291 particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0); 292 eveTrack = new TEveTrack(&pb, counter, trkProp); 293 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++)); 294 eveTrack->SetStdTitle(); 295 eveTrack->SetAttLineAttMarker(data_); 296 data_->AddElement(eveTrack); 297 eveTrack->SetLineColor(GetColor()); 298 if(particle->Charge == 0) eveTrack->SetLineStyle(7); 299 eveTrack->MakeTrack(); 300 } 301 } 302 } 303 template <> 304 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() 305 { 237 particle->P4().Px(), particle->P4().Py(), 238 particle->P4().Pz(), particle->P4().E(), 239 particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0); 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 } 251 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() { 306 252 std::vector<TLorentzVector> output; 307 253 TString type = GetType(); 308 254 TIter itTrack(branch_); 309 if(type == "Track") 310 { // CASE 1: TRACKS 255 if(type=="Track") { // CASE 1: TRACKS 311 256 Track *track; 312 while((track = (Track *)itTrack.Next())) 313 { 257 while((track = (Track *) itTrack.Next())) { 314 258 output.push_back(track->P4()); 315 259 } 316 } 317 else if(type == "Electron") 318 { // CASE 2: ELECTRONS 260 } else if(type=="Electron") { // CASE 2: ELECTRONS 319 261 Electron *electron; 320 while((electron = (Electron *)itTrack.Next())) 321 { 262 while((electron = (Electron *) itTrack.Next())) { 322 263 output.push_back(electron->P4()); 323 264 } 324 } 325 else if(type == "Muon") 326 { // CASE 3: MUONS 265 } else if(type=="Muon") { // CASE 3: MUONS 327 266 Muon *muon; 328 while((muon = (Muon *)itTrack.Next())) 329 { 267 while((muon = (Muon *) itTrack.Next())) { 330 268 output.push_back(muon->P4()); 331 269 } 332 } 333 else if(type == "Photon") 334 { // CASE 4: PHOTONS 270 } else if(type=="Photon") { // CASE 4: PHOTONS 335 271 Photon *photon; 336 while((photon = (Photon *)itTrack.Next())) 337 { 272 while((photon = (Photon *) itTrack.Next())) { 338 273 output.push_back(photon->P4()); 339 274 } 340 } 341 else if(type == "GenParticle") 342 { // CASE 5: GENPARTICLES 275 } else if(type=="GenParticle") { // CASE 5: GENPARTICLES 343 276 GenParticle *particle; 344 while((particle = (GenParticle *)itTrack.Next())) 345 { 277 while((particle = (GenParticle *) itTrack.Next())) { 346 278 if(particle->Status != 1) continue; 347 output.push_back(particle->P4());279 output.push_back(particle->P4()); 348 280 } 349 281 }
Note:
See TracChangeset
for help on using the changeset viewer.