- Timestamp:
- Oct 18, 2014, 12:27:15 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 5fbcfe8
- Parents:
- 400597a
- Location:
- display
- Files:
-
- 4 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 } -
display/DelphesBranchElement.h
r400597a r4fd37d4 22 22 #include "TColor.h" 23 23 #include "TString.h" 24 #include "TClonesArray.h" 25 #include "TClass.h" 24 26 #include <exception> 27 #include <iostream> 25 28 #include "display/DelphesCaloData.h" 26 29 #include "TEveElement.h" … … 31 34 { 32 35 public: 33 DelphesBranchBase(const char* name="", const char*type="", const enum EColor color=kBlack):name_(name),type_(type),color_(color) {}34 virtual ~DelphesBranchBase() {} ;36 DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):name_(name),branch_(branch),color_(color) {} 37 virtual ~DelphesBranchBase() {} 35 38 const char* GetName() const { return (const char*)name_; } 36 const char* GetType() const { return (const char*)type_; } 39 const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; } 40 virtual const char* GetClassName() = 0; 37 41 enum EColor GetColor() const { return color_; } 38 virtual const char* GetClassName() = 0;39 42 virtual void Reset() = 0; 43 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; } 44 virtual void ReadBranch() = 0; 40 45 41 46 protected: 42 47 TString name_; 43 T String type_; // needed for parsing the branch later on48 TClonesArray* branch_; 44 49 const enum EColor color_; 50 Float_t tkRadius_,tkHalfLength_, tk_Bz_; 45 51 }; 46 52 … … 50 56 public: 51 57 // constructor 52 DelphesBranchElement(const char* name="", const char*type="", const enum EColor color=kBlack):DelphesBranchBase(name, type, color) {58 DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack):DelphesBranchBase(name, branch, color) { 53 59 throw std::exception(); 54 60 } … … 60 66 EveContainer* GetContainer() { return data_; } 61 67 68 // tracking volume 69 virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; } 70 62 71 // resets the collection (before moving to the next event) 63 72 virtual void Reset() {}; … … 65 74 // template class name 66 75 virtual const char* GetClassName() { return data_->ClassName(); } 76 77 // read the branch and fill elements for display 78 virtual void ReadBranch() {} 67 79 68 80 private: … … 73 85 74 86 // special case for calo towers 75 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);87 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color); 76 88 template<> void DelphesBranchElement<DelphesCaloData>::Reset(); 89 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch(); 77 90 78 91 // special case for element lists 79 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color);92 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color); 80 93 template<> void DelphesBranchElement<TEveElementList>::Reset(); 94 template<> void DelphesBranchElement<TEveElementList>::ReadBranch(); 81 95 82 96 // special case for track lists 83 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color); 97 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color); 98 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz); 84 99 template<> void DelphesBranchElement<TEveTrackList>::Reset(); 100 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch(); 85 101 86 102 #endif // CINT, CLING -
display/DelphesEventDisplay.cc
r400597a r4fd37d4 53 53 totRadius_ = 2.0; 54 54 tkHalfLength_ = 3.0; 55 muHalfLength_ = 6.0; 55 56 bz_ = 3.8; 56 57 chain_ = new TChain("Delphes"); 57 58 treeReader_ = 0; 58 59 delphesDisplay_ = 0; 60 etaAxis_ = 0; 61 phiAxis_ = 0; 59 62 } 60 63 … … 83 86 totRadius_ = det3D.getDetectorRadius(); 84 87 tkHalfLength_ = det3D.getTrackerHalfLength(); 88 muHalfLength_ = det3D.getDetectorHalfLength(); 85 89 bz_ = det3D.getBField(); 90 etaAxis_ = det3D.getCaloAxes().first; 91 phiAxis_ = det3D.getCaloAxes().second; 86 92 TGeoVolume* top = det3D.getDetector(false); 87 93 geom->SetTopVolume(top); … … 105 111 106 112 // prepare data collections 107 readConfig(configFile, det3D, elements_, arrays_);113 readConfig(configFile, elements_); 108 114 for(std::vector<DelphesBranchBase*>::iterator element = elements_.begin(); element<elements_.end(); ++element) { 109 115 DelphesBranchElement<TEveTrackList>* item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element); … … 120 126 // find the first calo data and use that to initialize the calo display 121 127 for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) { 122 if(TString((*data)->GetType())==" tower") { // we could also use GetClassName()=="DelphesCaloData"128 if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData" 123 129 DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer(); 124 130 assert(container); … … 146 152 147 153 // function that parses the config to extract the branches of interest and prepare containers 148 void DelphesEventDisplay::readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays) {154 void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) { 149 155 ExRootConfReader *confReader = new ExRootConfReader; 150 156 confReader->ReadFile(configFile); 151 Double_t tk_radius = det3D.getTrackerRadius();152 Double_t tk_length = det3D.getTrackerHalfLength();153 Double_t tk_Bz = det3D.getBField();154 Double_t mu_radius = det3D.getDetectorRadius();155 Double_t mu_length = det3D.getDetectorHalfLength();156 TAxis* etaAxis = det3D.getCaloAxes().first;157 TAxis* phiAxis = det3D.getCaloAxes().second;158 157 ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch"); 159 158 Int_t nBranches = branches.GetSize()/3; … … 168 167 if(className=="Tower") { 169 168 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 170 clist = new DelphesBranchElement<DelphesCaloData>(name, "tower",kBlack);171 clist->GetContainer()->SetEtaBins(etaAxis );172 clist->GetContainer()->SetPhiBins(phiAxis );169 clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack); 170 clist->GetContainer()->SetEtaBins(etaAxis_); 171 clist->GetContainer()->SetPhiBins(phiAxis_); 173 172 elements.push_back(clist); 174 173 } else if(className=="Jet") { 175 174 if(input.Contains("GenJetFinder")) { 176 elist = new DelphesBranchElement<TEveElementList>(name, "jet",kCyan);175 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan); 177 176 elist->GetContainer()->SetRnrSelf(false); 178 177 elist->GetContainer()->SetRnrChildren(false); 178 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 179 179 elements.push_back(elist); 180 180 } else { 181 elements.push_back(new DelphesBranchElement<TEveElementList>(name,"jet",kYellow)); 181 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow); 182 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 183 elements.push_back(elist); 182 184 } 183 185 } else if(className=="Electron") { 184 tlist = new DelphesBranchElement<TEveTrackList>(name,"electron",kRed); 185 elements.push_back(tlist); 186 TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator(); 187 trkProp->SetMagField(0., 0., -tk_Bz); 188 trkProp->SetMaxR(tk_radius); 189 trkProp->SetMaxZ(tk_length); 186 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed); 187 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 188 elements.push_back(tlist); 190 189 } else if(className=="Photon") { 191 tlist = new DelphesBranchElement<TEveTrackList>(name,"photon",kYellow); 192 elements.push_back(tlist); 193 TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator(); 194 trkProp->SetMagField(0., 0., 0.); 195 trkProp->SetMaxR(tk_radius); 196 trkProp->SetMaxZ(tk_length); 190 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow); 191 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 192 elements.push_back(tlist); 197 193 } else if(className=="Muon") { 198 tlist = new DelphesBranchElement<TEveTrackList>(name,"muon",kGreen); 199 elements.push_back(tlist); 200 TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator(); 201 trkProp->SetMagField(0., 0., -tk_Bz); 202 trkProp->SetMaxR(mu_radius); 203 trkProp->SetMaxZ(mu_length); 194 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen); 195 tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_); 196 elements.push_back(tlist); 204 197 } else if(className=="MissingET") { 205 elements.push_back(new DelphesBranchElement<TEveElementList>(name,"vector",kViolet)); 198 elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet); 199 elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 200 elements.push_back(elist); 206 201 } else if(className=="GenParticle") { 207 tlist = new DelphesBranchElement<TEveTrackList>(name, "genparticle",kCyan);208 elements.push_back(tlist);202 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan); 203 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 209 204 tlist->GetContainer()->SetRnrSelf(false); 210 205 tlist->GetContainer()->SetRnrChildren(false); 211 TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator(); 212 trkProp->SetMagField(0., 0., -tk_Bz); 213 trkProp->SetMaxR(tk_radius); 214 trkProp->SetMaxZ(tk_length); 206 elements.push_back(tlist); 215 207 } else { 216 208 continue; 217 209 } 218 arrays.push_back(treeReader_->UseBranch(name));219 210 } 220 211 // second loop for tracks … … 225 216 if(className=="Track") { 226 217 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 227 tlist = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue); 228 elements.push_back(tlist); 229 TEveTrackPropagator *trkProp = tlist->GetContainer()->GetPropagator(); 230 trkProp->SetMagField(0., 0., -tk_Bz); 231 trkProp->SetMaxR(tk_radius); 232 trkProp->SetMaxZ(tk_length); 233 arrays.push_back(treeReader_->UseBranch(name)); 218 tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue); 219 tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_); 220 elements.push_back(tlist); 234 221 } 235 222 } … … 255 242 // Load selected branches with data from specified event 256 243 treeReader_->ReadEntry(event_id_); 257 258 // loop over selected branches, and apply the proper recipe to fill the collections. 259 // this is basically to loop on arrays_ to fill elements_. 260 std::vector<TClonesArray*>::iterator data = arrays_.begin(); 261 std::vector<DelphesBranchBase*>::iterator element = elements_.begin(); 262 for(; data<arrays_.end() && element<elements_.end(); ++data, ++element) { 263 TString type = (*element)->GetType(); 264 // branch on the element type 265 if(type=="tower") delphes_read_towers(*data,*element); 266 else if(type=="track" || type=="photon" || type=="electron" || type=="muon" || type=="genparticle") delphes_read_tracks(*data,*element); 267 else if(type=="jet") delphes_read_jets(*data,*element); 268 else if(type=="vector") delphes_read_vectors(*data,*element); 244 for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) { 245 (*data)->ReadBranch(); 269 246 } 270 247 … … 278 255 279 256 gEve->Redraw3D(kFALSE, kTRUE); 280 }281 282 void DelphesEventDisplay::delphes_read_towers(TClonesArray* data, DelphesBranchBase* element) {283 DelphesCaloData* container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>(element)->GetContainer();284 assert(container);285 // Loop over all towers286 TIter itTower(data);287 Tower *tower;288 while((tower = (Tower *) itTower.Next()))289 {290 container->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);291 container->FillSlice(0, tower->Eem);292 container->FillSlice(1, tower->Ehad);293 }294 container->DataChanged();295 }296 297 void DelphesEventDisplay::delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element) {298 TEveTrackList* container = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(element)->GetContainer();299 assert(container);300 TString type = element->GetType();301 TIter itTrack(data);302 Int_t counter = 0;303 TEveTrack *eveTrack;304 TEveTrackPropagator *trkProp = container->GetPropagator();305 if(type=="track") {306 // Loop over all tracks307 Track *track;308 while((track = (Track *) itTrack.Next())) {309 TParticle pb(track->PID, 1, 0, 0, 0, 0,310 track->P4().Px(), track->P4().Py(),311 track->P4().Pz(), track->P4().E(),312 track->X, track->Y, track->Z, 0.0);313 eveTrack = new TEveTrack(&pb, counter, trkProp);314 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));315 eveTrack->SetStdTitle();316 eveTrack->SetAttLineAttMarker(container);317 container->AddElement(eveTrack);318 eveTrack->SetLineColor(element->GetColor());319 eveTrack->MakeTrack();320 }321 } else if(type=="electron") {322 // Loop over all electrons323 Electron *electron;324 while((electron = (Electron *) itTrack.Next())) {325 TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,326 electron->P4().Px(), electron->P4().Py(),327 electron->P4().Pz(), electron->P4().E(),328 0., 0., 0., 0.);329 330 eveTrack = new TEveTrack(&pb, counter, trkProp);331 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));332 eveTrack->SetStdTitle();333 eveTrack->SetAttLineAttMarker(container);334 container->AddElement(eveTrack);335 eveTrack->SetLineColor(element->GetColor());336 eveTrack->MakeTrack();337 }338 } else if(type=="muon") {339 // Loop over all muons340 Muon *muon;341 while((muon = (Muon *) itTrack.Next())) {342 TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,343 muon->P4().Px(), muon->P4().Py(),344 muon->P4().Pz(), muon->P4().E(),345 0., 0., 0., 0.);346 347 eveTrack = new TEveTrack(&pb, counter, trkProp);348 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));349 eveTrack->SetStdTitle();350 eveTrack->SetAttLineAttMarker(container);351 container->AddElement(eveTrack);352 eveTrack->SetLineColor(element->GetColor());353 eveTrack->MakeTrack();354 }355 } else if(type=="photon") {356 // Loop over all photons357 Photon *photon;358 while((photon = (Photon *) itTrack.Next())) {359 TParticle pb(22, 1, 0, 0, 0, 0,360 photon->P4().Px(), photon->P4().Py(),361 photon->P4().Pz(), photon->P4().E(),362 0., 0., 0., 0.);363 eveTrack = new TEveTrack(&pb, counter, trkProp);364 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));365 eveTrack->SetStdTitle();366 eveTrack->SetAttLineAttMarker(container);367 eveTrack->SetLineStyle(7);368 container->AddElement(eveTrack);369 eveTrack->SetLineColor(element->GetColor());370 eveTrack->MakeTrack();371 }372 } else if(type=="genparticle") {373 // Loop over all particles374 GenParticle *particle;375 while((particle = (GenParticle *) itTrack.Next())) {376 TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,377 particle->P4().Px(), particle->P4().Py(),378 particle->P4().Pz(), particle->P4().E(),379 particle->X, particle->Y, particle->Z, particle->T);380 eveTrack = new TEveTrack(&pb, counter, trkProp);381 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));382 eveTrack->SetStdTitle();383 eveTrack->SetAttLineAttMarker(container);384 container->AddElement(eveTrack);385 eveTrack->SetLineColor(element->GetColor());386 if(particle->Charge==0) eveTrack->SetLineStyle(7);387 eveTrack->MakeTrack();388 }389 }390 }391 392 void DelphesEventDisplay::delphes_read_jets(TClonesArray* data, DelphesBranchBase* element) {393 TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();394 assert(container);395 TIter itJet(data);396 Jet *jet;397 TEveJetCone *eveJetCone;398 // Loop over all jets399 Int_t counter = 0;400 while((jet = (Jet *) itJet.Next()))401 {402 eveJetCone = new TEveJetCone();403 eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));404 eveJetCone->SetName(Form("jet [%d]", counter++));405 eveJetCone->SetMainTransparency(60);406 eveJetCone->SetLineColor(element->GetColor());407 eveJetCone->SetFillColor(element->GetColor());408 eveJetCone->SetCylinder(tkRadius_ - 10, tkHalfLength_ - 10);409 eveJetCone->SetPickable(kTRUE);410 eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);411 container->AddElement(eveJetCone);412 }413 }414 415 void DelphesEventDisplay::delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element) {416 TEveElementList* container = dynamic_cast<DelphesBranchElement<TEveElementList>*>(element)->GetContainer();417 assert(container);418 TIter itMet(data);419 MissingET *MET;420 TEveArrow *eveMet;421 // Missing Et422 Double_t maxPt = 50.;423 // TODO to be changed as we don't have access to maxPt anymore. MET scale could be a general parameter set in GUI424 while((MET = (MissingET*) itMet.Next())) {425 eveMet = new TEveArrow((tkRadius_ * MET->MET/maxPt)*cos(MET->Phi), (tkRadius_ * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.);426 eveMet->SetMainColor(element->GetColor());427 eveMet->SetTubeR(0.04);428 eveMet->SetConeR(0.08);429 eveMet->SetConeL(0.10);430 eveMet->SetPickable(kTRUE);431 eveMet->SetName("Missing Et");432 eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET));433 container->AddElement(eveMet);434 }435 257 } 436 258 -
display/DelphesEventDisplay.h
r400597a r4fd37d4 26 26 #include "display/Delphes3DGeometry.h" 27 27 #include "TChain.h" 28 #include "TAxis.h" 28 29 #include "TClonesArray.h" 29 30 … … 45 46 void make_gui(); 46 47 void load_event(); 47 void delphes_read_towers(TClonesArray* data, DelphesBranchBase* element); 48 void delphes_read_tracks(TClonesArray* data, DelphesBranchBase* element); 49 void delphes_read_jets(TClonesArray* data, DelphesBranchBase* element); 50 void delphes_read_vectors(TClonesArray* data, DelphesBranchBase* element); 51 void readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays); 48 void readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements); 52 49 53 50 // Configuration and global variables. 54 51 Int_t event_id_; 55 52 ExRootTreeReader *treeReader_; 56 Double_t tkRadius_, totRadius_, tkHalfLength_, bz_; 53 Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_; 54 TAxis *etaAxis_, *phiAxis_; 57 55 TChain* chain_; 58 56 std::vector<DelphesBranchBase*> elements_; 59 std::vector<TClonesArray*> arrays_;60 57 DelphesDisplay *delphesDisplay_; 61 58
Note:
See TracChangeset
for help on using the changeset viewer.