[369744d] | 1 | /*
|
---|
[f53a4d2] | 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
[1fa50c2] | 4 | *
|
---|
[f53a4d2] | 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
[1fa50c2] | 9 | *
|
---|
[f53a4d2] | 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
[1fa50c2] | 14 | *
|
---|
[f53a4d2] | 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
[369744d] | 17 | */
|
---|
| 18 |
|
---|
[cfc3160] | 19 | #include <cassert>
|
---|
[84dd1c8] | 20 | #include <iostream>
|
---|
[cfc3160] | 21 | #include <utility>
|
---|
| 22 | #include <algorithm>
|
---|
[f53a4d2] | 23 |
|
---|
[cfc3160] | 24 | #include "TGeoManager.h"
|
---|
| 25 | #include "TGeoVolume.h"
|
---|
| 26 | #include "TEveElement.h"
|
---|
| 27 | #include "TEveJetCone.h"
|
---|
| 28 | #include "TEveTrack.h"
|
---|
| 29 | #include "TEveTrackPropagator.h"
|
---|
| 30 | #include "TEveCalo.h"
|
---|
| 31 | #include "TEveManager.h"
|
---|
| 32 | #include "TEveGeoNode.h"
|
---|
| 33 | #include "TEveTrans.h"
|
---|
| 34 | #include "TEveViewer.h"
|
---|
| 35 | #include "TEveBrowser.h"
|
---|
| 36 | #include "TEveArrow.h"
|
---|
| 37 | #include "TMath.h"
|
---|
| 38 | #include "TSystem.h"
|
---|
| 39 | #include "TRootBrowser.h"
|
---|
| 40 | #include "TGButton.h"
|
---|
[6301e02] | 41 | #include "TGTextEntry.h"
|
---|
| 42 | #include "TGProgressBar.h"
|
---|
| 43 | #include "TGNumberEntry.h"
|
---|
[2ca23b5] | 44 | #include "TRootEmbeddedCanvas.h"
|
---|
[cfc3160] | 45 | #include "TClonesArray.h"
|
---|
[8b04b31] | 46 | #include "TEveEventManager.h"
|
---|
[2ca23b5] | 47 | #include "TCanvas.h"
|
---|
| 48 | #include "TH1F.h"
|
---|
[f53a4d2] | 49 | #include "TAxis.h"
|
---|
| 50 | #include "TChain.h"
|
---|
| 51 | #include "TGHtml.h"
|
---|
| 52 | #include "TGStatusBar.h"
|
---|
| 53 |
|
---|
| 54 | #include "display/DelphesCaloData.h"
|
---|
| 55 | #include "display/DelphesBranchElement.h"
|
---|
| 56 | #include "display/Delphes3DGeometry.h"
|
---|
| 57 | #include "display/DelphesEventDisplay.h"
|
---|
| 58 | #include "display/DelphesDisplay.h"
|
---|
| 59 | #include "display/Delphes3DGeometry.h"
|
---|
| 60 | #include "display/DelphesHtmlSummary.h"
|
---|
| 61 | #include "display/DelphesPlotSummary.h"
|
---|
| 62 |
|
---|
| 63 | #include "classes/DelphesClasses.h"
|
---|
| 64 | #include "external/ExRootAnalysis/ExRootConfReader.h"
|
---|
| 65 | #include "external/ExRootAnalysis/ExRootTreeReader.h"
|
---|
[cfc3160] | 66 |
|
---|
| 67 | DelphesEventDisplay::DelphesEventDisplay()
|
---|
| 68 | {
|
---|
[fafc433] | 69 | event_id_ = 0;
|
---|
[cfc3160] | 70 | tkRadius_ = 1.29;
|
---|
| 71 | totRadius_ = 2.0;
|
---|
| 72 | tkHalfLength_ = 3.0;
|
---|
[4fd37d4] | 73 | muHalfLength_ = 6.0;
|
---|
[cfc3160] | 74 | bz_ = 3.8;
|
---|
| 75 | chain_ = new TChain("Delphes");
|
---|
[fafc433] | 76 | treeReader_ = 0;
|
---|
| 77 | delphesDisplay_ = 0;
|
---|
[4fd37d4] | 78 | etaAxis_ = 0;
|
---|
| 79 | phiAxis_ = 0;
|
---|
[cfc3160] | 80 | }
|
---|
| 81 |
|
---|
| 82 | DelphesEventDisplay::~DelphesEventDisplay()
|
---|
| 83 | {
|
---|
| 84 | delete chain_;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[0a67548] | 87 | void DelphesEventDisplay::EventChanged(Int_t e)
|
---|
| 88 | {
|
---|
| 89 | if( e!= event_id_ ) {
|
---|
| 90 | event_id_ = e;
|
---|
| 91 | Emit("EventChanged(Int_t)",e);
|
---|
| 92 | load_event();
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 |
|
---|
[cfc3160] | 97 | DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D)
|
---|
| 98 | {
|
---|
[fafc433] | 99 | event_id_ = 0;
|
---|
[cfc3160] | 100 | tkRadius_ = 1.29;
|
---|
| 101 | totRadius_ = 2.0;
|
---|
| 102 | tkHalfLength_ = 3.0;
|
---|
| 103 | bz_ = 3.8;
|
---|
| 104 | chain_ = new TChain("Delphes");
|
---|
[fafc433] | 105 | treeReader_ = 0;
|
---|
| 106 | delphesDisplay_ = 0;
|
---|
[cfc3160] | 107 |
|
---|
| 108 | // initialize the application
|
---|
| 109 | TEveManager::Create(kTRUE, "IV");
|
---|
[2ca23b5] | 110 | fStatusBar_ = gEve->GetBrowser()->GetStatusBar();
|
---|
[f53a4d2] | 111 | TGeoManager *geom = gGeoManager;
|
---|
[cfc3160] | 112 |
|
---|
| 113 | // build the detector
|
---|
| 114 | tkRadius_ = det3D.getTrackerRadius();
|
---|
| 115 | totRadius_ = det3D.getDetectorRadius();
|
---|
| 116 | tkHalfLength_ = det3D.getTrackerHalfLength();
|
---|
[4fd37d4] | 117 | muHalfLength_ = det3D.getDetectorHalfLength();
|
---|
[cfc3160] | 118 | bz_ = det3D.getBField();
|
---|
[4fd37d4] | 119 | etaAxis_ = det3D.getCaloAxes().first;
|
---|
| 120 | phiAxis_ = det3D.getCaloAxes().second;
|
---|
[f53a4d2] | 121 | TGeoVolume *top = det3D.getDetector(false);
|
---|
[cfc3160] | 122 | geom->SetTopVolume(top);
|
---|
| 123 | TEveElementList *geometry = new TEveElementList("Geometry");
|
---|
[f53a4d2] | 124 | TObjArray *nodes = top->GetNodes();
|
---|
[30bb83a] | 125 | TIter itNodes(nodes);
|
---|
[f53a4d2] | 126 | TGeoNode *nodeobj;
|
---|
| 127 | TEveGeoTopNode *node;
|
---|
[30bb83a] | 128 | while((nodeobj = (TGeoNode*)itNodes.Next())) {
|
---|
| 129 | node = new TEveGeoTopNode(gGeoManager,nodeobj);
|
---|
| 130 | node->UseNodeTrans();
|
---|
| 131 | geometry->AddElement(node);
|
---|
| 132 | }
|
---|
[cfc3160] | 133 |
|
---|
| 134 | // Create chain of root trees
|
---|
| 135 | chain_->Add(inputFile);
|
---|
| 136 |
|
---|
| 137 | // Create object of class ExRootTreeReader
|
---|
[2ca23b5] | 138 | fStatusBar_->SetText("Opening Delphes data file", 1);
|
---|
[6301e02] | 139 | gSystem->ProcessEvents();
|
---|
[fafc433] | 140 | treeReader_ = new ExRootTreeReader(chain_);
|
---|
[cfc3160] | 141 |
|
---|
| 142 | // prepare data collections
|
---|
[4fd37d4] | 143 | readConfig(configFile, elements_);
|
---|
[f53a4d2] | 144 | for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element<elements_.end(); ++element) {
|
---|
| 145 | DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
|
---|
| 146 | DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
|
---|
[84dd1c8] | 147 | if(item_v1) gEve->AddElement(item_v1->GetContainer());
|
---|
| 148 | if(item_v2) gEve->AddElement(item_v2->GetContainer());
|
---|
| 149 | }
|
---|
[cfc3160] | 150 |
|
---|
| 151 | // viewers and scenes
|
---|
[fafc433] | 152 | delphesDisplay_ = new DelphesDisplay;
|
---|
[cfc3160] | 153 | gEve->AddGlobalElement(geometry);
|
---|
[fafc433] | 154 | delphesDisplay_->ImportGeomRPhi(geometry);
|
---|
| 155 | delphesDisplay_->ImportGeomRhoZ(geometry);
|
---|
[cfc3160] | 156 | // find the first calo data and use that to initialize the calo display
|
---|
[f53a4d2] | 157 | for(std::vector<DelphesBranchBase *>::iterator data=elements_.begin();data<elements_.end();++data) {
|
---|
[4fd37d4] | 158 | if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData"
|
---|
[f53a4d2] | 159 | DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
|
---|
[cfc3160] | 160 | assert(container);
|
---|
| 161 | TEveCalo3D *calo3d = new TEveCalo3D(container);
|
---|
| 162 | calo3d->SetBarrelRadius(tkRadius_);
|
---|
| 163 | calo3d->SetEndCapPos(tkHalfLength_);
|
---|
| 164 | gEve->AddGlobalElement(calo3d);
|
---|
[fafc433] | 165 | delphesDisplay_->ImportCaloRPhi(calo3d);
|
---|
| 166 | delphesDisplay_->ImportCaloRhoZ(calo3d);
|
---|
[cfc3160] | 167 | TEveCaloLego *lego = new TEveCaloLego(container);
|
---|
| 168 | lego->InitMainTrans();
|
---|
[c3c9ac5] | 169 | // lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
|
---|
| 170 | lego->RefMainTrans().SetScale(100, 100, TMath::Pi());
|
---|
[cfc3160] | 171 | lego->SetAutoRebin(kFALSE);
|
---|
| 172 | lego->Set2DMode(TEveCaloLego::kValSizeOutline);
|
---|
[fafc433] | 173 | delphesDisplay_->ImportCaloLego(lego);
|
---|
[cfc3160] | 174 | break;
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 |
|
---|
[5fbcfe8] | 178 | // the GUI: control panel, summary tab
|
---|
[fafc433] | 179 | make_gui();
|
---|
[5fbcfe8] | 180 |
|
---|
| 181 | //ready...
|
---|
[2ca23b5] | 182 | fStatusBar_->SetText("Ready.", 1);
|
---|
[6301e02] | 183 | gSystem->ProcessEvents();
|
---|
[ad015db] | 184 | load_event();
|
---|
[cfc3160] | 185 | gEve->Redraw3D(kTRUE);
|
---|
| 186 |
|
---|
| 187 | }
|
---|
[30bb83a] | 188 |
|
---|
[cfc3160] | 189 | // function that parses the config to extract the branches of interest and prepare containers
|
---|
[4fd37d4] | 190 | void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) {
|
---|
[cfc3160] | 191 | ExRootConfReader *confReader = new ExRootConfReader;
|
---|
| 192 | confReader->ReadFile(configFile);
|
---|
| 193 | ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
|
---|
| 194 | Int_t nBranches = branches.GetSize()/3;
|
---|
[f53a4d2] | 195 | DelphesBranchElement<TEveTrackList> *tlist;
|
---|
| 196 | DelphesBranchElement<DelphesCaloData> *clist;
|
---|
| 197 | DelphesBranchElement<TEveElementList> *elist;
|
---|
[a3b2495] | 198 | // first loop with all but tracks
|
---|
[cfc3160] | 199 | for(Int_t b = 0; b<nBranches; ++b) {
|
---|
| 200 | TString input = branches[b*3].GetString();
|
---|
| 201 | TString name = branches[b*3+1].GetString();
|
---|
| 202 | TString className = branches[b*3+2].GetString();
|
---|
[a3b2495] | 203 | if(className=="Tower") {
|
---|
[cfc3160] | 204 | if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
|
---|
[4fd37d4] | 205 | clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack);
|
---|
| 206 | clist->GetContainer()->SetEtaBins(etaAxis_);
|
---|
| 207 | clist->GetContainer()->SetPhiBins(phiAxis_);
|
---|
[cfc3160] | 208 | elements.push_back(clist);
|
---|
| 209 | } else if(className=="Jet") {
|
---|
| 210 | if(input.Contains("GenJetFinder")) {
|
---|
[4fd37d4] | 211 | elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan);
|
---|
[cfc3160] | 212 | elist->GetContainer()->SetRnrSelf(false);
|
---|
| 213 | elist->GetContainer()->SetRnrChildren(false);
|
---|
[4fd37d4] | 214 | elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
[cfc3160] | 215 | elements.push_back(elist);
|
---|
| 216 | } else {
|
---|
[4fd37d4] | 217 | elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow);
|
---|
| 218 | elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
| 219 | elements.push_back(elist);
|
---|
[cfc3160] | 220 | }
|
---|
| 221 | } else if(className=="Electron") {
|
---|
[4fd37d4] | 222 | tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed);
|
---|
| 223 | tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
[cfc3160] | 224 | elements.push_back(tlist);
|
---|
| 225 | } else if(className=="Photon") {
|
---|
[4fd37d4] | 226 | tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow);
|
---|
| 227 | tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
[cfc3160] | 228 | elements.push_back(tlist);
|
---|
| 229 | } else if(className=="Muon") {
|
---|
[4fd37d4] | 230 | tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen);
|
---|
| 231 | tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
|
---|
[cfc3160] | 232 | elements.push_back(tlist);
|
---|
| 233 | } else if(className=="MissingET") {
|
---|
[4fd37d4] | 234 | elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet);
|
---|
| 235 | elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
| 236 | elements.push_back(elist);
|
---|
[cfc3160] | 237 | } else if(className=="GenParticle") {
|
---|
[4fd37d4] | 238 | tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan);
|
---|
| 239 | tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
[cfc3160] | 240 | tlist->GetContainer()->SetRnrSelf(false);
|
---|
| 241 | tlist->GetContainer()->SetRnrChildren(false);
|
---|
[4fd37d4] | 242 | elements.push_back(tlist);
|
---|
[a3b2495] | 243 | } else {
|
---|
| 244 | continue;
|
---|
[cfc3160] | 245 | }
|
---|
| 246 | }
|
---|
[a3b2495] | 247 | // second loop for tracks
|
---|
| 248 | for(Int_t b = 0; b<nBranches; ++b) {
|
---|
| 249 | TString input = branches[b*3].GetString();
|
---|
| 250 | TString name = branches[b*3+1].GetString();
|
---|
| 251 | TString className = branches[b*3+2].GetString();
|
---|
| 252 | if(className=="Track") {
|
---|
| 253 | if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
|
---|
[4fd37d4] | 254 | tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue);
|
---|
| 255 | tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
|
---|
[a3b2495] | 256 | elements.push_back(tlist);
|
---|
| 257 | }
|
---|
| 258 | }
|
---|
[cfc3160] | 259 | }
|
---|
| 260 |
|
---|
| 261 | void DelphesEventDisplay::load_event()
|
---|
| 262 | {
|
---|
[fafc433] | 263 | // Load event specified in global event_id_.
|
---|
[cfc3160] | 264 | // The contents of previous event are removed.
|
---|
| 265 |
|
---|
[30bb83a] | 266 | // safety
|
---|
| 267 | if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
|
---|
| 268 |
|
---|
[2ca23b5] | 269 | // message
|
---|
| 270 | fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1);
|
---|
[6301e02] | 271 | gSystem->ProcessEvents();
|
---|
[cfc3160] | 272 |
|
---|
| 273 | // clear the previous event
|
---|
| 274 | gEve->GetViewers()->DeleteAnnotations();
|
---|
[fafc433] | 275 | for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
|
---|
[cfc3160] | 276 | (*data)->Reset();
|
---|
| 277 | }
|
---|
| 278 |
|
---|
[30bb83a] | 279 | // Load selected branches with data from specified event
|
---|
| 280 | treeReader_->ReadEntry(event_id_);
|
---|
[4fd37d4] | 281 | for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
|
---|
| 282 | (*data)->ReadBranch();
|
---|
[30bb83a] | 283 | }
|
---|
[cfc3160] | 284 |
|
---|
| 285 | // update display
|
---|
[f53a4d2] | 286 | TEveElement *top = (TEveElement*)gEve->GetCurrentEvent();
|
---|
[fafc433] | 287 | delphesDisplay_->DestroyEventRPhi();
|
---|
| 288 | delphesDisplay_->ImportEventRPhi(top);
|
---|
| 289 | delphesDisplay_->DestroyEventRhoZ();
|
---|
| 290 | delphesDisplay_->ImportEventRhoZ(top);
|
---|
[8b04b31] | 291 | update_html_summary();
|
---|
[ad015db] | 292 | plotSummary_->FillEvent();
|
---|
| 293 | plotSummary_->Draw();
|
---|
[cfc3160] | 294 |
|
---|
[30bb83a] | 295 | gEve->Redraw3D(kFALSE, kTRUE);
|
---|
[2ca23b5] | 296 | fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1);
|
---|
[6301e02] | 297 | gSystem->ProcessEvents();
|
---|
[cfc3160] | 298 | }
|
---|
| 299 |
|
---|
[8b04b31] | 300 | void DelphesEventDisplay::update_html_summary()
|
---|
| 301 | {
|
---|
| 302 | // Update summary of current event.
|
---|
| 303 |
|
---|
| 304 | TEveElement::List_i i;
|
---|
| 305 | TEveElement::List_i j;
|
---|
| 306 | Int_t k;
|
---|
| 307 | TEveElement *el;
|
---|
| 308 | DelphesHtmlObjTable *table;
|
---|
| 309 | TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
|
---|
| 310 | if (mgr) {
|
---|
| 311 | htmlSummary_->Clear("D");
|
---|
| 312 | for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
|
---|
| 313 | el = ((TEveElement*)(*i));
|
---|
| 314 | if (el->IsA() == TEvePointSet::Class()) {
|
---|
| 315 | TEvePointSet *ps = (TEvePointSet *)el;
|
---|
| 316 | TString ename = ps->GetElementName();
|
---|
| 317 | TString etitle = ps->GetElementTitle();
|
---|
| 318 | if (ename.First('\'') != kNPOS)
|
---|
| 319 | ename.Remove(ename.First('\''));
|
---|
| 320 | etitle.Remove(0, 2);
|
---|
| 321 | Int_t nel = atoi(etitle.Data());
|
---|
| 322 | table = htmlSummary_->AddTable(ename, 0, nel);
|
---|
| 323 | }
|
---|
| 324 | else if (el->IsA() == TEveTrackList::Class()) {
|
---|
| 325 | TEveTrackList *tracks = (TEveTrackList *)el;
|
---|
| 326 | TString ename = tracks->GetElementName();
|
---|
| 327 | if (ename.First('\'') != kNPOS)
|
---|
| 328 | ename.Remove(ename.First('\''));
|
---|
| 329 | table = htmlSummary_->AddTable(ename.Data(), 5,
|
---|
| 330 | tracks->NumChildren(), kTRUE, "first");
|
---|
| 331 | table->SetLabel(0, "Momentum");
|
---|
| 332 | table->SetLabel(1, "P_t");
|
---|
| 333 | table->SetLabel(2, "Phi");
|
---|
| 334 | table->SetLabel(3, "Theta");
|
---|
| 335 | table->SetLabel(4, "Eta");
|
---|
| 336 | k=0;
|
---|
| 337 | for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
|
---|
| 338 | Float_t p = ((TEveTrack*)(*j))->GetMomentum().Mag();
|
---|
| 339 | table->SetValue(0, k, p);
|
---|
| 340 | Float_t pt = ((TEveTrack*)(*j))->GetMomentum().Perp();
|
---|
| 341 | table->SetValue(1, k, pt);
|
---|
| 342 | Float_t phi = ((TEveTrack*)(*j))->GetMomentum().Phi();
|
---|
| 343 | table->SetValue(2, k, phi);
|
---|
| 344 | Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
|
---|
| 345 | table->SetValue(3, k, theta);
|
---|
| 346 | Float_t eta = theta>0.0005 && theta<3.1413 ? ((TEveTrack*)(*j))->GetMomentum().Eta() : 1e10;
|
---|
| 347 | table->SetValue(4, k, eta);
|
---|
| 348 | ++k;
|
---|
| 349 | }
|
---|
| 350 | }
|
---|
| 351 | }
|
---|
| 352 | htmlSummary_->Build();
|
---|
| 353 | gHtml_->Clear();
|
---|
| 354 | gHtml_->ParseText((char*)htmlSummary_->Html().Data());
|
---|
| 355 | gHtml_->Layout();
|
---|
| 356 | }
|
---|
| 357 |
|
---|
| 358 | }
|
---|
| 359 |
|
---|
[cfc3160] | 360 | /******************************************************************************/
|
---|
| 361 | // GUI
|
---|
| 362 | /******************************************************************************/
|
---|
| 363 |
|
---|
| 364 | void DelphesEventDisplay::make_gui()
|
---|
| 365 | {
|
---|
| 366 | // Create minimal GUI for event navigation.
|
---|
| 367 |
|
---|
| 368 | // add a tab on the left
|
---|
[f53a4d2] | 369 | TEveBrowser *browser = gEve->GetBrowser();
|
---|
[6301e02] | 370 | browser->SetWindowName("Delphes Event Display");
|
---|
[cfc3160] | 371 | browser->StartEmbedding(TRootBrowser::kLeft);
|
---|
| 372 |
|
---|
| 373 | // set the main title
|
---|
[f53a4d2] | 374 | TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
|
---|
[cfc3160] | 375 | frmMain->SetWindowName("Delphes Event Display");
|
---|
| 376 | frmMain->SetCleanup(kDeepCleanup);
|
---|
| 377 |
|
---|
| 378 | // build the navigation menu
|
---|
[6301e02] | 379 | TString icondir;
|
---|
| 380 | if(gSystem->Getenv("ROOTSYS"))
|
---|
| 381 | icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
|
---|
| 382 | if(!gSystem->OpenDirectory(icondir))
|
---|
| 383 | icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
|
---|
[f53a4d2] | 384 | TGGroupFrame *vf = new TGGroupFrame(frmMain,"Event navigation",kVerticalFrame | kFitWidth );
|
---|
[cfc3160] | 385 | {
|
---|
[f53a4d2] | 386 | TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain);
|
---|
[6301e02] | 387 | {
|
---|
[f53a4d2] | 388 | TGPictureButton *b = 0;
|
---|
[6301e02] | 389 |
|
---|
| 390 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
|
---|
| 391 | hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 10, 2, 10, 10));
|
---|
| 392 | b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
|
---|
| 393 |
|
---|
[f53a4d2] | 394 | TGNumberEntry *numberEntry = new TGNumberEntry(hf,0,9,-1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries());
|
---|
[0a67548] | 395 | hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY , 2, 0, 10, 10));
|
---|
| 396 | this->Connect("EventChanged(Int_t)","TGNumberEntry",numberEntry,"SetIntNumber(Long_t)");
|
---|
| 397 | numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)");
|
---|
| 398 | numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()");
|
---|
[6301e02] | 399 |
|
---|
| 400 | b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
|
---|
| 401 | hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY , 2, 10, 10, 10));
|
---|
| 402 | b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
|
---|
| 403 |
|
---|
| 404 | }
|
---|
| 405 | vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX , 2, 2, 2, 2));
|
---|
| 406 |
|
---|
[f53a4d2] | 407 | TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
|
---|
[0a67548] | 408 | progress->SetMax( treeReader_->GetEntries());
|
---|
| 409 | progress->ShowPosition(kTRUE, kFALSE, "Event %.0f");
|
---|
| 410 | progress->SetBarColor("green");
|
---|
| 411 | vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
|
---|
| 412 | this->Connect("EventChanged(Int_t)","TGHProgressBar",progress,"SetPosition(Float_t)");
|
---|
[cfc3160] | 413 | }
|
---|
[6301e02] | 414 | frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
|
---|
| 415 | vf = new TGGroupFrame(frmMain,"Batch operations",kVerticalFrame | kFitWidth );
|
---|
| 416 | {
|
---|
| 417 | TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots");
|
---|
| 418 | vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10));
|
---|
| 419 | b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()");
|
---|
| 420 | }
|
---|
| 421 | frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
|
---|
| 422 |
|
---|
[cfc3160] | 423 | frmMain->MapSubwindows();
|
---|
| 424 | frmMain->Resize();
|
---|
| 425 | frmMain->MapWindow();
|
---|
| 426 | browser->StopEmbedding();
|
---|
| 427 | browser->SetTabTitle("Event Control", 0);
|
---|
[5fbcfe8] | 428 |
|
---|
| 429 | // the summary tab
|
---|
| 430 | htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table");
|
---|
[f53a4d2] | 431 | TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
|
---|
[5fbcfe8] | 432 | gHtml_ = new TGHtml(0, 100, 100);
|
---|
| 433 | TEveWindowFrame *wf = slot->MakeFrame(gHtml_);
|
---|
| 434 | gHtml_->MapSubwindows();
|
---|
[2ca23b5] | 435 | wf->SetElementName("Summary tables");
|
---|
| 436 |
|
---|
| 437 | // plot tab
|
---|
| 438 | slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
|
---|
[f53a4d2] | 439 | TEveWindowTab *tab = slot->MakeTab();
|
---|
[2ca23b5] | 440 | tab->SetElementName("Summary plots");
|
---|
| 441 | tab->SetShowTitleBar(kFALSE);
|
---|
| 442 | plotSummary_ = new DelphesPlotSummary(tab);
|
---|
| 443 | plotSummary_->Init(elements_);
|
---|
[53b78e8] | 444 | plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)");
|
---|
| 445 |
|
---|
[cfc3160] | 446 | }
|
---|
| 447 |
|
---|
[f53a4d2] | 448 | void DelphesEventDisplay::Fwd() {
|
---|
| 449 | if (event_id_ < treeReader_->GetEntries() - 2) {
|
---|
| 450 | EventChanged(event_id_+1);
|
---|
| 451 | } else {
|
---|
| 452 | printf("Already at last event.\n");
|
---|
| 453 | }
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | void DelphesEventDisplay::Bck() {
|
---|
| 457 | if (event_id_ > 0) {
|
---|
| 458 | EventChanged(event_id_-1);
|
---|
| 459 | } else {
|
---|
| 460 | printf("Already at first event.\n");
|
---|
| 461 | }
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | void DelphesEventDisplay::PreSetEv(char *ev) {
|
---|
| 465 | event_id_tmp_ = Int_t(atoi(ev));
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | void DelphesEventDisplay::GoTo() {
|
---|
| 469 | if (event_id_tmp_>=0 && event_id_tmp_ < treeReader_->GetEntries()-1) {
|
---|
| 470 | EventChanged(event_id_tmp_);
|
---|
| 471 | } else {
|
---|
| 472 | printf("Error: no such event.\n");
|
---|
| 473 | }
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | void DelphesEventDisplay::InitSummaryPlots() {
|
---|
| 477 | plotSummary_->FillSample(treeReader_, event_id_);
|
---|
| 478 | plotSummary_->FillEvent();
|
---|
| 479 | plotSummary_->Draw();
|
---|
| 480 | }
|
---|
[53b78e8] | 481 |
|
---|
[f53a4d2] | 482 | void DelphesEventDisplay::DisplayProgress(Int_t p) {
|
---|
| 483 | fStatusBar_->SetText(Form("Processing... %d %%",p), 1);
|
---|
| 484 | gSystem->ProcessEvents();
|
---|
| 485 | }
|
---|