54 #include <TCollection.h>
55 #include <TDirectory.h>
57 #ifdef CEXMC_USE_ROOTQT
60 #include <QApplication>
82 const G4double CexmcHistoBeamMomentumMin( 0.0 *
GeV );
83 const G4double CexmcHistoBeamMomentumMax( 1.0 *
GeV );
84 const G4double CexmcHistoBeamMomentumResolution( 0.5 *
MeV );
85 const G4double CexmcHistoTPResolution( 0.1 *
cm );
86 const G4double CexmcHistoTPSafetyArea( 1.0 *
cm );
87 const G4double CexmcHistoMassResolution( 1.0 *
MeV );
89 const G4double CexmcHistoEnergyResolution( 1.0 *
MeV );
90 const G4double CexmcHistoMissEnergyMin( -0.1 *
GeV );
91 const G4double CexmcHistoMissEnergyMax( 0.2 *
GeV );
92 const G4double CexmcHistoMissEnergyResolution( 0.2 *
MeV );
93 const G4double CexmcHistoAngularResolution( 0.5 );
94 const G4double CexmcHistoAngularCResolution( 0.001 );
95 #ifdef CEXMC_USE_ROOTQT
96 const G4int CexmcHistoCanvasWidth( 800 );
97 const G4int CexmcHistoCanvasHeight( 600 );
99 const G4String CexmcHistoDirectoryHandle(
"histograms" );
100 const G4String CexmcHistoDirectoryTitle(
"Histograms" );
107 CexmcHistoManager * CexmcHistoManager::Instance(
void )
116 void CexmcHistoManager::Destroy(
void )
123 CexmcHistoManager::CexmcHistoManager() : outFile( NULL ),
125 nopMass( 0. ), verboseLevel( 0 ),
126 #ifdef CEXMC_USE_ROOTQT
127 rootCanvas( NULL ), areLiveHistogramsEnabled(
false ),
128 isHistoMenuInitialized(
false ), drawOptions1D(
"" ), drawOptions2D(
"" ),
129 drawOptions3D(
"" ), histoMenuHandle(
"" ), histoMenuLabel(
"" ),
133 for (
int i( 0 ); i < CexmcHistoType_SIZE; ++i )
135 histos.insert( CexmcHistoPair( CexmcHistoType( i ),
136 CexmcHistoVector() ) );
139 messenger =
new CexmcHistoManagerMessenger(
this );
143 CexmcHistoManager::~CexmcHistoManager()
153 #ifdef CEXMC_USE_ROOTQT
160 void CexmcHistoManager::AddHisto(
const CexmcHistoData &
data,
169 if ( data.isARHisto )
173 fullName +=
"_arrec";
174 rangeTypeLabel =
"rec";
178 fullName +=
"_arreal";
179 rangeTypeLabel =
"real";
183 switch ( data.triggerType )
187 decorTriggerTypeLabel =
" --tpt--";
188 fullTitle += decorTriggerTypeLabel;
189 triggerTypeLabel =
"tpt";
193 decorTriggerTypeLabel =
" --edt--";
194 fullTitle += decorTriggerTypeLabel;
195 triggerTypeLabel =
"edt";
199 decorTriggerTypeLabel =
" --rt--";
200 fullTitle += decorTriggerTypeLabel;
201 triggerTypeLabel =
"rt";
207 CexmcHistosMap::iterator found( histos.find( data.type ) );
209 if ( found == histos.end() )
212 CexmcHistoVector & histoVector( found->second );
214 if ( data.isARHisto )
218 dirOk = gDirectory->Get( fullName ) != NULL;
221 dirOk = ( gDirectory->mkdir( fullName, fullTitle ) != NULL );
224 gDirectory->cd( fullName );
226 std::ostringstream histoName;
227 std::ostringstream histoTitle;
228 histoName << data.name <<
"_r" << aRange.
index + 1 << rangeTypeLabel <<
229 "_" << triggerTypeLabel;
230 histoTitle << data.title <<
" {range " << aRange.
index + 1 <<
231 rangeTypeLabel <<
" [" << std::fixed <<
232 std::setprecision( 4 ) << aRange.
top <<
", " <<
233 aRange.
bottom <<
")}" << decorTriggerTypeLabel;
234 CreateHisto( histoVector, data.impl, histoName.str(), histoTitle.str(),
238 gDirectory->cd(
".." );
242 CreateHisto( histoVector, data.impl, fullName, fullTitle, data.axes );
247 void CexmcHistoManager::CreateHisto( CexmcHistoVector & histoVector,
256 histo =
new TH1F( name, title, axes.at( 0 ).nBins,
257 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax );
260 histo =
new TH2F( name, title, axes.at( 0 ).nBins,
261 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax,
262 axes.at( 1 ).nBins, axes.at( 1 ).nBinsMin,
263 axes.at( 1 ).nBinsMax );
266 histo =
new TH3F( name, title, axes.at( 0 ).nBins,
267 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax,
268 axes.at( 1 ).nBins, axes.at( 1 ).nBinsMin,
269 axes.at( 1 ).nBinsMax, axes.at( 2 ).nBins,
270 axes.at( 2 ).nBinsMin, axes.at( 2 ).nBinsMax );
277 histoVector.push_back( histo );
290 if ( ! physicsManager )
294 GetProductionModel() );
296 if ( ! productionModel )
300 productionModel->GetOutputParticle() );
302 productionModel->GetNucleusOutputParticle() );
304 if ( ! outputParticle || ! nucleusOutputParticle )
307 opName = outputParticle->GetParticleName();
308 nopName = nucleusOutputParticle->GetParticleName();
309 opMass = outputParticle->GetPDGMass();
310 nopMass = nucleusOutputParticle->GetPDGMass();
321 if ( runManager->ProjectIsSaved() )
323 G4String projectsDir( runManager->GetProjectsDir() );
324 G4String resultsFile( projectsDir +
"/" + runManager->GetProjectId() +
326 outFile =
new TFile( resultsFile,
"recreate" );
330 outFile =
new TDirectoryFile( CexmcHistoDirectoryHandle,
331 CexmcHistoDirectoryTitle );
332 gDirectory->cd( CexmcHistoDirectoryHandle );
338 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
339 runManager->GetUserDetectorConstruction() ) );
348 nBinsMinX = CexmcHistoBeamMomentumMin;
349 nBinsMaxX = CexmcHistoBeamMomentumMax;
350 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) /
351 CexmcHistoBeamMomentumResolution );
352 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
353 AddHisto( CexmcHistoData( CexmcMomentumBP_TPT_Histo, Cexmc_TH1F,
false,
354 false,
CexmcTPT,
"mombp",
"Beam momentum at the monitor", axes ) );
355 AddHisto( CexmcHistoData( CexmcMomentumBP_RT_Histo, Cexmc_TH1F,
false,
356 false,
CexmcRT,
"mombp",
"Beam momentum at the monitor", axes ) );
357 if ( verboseLevel > 0 )
359 AddHisto( CexmcHistoData( CexmcMomentumIP_TPT_Histo, Cexmc_TH1F,
false,
360 false,
CexmcTPT,
"momip",
"Momentum of the incident particle",
364 G4Box *
box( dynamic_cast< G4Box * >( lVolume->GetSolid() ) );
371 G4double halfWidth( width / 2 + CexmcHistoTPSafetyArea );
372 G4double halfHeight( height / 2 + CexmcHistoTPSafetyArea );
374 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
375 nBinsY =
Int_t( halfHeight * 2 / CexmcHistoTPResolution );
377 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
378 axes.push_back( CexmcHistoAxisData( nBinsY, -halfHeight, halfHeight ) );
379 AddHisto( CexmcHistoData( CexmcTPInMonitor_TPT_Histo, Cexmc_TH2F,
false,
380 false,
CexmcTPT,
"tpmon",
"Track points (mon)", axes ) );
383 G4Tubs * tube( dynamic_cast< G4Tubs * >( lVolume->GetSolid() ) );
389 height = tube->GetZHalfLength() * 2;
390 halfWidth =
radius + CexmcHistoTPSafetyArea;
391 halfHeight = height / 2 + CexmcHistoTPSafetyArea;
393 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
394 nBinsY =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
397 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
398 axes.push_back( CexmcHistoAxisData( nBinsY, -halfWidth, halfWidth ) );
399 axes.push_back( CexmcHistoAxisData(
nBinsZ, -halfHeight, halfHeight ) );
400 AddHisto( CexmcHistoData( CexmcTPInTarget_TPT_Histo, Cexmc_TH3F,
false,
401 false,
CexmcTPT,
"tptar",
"Track points (tar)", axes ) );
402 AddHisto( CexmcHistoData( CexmcTPInTarget_RT_Histo, Cexmc_TH3F,
false,
403 false,
CexmcRT,
"tptar",
"Track points (tar)", axes ) );
405 title =
"Reconstructed masses (" + nopName +
" vs. " + opName +
")";
406 nBinsMinX = opMass / 2;
407 nBinsMaxX = opMass + opMass / 2;
408 nBinsMinY = nopMass / 2;
409 nBinsMaxY = nopMass + nopMass / 2;
410 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
411 nBinsY =
Int_t( ( nBinsMaxY - nBinsMinY ) / CexmcHistoMassResolution );
413 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
414 axes.push_back( CexmcHistoAxisData( nBinsY, nBinsMinY, nBinsMaxY ) );
415 AddHisto( CexmcHistoData( CexmcRecMasses_EDT_Histo, Cexmc_TH2F,
false,
416 false,
CexmcEDT,
"recmasses", title, axes ) );
417 AddHisto( CexmcHistoData( CexmcRecMasses_RT_Histo, Cexmc_TH2F,
false,
418 false,
CexmcRT,
"recmasses", title, axes ) );
421 nBinsMaxX = CexmcHistoEnergyMax;
423 nBinsMaxY = CexmcHistoEnergyMax;
424 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
425 nBinsY =
Int_t( ( nBinsMaxY - nBinsMinY ) / CexmcHistoEnergyResolution );
427 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
428 axes.push_back( CexmcHistoAxisData( nBinsY, nBinsMinY, nBinsMaxY ) );
429 AddHisto( CexmcHistoData( CexmcAbsorbedEnergy_EDT_Histo, Cexmc_TH2F,
false,
430 false,
CexmcEDT,
"ae",
"Absorbed energy (rc vs. lc)", axes ) );
431 AddHisto( CexmcHistoData( CexmcAbsorbedEnergy_RT_Histo, Cexmc_TH2F,
false,
432 false,
CexmcRT,
"ae",
"Absorbed energy (rc vs. lc)", axes ) );
434 SetupARHistos( runManager->GetPhysicsManager()->GetProductionModel()->
435 GetAngularRanges() );
443 TIter objs( gDirectory->GetList() );
446 while ( ( obj = (
TObject * )objs() ) )
448 TString
name( obj->GetName() );
450 if ( obj->IsFolder() && ( name.Contains( TString(
"_arreal_" ) ) ||
451 name.Contains( TString(
"_arrec_" ) ) ) )
453 gDirectory->cd( name );
454 gDirectory->DeleteAll();
455 gDirectory->cd(
".." );
459 for ( CexmcHistosMap::iterator
k( histos.begin() );
k != histos.end();
462 if (
k->second.empty() )
465 if (
k->first >= CexmcHistoType_ARReal_START &&
466 k->first <= CexmcHistoType_ARReal_END )
472 for ( CexmcAngularRangeList::const_iterator
k( aRanges.begin() );
473 k != aRanges.end(); ++
k )
488 title =
"Reconstructed mass of " + opName;
489 nBinsMinX = opMass / 2;
490 nBinsMaxX = opMass + opMass / 2;
491 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
492 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
493 AddHisto( CexmcHistoData( CexmcRecMassOP_ARReal_RT_Histo, Cexmc_TH1F,
true,
494 false,
CexmcRT,
"recmassop", title, axes ), aRange );
496 title =
"Reconstructed mass of " + nopName;
497 nBinsMinX = nopMass / 2;
498 nBinsMaxX = nopMass + nopMass / 2;
499 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
501 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
502 AddHisto( CexmcHistoData( CexmcRecMassNOP_ARReal_RT_Histo, Cexmc_TH1F,
true,
503 false,
CexmcRT,
"recmassnop", title, axes ), aRange );
506 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
507 runManager->GetUserDetectorConstruction() ) );
514 G4Box *
box( dynamic_cast< G4Box * >( lVolume->GetSolid() ) );
521 G4double halfWidth( width / 2 + CexmcHistoTPSafetyArea );
522 G4double halfHeight( height / 2 + CexmcHistoTPSafetyArea );
524 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
525 Int_t nBinsY(
Int_t( halfHeight * 2 / CexmcHistoTPResolution ) );
527 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
528 axes.push_back( CexmcHistoAxisData( nBinsY, -halfHeight, halfHeight ) );
533 AddHisto( CexmcHistoData( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
534 Cexmc_TH2F,
true,
false,
CexmcEDT,
"opdpcl",
535 "Gamma position on the surface (lc)", axes ), aRange );
536 AddHisto( CexmcHistoData( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
537 Cexmc_TH2F,
true,
false,
CexmcEDT,
"opdpcr",
538 "Gamma position on the surface (rc)", axes ), aRange );
539 AddHisto( CexmcHistoData( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
540 Cexmc_TH2F,
true,
false,
CexmcRT,
"opdpcl",
541 "Gamma position on the surface (lc)", axes ), aRange );
542 AddHisto( CexmcHistoData( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
543 Cexmc_TH2F,
true,
false,
CexmcRT,
"opdpcr",
544 "Gamma position on the surface (rc)", axes ), aRange );
545 AddHisto( CexmcHistoData( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
546 Cexmc_TH2F,
true,
false,
CexmcEDT,
"recopdpcl",
547 "Reconstructed gamma position on the surface (lc)", axes ), aRange );
548 AddHisto( CexmcHistoData( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
549 Cexmc_TH2F,
true,
false,
CexmcEDT,
"recopdpcr",
550 "Reconstructed gamma position on the surface (rc)", axes ), aRange );
551 AddHisto( CexmcHistoData( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
552 Cexmc_TH2F,
true,
false,
CexmcRT,
"recopdpcl",
553 "Reconstructed gamma position on the surface (lc)", axes ), aRange );
554 AddHisto( CexmcHistoData( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
555 Cexmc_TH2F,
true,
false,
CexmcRT,
"recopdpcr",
556 "Reconstructed gamma position on the surface (rc)", axes ), aRange );
559 nBinsMaxX = CexmcHistoEnergyMax;
560 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
562 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
563 AddHisto( CexmcHistoData( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
564 Cexmc_TH1F,
true,
false,
CexmcTPT,
"kecl",
565 "Kinetic energy of gamma (lc)", axes ), aRange );
566 AddHisto( CexmcHistoData( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
567 Cexmc_TH1F,
true,
false,
CexmcTPT,
"kecr",
568 "Kinetic energy of gamma (rc)", axes ), aRange );
569 AddHisto( CexmcHistoData( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
570 Cexmc_TH1F,
true,
false,
CexmcRT,
"kecl",
571 "Kinetic energy of gamma (lc)", axes ), aRange );
572 AddHisto( CexmcHistoData( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
573 Cexmc_TH1F,
true,
false,
CexmcRT,
"kecr",
574 "Kinetic energy of gamma (rc)", axes ), aRange );
575 AddHisto( CexmcHistoData( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
576 Cexmc_TH1F,
true,
false,
CexmcEDT,
"aecl",
577 "Absorbed energy (lc)", axes ), aRange );
578 AddHisto( CexmcHistoData( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
579 Cexmc_TH1F,
true,
false,
CexmcEDT,
"aecr",
580 "Absorbed energy (rc)", axes ), aRange );
581 AddHisto( CexmcHistoData( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
582 Cexmc_TH1F,
true,
false,
CexmcRT,
"aecl",
583 "Absorbed energy (lc)", axes ), aRange );
584 AddHisto( CexmcHistoData( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
585 Cexmc_TH1F,
true,
false,
CexmcRT,
"aecr",
586 "Absorbed energy (rc)", axes ), aRange );
588 nBinsMinX = CexmcHistoMissEnergyMin;
589 nBinsMaxX = CexmcHistoMissEnergyMax;
590 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) /
591 CexmcHistoMissEnergyResolution );
593 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
594 AddHisto( CexmcHistoData( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
595 Cexmc_TH1F,
true,
false,
CexmcRT,
"mecl",
596 "Missing energy (lc)", axes ), aRange );
597 AddHisto( CexmcHistoData( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
598 Cexmc_TH1F,
true,
false,
CexmcRT,
"mecr",
599 "Missing energy (rc)", axes ), aRange );
601 title =
"Kinetic energy of newborn " + opName +
" (lab)";
603 nBinsMaxX = CexmcHistoEnergyMax;
604 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
606 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
607 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB_ARReal_TPT_Histo,
608 Cexmc_TH1F,
true,
false,
CexmcTPT,
"keop_lab", title, axes ), aRange );
609 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB_ARReal_RT_Histo,
610 Cexmc_TH1F,
true,
false,
CexmcRT,
"keop_lab", title, axes ), aRange );
612 title =
"Angle of newborn " + opName +
" (scm)";
615 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularCResolution );
617 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
618 AddHisto( CexmcHistoData( CexmcAngleOP_SCM_ARReal_TPT_Histo,
619 Cexmc_TH1F,
true,
false,
CexmcTPT,
"aop_scm", title, axes ), aRange );
620 AddHisto( CexmcHistoData( CexmcAngleOP_SCM_ARReal_RT_Histo,
621 Cexmc_TH1F,
true,
false,
CexmcRT,
"aop_scm", title, axes ), aRange );
623 title =
"Reconstruced angle of newborn " + opName +
" (scm)";
624 AddHisto( CexmcHistoData( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
625 Cexmc_TH1F,
true,
false,
CexmcRT,
"recaop_scm", title, axes ), aRange );
627 title =
"Real - reconstruced angle of newborn " + opName +
" (scm)";
628 AddHisto( CexmcHistoData( CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
629 Cexmc_TH1F,
true,
false,
CexmcRT,
"diffaop_scm", title, axes ),
634 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularResolution );
636 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
637 AddHisto( CexmcHistoData( CexmcOpenAngle_ARReal_TPT_Histo,
638 Cexmc_TH1F,
true,
false,
CexmcTPT,
"oa",
639 "Open angle between the gammas", axes ), aRange );
640 AddHisto( CexmcHistoData( CexmcOpenAngle_ARReal_RT_Histo,
641 Cexmc_TH1F,
true,
false,
CexmcRT,
"oa",
642 "Open angle between the gammas", axes ), aRange );
643 AddHisto( CexmcHistoData( CexmcRecOpenAngle_ARReal_RT_Histo,
644 Cexmc_TH1F,
true,
false,
CexmcRT,
"recoa",
645 "Reconstructed open angle between the gammas", axes ), aRange );
649 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularResolution );
651 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
652 AddHisto( CexmcHistoData( CexmcDiffOpenAngle_ARReal_RT_Histo,
653 Cexmc_TH1F,
true,
false,
CexmcRT,
"diffoa",
654 "Real - reconstructed open angle between the gammas", axes ), aRange );
657 G4Tubs * tube( dynamic_cast< G4Tubs * >( lVolume->GetSolid() ) );
663 height = tube->GetZHalfLength() * 2;
664 halfWidth =
radius + CexmcHistoTPSafetyArea;
665 halfHeight = height / 2 + CexmcHistoTPSafetyArea;
667 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
668 nBinsY =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
671 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
672 axes.push_back( CexmcHistoAxisData( nBinsY, -halfWidth, halfWidth ) );
673 axes.push_back( CexmcHistoAxisData(
nBinsZ, -halfHeight, halfHeight ) );
674 AddHisto( CexmcHistoData( CexmcTPInTarget_ARReal_TPT_Histo, Cexmc_TH3F,
675 true,
false,
CexmcTPT,
"tptar",
"Track points (tar)", axes ), aRange );
676 AddHisto( CexmcHistoData( CexmcTPInTarget_ARReal_RT_Histo, Cexmc_TH3F,
677 true,
false,
CexmcRT,
"tptar",
"Track points (tar)", axes ), aRange );
684 CexmcHistosMap::iterator found( histos.find( histoType ) );
685 if ( found == histos.end() || histos[ histoType ].size() <= index )
688 histos[ histoType ][ index ]->Fill( x );
695 CexmcHistosMap::iterator found( histos.find( histoType ) );
696 if ( found == histos.end() || histos[ histoType ].size() <= index )
701 histos[ histoType ][ index ]->Fill( x, y );
708 CexmcHistosMap::iterator found( histos.find( histoType ) );
709 if ( found == histos.end() || histos[ histoType ].size() <= index )
714 TH3 * histo( static_cast< TH3 * >( histos[ histoType ][ index ] ) );
716 histo->Fill( x, y, z );
723 CexmcHistosMap::iterator found( histos.find( histoType ) );
724 if ( found == histos.end() || histos[ histoType ].size() <= index )
729 Double_t curValue( histos[ histoType ][ index ]->GetBinContent(
731 histos[ histoType ][ index ]->SetBinContent( binX, binY,
732 curValue + value /
GeV );
736 void CexmcHistoManager::List(
void )
const
745 TObject * histo( gDirectory->FindObjectAny( value.c_str() ) );
749 G4cout <<
"Histogram '" << value <<
"' was not found" <<
G4endl;
754 histo->Print(
"range" );
758 #ifdef CEXMC_USE_ROOTQT
763 if ( ! areLiveHistogramsEnabled )
765 G4cout <<
"Live histograms option is disabled" <<
G4endl;
769 TObject * histo( gDirectory->FindObjectAny( histoName ) );
773 G4cout <<
"Histogram '" << histoName <<
"' was not found" <<
G4endl;
780 QFont defaultAppFont( QApplication::font() );
781 rootCanvas =
new CexmcHistoWidget;
782 QApplication::setFont( defaultAppFont );
783 rootCanvas->resize( CexmcHistoCanvasWidth, CexmcHistoCanvasHeight );
784 rootCanvas->GetCanvas()->cd();
787 histo->Draw( histoDrawOptions );
789 rootCanvas->GetCanvas()->Update();
796 areLiveHistogramsEnabled = on;
801 G4UIQt * qtSession( dynamic_cast< G4UIQt * >( session ) );
806 if ( ! histoMenuHandle.empty() && ! isHistoMenuInitialized )
808 qtSession->AddMenu( histoMenuHandle, histoMenuLabel );
809 BuildMenuTree( qtSession, histoMenuHandle, gDirectory->GetList() );
810 isHistoMenuInitialized =
true;
815 void CexmcHistoManager::BuildMenuTree( G4UIQt * session,
821 while ( ( obj = (
TObject * )objs() ) )
826 if ( obj->IsFolder() )
828 AddSubmenu( session, menu, name, title );
829 BuildMenuTree( session, name, ( ( TDirectory * )obj )->GetList() );
837 if ( obj->InheritsFrom( TH3::Class() ) &&
838 ! drawOptions3D.empty() )
841 options +=
G4String(
" " ) + drawOptions3D;
844 if ( obj->InheritsFrom( TH2::Class() ) &&
845 ! drawOptions2D.empty() )
848 options +=
G4String(
" " ) + drawOptions2D;
851 if ( obj->InheritsFrom( TH1::Class() ) &&
852 ! drawOptions1D.empty() )
854 options +=
G4String(
" " ) + drawOptions1D;
859 G4String cmd( CexmcMessenger::histoDirName +
"draw " + options );
860 session->AddButton( menu, title.c_str(), cmd );
866 void CexmcHistoManager::AddSubmenu( G4UIQt * session,
871 QMenu * menu(
new QMenu( label.c_str() ) );
872 QMenu * parentMenu( ( QMenu * )session->GetInteractor( parent ) );
874 parentMenu->addMenu( menu );