Changeset ffd01cb in git
- Timestamp:
- Oct 14, 2014, 11:26:44 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 5bb66c9
- Parents:
- a844c07
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/geometry.C
ra844c07 rffd01cb 5 5 #include <algorithm> 6 6 #include <sstream> 7 #include <exception> 7 8 #include "TGeoManager.h" 8 9 #include "TGeoVolume.h" … … 40 41 #include "TClonesArray.h" 41 42 #include "TGLClip.h" 43 #include "TEveArrow.h" 42 44 43 45 /* … … 54 56 class DelphesCaloData; 55 57 class DelphesDisplay; 58 class DelphesBranchBase; 59 template<typename EveContainer> class DelphesBranchElement; 56 60 void make_gui(); 57 61 void load_event(); 58 62 void delphes_read(); 63 void readConfig(const char *configFile, const Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays); 59 64 60 65 // Configuration and global variables. … … 84 89 TEveElementList *gJetList = 0; 85 90 TEveElementList *gGenJetList = 0; 86 TEve Arrow *gMet = 0;91 TEveElementList *gMetList = 0; 87 92 TEveTrackList *gTrackList = 0; 88 93 TEveTrackList *gElectronList = 0; … … 121 126 Double_t getDetectorRadius() const { return muonSystem_radius_; } 122 127 Double_t getTrackerHalfLength() const { return tk_length_; } 128 Double_t getDetectorHalfLength() const { return muonSystem_length_; } 123 129 Double_t getBField() const { return tk_Bz_; } 124 130 std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); } … … 147 153 Double_t muonSystem_thickn_; 148 154 Double_t muonSystem_radius_; 155 Double_t muonSystem_length_; 149 156 Double_t tk_radius_; 150 157 Double_t tk_length_; … … 282 289 283 290 muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_; 291 muonSystem_length_ = tk_length_ + contingency_ + (contingency_+calo_endcap_thickness_)*calorimeters_.size() + muonSystem_thickn_; 284 292 285 293 delete confReader; … … 490 498 /******************************************************************************/ 491 499 492 void delphes_event_display(const char *configFile, const char *inputFile, constDelphes3DGeometry& det3D)500 void delphes_event_display(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D) 493 501 { 494 502 … … 505 513 gPhiAxis = det3D.getCaloAxes().second; 506 514 507 TGeoVolume* top = det3D.getDetector(false); //TODO: can this be set in the GUI?515 TGeoVolume* top = det3D.getDetector(false); 508 516 geom->SetTopVolume(top); 509 517 TEveElementList *geometry = new TEveElementList("Geometry"); … … 542 550 gTreeReader = new ExRootTreeReader(&gChain); 543 551 552 // prepare data collections 553 std::vector<DelphesBranchBase*> elements; 554 std::vector<TClonesArray*> arrays; 555 //readConfig(configFile, det3D, elements, arrays); 544 556 // Get pointers to branches 545 557 //TODO make it configurable, for more objects (or can we guess from the config?) … … 571 583 gEve->AddElement(gGenJetList); 572 584 573 gMet = new TEveArrow(1., 0., 0., 0., 0., 0.); 574 gMet->SetMainColor(kViolet); 575 gMet->SetTubeR(0.02); 576 gMet->SetPickable(kTRUE); 577 gMet->SetName("Missing Et"); 578 gEve->GetCurrentEvent()->AddElement(gMet); 585 gMetList = new TEveElementList("Missing Et"); 586 gMetList->SetMainColor(kViolet); 587 gEve->AddElement(gMetList); 588 // gMet = new TEveArrow(1., 0., 0., 0., 0., 0.); 589 // gMet->SetMainColor(kViolet); 590 // gMet->SetTubeR(0.02); 591 // gMet->SetPickable(kTRUE); 592 // gMet->SetName("Missing Et"); 593 // gEve->GetCurrentEvent()->AddElement(gMet); 579 594 580 595 TEveTrackPropagator *trkProp; … … 662 677 if(gCaloData) gCaloData->ClearTowers(); 663 678 if(gJetList) gJetList->DestroyElements(); 679 if(gMetList) gMetList->DestroyElements(); 664 680 if(gGenJetList) gGenJetList->DestroyElements(); 665 681 if(gTrackList) gTrackList->DestroyElements(); … … 703 719 TEveJetCone *eveJetCone; 704 720 TEveTrack *eveTrack; 721 TEveArrow *eveMet; 705 722 706 723 Int_t counter; … … 839 856 itMet.Reset(); 840 857 while((MET = (MissingET*) itMet.Next())) { 841 delete gMet; 842 gMet = new TEveArrow((gRadius * MET->MET/maxPt)*cos(MET->Phi), (gRadius * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.); 843 gMet->SetMainColor(kViolet); 844 gMet->SetTubeR(0.04); 845 gMet->SetConeR(0.08); 846 gMet->SetConeL(0.10); 847 gMet->SetPickable(kTRUE); 848 gMet->SetName("Missing Et"); 849 gMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET)); 850 gMet->ProjectAllChildren(); 851 gEve->GetCurrentEvent()->AddElement(gMet); 858 eveMet = new TEveArrow((gRadius * MET->MET/maxPt)*cos(MET->Phi), (gRadius * MET->MET/maxPt)*sin(MET->Phi), 0., 0., 0., 0.); 859 eveMet->SetMainColor(kViolet); 860 eveMet->SetTubeR(0.04); 861 eveMet->SetConeR(0.08); 862 eveMet->SetConeL(0.10); 863 eveMet->SetPickable(kTRUE); 864 eveMet->SetName("Missing Et"); 865 eveMet->SetTitle(Form("Missing Et (%.1f GeV)",MET->MET)); 866 gMetList->AddElement(eveMet); 852 867 } 853 868 } … … 955 970 // 0 - no clip, 1 - clip plane, 2 - clip box 956 971 TGLViewer *v = gEve->GetDefaultGLViewer(); 957 Double_t plane[4] = { 0., 1., 0., 0. };972 //Double_t plane[4] = { 0., 1., 0., 0. }; 958 973 //v->GetClipSet()->SetClipState(1,plane); 959 974 //v->GetClipSet()->SetClipType(1); … … 966 981 } 967 982 983 // virtual class to represent objects from a Delphes-tree branch 984 class DelphesBranchBase 985 { 986 public: 987 DelphesBranchBase(const char* name, const char*type, const enum EColor color):name_(name),type_(type),color_(color) {} 988 virtual ~DelphesBranchBase() {}; 989 const char* GetName() const { return (const char*)name_; } 990 const char* GetType() const { return (const char*)type_; } 991 enum EColor GetColor() const { return color_; } 992 virtual const char* GetClassName() = 0; 993 virtual void Reset() = 0; 994 995 private: 996 TString name_; 997 TString type_; // needed for parsing the branch later on 998 const enum EColor color_; 999 }; 1000 // concrete implementations. EveContainer can be a TrackList, ElementList or CaloData. 1001 template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase 1002 { 1003 public: 1004 DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 1005 throw std::exception(); 1006 } 1007 1008 // destructor 1009 virtual ~DelphesBranchElement() { 1010 delete data_; 1011 } 1012 1013 // get the container (ElementList, TrackList, or CaloData) 1014 EveContainer* GetContainer() { return data_; } 1015 1016 // resets the collection (before moving to the next event) 1017 // making it pure virtual implies that only the specializations below will compile 1018 virtual void Reset() {}; 1019 1020 // template class name 1021 virtual const char* GetClassName() { return data_->ClassName(); } 1022 1023 private: 1024 EveContainer* data_; 1025 }; 1026 // special case for calo towers 1027 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 1028 if(TString(type)=="tower") { 1029 data_ = new DelphesCaloData(2); 1030 data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 1031 data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 1032 data_->IncDenyDestroy(); 1033 } else { 1034 throw std::exception(); 1035 } 1036 } 1037 template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); } 1038 // special case for element lists 1039 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 1040 if(TString(type)=="vector" || TString(type)=="jet") { 1041 data_ = new TEveElementList(name); 1042 data_->SetMainColor(color_); 1043 } else { 1044 throw std::exception(); 1045 } 1046 } 1047 template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); } 1048 // special case for track lists 1049 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, const char*type, const enum EColor color):DelphesBranchBase(name, type, color) { 1050 if(TString(type)=="track") { 1051 data_ = new TEveTrackList(name); 1052 data_->SetMainColor(color_); 1053 data_->SetMarkerColor(color_); 1054 data_->SetMarkerStyle(kCircle); 1055 data_->SetMarkerSize(0.5); 1056 } else if(TString(type)=="photon") { 1057 data_ = new TEveTrackList(name); 1058 data_->SetMainColor(color_); 1059 data_->SetMarkerColor(color_); 1060 data_->SetMarkerStyle(kCircle); 1061 data_->SetMarkerSize(0.5); 1062 } else { 1063 throw std::exception(); 1064 } 1065 } 1066 template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); } 1067 1068 // function that parses the config to extract the branches of interest and prepare containers 1069 void readConfig(const char *configFile, Delphes3DGeometry& det3D, std::vector<DelphesBranchBase*>& elements, std::vector<TClonesArray*>& arrays) { 1070 ExRootConfReader *confReader = new ExRootConfReader; 1071 confReader->ReadFile(configFile); 1072 Double_t tk_radius = det3D.getTrackerRadius(); 1073 Double_t tk_length = det3D.getTrackerHalfLength(); 1074 Double_t tk_Bz = det3D.getBField(); 1075 Double_t mu_radius = det3D.getDetectorRadius(); 1076 Double_t mu_length = det3D.getDetectorHalfLength(); 1077 TAxis* etaAxis = det3D.getCaloAxes().first; 1078 TAxis* phiAxis = det3D.getCaloAxes().second; 1079 ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch"); 1080 Int_t nBranches = branches.GetSize()/3; 1081 for(Int_t b = 0; b<nBranches; ++b) { 1082 TString input = branches[b*3].GetString(); 1083 TString name = branches[b*3+1].GetString(); 1084 TString className = branches[b*3+2].GetString(); 1085 if(className=="Track") { 1086 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 1087 DelphesBranchElement<TEveTrackList>* list = new DelphesBranchElement<TEveTrackList>(name,"track",kBlue); 1088 elements.push_back(list); 1089 TEveTrackPropagator *trkProp = list->GetContainer()->GetPropagator(); 1090 trkProp->SetMagField(0., 0., -tk_Bz); 1091 trkProp->SetMaxR(tk_radius); 1092 trkProp->SetMaxZ(tk_length); 1093 } else if(className=="Tower") { 1094 if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow 1095 DelphesBranchElement<DelphesCaloData>* list = new DelphesBranchElement<DelphesCaloData>(name,"tower",kBlack); 1096 list->GetContainer()->SetEtaBins(etaAxis); 1097 list->GetContainer()->SetPhiBins(phiAxis); 1098 elements.push_back(list); 1099 } else if(className=="Jet") { 1100 if(input.Contains("GenJetFinder")) { 1101 DelphesBranchElement<TEveElementList>* list = new DelphesBranchElement<TEveElementList>(name,"jet",kCyan); 1102 list->GetContainer()->SetRnrSelf(false); 1103 list->GetContainer()->SetRnrChildren(false); 1104 elements.push_back(list); 1105 } else { 1106 elements.push_back(new DelphesBranchElement<TEveElementList>(name,"jet",kYellow)); 1107 } 1108 } else if(className=="Electron") { 1109 DelphesBranchElement<TEveTrackList>* list = new DelphesBranchElement<TEveTrackList>(name,"track",kRed); 1110 elements.push_back(list); 1111 TEveTrackPropagator *trkProp = list->GetContainer()->GetPropagator(); 1112 trkProp->SetMagField(0., 0., -tk_Bz); 1113 trkProp->SetMaxR(tk_radius); 1114 trkProp->SetMaxZ(tk_length); 1115 } else if(className=="Photon") { 1116 DelphesBranchElement<TEveTrackList>* list = new DelphesBranchElement<TEveTrackList>(name,"photon",kYellow); 1117 elements.push_back(list); 1118 TEveTrackPropagator *trkProp = list->GetContainer()->GetPropagator(); 1119 trkProp->SetMagField(0., 0., 0.); 1120 trkProp->SetMaxR(tk_radius); 1121 trkProp->SetMaxZ(tk_length); 1122 } else if(className=="Muon") { 1123 DelphesBranchElement<TEveTrackList>* list = new DelphesBranchElement<TEveTrackList>(name,"track",kGreen); 1124 elements.push_back(list); 1125 TEveTrackPropagator *trkProp = list->GetContainer()->GetPropagator(); 1126 trkProp->SetMagField(0., 0., -tk_Bz); 1127 trkProp->SetMaxR(mu_radius); 1128 trkProp->SetMaxZ(mu_length); 1129 } else if(className=="MissingET") { 1130 elements.push_back(new DelphesBranchElement<TEveElementList>(name,"vector",kViolet)); 1131 } else if(className=="GenParticle") { 1132 DelphesBranchElement<TEveTrackList>* list = new DelphesBranchElement<TEveTrackList>(name,"track",kCyan); 1133 elements.push_back(list); 1134 list->GetContainer()->SetRnrSelf(false); 1135 list->GetContainer()->SetRnrChildren(false); 1136 TEveTrackPropagator *trkProp = list->GetContainer()->GetPropagator(); 1137 trkProp->SetMagField(0., 0., -tk_Bz); 1138 trkProp->SetMaxR(tk_radius); 1139 trkProp->SetMaxZ(tk_length); 1140 } 1141 arrays.push_back(gTreeReader->UseBranch(name)); 1142 } 1143 }
Note:
See TracChangeset
for help on using the changeset viewer.