Geant4  10.01.p03
G4RootNtupleManager.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: G4RootNtupleManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
29 
30 #include "G4RootNtupleManager.hh"
33 #include "G4AnalysisUtilities.hh"
34 
35 #include "tools/wroot/file"
36 
37 using namespace G4Analysis;
38 
39 //_____________________________________________________________________________
41  : G4VNtupleManager(state),
42  fNtupleDirectory(0),
43  fNtupleDescriptionVector(),
44  fNtupleVector()
45 {
46 }
47 
48 //_____________________________________________________________________________
50 {
51  std::vector<G4RootNtupleDescription*>::iterator it;
52  for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
53  delete (*it);
54  }
55 }
56 
57 //
58 // private methods
59 //
60 
61 //_____________________________________________________________________________
62 tools::wroot::ntuple::column<int>*
64 {
65  G4RootNtupleDescription* ntupleDecription
66  = GetNtupleInFunction(ntupleId, "GetNtupleIColumn");
67  if ( ! ntupleDecription ) return 0;
68 
69  std::map<G4int, tools::wroot::ntuple::column<int>* >& ntupleIColumnMap
70  = ntupleDecription->fNtupleIColumnMap;
71  std::map<G4int, tools::wroot::ntuple::column<int>* >::const_iterator it
72  = ntupleIColumnMap.find(columnId);
73 
74  if ( it == ntupleIColumnMap.end() ) {
75  G4ExceptionDescription description;
76  description << " " << "ntupleId " << ntupleId
77  << " columnId " << columnId << " does not exist.";
78  G4Exception("G4RootNtupleManager::GetNtupleIColumn()",
79  "Analysis_W001", JustWarning, description);
80  return 0;
81  }
82 
83  return it->second;
84 }
85 
86 //_____________________________________________________________________________
87 tools::wroot::ntuple::column<float>*
89 {
90  G4RootNtupleDescription* ntupleDecription
91  = GetNtupleInFunction(ntupleId, "GetNtupleFColumn");
92  if ( ! ntupleDecription ) return 0;
93 
94  std::map<G4int, tools::wroot::ntuple::column<float>* >& ntupleFColumnMap
95  = ntupleDecription->fNtupleFColumnMap;
96  std::map<G4int, tools::wroot::ntuple::column<float>* >::const_iterator it
97  = ntupleFColumnMap.find(columnId);
98 
99  if ( it == ntupleFColumnMap.end() ) {
100  G4ExceptionDescription description;
101  description << " " << "ntupleId " << ntupleId
102  << " columnId " << columnId << " does not exist.";
103  G4Exception("G4RootNtupleManager::GetNtupleFColumn()",
104  "Analysis_W001", JustWarning, description);
105  return 0;
106  }
107 
108  return it->second;
109 }
110 
111 
112 //_____________________________________________________________________________
113 tools::wroot::ntuple::column<double>*
115 {
116  G4RootNtupleDescription* ntupleDecription
117  = GetNtupleInFunction(ntupleId, "GetNtupleDColumn");
118  if ( ! ntupleDecription ) return 0;
119 
120  std::map<G4int, tools::wroot::ntuple::column<double>* >& ntupleDColumnMap
121  = ntupleDecription->fNtupleDColumnMap;
122  std::map<G4int, tools::wroot::ntuple::column<double>* >::const_iterator it
123  = ntupleDColumnMap.find(columnId);
124 
125  if ( it == ntupleDColumnMap.end() ) {
126  G4ExceptionDescription description;
127  description << " " << "ntupleId " << ntupleId
128  << " columnId " << columnId << " does not exist.";
129  G4Exception("G4RootNtupleManager::GetNtupleDColumn()",
130  "Analysis_W001", JustWarning, description);
131  return 0;
132  }
133 
134  return it->second;
135 }
136 
137 //_____________________________________________________________________________
138 tools::wroot::ntuple::column_string*
140 {
141  G4RootNtupleDescription* ntupleDecription
142  = GetNtupleInFunction(ntupleId, "GetNtupleSColumn");
143  if ( ! ntupleDecription ) return 0;
144 
145  std::map<G4int, tools::wroot::ntuple::column_string* >& ntupleSColumnMap
146  = ntupleDecription->fNtupleSColumnMap;
147  std::map<G4int, tools::wroot::ntuple::column_string* >::const_iterator it
148  = ntupleSColumnMap.find(columnId);
149 
150  if ( it == ntupleSColumnMap.end() ) {
151  G4ExceptionDescription description;
152  description << " " << "ntupleId " << ntupleId
153  << " columnId " << columnId << " does not exist.";
154  G4Exception("G4RootNtupleManager::GetNtupleSColumn()",
155  "Analysis_W001", JustWarning, description);
156  return 0;
157  }
158 
159  return it->second;
160 }
161 
162 //_____________________________________________________________________________
164  G4String functionName, G4bool warn,
165  G4bool /*onlyIfActive*/) const
166 {
167  G4int index = id - fFirstId;
168  if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
169  if ( warn) {
170  G4String inFunction = "G4RootNtupleManager::";
171  inFunction += functionName;
172  G4ExceptionDescription description;
173  description << " " << "ntuple " << id << " does not exist.";
174  G4Exception(inFunction, "Analysis_W011", JustWarning, description);
175  }
176  return 0;
177  }
178 
179  return fNtupleDescriptionVector[index];
180 }
181 
182 //
183 // protected methods
184 //
185 
186 //_____________________________________________________________________________
188 {
189 // Create ntuple from ntuple_booking.
190 
191  if ( ! fNtupleDescriptionVector.size() ) return;
192 
193  std::vector<G4RootNtupleDescription*>::iterator itn;
194  for (itn = fNtupleDescriptionVector.begin(); itn != fNtupleDescriptionVector.end(); itn++ ) {
195 
196  tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
197  if ( ! ntupleBooking ) continue;
198 
199 #ifdef G4VERBOSE
200  if ( fState.GetVerboseL4() )
202  ->Message("create from booking", "ntuple", ntupleBooking->name());
203 #endif
204 
205  (*itn)->fNtuple
206  = new tools::wroot::ntuple(*fNtupleDirectory, *ntupleBooking);
207  fNtupleVector.push_back((*itn)->fNtuple);
208 
209  if ( ntupleBooking->columns().size() ) {
210  // store ntuple columns in local maps
211  const std::vector<tools::column_booking>& columns
212  = ntupleBooking->columns();
213  std::vector<tools::column_booking>::const_iterator it;
214  G4int index = 0;
215  for ( it = columns.begin(); it!=columns.end(); ++it) {
216  if ( it->cls_id() == tools::_cid(int(0) ) ) {
217  (*itn)->fNtupleIColumnMap[index++]
218  = (*itn)->fNtuple->find_column<int>(it->name());
219  }
220  else if ( it->cls_id() == tools::_cid(float(0) ) ) {
221  (*itn)->fNtupleFColumnMap[index++]
222  = (*itn)->fNtuple->find_column<float>(it->name());
223  }
224  else if ( it->cls_id()== tools::_cid(double(0))) {
225  (*itn)->fNtupleDColumnMap[index++]
226  = (*itn)->fNtuple->find_column<double>(it->name());
227  }
228  else if ( it->cls_id()== tools::_cid(std::string(""))) {
229  (*itn)->fNtupleSColumnMap[index++]
230  = (*itn)->fNtuple->find_column_string(it->name());
231  }
232  else {
233  G4ExceptionDescription description;
234  description << " "
235  << "Unsupported column type " << it->name();
236  G4Exception("G4RootNtupleManager::CreateNtupleFromBooking()",
237  "Analysis_W002", JustWarning, description);
238  }
239  }
240  }
241 #ifdef G4VERBOSE
242  if ( fState.GetVerboseL3() )
244  ->Message("create from booking", "ntuple", ntupleBooking->name());
245 #endif
246  }
247 }
248 
249 //_____________________________________________________________________________
251 {
252  return ! fNtupleDescriptionVector.size();
253 }
254 
255 //_____________________________________________________________________________
257 {
258 // Reset ntuples
259 
260  std::vector<G4RootNtupleDescription*>::iterator it;
261  for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
262  // ntuple is deleted automatically when file is closed
263  // delete (*it)->fNtuple;
264  (*it)->fNtuple=0;
265  }
266  fNtupleVector.clear();
267 
268  return true;
269 }
270 
271 //_____________________________________________________________________________
272 tools::wroot::ntuple* G4RootNtupleManager::GetNtuple() const
273 {
274  return GetNtuple(fFirstId);
275 }
276 
277 //_____________________________________________________________________________
278 tools::wroot::ntuple* G4RootNtupleManager::GetNtuple(G4int ntupleId) const
279 {
280  G4RootNtupleDescription* ntupleDescription
281  = GetNtupleInFunction(ntupleId, "GetNtuple");
282 
283  if ( ! ntupleDescription ) return 0;
284 
285  return ntupleDescription->fNtuple;
286 }
287 
288 //_____________________________________________________________________________
290  const G4String& title)
291 {
292 #ifdef G4VERBOSE
293  if ( fState.GetVerboseL4() )
294  fState.GetVerboseL4()->Message("create", "ntuple", name);
295 #endif
296 
297  // Create ntuple description
298  G4int index = fNtupleDescriptionVector.size();
299  G4RootNtupleDescription* ntupleDescription
300  = new G4RootNtupleDescription();
301  fNtupleDescriptionVector.push_back(ntupleDescription);
302 
303  // Create ntuple booking
304  ntupleDescription->fNtupleBooking
305  = new tools::ntuple_booking(name, title);
306  // ntuple booking object is deleted in destructor
307 
308  // Create ntuple if the file is open
309  if ( fNtupleDirectory ) {
310  ntupleDescription->fNtuple
311  = new tools::wroot::ntuple(*fNtupleDirectory, name, title);
312  // ntuple object is deleted automatically when closing a file
313  fNtupleVector.push_back(ntupleDescription->fNtuple);
314  }
315 
316  fLockFirstId = true;
317 
318 #ifdef G4VERBOSE
319  if ( fState.GetVerboseL2() ) {
320  G4ExceptionDescription description;
321  description << name << " ntupleId " << index + fFirstId;
322  fState.GetVerboseL2()->Message("create", "ntuple", description);
323  }
324 #endif
325 
326  return index + fFirstId;
327 }
328 
329 //_____________________________________________________________________________
331  std::vector<int>* vector)
332 {
333  G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
334  return CreateNtupleIColumn(ntupleId, name, vector);
335 }
336 
337 //_____________________________________________________________________________
339  std::vector<float>* vector)
340 {
341  G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
342  return CreateNtupleFColumn(ntupleId, name, vector);
343 }
344 
345 //_____________________________________________________________________________
347  std::vector<double>* vector)
348 {
349  G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
350  return CreateNtupleDColumn(ntupleId, name, vector);
351 }
352 
353 //_____________________________________________________________________________
355 {
356  G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
357  return CreateNtupleSColumn(ntupleId, name);
358 }
359 
360 //_____________________________________________________________________________
362 {
363  // nothing to be done here
364 }
365 
366 //_____________________________________________________________________________
368  const G4String& name,
369  std::vector<int>* vector)
370 {
371 #ifdef G4VERBOSE
372  if ( fState.GetVerboseL4() ) {
373  G4ExceptionDescription description;
374  description << name << " ntupleId " << ntupleId;
375  fState.GetVerboseL4()->Message("create", "ntuple I column", description);
376  }
377 #endif
378 
379  G4RootNtupleDescription* ntupleDescription
380  = GetNtupleInFunction(ntupleId, "CreateNtupleIColumn");
381  if ( ! ntupleDescription ) return kInvalidId;
382 
383  tools::ntuple_booking* ntupleBooking
384  = ntupleDescription->fNtupleBooking;
385  if ( ! ntupleBooking ) {
386  G4ExceptionDescription description;
387  description << " "
388  << "Ntuple " << ntupleId << " has to be created first. ";
389  G4Exception("G4RootNtupleManager::CreateNtupleIColumn()",
390  "Analysis_W002", JustWarning, description);
391  return kInvalidId;
392  }
393 
394  // Save column info in booking
395  G4int index = ntupleBooking->columns().size();
396  if ( ! vector )
397  ntupleBooking->add_column<int>(name);
398  else
399  ntupleBooking->add_column<int>(name, *vector);
400 
401 
402  // Create column if ntuple already exists
403  if ( ntupleDescription->fNtuple ) {
404  if ( ! vector ) {
405  tools::wroot::ntuple::column<int>* column
406  = ntupleDescription->fNtuple->create_column<int>(name);
407  ntupleDescription->fNtupleIColumnMap[index] = column;
408  }
409  else {
410  ntupleDescription->fNtuple->create_column<int>(name, *vector);
411  }
412  }
413 
415 
416 #ifdef G4VERBOSE
417  if ( fState.GetVerboseL2() ) {
418  G4ExceptionDescription description;
419  description << name << " ntupleId " << ntupleId;
420  fState.GetVerboseL2()->Message("create", "ntuple I column", description);
421  }
422 #endif
423 
424  return index + fFirstNtupleColumnId;
425 }
426 
427 //_____________________________________________________________________________
429  const G4String& name,
430  std::vector<float>* vector)
431 {
432 #ifdef G4VERBOSE
433  if ( fState.GetVerboseL4() ) {
434  G4ExceptionDescription description;
435  description << name << " ntupleId " << ntupleId;
436  fState.GetVerboseL4()->Message("create", "ntuple F column", description);
437  }
438 #endif
439 
440  G4RootNtupleDescription* ntupleDescription
441  = GetNtupleInFunction(ntupleId, "CreateNtupleFColumn");
442  if ( ! ntupleDescription ) return kInvalidId;
443 
444  tools::ntuple_booking* ntupleBooking
445  = ntupleDescription->fNtupleBooking;
446 
447  if ( ! ntupleBooking ) {
448  G4ExceptionDescription description;
449  description << " "
450  << "Ntuple " << ntupleId << " has to be created first. ";
451  G4Exception("G4RootNtupleManager::CreateNtupleFColumn()",
452  "Analysis_W002", JustWarning, description);
453  return kInvalidId;
454  }
455 
456  // Save column info in booking
457  G4int index = ntupleBooking->columns().size();
458  if ( ! vector )
459  ntupleBooking->add_column<float>(name);
460  else
461  ntupleBooking->add_column<float>(name, *vector);
462 
463 
464  // Create column if ntuple already exists
465  if ( ntupleDescription->fNtuple ) {
466  if ( ! vector ) {
467  tools::wroot::ntuple::column<float>* column
468  = ntupleDescription->fNtuple->create_column<float>(name);
469  ntupleDescription->fNtupleFColumnMap[index] = column;
470  }
471  else {
472  ntupleDescription->fNtuple->create_column<float>(name, *vector);
473  }
474  }
475 
477 
478 #ifdef G4VERBOSE
479  if ( fState.GetVerboseL2() ) {
480  G4ExceptionDescription description;
481  description << name << " ntupleId " << ntupleId;
482  fState.GetVerboseL2()->Message("create", "ntuple F column", description);
483  }
484 #endif
485 
486  return index + fFirstNtupleColumnId;
487 }
488 
489 
490 //_____________________________________________________________________________
492  const G4String& name,
493  std::vector<double>* vector)
494 {
495 #ifdef G4VERBOSE
496  if ( fState.GetVerboseL4() ) {
497  G4ExceptionDescription description;
498  description << name << " ntupleId " << ntupleId;
499  fState.GetVerboseL4()->Message("create", "ntuple D column", description);
500  }
501 #endif
502 
503  G4RootNtupleDescription* ntupleDescription
504  = GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
505  if ( ! ntupleDescription ) return kInvalidId;
506 
507  tools::ntuple_booking* ntupleBooking
508  = ntupleDescription->fNtupleBooking;
509 
510  if ( ! ntupleBooking ) {
511  G4ExceptionDescription description;
512  description << " "
513  << "Ntuple " << ntupleId << " has to be created first. ";
514  G4Exception("G4RootNtupleManager::CreateNtupleDColumn()",
515  "Analysis_W002", JustWarning, description);
516  return kInvalidId;
517  }
518 
519  // Save column info in booking
520  G4int index = ntupleBooking->columns().size();
521  if ( ! vector )
522  ntupleBooking->add_column<double>(name);
523  else
524  ntupleBooking->add_column<double>(name, *vector);
525 
526 
527  // Create column if ntuple already exists
528  if ( ntupleDescription->fNtuple ) {
529  if ( ! vector ) {
530  tools::wroot::ntuple::column<double>* column
531  = ntupleDescription->fNtuple->create_column<double>(name);
532  ntupleDescription->fNtupleDColumnMap[index] = column;
533  }
534  else {
535  ntupleDescription->fNtuple->create_column<double>(name, *vector);
536  }
537  }
538 
540 
541 #ifdef G4VERBOSE
542  if ( fState.GetVerboseL2() ) {
543  G4ExceptionDescription description;
544  description << name << " ntupleId " << ntupleId;
545  fState.GetVerboseL2()->Message("create", "ntuple D column", description);
546  }
547 #endif
548 
549  return index + fFirstNtupleColumnId;
550 }
551 
552 //_____________________________________________________________________________
554  const G4String& name)
555 {
556 #ifdef G4VERBOSE
557  if ( fState.GetVerboseL4() ) {
558  G4ExceptionDescription description;
559  description << name << " ntupleId " << ntupleId;
560  fState.GetVerboseL4()->Message("create", "ntuple S column", description);
561  }
562 #endif
563 
564  G4RootNtupleDescription* ntupleDescription
565  = GetNtupleInFunction(ntupleId, "CreateNtupleSColumn");
566  if ( ! ntupleDescription ) return kInvalidId;
567 
568  tools::ntuple_booking* ntupleBooking
569  = ntupleDescription->fNtupleBooking;
570 
571  if ( ! ntupleBooking ) {
572  G4ExceptionDescription description;
573  description << " "
574  << "Ntuple " << ntupleId << " has to be created first. ";
575  G4Exception("G4RootNtupleManager::CreateNtupleSColumn()",
576  "Analysis_W002", JustWarning, description);
577  return kInvalidId;
578  }
579 
580  // Save column info in booking
581  G4int index = ntupleBooking->columns().size();
582  ntupleBooking->add_column<std::string>(name);
583 
584  // Create column if ntuple already exists
585  if ( ntupleDescription->fNtuple ) {
586  tools::wroot::ntuple::column_string* column
587  = ntupleDescription->fNtuple->create_column_string(name);
588  ntupleDescription->fNtupleSColumnMap[index] = column;
589  }
590 
592 
593 #ifdef G4VERBOSE
594  if ( fState.GetVerboseL2() ) {
595  G4ExceptionDescription description;
596  description << name << " ntupleId " << ntupleId;
597  fState.GetVerboseL2()->Message("create", "ntuple S column", description);
598  }
599 #endif
600 
601  return index + fFirstNtupleColumnId;
602 }
603 
604 //_____________________________________________________________________________
606 {
607  // nothing to be done here
608 }
609 
610 //_____________________________________________________________________________
612 {
613  return FillNtupleIColumn(fFirstId, columnId, value);
614 }
615 
616 //_____________________________________________________________________________
618 {
619  return FillNtupleFColumn(fFirstId, columnId, value);
620 }
621 
622 //_____________________________________________________________________________
624 {
625  return FillNtupleDColumn(fFirstId, columnId, value);
626 }
627 
628 //_____________________________________________________________________________
630  const G4String& value)
631 {
632  return FillNtupleSColumn(fFirstId, columnId, value);
633 }
634 
635 //_____________________________________________________________________________
637 {
638  return AddNtupleRow(fFirstId);
639 }
640 
641 //_____________________________________________________________________________
643  G4int value)
644 {
645  tools::wroot::ntuple::column<int>* column
646  = GetNtupleIColumn(ntupleId, columnId);
647  if ( ! column ) {
648  G4ExceptionDescription description;
649  description << " " << "ntupleId " << ntupleId
650  << " columnId " << columnId << " does not exist.";
651  G4Exception("G4RootNtupleManager::FillNtupleIColumn()",
652  "Analysis_W001", JustWarning, description);
653  return false;
654  }
655 
656  column->fill(value);
657 #ifdef G4VERBOSE
658  if ( fState.GetVerboseL4() ) {
659  G4ExceptionDescription description;
660  description << " ntupleId " << ntupleId
661  << " columnId " << columnId << " value " << value;
662  fState.GetVerboseL4()->Message("fill", "ntuple I column", description);
663  }
664 #endif
665  return true;
666 }
667 //_____________________________________________________________________________
669  G4float value)
670 {
671  tools::wroot::ntuple::column<float>* column
672  = GetNtupleFColumn(ntupleId, columnId);
673  if ( ! column ) {
674  G4ExceptionDescription description;
675  description << " " << "ntupleId " << ntupleId
676  << " columnId " << columnId << " does not exist.";
677  G4Exception("G4RootNtupleManager::FillNtupleFColumn()",
678  "Analysis_W001", JustWarning, description);
679  return false;
680  }
681 
682  column->fill(value);
683 #ifdef G4VERBOSE
684  if ( fState.GetVerboseL4() ) {
685  G4ExceptionDescription description;
686  description << " ntupleId " << ntupleId
687  << " columnId " << columnId << " value " << value;
688  fState.GetVerboseL4()->Message("fill", "ntuple F column", description);
689  }
690 #endif
691  return true;
692 }
693 
694 //_____________________________________________________________________________
696  G4double value)
697 {
698  tools::wroot::ntuple::column<double>* column
699  = GetNtupleDColumn(ntupleId, columnId);
700  if ( ! column ) {
701  G4ExceptionDescription description;
702  description << " " << "ntupleId " << ntupleId
703  << " columnId " << columnId << " does not exist.";
704  G4Exception("G4RootNtupleManager::FillNtupleDColumn()",
705  "Analysis_W001", JustWarning, description);
706  return false;
707  }
708 
709  column->fill(value);
710 #ifdef G4VERBOSE
711  if ( fState.GetVerboseL4() ) {
712  G4ExceptionDescription description;
713  description << " ntupleId " << ntupleId
714  << " columnId " << columnId << " value " << value;
715  fState.GetVerboseL4()->Message("fill", "ntuple D column", description);
716  }
717 #endif
718  return true;
719 }
720 
721 //_____________________________________________________________________________
723  const G4String& value)
724 {
725  tools::wroot::ntuple::column_string* column
726  = GetNtupleSColumn(ntupleId, columnId);
727  if ( ! column ) {
728  G4ExceptionDescription description;
729  description << " " << "ntupleId " << ntupleId
730  << " columnId " << columnId << " does not exist.";
731  G4Exception("G4RootNtupleManager::FillNtupleSColumn()",
732  "Analysis_W001", JustWarning, description);
733  return false;
734  }
735 
736  column->fill(value);
737 #ifdef G4VERBOSE
738  if ( fState.GetVerboseL4() ) {
739  G4ExceptionDescription description;
740  description << " ntupleId " << ntupleId
741  << " columnId " << columnId << " value " << value;
742  fState.GetVerboseL4()->Message("fill", "ntuple S column", description);
743  }
744 #endif
745  return true;
746 }
747 //_____________________________________________________________________________
749 {
750 #ifdef G4VERBOSE
751  if ( fState.GetVerboseL4() ) {
752  G4ExceptionDescription description;
753  description << " ntupleId " << ntupleId;
754  fState.GetVerboseL4()->Message("add", "ntuple row", description);
755  }
756 #endif
757 
758  G4RootNtupleDescription* ntupleDescription
759  = GetNtupleInFunction(ntupleId, "AddNtupleRow");
760  if ( ! ntupleDescription ) return false;
761 
762  if ( ! ntupleDescription->fNtuple ) {
763  G4ExceptionDescription description;
764  description << " " << " ntupleId " << ntupleId
765  << " does not exist. ";
766  G4Exception("G4RootNtupleManager::AddNtupleRow()",
767  "Analysis_W022", JustWarning, description);
768  return false;
769  }
770 
771  G4bool result = ntupleDescription->fNtuple->add_row();
772  if ( ! result ) {
773  G4ExceptionDescription description;
774  description << " " << " ntupleId " << ntupleId
775  << "adding row has failed.";
776  G4Exception("G4RootNtupleManager::AddNtupleRow()",
777  "Analysis_W002", JustWarning, description);
778  }
779 #ifdef G4VERBOSE
780  if ( fState.GetVerboseL4() ) {
781  G4ExceptionDescription description;
782  description << " ntupleId " << ntupleId;
783  fState.GetVerboseL4()->Message("add", "ntuple row", description, result);
784  }
785 #endif
786 
787  return result;
788 }
tools::wroot::ntuple::column< int > * GetNtupleIColumn(G4int ntupleId, G4int columnId) const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value)
std::map< G4int, tools::wroot::ntuple::column< float > * > fNtupleFColumnMap
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String name
Definition: TRTMaterials.hh:40
float G4float
Definition: G4Types.hh:77
virtual G4int CreateNtupleSColumn(const G4String &name)
tools::wroot::directory * fNtupleDirectory
std::map< G4int, tools::wroot::ntuple::column< int > * > fNtupleIColumnMap
virtual G4int CreateNtupleFColumn(const G4String &name, std::vector< float > *vector)
tools::wroot::ntuple::column< float > * GetNtupleFColumn(G4int ntupleId, G4int columnId) const
int G4int
Definition: G4Types.hh:78
const G4AnalysisVerbose * GetVerboseL2() const
std::map< G4int, tools::wroot::ntuple::column_string * > fNtupleSColumnMap
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value)
std::vector< tools::wroot::ntuple * > fNtupleVector
std::vector< G4RootNtupleDescription * > fNtupleDescriptionVector
const G4AnalysisVerbose * GetVerboseL3() const
const G4AnalysisVerbose * GetVerboseL4() const
std::map< G4int, tools::wroot::ntuple::column< double > * > fNtupleDColumnMap
bool G4bool
Definition: G4Types.hh:79
tools::wroot::ntuple::column_string * GetNtupleSColumn(G4int ntupleId, G4int columnId) const
virtual G4RootNtupleDescription * GetNtupleInFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
tools::wroot::ntuple * GetNtuple() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4bool AddNtupleRow()
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String &value)
tools::wroot::ntuple * fNtuple
tools::ntuple_booking * fNtupleBooking
tools::wroot::ntuple::column< double > * GetNtupleDColumn(G4int ntupleId, G4int columnId) const
virtual G4int CreateNtuple(const G4String &name, const G4String &title)
G4bool fLockFirstNtupleColumnId
virtual G4int CreateNtupleIColumn(const G4String &name, std::vector< int > *vector)
double G4double
Definition: G4Types.hh:76
G4RootNtupleManager(const G4AnalysisManagerState &state)
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value)
const G4int kInvalidId
virtual G4int CreateNtupleDColumn(const G4String &name, std::vector< double > *vector)
const G4AnalysisManagerState & fState