Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc (Version 9.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * ===========================================     27  * ============================================================================
 28  *                                                 28  *
 29  *       Filename:  CexmcEventAction.cc            29  *       Filename:  CexmcEventAction.cc
 30  *                                                 30  *
 31  *    Description:  event action                   31  *    Description:  event action
 32  *                                                 32  *
 33  *        Version:  1.0                            33  *        Version:  1.0
 34  *        Created:  27.10.2009 22:48:08            34  *        Created:  27.10.2009 22:48:08
 35  *       Revision:  none                           35  *       Revision:  none
 36  *       Compiler:  gcc                            36  *       Compiler:  gcc
 37  *                                                 37  *
 38  *         Author:  Alexey Radkov (),              38  *         Author:  Alexey Radkov (), 
 39  *        Company:  PNPI                           39  *        Company:  PNPI
 40  *                                                 40  *
 41  * ===========================================     41  * ============================================================================
 42  */                                                42  */
 43                                                    43 
 44 #include <cmath>                                   44 #include <cmath>
 45 #ifdef CEXMC_USE_PERSISTENCY                       45 #ifdef CEXMC_USE_PERSISTENCY
 46 #include <boost/archive/binary_oarchive.hpp>       46 #include <boost/archive/binary_oarchive.hpp>
 47 #endif                                             47 #endif
 48 #include <G4DigiManager.hh>                        48 #include <G4DigiManager.hh>
 49 #include <G4Event.hh>                              49 #include <G4Event.hh>
 50 #include <G4Circle.hh>                             50 #include <G4Circle.hh>
 51 #include <G4VisAttributes.hh>                      51 #include <G4VisAttributes.hh>
 52 #include <G4VisManager.hh>                         52 #include <G4VisManager.hh>
 53 #include <G4VTrajectory.hh>                        53 #include <G4VTrajectory.hh>
 54 #include <G4TrajectoryContainer.hh>                54 #include <G4TrajectoryContainer.hh>
 55 #include <G4Colour.hh>                             55 #include <G4Colour.hh>
 56 #include <G4SystemOfUnits.hh>                  << 
 57 #include "CexmcEventAction.hh"                     56 #include "CexmcEventAction.hh"
 58 #include "CexmcEventActionMessenger.hh"            57 #include "CexmcEventActionMessenger.hh"
 59 #include "CexmcEventInfo.hh"                       58 #include "CexmcEventInfo.hh"
 60 #include "CexmcEventSObject.hh"                    59 #include "CexmcEventSObject.hh"
 61 #include "CexmcEventFastSObject.hh"                60 #include "CexmcEventFastSObject.hh"
 62 #include "CexmcTrackingAction.hh"                  61 #include "CexmcTrackingAction.hh"
 63 #include "CexmcChargeExchangeReconstructor.hh"     62 #include "CexmcChargeExchangeReconstructor.hh"
 64 #include "CexmcRunManager.hh"                      63 #include "CexmcRunManager.hh"
 65 #include "CexmcHistoManager.hh"                    64 #include "CexmcHistoManager.hh"
 66 #include "CexmcRun.hh"                             65 #include "CexmcRun.hh"
 67 #include "CexmcPhysicsManager.hh"                  66 #include "CexmcPhysicsManager.hh"
 68 #include "CexmcProductionModel.hh"                 67 #include "CexmcProductionModel.hh"
 69 #include "CexmcProductionModelData.hh"             68 #include "CexmcProductionModelData.hh"
 70 #include "CexmcEnergyDepositDigitizer.hh"          69 #include "CexmcEnergyDepositDigitizer.hh"
 71 #include "CexmcEnergyDepositStore.hh"              70 #include "CexmcEnergyDepositStore.hh"
 72 #include "CexmcTrackPointsDigitizer.hh"            71 #include "CexmcTrackPointsDigitizer.hh"
 73 #include "CexmcTrackPointsStore.hh"                72 #include "CexmcTrackPointsStore.hh"
 74 #include "CexmcTrackPointInfo.hh"                  73 #include "CexmcTrackPointInfo.hh"
 75 #include "CexmcException.hh"                       74 #include "CexmcException.hh"
 76 #include "CexmcCommon.hh"                          75 #include "CexmcCommon.hh"
 77                                                    76 
 78                                                    77 
 79 namespace                                          78 namespace
 80 {                                                  79 {
 81     G4double  CexmcSmallCircleScreenSize( 5.0      80     G4double  CexmcSmallCircleScreenSize( 5.0 );
 82     G4double  CexmcBigCircleScreenSize( 10.0 )     81     G4double  CexmcBigCircleScreenSize( 10.0 );
 83     G4Colour  CexmcTrackPointsMarkerColour( 0.     82     G4Colour  CexmcTrackPointsMarkerColour( 0.0, 1.0, 0.4 );
 84     G4Colour  CexmcRecTrackPointsMarkerColour(     83     G4Colour  CexmcRecTrackPointsMarkerColour( 1.0, 0.4, 0.0 );
 85                                                    84 
 86 #ifdef CEXMC_USE_ROOT                          <<  85 
 87     inline G4double  CexmcGetKinEnergy( G4doub     86     inline G4double  CexmcGetKinEnergy( G4double  momentumAmp, G4double  mass )
 88     {                                              87     {
 89         return std::sqrt( momentumAmp * moment     88         return std::sqrt( momentumAmp * momentumAmp + mass * mass ) - mass;
 90     }                                              89     }
 91 #endif                                         << 
 92 }                                                  90 }
 93                                                    91 
 94                                                    92 
 95 CexmcEventAction::CexmcEventAction( CexmcPhysi <<  93 CexmcEventAction::CexmcEventAction( CexmcPhysicsManager *  physicsManager,
 96                                     G4int  ver <<  94                                     G4int  verbose ) :
 97     physicsManager( physicsManager_ ), reconst <<  95     physicsManager( physicsManager ), reconstructor( NULL ), opKinEnergy( 0. ),
 98 #ifdef CEXMC_USE_ROOT                          <<  96     verbose( verbose ), verboseDraw( 4 ), messenger( NULL )
 99     opKinEnergy( 0. ),                         << 
100 #endif                                         << 
101     verbose( verbose_ ), verboseDraw( 4 ), mes << 
102 {                                                  97 {
103     G4DigiManager *  digiManager( G4DigiManage     98     G4DigiManager *  digiManager( G4DigiManager::GetDMpointer() );
104     digiManager->AddNewModule( new CexmcEnergy     99     digiManager->AddNewModule( new CexmcEnergyDepositDigitizer(
105                                                   100                                                     CexmcEDDigitizerName ) );
106     digiManager->AddNewModule( new CexmcTrackP    101     digiManager->AddNewModule( new CexmcTrackPointsDigitizer(
107                                                   102                                                     CexmcTPDigitizerName ) );
108     reconstructor = new CexmcChargeExchangeRec    103     reconstructor = new CexmcChargeExchangeReconstructor(
109                                         physic    104                                         physicsManager->GetProductionModel() );
110     messenger = new CexmcEventActionMessenger(    105     messenger = new CexmcEventActionMessenger( this );
111 }                                                 106 }
112                                                   107 
113                                                   108 
114 CexmcEventAction::~CexmcEventAction()             109 CexmcEventAction::~CexmcEventAction()
115 {                                                 110 {
116     delete reconstructor;                         111     delete reconstructor;
117     delete messenger;                             112     delete messenger;
118 }                                                 113 }
119                                                   114 
120                                                   115 
121 void  CexmcEventAction::BeamParticleChangeHook    116 void  CexmcEventAction::BeamParticleChangeHook( void )
122 {                                                 117 {
123     reconstructor->SetupBeamParticle();           118     reconstructor->SetupBeamParticle();
124 }                                                 119 }
125                                                   120 
126                                                   121 
127 void  CexmcEventAction::BeginOfEventAction( co    122 void  CexmcEventAction::BeginOfEventAction( const G4Event * )
128 {                                                 123 {
129     G4RunManager *         runManager( G4RunMa    124     G4RunManager *         runManager( G4RunManager::GetRunManager() );
130     CexmcTrackingAction *  trackingAction         125     CexmcTrackingAction *  trackingAction
131             ( static_cast< CexmcTrackingAction    126             ( static_cast< CexmcTrackingAction * >(
132                         const_cast< G4UserTrac    127                         const_cast< G4UserTrackingAction * >(
133                                     runManager    128                                     runManager->GetUserTrackingAction() ) ) );
134     trackingAction->BeginOfEventAction();         129     trackingAction->BeginOfEventAction();
135                                                   130 
136     physicsManager->ResetNumberOfTriggeredStud    131     physicsManager->ResetNumberOfTriggeredStudiedInteractions();
137 }                                                 132 }
138                                                   133 
139                                                   134 
140 CexmcEnergyDepositStore *  CexmcEventAction::M    135 CexmcEnergyDepositStore *  CexmcEventAction::MakeEnergyDepositStore(
141                                 const CexmcEne    136                                 const CexmcEnergyDepositDigitizer *  digitizer )
142 {                                                 137 {
143     G4double  monitorED( digitizer->GetMonitor    138     G4double  monitorED( digitizer->GetMonitorED() );
144     G4double  vetoCounterEDLeft( digitizer->Ge    139     G4double  vetoCounterEDLeft( digitizer->GetVetoCounterEDLeft() );
145     G4double  vetoCounterEDRight( digitizer->G    140     G4double  vetoCounterEDRight( digitizer->GetVetoCounterEDRight() );
146     G4double  calorimeterEDLeft( digitizer->Ge    141     G4double  calorimeterEDLeft( digitizer->GetCalorimeterEDLeft() );
147     G4double  calorimeterEDRight( digitizer->G    142     G4double  calorimeterEDRight( digitizer->GetCalorimeterEDRight() );
148     G4int     calorimeterEDLeftMaxX( digitizer    143     G4int     calorimeterEDLeftMaxX( digitizer->GetCalorimeterEDLeftMaxX() );
149     G4int     calorimeterEDLeftMaxY( digitizer    144     G4int     calorimeterEDLeftMaxY( digitizer->GetCalorimeterEDLeftMaxY() );
150     G4int     calorimeterEDRightMaxX( digitize    145     G4int     calorimeterEDRightMaxX( digitizer->GetCalorimeterEDRightMaxX() );
151     G4int     calorimeterEDRightMaxY( digitize    146     G4int     calorimeterEDRightMaxY( digitizer->GetCalorimeterEDRightMaxY() );
152                                                   147 
153     const CexmcEnergyDepositCalorimeterCollect    148     const CexmcEnergyDepositCalorimeterCollection &
154               calorimeterEDLeftCollection(        149               calorimeterEDLeftCollection(
155                             digitizer->GetCalo    150                             digitizer->GetCalorimeterEDLeftCollection() );
156     const CexmcEnergyDepositCalorimeterCollect    151     const CexmcEnergyDepositCalorimeterCollection &
157               calorimeterEDRightCollection(       152               calorimeterEDRightCollection(
158                             digitizer->GetCalo    153                             digitizer->GetCalorimeterEDRightCollection() );
159                                                   154 
160     /* ATTENTION: return object in heap - must    155     /* ATTENTION: return object in heap - must be freed by caller! */
161     return new CexmcEnergyDepositStore( monito    156     return new CexmcEnergyDepositStore( monitorED, vetoCounterEDLeft,
162                     vetoCounterEDRight, calori    157                     vetoCounterEDRight, calorimeterEDLeft, calorimeterEDRight,
163                     calorimeterEDLeftMaxX, cal    158                     calorimeterEDLeftMaxX, calorimeterEDLeftMaxY,
164                     calorimeterEDRightMaxX, ca    159                     calorimeterEDRightMaxX, calorimeterEDRightMaxY,
165                     calorimeterEDLeftCollectio    160                     calorimeterEDLeftCollection, calorimeterEDRightCollection );
166 }                                                 161 }
167                                                   162 
168                                                   163 
169 CexmcTrackPointsStore *  CexmcEventAction::Mak    164 CexmcTrackPointsStore *  CexmcEventAction::MakeTrackPointsStore(
170                                 const CexmcTra    165                                 const CexmcTrackPointsDigitizer *  digitizer )
171 {                                                 166 {
172     const CexmcTrackPointInfo &                   167     const CexmcTrackPointInfo &
173                 monitorTP( digitizer->GetMonit    168                 monitorTP( digitizer->GetMonitorTP() );
174     const CexmcTrackPointInfo &                   169     const CexmcTrackPointInfo &
175                 targetTPBeamParticle(             170                 targetTPBeamParticle(
176                     digitizer->GetTargetTPBeam    171                     digitizer->GetTargetTPBeamParticle() );
177     const CexmcTrackPointInfo &                   172     const CexmcTrackPointInfo &
178                 targetTPOutputParticle(           173                 targetTPOutputParticle(
179                     digitizer->GetTargetTPOutp    174                     digitizer->GetTargetTPOutputParticle() );
180     const CexmcTrackPointInfo &                   175     const CexmcTrackPointInfo &
181                 targetTPNucleusParticle(          176                 targetTPNucleusParticle(
182                     digitizer->GetTargetTPNucl    177                     digitizer->GetTargetTPNucleusParticle() );
183     const CexmcTrackPointInfo &                   178     const CexmcTrackPointInfo &
184                 targetTPOutputParticleDecayPro    179                 targetTPOutputParticleDecayProductParticle1(
185                     digitizer->                   180                     digitizer->
186                     GetTargetTPOutputParticleD    181                     GetTargetTPOutputParticleDecayProductParticle( 0 ) );
187     const CexmcTrackPointInfo &                   182     const CexmcTrackPointInfo &
188                 targetTPOutputParticleDecayPro    183                 targetTPOutputParticleDecayProductParticle2(
189                     digitizer->                   184                     digitizer->
190                     GetTargetTPOutputParticleD    185                     GetTargetTPOutputParticleDecayProductParticle( 1 ) );
191     const CexmcTrackPointInfo &                   186     const CexmcTrackPointInfo &
192                 vetoCounterTPLeft(                187                 vetoCounterTPLeft(
193                     digitizer->GetVetoCounterT    188                     digitizer->GetVetoCounterTPLeft() );
194     const CexmcTrackPointInfo &                   189     const CexmcTrackPointInfo &
195                 vetoCounterTPRight(               190                 vetoCounterTPRight(
196                     digitizer->GetVetoCounterT    191                     digitizer->GetVetoCounterTPRight() );
197     const CexmcTrackPointInfo &                   192     const CexmcTrackPointInfo &
198                 calorimeterTPLeft(                193                 calorimeterTPLeft(
199                     digitizer->GetCalorimeterT    194                     digitizer->GetCalorimeterTPLeft() );
200     const CexmcTrackPointInfo &                   195     const CexmcTrackPointInfo &
201                 calorimeterTPRight(               196                 calorimeterTPRight(
202                     digitizer->GetCalorimeterT    197                     digitizer->GetCalorimeterTPRight() );
203                                                   198 
204     /* ATTENTION: return object in heap - must    199     /* ATTENTION: return object in heap - must be freed by caller! */
205     return new CexmcTrackPointsStore( monitorT    200     return new CexmcTrackPointsStore( monitorTP, targetTPBeamParticle,
206                   targetTPOutputParticle, targ    201                   targetTPOutputParticle, targetTPNucleusParticle,
207                   targetTPOutputParticleDecayP    202                   targetTPOutputParticleDecayProductParticle1,
208                   targetTPOutputParticleDecayP    203                   targetTPOutputParticleDecayProductParticle2,
209                   vetoCounterTPLeft, vetoCount    204                   vetoCounterTPLeft, vetoCounterTPRight,
210                   calorimeterTPLeft, calorimet    205                   calorimeterTPLeft, calorimeterTPRight );
211 }                                                 206 }
212                                                   207 
213                                                   208 
214 void  CexmcEventAction::PrintEnergyDeposit(       209 void  CexmcEventAction::PrintEnergyDeposit(
215                                     const Cexm    210                                     const CexmcEnergyDepositStore *  edStore )
216 {                                                 211 {
217     G4cout << " --- Energy Deposit" << G4endl;    212     G4cout << " --- Energy Deposit" << G4endl;
218     G4cout << "       monitor : " <<              213     G4cout << "       monitor : " <<
219             G4BestUnit( edStore->monitorED, "E    214             G4BestUnit( edStore->monitorED, "Energy" ) << G4endl;
220     G4cout << "        vc (l) : " <<              215     G4cout << "        vc (l) : " <<
221             G4BestUnit( edStore->vetoCounterED    216             G4BestUnit( edStore->vetoCounterEDLeft, "Energy" ) << G4endl;
222     G4cout << "        vc (r) : " <<              217     G4cout << "        vc (r) : " <<
223             G4BestUnit( edStore->vetoCounterED    218             G4BestUnit( edStore->vetoCounterEDRight, "Energy" ) << G4endl;
224     G4cout << "       cal (l) : " <<              219     G4cout << "       cal (l) : " <<
225             G4BestUnit( edStore->calorimeterED    220             G4BestUnit( edStore->calorimeterEDLeft, "Energy" );
226     G4cout << edStore->calorimeterEDLeftCollec    221     G4cout << edStore->calorimeterEDLeftCollection;
227     G4cout << "       cal (r) : " <<              222     G4cout << "       cal (r) : " <<
228             G4BestUnit( edStore->calorimeterED    223             G4BestUnit( edStore->calorimeterEDRight, "Energy" );
229     G4cout << edStore->calorimeterEDRightColle    224     G4cout << edStore->calorimeterEDRightCollection;
230 }                                                 225 }
231                                                   226 
232                                                   227 
233 void  CexmcEventAction::PrintTrackPoints(         228 void  CexmcEventAction::PrintTrackPoints(
234                                     const Cexm    229                                     const CexmcTrackPointsStore *  tpStore )
235 {                                                 230 {
236     if ( ! tpStore )                              231     if ( ! tpStore )
237         return;                                   232         return;
238                                                   233 
239     G4cout << " --- Track Points" << G4endl;      234     G4cout << " --- Track Points" << G4endl;
240     G4cout << "       monitor : " << tpStore->    235     G4cout << "       monitor : " << tpStore->monitorTP << G4endl;
241     G4cout << "        target : " << tpStore->    236     G4cout << "        target : " << tpStore->targetTPBeamParticle << G4endl;
242     G4cout << "               : " << tpStore->    237     G4cout << "               : " << tpStore->targetTPOutputParticle << G4endl;
243     G4cout << "               : " << tpStore->    238     G4cout << "               : " << tpStore->targetTPNucleusParticle << G4endl;
244     G4cout << "               : " <<              239     G4cout << "               : " <<
245             tpStore->targetTPOutputParticleDec    240             tpStore->targetTPOutputParticleDecayProductParticle1 << G4endl;
246     G4cout << "               : " <<              241     G4cout << "               : " <<
247             tpStore->targetTPOutputParticleDec    242             tpStore->targetTPOutputParticleDecayProductParticle2 << G4endl;
248     G4cout << "        vc (l) : " << tpStore->    243     G4cout << "        vc (l) : " << tpStore->vetoCounterTPLeft << G4endl;
249     G4cout << "        vc (r) : " << tpStore->    244     G4cout << "        vc (r) : " << tpStore->vetoCounterTPRight << G4endl;
250     G4cout << "       cal (l) : " << tpStore->    245     G4cout << "       cal (l) : " << tpStore->calorimeterTPLeft << G4endl;
251     G4cout << "       cal (r) : " << tpStore->    246     G4cout << "       cal (r) : " << tpStore->calorimeterTPRight << G4endl;
252     G4cout << "      ---" << G4endl;              247     G4cout << "      ---" << G4endl;
253     G4cout << "      angle between the " <<       248     G4cout << "      angle between the " <<
254         tpStore->targetTPOutputParticle.partic    249         tpStore->targetTPOutputParticle.particle->GetParticleName() <<
255         " decay products : " <<                   250         " decay products : " <<
256         tpStore->targetTPOutputParticleDecayPr    251         tpStore->targetTPOutputParticleDecayProductParticle1.directionWorld.
257             angle(                                252             angle(
258         tpStore->targetTPOutputParticleDecayPr    253         tpStore->targetTPOutputParticleDecayProductParticle2.directionWorld ) /
259             deg << " deg" << G4endl;              254             deg << " deg" << G4endl;
260 }                                                 255 }
261                                                   256 
262                                                   257 
263 void  CexmcEventAction::PrintProductionModelDa    258 void  CexmcEventAction::PrintProductionModelData(
264                                 const CexmcAng    259                                 const CexmcAngularRangeList &  angularRanges,
265                                 const CexmcPro    260                                 const CexmcProductionModelData &  pmData )
266 {                                                 261 {
267     G4cout << " --- Triggered angular ranges:     262     G4cout << " --- Triggered angular ranges: " << angularRanges;
268     G4cout << " --- Production model data: " <    263     G4cout << " --- Production model data: " << pmData;
269 }                                                 264 }
270                                                   265 
271                                                   266 
272 void  CexmcEventAction::PrintReconstructedData    267 void  CexmcEventAction::PrintReconstructedData(
273                     const CexmcAngularRangeLis    268                     const CexmcAngularRangeList &  triggeredRecAngularRanges,
274                     const CexmcAngularRange &     269                     const CexmcAngularRange &  angularGap ) const
275 {                                                 270 {
276     G4cout << " --- Reconstructed data: " << G    271     G4cout << " --- Reconstructed data: " << G4endl;
277     G4cout << "       -- entry points:" << G4e    272     G4cout << "       -- entry points:" << G4endl;
278     G4cout << "              left: " << G4Best    273     G4cout << "              left: " << G4BestUnit(
279         reconstructor->GetCalorimeterEPLeftPos    274         reconstructor->GetCalorimeterEPLeftPosition(), "Length" ) << G4endl;
280     G4cout << "             right: " << G4Best    275     G4cout << "             right: " << G4BestUnit(
281         reconstructor->GetCalorimeterEPRightPo    276         reconstructor->GetCalorimeterEPRightPosition(), "Length" ) << G4endl;
282     G4cout << "            target: " << G4Best    277     G4cout << "            target: " << G4BestUnit(
283         reconstructor->GetTargetEPPosition(),     278         reconstructor->GetTargetEPPosition(), "Length" ) << G4endl;
284     G4cout << "       -- the angle: " << recon    279     G4cout << "       -- the angle: " << reconstructor->GetTheAngle() / deg <<
285         " deg" << G4endl;                         280         " deg" << G4endl;
286     G4cout << "       -- mass of the output pa    281     G4cout << "       -- mass of the output particle: " << G4BestUnit(
287         reconstructor->GetOutputParticleMass()    282         reconstructor->GetOutputParticleMass(), "Energy" ) << G4endl;
288     G4cout << "       -- mass of the nucleus o    283     G4cout << "       -- mass of the nucleus output particle: " << G4BestUnit(
289         reconstructor->GetNucleusOutputParticl    284         reconstructor->GetNucleusOutputParticleMass(), "Energy" ) << G4endl;
290     if ( reconstructor->IsMassCutUsed() )         285     if ( reconstructor->IsMassCutUsed() )
291     {                                             286     {
292         if ( reconstructor->HasMassCutTriggere    287         if ( reconstructor->HasMassCutTriggered() )
293             G4cout << "            < mass cut     288             G4cout << "            < mass cut passed >" << G4endl;
294         else                                      289         else
295             G4cout << "            < mass cut     290             G4cout << "            < mass cut failed >" << G4endl;
296     }                                             291     }
297     if ( reconstructor->IsAbsorbedEnergyCutUse    292     if ( reconstructor->IsAbsorbedEnergyCutUsed() )
298     {                                             293     {
299         if ( reconstructor->HasAbsorbedEnergyC    294         if ( reconstructor->HasAbsorbedEnergyCutTriggered() )
300             G4cout << "            < absorbed     295             G4cout << "            < absorbed energy cut passed >" << G4endl;
301         else                                      296         else
302             G4cout << "            < absorbed     297             G4cout << "            < absorbed energy cut failed >" << G4endl;
303     }                                             298     }
304     const CexmcProductionModelData &  pmData(     299     const CexmcProductionModelData &  pmData(
305                                     reconstruc    300                                     reconstructor->GetProductionModelData() );
306     G4cout << "       -- production model data    301     G4cout << "       -- production model data: " << pmData;
307     G4cout << "       -- triggered angular ran    302     G4cout << "       -- triggered angular ranges: ";
308     if ( triggeredRecAngularRanges.empty() )      303     if ( triggeredRecAngularRanges.empty() )
309         G4cout << "< orphan detected, gap " <<    304         G4cout << "< orphan detected, gap " << angularGap << " >" << G4endl;
310     else                                          305     else
311         G4cout << triggeredRecAngularRanges;      306         G4cout << triggeredRecAngularRanges;
312 }                                                 307 }
313                                                   308 
314                                                   309 
315 #ifdef CEXMC_USE_ROOT                             310 #ifdef CEXMC_USE_ROOT
316                                                   311 
317 void  CexmcEventAction::FillEDTHistos( const C    312 void  CexmcEventAction::FillEDTHistos( const CexmcEnergyDepositStore *  edStore,
318                 const CexmcAngularRangeList &     313                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
319 {                                                 314 {
320     CexmcHistoManager *  histoManager( CexmcHi    315     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
321                                                   316 
322     histoManager->Add( CexmcAbsorbedEnergy_EDT    317     histoManager->Add( CexmcAbsorbedEnergy_EDT_Histo, 0,
323                        edStore->calorimeterEDL    318                        edStore->calorimeterEDLeft,
324                        edStore->calorimeterEDR    319                        edStore->calorimeterEDRight );
325                                                   320 
326     for ( CexmcAngularRangeList::const_iterato    321     for ( CexmcAngularRangeList::const_iterator
327                         k( triggeredAngularRan    322                         k( triggeredAngularRanges.begin() );
328                                     k != trigg    323                                     k != triggeredAngularRanges.end(); ++k )
329     {                                             324     {
330         histoManager->Add( CexmcAbsEnInLeftCal    325         histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
331                            k->index, edStore->    326                            k->index, edStore->calorimeterEDLeft );
332         histoManager->Add( CexmcAbsEnInRightCa    327         histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
333                            k->index, edStore->    328                            k->index, edStore->calorimeterEDRight );
334     }                                             329     }
335 }                                                 330 }
336                                                   331 
337                                                   332 
338 void  CexmcEventAction::FillTPTHistos( const C    333 void  CexmcEventAction::FillTPTHistos( const CexmcTrackPointsStore *  tpStore,
339                 const CexmcProductionModelData    334                 const CexmcProductionModelData &  pmData,
340                 const CexmcAngularRangeList &     335                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
341 {                                                 336 {
342     CexmcHistoManager *  histoManager( CexmcHi    337     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
343                                                   338 
344     if ( tpStore->monitorTP.IsValid() )           339     if ( tpStore->monitorTP.IsValid() )
345     {                                             340     {
346         histoManager->Add( CexmcMomentumBP_TPT    341         histoManager->Add( CexmcMomentumBP_TPT_Histo, 0,
347                            tpStore->monitorTP.    342                            tpStore->monitorTP.momentumAmp );
348         histoManager->Add( CexmcTPInMonitor_TP    343         histoManager->Add( CexmcTPInMonitor_TPT_Histo, 0,
349                            tpStore->monitorTP.    344                            tpStore->monitorTP.positionLocal.x(),
350                            tpStore->monitorTP.    345                            tpStore->monitorTP.positionLocal.y() );
351     }                                             346     }
352                                                   347 
353     if ( tpStore->targetTPOutputParticle.IsVal    348     if ( tpStore->targetTPOutputParticle.IsValid() )
354     {                                             349     {
355         histoManager->Add( CexmcTPInTarget_TPT    350         histoManager->Add( CexmcTPInTarget_TPT_Histo, 0,
356                            tpStore->targetTPOu    351                            tpStore->targetTPOutputParticle.positionLocal.x(),
357                            tpStore->targetTPOu    352                            tpStore->targetTPOutputParticle.positionLocal.y(),
358                            tpStore->targetTPOu    353                            tpStore->targetTPOutputParticle.positionLocal.z() );
359         if ( histoManager->GetVerboseLevel() >    354         if ( histoManager->GetVerboseLevel() > 0 )
360         {                                         355         {
361             histoManager->Add( CexmcMomentumIP    356             histoManager->Add( CexmcMomentumIP_TPT_Histo, 0,
362                                pmData.incident    357                                pmData.incidentParticleLAB.rho() );
363         }                                         358         }
364     }                                             359     }
365                                                   360 
366     for ( CexmcAngularRangeList::const_iterato    361     for ( CexmcAngularRangeList::const_iterator
367                         k( triggeredAngularRan    362                         k( triggeredAngularRanges.begin() );
368                                     k != trigg    363                                     k != triggeredAngularRanges.end(); ++k )
369     {                                             364     {
370         if ( tpStore->calorimeterTPLeft.IsVali    365         if ( tpStore->calorimeterTPLeft.IsValid() )
371         {                                         366         {
372             /* kinetic energy and momentum of     367             /* kinetic energy and momentum of gamma are equal */
373             G4double  kinEnergy( tpStore->calo    368             G4double  kinEnergy( tpStore->calorimeterTPLeft.momentumAmp );
374             histoManager->Add( CexmcKinEnAtLef    369             histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
375                                k->index, kinEn    370                                k->index, kinEnergy );
376         }                                         371         }
377         if ( tpStore->calorimeterTPRight.IsVal    372         if ( tpStore->calorimeterTPRight.IsValid() )
378         {                                         373         {
379             G4double  kinEnergy( tpStore->calo    374             G4double  kinEnergy( tpStore->calorimeterTPRight.momentumAmp );
380             histoManager->Add( CexmcKinEnAtRig    375             histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
381                                k->index, kinEn    376                                k->index, kinEnergy );
382         }                                         377         }
383         if ( tpStore->targetTPOutputParticle.I    378         if ( tpStore->targetTPOutputParticle.IsValid() )
384         {                                         379         {
385             histoManager->Add( CexmcTPInTarget    380             histoManager->Add( CexmcTPInTarget_ARReal_TPT_Histo, k->index,
386                            tpStore->targetTPOu    381                            tpStore->targetTPOutputParticle.positionLocal.x(),
387                            tpStore->targetTPOu    382                            tpStore->targetTPOutputParticle.positionLocal.y(),
388                            tpStore->targetTPOu    383                            tpStore->targetTPOutputParticle.positionLocal.z() );
389             histoManager->Add( CexmcKinEnOP_LA    384             histoManager->Add( CexmcKinEnOP_LAB_ARReal_TPT_Histo, k->index,
390                                opKinEnergy );     385                                opKinEnergy );
391             histoManager->Add( CexmcAngleOP_SC    386             histoManager->Add( CexmcAngleOP_SCM_ARReal_TPT_Histo, k->index,
392                                pmData.outputPa    387                                pmData.outputParticleSCM.cosTheta() );
393         }                                         388         }
394         if ( tpStore->targetTPOutputParticleDe    389         if ( tpStore->targetTPOutputParticleDecayProductParticle1.IsValid() &&
395              tpStore->targetTPOutputParticleDe    390              tpStore->targetTPOutputParticleDecayProductParticle2.IsValid() )
396         {                                         391         {
397             G4double  openAngle(                  392             G4double  openAngle(
398                         tpStore->targetTPOutpu    393                         tpStore->targetTPOutputParticleDecayProductParticle1.
399                         directionWorld.angle(     394                         directionWorld.angle( tpStore->
400                                 targetTPOutput    395                                 targetTPOutputParticleDecayProductParticle2.
401                                         direct    396                                         directionWorld ) / deg );
402             histoManager->Add( CexmcOpenAngle_    397             histoManager->Add( CexmcOpenAngle_ARReal_TPT_Histo, k->index,
403                                openAngle );       398                                openAngle );
404         }                                         399         }
405     }                                             400     }
406 }                                                 401 }
407                                                   402 
408                                                   403 
409 void  CexmcEventAction::FillRTHistos( G4bool      404 void  CexmcEventAction::FillRTHistos( G4bool  reconstructorHasFullTrigger,
410                 const CexmcEnergyDepositStore     405                 const CexmcEnergyDepositStore *  edStore,
411                 const CexmcTrackPointsStore *     406                 const CexmcTrackPointsStore *  tpStore,
412                 const CexmcProductionModelData    407                 const CexmcProductionModelData &  pmData,
413                 const CexmcAngularRangeList &     408                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
414 {                                                 409 {
415     CexmcHistoManager *  histoManager( CexmcHi    410     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
416                                                   411 
417     G4double    opMass( reconstructor->GetOutp    412     G4double    opMass( reconstructor->GetOutputParticleMass() );
418     G4double    nopMass( reconstructor->GetNuc    413     G4double    nopMass( reconstructor->GetNucleusOutputParticleMass() );
419                                                   414 
420     histoManager->Add( CexmcRecMasses_EDT_Hist    415     histoManager->Add( CexmcRecMasses_EDT_Histo, 0, opMass, nopMass );
421                                                   416 
422     for ( CexmcAngularRangeList::const_iterato    417     for ( CexmcAngularRangeList::const_iterator
423                         k( triggeredAngularRan    418                         k( triggeredAngularRanges.begin() );
424                                     k != trigg    419                                     k != triggeredAngularRanges.end(); ++k )
425     {                                             420     {
426         if ( tpStore->calorimeterTPLeft.IsVali    421         if ( tpStore->calorimeterTPLeft.IsValid() )
427         {                                         422         {
428             histoManager->Add( CexmcOPDPAtLeft    423             histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
429                                k->index,          424                                k->index,
430                                tpStore->calori    425                                tpStore->calorimeterTPLeft.positionLocal.x(),
431                                tpStore->calori    426                                tpStore->calorimeterTPLeft.positionLocal.y() );
432         }                                         427         }
433         if ( tpStore->calorimeterTPRight.IsVal    428         if ( tpStore->calorimeterTPRight.IsValid() )
434         {                                         429         {
435             histoManager->Add( CexmcOPDPAtRigh    430             histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
436                                k->index,          431                                k->index,
437                                tpStore->calori    432                                tpStore->calorimeterTPRight.positionLocal.x(),
438                                tpStore->calori    433                                tpStore->calorimeterTPRight.positionLocal.y() );
439         }                                         434         }
440         histoManager->Add( CexmcRecOPDPAtLeftC    435         histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
441                            k->index,              436                            k->index,
442                            reconstructor->GetC    437                            reconstructor->GetCalorimeterEPLeftPosition().x(),
443                            reconstructor->GetC    438                            reconstructor->GetCalorimeterEPLeftPosition().y() );
444         histoManager->Add( CexmcRecOPDPAtRight    439         histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
445                            k->index,              440                            k->index,
446                            reconstructor->GetC    441                            reconstructor->GetCalorimeterEPRightPosition().x(),
447                            reconstructor->GetC    442                            reconstructor->GetCalorimeterEPRightPosition().y() );
448     }                                             443     }
449                                                   444 
450     if ( ! reconstructorHasFullTrigger )          445     if ( ! reconstructorHasFullTrigger )
451         return;                                   446         return;
452                                                   447 
453     if ( tpStore->monitorTP.IsValid() )           448     if ( tpStore->monitorTP.IsValid() )
454     {                                             449     {
455         histoManager->Add( CexmcMomentumBP_RT_    450         histoManager->Add( CexmcMomentumBP_RT_Histo, 0,
456                            tpStore->monitorTP.    451                            tpStore->monitorTP.momentumAmp );
457     }                                             452     }
458                                                   453 
459     if ( tpStore->targetTPOutputParticle.IsVal    454     if ( tpStore->targetTPOutputParticle.IsValid() )
460     {                                             455     {
461         histoManager->Add( CexmcTPInTarget_RT_    456         histoManager->Add( CexmcTPInTarget_RT_Histo, 0,
462                            tpStore->targetTPOu    457                            tpStore->targetTPOutputParticle.positionLocal.x(),
463                            tpStore->targetTPOu    458                            tpStore->targetTPOutputParticle.positionLocal.y(),
464                            tpStore->targetTPOu    459                            tpStore->targetTPOutputParticle.positionLocal.z() );
465     }                                             460     }
466                                                   461 
467     histoManager->Add( CexmcRecMasses_RT_Histo    462     histoManager->Add( CexmcRecMasses_RT_Histo, 0,
468                        reconstructor->GetOutpu    463                        reconstructor->GetOutputParticleMass(),
469                        reconstructor->GetNucle    464                        reconstructor->GetNucleusOutputParticleMass() );
470                                                   465 
471     histoManager->Add( CexmcAbsorbedEnergy_RT_    466     histoManager->Add( CexmcAbsorbedEnergy_RT_Histo, 0,
472                        edStore->calorimeterEDL    467                        edStore->calorimeterEDLeft,
473                        edStore->calorimeterEDR    468                        edStore->calorimeterEDRight );
474                                                   469 
475     G4double  recCosTheta( reconstructor->GetP    470     G4double  recCosTheta( reconstructor->GetProductionModelData().
476                                                   471                                                outputParticleSCM.cosTheta());
477                                                   472 
478     for ( CexmcAngularRangeList::const_iterato    473     for ( CexmcAngularRangeList::const_iterator
479                         k( triggeredAngularRan    474                         k( triggeredAngularRanges.begin() );
480                                     k != trigg    475                                     k != triggeredAngularRanges.end(); ++k )
481     {                                             476     {
482         histoManager->Add( CexmcRecMassOP_ARRe    477         histoManager->Add( CexmcRecMassOP_ARReal_RT_Histo, k->index, opMass );
483         histoManager->Add( CexmcRecMassNOP_ARR    478         histoManager->Add( CexmcRecMassNOP_ARReal_RT_Histo, k->index, nopMass );
484         if ( tpStore->calorimeterTPLeft.IsVali    479         if ( tpStore->calorimeterTPLeft.IsValid() )
485         {                                         480         {
486             G4double  kinEnergy( tpStore->calo    481             G4double  kinEnergy( tpStore->calorimeterTPLeft.momentumAmp );
487             histoManager->Add( CexmcKinEnAtLef    482             histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
488                                k->index, kinEn    483                                k->index, kinEnergy );
489             histoManager->Add( CexmcMissEnFrom    484             histoManager->Add( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
490                                k->index,          485                                k->index,
491                                kinEnergy - edS    486                                kinEnergy - edStore->calorimeterEDLeft );
492         }                                         487         }
493         if ( tpStore->calorimeterTPRight.IsVal    488         if ( tpStore->calorimeterTPRight.IsValid() )
494         {                                         489         {
495             G4double  kinEnergy( tpStore->calo    490             G4double  kinEnergy( tpStore->calorimeterTPRight.momentumAmp );
496             histoManager->Add( CexmcKinEnAtRig    491             histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
497                                k->index, kinEn    492                                k->index, kinEnergy );
498             histoManager->Add( CexmcMissEnFrom    493             histoManager->Add( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
499                                k->index,          494                                k->index,
500                                kinEnergy - edS    495                                kinEnergy - edStore->calorimeterEDRight );
501         }                                         496         }
502         if ( tpStore->targetTPOutputParticle.I    497         if ( tpStore->targetTPOutputParticle.IsValid() )
503         {                                         498         {
504             histoManager->Add( CexmcTPInTarget    499             histoManager->Add( CexmcTPInTarget_ARReal_RT_Histo, k->index,
505                            tpStore->targetTPOu    500                            tpStore->targetTPOutputParticle.positionLocal.x(),
506                            tpStore->targetTPOu    501                            tpStore->targetTPOutputParticle.positionLocal.y(),
507                            tpStore->targetTPOu    502                            tpStore->targetTPOutputParticle.positionLocal.z() );
508             histoManager->Add( CexmcKinEnOP_LA    503             histoManager->Add( CexmcKinEnOP_LAB_ARReal_RT_Histo, k->index,
509                                opKinEnergy );     504                                opKinEnergy );
510             histoManager->Add( CexmcAngleOP_SC    505             histoManager->Add( CexmcAngleOP_SCM_ARReal_RT_Histo, k->index,
511                                pmData.outputPa    506                                pmData.outputParticleSCM.cosTheta() );
512             G4double  diffCosTheta( pmData.out    507             G4double  diffCosTheta( pmData.outputParticleSCM.cosTheta() -
513                                     recCosThet    508                                     recCosTheta );
514             histoManager->Add( CexmcDiffAngleO    509             histoManager->Add( CexmcDiffAngleOP_SCM_ARReal_RT_Histo, k->index,
515                                diffCosTheta );    510                                diffCosTheta );
516         }                                         511         }
517         if ( tpStore->targetTPOutputParticleDe    512         if ( tpStore->targetTPOutputParticleDecayProductParticle1.IsValid() &&
518              tpStore->targetTPOutputParticleDe    513              tpStore->targetTPOutputParticleDecayProductParticle2.IsValid() )
519         {                                         514         {
520             G4double  openAngle(                  515             G4double  openAngle(
521                         tpStore->targetTPOutpu    516                         tpStore->targetTPOutputParticleDecayProductParticle1.
522                         directionWorld.angle(     517                         directionWorld.angle( tpStore->
523                                 targetTPOutput    518                                 targetTPOutputParticleDecayProductParticle2.
524                                         direct    519                                         directionWorld ) / deg );
525             histoManager->Add( CexmcOpenAngle_    520             histoManager->Add( CexmcOpenAngle_ARReal_RT_Histo, k->index,
526                                openAngle );       521                                openAngle );
527             G4double  diffOpenAngle( openAngle    522             G4double  diffOpenAngle( openAngle - reconstructor->GetTheAngle() /
528                                      deg );       523                                      deg );
529             histoManager->Add( CexmcDiffOpenAn    524             histoManager->Add( CexmcDiffOpenAngle_ARReal_RT_Histo, k->index,
530                                diffOpenAngle )    525                                diffOpenAngle );
531         }                                         526         }
532         if ( tpStore->calorimeterTPLeft.IsVali    527         if ( tpStore->calorimeterTPLeft.IsValid() )
533         {                                         528         {
534             histoManager->Add( CexmcOPDPAtLeft    529             histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
535                                k->index,          530                                k->index,
536                                tpStore->calori    531                                tpStore->calorimeterTPLeft.positionLocal.x(),
537                                tpStore->calori    532                                tpStore->calorimeterTPLeft.positionLocal.y() );
538         }                                         533         }
539         if ( tpStore->calorimeterTPRight.IsVal    534         if ( tpStore->calorimeterTPRight.IsValid() )
540         {                                         535         {
541             histoManager->Add( CexmcOPDPAtRigh    536             histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
542                                k->index,          537                                k->index,
543                                tpStore->calori    538                                tpStore->calorimeterTPRight.positionLocal.x(),
544                                tpStore->calori    539                                tpStore->calorimeterTPRight.positionLocal.y() );
545         }                                         540         }
546         histoManager->Add( CexmcAbsEnInLeftCal    541         histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
547                            k->index, edStore->    542                            k->index, edStore->calorimeterEDLeft );
548         histoManager->Add( CexmcAbsEnInRightCa    543         histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
549                            k->index, edStore->    544                            k->index, edStore->calorimeterEDRight );
550         histoManager->Add( CexmcRecAngleOP_SCM    545         histoManager->Add( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
551                            k->index, recCosThe    546                            k->index, recCosTheta );
552         histoManager->Add( CexmcRecOpenAngle_A    547         histoManager->Add( CexmcRecOpenAngle_ARReal_RT_Histo,
553                            k->index, reconstru    548                            k->index, reconstructor->GetTheAngle() / deg );
554         histoManager->Add( CexmcRecOPDPAtLeftC    549         histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
555                            k->index,              550                            k->index,
556                            reconstructor->GetC    551                            reconstructor->GetCalorimeterEPLeftPosition().x(),
557                            reconstructor->GetC    552                            reconstructor->GetCalorimeterEPLeftPosition().y() );
558         histoManager->Add( CexmcRecOPDPAtRight    553         histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
559                            k->index,              554                            k->index,
560                            reconstructor->GetC    555                            reconstructor->GetCalorimeterEPRightPosition().x(),
561                            reconstructor->GetC    556                            reconstructor->GetCalorimeterEPRightPosition().y() );
562     }                                             557     }
563 }                                                 558 }
564                                                   559 
565 #endif                                            560 #endif
566                                                   561 
567                                                   562 
568 void  CexmcEventAction::DrawTrajectories( cons    563 void  CexmcEventAction::DrawTrajectories( const G4Event *  event )
569 {                                                 564 {
570     G4VisManager *  visManager( static_cast< G    565     G4VisManager *  visManager( static_cast< G4VisManager * >(
571                                     G4VVisMana    566                                     G4VVisManager::GetConcreteInstance() ) );
572     if ( ! visManager || ! visManager->GetCurr    567     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
573         return;                                   568         return;
574                                                   569 
575     G4int                    nTraj( 0 );          570     G4int                    nTraj( 0 );
576     G4TrajectoryContainer *  trajContainer( ev    571     G4TrajectoryContainer *  trajContainer( event->GetTrajectoryContainer() );
577                                                   572 
578     if ( ! trajContainer )                        573     if ( ! trajContainer )
579         return;                                   574         return;
580                                                   575 
581     nTraj = trajContainer->entries();             576     nTraj = trajContainer->entries();
582                                                   577 
583     for ( int  i( 0 ); i < nTraj; ++i )           578     for ( int  i( 0 ); i < nTraj; ++i )
584     {                                             579     {
585         G4VTrajectory *  traj( ( *trajContaine    580         G4VTrajectory *  traj( ( *trajContainer )[ i ] );
586         traj->DrawTrajectory();                   581         traj->DrawTrajectory();
587     }                                             582     }
588 }                                                 583 }
589                                                   584 
590                                                   585 
591 void  CexmcEventAction::DrawTrackPoints(          586 void  CexmcEventAction::DrawTrackPoints(
592                                 const CexmcTra    587                                 const CexmcTrackPointsStore *  tpStore ) const
593 {                                                 588 {
594     G4VisManager *  visManager( static_cast< G    589     G4VisManager *  visManager( static_cast< G4VisManager * >(
595                                     G4VVisMana    590                                     G4VVisManager::GetConcreteInstance() ) );
596     if ( ! visManager || ! visManager->GetCurr    591     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
597         return;                                   592         return;
598                                                   593 
599     G4Circle         circle;                      594     G4Circle         circle;
600     G4VisAttributes  visAttributes( CexmcTrack    595     G4VisAttributes  visAttributes( CexmcTrackPointsMarkerColour );
601     circle.SetScreenSize( CexmcSmallCircleScre    596     circle.SetScreenSize( CexmcSmallCircleScreenSize );
602     circle.SetFillStyle( G4Circle::filled );      597     circle.SetFillStyle( G4Circle::filled );
603     circle.SetVisAttributes( visAttributes );     598     circle.SetVisAttributes( visAttributes );
604                                                   599 
605     if ( tpStore->monitorTP.IsValid() )           600     if ( tpStore->monitorTP.IsValid() )
606     {                                             601     {
607         circle.SetPosition( tpStore->monitorTP    602         circle.SetPosition( tpStore->monitorTP.positionWorld );
608         visManager->Draw( circle );               603         visManager->Draw( circle );
609     }                                             604     }
610                                                   605 
611     if ( tpStore->targetTPBeamParticle.IsValid    606     if ( tpStore->targetTPBeamParticle.IsValid() )
612     {                                             607     {
613         circle.SetPosition( tpStore->targetTPB    608         circle.SetPosition( tpStore->targetTPBeamParticle.positionWorld );
614         visManager->Draw( circle );               609         visManager->Draw( circle );
615     }                                             610     }
616                                                   611 
617     if ( tpStore->targetTPOutputParticle.IsVal    612     if ( tpStore->targetTPOutputParticle.IsValid() )
618     {                                             613     {
619         circle.SetPosition( tpStore->targetTPO    614         circle.SetPosition( tpStore->targetTPOutputParticle.positionWorld );
620         visManager->Draw( circle );               615         visManager->Draw( circle );
621     }                                             616     }
622                                                   617 
623     if ( tpStore->vetoCounterTPLeft.IsValid()     618     if ( tpStore->vetoCounterTPLeft.IsValid() )
624     {                                             619     {
625         circle.SetPosition( tpStore->vetoCount    620         circle.SetPosition( tpStore->vetoCounterTPLeft.positionWorld );
626         visManager->Draw( circle );               621         visManager->Draw( circle );
627     }                                             622     }
628                                                   623 
629     if ( tpStore->vetoCounterTPRight.IsValid()    624     if ( tpStore->vetoCounterTPRight.IsValid() )
630     {                                             625     {
631         circle.SetPosition( tpStore->vetoCount    626         circle.SetPosition( tpStore->vetoCounterTPRight.positionWorld );
632         visManager->Draw( circle );               627         visManager->Draw( circle );
633     }                                             628     }
634                                                   629 
635     if ( tpStore->calorimeterTPLeft.IsValid()     630     if ( tpStore->calorimeterTPLeft.IsValid() )
636     {                                             631     {
637         circle.SetPosition( tpStore->calorimet    632         circle.SetPosition( tpStore->calorimeterTPLeft.positionWorld );
638         visManager->Draw( circle );               633         visManager->Draw( circle );
639     }                                             634     }
640                                                   635 
641     if ( tpStore->calorimeterTPRight.IsValid()    636     if ( tpStore->calorimeterTPRight.IsValid() )
642     {                                             637     {
643         circle.SetPosition( tpStore->calorimet    638         circle.SetPosition( tpStore->calorimeterTPRight.positionWorld );
644         visManager->Draw( circle );               639         visManager->Draw( circle );
645     }                                             640     }
646 }                                                 641 }
647                                                   642 
648                                                   643 
649 void  CexmcEventAction::DrawReconstructionData    644 void  CexmcEventAction::DrawReconstructionData( void )
650 {                                                 645 {
651     G4VisManager *  visManager( static_cast< G    646     G4VisManager *  visManager( static_cast< G4VisManager * >(
652                                     G4VVisMana    647                                     G4VVisManager::GetConcreteInstance() ) );
653     if ( ! visManager || ! visManager->GetCurr    648     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
654         return;                                   649         return;
655                                                   650 
656     G4Circle  circle( reconstructor->GetTarget    651     G4Circle  circle( reconstructor->GetTargetEPWorldPosition() );
657     circle.SetScreenSize( CexmcSmallCircleScre    652     circle.SetScreenSize( CexmcSmallCircleScreenSize );
658     circle.SetFillStyle( G4Circle::filled );      653     circle.SetFillStyle( G4Circle::filled );
659     G4VisAttributes  visAttributes( CexmcRecTr    654     G4VisAttributes  visAttributes( CexmcRecTrackPointsMarkerColour );
660     circle.SetVisAttributes( visAttributes );     655     circle.SetVisAttributes( visAttributes );
661     visManager->Draw( circle );                   656     visManager->Draw( circle );
662                                                   657 
663     circle.SetScreenSize( CexmcBigCircleScreen    658     circle.SetScreenSize( CexmcBigCircleScreenSize );
664     circle.SetPosition( reconstructor->GetCalo    659     circle.SetPosition( reconstructor->GetCalorimeterEPLeftWorldPosition() );
665     visManager->Draw( circle );                   660     visManager->Draw( circle );
666                                                   661 
667     circle.SetPosition( reconstructor->GetCalo    662     circle.SetPosition( reconstructor->GetCalorimeterEPRightWorldPosition() );
668     visManager->Draw( circle );                   663     visManager->Draw( circle );
669 }                                                 664 }
670                                                   665 
671                                                   666 
672 void  CexmcEventAction::UpdateRunHits(            667 void  CexmcEventAction::UpdateRunHits(
673                                     const Cexm    668                                     const CexmcAngularRangeList &  aRangesReal,
674                                     const Cexm    669                                     const CexmcAngularRangeList &  aRangesRec,
675                                     G4bool  tp    670                                     G4bool  tpDigitizerHasTriggered,
676                                     G4bool  ed    671                                     G4bool  edDigitizerHasTriggered,
677                                     G4bool  ed    672                                     G4bool  edDigitizerMonitorHasTriggered,
678                                     G4bool  re    673                                     G4bool  reconstructorHasFullTrigger,
679                                     const Cexm    674                                     const CexmcAngularRange &  aGap )
680 {                                                 675 {
681     G4RunManager *    runManager( G4RunManager    676     G4RunManager *    runManager( G4RunManager::GetRunManager() );
682     const CexmcRun *  run( static_cast< const     677     const CexmcRun *  run( static_cast< const CexmcRun * >(
683                                                   678                                                 runManager->GetCurrentRun() ) );
684     CexmcRun *        theRun( const_cast< Cexm    679     CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
685                                                   680 
686     if ( tpDigitizerHasTriggered )                681     if ( tpDigitizerHasTriggered )
687     {                                             682     {
688         for ( CexmcAngularRangeList::const_ite    683         for ( CexmcAngularRangeList::const_iterator  k( aRangesReal.begin() );
689                                                   684                                                 k != aRangesReal.end(); ++k )
690         {                                         685         {
691             theRun->IncrementNmbOfHitsSampledF    686             theRun->IncrementNmbOfHitsSampledFull( k->index );
692             if ( edDigitizerMonitorHasTriggere    687             if ( edDigitizerMonitorHasTriggered )
693                 theRun->IncrementNmbOfHitsSamp    688                 theRun->IncrementNmbOfHitsSampled( k->index );
694             if ( reconstructorHasFullTrigger )    689             if ( reconstructorHasFullTrigger )
695                 theRun->IncrementNmbOfHitsTrig    690                 theRun->IncrementNmbOfHitsTriggeredRealRange( k->index );
696         }                                         691         }
697         if ( reconstructorHasFullTrigger )        692         if ( reconstructorHasFullTrigger )
698         {                                         693         {
699             if ( aRangesRec.empty() )             694             if ( aRangesRec.empty() )
700             {                                     695             {
701                 theRun->IncrementNmbOfOrphanHi    696                 theRun->IncrementNmbOfOrphanHits( aGap.index );
702             }                                     697             }
703             else                                  698             else
704             {                                     699             {
705                 for ( CexmcAngularRangeList::c    700                 for ( CexmcAngularRangeList::const_iterator
706                         k( aRangesRec.begin()     701                         k( aRangesRec.begin() ); k != aRangesRec.end(); ++k )
707                 {                                 702                 {
708                     theRun->IncrementNmbOfHits    703                     theRun->IncrementNmbOfHitsTriggeredRecRange( k->index );
709                 }                                 704                 }
710             }                                     705             }
711         }                                         706         }
712     }                                             707     }
713     else                                          708     else
714     {                                             709     {
715         if ( edDigitizerHasTriggered )            710         if ( edDigitizerHasTriggered )
716             theRun->IncrementNmbOfFalseHitsTri    711             theRun->IncrementNmbOfFalseHitsTriggeredEDT();
717         if ( reconstructorHasFullTrigger )        712         if ( reconstructorHasFullTrigger )
718             theRun->IncrementNmbOfFalseHitsTri    713             theRun->IncrementNmbOfFalseHitsTriggeredRec();
719     }                                             714     }
720 }                                                 715 }
721                                                   716 
722                                                   717 
723 #ifdef CEXMC_USE_PERSISTENCY                      718 #ifdef CEXMC_USE_PERSISTENCY
724                                                   719 
725 void  CexmcEventAction::SaveEvent( const G4Eve    720 void  CexmcEventAction::SaveEvent( const G4Event *  event,
726                                    G4bool  edD    721                                    G4bool  edDigitizerHasTriggered,
727                                    const Cexmc    722                                    const CexmcEnergyDepositStore *  edStore,
728                                    const Cexmc    723                                    const CexmcTrackPointsStore *  tpStore,
729                                    const Cexmc    724                                    const CexmcProductionModelData &  pmData )
730 {                                                 725 {
731     CexmcRunManager *  runManager( static_cast    726     CexmcRunManager *  runManager( static_cast< CexmcRunManager * >(
732                                             G4    727                                             G4RunManager::GetRunManager() ) );
733     if ( ! runManager->ProjectIsSaved() )         728     if ( ! runManager->ProjectIsSaved() )
734         return;                                   729         return;
735                                                   730 
736     if ( runManager->GetEventDataVerboseLevel(    731     if ( runManager->GetEventDataVerboseLevel() == CexmcWriteNoEventData )
737         return;                                   732         return;
738                                                   733 
739     if ( ! edDigitizerHasTriggered && runManag    734     if ( ! edDigitizerHasTriggered && runManager->GetEventDataVerboseLevel() !=
740                                                   735                                                 CexmcWriteEventDataOnEveryTPT )
741         return;                                   736         return;
742                                                   737 
743     boost::archive::binary_oarchive *  archive    738     boost::archive::binary_oarchive *  archive(
744                                             ru    739                                             runManager->GetEventsArchive() );
745     if ( archive )                                740     if ( archive )
746     {                                             741     {
747         CexmcEventSObject  sObject = { event->    742         CexmcEventSObject  sObject = { event->GetEventID(),
748             edDigitizerHasTriggered, edStore->    743             edDigitizerHasTriggered, edStore->monitorED,
749             edStore->vetoCounterEDLeft, edStor    744             edStore->vetoCounterEDLeft, edStore->vetoCounterEDRight,
750             edStore->calorimeterEDLeft, edStor    745             edStore->calorimeterEDLeft, edStore->calorimeterEDRight,
751             edStore->calorimeterEDLeftCollecti    746             edStore->calorimeterEDLeftCollection,
752             edStore->calorimeterEDRightCollect    747             edStore->calorimeterEDRightCollection,
753             tpStore->monitorTP, tpStore->targe    748             tpStore->monitorTP, tpStore->targetTPBeamParticle,
754             tpStore->targetTPOutputParticle, t    749             tpStore->targetTPOutputParticle, tpStore->targetTPNucleusParticle,
755             tpStore->targetTPOutputParticleDec    750             tpStore->targetTPOutputParticleDecayProductParticle1,
756             tpStore->targetTPOutputParticleDec    751             tpStore->targetTPOutputParticleDecayProductParticle2,
757             tpStore->vetoCounterTPLeft, tpStor    752             tpStore->vetoCounterTPLeft, tpStore->vetoCounterTPRight,
758             tpStore->calorimeterTPLeft, tpStor    753             tpStore->calorimeterTPLeft, tpStore->calorimeterTPRight, pmData };
759         archive->operator<<( sObject );           754         archive->operator<<( sObject );
760         const CexmcRun *  run( static_cast< co    755         const CexmcRun *  run( static_cast< const CexmcRun * >(
761                                                   756                                                 runManager->GetCurrentRun() ) );
762         CexmcRun *        theRun( const_cast<     757         CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
763         theRun->IncrementNmbOfSavedEvents();      758         theRun->IncrementNmbOfSavedEvents();
764     }                                             759     }
765 }                                                 760 }
766                                                   761 
767                                                   762 
768 void  CexmcEventAction::SaveEventFast( const G    763 void  CexmcEventAction::SaveEventFast( const G4Event *  event,
769                                        G4bool     764                                        G4bool  tpDigitizerHasTriggered,
770                                        G4bool     765                                        G4bool  edDigitizerHasTriggered,
771                                        G4bool     766                                        G4bool  edDigitizerMonitorHasTriggered,
772                                        G4doubl    767                                        G4double  opCosThetaSCM )
773 {                                                 768 {
774     CexmcRunManager *  runManager( static_cast    769     CexmcRunManager *  runManager( static_cast< CexmcRunManager * >(
775                                             G4    770                                             G4RunManager::GetRunManager() ) );
776     if ( ! runManager->ProjectIsSaved() )         771     if ( ! runManager->ProjectIsSaved() )
777         return;                                   772         return;
778                                                   773 
779     if ( runManager->GetEventDataVerboseLevel(    774     if ( runManager->GetEventDataVerboseLevel() == CexmcWriteNoEventData )
780         return;                                   775         return;
781                                                   776 
782     boost::archive::binary_oarchive *  archive    777     boost::archive::binary_oarchive *  archive(
783                                         runMan    778                                         runManager->GetFastEventsArchive() );
784     if ( archive )                                779     if ( archive )
785     {                                             780     {
786         if ( ! tpDigitizerHasTriggered )          781         if ( ! tpDigitizerHasTriggered )
787             opCosThetaSCM = CexmcInvalidCosThe    782             opCosThetaSCM = CexmcInvalidCosTheta;
788                                                   783 
789         CexmcEventFastSObject  sObject = { eve    784         CexmcEventFastSObject  sObject = { event->GetEventID(), opCosThetaSCM,
790                                            edD    785                                            edDigitizerHasTriggered,
791                                            edD    786                                            edDigitizerMonitorHasTriggered };
792         archive->operator<<( sObject );           787         archive->operator<<( sObject );
793         const CexmcRun *  run( static_cast< co    788         const CexmcRun *  run( static_cast< const CexmcRun * >(
794                                                   789                                                 runManager->GetCurrentRun() ) );
795         CexmcRun *        theRun( const_cast<     790         CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
796         theRun->IncrementNmbOfSavedFastEvents(    791         theRun->IncrementNmbOfSavedFastEvents();
797     }                                             792     }
798 }                                                 793 }
799                                                   794 
800 #endif                                            795 #endif
801                                                   796 
802                                                   797 
803 void  CexmcEventAction::EndOfEventAction( cons    798 void  CexmcEventAction::EndOfEventAction( const G4Event *  event )
804 {                                                 799 {
805     G4DigiManager *                digiManager    800     G4DigiManager *                digiManager( G4DigiManager::GetDMpointer() );
806     CexmcEnergyDepositDigitizer *  energyDepos    801     CexmcEnergyDepositDigitizer *  energyDepositDigitizer(
807             static_cast< CexmcEnergyDepositDig    802             static_cast< CexmcEnergyDepositDigitizer * >( digiManager->
808                                 FindDigitizerM    803                                 FindDigitizerModule( CexmcEDDigitizerName ) ) );
809     CexmcTrackPointsDigitizer *    trackPoints    804     CexmcTrackPointsDigitizer *    trackPointsDigitizer(
810             static_cast< CexmcTrackPointsDigit    805             static_cast< CexmcTrackPointsDigitizer * >( digiManager->
811                                 FindDigitizerM    806                                 FindDigitizerModule( CexmcTPDigitizerName ) ) );
812                                                   807 
813     energyDepositDigitizer->Digitize();           808     energyDepositDigitizer->Digitize();
814     trackPointsDigitizer->Digitize();             809     trackPointsDigitizer->Digitize();
815                                                   810 
816     G4bool  edDigitizerMonitorHasTriggered(       811     G4bool  edDigitizerMonitorHasTriggered(
817                                 energyDepositD    812                                 energyDepositDigitizer->MonitorHasTriggered() );
818     G4bool  edDigitizerHasTriggered( false );     813     G4bool  edDigitizerHasTriggered( false );
819                                                   814 
820     CexmcEventInfo *  eventInfo( static_cast<     815     CexmcEventInfo *  eventInfo( static_cast< CexmcEventInfo * >(
821                                                   816                                                 event->GetUserInformation() ) );
822     if ( ! eventInfo || eventInfo->EdTriggerIs    817     if ( ! eventInfo || eventInfo->EdTriggerIsOk() )
823         edDigitizerHasTriggered = energyDeposi    818         edDigitizerHasTriggered = energyDepositDigitizer->HasTriggered();
824                                                   819 
825     G4bool  tpDigitizerHasTriggered( trackPoin    820     G4bool  tpDigitizerHasTriggered( trackPointsDigitizer->HasTriggered() );
826     G4bool  reconstructorHasBasicTrigger( fals    821     G4bool  reconstructorHasBasicTrigger( false );
827     G4bool  reconstructorHasFullTrigger( false    822     G4bool  reconstructorHasFullTrigger( false );
828                                                   823 
829     CexmcEnergyDepositStore *  edStore( MakeEn    824     CexmcEnergyDepositStore *  edStore( MakeEnergyDepositStore(
830                                                   825                                                     energyDepositDigitizer ) );
831     CexmcTrackPointsStore *    tpStore( MakeTr    826     CexmcTrackPointsStore *    tpStore( MakeTrackPointsStore(
832                                                   827                                                     trackPointsDigitizer ) );
833                                                   828 
834     try                                           829     try
835     {                                             830     {
836         CexmcProductionModel *  productionMode    831         CexmcProductionModel *  productionModel(
837                                         physic    832                                         physicsManager->GetProductionModel() );
838                                                   833 
839         if ( ! productionModel )                  834         if ( ! productionModel )
840             throw CexmcException( CexmcWeirdEx    835             throw CexmcException( CexmcWeirdException );
841                                                   836 
842         const CexmcAngularRangeList &     angu    837         const CexmcAngularRangeList &     angularRanges(
843                                 productionMode    838                                 productionModel->GetAngularRanges() );
844         const CexmcAngularRangeList &     trig    839         const CexmcAngularRangeList &     triggeredAngularRanges(
845                                 productionMode    840                                 productionModel->GetTriggeredAngularRanges() );
846         const CexmcProductionModelData &  pmDa    841         const CexmcProductionModelData &  pmData(
847                                 productionMode    842                                 productionModel->GetProductionModelData() );
848                                                   843 
849         if ( edDigitizerHasTriggered )            844         if ( edDigitizerHasTriggered )
850         {                                         845         {
851             reconstructor->Reconstruct( edStor    846             reconstructor->Reconstruct( edStore );
852             reconstructorHasBasicTrigger = rec    847             reconstructorHasBasicTrigger = reconstructor->HasBasicTrigger();
853             reconstructorHasFullTrigger = reco    848             reconstructorHasFullTrigger = reconstructor->HasFullTrigger();
854         }                                         849         }
855                                                   850 
856         CexmcAngularRangeList  triggeredRecAng    851         CexmcAngularRangeList  triggeredRecAngularRanges;
857                                                   852 
858         if ( reconstructorHasBasicTrigger )       853         if ( reconstructorHasBasicTrigger )
859         {                                         854         {
860             for ( CexmcAngularRangeList::const    855             for ( CexmcAngularRangeList::const_iterator
861                   k( angularRanges.begin() );     856                   k( angularRanges.begin() ); k != angularRanges.end(); ++k )
862             {                                     857             {
863                 G4double  cosTheta( reconstruc    858                 G4double  cosTheta( reconstructor->GetProductionModelData().
864                                     outputPart    859                                     outputParticleSCM.cosTheta() );
865                 if ( cosTheta <= k->top && cos    860                 if ( cosTheta <= k->top && cosTheta > k->bottom )
866                     triggeredRecAngularRanges.    861                     triggeredRecAngularRanges.push_back( CexmcAngularRange(
867                                                   862                                                 k->top, k->bottom, k->index ) );
868             }                                     863             }
869         }                                         864         }
870                                                   865 
871         CexmcAngularRange  angularGap( 0.0, 0.    866         CexmcAngularRange  angularGap( 0.0, 0.0, 0 );
872         if ( triggeredRecAngularRanges.empty()    867         if ( triggeredRecAngularRanges.empty() )
873         {                                         868         {
874             CexmcAngularRangeList  angularGaps    869             CexmcAngularRangeList  angularGaps;
875             GetAngularGaps( angularRanges, ang    870             GetAngularGaps( angularRanges, angularGaps );
876             for ( CexmcAngularRangeList::const    871             for ( CexmcAngularRangeList::const_iterator
877                     k( angularGaps.begin() );     872                     k( angularGaps.begin() ); k != angularGaps.end(); ++k )
878             {                                     873             {
879                 G4double  cosTheta( reconstruc    874                 G4double  cosTheta( reconstructor->GetProductionModelData().
880                                     outputPart    875                                     outputParticleSCM.cosTheta() );
881                 if ( cosTheta <= k->top && cos    876                 if ( cosTheta <= k->top && cosTheta > k->bottom )
882                 {                                 877                 {
883                     angularGap = *k;              878                     angularGap = *k;
884                     break;                        879                     break;
885                 }                                 880                 }
886             }                                     881             }
887         }                                         882         }
888                                                   883 
889         UpdateRunHits( triggeredAngularRanges,    884         UpdateRunHits( triggeredAngularRanges, triggeredRecAngularRanges,
890                        tpDigitizerHasTriggered    885                        tpDigitizerHasTriggered, edDigitizerHasTriggered,
891                        edDigitizerMonitorHasTr    886                        edDigitizerMonitorHasTriggered,
892                        reconstructorHasFullTri    887                        reconstructorHasFullTrigger, angularGap );
893                                                   888 
894         if ( verbose > 0 )                        889         if ( verbose > 0 )
895         {                                         890         {
896             G4bool  printMessages( verbose > 3    891             G4bool  printMessages( verbose > 3 ||
897                         ( ( verbose == 1 ) &&     892                         ( ( verbose == 1 ) && tpDigitizerHasTriggered ) ||
898                         ( ( verbose == 2 ) &&     893                         ( ( verbose == 2 ) && edDigitizerHasTriggered ) ||
899                         ( ( verbose == 3 ) &&     894                         ( ( verbose == 3 ) && ( tpDigitizerHasTriggered ||
900                                                   895                                                 edDigitizerHasTriggered ) ) );
901             if ( printMessages )                  896             if ( printMessages )
902             {                                     897             {
903                 G4cout << "Event " << event->G    898                 G4cout << "Event " << event->GetEventID() << G4endl;
904                 if ( tpDigitizerHasTriggered )    899                 if ( tpDigitizerHasTriggered )
905                 {                                 900                 {
906                     PrintTrackPoints( tpStore     901                     PrintTrackPoints( tpStore );
907                     PrintProductionModelData(     902                     PrintProductionModelData( triggeredAngularRanges, pmData );
908                 }                                 903                 }
909                 if ( reconstructorHasBasicTrig    904                 if ( reconstructorHasBasicTrigger )
910                     PrintReconstructedData( tr    905                     PrintReconstructedData( triggeredRecAngularRanges,
911                                             an    906                                             angularGap );
912                 if ( edDigitizerHasTriggered )    907                 if ( edDigitizerHasTriggered )
913                     PrintEnergyDeposit( edStor    908                     PrintEnergyDeposit( edStore );
914             }                                     909             }
915         }                                         910         }
916                                                   911 
917         if ( verboseDraw > 0 )                    912         if ( verboseDraw > 0 )
918         {                                         913         {
919             G4bool  drawTrajectories( verboseD    914             G4bool  drawTrajectories( verboseDraw > 3 ||
920                         ( ( verboseDraw == 1 )    915                         ( ( verboseDraw == 1 ) && tpDigitizerHasTriggered ) ||
921                         ( ( verboseDraw == 2 )    916                         ( ( verboseDraw == 2 ) && edDigitizerHasTriggered ) ||
922                         ( ( verboseDraw == 3 )    917                         ( ( verboseDraw == 3 ) && ( tpDigitizerHasTriggered ||
923                                                   918                                                 edDigitizerHasTriggered ) ) );
924             if ( drawTrajectories )               919             if ( drawTrajectories )
925             {                                     920             {
926                 DrawTrajectories( event );        921                 DrawTrajectories( event );
927                 if ( tpDigitizerHasTriggered )    922                 if ( tpDigitizerHasTriggered )
928                     DrawTrackPoints( tpStore )    923                     DrawTrackPoints( tpStore );
929                 if ( reconstructorHasBasicTrig    924                 if ( reconstructorHasBasicTrigger )
930                     DrawReconstructionData();     925                     DrawReconstructionData();
931             }                                     926             }
932         }                                         927         }
933                                                   928 
934 #ifdef CEXMC_USE_PERSISTENCY                      929 #ifdef CEXMC_USE_PERSISTENCY
935         if ( edDigitizerHasTriggered || tpDigi    930         if ( edDigitizerHasTriggered || tpDigitizerHasTriggered )
936         {                                         931         {
937             SaveEventFast( event, tpDigitizerH    932             SaveEventFast( event, tpDigitizerHasTriggered,
938                            edDigitizerHasTrigg    933                            edDigitizerHasTriggered,
939                            edDigitizerMonitorH    934                            edDigitizerMonitorHasTriggered,
940                            pmData.outputPartic    935                            pmData.outputParticleSCM.cosTheta() );
941             SaveEvent( event, edDigitizerHasTr    936             SaveEvent( event, edDigitizerHasTriggered, edStore, tpStore,
942                        pmData );                  937                        pmData );
943         }                                         938         }
944 #endif                                            939 #endif
945                                                   940 
946 #ifdef CEXMC_USE_ROOT                             941 #ifdef CEXMC_USE_ROOT
947         /* opKinEnergy will be used in several    942         /* opKinEnergy will be used in several histos */
948         if ( tpStore->targetTPOutputParticle.I    943         if ( tpStore->targetTPOutputParticle.IsValid() )
949         {                                         944         {
950             opKinEnergy = CexmcGetKinEnergy(      945             opKinEnergy = CexmcGetKinEnergy(
951                     tpStore->targetTPOutputPar    946                     tpStore->targetTPOutputParticle.momentumAmp,
952                     tpStore->targetTPOutputPar    947                     tpStore->targetTPOutputParticle.particle->GetPDGMass() );
953         }                                         948         }
954                                                   949 
955         if ( edDigitizerHasTriggered )            950         if ( edDigitizerHasTriggered )
956             FillEDTHistos( edStore, triggeredA    951             FillEDTHistos( edStore, triggeredAngularRanges );
957                                                   952 
958         /* fill TPT histos only when the monit    953         /* fill TPT histos only when the monitor has triggered because events
959          * when it was missed have less value     954          * when it was missed have less value for us */
960         if ( tpDigitizerHasTriggered && edDigi    955         if ( tpDigitizerHasTriggered && edDigitizerMonitorHasTriggered )
961             FillTPTHistos( tpStore, pmData, tr    956             FillTPTHistos( tpStore, pmData, triggeredAngularRanges );
962                                                   957 
963         if ( reconstructorHasBasicTrigger )       958         if ( reconstructorHasBasicTrigger )
964             FillRTHistos( reconstructorHasFull    959             FillRTHistos( reconstructorHasFullTrigger, edStore, tpStore,
965                           pmData, triggeredAng    960                           pmData, triggeredAngularRanges );
966 #endif                                            961 #endif
967                                                   962 
968         G4Event *  theEvent( const_cast< G4Eve    963         G4Event *  theEvent( const_cast< G4Event * >( event ) );
969         if ( eventInfo )                          964         if ( eventInfo )
970         {                                         965         {
971             delete eventInfo;                     966             delete eventInfo;
972             theEvent->SetUserInformation( NULL    967             theEvent->SetUserInformation( NULL );
973         }                                         968         }
974         theEvent->SetUserInformation( new Cexm    969         theEvent->SetUserInformation( new CexmcEventInfo(
975                                                   970                                                 edDigitizerHasTriggered,
976                                                   971                                                 tpDigitizerHasTriggered,
977                                                   972                                                 reconstructorHasFullTrigger ) );
978     }                                             973     }
979     catch ( CexmcException &  e )                 974     catch ( CexmcException &  e )
980     {                                             975     {
981         G4cout << e.what() << G4endl;             976         G4cout << e.what() << G4endl;
982     }                                             977     }
983     catch ( ... )                                 978     catch ( ... )
984     {                                             979     {
985         G4cout << "Unknown exception caught" <    980         G4cout << "Unknown exception caught" << G4endl;
986     }                                             981     }
987                                                   982 
988     delete edStore;                               983     delete edStore;
989     delete tpStore;                               984     delete tpStore;
990 }                                                 985 }
991                                                   986 
992                                                   987