Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /* 27 * =========================================== 28 * 29 * Filename: CexmcHistoManager.cc 30 * 31 * Description: histograming manager (sing 32 * 33 * Version: 1.0 34 * Created: 26.11.2009 21:00:03 35 * Revision: none 36 * Compiler: gcc 37 * 38 * Author: Alexey Radkov (), 39 * Company: PNPI 40 * 41 * =========================================== 42 */ 43 44 #ifdef CEXMC_USE_ROOT 45 46 #include <iostream> 47 #include <iomanip> 48 #include <TH1.h> 49 #include <TH1F.h> 50 #include <TH2F.h> 51 #include <TH3F.h> 52 #include <TFile.h> 53 #include <TObject.h> 54 #include <TCollection.h> 55 #include <TDirectory.h> 56 #include <TString.h> 57 #ifdef CEXMC_USE_ROOTQT 58 #include <TCanvas.h> 59 #include <TList.h> 60 #include <QApplication> 61 #include <QFont> 62 #include <QMenu> 63 #include <G4UIQt.hh> 64 #include "CexmcMessenger.hh" 65 #endif 66 #include <G4LogicalVolume.hh> 67 #include <G4Box.hh> 68 #include <G4Tubs.hh> 69 #include <G4SystemOfUnits.hh> 70 #include "CexmcHistoManager.hh" 71 #include "CexmcHistoManagerMessenger.hh" 72 #include "CexmcProductionModel.hh" 73 #include "CexmcPhysicsManager.hh" 74 #include "CexmcRunManager.hh" 75 #include "CexmcSetup.hh" 76 #include "CexmcException.hh" 77 #include "CexmcHistoWidget.hh" 78 79 80 namespace 81 { 82 const G4double CexmcHistoBeamMomentumMin( 83 const G4double CexmcHistoBeamMomentumMax( 84 const G4double CexmcHistoBeamMomentumReso 85 const G4double CexmcHistoTPResolution( 0. 86 const G4double CexmcHistoTPSafetyArea( 1. 87 const G4double CexmcHistoMassResolution( 88 const G4double CexmcHistoEnergyMax( 1.0 * 89 const G4double CexmcHistoEnergyResolution 90 const G4double CexmcHistoMissEnergyMin( - 91 const G4double CexmcHistoMissEnergyMax( 0 92 const G4double CexmcHistoMissEnergyResolu 93 const G4double CexmcHistoAngularResolutio 94 const G4double CexmcHistoAngularCResoluti 95 #ifdef CEXMC_USE_ROOTQT 96 const G4int CexmcHistoCanvasWidth( 800 97 const G4int CexmcHistoCanvasHeight( 60 98 #endif 99 const G4String CexmcHistoDirectoryHandle( 100 const G4String CexmcHistoDirectoryTitle( 101 } 102 103 104 CexmcHistoManager * CexmcHistoManager::instan 105 106 107 CexmcHistoManager * CexmcHistoManager::Instan 108 { 109 if ( instance == NULL ) 110 instance = new CexmcHistoManager; 111 112 return instance; 113 } 114 115 116 void CexmcHistoManager::Destroy( void ) 117 { 118 delete instance; 119 instance = NULL; 120 } 121 122 123 CexmcHistoManager::CexmcHistoManager() : outFi 124 isInitialized( false ), opName( "" ), nopN 125 nopMass( 0. ), verboseLevel( 0 ), 126 #ifdef CEXMC_USE_ROOTQT 127 rootCanvas( NULL ), areLiveHistogramsEnabl 128 isHistoMenuInitialized( false ), drawOptio 129 drawOptions3D( "" ), histoMenuHandle( "" ) 130 #endif 131 messenger( NULL ) 132 { 133 for ( int i( 0 ); i < CexmcHistoType_SIZE 134 { 135 histos.insert( CexmcHistoPair( CexmcHi 136 CexmcHi 137 } 138 139 messenger = new CexmcHistoManagerMessenger 140 } 141 142 143 CexmcHistoManager::~CexmcHistoManager() 144 { 145 if ( outFile ) 146 { 147 outFile->Write(); 148 outFile->Close(); 149 } 150 151 /* all histograms will be deleted by outFi 152 delete outFile; 153 #ifdef CEXMC_USE_ROOTQT 154 delete rootCanvas; 155 #endif 156 delete messenger; 157 } 158 159 160 void CexmcHistoManager::AddHisto( const Cexmc 161 const Cexmc 162 { 163 G4String fullName( data.name ); 164 G4String fullTitle( data.title ); 165 G4String rangeTypeLabel; 166 G4String triggerTypeLabel; 167 G4String decorTriggerTypeLabel; 168 169 if ( data.isARHisto ) 170 { 171 if ( data.isARRec ) 172 { 173 fullName += "_arrec"; 174 rangeTypeLabel = "rec"; 175 } 176 else 177 { 178 fullName += "_arreal"; 179 rangeTypeLabel = "real"; 180 } 181 } 182 183 switch ( data.triggerType ) 184 { 185 case CexmcTPT : 186 fullName += "_tpt"; 187 decorTriggerTypeLabel = " --tpt--"; 188 fullTitle += decorTriggerTypeLabel; 189 triggerTypeLabel = "tpt"; 190 break; 191 case CexmcEDT : 192 fullName += "_edt"; 193 decorTriggerTypeLabel = " --edt--"; 194 fullTitle += decorTriggerTypeLabel; 195 triggerTypeLabel = "edt"; 196 break; 197 case CexmcRT : 198 fullName += "_rt"; 199 decorTriggerTypeLabel = " --rt--"; 200 fullTitle += decorTriggerTypeLabel; 201 triggerTypeLabel = "rt"; 202 break; 203 default : 204 break; 205 } 206 207 CexmcHistosMap::iterator found( histos.fi 208 209 if ( found == histos.end() ) 210 throw CexmcException( CexmcWeirdExcept 211 212 CexmcHistoVector & histoVector( found->se 213 214 if ( data.isARHisto ) 215 { 216 G4bool dirOk( false ); 217 218 dirOk = gDirectory->Get( fullName ) != 219 220 if ( ! dirOk ) 221 dirOk = ( gDirectory->mkdir( fullN 222 223 if ( dirOk ) 224 gDirectory->cd( fullName ); 225 226 std::ostringstream histoName; 227 std::ostringstream histoTitle; 228 histoName << data.name << "_r" << aRan 229 "_" << triggerTypeLabel; 230 histoTitle << data.title << " {range " 231 rangeTypeLabel << " [" << std: 232 std::setprecision( 4 ) << aRan 233 aRange.bottom << ")}" << decor 234 CreateHisto( histoVector, data.impl, h 235 data.axes ); 236 237 if ( dirOk ) 238 gDirectory->cd( ".." ); 239 } 240 else 241 { 242 CreateHisto( histoVector, data.impl, f 243 } 244 } 245 246 247 void CexmcHistoManager::CreateHisto( CexmcHis 248 CexmcHistoImpl histoI 249 const G4String & titl 250 { 251 TH1 * histo( NULL ); 252 253 switch ( histoImpl ) 254 { 255 case Cexmc_TH1F : 256 histo = new TH1F( name, title, axes.at 257 axes.at( 0 ).nBinsMi 258 break; 259 case Cexmc_TH2F : 260 histo = new TH2F( name, title, axes.at 261 axes.at( 0 ).nBinsMi 262 axes.at( 1 ).nBins, 263 axes.at( 1 ).nBinsMa 264 break; 265 case Cexmc_TH3F : 266 histo = new TH3F( name, title, axes.at 267 axes.at( 0 ).nBinsMi 268 axes.at( 1 ).nBins, 269 axes.at( 1 ).nBinsMa 270 axes.at( 2 ).nBinsMi 271 break; 272 default : 273 break; 274 } 275 276 if ( histo ) 277 histoVector.push_back( histo ); 278 } 279 280 281 void CexmcHistoManager::Initialize( void ) 282 { 283 if ( isInitialized ) 284 return; 285 286 CexmcRunManager * runManager( static 287 G4 288 CexmcPhysicsManager * physicsManager( ru 289 290 if ( ! physicsManager ) 291 throw CexmcException( CexmcWeirdExcept 292 293 CexmcProductionModel * productionModel( p 294 295 296 if ( ! productionModel ) 297 throw CexmcException( CexmcWeirdExcept 298 299 G4ParticleDefinition * outputParticle( 300 productionMode 301 G4ParticleDefinition * nucleusOutputParti 302 productionMode 303 304 if ( ! outputParticle || ! nucleusOutputPa 305 throw CexmcException( CexmcIncompleteP 306 307 opName = outputParticle->GetParticleName() 308 nopName = nucleusOutputParticle->GetPartic 309 opMass = outputParticle->GetPDGMass(); 310 nopMass = nucleusOutputParticle->GetPDGMas 311 312 G4String title; 313 Int_t nBinsX; 314 Int_t nBinsY; 315 Double_t nBinsMinX; 316 Double_t nBinsMaxX; 317 Double_t nBinsMinY; 318 Double_t nBinsMaxY; 319 CexmcHistoAxes axes; 320 321 if ( runManager->ProjectIsSaved() ) 322 { 323 G4String projectsDir( runManager->Get 324 G4String resultsFile( projectsDir + " 325 ".root" ); 326 outFile = new TFile( resultsFile, "rec 327 } 328 else 329 { 330 outFile = new TDirectoryFile( CexmcHis 331 CexmcHis 332 gDirectory->cd( CexmcHistoDirectoryHan 333 } 334 335 if ( ! outFile ) 336 throw CexmcException( CexmcWeirdExcept 337 338 const CexmcSetup * setup( static_cast< co 339 runManager->Ge 340 if ( ! setup ) 341 throw CexmcException( CexmcWeirdExcept 342 343 const G4LogicalVolume * lVolume( setup->G 344 345 if ( ! lVolume ) 346 throw CexmcException( CexmcIncompatibl 347 348 nBinsMinX = CexmcHistoBeamMomentumMin; 349 nBinsMaxX = CexmcHistoBeamMomentumMax; 350 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 351 CexmcHistoBeamMomentumReso 352 axes.push_back( CexmcHistoAxisData( nBinsX 353 AddHisto( CexmcHistoData( CexmcMomentumBP_ 354 false, CexmcTPT, "mombp", "Beam mome 355 AddHisto( CexmcHistoData( CexmcMomentumBP_ 356 false, CexmcRT, "mombp", "Beam momen 357 if ( verboseLevel > 0 ) 358 { 359 AddHisto( CexmcHistoData( CexmcMomentu 360 false, CexmcTPT, "momip", "Momentu 361 axes ) ); 362 } 363 364 G4Box * box( dynamic_cast< G4Box * >( lV 365 366 if ( ! box ) 367 throw CexmcException( CexmcIncompatibl 368 369 G4double width( box->GetXHalfLength() * 2 370 G4double height( box->GetYHalfLength() * 371 G4double halfWidth( width / 2 + CexmcHist 372 G4double halfHeight( height / 2 + CexmcHi 373 374 nBinsX = Int_t( halfWidth * 2 / CexmcHisto 375 nBinsY = Int_t( halfHeight * 2 / CexmcHist 376 axes.clear(); 377 axes.push_back( CexmcHistoAxisData( nBinsX 378 axes.push_back( CexmcHistoAxisData( nBinsY 379 AddHisto( CexmcHistoData( CexmcTPInMonitor 380 false, CexmcTPT, "tpmon", "Track point 381 382 lVolume = setup->GetVolume( CexmcSetup::Ta 383 G4Tubs * tube( dynamic_cast< G4Tubs * >( 384 385 if ( ! tube ) 386 throw CexmcException( CexmcIncompatibl 387 388 G4double radius( tube->GetOuterRadius() ) 389 height = tube->GetZHalfLength() * 2; 390 halfWidth = radius + CexmcHistoTPSafetyAre 391 halfHeight = height / 2 + CexmcHistoTPSafe 392 393 nBinsX = Int_t( halfWidth * 2 / CexmcHisto 394 nBinsY = Int_t( halfWidth * 2 / CexmcHisto 395 Int_t nBinsZ( Int_t( halfHeight * 2 / Cex 396 axes.clear(); 397 axes.push_back( CexmcHistoAxisData( nBinsX 398 axes.push_back( CexmcHistoAxisData( nBinsY 399 axes.push_back( CexmcHistoAxisData( nBinsZ 400 AddHisto( CexmcHistoData( CexmcTPInTarget_ 401 false, CexmcTPT, "tptar", "Track point 402 AddHisto( CexmcHistoData( CexmcTPInTarget_ 403 false, CexmcRT, "tptar", "Track points 404 405 title = "Reconstructed masses (" + nopName 406 nBinsMinX = opMass / 2; 407 nBinsMaxX = opMass + opMass / 2; 408 nBinsMinY = nopMass / 2; 409 nBinsMaxY = nopMass + nopMass / 2; 410 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 411 nBinsY = Int_t( ( nBinsMaxY - nBinsMinY ) 412 axes.clear(); 413 axes.push_back( CexmcHistoAxisData( nBinsX 414 axes.push_back( CexmcHistoAxisData( nBinsY 415 AddHisto( CexmcHistoData( CexmcRecMasses_E 416 false, CexmcEDT, "recmasses", title, a 417 AddHisto( CexmcHistoData( CexmcRecMasses_R 418 false, CexmcRT, "recmasses", title, ax 419 420 nBinsMinX = 0.; 421 nBinsMaxX = CexmcHistoEnergyMax; 422 nBinsMinY = 0.; 423 nBinsMaxY = CexmcHistoEnergyMax; 424 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 425 nBinsY = Int_t( ( nBinsMaxY - nBinsMinY ) 426 axes.clear(); 427 axes.push_back( CexmcHistoAxisData( nBinsX 428 axes.push_back( CexmcHistoAxisData( nBinsY 429 AddHisto( CexmcHistoData( CexmcAbsorbedEne 430 false, CexmcEDT, "ae", "Absorbed energ 431 AddHisto( CexmcHistoData( CexmcAbsorbedEne 432 false, CexmcRT, "ae", "Absorbed energy 433 434 SetupARHistos( runManager->GetPhysicsManag 435 GetAngularRanges() ); 436 437 isInitialized = true; 438 } 439 440 441 void CexmcHistoManager::SetupARHistos( const 442 { 443 TIter objs( gDirectory->GetList() ); 444 TObject * obj( NULL ); 445 446 while ( ( obj = ( TObject * )objs() ) ) 447 { 448 TString name( obj->GetName() ); 449 450 if ( obj->IsFolder() && ( name.Contain 451 name.Contain 452 { 453 gDirectory->cd( name ); 454 gDirectory->DeleteAll(); 455 gDirectory->cd( ".." ); 456 } 457 } 458 459 for ( CexmcHistosMap::iterator k( histos. 460 461 { 462 if ( k->second.empty() ) 463 continue; 464 465 if ( k->first >= CexmcHistoType_ARReal 466 k->first <= CexmcHistoType_ARReal 467 { 468 k->second.clear(); 469 } 470 } 471 472 for ( CexmcAngularRangeList::const_iterato 473 474 { 475 AddARHistos( *k ); 476 } 477 } 478 479 480 void CexmcHistoManager::AddARHistos( const Ce 481 { 482 G4String title; 483 Int_t nBinsX; 484 Double_t nBinsMinX; 485 Double_t nBinsMaxX; 486 CexmcHistoAxes axes; 487 488 title = "Reconstructed mass of " + opName; 489 nBinsMinX = opMass / 2; 490 nBinsMaxX = opMass + opMass / 2; 491 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 492 axes.push_back( CexmcHistoAxisData( nBinsX 493 AddHisto( CexmcHistoData( CexmcRecMassOP_A 494 false, CexmcRT, "recmassop", title, ax 495 496 title = "Reconstructed mass of " + nopName 497 nBinsMinX = nopMass / 2; 498 nBinsMaxX = nopMass + nopMass / 2; 499 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 500 axes.clear(); 501 axes.push_back( CexmcHistoAxisData( nBinsX 502 AddHisto( CexmcHistoData( CexmcRecMassNOP_ 503 false, CexmcRT, "recmassnop", title, a 504 505 G4RunManager * runManager( G4RunManag 506 const CexmcSetup * setup( static_cast< co 507 runManager->Ge 508 if ( ! setup ) 509 throw CexmcException( CexmcWeirdExcept 510 511 const G4LogicalVolume * lVolume( setup->G 512 513 514 G4Box * box( dynamic_cast< G4Box * >( lV 515 516 if ( ! box ) 517 throw CexmcException( CexmcIncompatibl 518 519 G4double width( box->GetXHalfLength() * 2 520 G4double height( box->GetYHalfLength() * 521 G4double halfWidth( width / 2 + CexmcHist 522 G4double halfHeight( height / 2 + CexmcHi 523 524 nBinsX = Int_t( halfWidth * 2 / CexmcHisto 525 Int_t nBinsY( Int_t( halfHeight * 2 / Cex 526 axes.clear(); 527 axes.push_back( CexmcHistoAxisData( nBinsX 528 axes.push_back( CexmcHistoAxisData( nBinsY 529 530 /* looks like there is no possibility to d 531 * so imagine that you look at calorimeter 532 * the beam */ 533 AddHisto( CexmcHistoData( CexmcOPDPAtLeftC 534 Cexmc_TH2F, true, false, CexmcEDT, "op 535 "Gamma position on the surface (lc)", 536 AddHisto( CexmcHistoData( CexmcOPDPAtRight 537 Cexmc_TH2F, true, false, CexmcEDT, "op 538 "Gamma position on the surface (rc)", 539 AddHisto( CexmcHistoData( CexmcOPDPAtLeftC 540 Cexmc_TH2F, true, false, CexmcRT, "opd 541 "Gamma position on the surface (lc)", 542 AddHisto( CexmcHistoData( CexmcOPDPAtRight 543 Cexmc_TH2F, true, false, CexmcRT, "opd 544 "Gamma position on the surface (rc)", 545 AddHisto( CexmcHistoData( CexmcRecOPDPAtLe 546 Cexmc_TH2F, true, false, CexmcEDT, "re 547 "Reconstructed gamma position on the s 548 AddHisto( CexmcHistoData( CexmcRecOPDPAtRi 549 Cexmc_TH2F, true, false, CexmcEDT, "re 550 "Reconstructed gamma position on the s 551 AddHisto( CexmcHistoData( CexmcRecOPDPAtLe 552 Cexmc_TH2F, true, false, CexmcRT, "rec 553 "Reconstructed gamma position on the s 554 AddHisto( CexmcHistoData( CexmcRecOPDPAtRi 555 Cexmc_TH2F, true, false, CexmcRT, "rec 556 "Reconstructed gamma position on the s 557 558 nBinsMinX = 0.; 559 nBinsMaxX = CexmcHistoEnergyMax; 560 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 561 axes.clear(); 562 axes.push_back( CexmcHistoAxisData( nBinsX 563 AddHisto( CexmcHistoData( CexmcKinEnAtLeft 564 Cexmc_TH1F, true, false, CexmcTPT, "ke 565 "Kinetic energy of gamma (lc)", axes ) 566 AddHisto( CexmcHistoData( CexmcKinEnAtRigh 567 Cexmc_TH1F, true, false, CexmcTPT, "ke 568 "Kinetic energy of gamma (rc)", axes ) 569 AddHisto( CexmcHistoData( CexmcKinEnAtLeft 570 Cexmc_TH1F, true, false, CexmcRT, "kec 571 "Kinetic energy of gamma (lc)", axes ) 572 AddHisto( CexmcHistoData( CexmcKinEnAtRigh 573 Cexmc_TH1F, true, false, CexmcRT, "kec 574 "Kinetic energy of gamma (rc)", axes ) 575 AddHisto( CexmcHistoData( CexmcAbsEnInLeft 576 Cexmc_TH1F, true, false, CexmcEDT, "ae 577 "Absorbed energy (lc)", axes ), aRange 578 AddHisto( CexmcHistoData( CexmcAbsEnInRigh 579 Cexmc_TH1F, true, false, CexmcEDT, "ae 580 "Absorbed energy (rc)", axes ), aRange 581 AddHisto( CexmcHistoData( CexmcAbsEnInLeft 582 Cexmc_TH1F, true, false, CexmcRT, "aec 583 "Absorbed energy (lc)", axes ), aRange 584 AddHisto( CexmcHistoData( CexmcAbsEnInRigh 585 Cexmc_TH1F, true, false, CexmcRT, "aec 586 "Absorbed energy (rc)", axes ), aRange 587 588 nBinsMinX = CexmcHistoMissEnergyMin; 589 nBinsMaxX = CexmcHistoMissEnergyMax; 590 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 591 CexmcHistoMissEnergyResolu 592 axes.clear(); 593 axes.push_back( CexmcHistoAxisData( nBinsX 594 AddHisto( CexmcHistoData( CexmcMissEnFromL 595 Cexmc_TH1F, true, false, CexmcRT, "mec 596 "Missing energy (lc)", axes ), aRange 597 AddHisto( CexmcHistoData( CexmcMissEnFromR 598 Cexmc_TH1F, true, false, CexmcRT, "mec 599 "Missing energy (rc)", axes ), aRange 600 601 title = "Kinetic energy of newborn " + opN 602 nBinsMinX = 0.; 603 nBinsMaxX = CexmcHistoEnergyMax; 604 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 605 axes.clear(); 606 axes.push_back( CexmcHistoAxisData( nBinsX 607 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB 608 Cexmc_TH1F, true, false, CexmcTPT, "ke 609 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB 610 Cexmc_TH1F, true, false, CexmcRT, "keo 611 612 title = "Angle of newborn " + opName + " ( 613 nBinsMinX = -1.0; 614 nBinsMaxX = 1.0; 615 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 616 axes.clear(); 617 axes.push_back( CexmcHistoAxisData( nBinsX 618 AddHisto( CexmcHistoData( CexmcAngleOP_SCM 619 Cexmc_TH1F, true, false, CexmcTPT, "ao 620 AddHisto( CexmcHistoData( CexmcAngleOP_SCM 621 Cexmc_TH1F, true, false, CexmcRT, "aop 622 623 title = "Reconstruced angle of newborn " + 624 AddHisto( CexmcHistoData( CexmcRecAngleOP_ 625 Cexmc_TH1F, true, false, CexmcRT, "rec 626 627 title = "Real - reconstruced angle of newb 628 AddHisto( CexmcHistoData( CexmcDiffAngleOP 629 Cexmc_TH1F, true, false, CexmcRT, "dif 630 aRange ); 631 632 nBinsMinX = 0.; 633 nBinsMaxX = 360.; 634 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 635 axes.clear(); 636 axes.push_back( CexmcHistoAxisData( nBinsX 637 AddHisto( CexmcHistoData( CexmcOpenAngle_A 638 Cexmc_TH1F, true, false, CexmcTPT, "oa 639 "Open angle between the gammas", axes 640 AddHisto( CexmcHistoData( CexmcOpenAngle_A 641 Cexmc_TH1F, true, false, CexmcRT, "oa" 642 "Open angle between the gammas", axes 643 AddHisto( CexmcHistoData( CexmcRecOpenAngl 644 Cexmc_TH1F, true, false, CexmcRT, "rec 645 "Reconstructed open angle between the 646 647 nBinsMinX = -180.; 648 nBinsMaxX = 180.; 649 nBinsX = Int_t( ( nBinsMaxX - nBinsMinX ) 650 axes.clear(); 651 axes.push_back( CexmcHistoAxisData( nBinsX 652 AddHisto( CexmcHistoData( CexmcDiffOpenAng 653 Cexmc_TH1F, true, false, CexmcRT, "dif 654 "Real - reconstructed open angle betwe 655 656 lVolume = setup->GetVolume( CexmcSetup::Ta 657 G4Tubs * tube( dynamic_cast< G4Tubs * >( 658 659 if ( ! tube ) 660 throw CexmcException( CexmcIncompatibl 661 662 G4double radius( tube->GetOuterRadius() ) 663 height = tube->GetZHalfLength() * 2; 664 halfWidth = radius + CexmcHistoTPSafetyAre 665 halfHeight = height / 2 + CexmcHistoTPSafe 666 667 nBinsX = Int_t( halfWidth * 2 / CexmcHisto 668 nBinsY = Int_t( halfWidth * 2 / CexmcHisto 669 Int_t nBinsZ( Int_t( halfHeight * 2 / Cex 670 axes.clear(); 671 axes.push_back( CexmcHistoAxisData( nBinsX 672 axes.push_back( CexmcHistoAxisData( nBinsY 673 axes.push_back( CexmcHistoAxisData( nBinsZ 674 AddHisto( CexmcHistoData( CexmcTPInTarget_ 675 true, false, CexmcTPT, "tptar", "Track 676 AddHisto( CexmcHistoData( CexmcTPInTarget_ 677 true, false, CexmcRT, "tptar", "Track 678 } 679 680 681 void CexmcHistoManager::Add( CexmcHistoType 682 G4double x ) 683 { 684 CexmcHistosMap::iterator found( histos.fi 685 if ( found == histos.end() || histos[ hist 686 throw CexmcException( CexmcWeirdExcept 687 688 histos[ histoType ][ index ]->Fill( x ); 689 } 690 691 692 void CexmcHistoManager::Add( CexmcHistoType 693 G4double x, G4d 694 { 695 CexmcHistosMap::iterator found( histos.fi 696 if ( found == histos.end() || histos[ hist 697 throw CexmcException( CexmcWeirdExcept 698 699 /* no cast needed because TH1 has virtual 700 * Fill( Double_t, Double_t ) */ 701 histos[ histoType ][ index ]->Fill( x, y ) 702 } 703 704 705 void CexmcHistoManager::Add( CexmcHistoType 706 G4double x, G4d 707 { 708 CexmcHistosMap::iterator found( histos.fi 709 if ( found == histos.end() || histos[ hist 710 throw CexmcException( CexmcWeirdExcept 711 712 /* cast needed because TH1 does not have v 713 * Fill( Double_t, Double_t, Double_t ) */ 714 TH3 * histo( static_cast< TH3 * >( histos 715 716 histo->Fill( x, y, z ); 717 } 718 719 720 void CexmcHistoManager::Add( CexmcHistoType 721 G4int binX, G4i 722 { 723 CexmcHistosMap::iterator found( histos.fi 724 if ( found == histos.end() || histos[ hist 725 throw CexmcException( CexmcWeirdExcept 726 727 ++binX; 728 ++binY; 729 Double_t curValue( histos[ histoType ][ i 730 731 histos[ histoType ][ index ]->SetBinConten 732 733 } 734 735 736 void CexmcHistoManager::List( void ) const 737 { 738 /* BEWARE: list will be printed on stdout 739 gDirectory->ls(); 740 } 741 742 743 void CexmcHistoManager::Print( const G4String 744 { 745 TObject * histo( gDirectory->FindObjectAn 746 747 if ( ! histo ) 748 { 749 G4cout << "Histogram '" << value << "' 750 return; 751 } 752 753 /* BEWARE: histo will be printed on stdout 754 histo->Print( "range" ); 755 } 756 757 758 #ifdef CEXMC_USE_ROOTQT 759 760 void CexmcHistoManager::Draw( const G4String 761 const G4String 762 { 763 if ( ! areLiveHistogramsEnabled ) 764 { 765 G4cout << "Live histograms option is d 766 return; 767 } 768 769 TObject * histo( gDirectory->FindObjectAn 770 771 if ( ! histo ) 772 { 773 G4cout << "Histogram '" << histoName < 774 return; 775 } 776 777 if ( ! rootCanvas ) 778 { 779 /* save default application font becau 780 QFont defaultAppFont( QApplication::f 781 rootCanvas = new CexmcHistoWidget; 782 QApplication::setFont( defaultAppFont 783 rootCanvas->resize( CexmcHistoCanvasWi 784 rootCanvas->GetCanvas()->cd(); 785 } 786 787 histo->Draw( histoDrawOptions ); 788 rootCanvas->show(); 789 rootCanvas->GetCanvas()->Update(); 790 } 791 792 793 void CexmcHistoManager::EnableLiveHistograms( 794 795 { 796 areLiveHistogramsEnabled = on; 797 798 if ( ! on || ! isInitialized ) 799 return; 800 801 G4UIQt * qtSession( dynamic_cast< G4UIQt 802 803 if ( ! qtSession ) 804 return; 805 806 if ( ! histoMenuHandle.empty() && ! isHist 807 { 808 qtSession->AddMenu( histoMenuHandle, h 809 BuildMenuTree( qtSession, histoMenuHan 810 isHistoMenuInitialized = true; 811 } 812 } 813 814 815 void CexmcHistoManager::BuildMenuTree( G4UIQt 816 const 817 { 818 TIter objs( ls ); 819 TObject * obj( NULL ); 820 821 while ( ( obj = ( TObject * )objs() ) ) 822 { 823 G4String name( obj->GetName() ); 824 G4String title( obj->GetTitle() ); 825 826 if ( obj->IsFolder() ) 827 { 828 AddSubmenu( session, menu, name, t 829 BuildMenuTree( session, name, ( ( 830 } 831 else 832 { 833 G4String options( name ); 834 835 do 836 { 837 if ( obj->InheritsFrom( TH3::C 838 ! drawOptions3D.empty() ) 839 { 840 title = G4String( "3: " ) 841 options += G4String( " " ) 842 break; 843 } 844 if ( obj->InheritsFrom( TH2::C 845 ! drawOptions2D.empty() ) 846 { 847 title = G4String( "2: " ) 848 options += G4String( " " ) 849 break; 850 } 851 if ( obj->InheritsFrom( TH1::C 852 ! drawOptions1D.empty() ) 853 { 854 options += G4String( " " ) 855 break; 856 } 857 } while ( false ); 858 859 G4String cmd( CexmcMessenger::his 860 session->AddButton( menu, title.c_ 861 } 862 } 863 } 864 865 866 void CexmcHistoManager::AddSubmenu( G4UIQt * 867 const G4S 868 const G4S 869 const G4S 870 { 871 QMenu * menu( new QMenu( label.c_str() ) ); 872 QMenu * parentMenu( ( QMenu * )session->Get 873 874 parentMenu->addMenu( menu ); 875 session->AddInteractor( name, ( G4Interactor 876 } 877 878 #endif 879 880 #endif 881 882