View | Details | Raw Unified | Return to problem 2335
Collapse All | Expand All

(-)a/source/analysis/management/include/G4NtupleBookingManager.hh (+2 lines)
Lines 42-53 struct G4NtupleBooking Link Here
42
{
42
{
43
  G4NtupleBooking() 
43
  G4NtupleBooking() 
44
    :  fNtupleBooking(),
44
    :  fNtupleBooking(),
45
       fNtupleId(-1),
45
       fFileName(),
46
       fFileName(),
46
       fActivation(true) {}
47
       fActivation(true) {}
47
48
48
  ~G4NtupleBooking() {}    
49
  ~G4NtupleBooking() {}    
49
50
50
  tools::ntuple_booking fNtupleBooking;
51
  tools::ntuple_booking fNtupleBooking;
52
  G4int fNtupleId;
51
  G4String fFileName;
53
  G4String fFileName;
52
  G4bool fActivation;
54
  G4bool fActivation;
53
};
55
};
(-)a/source/analysis/management/include/G4TNtupleManager.icc (-15 / +34 lines)
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(
(-)a/source/analysis/management/src/G4NtupleBookingManager.cc (-2 / +3 lines)
Lines 101-106 G4int G4NtupleBookingManager::CreateNtuple( Link Here
101
  // Save name & title in ntuple booking
101
  // Save name & title in ntuple booking
102
  ntupleBooking->fNtupleBooking.set_name(name);
102
  ntupleBooking->fNtupleBooking.set_name(name);
103
  ntupleBooking->fNtupleBooking.set_title(title);
103
  ntupleBooking->fNtupleBooking.set_title(title);
104
  ntupleBooking->fNtupleId = G4int(index + fFirstId);
104
105
105
  // Create ntuple
106
  // Create ntuple
106
  fLockFirstId = true;
107
  fLockFirstId = true;
Lines 108-119 G4int G4NtupleBookingManager::CreateNtuple( Link Here
108
#ifdef G4VERBOSE
109
#ifdef G4VERBOSE
109
  if ( fState.GetVerboseL2() ) {
110
  if ( fState.GetVerboseL2() ) {
110
    G4ExceptionDescription description;
111
    G4ExceptionDescription description;
111
    description << name << " ntupleId " << index + fFirstId;
112
    description << name << " ntupleId " << ntupleBooking->fNtupleId;
112
    fState.GetVerboseL2()->Message("create", "ntuple booking", description);
113
    fState.GetVerboseL2()->Message("create", "ntuple booking", description);
113
  } 
114
  } 
114
#endif
115
#endif
115
116
116
  return G4int(index + fFirstId);
117
  return ntupleBooking->fNtupleId;
117
}                                         
118
}                                         
118
119
119
//_____________________________________________________________________________
120
//_____________________________________________________________________________

Return to problem 2335