38 gPARMS->SetDefaultParameter(
"TPOLHit:ADC_THRESHOLD", ADC_THRESHOLD,
39 "ADC pulse-height threshold");
176 uint32_t trig_mask, fp_trig_mask;
178 loop->GetSingle(trig_words);
188 int trig_bits = fp_trig_mask > 0 ? 10 + fp_trig_mask:trig_mask;
194 vector<const Df250WindowRawData*> windowraws;
195 loop->Get(windowraws);
196 for(
unsigned int i=0; i< windowraws.size(); i++){
198 if (windowraw->
rocid!=84)
continue;
199 if (!(windowraw->
slot==13||windowraw->
slot==14))
continue;
200 int slot = windowraw->
slot;
201 int channel = windowraw->
channel;
203 const vector<uint16_t> &samplesvector = windowraw->
samples;
204 unsigned int nsamples=samplesvector.size();
206 if (nsamples==0) jerr <<
"Raw samples vector is empty." << endl;
207 if (samplesvector[0] > 133.0)
continue;
208 double w_samp1 = 0.0;
double w_min = 0.0;
double w_max = 0.0;
double w_integral = 0.0;
209 for (uint16_t c_samp=0; c_samp<nsamples; c_samp++) {
211 w_integral = samplesvector[0];
212 w_min = samplesvector[0];
213 w_max = samplesvector[0];
214 w_samp1 = samplesvector[0];
216 w_integral += samplesvector[c_samp];
217 if (w_min > samplesvector[c_samp]) w_min = samplesvector[c_samp];
218 if (w_max < samplesvector[c_samp]) w_max = samplesvector[c_samp];
221 double pulse_height = w_max - w_min;
222 if (pulse_height < ADC_THRESHOLD)
continue;
224 hit->
sector = GetSector(slot,channel);
229 hit->
integral = w_integral - nsamples*w_samp1;
230 hit->
dE = pulse_height;
231 hit->
t =
t_scale*GetPulseTime(samplesvector,w_min,w_max,ADC_THRESHOLD);
232 _data.push_back(hit);
256 if (slot == 13) sector = 25 - channel;
258 if (channel <= 8) sector = 9 - channel;
259 else sector =
NSECTORS + 9 - channel;
262 if (sector == 9) sector = 6;
263 else if (sector == 6) sector = 9;
264 if (sector == 0) jerr <<
"sector did not change from initial value (0)." << endl;
277 int lastbelowsamp=0;
double peakheight = w_max-w_min;
278 double threshold = w_min + peakheight/2.0;
279 double firstaboveheight=0, lastbelowheight=0;
281 if (peakheight > minpeakheight) {
282 for (uint16_t c_samp=0; c_samp<waveform.size(); c_samp++) {
283 if (waveform[c_samp]>threshold) {
284 firstaboveheight = waveform[c_samp];
285 lastbelowsamp = c_samp-1;
286 lastbelowheight = waveform[c_samp-1];
290 w_time = lastbelowsamp + (threshold-lastbelowheight)/(firstaboveheight-lastbelowheight);
302 sprintf(str,
"Bad sector # requested in DTPOLHit_factory::GetConstant()!"
305 throw JException(str);
308 return the_table[in_sector];
315 sprintf(str,
"Bad sector # requested in DTPOLHit_factory::GetConstant()!"
316 " requested=%d , should be %ud",
319 throw JException(str);
322 return the_table[in_hit->
sector];
const double SECTOR_DIVISION
int GetSector(int slot, int channel)
sprintf(text,"Post KinFit Cut")
vector< uint16_t > samples
const double GetConstant(const vector< double > &the_table, const int in_sector) const
static const double INNER_RADIUS
double GetPhi(int sector)
double GetPulseTime(const vector< uint16_t > waveform, double w_min, double w_max, double minpeakheight)
bool DTPOLRingHit_fadc_cmp(const DTPOLRingDigiHit *a, const DTPOLRingDigiHit *b)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
bool DTPOLSectorHit_fadc_cmp(const DTPOLSectorDigiHit *a, const DTPOLSectorDigiHit *b)
static const double SECTOR_DIVISION
static const double RING_DIVISION
static const double OUTER_RADIUS
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
static const int NSECTORS