Changeset 7513718 in git
- Timestamp:
- Oct 8, 2014, 11:07:34 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- e0c1ff0
- Parents:
- 7f66dc0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/geometry.C
r7f66dc0 r7513718 77 77 const char* Calorimeters="Calorimeter"); 78 78 79 void loadFromFile(const char* filename, const char* name="DelphesGeometry"); 80 void save(const char* filename, const char* name="DelphesGeometry"); 81 79 82 void setContingency(Double_t contingency) { contingency_ = contingency; } 80 83 void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; } … … 83 86 84 87 TGeoVolume* getDetector(bool withTowers = true); 88 89 Double_t getTrackerRadius() const { return tk_radius_; } 90 Double_t getTrackerHalfLength() const { return tk_length_; } 91 Double_t getBField() const { return tk_Bz_; } 92 std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); } 85 93 86 94 private: … … 98 106 TGeoMedium *calomed_; 99 107 TGeoMedium *mudetmed_; 108 109 TAxis* etaAxis_; 110 TAxis* phiAxis_; 100 111 101 112 Double_t contingency_; … … 106 117 Double_t tk_length_; 107 118 Double_t tk_etamax_; 119 Double_t tk_Bz_; 108 120 109 121 std::vector<std::string> calorimeters_; … … 119 131 //--- the geometry manager 120 132 geom_ = geom==NULL? gGeoManager : geom; 133 gGeoManager->DefaultColors(); 121 134 122 135 //--- define some materials … … 139 152 140 153 // read these parameters from the Delphes Card (with default values) 154 etaAxis_ = NULL; 155 phiAxis_ = NULL; 141 156 tk_radius_ = 120.; 142 157 tk_length_ = 150.; 143 158 tk_etamax_ = 3.0; 159 tk_Bz_ = 1.; 144 160 } 145 161 … … 153 169 tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100; // tk_radius 154 170 tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100; // tk_length 171 tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz 155 172 156 173 { … … 217 234 caloBinning_[*calo] = caloBinning; 218 235 } 236 237 set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()]; 238 Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo 239 unsigned int i = 0; 240 for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) { 241 etaBins[i++] = itEtaSet.first; 242 } 243 etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins); 244 phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT 219 245 220 246 delete confReader; … … 427 453 void delphes_event_display(const char *configFile, const char *inputFile) 428 454 { 429 // to be the main function, initializes the application. 430 431 gSystem->Load("libDelphesDisplay"); 432 433 TEveManager::Create(kTRUE, "IV"); 434 435 //------------------------------------ TODO: this should be moved to the geometry class 436 ExRootConfParam param, paramEtaBins; 437 Long_t i, j, size, sizeEtaBins; 438 set< Double_t > etaSet; 439 set< Double_t >::iterator itEtaSet; 440 441 Double_t *etaBins; 442 443 ExRootConfReader *confReader = new ExRootConfReader; 444 confReader->ReadFile(configFile); 445 446 gRadius = confReader->GetDouble("ParticlePropagator::Radius", 1.0); 447 gHalfLength = confReader->GetDouble("ParticlePropagator::HalfLength", 3.0); 448 gBz = confReader->GetDouble("ParticlePropagator::Bz", 0.0); 449 450 451 // read eta and phi bins 452 param = confReader->GetParam("Calorimeter::EtaPhiBins"); 453 size = param.GetSize(); 454 etaSet.clear(); 455 for(i = 0; i < size/2; ++i) 456 { 457 paramEtaBins = param[i*2]; 458 sizeEtaBins = paramEtaBins.GetSize(); 459 460 for(j = 0; j < sizeEtaBins; ++j) 461 { 462 etaSet.insert(paramEtaBins[j].GetDouble()); 463 } 464 } 465 466 delete confReader; 467 468 etaBins = new Double_t[etaSet.size()]; 469 i = 0; 470 471 for(itEtaSet = etaSet.begin(); itEtaSet != etaSet.end(); ++itEtaSet) 472 { 473 etaBins[i] = *itEtaSet; 474 ++i; 475 } 476 477 gEtaAxis = new TAxis(etaSet.size() - 1, etaBins); 478 gPhiAxis = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT 479 //----------------------------------------------------------------------- 480 481 // Create chain of root trees 482 gChain.Add(inputFile); 483 484 // Create object of class ExRootTreeReader 455 // to be the main function... 456 457 // initialize the application 458 gSystem->Load("libDelphesDisplay"); 459 TEveManager::Create(kTRUE, "IV"); 460 461 // build the detector 462 Delphes3DGeometry det3D; 463 det3D.readFile(filename,ParticlePropagator, TrackingEfficiency, MuonEfficiency, Calorimeters); 464 gRadius = det3D.getTrackerRadius(); 465 gHalfLength = det3D.getTrackerHalfLength(); 466 gBz = det3D.getBField(); 467 gEtaAxis = det3D.getCaloAxes().first; 468 gPhiAxis = det3D.getCaloAxes().second; 469 TGeoVolume* top = gGeoManager->GetTopVolume()->FindNode("Delphes3DGeometry_1")->GetVolume(); 470 TEveElementList *geometry = new TEveElementList("Geometry"); 471 TEveGeoTopNode* trk = new TEveGeoTopNode(gGeoManager, top->FindNode("tracker_1")); 472 trk->SetVisLevel(6); 473 geometry->AddElement(trk); 474 TEveGeoTopNode* calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_barrel_1")); 475 calo->SetVisLevel(3); 476 geometry->AddElement(calo); 477 calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_1")); 478 calo->SetVisLevel(3); 479 calo->UseNodeTrans(); 480 geometry->AddElement(calo); 481 calo = new TEveGeoTopNode(gGeoManager, top->FindNode("Calorimeter_endcap_2")); 482 calo->SetVisLevel(3); 483 calo->UseNodeTrans(); 484 geometry->AddElement(calo); 485 TEveGeoTopNode* muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_barrel_1")); 486 muon->SetVisLevel(4); 487 geometry->AddElement(muon); 488 muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_1")); 489 muon->SetVisLevel(4); 490 muon->UseNodeTrans(); 491 geometry->AddElement(muon); 492 muon = new TEveGeoTopNode(gGeoManager, top->FindNode("muons_endcap_2")); 493 muon->SetVisLevel(4); 494 muon->UseNodeTrans(); 495 geometry->AddElement(muon); 496 497 // Create chain of root trees 498 gChain.Add(inputFile); 499 500 // Create object of class ExRootTreeReader 485 501 printf("*** Opening Delphes data file ***\n"); 486 gTreeReader = new ExRootTreeReader(&gChain);487 488 // Get pointers to branches489 //TODO make it configurable, for more objects (or can we guess from the config?)490 gBranchTower = gTreeReader->UseBranch("Tower");491 gBranchTrack = gTreeReader->UseBranch("Track");492 gBranchJet = gTreeReader->UseBranch("Jet"); 493 502 gTreeReader = new ExRootTreeReader(&gChain); 503 504 // Get pointers to branches 505 gBranchTower = gTreeReader->UseBranch("Tower"); 506 gBranchTrack = gTreeReader->UseBranch("Track"); 507 gBranchJet = gTreeReader->UseBranch("Jet"); 508 509 //TODO make it configurable, for more objects (or can we guess from the config?) 494 510 // idea: for pf objects, we could use the TEveCompound to show track + cluster ??? (nice display but little meaning) 495 511 // for MET and SHT, show an arrow (tooltip = title) … … 514 530 */ 515 531 516 // data517 gCaloData = new DelphesCaloData(2);518 gCaloData->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);519 gCaloData->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);520 gCaloData->SetEtaBins(gEtaAxis);521 gCaloData->SetPhiBins(gPhiAxis);522 gCaloData->IncDenyDestroy();523 524 gJetList = new TEveElementList("Jets");525 gEve->AddElement(gJetList);526 527 gTrackList = new TEveTrackList("Tracks");528 gTrackList->SetMainColor(kBlue);529 gTrackList->SetMarkerColor(kRed);530 gTrackList->SetMarkerStyle(kCircle);531 gTrackList->SetMarkerSize(0.5);532 gEve->AddElement(gTrackList);533 534 TEveTrackPropagator *trkProp = gTrackList->GetPropagator();535 trkProp->SetMagField(0.0, 0.0, -gBz);536 trkProp->SetMaxR(gRadius*100.0);537 trkProp->SetMaxZ(gHalfLength*100.0);538 539 // viewers and scenes540 541 TEveCalo3D *calo = new TEveCalo3D(gCaloData);542 calo->SetBarrelRadius(gRadius*100.0); //TODO get it from geometry class543 calo->SetEndCapPos(gHalfLength*100.0); //TODO get it from geometry class544 545 gStyle->SetPalette(1, 0);546 TEveCaloLego *lego = new TEveCaloLego(gCaloData);547 lego->InitMainTrans();548 lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());549 lego->SetAutoRebin(kFALSE);550 lego->Set2DMode(TEveCaloLego::kValSizeOutline);551 552 gDelphesDisplay = new DelphesDisplay;553 gEve->AddGlobalElement(geometry);554 gEve->AddGlobalElement(calo);555 gDelphesDisplay->ImportGeomRPhi(geometry);556 gDelphesDisplay->ImportCaloRPhi(calo);557 gDelphesDisplay->ImportGeomRhoZ(geometry);558 gDelphesDisplay->ImportCaloRhoZ(calo);559 gDelphesDisplay->ImportCaloLego(lego);560 gEve->Redraw3D(kTRUE);532 // data 533 gCaloData = new DelphesCaloData(2); 534 gCaloData->RefSliceInfo(0).Setup("ECAL", 0.1, kRed); 535 gCaloData->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue); 536 gCaloData->SetEtaBins(gEtaAxis); 537 gCaloData->SetPhiBins(gPhiAxis); 538 gCaloData->IncDenyDestroy(); 539 540 gJetList = new TEveElementList("Jets"); 541 gEve->AddElement(gJetList); 542 543 gTrackList = new TEveTrackList("Tracks"); 544 gTrackList->SetMainColor(kBlue); 545 gTrackList->SetMarkerColor(kRed); 546 gTrackList->SetMarkerStyle(kCircle); 547 gTrackList->SetMarkerSize(0.5); 548 gEve->AddElement(gTrackList); 549 550 TEveTrackPropagator *trkProp = gTrackList->GetPropagator(); 551 trkProp->SetMagField(0.0, 0.0, -gBz); 552 trkProp->SetMaxR(gRadius*100.0); 553 trkProp->SetMaxZ(gHalfLength*100.0); 554 555 // viewers and scenes 556 557 TEveCalo3D *calo = new TEveCalo3D(gCaloData); 558 calo->SetBarrelRadius(gRadius*100.0); 559 calo->SetEndCapPos(gHalfLength*100.0); 560 561 gStyle->SetPalette(1, 0); 562 TEveCaloLego *lego = new TEveCaloLego(gCaloData); 563 lego->InitMainTrans(); 564 lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi()); 565 lego->SetAutoRebin(kFALSE); 566 lego->Set2DMode(TEveCaloLego::kValSizeOutline); 567 568 gDelphesDisplay = new DelphesDisplay; 569 gEve->AddGlobalElement(geometry); 570 gEve->AddGlobalElement(calo); 571 gDelphesDisplay->ImportGeomRPhi(geometry); 572 gDelphesDisplay->ImportCaloRPhi(calo); 573 gDelphesDisplay->ImportGeomRhoZ(geometry); 574 gDelphesDisplay->ImportCaloRhoZ(calo); 575 gDelphesDisplay->ImportCaloLego(lego); 576 gEve->Redraw3D(kTRUE); 561 577 562 578 }
Note:
See TracChangeset
for help on using the changeset viewer.