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 const G4int CexmcHistoCanvasWidth( 800 );
96 const G4int CexmcHistoCanvasHeight( 600 );
97 const G4String CexmcHistoDirectoryHandle(
"histograms" );
98 const G4String CexmcHistoDirectoryTitle(
"Histograms" );
105 CexmcHistoManager * CexmcHistoManager::Instance(
void )
114 void CexmcHistoManager::Destroy(
void )
121 CexmcHistoManager::CexmcHistoManager() : outFile( NULL ),
122 isInitialized( false ), opName(
"" ), nopName(
"" ), opMass( 0. ),
123 nopMass( 0. ), verboseLevel( 0 ),
124 #ifdef CEXMC_USE_ROOTQT
125 rootCanvas( NULL ), areLiveHistogramsEnabled( false ),
126 isHistoMenuInitialized( false ), drawOptions1D(
"" ), drawOptions2D(
"" ),
127 drawOptions3D(
"" ), histoMenuHandle(
"" ), histoMenuLabel(
"" ),
131 for (
int i( 0 ); i < CexmcHistoType_SIZE; ++i )
133 histos.insert( CexmcHistoPair( CexmcHistoType( i ),
134 CexmcHistoVector() ) );
137 messenger =
new CexmcHistoManagerMessenger(
this );
141 CexmcHistoManager::~CexmcHistoManager()
151 #ifdef CEXMC_USE_ROOTQT
158 void CexmcHistoManager::AddHisto(
const CexmcHistoData & data,
167 if ( data.isARHisto )
171 fullName +=
"_arrec";
172 rangeTypeLabel =
"rec";
176 fullName +=
"_arreal";
177 rangeTypeLabel =
"real";
181 switch ( data.triggerType )
185 decorTriggerTypeLabel =
" --tpt--";
186 fullTitle += decorTriggerTypeLabel;
187 triggerTypeLabel =
"tpt";
191 decorTriggerTypeLabel =
" --edt--";
192 fullTitle += decorTriggerTypeLabel;
193 triggerTypeLabel =
"edt";
197 decorTriggerTypeLabel =
" --rt--";
198 fullTitle += decorTriggerTypeLabel;
199 triggerTypeLabel =
"rt";
205 CexmcHistosMap::iterator found( histos.find( data.type ) );
207 if ( found == histos.end() )
210 CexmcHistoVector & histoVector( found->second );
212 if ( data.isARHisto )
216 dirOk = gDirectory->Get( fullName ) != NULL;
219 dirOk = ( gDirectory->mkdir( fullName, fullTitle ) != NULL );
222 gDirectory->cd( fullName );
224 std::ostringstream histoName;
225 std::ostringstream histoTitle;
226 histoName << data.name <<
"_r" << aRange.
index + 1 << rangeTypeLabel <<
227 "_" << triggerTypeLabel;
228 histoTitle << data.title <<
" {range " << aRange.
index + 1 <<
229 rangeTypeLabel <<
" [" << std::fixed <<
230 std::setprecision( 4 ) << aRange.
top <<
", " <<
231 aRange.
bottom <<
")}" << decorTriggerTypeLabel;
232 CreateHisto( histoVector, data.impl, histoName.str(), histoTitle.str(),
236 gDirectory->cd(
".." );
240 CreateHisto( histoVector, data.impl, fullName, fullTitle, data.axes );
245 void CexmcHistoManager::CreateHisto( CexmcHistoVector & histoVector,
247 const G4String & title,
const CexmcHistoAxes & axes )
254 histo =
new TH1F( name, title, axes.at( 0 ).nBins,
255 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax );
258 histo =
new TH2F( name, title, axes.at( 0 ).nBins,
259 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax,
260 axes.at( 1 ).nBins, axes.at( 1 ).nBinsMin,
261 axes.at( 1 ).nBinsMax );
264 histo =
new TH3F( name, title, axes.at( 0 ).nBins,
265 axes.at( 0 ).nBinsMin, axes.at( 0 ).nBinsMax,
266 axes.at( 1 ).nBins, axes.at( 1 ).nBinsMin,
267 axes.at( 1 ).nBinsMax, axes.at( 2 ).nBins,
268 axes.at( 2 ).nBinsMin, axes.at( 2 ).nBinsMax );
275 histoVector.push_back( histo );
288 if ( ! physicsManager )
292 GetProductionModel() );
294 if ( ! productionModel )
298 productionModel->GetOutputParticle() );
300 productionModel->GetNucleusOutputParticle() );
302 if ( ! outputParticle || ! nucleusOutputParticle )
305 opName = outputParticle->GetParticleName();
306 nopName = nucleusOutputParticle->GetParticleName();
307 opMass = outputParticle->GetPDGMass();
308 nopMass = nucleusOutputParticle->GetPDGMass();
319 if ( runManager->ProjectIsSaved() )
321 G4String projectsDir( runManager->GetProjectsDir() );
322 G4String resultsFile( projectsDir +
"/" + runManager->GetProjectId() +
324 outFile =
new TFile( resultsFile,
"recreate" );
328 outFile =
new TDirectoryFile( CexmcHistoDirectoryHandle,
329 CexmcHistoDirectoryTitle );
330 gDirectory->cd( CexmcHistoDirectoryHandle );
336 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
337 runManager->GetUserDetectorConstruction() ) );
346 nBinsMinX = CexmcHistoBeamMomentumMin;
347 nBinsMaxX = CexmcHistoBeamMomentumMax;
348 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) /
349 CexmcHistoBeamMomentumResolution );
350 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
351 AddHisto( CexmcHistoData( CexmcMomentumBP_TPT_Histo, Cexmc_TH1F,
false,
352 false,
CexmcTPT,
"mombp",
"Beam momentum at the monitor", axes ) );
353 AddHisto( CexmcHistoData( CexmcMomentumBP_RT_Histo, Cexmc_TH1F,
false,
354 false,
CexmcRT,
"mombp",
"Beam momentum at the monitor", axes ) );
355 if ( verboseLevel > 0 )
357 AddHisto( CexmcHistoData( CexmcMomentumIP_TPT_Histo, Cexmc_TH1F,
false,
358 false,
CexmcTPT,
"momip",
"Momentum of the incident particle",
362 G4Box * box( dynamic_cast< G4Box * >( lVolume->GetSolid() ) );
368 G4double height( box->GetYHalfLength() * 2 );
370 G4double halfHeight( height / 2 + CexmcHistoTPSafetyArea );
372 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
373 nBinsY =
Int_t( halfHeight * 2 / CexmcHistoTPResolution );
375 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
376 axes.push_back( CexmcHistoAxisData( nBinsY, -halfHeight, halfHeight ) );
377 AddHisto( CexmcHistoData( CexmcTPInMonitor_TPT_Histo, Cexmc_TH2F,
false,
378 false,
CexmcTPT,
"tpmon",
"Track points (mon)", axes ) );
381 G4Tubs * tube( dynamic_cast< G4Tubs * >( lVolume->GetSolid() ) );
386 G4double radius( tube->GetOuterRadius() );
387 height = tube->GetZHalfLength() * 2;
388 halfWidth = radius + CexmcHistoTPSafetyArea;
389 halfHeight = height / 2 + CexmcHistoTPSafetyArea;
391 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
392 nBinsY =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
393 Int_t nBinsZ(
Int_t( halfHeight * 2 / CexmcHistoTPResolution ) );
395 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
396 axes.push_back( CexmcHistoAxisData( nBinsY, -halfWidth, halfWidth ) );
397 axes.push_back( CexmcHistoAxisData( nBinsZ, -halfHeight, halfHeight ) );
398 AddHisto( CexmcHistoData( CexmcTPInTarget_TPT_Histo, Cexmc_TH3F,
false,
399 false,
CexmcTPT,
"tptar",
"Track points (tar)", axes ) );
400 AddHisto( CexmcHistoData( CexmcTPInTarget_RT_Histo, Cexmc_TH3F,
false,
401 false,
CexmcRT,
"tptar",
"Track points (tar)", axes ) );
403 title =
"Reconstructed masses (" + nopName +
" vs. " + opName +
")";
404 nBinsMinX = opMass / 2;
405 nBinsMaxX = opMass + opMass / 2;
406 nBinsMinY = nopMass / 2;
407 nBinsMaxY = nopMass + nopMass / 2;
408 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
409 nBinsY =
Int_t( ( nBinsMaxY - nBinsMinY ) / CexmcHistoMassResolution );
411 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
412 axes.push_back( CexmcHistoAxisData( nBinsY, nBinsMinY, nBinsMaxY ) );
413 AddHisto( CexmcHistoData( CexmcRecMasses_EDT_Histo, Cexmc_TH2F,
false,
414 false,
CexmcEDT,
"recmasses", title, axes ) );
415 AddHisto( CexmcHistoData( CexmcRecMasses_RT_Histo, Cexmc_TH2F,
false,
416 false,
CexmcRT,
"recmasses", title, axes ) );
419 nBinsMaxX = CexmcHistoEnergyMax;
421 nBinsMaxY = CexmcHistoEnergyMax;
422 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
423 nBinsY =
Int_t( ( nBinsMaxY - nBinsMinY ) / CexmcHistoEnergyResolution );
425 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
426 axes.push_back( CexmcHistoAxisData( nBinsY, nBinsMinY, nBinsMaxY ) );
427 AddHisto( CexmcHistoData( CexmcAbsorbedEnergy_EDT_Histo, Cexmc_TH2F,
false,
428 false,
CexmcEDT,
"ae",
"Absorbed energy (rc vs. lc)", axes ) );
429 AddHisto( CexmcHistoData( CexmcAbsorbedEnergy_RT_Histo, Cexmc_TH2F,
false,
430 false,
CexmcRT,
"ae",
"Absorbed energy (rc vs. lc)", axes ) );
432 SetupARHistos( runManager->GetPhysicsManager()->GetProductionModel()->
433 GetAngularRanges() );
441 TIter objs( gDirectory->GetList() );
442 TObject * obj( NULL );
444 while ( ( obj = ( TObject * )objs() ) )
446 TString
name( obj->GetName() );
448 if ( obj->IsFolder() && ( name.Contains( TString(
"_arreal_" ) ) ||
449 name.Contains( TString(
"_arrec_" ) ) ) )
451 gDirectory->cd( name );
452 gDirectory->DeleteAll();
453 gDirectory->cd(
".." );
457 for ( CexmcHistosMap::iterator k( histos.begin() ); k != histos.end();
460 if ( k->second.empty() )
463 if ( k->first >= CexmcHistoType_ARReal_START &&
464 k->first <= CexmcHistoType_ARReal_END )
470 for ( CexmcAngularRangeList::const_iterator k( aRanges.begin() );
471 k != aRanges.end(); ++k )
486 title =
"Reconstructed mass of " + opName;
487 nBinsMinX = opMass / 2;
488 nBinsMaxX = opMass + opMass / 2;
489 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
490 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
491 AddHisto( CexmcHistoData( CexmcRecMassOP_ARReal_RT_Histo, Cexmc_TH1F,
true,
492 false,
CexmcRT,
"recmassop", title, axes ), aRange );
494 title =
"Reconstructed mass of " + nopName;
495 nBinsMinX = nopMass / 2;
496 nBinsMaxX = nopMass + nopMass / 2;
497 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoMassResolution );
499 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
500 AddHisto( CexmcHistoData( CexmcRecMassNOP_ARReal_RT_Histo, Cexmc_TH1F,
true,
501 false,
CexmcRT,
"recmassnop", title, axes ), aRange );
504 const CexmcSetup * setup( static_cast< const CexmcSetup * >(
505 runManager->GetUserDetectorConstruction() ) );
512 G4Box * box( dynamic_cast< G4Box * >( lVolume->GetSolid() ) );
518 G4double height( box->GetYHalfLength() * 2 );
520 G4double halfHeight( height / 2 + CexmcHistoTPSafetyArea );
522 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
523 Int_t nBinsY(
Int_t( halfHeight * 2 / CexmcHistoTPResolution ) );
525 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
526 axes.push_back( CexmcHistoAxisData( nBinsY, -halfHeight, halfHeight ) );
531 AddHisto( CexmcHistoData( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
532 Cexmc_TH2F,
true,
false,
CexmcEDT,
"opdpcl",
533 "Gamma position on the surface (lc)", axes ), aRange );
534 AddHisto( CexmcHistoData( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
535 Cexmc_TH2F,
true,
false,
CexmcEDT,
"opdpcr",
536 "Gamma position on the surface (rc)", axes ), aRange );
537 AddHisto( CexmcHistoData( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
538 Cexmc_TH2F,
true,
false,
CexmcRT,
"opdpcl",
539 "Gamma position on the surface (lc)", axes ), aRange );
540 AddHisto( CexmcHistoData( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
541 Cexmc_TH2F,
true,
false,
CexmcRT,
"opdpcr",
542 "Gamma position on the surface (rc)", axes ), aRange );
543 AddHisto( CexmcHistoData( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
544 Cexmc_TH2F,
true,
false,
CexmcEDT,
"recopdpcl",
545 "Reconstructed gamma position on the surface (lc)", axes ), aRange );
546 AddHisto( CexmcHistoData( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
547 Cexmc_TH2F,
true,
false,
CexmcEDT,
"recopdpcr",
548 "Reconstructed gamma position on the surface (rc)", axes ), aRange );
549 AddHisto( CexmcHistoData( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
550 Cexmc_TH2F,
true,
false,
CexmcRT,
"recopdpcl",
551 "Reconstructed gamma position on the surface (lc)", axes ), aRange );
552 AddHisto( CexmcHistoData( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
553 Cexmc_TH2F,
true,
false,
CexmcRT,
"recopdpcr",
554 "Reconstructed gamma position on the surface (rc)", axes ), aRange );
557 nBinsMaxX = CexmcHistoEnergyMax;
558 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
560 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
561 AddHisto( CexmcHistoData( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
562 Cexmc_TH1F,
true,
false,
CexmcTPT,
"kecl",
563 "Kinetic energy of gamma (lc)", axes ), aRange );
564 AddHisto( CexmcHistoData( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
565 Cexmc_TH1F,
true,
false,
CexmcTPT,
"kecr",
566 "Kinetic energy of gamma (rc)", axes ), aRange );
567 AddHisto( CexmcHistoData( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
568 Cexmc_TH1F,
true,
false,
CexmcRT,
"kecl",
569 "Kinetic energy of gamma (lc)", axes ), aRange );
570 AddHisto( CexmcHistoData( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
571 Cexmc_TH1F,
true,
false,
CexmcRT,
"kecr",
572 "Kinetic energy of gamma (rc)", axes ), aRange );
573 AddHisto( CexmcHistoData( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
574 Cexmc_TH1F,
true,
false,
CexmcEDT,
"aecl",
575 "Absorbed energy (lc)", axes ), aRange );
576 AddHisto( CexmcHistoData( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
577 Cexmc_TH1F,
true,
false,
CexmcEDT,
"aecr",
578 "Absorbed energy (rc)", axes ), aRange );
579 AddHisto( CexmcHistoData( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
580 Cexmc_TH1F,
true,
false,
CexmcRT,
"aecl",
581 "Absorbed energy (lc)", axes ), aRange );
582 AddHisto( CexmcHistoData( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
583 Cexmc_TH1F,
true,
false,
CexmcRT,
"aecr",
584 "Absorbed energy (rc)", axes ), aRange );
586 nBinsMinX = CexmcHistoMissEnergyMin;
587 nBinsMaxX = CexmcHistoMissEnergyMax;
588 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) /
589 CexmcHistoMissEnergyResolution );
591 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
592 AddHisto( CexmcHistoData( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
593 Cexmc_TH1F,
true,
false,
CexmcRT,
"mecl",
594 "Missing energy (lc)", axes ), aRange );
595 AddHisto( CexmcHistoData( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
596 Cexmc_TH1F,
true,
false,
CexmcRT,
"mecr",
597 "Missing energy (rc)", axes ), aRange );
599 title =
"Kinetic energy of newborn " + opName +
" (lab)";
601 nBinsMaxX = CexmcHistoEnergyMax;
602 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoEnergyResolution );
604 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
605 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB_ARReal_TPT_Histo,
606 Cexmc_TH1F,
true,
false,
CexmcTPT,
"keop_lab", title, axes ), aRange );
607 AddHisto( CexmcHistoData( CexmcKinEnOP_LAB_ARReal_RT_Histo,
608 Cexmc_TH1F,
true,
false,
CexmcRT,
"keop_lab", title, axes ), aRange );
610 title =
"Angle of newborn " + opName +
" (scm)";
613 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularCResolution );
615 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
616 AddHisto( CexmcHistoData( CexmcAngleOP_SCM_ARReal_TPT_Histo,
617 Cexmc_TH1F,
true,
false,
CexmcTPT,
"aop_scm", title, axes ), aRange );
618 AddHisto( CexmcHistoData( CexmcAngleOP_SCM_ARReal_RT_Histo,
619 Cexmc_TH1F,
true,
false,
CexmcRT,
"aop_scm", title, axes ), aRange );
621 title =
"Reconstruced angle of newborn " + opName +
" (scm)";
622 AddHisto( CexmcHistoData( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
623 Cexmc_TH1F,
true,
false,
CexmcRT,
"recaop_scm", title, axes ), aRange );
625 title =
"Real - reconstruced angle of newborn " + opName +
" (scm)";
626 AddHisto( CexmcHistoData( CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
627 Cexmc_TH1F,
true,
false,
CexmcRT,
"diffaop_scm", title, axes ),
632 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularResolution );
634 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
635 AddHisto( CexmcHistoData( CexmcOpenAngle_ARReal_TPT_Histo,
636 Cexmc_TH1F,
true,
false,
CexmcTPT,
"oa",
637 "Open angle between the gammas", axes ), aRange );
638 AddHisto( CexmcHistoData( CexmcOpenAngle_ARReal_RT_Histo,
639 Cexmc_TH1F,
true,
false,
CexmcRT,
"oa",
640 "Open angle between the gammas", axes ), aRange );
641 AddHisto( CexmcHistoData( CexmcRecOpenAngle_ARReal_RT_Histo,
642 Cexmc_TH1F,
true,
false,
CexmcRT,
"recoa",
643 "Reconstructed open angle between the gammas", axes ), aRange );
647 nBinsX =
Int_t( ( nBinsMaxX - nBinsMinX ) / CexmcHistoAngularResolution );
649 axes.push_back( CexmcHistoAxisData( nBinsX, nBinsMinX, nBinsMaxX ) );
650 AddHisto( CexmcHistoData( CexmcDiffOpenAngle_ARReal_RT_Histo,
651 Cexmc_TH1F,
true,
false,
CexmcRT,
"diffoa",
652 "Real - reconstructed open angle between the gammas", axes ), aRange );
655 G4Tubs * tube( dynamic_cast< G4Tubs * >( lVolume->GetSolid() ) );
660 G4double radius( tube->GetOuterRadius() );
661 height = tube->GetZHalfLength() * 2;
662 halfWidth = radius + CexmcHistoTPSafetyArea;
663 halfHeight = height / 2 + CexmcHistoTPSafetyArea;
665 nBinsX =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
666 nBinsY =
Int_t( halfWidth * 2 / CexmcHistoTPResolution );
667 Int_t nBinsZ(
Int_t( halfHeight * 2 / CexmcHistoTPResolution ) );
669 axes.push_back( CexmcHistoAxisData( nBinsX, -halfWidth, halfWidth ) );
670 axes.push_back( CexmcHistoAxisData( nBinsY, -halfWidth, halfWidth ) );
671 axes.push_back( CexmcHistoAxisData( nBinsZ, -halfHeight, halfHeight ) );
672 AddHisto( CexmcHistoData( CexmcTPInTarget_ARReal_TPT_Histo, Cexmc_TH3F,
673 true,
false,
CexmcTPT,
"tptar",
"Track points (tar)", axes ), aRange );
674 AddHisto( CexmcHistoData( CexmcTPInTarget_ARReal_RT_Histo, Cexmc_TH3F,
675 true,
false,
CexmcRT,
"tptar",
"Track points (tar)", axes ), aRange );
682 CexmcHistosMap::iterator found( histos.find( histoType ) );
683 if ( found == histos.end() || histos[ histoType ].size() <= index )
686 histos[ histoType ][ index ]->Fill( x );
693 CexmcHistosMap::iterator found( histos.find( histoType ) );
694 if ( found == histos.end() || histos[ histoType ].size() <= index )
699 histos[ histoType ][ index ]->Fill( x, y );
706 CexmcHistosMap::iterator found( histos.find( histoType ) );
707 if ( found == histos.end() || histos[ histoType ].size() <= index )
712 TH3 * histo( static_cast< TH3 * >( histos[ histoType ][ index ] ) );
714 histo->Fill( x, y, z );
721 CexmcHistosMap::iterator found( histos.find( histoType ) );
722 if ( found == histos.end() || histos[ histoType ].size() <= index )
727 Double_t curValue( histos[ histoType ][ index ]->GetBinContent(
729 histos[ histoType ][ index ]->SetBinContent( binX, binY,
730 curValue + value /
GeV );
734 void CexmcHistoManager::List(
void )
const
743 TObject * histo( gDirectory->FindObjectAny( value.c_str() ) );
747 G4cout <<
"Histogram '" << value <<
"' was not found" <<
G4endl;
752 histo->Print(
"range" );
756 #ifdef CEXMC_USE_ROOTQT
758 void CexmcHistoManager::Draw(
const G4String & histoName,
761 if ( ! areLiveHistogramsEnabled )
763 G4cout <<
"Live histograms option is disabled" <<
G4endl;
767 TObject * histo( gDirectory->FindObjectAny( histoName ) );
771 G4cout <<
"Histogram '" << histoName <<
"' was not found" <<
G4endl;
778 QFont defaultAppFont( QApplication::font() );
779 rootCanvas =
new CexmcHistoWidget;
780 QApplication::setFont( defaultAppFont );
781 rootCanvas->resize( CexmcHistoCanvasWidth, CexmcHistoCanvasHeight );
782 rootCanvas->GetCanvas()->cd();
785 histo->Draw( histoDrawOptions );
787 rootCanvas->GetCanvas()->Update();
794 areLiveHistogramsEnabled = on;
799 G4UIQt * qtSession( dynamic_cast< G4UIQt * >( session ) );
804 if ( ! histoMenuHandle.empty() && ! isHistoMenuInitialized )
806 qtSession->AddMenu( histoMenuHandle, histoMenuLabel );
807 BuildMenuTree( qtSession, histoMenuHandle, gDirectory->GetList() );
808 isHistoMenuInitialized =
true;
813 void CexmcHistoManager::BuildMenuTree( G4UIQt * session,
817 TObject * obj( NULL );
819 while ( ( obj = ( TObject * )objs() ) )
824 if ( obj->IsFolder() )
826 AddSubmenu( session, menu, name, title );
827 BuildMenuTree( session, name, ( ( TDirectory * )obj )->GetList() );
835 if ( obj->InheritsFrom( TH3::Class() ) &&
836 ! drawOptions3D.empty() )
839 options +=
G4String(
" " ) + drawOptions3D;
842 if ( obj->InheritsFrom( TH2::Class() ) &&
843 ! drawOptions2D.empty() )
846 options +=
G4String(
" " ) + drawOptions2D;
849 if ( obj->InheritsFrom( TH1::Class() ) &&
850 ! drawOptions1D.empty() )
852 options +=
G4String(
" " ) + drawOptions1D;
857 G4String cmd( CexmcMessenger::histoDirName +
"draw " + options );
858 session->AddButton( menu, title.c_str(), cmd );
864 void CexmcHistoManager::AddSubmenu( G4UIQt * session,
869 QMenu * menu(
new QMenu( label.c_str() ) );
870 QMenu * parentMenu( ( QMenu * )session->GetInteractor( parent ) );
872 parentMenu->addMenu( menu );
G4GLOB_DLL std::ostream G4cout
void Print(const std::vector< T > &data)
static G4UIterminal * session
static G4RunManager * GetRunManager()
const G4double x[NPOINTSGL]
std::vector< CexmcAngularRange > CexmcAngularRangeList
static MCTruthManager * instance
G4bool isInitialized()
Check if the generator is initialized.
void Add(G4int Elements, T *To, T *A1, T *A2=NULL)
Add two arrays together.