Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExG4HbookNtupleManager.cc
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 // $Id$
27 //
28 /// \file common/analysis/src/ExG4HbookNtupleManager.cc
29 /// \brief Implementation of the ExG4HbookNtupleManager class
30 
31 // Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
32 
33 #ifdef G4_USE_HBOOK
34 
36 #include "ExG4HbookFileManager.hh"
38 #include "G4UnitsTable.hh"
39 
40 #include <iostream>
41 
42 //_____________________________________________________________________________
43 ExG4HbookNtupleManager::ExG4HbookNtupleManager(const G4AnalysisManagerState& state)
44  : G4VNtupleManager(state),
45  fNtupleHbookIdOffset(-1),
46  fNtupleVector()
47 {
48 }
49 
50 //_____________________________________________________________________________
51 ExG4HbookNtupleManager::~ExG4HbookNtupleManager()
52 {
53  // Reset();
54 
55  std::vector<ExG4HbookNtupleDescription*>::iterator it;
56  for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
57  delete *it;
58  }
59 }
60 
61 //
62 // private methods
63 //
64 
65 //_____________________________________________________________________________
66 void ExG4HbookNtupleManager::SetNtupleHbookIdOffset()
67 {
68 // Set fH1HbookIdOffset if needed
69 
70  if ( fNtupleHbookIdOffset == -1 ) {
71  if ( fFirstId > 0 )
72  fNtupleHbookIdOffset = 0;
73  else
74  fNtupleHbookIdOffset = 1;
75 
76  if ( fNtupleHbookIdOffset > 0 ) {
77  G4ExceptionDescription description;
78  description << "Ntuple will be defined in HBOOK with ID = G4_firstNtupleId + 1";
79  G4Exception("ExG4HbookNtupleManager::SetNtupleHbookIdOffset()",
80  "Analysis_W011", JustWarning, description);
81  }
82  }
83 }
84 
85 //_____________________________________________________________________________
86 void ExG4HbookNtupleManager::CreateNtuplesFromBooking()
87 {
88 // Create ntuple from ntuple_booking.
89 
90  if ( ! fNtupleVector.size() ) return;
91 
92  // Set fNtupleHbookIdOffset if needed
93  SetNtupleHbookIdOffset();
94 
95  G4int index = 0;
96  std::vector<ExG4HbookNtupleDescription*>::iterator itn;
97  for (itn = fNtupleVector.begin(); itn != fNtupleVector.end(); itn++ ) {
98 
99  tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
100  if ( ! ntupleBooking ) continue;
101 
102 #ifdef G4VERBOSE
103  if ( fState.GetVerboseL4() )
104  fState.GetVerboseL4()
105  ->Message("create from booking", "ntuple", ntupleBooking->m_name);
106 #endif
107 
108  // Create an "ntuple" directory both in memory and in the file
109  fFileManager->CreateNtupleDirectory();
110  G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
111  ++index;
112 
113  // We should be under //PAWC/LUN1/ntuple
114  (*itn)->fNtuple
115  = new tools::hbook::wntuple(hbookIndex, G4cout, *ntupleBooking);
116  if ( ntupleBooking->m_columns.size() ) {
117  // store ntuple columns in local maps
118  const std::vector<tools::ntuple_booking::col_t>& columns
119  = ntupleBooking->m_columns;
120  std::vector<tools::ntuple_booking::col_t>::const_iterator it;
121  G4int counter = 0;
122  for ( it = columns.begin(); it!=columns.end(); ++it) {
123  if ( (*it).second == tools::_cid(int(0) ) ) {
124  (*itn)->fNtupleIColumnMap[counter++]
125  = (*itn)->fNtuple->find_column<int>((*it).first);
126  }
127  else if( (*it).second == tools::_cid(float(0) ) ) {
128  (*itn)->fNtupleFColumnMap[counter++]
129  = (*itn)->fNtuple->find_column<float>((*it).first);
130  }
131  else if((*it).second== tools::_cid(double(0))) {
132  (*itn)->fNtupleDColumnMap[counter++]
133  = (*itn)->fNtuple->find_column<double>((*it).first);
134  }
135  else {
136  G4ExceptionDescription description;
137  description << " "
138  << "Unsupported column type " << (*it).first;
139  G4Exception("G4HbookAnalysisManager::CreateNtupleFromBooking()",
140  "Analysis_W004", JustWarning, description);
141  }
142  }
143  }
144  FinishNtuple();
145 #ifdef G4VERBOSE
146  if ( fState.GetVerboseL3() )
147  fState.GetVerboseL3()
148  ->Message("create from booking", "ntuple", ntupleBooking->m_name);
149 #endif
150  }
151 }
152 
153 //_____________________________________________________________________________
154 tools::hbook::wntuple::column<int>*
155 ExG4HbookNtupleManager::GetNtupleIColumn(G4int ntupleId, G4int columnId) const
156 {
157  ExG4HbookNtupleDescription* ntupleDecription
158  = GetNtupleInFunction(ntupleId, "GetNtupleIColumn");
159  if ( ! ntupleDecription ) return 0;
160 
161  std::map<G4int, tools::hbook::wntuple::column<int>* >& ntupleIColumnMap
162  = ntupleDecription->fNtupleIColumnMap;
163  std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
164  = ntupleIColumnMap.find(columnId);
165  if ( it == ntupleIColumnMap.end() ) {
166  G4ExceptionDescription description;
167  description << " " << "ntupleId " << ntupleId
168  << "column " << columnId << " does not exist.";
169  G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
170  "Analysis_W009", JustWarning, description);
171  return 0;
172  }
173 
174  return it->second;
175 }
176 
177 //_____________________________________________________________________________
178 tools::hbook::wntuple::column<float>*
179 ExG4HbookNtupleManager::GetNtupleFColumn(G4int ntupleId, G4int columnId) const
180 {
181  ExG4HbookNtupleDescription* ntupleDecription
182  = GetNtupleInFunction(ntupleId, "GetNtupleFColumn");
183  if ( ! ntupleDecription ) return 0;
184 
185  std::map<G4int, tools::hbook::wntuple::column<float>* >& ntupleFColumnMap
186  = ntupleDecription->fNtupleFColumnMap;
187  std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
188  = ntupleFColumnMap.find(columnId);
189  if ( it == ntupleFColumnMap.end() ) {
190  G4ExceptionDescription description;
191  description << " " << "ntupleId " << ntupleId
192  << "column " << columnId << " does not exist.";
193  G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
194  "Analysis_W009", JustWarning, description);
195  return 0;
196  }
197 
198  return it->second;
199 }
200 
201 //_____________________________________________________________________________
202 tools::hbook::wntuple::column<double>*
203 ExG4HbookNtupleManager::GetNtupleDColumn(G4int ntupleId, G4int columnId) const
204 {
205  ExG4HbookNtupleDescription* ntupleDecription
206  = GetNtupleInFunction(ntupleId, "GetNtupleDColumn");
207  if ( ! ntupleDecription ) return 0;
208 
209  std::map<G4int, tools::hbook::wntuple::column<double>* >& ntupleDColumnMap
210  = ntupleDecription->fNtupleDColumnMap;
211  std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
212  = ntupleDColumnMap.find(columnId);
213  if ( it == ntupleDColumnMap.end() ) {
214  G4ExceptionDescription description;
215  description << " " << "ntupleId " << ntupleId
216  << "column " << columnId << " does not exist.";
217  G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
218  "Analysis_W009", JustWarning, description);
219  return 0;
220  }
221 
222  return it->second;
223 }
224 
225 //_____________________________________________________________________________
226 void ExG4HbookNtupleManager::Reset()
227 {
228 // Reset ntuple
229 
230  std::vector<ExG4HbookNtupleDescription*>::iterator it3;
231  for (it3 = fNtupleVector.begin(); it3 != fNtupleVector.end(); it3++ ) {
232  delete (*it3)->fNtuple;
233  (*it3)->fNtuple = 0;
234  }
235 }
236 
237 //
238 // protected methods
239 //
240 
241 //_____________________________________________________________________________
242 ExG4HbookNtupleDescription* ExG4HbookNtupleManager::GetNtupleInFunction(
243  G4int id,
244  G4String functionName, G4bool warn,
245  G4bool /*onlyIfActive*/) const
246 {
247  G4int index = id - fFirstId;
248  if ( index < 0 || index >= G4int(fNtupleVector.size()) ) {
249  if ( warn) {
250  G4String inFunction = "G4HbookAnalysisManager::";
251  inFunction += functionName;
252  G4ExceptionDescription description;
253  description << " " << "ntuple " << id << " does not exist.";
254  G4Exception(inFunction, "Analysis_W007", JustWarning, description);
255  }
256  return 0;
257  }
258 
259  return fNtupleVector[index];
260 }
261 
262 //
263 // public methods
264 //
265 
266 //_____________________________________________________________________________
267 G4int ExG4HbookNtupleManager::CreateNtuple(const G4String& name,
268  const G4String& title)
269 {
270  // Create an "ntuple" directory both in memory and in the file
271  if ( fFileManager->IsFile() )
272  fFileManager->CreateNtupleDirectory();
273 
274 #ifdef G4VERBOSE
275  if ( fState.GetVerboseL4() )
276  fState.GetVerboseL4()->Message("create", "ntuple", name);
277 #endif
278 
279  // Create ntuple description
280  G4int index = fNtupleVector.size();
281  ExG4HbookNtupleDescription* ntupleDescription
282  = new ExG4HbookNtupleDescription();
283  fNtupleVector.push_back(ntupleDescription);
284 
285  // Create ntuple booking
286  ntupleDescription->fNtupleBooking = new tools::ntuple_booking();
287  ntupleDescription->fNtupleBooking->m_name = name;
288  ntupleDescription->fNtupleBooking->m_title = title;
289  // ntuple booking object is deleted in destructor
290 
291  // Set fNtupleHbookIdOffset if needed
292  SetNtupleHbookIdOffset();
293 
294  // Create ntuple if the file is open
295  // We should be under //PAWC/LUN1/ntuple
296  if ( fFileManager->IsFile() ) {
297  G4int hbookIndex = fNtupleHbookIdOffset + index + fFirstId;
298  ntupleDescription->fNtuple
299  = new tools::hbook::wntuple(hbookIndex, name);
300  // ntuple object is deleted when closing a file
301  }
302 
303 #ifdef G4VERBOSE
304  if ( fState.GetVerboseL2() ) {
305  G4ExceptionDescription description;
306  description << name << " ntupleId " << index + fFirstId;
307  fState.GetVerboseL2()->Message("create", "ntuple", description);
308  }
309 #endif
310 
311  return index + fFirstId;
312 }
313 
314 //_____________________________________________________________________________
315 G4int ExG4HbookNtupleManager::CreateNtupleIColumn(const G4String& name)
316 {
317  G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
318  return CreateNtupleIColumn(ntupleId, name);
319 }
320 
321 //_____________________________________________________________________________
322 G4int ExG4HbookNtupleManager::CreateNtupleFColumn(const G4String& name)
323 {
324  G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
325  return CreateNtupleFColumn(ntupleId, name);
326 }
327 
328 //_____________________________________________________________________________
329 G4int ExG4HbookNtupleManager::CreateNtupleDColumn(const G4String& name)
330 {
331  G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
332  return CreateNtupleDColumn(ntupleId, name);
333 }
334 
335 //_____________________________________________________________________________
336 void ExG4HbookNtupleManager::FinishNtuple()
337 {
338  G4int ntupleId = fNtupleVector.size() + fFirstId - 1;
339  FinishNtuple(ntupleId);
340 }
341 
342 //_____________________________________________________________________________
343 G4int ExG4HbookNtupleManager::CreateNtupleIColumn(G4int ntupleId,
344  const G4String& name)
345 {
346 #ifdef G4VERBOSE
347  if ( fState.GetVerboseL4() ) {
348  G4ExceptionDescription description;
349  description << name << " ntupleId " << ntupleId;
350  fState.GetVerboseL4()->Message("create", "ntuple I column", description);
351  }
352 #endif
353 
354  ExG4HbookNtupleDescription* ntupleDescription
355  = GetNtupleInFunction(ntupleId, "CreateNtupleIColumn");
356  tools::ntuple_booking* ntupleBooking
357  = ntupleDescription->fNtupleBooking;
358 
359  if ( ! ntupleBooking ) {
360  G4ExceptionDescription description;
361  description << " "
362  << "Ntuple " << ntupleId << " has to be created first. ";
363  G4Exception("G4HbookAnalysisManager::CreateNtupleIColumn()",
364  "Analysis_W005", JustWarning, description);
365  return -1;
366  }
367 
368  // Save column info in booking
369  G4int index = ntupleBooking->m_columns.size();
370  ntupleBooking->add_column<int>(name);
371 
372  // Create column if ntuple already exists
373  if ( ntupleDescription->fNtuple ) {
374  tools::hbook::wntuple::column<int>* column
375  = ntupleDescription->fNtuple->create_column<int>(name);
376  ntupleDescription->fNtupleIColumnMap[index] = column;
377  }
378 
379  fLockFirstNtupleColumnId = true;
380 
381 #ifdef G4VERBOSE
382  if ( fState.GetVerboseL2() ) {
383  G4ExceptionDescription description;
384  description << name << " ntupleId " << ntupleId;
385  fState.GetVerboseL2()->Message("create", "ntuple I column", description);
386  }
387 #endif
388 
389  return index + fFirstNtupleColumnId;
390 }
391 
392 //_____________________________________________________________________________
393 G4int ExG4HbookNtupleManager::CreateNtupleFColumn(G4int ntupleId,
394  const G4String& name)
395 {
396 #ifdef G4VERBOSE
397  if ( fState.GetVerboseL4() ) {
398  G4ExceptionDescription description;
399  description << name << " ntupleId " << ntupleId;
400  fState.GetVerboseL4()->Message("create", "ntuple F column", description);
401  }
402 #endif
403 
404  ExG4HbookNtupleDescription* ntupleDescription
405  = GetNtupleInFunction(ntupleId, "CreateNtupleFColumn");
406  tools::ntuple_booking* ntupleBooking
407  = ntupleDescription->fNtupleBooking;
408 
409  if ( ! ntupleBooking ) {
410  G4ExceptionDescription description;
411  description << " "
412  << "Ntuple " << ntupleId << " has to be created first. ";
413  G4Exception("G4HbookAnalysisManager::CreateNtupleFColumn()",
414  "Analysis_W005", JustWarning, description);
415  return -1;
416  }
417 
418  // Save column info in booking
419  G4int index = ntupleBooking->m_columns.size();
420  ntupleBooking->add_column<float>(name);
421 
422  // Create column if ntuple already exists
423  if ( ntupleDescription->fNtuple ) {
424  tools::hbook::wntuple::column<float>* column
425  = ntupleDescription->fNtuple->create_column<float>(name);
426  ntupleDescription->fNtupleFColumnMap[index] = column;
427  }
428 
429  fLockFirstNtupleColumnId = true;
430 
431 #ifdef G4VERBOSE
432  if ( fState.GetVerboseL2() ) {
433  G4ExceptionDescription description;
434  description << name << " ntupleId " << ntupleId;
435  fState.GetVerboseL2()->Message("create", "ntuple F column", description);
436  }
437 #endif
438 
439  return index + fFirstNtupleColumnId;
440 }
441 
442 
443 //_____________________________________________________________________________
444 G4int ExG4HbookNtupleManager::CreateNtupleDColumn(G4int ntupleId,
445  const G4String& name)
446 {
447 #ifdef G4VERBOSE
448  if ( fState.GetVerboseL4() ) {
449  G4ExceptionDescription description;
450  description << name << " ntupleId " << ntupleId;
451  fState.GetVerboseL4()->Message("create", "ntuple D column", description);
452  }
453 #endif
454 
455  ExG4HbookNtupleDescription* ntupleDescription
456  = GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
457  tools::ntuple_booking* ntupleBooking
458  = ntupleDescription->fNtupleBooking;
459 
460  if ( ! ntupleBooking ) {
461  G4ExceptionDescription description;
462  description << " "
463  << "Ntuple " << ntupleId << " has to be created first. ";
464  G4Exception("G4HbookAnalysisManager::CreateNtupleDColumn()",
465  "Analysis_W005", JustWarning, description);
466  return -1;
467  }
468 
469  // Save column info in booking
470  G4int index = ntupleBooking->m_columns.size();
471  ntupleBooking->add_column<double>(name);
472 
473  // Create column if ntuple already exists
474  if ( ntupleDescription->fNtuple ) {
475  tools::hbook::wntuple::column<double>* column
476  = ntupleDescription->fNtuple->create_column<double>(name);
477  ntupleDescription->fNtupleDColumnMap[index] = column;
478  }
479 
480  fLockFirstNtupleColumnId = true;
481 
482 #ifdef G4VERBOSE
483  if ( fState.GetVerboseL2() ) {
484  G4ExceptionDescription description;
485  description << name << " ntupleId " << ntupleId;
486  fState.GetVerboseL2()->Message("create", "ntuple D column", description);
487  }
488 #endif
489 
490  return index + fFirstNtupleColumnId;
491 }
492 
493 //_____________________________________________________________________________
494 void ExG4HbookNtupleManager::FinishNtuple(G4int ntupleId)
495 {
496  ExG4HbookNtupleDescription* ntupleDescription
497  = GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
498  tools::hbook::wntuple* ntuple = ntupleDescription->fNtuple;
499 
500  if ( ! ntuple ) return;
501 
502 #ifdef G4VERBOSE
503  if ( fState.GetVerboseL4() )
504  fState.GetVerboseL4()
505  ->Message("finish", "ntuple", ntupleDescription->fNtupleBooking->m_name);
506 #endif
507 
508  // Return to //PAWC/LUN1 :
509  tools::hbook::CHCDIR("//PAWC/LUN1"," ");
510 
511  //fNtuple->add_row_beg();
512 #ifdef G4VERBOSE
513  if ( fState.GetVerboseL2() )
514  fState.GetVerboseL2()
515  ->Message("finish", "ntuple", ntupleDescription->fNtupleBooking->m_name);
516 #endif
517 }
518 
519 //_____________________________________________________________________________
520 G4bool ExG4HbookNtupleManager::FillNtupleIColumn(G4int columnId, G4int value)
521 {
522  return FillNtupleIColumn(fFirstId, columnId, value);
523 }
524 
525 //_____________________________________________________________________________
526 G4bool ExG4HbookNtupleManager::FillNtupleFColumn(G4int columnId, G4float value)
527 {
528  return FillNtupleFColumn(fFirstId, columnId, value);
529 }
530 
531 //_____________________________________________________________________________
532 G4bool ExG4HbookNtupleManager::FillNtupleDColumn(G4int columnId, G4double value)
533 {
534  return FillNtupleDColumn(fFirstId, columnId, value);
535 }
536 
537 //_____________________________________________________________________________
538 G4bool ExG4HbookNtupleManager::AddNtupleRow()
539 {
540  return AddNtupleRow(fFirstId);
541 }
542 
543 //_____________________________________________________________________________
544 G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
545  G4int ntupleId, G4int columnId,
546  G4int value)
547 {
548  tools::hbook::wntuple::column<int>* column
549  = GetNtupleIColumn(ntupleId, columnId);
550  if ( ! column ) {
551  G4ExceptionDescription description;
552  description << " " << "ntupleId " << ntupleId
553  << "column " << columnId << " does not exist.";
554  G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
555  "Analysis_W009", JustWarning, description);
556  return false;
557  }
558 
559  column->fill(value);
560  #ifdef G4VERBOSE
561  if ( fState.GetVerboseL4() ) {
562  G4ExceptionDescription description;
563  description << " ntupleId " << ntupleId
564  << " columnId " << columnId << " value " << value;
565  fState.GetVerboseL4()->Message("fill", "ntuple I column", description);
566  }
567 #endif
568  return true;
569 }
570 //_____________________________________________________________________________
571 G4bool ExG4HbookNtupleManager::FillNtupleFColumn(
572  G4int ntupleId, G4int columnId,
573  G4float value)
574 {
575  tools::hbook::wntuple::column<float>* column
576  = GetNtupleFColumn(ntupleId, columnId);
577  if ( ! column ) {
578  G4ExceptionDescription description;
579  description << " " << "ntupleId " << ntupleId
580  << "column " << columnId << " does not exist.";
581  G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
582  "Analysis_W009", JustWarning, description);
583  return false;
584  }
585 
586  column->fill(value);
587 #ifdef G4VERBOSE
588  if ( fState.GetVerboseL4() ) {
589  G4ExceptionDescription description;
590  description << " ntupleId " << ntupleId
591  << " columnId " << columnId << " value " << value;
592  fState.GetVerboseL4()->Message("fill", "ntuple F column", description);
593  }
594 #endif
595  return true;
596 }
597 //_____________________________________________________________________________
598 G4bool ExG4HbookNtupleManager::FillNtupleDColumn(
599  G4int ntupleId, G4int columnId,
600  G4double value)
601 {
602  tools::hbook::wntuple::column<double>* column
603  = GetNtupleDColumn(ntupleId, columnId);
604  if ( ! column ) {
605  G4ExceptionDescription description;
606  description << " " << "ntupleId " << ntupleId
607  << "column " << columnId << " does not exist.";
608  G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
609  "Analysis_W009", JustWarning, description);
610  return false;
611  }
612 
613  column->fill(value);
614 #ifdef G4VERBOSE
615  if ( fState.GetVerboseL4() ) {
616  G4ExceptionDescription description;
617  description << " ntupleId " << ntupleId
618  << " columnId " << columnId << " value " << value;
619  fState.GetVerboseL4()->Message("fill", "ntuple D column", description);
620  }
621 #endif
622  return true;
623 }
624 
625 //_____________________________________________________________________________
626 G4bool ExG4HbookNtupleManager::AddNtupleRow(G4int ntupleId)
627 {
628 #ifdef G4VERBOSE
629  if ( fState.GetVerboseL4() ) {
630  G4ExceptionDescription description;
631  description << " ntupleId " << ntupleId;
632  fState.GetVerboseL4()->Message("add", "ntuple row", description);
633  }
634 #endif
635 
636  ExG4HbookNtupleDescription* ntupleDescription
637  = GetNtupleInFunction(ntupleId, "AddNtupleRow");
638 
639  if ( ! ntupleDescription || ! ntupleDescription->fNtuple ) {
640  G4ExceptionDescription description;
641  description << " " << " ntupleId " << ntupleId
642  << " does not exist. ";
643  G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
644  "Analysis_W008", JustWarning, description);
645  return false;
646  }
647 
648  ntupleDescription->fNtuple->add_row();
649 #ifdef G4VERBOSE
650  if ( fState.GetVerboseL4() ) {
651  G4ExceptionDescription description;
652  description << " ntupleId " << ntupleId;
653  fState.GetVerboseL4()->Message("add", "ntuple row", description, true);
654  }
655 #endif
656  return true;
657 }
658 
659 //_____________________________________________________________________________
660 tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple() const
661 {
662  return GetNtuple(fFirstId);
663 }
664 
665 //_____________________________________________________________________________
666 tools::hbook::wntuple* ExG4HbookNtupleManager::GetNtuple(G4int ntupleId) const
667 {
668  ExG4HbookNtupleDescription* ntupleDescription
669  = GetNtupleInFunction(ntupleId, "GetNtuple");
670 
671  return ntupleDescription->fNtuple;
672 }
673 
674 //_____________________________________________________________________________
675 G4bool ExG4HbookNtupleManager::SetNtupleHbookIdOffset(G4int offset)
676 {
677  if ( fNtupleVector.size() ) {
678  G4ExceptionDescription description;
679  description
680  << "Cannot set NtupleHbookIdOffset as some ntuples already exist.";
681  G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
682  "Analysis_W009", JustWarning, description);
683  return false;
684  }
685 
686  if ( fFirstId + offset < 1 ) {
687  G4ExceptionDescription description;
688  description << "The first ntuple HBOOK id must be >= 1.";
689  G4Exception("G4HbookAnalysisManager::SetNtupleHbookIdOffset()",
690  "Analysis_W009", JustWarning, description);
691  return false;
692  }
693 
694  fNtupleHbookIdOffset = offset;
695  return true;
696 }
697 
698 #endif
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
float G4float
Definition: G4Types.hh:77
const XML_Char * name
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
Definition of the ExG4HbookNtupleManager class.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
Definition of the ExG4HbookFileManager class.