102
104
spill.SetReconEvents(revts);
104
106
// Construct digits from hits for each MC event
105
for ( unsigned int event_i = 0; event_i < spill.GetMCEventSize(); event_i++ ) {
107
for ( size_t event_i = 0; event_i < spill.GetMCEventSize(); event_i++ ) {
106
108
MCEvent *mc_evt = spill.GetMCEvents()->at(event_i);
107
109
SciFiDigitPArray digits;
108
110
if ( mc_evt->GetSciFiHits() ) {
109
construct_digits(mc_evt->GetSciFiHits(), spill.GetSpillNumber(),
110
static_cast<int>(event_i), digits);
111
construct_digits(mc_evt->GetSciFiHits(), spill.GetSpillNumber(), event_i, digits);
113
if ( mc_evt->GetSciFiNoiseHits() ) {
114
add_noise(mc_evt->GetSciFiNoiseHits(), digits);
113
117
// Make a SciFiEvent to hold the digits produced
171
176
double time1 = a_hit->GetTime();
172
177
// int tdcCounts = compute_tdc_counts(time1);
179
// Pull tracker/station/plane information from geometry
180
int tracker = a_hit->GetChannelId()->GetTrackerNumber();
181
int station = a_hit->GetChannelId()->GetStationNumber();
182
int plane = a_hit->GetChannelId()->GetPlaneNumber();
184
// Create Digit for use with MC lookup, will update NPE later
185
SciFiDigit *a_digit = new SciFiDigit(spill_num, event_num,
186
tracker, station, plane, chanNo, nPE, time1);
188
a_hit->GetChannelId()->SetID(lookup.get_digit_id(a_digit));
174
190
// Loop over all the other hits.
175
191
for ( unsigned int hit_j = hit_i+1; hit_j < hits->size(); hit_j++ ) {
176
192
if ( check_param(&(*hits)[hit_i], &(*hits)[hit_j]) ) {
178
194
double edep_j = same_digit->GetEnergyDeposited();
179
195
nPE += edep_j*_eV_to_phe;
180
196
same_digit->GetChannelId()->SetUsed(true);
197
same_digit->GetChannelId()->SetID(lookup.get_digit_id(a_digit));
182
199
} // ends loop over all the array
183
int tracker = a_hit->GetChannelId()->GetTrackerNumber();
184
int station = a_hit->GetChannelId()->GetStationNumber();
185
int plane = a_hit->GetChannelId()->GetPlaneNumber();
187
SciFiDigit *a_digit = new SciFiDigit(spill_num, event_num,
188
tracker, station, plane, chanNo, nPE, time1);
201
a_digit->set_npe(nPE);
189
203
// .start. TO BE REMOVED .start.//
190
204
ThreeVector position = a_hit->GetPosition();
191
205
ThreeVector momentum = a_hit->GetMomentum();
192
206
a_digit->set_true_position(position);
193
207
a_digit->set_true_momentum(momentum);
194
208
// .end. TO BE REMOVED .end.//
195
210
digits.push_back(a_digit);
197
212
} // ends 'for' loop over hits
215
void MapCppTrackerMCDigitization::add_noise(SciFiNoiseHitArray *noises,
216
SciFiDigitPArray &digits) {
218
/**************************************************************************
219
* Function checks which channel has noise against which channel has a
220
* digit. If noise is in the same channel as a digit then the noise is
221
* added to the digit. If the noise is removed from the digit by one
222
* channel, then a new digit is created.
223
* Regardless, if noise is over the NPE cut off, 2 NPE, then a new digit
225
**************************************************************************/
229
for (unsigned int j = 0; j < noises->size(); j++) {
230
for (unsigned int i = 0; i < digits.size(); i++) {
232
// Checks if noise is in the same channel as a digit
233
if (digits[i]->get_tracker() == noises->at(j).GetTracker() &&
234
digits[i]->get_station() == noises->at(j).GetStation() &&
235
digits[i]->get_plane() == noises->at(j).GetPlane() &&
236
digits[i]->get_channel() == noises->at(j).GetChannel() &&
237
noises->at(j).GetUsed() == false) {
238
double digit_npe = digits[i]->get_npe();
239
double noise_npe = noises->at(j).GetNPE();
240
digits[i]->set_npe(digit_npe + noise_npe);
241
noises->at(j).SetUsed(true);
242
noises->at(j).SetID(static_cast<double>(lookup.get_digit_id(digits[i])));
245
// Checks if noise is one channel removed from a digit
246
} else if (digits[i]->get_tracker() == noises->at(j).GetTracker() &&
247
digits[i]->get_station() == noises->at(j).GetStation() &&
248
digits[i]->get_plane() == noises->at(j).GetPlane() &&
249
abs(digits[i]->get_channel() - noises->at(j).GetChannel()) <= 1.0 &&
250
noises->at(j).GetUsed() == false) {
251
SciFiNoiseHit a_noise = noises->at(j);
252
SciFiDigit* a_digit = new SciFiDigit(a_noise.GetSpill(), a_noise.GetEvent(),
253
a_noise.GetTracker(), a_noise.GetStation(), a_noise.GetPlane(),
254
a_noise.GetChannel(), a_noise.GetNPE(), a_noise.GetTime());
255
digits.push_back(a_digit);
256
noises->at(j).SetUsed(true);
257
noises->at(j).SetID(static_cast<double>(lookup.get_digit_id(a_digit)));
262
// Checks if noise is above NPE cutoff
263
if (noises->at(j).GetNPE() >= _SciFiNPECut &&
264
noises->at(j).GetUsed() == false) {
265
SciFiNoiseHit a_noise = noises->at(j);
266
SciFiDigit* a_digit = new SciFiDigit(a_noise.GetSpill(), a_noise.GetEvent(),
267
a_noise.GetTracker(), a_noise.GetStation(),
268
a_noise.GetPlane(), a_noise.GetChannel(),
269
a_noise.GetNPE(), a_noise.GetTime());
270
digits.push_back(a_digit);
271
noises->at(j).SetUsed(true);
272
noises->at(j).SetID(static_cast<double>(lookup.get_digit_id(a_digit)));
200
277
int MapCppTrackerMCDigitization::compute_tdc_counts(double time1) {
201
278
double tmpcounts;