Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/analysis/management/src/G4NtupleBookingManager.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 /analysis/management/src/G4NtupleBookingManager.cc (Version 11.3.0) and /analysis/management/src/G4NtupleBookingManager.cc (Version 11.1.3)


  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 // Author: Ivana Hrivnacova, 01/09/2020  (ivan     27 // Author: Ivana Hrivnacova, 01/09/2020  (ivana@ipno.in2p3.fr)
 28                                                    28 
 29 #include "G4NtupleBookingManager.hh"               29 #include "G4NtupleBookingManager.hh"
 30 #include "G4AnalysisManagerState.hh"               30 #include "G4AnalysisManagerState.hh"
 31 #include "G4AnalysisUtilities.hh"                  31 #include "G4AnalysisUtilities.hh"
 32                                                    32 
 33 using namespace G4Analysis;                        33 using namespace G4Analysis;
 34 using std::to_string;                              34 using std::to_string;
 35                                                    35 
 36 //                                                 36 //
 37 // private template functions                      37 // private template functions
 38 //                                                 38 //
 39                                                    39 
 40 //____________________________________________     40 //_____________________________________________________________________________
 41 G4NtupleBookingManager::G4NtupleBookingManager     41 G4NtupleBookingManager::G4NtupleBookingManager(
 42   const G4AnalysisManagerState& state)             42   const G4AnalysisManagerState& state)
 43   : G4BaseAnalysisManager(state)                   43   : G4BaseAnalysisManager(state)
 44 {}                                                 44 {}
 45                                                    45 
 46 //____________________________________________     46 //_____________________________________________________________________________
 47 G4NtupleBookingManager::~G4NtupleBookingManage     47 G4NtupleBookingManager::~G4NtupleBookingManager()
 48 {                                                  48 {
 49   for ( auto ntupleBooking : fNtupleBookingVec     49   for ( auto ntupleBooking : fNtupleBookingVector ) {
 50     delete ntupleBooking;                          50     delete ntupleBooking;
 51   }                                                51   }
 52 }                                                  52 }
 53                                                    53 
 54 //____________________________________________     54 //_____________________________________________________________________________
 55 G4NtupleBooking*                                   55 G4NtupleBooking*
 56 G4NtupleBookingManager::GetNtupleBookingInFunc     56 G4NtupleBookingManager::GetNtupleBookingInFunction(
 57   G4int id, std::string_view functionName, G4b     57   G4int id, std::string_view functionName, G4bool warn) const
 58 {                                                  58 {
 59   auto index = id - fFirstId;                      59   auto index = id - fFirstId;
 60   if ( index < 0 || index >= G4int(fNtupleBook     60   if ( index < 0 || index >= G4int(fNtupleBookingVector.size()) ) {
 61     if ( warn) {                                   61     if ( warn) {
 62       Warn("Ntuple booking " + to_string(id) +     62       Warn("Ntuple booking " + to_string(id) + " does not exist.",
 63         fkClass, functionName);                    63         fkClass, functionName);
 64     }                                              64     }
 65     return nullptr;                                65     return nullptr;
 66   }                                                66   }
 67                                                    67 
 68   return fNtupleBookingVector[index];              68   return fNtupleBookingVector[index];
 69 }                                                  69 }
 70                                                    70 
 71 //____________________________________________     71 //_____________________________________________________________________________
 72 G4bool G4NtupleBookingManager::CheckName(          72 G4bool G4NtupleBookingManager::CheckName(
 73   const G4String& name, const G4String& object     73   const G4String& name, const G4String& objectType) const
 74 {                                                  74 {
 75   if (name.size() == 0u) {                         75   if (name.size() == 0u) {
 76     Warn("Empty " + objectType + " name is not     76     Warn("Empty " + objectType + " name is not allowed.\n" +
 77       objectType + " was not created.",  fkCla     77       objectType + " was not created.",  fkClass, "CheckName");
 78     return false;                                  78     return false;
 79   }                                                79   }
 80   return true;                                     80   return true;
 81 }                                                  81 }
 82                                                    82 
 83 //                                                 83 //
 84 // protected functions                             84 // protected functions
 85 //                                                 85 //
 86                                                    86 
 87 //____________________________________________     87 //_____________________________________________________________________________
 88 G4bool G4NtupleBookingManager::IsEmpty() const     88 G4bool G4NtupleBookingManager::IsEmpty() const
 89 {                                                  89 {
 90   return fNtupleBookingVector.size() == 0u;        90   return fNtupleBookingVector.size() == 0u;
 91 }                                                  91 }
 92                                                    92 
 93 //____________________________________________     93 //_____________________________________________________________________________
 94 G4int G4NtupleBookingManager::CreateNtuple(        94 G4int G4NtupleBookingManager::CreateNtuple(
 95   const G4String& name, const G4String& title)     95   const G4String& name, const G4String& title)
 96 {                                                  96 {
 97   if ( ! CheckName(name, "Ntuple") ) return kI     97   if ( ! CheckName(name, "Ntuple") ) return kInvalidId;
 98                                                    98 
 99   Message(kVL4, "create", "ntuple booking", na     99   Message(kVL4, "create", "ntuple booking", name);
100                                                   100 
101   G4int index = 0;                             << 101   // Create ntuple description
102   G4NtupleBooking* ntupleBooking = nullptr;    << 102   auto index = fNtupleBookingVector.size();
103   if (fFreeIds.empty()) {                      << 103   auto ntupleBooking = new G4NtupleBooking();
104     index = (G4int)fNtupleBookingVector.size() << 104   fNtupleBookingVector.push_back(ntupleBooking);
105     ntupleBooking = new G4NtupleBooking();     << 
106     fNtupleBookingVector.push_back(ntupleBooki << 
107     ntupleBooking->fNtupleId = G4int(index + f << 
108   }                                            << 
109   else {                                       << 
110     // Get the first freed Id                  << 
111     index = *(fFreeIds.begin()) - GetFirstId() << 
112     ntupleBooking = fNtupleBookingVector[index << 
113     ntupleBooking->fNtupleBooking = tools::ntu << 
114     ntupleBooking->Reset();                    << 
115                                                << 
116     // Remove the id from the set              << 
117     fFreeIds.erase(fFreeIds.begin());          << 
118   }                                            << 
119                                                   105 
120   // Save name & title in ntuple booking          106   // Save name & title in ntuple booking
121   ntupleBooking->fNtupleBooking.set_name(name)    107   ntupleBooking->fNtupleBooking.set_name(name);
122   ntupleBooking->fNtupleBooking.set_title(titl    108   ntupleBooking->fNtupleBooking.set_title(title);
                                                   >> 109   ntupleBooking->fNtupleId = G4int(index + fFirstId);
123                                                   110 
124   // Update related data                       << 111   // Create ntuple
125   fLockFirstId = true;                            112   fLockFirstId = true;
126   fCurrentNtupleId = ntupleBooking->fNtupleId; << 
127                                                   113 
128   Message(kVL2, "create", "ntuple booking",       114   Message(kVL2, "create", "ntuple booking",
129     name +  " ntupleId " + to_string(ntupleBoo    115     name +  " ntupleId " + to_string(ntupleBooking->fNtupleId));
130                                                   116 
131   return fCurrentNtupleId;                     << 117   return ntupleBooking->fNtupleId;
132 }                                                 118 }
133                                                   119 
134 //____________________________________________    120 //_____________________________________________________________________________
135 G4int G4NtupleBookingManager::CreateNtupleICol    121 G4int G4NtupleBookingManager::CreateNtupleIColumn(const G4String& name,
136                                                   122                                                std::vector<int>* vector)
137 {                                                 123 {
138   return CreateNtupleIColumn(GetCurrentNtupleI    124   return CreateNtupleIColumn(GetCurrentNtupleId(), name, vector);
139 }                                                 125 }
140                                                   126 
141 //____________________________________________    127 //_____________________________________________________________________________
142 G4int G4NtupleBookingManager::CreateNtupleFCol    128 G4int G4NtupleBookingManager::CreateNtupleFColumn(const G4String& name,
143                                                   129                                                std::vector<float>* vector)
144 {                                                 130 {
145   return CreateNtupleFColumn(GetCurrentNtupleI    131   return CreateNtupleFColumn(GetCurrentNtupleId(), name, vector);
146 }                                                 132 }
147                                                   133 
148 //____________________________________________    134 //_____________________________________________________________________________
149 G4int G4NtupleBookingManager::CreateNtupleDCol    135 G4int G4NtupleBookingManager::CreateNtupleDColumn(const G4String& name,
150                                                   136                                                std::vector<double>* vector)
151 {                                                 137 {
152   return CreateNtupleDColumn(GetCurrentNtupleI    138   return CreateNtupleDColumn(GetCurrentNtupleId(), name, vector);
153 }                                                 139 }
154                                                   140 
155 //____________________________________________    141 //_____________________________________________________________________________
156 G4int G4NtupleBookingManager::CreateNtupleSCol    142 G4int G4NtupleBookingManager::CreateNtupleSColumn(const G4String& name,
157                                                   143                                                std::vector<std::string>* vector)
158 {                                                 144 {
159   return CreateNtupleSColumn(GetCurrentNtupleI    145   return CreateNtupleSColumn(GetCurrentNtupleId(), name, vector);
160 }                                                 146 }
161                                                   147 
162 //____________________________________________    148 //_____________________________________________________________________________
163 G4NtupleBooking*  G4NtupleBookingManager::Fini    149 G4NtupleBooking*  G4NtupleBookingManager::FinishNtuple()
164 {                                                 150 {
165   return FinishNtuple(GetCurrentNtupleId());      151   return FinishNtuple(GetCurrentNtupleId());
166 }                                                 152 }
167                                                   153 
168 //____________________________________________    154 //_____________________________________________________________________________
169 G4int G4NtupleBookingManager::CreateNtupleICol    155 G4int G4NtupleBookingManager::CreateNtupleIColumn(
170   G4int ntupleId, const G4String& name, std::v    156   G4int ntupleId, const G4String& name, std::vector<int>* vector)
171 {                                                 157 {
172   return CreateNtupleTColumn<int>(ntupleId, na    158   return CreateNtupleTColumn<int>(ntupleId, name, vector);
173 }                                                 159 }
174                                                   160 
175 //____________________________________________    161 //_____________________________________________________________________________
176 G4int G4NtupleBookingManager::CreateNtupleFCol    162 G4int G4NtupleBookingManager::CreateNtupleFColumn(
177   G4int ntupleId, const G4String& name, std::v    163   G4int ntupleId, const G4String& name, std::vector<float>* vector)
178 {                                                 164 {
179   return CreateNtupleTColumn<float>(ntupleId,     165   return CreateNtupleTColumn<float>(ntupleId, name, vector);
180 }                                                 166 }
181                                                   167 
182 //____________________________________________    168 //_____________________________________________________________________________
183 G4int G4NtupleBookingManager::CreateNtupleDCol    169 G4int G4NtupleBookingManager::CreateNtupleDColumn(
184   G4int ntupleId, const G4String& name, std::v    170   G4int ntupleId, const G4String& name, std::vector<double>* vector)
185 {                                                 171 {
186   return CreateNtupleTColumn<double>(ntupleId,    172   return CreateNtupleTColumn<double>(ntupleId, name, vector);
187 }                                                 173 }
188                                                   174 
189 //____________________________________________    175 //_____________________________________________________________________________
190 G4int G4NtupleBookingManager::CreateNtupleSCol    176 G4int G4NtupleBookingManager::CreateNtupleSColumn(
191   G4int ntupleId, const G4String& name, std::v    177   G4int ntupleId, const G4String& name, std::vector<std::string>* vector)
192 {                                                 178 {
193   return CreateNtupleTColumn<std::string>(ntup    179   return CreateNtupleTColumn<std::string>(ntupleId, name, vector);
194 }                                                 180 }
195                                                   181 
196 //____________________________________________    182 //_____________________________________________________________________________
197 G4NtupleBooking*  G4NtupleBookingManager::Fini    183 G4NtupleBooking*  G4NtupleBookingManager::FinishNtuple(
198   G4int ntupleId)                                 184   G4int ntupleId)
199 {                                                 185 {
200   // Nothing to be done for booking,              186   // Nothing to be done for booking,
201   return GetNtupleBookingInFunction(ntupleId,     187   return GetNtupleBookingInFunction(ntupleId, "FinishNtuple");
202 }                                                 188 }
203                                                   189 
204 //____________________________________________    190 //_____________________________________________________________________________
205 G4bool G4NtupleBookingManager::SetFirstNtupleC    191 G4bool G4NtupleBookingManager::SetFirstNtupleColumnId(G4int firstId)
206 {                                                 192 {
207   if ( fLockFirstNtupleColumnId ) {               193   if ( fLockFirstNtupleColumnId ) {
208     Warn("Cannot set FirstNtupleColumnId as it    194     Warn("Cannot set FirstNtupleColumnId as its value was already used.",
209       fkClass, "SetFirstNtupleColumnId");         195       fkClass, "SetFirstNtupleColumnId");
210     return false;                                 196     return false;
211   }                                               197   }
212                                                   198 
213   fFirstNtupleColumnId = firstId;                 199   fFirstNtupleColumnId = firstId;
214   return true;                                    200   return true;
215 }                                                 201 }
216                                                   202 
217 //____________________________________________    203 //_____________________________________________________________________________
218 void  G4NtupleBookingManager::SetActivation(      204 void  G4NtupleBookingManager::SetActivation(
219   G4bool activation)                              205   G4bool activation)
220 {                                                 206 {
221   for ( auto ntupleBooking : fNtupleBookingVec    207   for ( auto ntupleBooking : fNtupleBookingVector ) {
222     ntupleBooking->fActivation = activation;      208     ntupleBooking->fActivation = activation;
223   }                                               209   }
224 }                                                 210 }
225                                                   211 
226 //____________________________________________    212 //_____________________________________________________________________________
227 void  G4NtupleBookingManager::SetActivation(      213 void  G4NtupleBookingManager::SetActivation(
228   G4int ntupleId, G4bool activation)              214   G4int ntupleId, G4bool activation)
229 {                                                 215 {
230   auto ntupleBooking                              216   auto ntupleBooking
231     = GetNtupleBookingInFunction(ntupleId, "Se    217     = GetNtupleBookingInFunction(ntupleId, "SetActivation");
232   if (ntupleBooking == nullptr) return;           218   if (ntupleBooking == nullptr) return;
233                                                   219 
234   ntupleBooking->fActivation = activation;        220   ntupleBooking->fActivation = activation;
235 }                                                 221 }
236                                                   222 
237 //____________________________________________    223 //_____________________________________________________________________________
238 G4bool  G4NtupleBookingManager::GetActivation(    224 G4bool  G4NtupleBookingManager::GetActivation(
239   G4int ntupleId) const                           225   G4int ntupleId) const
240 {                                                 226 {
241   auto ntupleBooking                              227   auto ntupleBooking
242     = GetNtupleBookingInFunction(ntupleId, "Ge    228     = GetNtupleBookingInFunction(ntupleId, "GetActivation");
243   if (ntupleBooking == nullptr) return false;     229   if (ntupleBooking == nullptr) return false;
244                                                   230 
245   return ntupleBooking->fActivation;              231   return ntupleBooking->fActivation;
246 }                                                 232 }
247                                                   233 
248 //____________________________________________    234 //_____________________________________________________________________________
249 void  G4NtupleBookingManager::SetFileName(        235 void  G4NtupleBookingManager::SetFileName(
250   const G4String& fileName)                       236   const G4String& fileName)
251 {                                                 237 {
252   for ( auto ntupleBooking : fNtupleBookingVec    238   for ( auto ntupleBooking : fNtupleBookingVector ) {
253     ntupleBooking->fFileName = fileName;          239     ntupleBooking->fFileName = fileName;
254   }                                               240   }
255 }                                                 241 }
256                                                   242 
257 //____________________________________________    243 //_____________________________________________________________________________
258 void  G4NtupleBookingManager::SetFileName(        244 void  G4NtupleBookingManager::SetFileName(
259   G4int ntupleId, const G4String& fileName)       245   G4int ntupleId, const G4String& fileName)
260 {                                                 246 {
261   auto ntupleBooking                              247   auto ntupleBooking
262     = GetNtupleBookingInFunction(ntupleId, "Se    248     = GetNtupleBookingInFunction(ntupleId, "SetFileName");
263   if (ntupleBooking == nullptr) return;           249   if (ntupleBooking == nullptr) return;
264                                                   250 
265   // Do nothing if file name does not change      251   // Do nothing if file name does not change
266   if ( ntupleBooking->fFileName == fileName )     252   if ( ntupleBooking->fFileName == fileName ) return;
267                                                   253 
268   auto ntupleFileName = fileName;                 254   auto ntupleFileName = fileName;
269   auto extension = GetExtension(fileName);        255   auto extension = GetExtension(fileName);
270   if (extension.size() != 0u) {                   256   if (extension.size() != 0u) {
271     // Check if valid extension (if present)      257     // Check if valid extension (if present)
272     auto output = G4Analysis::GetOutput(extens    258     auto output = G4Analysis::GetOutput(extension);
273     if ( output == G4AnalysisOutput::kNone ) {    259     if ( output == G4AnalysisOutput::kNone ) {
274       Warn("The file extension " + extension +    260       Warn("The file extension " + extension + " is not supported.",
275         fkClass, "SetFileName");                  261         fkClass, "SetFileName");
276       return;                                     262       return;
277     }                                             263     }
278   }                                               264   }
279   else {                                          265   else {
280     if (fFileType.size() != 0u) {                 266     if (fFileType.size() != 0u) {
281       //add extension if missing and file type    267       //add extension if missing and file type is defined
282       ntupleFileName = fileName + "." + fFileT    268       ntupleFileName = fileName + "." + fFileType;
283     }                                             269     }
284   }                                               270   }
285                                                   271 
286   // Save the fileName in booking                 272   // Save the fileName in booking
287   // If extension is still missing (possible w    273   // If extension is still missing (possible with generic manager),
288   // it will be completed with the default one    274   // it will be completed with the default one at OpenFile
289   ntupleBooking->fFileName = std::move(ntupleF << 275   ntupleBooking->fFileName = ntupleFileName;
290 }                                                 276 }
291                                                   277 
292 //____________________________________________    278 //_____________________________________________________________________________
293 G4String  G4NtupleBookingManager::GetFileName(    279 G4String  G4NtupleBookingManager::GetFileName(
294   G4int ntupleId) const                           280   G4int ntupleId) const
295 {                                                 281 {
296   auto ntupleBooking                              282   auto ntupleBooking
297     = GetNtupleBookingInFunction(ntupleId, "Ge    283     = GetNtupleBookingInFunction(ntupleId, "GetFileName");
298   if (ntupleBooking == nullptr) return "";        284   if (ntupleBooking == nullptr) return "";
299                                                   285 
300   return ntupleBooking->fFileName;                286   return ntupleBooking->fFileName;
301 }                                                 287 }
302                                                   288 
303 //____________________________________________    289 //_____________________________________________________________________________
304 void G4NtupleBookingManager::ClearData()          290 void G4NtupleBookingManager::ClearData()
305 {                                                 291 {
306   for ( auto ntupleBooking : fNtupleBookingVec    292   for ( auto ntupleBooking : fNtupleBookingVector ) {
307     delete ntupleBooking;                         293     delete ntupleBooking;
308   }                                               294   }
309   fNtupleBookingVector.clear();                   295   fNtupleBookingVector.clear();
310   fLockFirstNtupleColumnId = false;               296   fLockFirstNtupleColumnId = false;
311                                                   297 
312   Message(G4Analysis::kVL2, "clear", "ntupleBo    298   Message(G4Analysis::kVL2, "clear", "ntupleBookings");
313 }                                                 299 }
314                                                   300 
315 //____________________________________________ << 
316 G4bool G4NtupleBookingManager::Delete(G4int id << 
317 {                                              << 
318   Message(kVL4, "delete", "ntuple booking ntup << 
319                                                << 
320   auto ntupleBooking = GetNtupleBookingInFunct << 
321                                                << 
322   if (ntupleBooking == nullptr) return false;  << 
323                                                << 
324   // Update ntuple booking                     << 
325   ntupleBooking->SetDeleted(true, keepSetting) << 
326                                                << 
327   // Register freed Id                         << 
328   fFreeIds.insert(id);                         << 
329                                                << 
330   Message(G4Analysis::kVL2, "delete", "ntuple  << 
331                                                << 
332   return true;                                 << 
333 }                                              << 
334                                                << 
335 //____________________________________________ << 
336 G4bool G4NtupleBookingManager::List(std::ostre << 
337 {                                              << 
338   // Save current output stream formatting     << 
339   std::ios_base::fmtflags outputFlags(output.f << 
340                                                << 
341   // Define optimal field widths               << 
342   size_t maxNameLength = 0;                    << 
343   size_t maxTitleLength = 0;                   << 
344   // size_t maxEntries = 0;                    << 
345   size_t nofActive = 0;                        << 
346   for (auto g4NtupleBooking : fNtupleBookingVe << 
347     const auto& ntupleBooking = g4NtupleBookin << 
348     if (ntupleBooking.name().length() > maxNam << 
349       maxNameLength = ntupleBooking.name().len << 
350     }                                          << 
351     if (ntupleBooking.title().length() > maxTi << 
352       maxTitleLength = ntupleBooking.title().l << 
353     }                                          << 
354     // if (ntuple->entries() > maxEntries) {   << 
355     //   maxEntries = ntuple->entries();       << 
356     // }                                       << 
357     if (g4NtupleBooking->fActivation) {        << 
358       ++nofActive;                             << 
359     }                                          << 
360   }                                            << 
361   size_t maxIdWidth = std::to_string(fNtupleBo << 
362   // update strings width for added double quo << 
363   maxNameLength += 2;                          << 
364   maxTitleLength += 2;                         << 
365                                                << 
366   // List general info                         << 
367   output << "Ntuple: " << nofActive << " activ << 
368   if (! onlyIfActive) {                        << 
369      output << " of " << GetNofNtuples(true) < << 
370   }                                            << 
371   output << G4endl;                            << 
372                                                << 
373   // List objects                              << 
374   G4int counter = 0;                           << 
375   for (auto g4NtupleBooking : fNtupleBookingVe << 
376     const auto& ntupleBooking = g4NtupleBookin << 
377                                                << 
378     // skip inactivated objcets                << 
379     if (fState.GetIsActivation() && onlyIfActi << 
380                                                << 
381     // print selected info                     << 
382     output << "   id: " << std::setw((G4int)ma << 
383       << " name: \"" << std::setw((G4int)maxNa << 
384       << " title: \"" << std::setw((G4int)maxT << 
385       // << " entries: " << std::setw((G4int)m << 
386     if (! onlyIfActive) {                      << 
387       output << " active: " << std::boolalpha  << 
388     }                                          << 
389     output  << G4endl;                         << 
390   }                                            << 
391                                                << 
392   // Restore the output stream formatting      << 
393   output.flags(outputFlags);                   << 
394                                                << 
395   return output.good();                        << 
396 }                                              << 
397                                                << 
398 //                                                301 //
399 // public methods                                 302 // public methods
400 //                                                303 //
401                                                   304 
402 //____________________________________________    305 //_____________________________________________________________________________
403 void G4NtupleBookingManager::SetFileType(const    306 void G4NtupleBookingManager::SetFileType(const G4String& fileType)
404 {                                                 307 {
405   // do nothing if file type is defined and is    308   // do nothing if file type is defined and is same
406   if ( fFileType == fileType ) return;            309   if ( fFileType == fileType ) return;
407                                                   310 
408   // save the type                                311   // save the type
409   fFileType = fileType;                           312   fFileType = fileType;
410                                                   313 
411   // Give warning and redefine file extension     314   // Give warning and redefine file extension in bookings
412   // with file name of different fileTypes        315   // with file name of different fileTypes
413   for ( auto ntupleBooking : fNtupleBookingVec    316   for ( auto ntupleBooking : fNtupleBookingVector ) {
414     if ((ntupleBooking->fFileName).size() == 0    317     if ((ntupleBooking->fFileName).size() == 0u) continue;
415                                                   318 
416     auto extension = GetExtension(ntupleBookin    319     auto extension = GetExtension(ntupleBooking->fFileName);
417     if ( fFileType == extension ) continue;       320     if ( fFileType == extension ) continue;
418                                                   321 
419     // multiple file types are not suported       322     // multiple file types are not suported
420     auto baseFileName = GetBaseName(ntupleBook    323     auto baseFileName = GetBaseName(ntupleBooking->fFileName);
421     auto ntupleFileName = baseFileName + "." +    324     auto ntupleFileName = baseFileName + "." + fFileType;
422     if (extension.size() != 0u) {                 325     if (extension.size() != 0u) {
423       Warn("Writing ntuples in files of differ    326       Warn("Writing ntuples in files of different output types " +
424            fFileType + ", " + extension + " is    327            fFileType + ", " + extension + " is not supported.",
425            fkClass, "SetFileType");               328            fkClass, "SetFileType");
426     }                                             329     }
427                                                   330 
428     // Save the info in ntuple description        331     // Save the info in ntuple description
429     ntupleBooking->fFileName = std::move(ntupl << 332     ntupleBooking->fFileName = ntupleFileName;
430   }                                               333   }
431 }                                              << 
432                                                << 
433 //____________________________________________ << 
434 tools::ntuple_booking* G4NtupleBookingManager: << 
435   G4bool warn, G4bool onlyIfActive) const      << 
436 {                                              << 
437   return GetNtuple(fFirstId, warn, onlyIfActiv << 
438 }                                              << 
439                                                << 
440 //____________________________________________ << 
441 tools::ntuple_booking* G4NtupleBookingManager: << 
442   G4int ntupleId, G4bool warn, G4bool onlyIfAc << 
443 {                                              << 
444   auto g4Booking = GetNtupleBookingInFunction( << 
445                                                << 
446   if (g4Booking == nullptr) return nullptr;    << 
447                                                << 
448   if ( ( g4Booking->GetDeleted() ) ||          << 
449        ( onlyIfActive && (! g4Booking->fActiva << 
450                                                << 
451   return &(g4Booking->fNtupleBooking);         << 
452 }                                                 334 }
453                                                   335