Geant4 Cross Reference |
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 // $Id$ 26 27 27 // Author: Ivana Hrivnacova, 25/07/2014 (ivana 28 // Author: Ivana Hrivnacova, 25/07/2014 (ivana@ipno.in2p3.fr) 28 29 29 #include "G4XmlRNtupleManager.hh" 30 #include "G4XmlRNtupleManager.hh" 30 #include "G4XmlRFileManager.hh" << 31 #include "G4XmlRNtupleDescription.hh" 31 #include "G4AnalysisManagerState.hh" 32 #include "G4AnalysisManagerState.hh" 32 #include "G4AnalysisUtilities.hh" << 33 33 34 using namespace G4Analysis; << 34 // 35 using std::to_string; << 36 << 37 // << 38 // utility function (to be provided in tools) 35 // utility function (to be provided in tools) 39 // 36 // 40 37 41 namespace tools { 38 namespace tools { 42 namespace aida { 39 namespace aida { 43 template <class T> 40 template <class T> 44 bool to_vector(base_ntu& a_ntu,std::vector<T>& 41 bool to_vector(base_ntu& a_ntu,std::vector<T>& a_vec) { 45 a_vec.clear(); 42 a_vec.clear(); 46 const std::vector<base_col*>& cols = a_ntu.c 43 const std::vector<base_col*>& cols = a_ntu.cols(); 47 if(cols.empty()) return false; 44 if(cols.empty()) return false; 48 base_col* _base_col = cols.front(); 45 base_col* _base_col = cols.front(); 49 aida_col<T>* _col = safe_cast<base_col, aida 46 aida_col<T>* _col = safe_cast<base_col, aida_col<T> >(*_base_col); 50 if(!_col) return false; 47 if(!_col) return false; 51 a_ntu.start(); 48 a_ntu.start(); 52 uint64 _rows = a_ntu.rows(); 49 uint64 _rows = a_ntu.rows(); 53 a_vec.resize(_rows); 50 a_vec.resize(_rows); 54 T v; 51 T v; 55 {for(uint64 row=0;row<_rows;row++) { 52 {for(uint64 row=0;row<_rows;row++) { 56 if(!a_ntu.next()) {a_vec.clear();return fa 53 if(!a_ntu.next()) {a_vec.clear();return false;} 57 if(!_col->get_entry(v)) {a_vec.clear();ret 54 if(!_col->get_entry(v)) {a_vec.clear();return false;} 58 a_vec[row] = v; 55 a_vec[row] = v; 59 }} 56 }} 60 return true; 57 return true; 61 } 58 } 62 }} 59 }} 63 60 64 //____________________________________________ 61 //_____________________________________________________________________________ 65 G4XmlRNtupleManager::G4XmlRNtupleManager(const 62 G4XmlRNtupleManager::G4XmlRNtupleManager(const G4AnalysisManagerState& state) 66 : G4TRNtupleManager<tools::aida::ntuple>(stat << 63 : G4VRNtupleManager(state), 67 {} << 64 fNtupleVector() >> 65 { >> 66 } 68 67 69 // << 68 //_____________________________________________________________________________ >> 69 G4XmlRNtupleManager::~G4XmlRNtupleManager() >> 70 { >> 71 std::vector<G4XmlRNtupleDescription*>::iterator it; >> 72 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) { >> 73 delete (*it); >> 74 } >> 75 } >> 76 >> 77 // 70 // private methods 78 // private methods 71 // 79 // 72 80 73 //____________________________________________ 81 //_____________________________________________________________________________ 74 G4int G4XmlRNtupleManager::ReadNtupleImpl(cons << 82 G4XmlRNtupleDescription* G4XmlRNtupleManager::GetNtupleInFunction(G4int id, 75 cons << 83 G4String functionName, G4bool warn) const 76 cons << 84 { 77 G4bo << 85 G4int index = id - fFirstId; 78 { << 86 if ( index < 0 || index >= G4int(fNtupleVector.size()) ) { 79 Message(kVL4, "read", "ntuple", ntupleName); << 87 if ( warn) { 80 << 88 G4String inFunction = "G4XmlRNtupleManager::"; 81 // Ntuples are saved per object and per thre << 89 inFunction += functionName; 82 // but apply the ntuple name and the thread << 90 G4ExceptionDescription description; 83 // only if fileName is not provided explicit << 91 description << " " << "ntuple " << id << " does not exist."; 84 auto fullFileName = fileName; << 92 G4Exception(inFunction, "Analysis_WR011", JustWarning, description); 85 if ( ! isUserFileName ) { << 93 } 86 fullFileName = fFileManager->GetNtupleFile << 94 return nullptr; 87 } 95 } >> 96 >> 97 return fNtupleVector[index]; >> 98 } >> 99 >> 100 // >> 101 // protected methods >> 102 // >> 103 >> 104 //_____________________________________________________________________________ >> 105 G4bool G4XmlRNtupleManager::IsEmpty() const >> 106 { >> 107 return ! fNtupleVector.size(); >> 108 } >> 109 >> 110 //_____________________________________________________________________________ >> 111 G4bool G4XmlRNtupleManager::Reset() >> 112 { >> 113 // Reset ntuples >> 114 >> 115 std::vector<G4XmlRNtupleDescription*>::iterator it; >> 116 for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) { >> 117 // ntuple is deleted automatically when file is closed >> 118 // delete (*it)->fNtuple; >> 119 (*it)->fNtuple=0; >> 120 } >> 121 >> 122 return true; >> 123 } 88 124 89 auto handler = fFileManager->GetHandler<tool << 125 //_____________________________________________________________________________ 90 fullFileName, << 126 tools::aida::ntuple* G4XmlRNtupleManager::GetNtuple() const 91 if (handler == nullptr) return kInvalidId; << 127 { >> 128 return GetNtuple(fFirstId); >> 129 } 92 130 93 auto rntuple = static_cast<tools::aida::ntup << 131 //_____________________________________________________________________________ 94 auto id = SetNtuple(new G4TRNtupleDescriptio << 132 tools::aida::ntuple* G4XmlRNtupleManager::GetNtuple(G4int ntupleId) const >> 133 { >> 134 G4XmlRNtupleDescription* rntupleDescription >> 135 = GetNtupleInFunction(ntupleId, "GetRNtuple"); 95 136 96 Message(kVL2, "read", "ntuple", ntupleName, << 137 if ( ! rntupleDescription ) return nullptr; >> 138 >> 139 return rntupleDescription->fNtuple; >> 140 } 97 141 >> 142 //_____________________________________________________________________________ >> 143 G4int G4XmlRNtupleManager::SetNtuple(G4XmlRNtupleDescription* rntupleDescription) >> 144 { >> 145 G4int id = fNtupleVector.size() + fFirstId; >> 146 >> 147 fNtupleVector.push_back(rntupleDescription); >> 148 98 return id; 149 return id; >> 150 } >> 151 >> 152 //_____________________________________________________________________________ >> 153 G4bool G4XmlRNtupleManager::SetNtupleIColumn(const G4String& columnName, >> 154 G4int& value) >> 155 { >> 156 return SetNtupleIColumn(fFirstId, columnName, value); >> 157 } >> 158 >> 159 //_____________________________________________________________________________ >> 160 G4bool G4XmlRNtupleManager::SetNtupleFColumn(const G4String& columnName, >> 161 G4float& value) >> 162 { >> 163 return SetNtupleFColumn(fFirstId, columnName, value); >> 164 } >> 165 >> 166 //_____________________________________________________________________________ >> 167 G4bool G4XmlRNtupleManager::SetNtupleDColumn(const G4String& columnName, >> 168 G4double& value) >> 169 { >> 170 return SetNtupleDColumn(fFirstId, columnName, value); 99 } 171 } 100 172 101 //____________________________________________ 173 //_____________________________________________________________________________ 102 G4bool G4XmlRNtupleManager::SetNtupleIColumn(G << 174 G4bool G4XmlRNtupleManager::SetNtupleSColumn(const G4String& columnName, 103 c << 175 G4String& value) >> 176 { >> 177 return SetNtupleSColumn(fFirstId, columnName, value); >> 178 } >> 179 >> 180 //_____________________________________________________________________________ >> 181 G4bool G4XmlRNtupleManager::SetNtupleIColumn(const G4String& columnName, 104 s 182 std::vector<G4int>& vector) 105 { 183 { 106 // Override base class default implementation << 184 return SetNtupleIColumn(fFirstId, columnName, vector); >> 185 } 107 186 108 Message(kVL4, "set", "ntuple I column", << 187 //_____________________________________________________________________________ 109 " ntupleId " + to_string(ntupleId) + " " + << 188 G4bool G4XmlRNtupleManager::SetNtupleFColumn(const G4String& columnName, >> 189 std::vector<G4float>& vector) >> 190 { >> 191 return SetNtupleFColumn(fFirstId, columnName, vector); >> 192 } 110 193 111 auto ntupleDescription = GetNtupleDescriptio << 194 //_____________________________________________________________________________ 112 if (ntupleDescription == nullptr) return fal << 195 G4bool G4XmlRNtupleManager::SetNtupleDColumn(const G4String& columnName, >> 196 std::vector<G4double>& vector) >> 197 { >> 198 return SetNtupleDColumn(fFirstId, columnName, vector); >> 199 } 113 200 114 // not supported << 201 //_____________________________________________________________________________ 115 //tools::ntuple_binding* ntupleBinding = ntu << 202 G4bool G4XmlRNtupleManager::SetNtupleIColumn(G4int ntupleId, 116 //ntupleBinding->add_column(columnName, vect << 203 const G4String& columnName, >> 204 G4int& value) >> 205 { >> 206 #ifdef G4VERBOSE >> 207 if ( fState.GetVerboseL4() ) { >> 208 G4ExceptionDescription description; >> 209 description << " ntupleId " << ntupleId << " " << columnName; >> 210 fState.GetVerboseL4()->Message("set", "ntuple I column", description); >> 211 } >> 212 #endif >> 213 >> 214 G4XmlRNtupleDescription* ntupleDescription >> 215 = GetNtupleInFunction(ntupleId, "SetNtupleIColumn"); >> 216 if ( ! ntupleDescription ) return false; >> 217 >> 218 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; >> 219 ntupleBinding->add_column(columnName, value); 117 220 118 auto subNtuple = new tools::aida::ntuple(G4c << 221 #ifdef G4VERBOSE 119 ntupleDescription->fIVectorBindingMap[subNtu << 222 if ( fState.GetVerboseL2() ) { >> 223 G4ExceptionDescription description; >> 224 description << " ntupleId " << ntupleId << " " << columnName; >> 225 fState.GetVerboseL2()->Message("set", "ntuple I colum", description, true); >> 226 } >> 227 #endif >> 228 >> 229 return true; >> 230 } >> 231 >> 232 //_____________________________________________________________________________ >> 233 G4bool G4XmlRNtupleManager::SetNtupleFColumn(G4int ntupleId, >> 234 const G4String& columnName, >> 235 G4float& value) >> 236 { >> 237 #ifdef G4VERBOSE >> 238 if ( fState.GetVerboseL4() ) { >> 239 G4ExceptionDescription description; >> 240 description << " ntupleId " << ntupleId << " " << columnName; >> 241 fState.GetVerboseL4()->Message("set", "ntuple F column", description); >> 242 } >> 243 #endif >> 244 >> 245 G4XmlRNtupleDescription* ntupleDescription >> 246 = GetNtupleInFunction(ntupleId, "SetNtupleFColumn"); >> 247 if ( ! ntupleDescription ) return false; >> 248 120 tools::ntuple_binding* ntupleBinding = ntupl 249 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 121 ntupleBinding->add_column_cid(columnName, *s << 250 ntupleBinding->add_column(columnName, value); 122 251 123 Message(kVL2, "set", "ntuple I column", << 252 #ifdef G4VERBOSE 124 " ntupleId " + to_string(ntupleId) + " " + << 253 if ( fState.GetVerboseL2() ) { >> 254 G4ExceptionDescription description; >> 255 description << " ntupleId " << ntupleId << " " << columnName; >> 256 fState.GetVerboseL2()->Message("set", "ntuple F colum", description, true); >> 257 } >> 258 #endif 125 259 126 return true; 260 return true; 127 } 261 } 128 262 129 //____________________________________________ 263 //_____________________________________________________________________________ 130 G4bool G4XmlRNtupleManager::SetNtupleFColumn(G << 264 G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId, 131 c << 265 const G4String& columnName, 132 s << 266 G4double& value) 133 { << 267 { 134 // Override base class default implementation << 268 // Add protection if ntuple is initialized >> 269 >> 270 #ifdef G4VERBOSE >> 271 if ( fState.GetVerboseL4() ) { >> 272 G4ExceptionDescription description; >> 273 description << " ntupleId " << ntupleId << " " << columnName; >> 274 fState.GetVerboseL4()->Message("set", "ntuple D column", description); >> 275 } >> 276 #endif >> 277 >> 278 G4XmlRNtupleDescription* ntupleDescription >> 279 = GetNtupleInFunction(ntupleId, "SetNtupleDColumn"); >> 280 if ( ! ntupleDescription ) return false; >> 281 >> 282 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; >> 283 ntupleBinding->add_column(columnName, value); 135 284 136 Message(kVL4, "set", "ntuple F column", << 285 #ifdef G4VERBOSE 137 " ntupleId " + to_string(ntupleId) + " " + << 286 if ( fState.GetVerboseL2() ) { >> 287 G4ExceptionDescription description; >> 288 description << " ntupleId " << ntupleId << " " << columnName; >> 289 fState.GetVerboseL2()->Message("set", "ntuple D colum", description, true); >> 290 } >> 291 #endif 138 292 >> 293 return true; >> 294 } >> 295 >> 296 //_____________________________________________________________________________ >> 297 G4bool G4XmlRNtupleManager::SetNtupleSColumn(G4int ntupleId, >> 298 const G4String& columnName, >> 299 G4String& value) >> 300 { >> 301 // Add protection if ntuple is initialized >> 302 >> 303 #ifdef G4VERBOSE >> 304 if ( fState.GetVerboseL4() ) { >> 305 G4ExceptionDescription description; >> 306 description << " ntupleId " << ntupleId << " " << columnName; >> 307 fState.GetVerboseL4()->Message("set", "ntuple S column", description); >> 308 } >> 309 #endif >> 310 >> 311 G4XmlRNtupleDescription* ntupleDescription >> 312 = GetNtupleInFunction(ntupleId, "SetNtupleSColumn"); >> 313 if ( ! ntupleDescription ) return false; >> 314 >> 315 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; >> 316 ntupleBinding->add_column(columnName, value); >> 317 >> 318 #ifdef G4VERBOSE >> 319 if ( fState.GetVerboseL2() ) { >> 320 G4ExceptionDescription description; >> 321 description << " ntupleId " << ntupleId << " " << columnName; >> 322 fState.GetVerboseL2()->Message("set", "ntuple S colum", description, true); >> 323 } >> 324 #endif 139 325 140 auto ntupleDescription = GetNtupleDescriptio << 326 return true; 141 if (ntupleDescription == nullptr) return fal << 327 } >> 328 >> 329 //_____________________________________________________________________________ >> 330 G4bool G4XmlRNtupleManager::SetNtupleIColumn(G4int ntupleId, >> 331 const G4String& columnName, >> 332 std::vector<G4int>& vector) >> 333 { >> 334 // Add protection if ntuple is initialized 142 335 >> 336 #ifdef G4VERBOSE >> 337 if ( fState.GetVerboseL4() ) { >> 338 G4ExceptionDescription description; >> 339 description << " ntupleId " << ntupleId << " " << columnName; >> 340 fState.GetVerboseL4()->Message("set", "ntuple I column", description); >> 341 } >> 342 #endif >> 343 >> 344 G4XmlRNtupleDescription* ntupleDescription >> 345 = GetNtupleInFunction(ntupleId, "SetNtupleIColumn"); >> 346 if ( ! ntupleDescription ) return false; >> 347 143 // not supported 348 // not supported 144 //tools::ntuple_binding* ntupleBinding = ntu 349 //tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 145 //ntupleBinding->add_column(columnName, vect 350 //ntupleBinding->add_column(columnName, vector); 146 351 147 auto subNtuple = new tools::aida::ntuple(G4c << 352 tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName); 148 ntupleDescription->fFVectorBindingMap[subNtu << 353 ntupleDescription->fIVectorBindingMap[subNtuple] = &vector; 149 tools::ntuple_binding* ntupleBinding = ntupl 354 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 150 ntupleBinding->add_column_cid(columnName, *s << 355 ntupleBinding->add_column(columnName, *subNtuple); 151 356 152 Message(kVL4, "set", "ntuple F column", << 357 #ifdef G4VERBOSE 153 " ntupleId " + to_string(ntupleId) + " " + << 358 if ( fState.GetVerboseL2() ) { >> 359 G4ExceptionDescription description; >> 360 description << " ntupleId " << ntupleId << " " << columnName; >> 361 fState.GetVerboseL2()->Message("set", "ntuple I colum", description, true); >> 362 } >> 363 #endif 154 364 155 return true; 365 return true; 156 } 366 } 157 367 158 //____________________________________________ 368 //_____________________________________________________________________________ 159 G4bool G4XmlRNtupleManager::SetNtupleDColumn(G << 369 G4bool G4XmlRNtupleManager::SetNtupleFColumn(G4int ntupleId, 160 c << 370 const G4String& columnName, 161 s << 371 std::vector<G4float>& vector) 162 { 372 { 163 // Override base class default implementation << 373 // Add protection if ntuple is initialized 164 << 165 Message(kVL4, "set", "ntuple D column", << 166 " ntupleId " + to_string(ntupleId) + " " + << 167 << 168 auto ntupleDescription = GetNtupleDescriptio << 169 if (ntupleDescription == nullptr) return fal << 170 374 >> 375 #ifdef G4VERBOSE >> 376 if ( fState.GetVerboseL4() ) { >> 377 G4ExceptionDescription description; >> 378 description << " ntupleId " << ntupleId << " " << columnName; >> 379 fState.GetVerboseL4()->Message("set", "ntuple F column of vector", description); >> 380 } >> 381 #endif >> 382 >> 383 G4XmlRNtupleDescription* ntupleDescription >> 384 = GetNtupleInFunction(ntupleId, "SetNtupleFColumn"); >> 385 if ( ! ntupleDescription ) return false; >> 386 171 // not supported 387 // not supported 172 //tools::ntuple_binding* ntupleBinding = ntu 388 //tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 173 //ntupleBinding->add_column(columnName, vect 389 //ntupleBinding->add_column(columnName, vector); 174 390 175 auto subNtuple = new tools::aida::ntuple(G4c << 391 tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName); 176 ntupleDescription->fDVectorBindingMap[subNtu << 392 ntupleDescription->fFVectorBindingMap[subNtuple] = &vector; 177 tools::ntuple_binding* ntupleBinding = ntupl 393 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 178 ntupleBinding->add_column_cid(columnName, *s << 394 ntupleBinding->add_column(columnName, *subNtuple); 179 395 180 Message(kVL2, "set", "ntuple D column", << 396 #ifdef G4VERBOSE 181 " ntupleId " + to_string(ntupleId) + " " + << 397 if ( fState.GetVerboseL2() ) { >> 398 G4ExceptionDescription description; >> 399 description << " ntupleId " << ntupleId << " " << columnName; >> 400 fState.GetVerboseL2()->Message("set", "ntuple F colum", description, true); >> 401 } >> 402 #endif 182 403 183 return true; 404 return true; 184 } 405 } 185 406 186 //____________________________________________ 407 //_____________________________________________________________________________ 187 G4bool G4XmlRNtupleManager::SetNtupleSColumn(G << 408 G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId, 188 c << 409 const G4String& columnName, 189 s << 410 std::vector<G4double>& vector) 190 { 411 { 191 // Override base class default implementation << 412 // Add protection if ntuple is initialized 192 << 193 Message(kVL4, "set", "ntuple S column", << 194 " ntupleId " + to_string(ntupleId) + " " + << 195 << 196 auto ntupleDescription = GetNtupleDescriptio << 197 if (ntupleDescription == nullptr) return fal << 198 413 >> 414 #ifdef G4VERBOSE >> 415 if ( fState.GetVerboseL4() ) { >> 416 G4ExceptionDescription description; >> 417 description << " ntupleId " << ntupleId << " " << columnName; >> 418 fState.GetVerboseL4()->Message("set", "ntuple D column of vector", description); >> 419 } >> 420 #endif >> 421 >> 422 G4XmlRNtupleDescription* ntupleDescription >> 423 = GetNtupleInFunction(ntupleId, "SetNtupleDColumn"); >> 424 if ( ! ntupleDescription ) return false; >> 425 199 // not supported 426 // not supported 200 //tools::ntuple_binding* ntupleBinding = ntu 427 //tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 201 //ntupleBinding->add_column(columnName, vect 428 //ntupleBinding->add_column(columnName, vector); 202 429 203 auto subNtuple = new tools::aida::ntuple(G4c << 430 tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName); 204 ntupleDescription->fSVectorBindingMap[subNtu << 431 ntupleDescription->fDVectorBindingMap[subNtuple] = &vector; 205 tools::ntuple_binding* ntupleBinding = ntupl 432 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 206 ntupleBinding->add_column_cid(columnName, *s << 433 ntupleBinding->add_column(columnName, *subNtuple); 207 434 208 Message(kVL2, "set", "ntuple S column", << 435 #ifdef G4VERBOSE 209 " ntupleId " + to_string(ntupleId) + " " + << 436 if ( fState.GetVerboseL2() ) { >> 437 G4ExceptionDescription description; >> 438 description << " ntupleId " << ntupleId << " " << columnName; >> 439 fState.GetVerboseL2()->Message("set", "ntuple D colum", description, true); >> 440 } >> 441 #endif 210 442 211 return true; 443 return true; 212 } 444 } 213 445 214 //____________________________________________ 446 //_____________________________________________________________________________ 215 G4bool G4XmlRNtupleManager::GetTNtupleRow( << 447 G4bool G4XmlRNtupleManager::GetNtupleRow() 216 G4TRNtupleDescription<tools::aida::ntuple>* << 448 { >> 449 return GetNtupleRow(fFirstId); >> 450 } >> 451 >> 452 //_____________________________________________________________________________ >> 453 G4bool G4XmlRNtupleManager::GetNtupleRow(G4int ntupleId) 217 { 454 { 218 auto ntuple = ntupleDescription->fNtuple; << 455 #ifdef G4VERBOSE >> 456 if ( fState.GetVerboseL4() ) { >> 457 G4ExceptionDescription description; >> 458 description << " ntupleId " << ntupleId; >> 459 fState.GetVerboseL4()->Message("get", "ntuple row", description); >> 460 } >> 461 #endif >> 462 >> 463 G4XmlRNtupleDescription* ntupleDescription >> 464 = GetNtupleInFunction(ntupleId, "GetNtupleRow"); >> 465 if ( ! ntupleDescription ) return false; >> 466 >> 467 tools::aida::ntuple* ntuple = ntupleDescription->fNtuple; 219 468 220 G4bool isInitialized = ntupleDescription->fI 469 G4bool isInitialized = ntupleDescription->fIsInitialized; 221 if ( ! isInitialized ) { 470 if ( ! isInitialized ) { 222 tools::ntuple_binding* ntupleBinding = ntu 471 tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding; 223 if ( ! ntuple->set_binding(std::cout, *ntu 472 if ( ! ntuple->set_binding(std::cout, *ntupleBinding) ) { 224 Warn("Ntuple initialization failed !!", << 473 G4ExceptionDescription description; >> 474 description >> 475 << " " >> 476 << "Ntuple initialization failed !!"; >> 477 G4Exception("G4XmlRNtuple::GetNtupleRow()", >> 478 "Analysis_WR021", JustWarning, description); 225 return false; 479 return false; 226 } 480 } 227 ntupleDescription->fIsInitialized = true; 481 ntupleDescription->fIsInitialized = true; 228 ntuple->start(); 482 ntuple->start(); 229 } 483 } 230 484 231 G4bool next = ntuple->next(); 485 G4bool next = ntuple->next(); 232 if ( next ) { 486 if ( next ) { 233 if ( ! ntuple->get_row() ) { 487 if ( ! ntuple->get_row() ) { 234 Warn("Ntuple get_row() failed !!", fkCla << 488 G4ExceptionDescription description; >> 489 description >> 490 << " " >> 491 << "Ntuple get_row() failed !!"; >> 492 G4Exception("G4XmlRNtuple::GetNtupleRow()", >> 493 "Analysis_WR021", JustWarning, description); 235 return false; 494 return false; 236 } 495 } 237 496 238 // fill vector from sub ntuples 497 // fill vector from sub ntuples 239 for ( auto [key, value] : ntupleDescriptio << 498 240 tools::aida::to_vector<int>(*key, *value << 499 {std::map<tools::aida::ntuple*, std::vector<int>* >::iterator it; 241 } << 500 for ( it = ntupleDescription->fIVectorBindingMap.begin(); 242 for ( auto [key, value] : ntupleDescriptio << 501 it != ntupleDescription->fIVectorBindingMap.end(); it++) { 243 tools::aida::to_vector<float>(*key, *val << 502 tools::aida::to_vector<int>(*(it->first), *(it->second)); 244 } << 503 }} 245 for ( auto [key, value] : ntupleDescriptio << 504 {std::map<tools::aida::ntuple*, std::vector<float>* >::iterator it; 246 tools::aida::to_vector<double>(*key, *va << 505 for ( it = ntupleDescription->fFVectorBindingMap.begin(); 247 } << 506 it != ntupleDescription->fFVectorBindingMap.end(); it++) { 248 for ( auto [key, value] : ntupleDescriptio << 507 tools::aida::to_vector<float>(*(it->first), *(it->second)); 249 tools::aida::to_vector<std::string>(*key << 508 }} 250 } << 509 {std::map<tools::aida::ntuple*, std::vector<double>* >::iterator it; 251 } << 510 for ( it = ntupleDescription->fDVectorBindingMap.begin(); >> 511 it != ntupleDescription->fDVectorBindingMap.end(); it++) { >> 512 tools::aida::to_vector<double>(*(it->first), *(it->second)); >> 513 }} >> 514 } >> 515 >> 516 #ifdef G4VERBOSE >> 517 if ( fState.GetVerboseL2() ) { >> 518 G4ExceptionDescription description; >> 519 description << " ntupleId " << ntupleId; >> 520 fState.GetVerboseL2()->Message("get", "ntuple row", description, true); >> 521 } >> 522 #endif 252 523 253 return next; 524 return next; 254 } << 525 } 255 526