Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CexmcHistoManager.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * =============================================================================
28  *
29  * Filename: CexmcHistoManager.hh
30  *
31  * Description: histograming manager (singleton)
32  *
33  * Version: 1.0
34  * Created: 26.11.2009 20:55:16
35  * Revision: none
36  * Compiler: gcc
37  *
38  * Author: Alexey Radkov (),
39  * Company: PNPI
40  *
41  * =============================================================================
42  */
43 
44 #ifndef CEXMC_HISTO_MANAGER_HH
45 #define CEXMC_HISTO_MANAGER_HH
46 
47 #ifdef CEXMC_USE_ROOT
48 
49 #include <vector>
50 #include <map>
51 #include <Rtypes.h>
52 #include <G4String.hh>
53 #include "CexmcAngularRange.hh"
54 #include "CexmcCommon.hh"
55 
56 class TFile;
57 class TH1;
58 #ifdef CEXMC_USE_ROOTQT
59 class TQtWidget;
60 #endif
61 class CexmcHistoManagerMessenger;
62 
63 
64 enum CexmcHistoType
65 {
66  CexmcMomentumBP_TPT_Histo,
67  CexmcMomentumBP_RT_Histo,
68  CexmcMomentumIP_TPT_Histo,
69  CexmcTPInMonitor_TPT_Histo,
70  CexmcTPInTarget_TPT_Histo,
71  CexmcTPInTarget_RT_Histo,
72  CexmcRecMasses_EDT_Histo,
73  CexmcRecMasses_RT_Histo,
74  CexmcAbsorbedEnergy_EDT_Histo,
75  CexmcAbsorbedEnergy_RT_Histo,
76  CexmcHistoType_ARReal_START,
77  CexmcRecMassOP_ARReal_RT_Histo = CexmcHistoType_ARReal_START,
78  CexmcRecMassNOP_ARReal_RT_Histo,
79  CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
80  CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
81  CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
82  CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
83  CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
84  CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
85  CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
86  CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
87  CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
88  CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
89  CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
90  CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
91  CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
92  CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
93  CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
94  CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
95  CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
96  CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
97  CexmcKinEnOP_LAB_ARReal_TPT_Histo,
98  CexmcKinEnOP_LAB_ARReal_RT_Histo,
99  CexmcAngleOP_SCM_ARReal_TPT_Histo,
100  CexmcAngleOP_SCM_ARReal_RT_Histo,
101  CexmcRecAngleOP_SCM_ARReal_RT_Histo,
102  CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
103  CexmcOpenAngle_ARReal_TPT_Histo,
104  CexmcOpenAngle_ARReal_RT_Histo,
105  CexmcRecOpenAngle_ARReal_RT_Histo,
106  CexmcDiffOpenAngle_ARReal_RT_Histo,
107  CexmcTPInTarget_ARReal_TPT_Histo,
108  CexmcTPInTarget_ARReal_RT_Histo,
109  CexmcHistoType_ARReal_END = CexmcTPInTarget_ARReal_RT_Histo,
110  CexmcHistoType_SIZE
111 };
112 
113 
114 class CexmcHistoManager
115 {
116  private:
117  typedef std::vector< TH1 * > CexmcHistoVector;
118 
119  typedef std::map< CexmcHistoType, CexmcHistoVector > CexmcHistosMap;
120 
121  typedef CexmcHistosMap::value_type CexmcHistoPair;
122 
123  struct CexmcHistoAxisData
124  {
125  CexmcHistoAxisData() : nBins( 0 ), nBinsMin( 0 ), nBinsMax( 0 )
126  {}
127 
128  CexmcHistoAxisData( Int_t nBins, Double_t nBinsMin,
129  Double_t nBinsMax ) :
130  nBins( nBins ), nBinsMin( nBinsMin ), nBinsMax( nBinsMax )
131  {}
132 
133  Int_t nBins;
134 
135  Double_t nBinsMin;
136 
137  Double_t nBinsMax;
138  };
139 
140  typedef std::vector< CexmcHistoAxisData > CexmcHistoAxes;
141 
142  enum CexmcHistoImpl
143  {
144  Cexmc_TH1F,
145  Cexmc_TH2F,
146  Cexmc_TH3F
147  };
148 
149  struct CexmcHistoData
150  {
151  CexmcHistoData() :
152  type( CexmcHistoType_SIZE ), impl( Cexmc_TH1F ),
153  isARHisto( false ), isARRec( false ), triggerType( CexmcTPT )
154  {}
155 
156  CexmcHistoData( CexmcHistoType type, CexmcHistoImpl impl,
157  bool isARHisto, bool isARRec,
158  CexmcTriggerType triggerType,
159  const G4String & name, const G4String & title,
160  const CexmcHistoAxes & axes ) :
161  type( type ), impl( impl ), isARHisto( isARHisto ),
162  isARRec( isARRec ), triggerType( triggerType ), name( name ),
163  title( title ), axes( axes )
164  {}
165 
166  CexmcHistoType type;
167 
168  CexmcHistoImpl impl;
169 
170  bool isARHisto;
171 
172  bool isARRec;
173 
174  CexmcTriggerType triggerType;
175 
176  G4String name;
177 
178  G4String title;
179 
180  CexmcHistoAxes axes;
181  };
182 
183  public:
184  static CexmcHistoManager * Instance( void );
185 
186  static void Destroy( void );
187 
188  private:
189  CexmcHistoManager();
190 
191  ~CexmcHistoManager();
192 
193  public:
194  void Initialize( void );
195 
196  void SetupARHistos( const CexmcAngularRangeList & aRanges );
197 
198  void AddARHistos( const CexmcAngularRange & aRange );
199 
200  void Add( CexmcHistoType histoType, unsigned int index,
201  G4double x );
202 
203  void Add( CexmcHistoType histoType, unsigned int index, G4double x,
204  G4double y );
205 
206  void Add( CexmcHistoType histoType, unsigned int index, G4double x,
207  G4double y, G4double z );
208 
209  void Add( CexmcHistoType histoType, unsigned int index, G4int binX,
210  G4int binY, G4double value );
211 
212  void List( void ) const;
213 
214  void Print( const G4String & value );
215 
216 #ifdef CEXMC_USE_ROOTQT
217  void Draw( const G4String & histoName,
218  const G4String & histoDrawOptions = "" );
219 #endif
220 
221  public:
222  void SetVerboseLevel( G4int value );
223 
224  G4int GetVerboseLevel( void ) const;
225 
226  private:
227  void AddHisto( const CexmcHistoData & data,
228  const CexmcAngularRange & aRange = CexmcAngularRange() );
229 
230  void CreateHisto( CexmcHistoVector & histoVector,
231  CexmcHistoImpl histoImpl, const G4String & name,
232  const G4String & title,
233  const CexmcHistoAxes & axes );
234 
235  private:
236  TFile * outFile;
237 
238  private:
239  CexmcHistosMap histos;
240 
241  bool isInitialized;
242 
243  G4String opName;
244 
245  G4String nopName;
246 
247  G4double opMass;
248 
249  G4double nopMass;
250 
251  G4int verboseLevel;
252 
253 #ifdef CEXMC_USE_ROOTQT
254  private:
255 
256  TQtWidget * rootCanvas;
257 #endif
258 
259  private:
260  CexmcHistoManagerMessenger * messenger;
261 
262  private:
263  static CexmcHistoManager * instance;
264 };
265 
266 
267 inline void CexmcHistoManager::SetVerboseLevel( G4int value )
268 {
269  verboseLevel = value;
270 }
271 
272 
273 inline G4int CexmcHistoManager::GetVerboseLevel( void ) const
274 {
275  return verboseLevel;
276 }
277 
278 #endif
279 
280 #endif
281