- Timestamp:
- Dec 9, 2014, 1:26:26 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- 49234af
- Parents:
- 01f457a (diff), f6b6ee7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- examples
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/EventDisplay.C
r01f457a re7e90df 1 /* 2 root -l examples/EventDisplay.C\(\"examples/delphes_card_CMS.tcl\",\"delphes_output.root\"\) 3 ShowEvent(1); 4 ShowEvent(2); 5 */ 1 /* Example: 2 * root -l 'EventDisplay.C("delphes_card_CMS.tcl","../delphes_output.root")' 3 * root -l 'EventDisplay.C("delphes_card_FCC_basic.tcl","../delphes_output.root","ParticlePropagator","ChargedHadronTrackingEfficiency","MuonTrackingEfficiency","Ecal,Hcal")' 4 */ 6 5 7 //------------------------------------------------------------------------------ 6 void EventDisplay(const char* configfile = "delphes_card_CMS.tcl", const char* datafile = "delphes_output.root", 7 const char* ParticlePropagator="ParticlePropagator", 8 const char* TrackingEfficiency="ChargedHadronTrackingEfficiency", 9 const char* MuonEfficiency="MuonEfficiency", 10 const char* Calorimeters="Calorimeter", 11 bool displayGeometryOnly = false) 12 { 13 // load the libraries 14 gSystem->Load("libGeom"); 15 gSystem->Load("libGuiHtml"); 16 gSystem->Load("../libDelphesDisplay"); 8 17 9 // radius of the barrel, in m 10 Double_t gRadius = 1.29; 18 if(displayGeometryOnly) { 19 // create the detector representation without transparency 20 Delphes3DGeometry det3D_geom(new TGeoManager("delphes", "Delphes geometry"), false); 21 det3D_geom.readFile(configfile, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters); 11 22 12 // half-length of the barrel, in m 13 Double_t gHalfLength = 3.0;23 // display 24 det3D_geom.getDetector()->Draw("ogl"); 14 25 15 // magnetic field 16 Double_t gBz = 3.8; 26 } else { 17 27 18 TAxis *gEtaAxis = 0; 19 TAxis *gPhiAxis = 0; 28 // create the detector representation 29 Delphes3DGeometry det3D(new TGeoManager("delphes", "Delphes geometry"), true); 30 det3D.readFile(configfile, ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters); 20 31 21 //------------------------------------------------------------------------------ 32 // create the application 33 DelphesEventDisplay* display = new DelphesEventDisplay(configfile, datafile, det3D); 22 34 23 #include <set> 24 #include <vector> 25 26 using namespace std; 27 28 class ExRootTreeReader; 29 class DelphesCaloData; 30 class DelphesDisplay; 31 32 TChain gChain("Delphes"); 33 34 ExRootTreeReader *gTreeReader = 0; 35 36 TClonesArray *gBranchTower = 0; 37 TClonesArray *gBranchTrack = 0; 38 TClonesArray *gBranchJet = 0; 39 40 DelphesCaloData *gCaloData = 0; 41 TEveElementList *gJetList = 0; 42 TEveTrackList *gTrackList = 0; 43 44 DelphesDisplay *gDelphesDisplay = 0; 45 46 //------------------------------------------------------------------------------ 47 48 void EventDisplay(const char *configFile, const char *inputFile) 49 { 50 gSystem->Load("libDelphesDisplay"); 51 52 TEveManager::Create(kTRUE, "IV"); 53 54 ExRootConfParam param, paramEtaBins; 55 Long_t i, j, size, sizeEtaBins; 56 set< Double_t > etaSet; 57 set< Double_t >::iterator itEtaSet; 58 59 Double_t *etaBins; 60 61 ExRootConfReader *confReader = new ExRootConfReader; 62 confReader->ReadFile(configFile); 63 64 gRadius = confReader->GetDouble("ParticlePropagator::Radius", 1.0); 65 gHalfLength = confReader->GetDouble("ParticlePropagator::HalfLength", 3.0); 66 gBz = confReader->GetDouble("ParticlePropagator::Bz", 0.0); 67 68 // read eta and phi bins 69 param = confReader->GetParam("Calorimeter::EtaPhiBins"); 70 size = param.GetSize(); 71 etaSet.clear(); 72 for(i = 0; i < size/2; ++i) 73 { 74 paramEtaBins = param[i*2]; 75 sizeEtaBins = paramEtaBins.GetSize(); 76 77 for(j = 0; j < sizeEtaBins; ++j) 78 { 79 etaSet.insert(paramEtaBins[j].GetDouble()); 80 } 81 } 82 83 delete confReader; 84 85 etaBins = new Double_t[etaSet.size()]; 86 i = 0; 87 88 for(itEtaSet = etaSet.begin(); itEtaSet != etaSet.end(); ++itEtaSet) 89 { 90 etaBins[i] = *itEtaSet; 91 ++i; 92 } 93 94 gEtaAxis = new TAxis(etaSet.size() - 1, etaBins); 95 gPhiAxis = new TAxis(72, -TMath::Pi(), TMath::Pi()); 96 97 // Create chain of root trees 98 gChain.Add(inputFile); 99 100 // Create object of class ExRootTreeReader 101 gTreeReader = new ExRootTreeReader(&gChain); 102 103 // Get pointers to branches 104 gBranchTower = gTreeReader->UseBranch("Tower"); 105 gBranchTrack = gTreeReader->UseBranch("Track"); 106 gBranchJet = gTreeReader->UseBranch("Jet"); 107 108 // data 109 gCaloData = new DelphesCaloData(2); 110 gCaloData->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 111 gCaloData->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 112 gCaloData->SetEtaBins(gEtaAxis); 113 gCaloData->SetPhiBins(gPhiAxis); 114 gCaloData->IncDenyDestroy(); 115 116 gJetList = new TEveElementList("Jets"); 117 gEve->AddElement(gJetList); 118 119 gTrackList = new TEveTrackList("Tracks"); 120 gTrackList->SetMainColor(kBlue); 121 gTrackList->SetMarkerColor(kRed); 122 gTrackList->SetMarkerStyle(kCircle); 123 gTrackList->SetMarkerSize(0.5); 124 gEve->AddElement(gTrackList); 125 126 TEveTrackPropagator *trkProp = gTrackList->GetPropagator(); 127 trkProp->SetMagField(0.0, 0.0, -gBz); 128 trkProp->SetMaxR(gRadius*100.0); 129 trkProp->SetMaxZ(gHalfLength*100.0); 130 131 // viewers and scenes 132 133 TEveElementList *geometry = new TEveElementList("Geometry"); 134 135 TEveGeoShape *barell = new TEveGeoShape("Barell"); 136 barell->SetShape(new TGeoTube(gRadius*100.0 - 1, gRadius*100.0, gHalfLength*100.0)); 137 barell->SetMainColor(kCyan); 138 barell->SetMainTransparency(80); 139 geometry->AddElement(barell); 140 141 TEveCalo3D *calo = new TEveCalo3D(gCaloData); 142 calo->SetBarrelRadius(gRadius*100.0); 143 calo->SetEndCapPos(gHalfLength*100.0); 144 145 gStyle->SetPalette(1, 0); 146 TEveCaloLego *lego = new TEveCaloLego(gCaloData); 147 lego->InitMainTrans(); 148 lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi()); 149 lego->SetAutoRebin(kFALSE); 150 lego->Set2DMode(TEveCaloLego::kValSizeOutline); 151 152 gDelphesDisplay = new DelphesDisplay; 153 154 gEve->AddGlobalElement(geometry); 155 gEve->AddGlobalElement(calo); 156 157 gDelphesDisplay->ImportGeomRPhi(geometry); 158 gDelphesDisplay->ImportCaloRPhi(calo); 159 160 gDelphesDisplay->ImportGeomRhoZ(geometry); 161 gDelphesDisplay->ImportCaloRhoZ(calo); 162 163 gDelphesDisplay->ImportCaloLego(lego); 164 165 gEve->Redraw3D(kTRUE); 35 } 166 36 } 167 37 168 //------------------------------------------------------------------------------169 170 void ShowEvent(Long64_t event)171 {172 TIter itTower(gBranchTower);173 TIter itTrack(gBranchTrack);174 TIter itJet(gBranchJet);175 176 Tower *tower;177 Track *track;178 Jet *jet;179 180 TEveJetCone *eveJetCone;181 TEveTrack *eveTrack;182 183 Int_t counter;184 185 TEveElement *currentEvent = gEve->GetCurrentEvent();186 187 TEveTrackPropagator *trkProp = gTrackList->GetPropagator();188 189 if(event >= gTreeReader->GetEntries()) return;190 191 // Load selected branches with data from specified event192 gTreeReader->ReadEntry(event);193 194 gCaloData->ClearTowers();195 gJetList->DestroyElements();196 gTrackList->DestroyElements();197 198 // Loop over all towers199 itTower.Reset();200 while((tower = (Tower *) itTower.Next()))201 {202 gCaloData->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);203 gCaloData->FillSlice(0, tower->Eem);204 gCaloData->FillSlice(1, tower->Ehad);205 }206 gCaloData->DataChanged();207 208 // Loop over all tracks209 itTrack.Reset();210 counter = 0;211 while((track = (Track *) itTrack.Next()))212 {213 TParticle pb(track->PID, 1, 0, 0, 0, 0,214 track->P4().Px(), track->P4().Py(),215 track->P4().Pz(), track->P4().E(),216 track->X, track->Y, track->Z, 0.0);217 218 eveTrack = new TEveTrack(&pb, counter, trkProp);219 eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));220 eveTrack->SetStdTitle();221 eveTrack->SetAttLineAttMarker(gTrackList);222 223 switch(TMath::Abs(track->PID))224 {225 case 11:226 eveTrack->SetLineColor(kRed);227 break;228 case 13:229 eveTrack->SetLineColor(kGreen);230 break;231 default:232 eveTrack->SetLineColor(kBlue);233 }234 gTrackList->AddElement(eveTrack);235 eveTrack->MakeTrack();236 }237 238 // Loop over all jets239 itJet.Reset();240 counter = 0;241 while((jet = (Jet *) itJet.Next()))242 {243 eveJetCone = new TEveJetCone();244 eveJetCone->SetName(Form("jet [%d]", counter++));245 eveJetCone->SetMainTransparency(60);246 eveJetCone->SetLineColor(kYellow);247 eveJetCone->SetCylinder(gRadius*100.0 - 10, gHalfLength*100.0 - 10);248 eveJetCone->SetPickable(kTRUE);249 eveJetCone->AddEllipticCone(jet->Eta, jet->Phi, jet->DeltaEta, jet->DeltaPhi);250 gJetList->AddElement(eveJetCone);251 }252 253 gDelphesDisplay->DestroyEventRPhi();254 gDelphesDisplay->ImportEventRPhi(currentEvent);255 256 gDelphesDisplay->DestroyEventRhoZ();257 gDelphesDisplay->ImportEventRhoZ(currentEvent);258 259 gEve->Redraw3D(kTRUE);260 } -
examples/Example1.C
r01f457a re7e90df 1 1 /* 2 3 2 Simple macro showing how to access branches from the delphes output root file, 4 3 loop over events, and plot simple quantities such as the jet pt and the di-electron invariant 5 4 mass. 6 5 7 root -l examples/Example1.C \(\"delphes_output.root\"\)6 root -l examples/Example1.C'("delphes_output.root")' 8 7 */ 9 8 … … 67 66 histMass->Draw(); 68 67 } 68 -
examples/Example2.C
r01f457a re7e90df 1 1 /* 2 3 2 Simple macro showing how to access branches from the delphes output root file, 4 3 loop over events, store histograms in a root file and print them as image files. 5 4 6 root -l examples/Example2.C \(\"delphes_output.root\"\)5 root -l examples/Example2.C'("delphes_output.root")' 7 6 */ 8 7 -
examples/Example3.C
r01f457a re7e90df 1 1 /* 2 3 2 This macro shows how to access the particle-level reference for reconstructed objects. 4 3 It is also shown how to loop over the jet constituents. 5 4 6 root -l examples/Example3.C \(\"delphes_output.root\"\)5 root -l examples/Example3.C'("delphes_output.root")' 7 6 */ 8 7 -
examples/MemoryUsage.C
r01f457a re7e90df 1 1 /* 2 root -l examples/MemoryUsage.C \(\"ps_output.txt\"\)2 root -l examples/MemoryUsage.C'("ps_output.txt")' 3 3 */ 4 4 -
examples/ProcessingTime.C
r01f457a re7e90df 1 1 /* 2 root -l examples/ProcessingTime.C \(\"delphes_output.root\"\)2 root -l examples/ProcessingTime.C'("delphes_output.root")' 3 3 */ 4 4
Note:
See TracChangeset
for help on using the changeset viewer.