|
Lines 152-163
G4bool G4TNtupleManager<TN, TF>::FillNtupleTColumn(
Link Here
|
| 152 |
template <typename TN, typename TF> |
152 |
template <typename TN, typename TF> |
| 153 |
G4int G4TNtupleManager<TN, TF>::CreateNtuple(G4NtupleBooking* ntupleBooking) |
153 |
G4int G4TNtupleManager<TN, TF>::CreateNtuple(G4NtupleBooking* ntupleBooking) |
| 154 |
{ |
154 |
{ |
| 155 |
// This ntuple id |
155 |
|
| 156 |
auto ntupleId = G4int(fNtupleDescriptionVector.size()) + fFirstId; |
156 |
#ifdef G4VERBOSE |
|
|
157 |
if ( fState.GetVerboseL4() ) { |
| 158 |
fState.GetVerboseL4() |
| 159 |
->Message("create from booking", "ntuple", |
| 160 |
ntupleBooking->fNtupleBooking.name()); |
| 161 |
} |
| 162 |
#endif |
| 163 |
|
| 164 |
// The ntuple index |
| 165 |
auto index = ntupleBooking->fNtupleId - fFirstId; |
| 166 |
|
| 167 |
// Check if the ntuple description of this id already exists |
| 168 |
// (what should normally never happen) |
| 169 |
// delete it and print a warning |
| 170 |
if ( index < G4int(fNtupleDescriptionVector.size()) && |
| 171 |
fNtupleDescriptionVector[index] ) { |
| 172 |
delete fNtupleDescriptionVector[index]; |
| 173 |
G4ExceptionDescription description; |
| 174 |
description |
| 175 |
<< "Ntuple description " << ntupleBooking->fNtupleId << " already exists."; |
| 176 |
G4Exception("G4TNtupleManager::CreateNtuple", |
| 177 |
"Analysis_W002", JustWarning, description); |
| 178 |
} |
| 179 |
|
| 180 |
// Allocate the vector element(s) |
| 181 |
while ( index >= G4int(fNtupleDescriptionVector.size()) ) { |
| 182 |
fNtupleDescriptionVector.push_back(nullptr); |
| 183 |
} |
| 157 |
|
184 |
|
| 158 |
// Create ntuple description from ntuple booking. |
185 |
// Create ntuple description from ntuple booking. |
| 159 |
auto ntupleDescription = new G4TNtupleDescription<TN, TF>(ntupleBooking); |
186 |
auto ntupleDescription = new G4TNtupleDescription<TN, TF>(ntupleBooking); |
| 160 |
fNtupleDescriptionVector.push_back(ntupleDescription); |
187 |
fNtupleDescriptionVector[index] = ntupleDescription; |
| 161 |
|
188 |
|
| 162 |
// Do not create ntuple if it is inactivated |
189 |
// Do not create ntuple if it is inactivated |
| 163 |
if ( fState.GetIsActivation() && |
190 |
if ( fState.GetIsActivation() && |
|
Lines 167-185
G4int G4TNtupleManager<TN, TF>::CreateNtuple(G4NtupleBooking* ntupleBooking)
Link Here
|
| 167 |
if ( ntupleDescription->fNtuple ) { |
194 |
if ( ntupleDescription->fNtuple ) { |
| 168 |
G4ExceptionDescription description; |
195 |
G4ExceptionDescription description; |
| 169 |
description |
196 |
description |
| 170 |
<< "Ntuple " << ntupleId << " already exists."; |
197 |
<< "Ntuple " << ntupleBooking->fNtupleId << " already exists."; |
| 171 |
G4Exception("G4TNtupleManager::CreateNtuple", |
198 |
G4Exception("G4TNtupleManager::CreateNtuple", |
| 172 |
"Analysis_W002", JustWarning, description); |
199 |
"Analysis_W002", JustWarning, description); |
| 173 |
return ntupleId; |
200 |
return ntupleBooking->fNtupleId; |
| 174 |
} |
201 |
} |
| 175 |
|
202 |
|
| 176 |
#ifdef G4VERBOSE |
|
|
| 177 |
if ( fState.GetVerboseL4() ) |
| 178 |
fState.GetVerboseL4() |
| 179 |
->Message("create from booking", "ntuple", |
| 180 |
ntupleDescription->fNtupleBooking.name()); |
| 181 |
#endif |
| 182 |
|
| 183 |
// create ntuple |
203 |
// create ntuple |
| 184 |
CreateTNtupleFromBooking(ntupleDescription); |
204 |
CreateTNtupleFromBooking(ntupleDescription); |
| 185 |
|
205 |
|
|
Lines 191-203
G4int G4TNtupleManager<TN, TF>::CreateNtuple(G4NtupleBooking* ntupleBooking)
Link Here
|
| 191 |
if ( fState.GetVerboseL3() ) |
211 |
if ( fState.GetVerboseL3() ) |
| 192 |
fState.GetVerboseL3() |
212 |
fState.GetVerboseL3() |
| 193 |
->Message("create from booking", "ntuple", |
213 |
->Message("create from booking", "ntuple", |
| 194 |
ntupleDescription->fNtupleBooking.name()); |
214 |
ntupleBooking->fNtupleBooking.name()); |
| 195 |
#endif |
215 |
#endif |
| 196 |
|
216 |
|
| 197 |
return ntupleId; |
217 |
return ntupleBooking->fNtupleId; |
| 198 |
} |
218 |
} |
| 199 |
|
219 |
|
| 200 |
|
|
|
| 201 |
//_____________________________________________________________________________ |
220 |
//_____________________________________________________________________________ |
| 202 |
template <typename TN, typename TF> |
221 |
template <typename TN, typename TF> |
| 203 |
void G4TNtupleManager<TN, TF>::CreateNtuplesFromBooking( |
222 |
void G4TNtupleManager<TN, TF>::CreateNtuplesFromBooking( |