Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
CexmcHistoManager.hh
이 파일의 문서화 페이지로 가기
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 TDirectoryFile;
57 class TH1;
58 #ifdef CEXMC_USE_ROOTQT
59 class TQtWidget;
60 class TList;
61 class G4UIsession;
62 class G4UIQt;
63 #endif
64 class CexmcHistoManagerMessenger;
65 
66 
67 enum CexmcHistoType
68 {
69  CexmcMomentumBP_TPT_Histo,
70  CexmcMomentumBP_RT_Histo,
71  CexmcMomentumIP_TPT_Histo,
72  CexmcTPInMonitor_TPT_Histo,
73  CexmcTPInTarget_TPT_Histo,
74  CexmcTPInTarget_RT_Histo,
75  CexmcRecMasses_EDT_Histo,
76  CexmcRecMasses_RT_Histo,
77  CexmcAbsorbedEnergy_EDT_Histo,
78  CexmcAbsorbedEnergy_RT_Histo,
79  CexmcHistoType_ARReal_START,
80  CexmcRecMassOP_ARReal_RT_Histo = CexmcHistoType_ARReal_START,
81  CexmcRecMassNOP_ARReal_RT_Histo,
82  CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
83  CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
84  CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
85  CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
86  CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
87  CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
88  CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
89  CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
90  CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
91  CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
92  CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
93  CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
94  CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
95  CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
96  CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
97  CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
98  CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
99  CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
100  CexmcKinEnOP_LAB_ARReal_TPT_Histo,
101  CexmcKinEnOP_LAB_ARReal_RT_Histo,
102  CexmcAngleOP_SCM_ARReal_TPT_Histo,
103  CexmcAngleOP_SCM_ARReal_RT_Histo,
104  CexmcRecAngleOP_SCM_ARReal_RT_Histo,
105  CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
106  CexmcOpenAngle_ARReal_TPT_Histo,
107  CexmcOpenAngle_ARReal_RT_Histo,
108  CexmcRecOpenAngle_ARReal_RT_Histo,
109  CexmcDiffOpenAngle_ARReal_RT_Histo,
110  CexmcTPInTarget_ARReal_TPT_Histo,
111  CexmcTPInTarget_ARReal_RT_Histo,
112  CexmcHistoType_ARReal_END = CexmcTPInTarget_ARReal_RT_Histo,
113  CexmcHistoType_SIZE
114 };
115 
116 
117 class CexmcHistoManager
118 {
119  private:
120  typedef std::vector< TH1 * > CexmcHistoVector;
121 
122  typedef std::map< CexmcHistoType, CexmcHistoVector > CexmcHistosMap;
123 
124  typedef CexmcHistosMap::value_type CexmcHistoPair;
125 
126  struct CexmcHistoAxisData
127  {
128  CexmcHistoAxisData() : nBins( 0 ), nBinsMin( 0 ), nBinsMax( 0 )
129  {}
130 
131  CexmcHistoAxisData( Int_t nBins_, Double_t nBinsMin_,
132  Double_t nBinsMax_ ) :
133  nBins( nBins_ ), nBinsMin( nBinsMin_ ), nBinsMax( nBinsMax_ )
134  {}
135 
136  Int_t nBins;
137 
138  Double_t nBinsMin;
139 
140  Double_t nBinsMax;
141  };
142 
143  typedef std::vector< CexmcHistoAxisData > CexmcHistoAxes;
144 
145  enum CexmcHistoImpl
146  {
147  Cexmc_TH1F,
148  Cexmc_TH2F,
149  Cexmc_TH3F
150  };
151 
152  struct CexmcHistoData
153  {
154  CexmcHistoData() :
155  type( CexmcHistoType_SIZE ), impl( Cexmc_TH1F ),
156  isARHisto( false ), isARRec( false ), triggerType( CexmcTPT )
157  {}
158 
159  CexmcHistoData( CexmcHistoType type_, CexmcHistoImpl impl_,
160  bool isARHisto_, bool isARRec_,
161  CexmcTriggerType triggerType_,
162  const G4String & name_, const G4String & title_,
163  const CexmcHistoAxes & axes_ ) :
164  type( type_ ), impl( impl_ ), isARHisto( isARHisto_ ),
165  isARRec( isARRec_ ), triggerType( triggerType_ ), name( name_ ),
166  title( title_ ), axes( axes_ )
167  {}
168 
169  CexmcHistoType type;
170 
171  CexmcHistoImpl impl;
172 
173  bool isARHisto;
174 
175  bool isARRec;
176 
177  CexmcTriggerType triggerType;
178 
179  G4String name;
180 
181  G4String title;
182 
183  CexmcHistoAxes axes;
184  };
185 
186  public:
187  static CexmcHistoManager * Instance( void );
188 
189  static void Destroy( void );
190 
191  private:
192  CexmcHistoManager();
193 
194  ~CexmcHistoManager();
195 
196  public:
197  void Initialize( void );
198 
199  void SetupARHistos( const CexmcAngularRangeList & aRanges );
200 
201  void AddARHistos( const CexmcAngularRange & aRange );
202 
203  void Add( CexmcHistoType histoType, unsigned int index,
204  G4double x );
205 
206  void Add( CexmcHistoType histoType, unsigned int index, G4double x,
207  G4double y );
208 
209  void Add( CexmcHistoType histoType, unsigned int index, G4double x,
210  G4double y, G4double z );
211 
212  void Add( CexmcHistoType histoType, unsigned int index, G4int binX,
213  G4int binY, G4double value );
214 
215  void List( void ) const;
216 
217  void Print( const G4String & value );
218 
219 #ifdef CEXMC_USE_ROOTQT
220  void Draw( const G4String & histoName,
221  const G4String & histoDrawOptions = "" );
222 
223  void EnableLiveHistograms( G4UIsession * session, G4bool on = true );
224 
225  void AddHistoMenu( const G4String & handle,
226  const G4String & label = "Histograms" );
227 
228  void SetDrawOptions1D( const G4String & value );
229 
230  void SetDrawOptions2D( const G4String & value );
231 
232  void SetDrawOptions3D( const G4String & value );
233 #endif
234 
235  public:
236  void SetVerboseLevel( G4int value );
237 
238  G4int GetVerboseLevel( void ) const;
239 
240  private:
241  void AddHisto( const CexmcHistoData & data,
242  const CexmcAngularRange & aRange = CexmcAngularRange() );
243 
244  void CreateHisto( CexmcHistoVector & histoVector,
245  CexmcHistoImpl histoImpl, const G4String & name,
246  const G4String & title,
247  const CexmcHistoAxes & axes );
248 
249 #ifdef CEXMC_USE_ROOTQT
250  void BuildMenuTree( G4UIQt * session, const G4String & menu,
251  TList * ls );
252 
253  void AddSubmenu( G4UIQt * session, const G4String & parent,
254  const G4String & name, const G4String & label );
255 #endif
256 
257  private:
258  TDirectoryFile * outFile;
259 
260  private:
261  CexmcHistosMap histos;
262 
263  bool isInitialized;
264 
265  G4String opName;
266 
267  G4String nopName;
268 
269  G4double opMass;
270 
271  G4double nopMass;
272 
273  G4int verboseLevel;
274 
275 #ifdef CEXMC_USE_ROOTQT
276  private:
277  TQtWidget * rootCanvas;
278 
279  G4bool areLiveHistogramsEnabled;
280 
281  G4bool isHistoMenuInitialized;
282 
283  G4String drawOptions1D;
284 
285  G4String drawOptions2D;
286 
287  G4String drawOptions3D;
288 
289  G4String histoMenuHandle;
290 
291  G4String histoMenuLabel;
292 #endif
293 
294  private:
295  CexmcHistoManagerMessenger * messenger;
296 
297  private:
298  static CexmcHistoManager * instance;
299 };
300 
301 
302 inline void CexmcHistoManager::SetVerboseLevel( G4int value )
303 {
304  verboseLevel = value;
305 }
306 
307 
308 inline G4int CexmcHistoManager::GetVerboseLevel( void ) const
309 {
310  return verboseLevel;
311 }
312 
313 #ifdef CEXMC_USE_ROOTQT
314 
315 inline void CexmcHistoManager::AddHistoMenu( const G4String & handle,
316  const G4String & label )
317 {
318  histoMenuHandle = handle;
319  histoMenuLabel = label;
320 }
321 
322 
323 inline void CexmcHistoManager::SetDrawOptions1D( const G4String & value )
324 {
325  drawOptions1D = value;
326 }
327 
328 
329 inline void CexmcHistoManager::SetDrawOptions2D( const G4String & value )
330 {
331  drawOptions2D = value;
332 }
333 
334 
335 inline void CexmcHistoManager::SetDrawOptions3D( const G4String & value )
336 {
337  drawOptions3D = value;
338 }
339 #endif //CEXMC_USE_ROOTQT
340 #endif
341 
342 #endif
343 
Float_t x
Definition: compare.C:6
const XML_Char * name
Definition: expat.h:151
G4double Double_t
static G4UIterminal * session
hist1 Draw("HIST")
Float_t y
Definition: compare.C:6
void Initialize()
Definition: errprop.cc:101
Double_t z
void Add(G4int Elements, T *To, T *A1, T *A2=NULL)
Definition: G4ArrayOps.hh:77
CexmcTriggerType
Definition: CexmcCommon.hh:99
const XML_Char const XML_Char * data
Definition: expat.h:268
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4int Int_t
const XML_Char int const XML_Char * value
Definition: expat.h:331
void Print(G4Element &ele)
Definition: pyG4Element.cc:56
int G4int
Definition: G4Types.hh:78
std::vector< CexmcAngularRange > CexmcAngularRangeList
static MCTruthManager * instance
G4bool isInitialized()
input_file_1 ls()