Hall C ROOT/C++ Analyzer (hcana)
Loading...
Searching...
No Matches
THcAerogel.cxx
Go to the documentation of this file.
1
8#include "THcAerogel.h"
9#include "THcHodoscope.h"
10#include "TClonesArray.h"
11#include "THcSignalHit.h"
12#include "THaEvData.h"
13#include "THaDetMap.h"
14#include "THcDetectorMap.h"
15#include "THcGlobals.h"
16#include "THaCutList.h"
17#include "THcParmList.h"
18#include "THcHitList.h"
19#include "THaApparatus.h"
20#include "VarDef.h"
21#include "VarType.h"
22#include "THaTrack.h"
23#include "TClonesArray.h"
24#include "TMath.h"
25#include "THaTrackProj.h"
26#include "THcRawAdcHit.h"
28
29#include <cstring>
30#include <cstdio>
31#include <cstdlib>
32#include <iostream>
33
34using namespace std;
35
36//_____________________________________________________________________________
37THcAerogel::THcAerogel( const char* name, const char* description,
38 THaApparatus* apparatus ) :
39 THaNonTrackingDetector(name,description,apparatus), fPresentP(0),
40 fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0),
41 fAdcNegTimeWindowMax(0),fPedNegDefault(0),fPedPosDefault(0),
42 fRegionValue(0), fPosGain(0), fNegGain(0),
43 frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0),
44 frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0),
45 frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0),
46 frNegAdcPulseIntRaw(0), frNegAdcPulseAmpRaw(0), frNegAdcPulseTimeRaw(0),
47 frNegAdcPed(0), frNegAdcPulseInt(0), frNegAdcPulseAmp(0),
48 frNegAdcPulseTime(0), fPosAdcErrorFlag(0), fNegAdcErrorFlag(0),
49 frPosAdcSampPedRaw(0), frPosAdcSampPulseIntRaw(0), frPosAdcSampPulseAmpRaw(0),
50 frPosAdcSampPulseTimeRaw(0), frPosAdcSampPed(0), frPosAdcSampPulseInt(0),
51 frPosAdcSampPulseAmp(0), frPosAdcSampPulseTime(0),
52 frNegAdcSampPedRaw(0),frNegAdcSampPulseIntRaw(0), frNegAdcSampPulseAmpRaw(0),
53 frNegAdcSampPulseTimeRaw(0), frNegAdcSampPed(0), frNegAdcSampPulseInt(0),
54 frNegAdcSampPulseAmp(0), frNegAdcSampPulseTime(0),
55 fPosPedSum(0), fPosPedSum2(0), fPosPedLimit(0),
56 fPosPedCount(0), fNegPedSum(0), fNegPedSum2(0), fNegPedLimit(0), fNegPedCount(0),
57 fA_Pos(0), fA_Neg(0), fA_Pos_p(0), fA_Neg_p(0), fT_Pos(0), fT_Neg(0),
58 fPosPed(0), fPosSig(0), fPosThresh(0), fNegPed(0), fNegSig(0),
59 fNegThresh(0), fPosPedMean(0), fNegPedMean(0),
60 fPosTDCHits(0), fNegTDCHits(0), fPosADCHits(0), fNegADCHits(0)
61{
62}
63
64//_____________________________________________________________________________
67 fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0),
68 fAdcNegTimeWindowMax(0),
69 fPedNegDefault(0),fPedPosDefault(0),fRegionValue(0), fPosGain(0), fNegGain(0),
70 frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0),
71 frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0),
72 frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0),
73 frNegAdcPulseIntRaw(0), frNegAdcPulseAmpRaw(0), frNegAdcPulseTimeRaw(0),
74 frNegAdcPed(0), frNegAdcPulseInt(0), frNegAdcPulseAmp(0),
75 frNegAdcPulseTime(0), fPosAdcErrorFlag(0), fNegAdcErrorFlag(0),
76 frPosAdcSampPedRaw(0), frPosAdcSampPulseIntRaw(0), frPosAdcSampPulseAmpRaw(0),
77 frPosAdcSampPulseTimeRaw(0), frPosAdcSampPed(0), frPosAdcSampPulseInt(0),
78 frPosAdcSampPulseAmp(0), frPosAdcSampPulseTime(0),
79 frNegAdcSampPedRaw(0),frNegAdcSampPulseIntRaw(0), frNegAdcSampPulseAmpRaw(0),
80 frNegAdcSampPulseTimeRaw(0), frNegAdcSampPed(0), frNegAdcSampPulseInt(0),
81 frNegAdcSampPulseAmp(0), frNegAdcSampPulseTime(0),
82 fPosPedSum(0), fPosPedSum2(0), fPosPedLimit(0),
83 fPosPedCount(0), fNegPedSum(0), fNegPedSum2(0), fNegPedLimit(0), fNegPedCount(0),
84 fA_Pos(0), fA_Neg(0), fA_Pos_p(0), fA_Neg_p(0), fT_Pos(0), fT_Neg(0),
85 fPosPed(0), fPosSig(0), fPosThresh(0), fNegPed(0), fNegSig(0),
86 fNegThresh(0), fPosPedMean(0), fNegPedMean(0),
87 fPosTDCHits(0), fNegTDCHits(0), fPosADCHits(0), fNegADCHits(0)
88{
89}
90
91//_____________________________________________________________________________
93{
94 // Destructor
96}
97
98//_____________________________________________________________________________
100{
101 // Delete all dynamically allocated memory
102
103 delete frPosAdcPedRaw; frPosAdcPedRaw = NULL;
107 delete frPosAdcPed; frPosAdcPed = NULL;
108 delete frPosAdcPulseInt; frPosAdcPulseInt = NULL;
109 delete frPosAdcPulseAmp; frPosAdcPulseAmp = NULL;
111 delete frNegAdcPedRaw; frNegAdcPedRaw = NULL;
115 delete frNegAdcPed; frNegAdcPed = NULL;
116 delete frNegAdcPulseInt; frNegAdcPulseInt = NULL;
117 delete frNegAdcPulseAmp; frNegAdcPulseAmp = NULL;
119 delete fPosAdcErrorFlag; fPosAdcErrorFlag = NULL;
120 delete fNegAdcErrorFlag; fNegAdcErrorFlag = NULL;
121
126 delete frPosAdcSampPed; frPosAdcSampPed = NULL;
134 delete frNegAdcSampPed; frNegAdcSampPed = NULL;
138
139 delete [] fRegionValue; fRegionValue = 0;
144 delete [] fPedNegDefault; fPedNegDefault = 0;
145 delete [] fPedPosDefault; fPedPosDefault = 0;
146
147 // 6 GeV variables
148 delete fPosTDCHits; fPosTDCHits = NULL;
149 delete fNegTDCHits; fNegTDCHits = NULL;
150 delete fPosADCHits; fPosADCHits = NULL;
151 delete fNegADCHits; fNegADCHits = NULL;
152
153 delete [] fPosGain; fPosGain = NULL;
154 delete [] fNegGain; fNegGain = NULL;
155
156 delete [] fA_Pos; fA_Pos = NULL;
157 delete [] fA_Neg; fA_Neg = NULL;
158 delete [] fA_Pos_p; fA_Pos_p = NULL;
159 delete [] fA_Neg_p; fA_Neg_p = NULL;
160 delete [] fT_Pos; fT_Pos = NULL;
161 delete [] fT_Neg; fT_Neg = NULL;
162
163 if (fSixGevData)
165}
166
167//_____________________________________________________________________________
169{
170 // Delete all dynamically allocated memory for pedestal processing
171
172 delete [] fPosPedLimit; fPosPedLimit = NULL;
173 delete [] fNegPedLimit; fNegPedLimit = NULL;
174 delete [] fPosPedMean; fPosPedMean = NULL;
175 delete [] fNegPedMean; fNegPedMean = NULL;
176 delete [] fPosPedSum; fPosPedSum = NULL;
177 delete [] fPosPedSum2; fPosPedSum2 = NULL;
178 delete [] fPosPedCount; fPosPedCount = NULL;
179 delete [] fNegPedSum; fNegPedSum = NULL;
180 delete [] fNegPedSum2; fNegPedSum2 = NULL;
181 delete [] fNegPedCount; fNegPedCount = NULL;
182 delete [] fPosPed; fPosPed = NULL;
183 delete [] fPosSig; fPosSig = NULL;
184 delete [] fPosThresh; fPosThresh = NULL;
185 delete [] fNegPed; fNegPed = NULL;
186 delete [] fNegSig; fNegSig = NULL;
187 delete [] fNegThresh; fNegThresh = NULL;
188}
189
190//_____________________________________________________________________________
192{
193
194 // cout << "THcAerogel::Init for: " << GetName() << endl;
195
196 char EngineDID[] = "xAERO";
197 EngineDID[0] = toupper(GetApparatus()->GetName()[0]);
198 if( gHcDetectorMap->FillMap(fDetMap, EngineDID) < 0 ) {
199 static const char* const here = "Init()";
200 Error( Here(here), "Error filling detectormap for %s.", EngineDID );
201 return kInitError;
202 }
203
204 EStatus status;
205 if( (status = THaNonTrackingDetector::Init( date )) )
206 return fStatus=status;
207
208 // Should probably put this in ReadDatabase as we will know the
209 // maximum number of hits after setting up the detector map
210 InitHitList(fDetMap, "THcAerogelHit", fDetMap->GetTotNumChan()+1,
211 0, fADC_RefTimeCut);
212
214 if( !app ||
215 !(fglHod = dynamic_cast<THcHodoscope*>(app->GetDetector("hod"))) ) {
216 static const char* const here = "ReadDatabase()";
217 Warning(Here(here),"Hodoscope \"%s\" not found. ","hod");
218 }
219
220 fPresentP = 0;
221 THaVar* vpresent = gHaVars->Find(Form("%s.present",GetApparatus()->GetName()));
222 if(vpresent) {
223 fPresentP = (Bool_t *) vpresent->GetValuePointer();
224 }
225 return fStatus = kOK;
226}
227
228//_____________________________________________________________________________
230{
231 // This function is called by THaDetectorBase::Init() once at the beginning
232 // of the analysis.
233
234 // cout << "THcAerogel::ReadDatabase for: " << GetName() << endl;
235
236 char prefix[2];
237 prefix[0]=tolower(GetApparatus()->GetName()[0]);
238 prefix[1]='\0';
239
240 CreateMissReportParms(Form("%saero",prefix));
241
242 fNRegions = 1; // Default if not set in parameter file
243
244 DBRequest listextra[]={
245 {"aero_num_pairs", &fNelem, kInt},
246 {0}
247 };
248
249 gHcParms->LoadParmValues((DBRequest*)&listextra, prefix);
250
251 Bool_t optional = true;
252
253 cout << "Created aerogel detector " << GetApparatus()->GetName() << "."
254 << GetName() << " with " << fNelem << " PMT pairs" << endl;
255
256 DeleteArrays(); // avoid memory leak when reinitializing
257
258 fPosGain = new Double_t[fNelem];
259 fNegGain = new Double_t[fNelem];
260
261 // 6 GeV variables
262 fTdcOffset = 0; // Offset to make reference time subtracted times positve
263 fA_Pos = new Float_t[fNelem];
264 fA_Neg = new Float_t[fNelem];
265 fA_Pos_p = new Float_t[fNelem];
266 fA_Neg_p = new Float_t[fNelem];
267 fT_Pos = new Float_t[fNelem];
268 fT_Neg = new Float_t[fNelem];
269
270 // Normal constructor with name and description
271 frPosAdcPedRaw = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
275 frPosAdcPed = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
276 frPosAdcPulseInt = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
277 frPosAdcPulseAmp = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
279 frNegAdcPedRaw = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
283 frNegAdcPed = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
284 frNegAdcPulseInt = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
285 frNegAdcPulseAmp = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
287 fPosAdcErrorFlag = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
288 fNegAdcErrorFlag = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
289 //
290 // Normal constructor with name and description
295 frPosAdcSampPed = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
303 frNegAdcSampPed = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
307 //
308 fNumPosAdcHits.assign(fNelem, 0);
309 fNumGoodPosAdcHits.assign(fNelem, 0);
310 fNumNegAdcHits.assign(fNelem, 0);
311 fNumGoodNegAdcHits.assign(fNelem, 0);
312 fNumTracksMatched.assign(fNelem, 0);
313 fNumTracksFired.assign(fNelem, 0);
314 fPosNpe.assign(fNelem, 0.0);
315 fNegNpe.assign(fNelem, 0.0);
316 fGoodPosAdcPed.assign(fNelem, 0.0);
317 fGoodPosAdcMult.assign(fNelem, 0.0);
318 fGoodPosAdcPulseInt.assign(fNelem, 0.0);
319 fGoodPosAdcPulseIntRaw.assign(fNelem, 0.0);
320 fGoodPosAdcPulseAmp.assign(fNelem, 0.0);
321 fGoodPosAdcPulseTime.assign(fNelem, 0.0);
322 fGoodPosAdcTdcDiffTime.assign(fNelem, 0.0);
323 fGoodNegAdcPed.assign(fNelem, 0.0);
324 fGoodNegAdcMult.assign(fNelem, 0.0);
325 fGoodNegAdcPulseInt.assign(fNelem, 0.0);
326 fGoodNegAdcPulseIntRaw.assign(fNelem, 0.0);
327 fGoodNegAdcPulseAmp.assign(fNelem, 0.0);
328 fGoodNegAdcPulseTime.assign(fNelem, 0.0);
329 fGoodNegAdcTdcDiffTime.assign(fNelem, 0.0);
330
331 // 6 GeV variables
332 fPosTDCHits = new TClonesArray("THcSignalHit", fNelem*16);
333 fNegTDCHits = new TClonesArray("THcSignalHit", fNelem*16);
334 fPosADCHits = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
335 fNegADCHits = new TClonesArray("THcSignalHit", fNelem*MaxNumAdcPulse);
336
337 fPosNpeSixGev.assign(fNelem, 0.0);
338 fNegNpeSixGev.assign(fNelem, 0.0);
339
340 // Region parameters
343
350
351 DBRequest list[]={
352 {"aero_num_regions", &fNRegions, kInt},
353 {"aero_red_chi2_min", &fRedChi2Min, kDouble},
354 {"aero_red_chi2_max", &fRedChi2Max, kDouble},
355 {"aero_beta_min", &fBetaMin, kDouble},
356 {"aero_beta_max", &fBetaMax, kDouble},
357 {"aero_enorm_min", &fENormMin, kDouble},
358 {"aero_enorm_max", &fENormMax, kDouble},
359 {"aero_dp_min", &fDpMin, kDouble},
360 {"aero_dp_max", &fDpMax, kDouble},
361 {"aero_diff_box_zpos", &fDiffBoxZPos, kDouble},
362 {"aero_npe_thresh", &fNpeThresh, kDouble},
365 {"aero_adcPosTimeWindowMin", fAdcPosTimeWindowMin, kDouble, static_cast<UInt_t>(fNelem), 1},
366 {"aero_adcPosTimeWindowMax", fAdcPosTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1},
367 {"aero_adcNegTimeWindowMin", fAdcNegTimeWindowMin, kDouble, static_cast<UInt_t>(fNelem), 1},
368 {"aero_adcNegTimeWindowMax", fAdcNegTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1},
369 {"aero_PedNegDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNelem), 1},
370 {"aero_PedPosDefault", fPedPosDefault, kInt, static_cast<UInt_t>(fNelem), 1},
371 {"aero_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1},
372 {"aero_debug_adc", &fDebugAdc, kInt, 0, 1},
373 {"aero_six_gev_data", &fSixGevData, kInt, 0, 1},
374 {"aero_pos_gain", fPosGain, kDouble, (UInt_t) fNelem},
375 {"aero_neg_gain", fNegGain, kDouble, (UInt_t) fNelem},
376 {"aero_tdc_offset", &fTdcOffset, kInt, 0, optional},
377 {"aero_region", &fRegionValue[0], kDouble, (UInt_t) fRegionsValueMax},
378 {"aero_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1},
379 {"aero_SampThreshold", &fSampThreshold, kDouble,0,1},
380 {"aero_SampNSA", &fSampNSA, kInt,0,1},
381 {"aero_SampNSAT", &fSampNSAT, kInt,0,1},
382 {"aero_SampNSB", &fSampNSB, kInt,0,1},
383 {"aero_OutputSampWaveform", &fOutputSampWaveform, kInt,0,1},
384 {"aero_UseSampWaveform", &fUseSampWaveform, kInt,0,1},
385 {0}
386 };
387
388 fSampThreshold = 5.;
389 fSampNSA = 0; // use value stored in event 125 info
390 fSampNSB = 0; // use value stored in event 125 info
391 fSampNSAT = 2; // default value in THcRawHit::SetF250Params
392 fOutputSampWaveform = 0; // 0= no output , 1 = output Sample Waveform
393 fUseSampWaveform = 0; // 0= do not use , 1 = use Sample Waveform
394
395 for(Int_t ip=0;ip<fNelem;ip++) {
396 fAdcPosTimeWindowMin[ip] = -1000.;
397 fAdcNegTimeWindowMin[ip] = -1000.;
398 fAdcPosTimeWindowMax[ip] = 1000.;
399 fAdcNegTimeWindowMax[ip] = 1000.;
400 fPedNegDefault[ip] = 0.;
401 fPedPosDefault[ip] = 0.;
402 }
403
404 fSixGevData = 0; // Set 6 GeV data parameter to false unless set in parameter file
405 fDebugAdc = 0; // Set ADC debug parameter to false unless set in parameter file
406 fAdcTdcOffset = 0.0;
407 fADC_RefTimeCut = 0;
408
409 gHcParms->LoadParmValues((DBRequest*)&list, prefix);
410 if (fSixGevData) {
411 // Create arrays to hold pedestal results
413
414 DBRequest list2[]={
415 {"aero_pos_ped_limit", fPosPedLimit, kInt, (UInt_t) fNelem, optional},
416 {"aero_neg_ped_limit", fNegPedLimit, kInt, (UInt_t) fNelem, optional},
417 {"aero_pos_ped_mean", fPosPedMean, kDouble, (UInt_t) fNelem, optional},
418 {"aero_neg_ped_mean", fNegPedMean, kDouble, (UInt_t) fNelem, optional},
419 {"aero_min_peds", &fMinPeds, kInt, 0, optional},
420 {0}
421 };
422 gHcParms->LoadParmValues((DBRequest*)&list2, prefix);
423
424 cout << "6 GeV Data Analysis Flag Set To TRUE" << endl;
425 }
426
427 fIsInit = true;
428
429 // cout << "Track Matching Parameters for: " << GetApparatus()->GetName()
430 // << "." << GetName() << endl;
431 // for (Int_t iregion = 0; iregion < fNRegions; iregion++) {
432 // cout << "Region = " << iregion + 1 << endl;
433 // for (Int_t ivalue = 0; ivalue < 8; ivalue++)
434 // cout << fRegionValue[GetIndex(iregion, ivalue)] << " ";
435 // cout << endl;
436 // }
437
438 return kOK;
439}
440
441//_____________________________________________________________________________
443{
444 // Initialize global variables for histogramming and tree
445
446 // cout << "THcAerogel::DefineVariables called for: " << GetName() << endl;
447
448 if( mode == kDefine && fIsSetup ) return kOK;
449 fIsSetup = ( mode == kDefine );
450
451 // Register variables in global list
452
453 // Do we need to put the number of pos/neg TDC/ADC hits into the variables?
454 // No. They show up in tree as Ndata.H.aero.postdchits for example
455
456 if (fDebugAdc) {
457 RVarDef vars[] = {
458 {"posGain", "Positive PMT gains", "fPosGain"},
459 {"negGain", "Negative PMT gains", "fNegGain"},
460
461 {"numPosAdcHits", "Number of Positive ADC Hits Per PMT", "fNumPosAdcHits"}, // Aerogel occupancy
462 {"totNumPosAdcHits", "Total Number of Positive ADC Hits", "fTotNumPosAdcHits"}, // Aerogel multiplicity
463 {"numNegAdcHits", "Number of Negative ADC Hits Per PMT", "fNumNegAdcHits"}, // Aerogel occupancy
464 {"totNumNegAdcHits", "Total Number of Negative ADC Hits", "fTotNumNegAdcHits"}, // Aerogel multiplicity
465 {"totnumAdcHits", "Total Number of ADC Hits Per PMT", "fTotNumAdcHits"}, // Aerogel multiplicity
466
467 {"posAdcPedRaw", "Positive Raw ADC pedestals", "frPosAdcPedRaw.THcSignalHit.GetData()"},
468 {"posAdcPulseIntRaw", "Positive Raw ADC pulse integrals", "frPosAdcPulseIntRaw.THcSignalHit.GetData()"},
469 {"posAdcPulseAmpRaw", "Positive Raw ADC pulse amplitudes", "frPosAdcPulseAmpRaw.THcSignalHit.GetData()"},
470 {"posAdcPulseTimeRaw", "Positive Raw ADC pulse times", "frPosAdcPulseTimeRaw.THcSignalHit.GetData()"},
471 {"posAdcPed", "Positive ADC pedestals", "frPosAdcPed.THcSignalHit.GetData()"},
472 {"posAdcPulseInt", "Positive ADC pulse integrals", "frPosAdcPulseInt.THcSignalHit.GetData()"},
473 {"posAdcPulseAmp", "Positive ADC pulse amplitudes", "frPosAdcPulseAmp.THcSignalHit.GetData()"},
474 {"posAdcPulseTime", "Positive ADC pulse times", "frPosAdcPulseTime.THcSignalHit.GetData()"},
475 {"posAdcSampPedRaw", "Positive Raw Samp ADC pedestals", "frPosAdcSampPedRaw.THcSignalHit.GetData()"},
476 {"posAdcSampPulseIntRaw", "Positive Raw Samp ADC pulse integrals", "frPosAdcSampPulseIntRaw.THcSignalHit.GetData()"},
477 {"posAdcSampPulseAmpRaw", "Positive Raw Samp ADC pulse amplitudes", "frPosAdcSampPulseAmpRaw.THcSignalHit.GetData()"},
478 {"posAdcSampPulseTimeRaw", "Positive Raw Samp ADC pulse times", "frPosAdcSampPulseTimeRaw.THcSignalHit.GetData()"},
479 {"posAdcSampPed", "Positive Samp ADC pedestals", "frPosAdcSampPed.THcSignalHit.GetData()"},
480 {"posAdcSampPulseInt", "Positive Samp ADC pulse integrals", "frPosAdcSampPulseInt.THcSignalHit.GetData()"},
481 {"posAdcSampPulseAmp", "Positive Samp ADC pulse amplitudes", "frPosAdcSampPulseAmp.THcSignalHit.GetData()"},
482 {"posAdcSampPulseTime", "Positive Samp ADC pulse times", "frPosAdcSampPulseTime.THcSignalHit.GetData()"},
483 {"negAdcPedRaw", "Negative Raw ADC pedestals", "frNegAdcPedRaw.THcSignalHit.GetData()"},
484 {"negAdcPulseIntRaw", "Negative Raw ADC pulse integrals", "frNegAdcPulseIntRaw.THcSignalHit.GetData()"},
485 {"negAdcPulseAmpRaw", "Negative Raw ADC pulse amplitudes", "frNegAdcPulseAmpRaw.THcSignalHit.GetData()"},
486 {"negAdcPulseTimeRaw", "Negative Raw ADC pulse times", "frNegAdcPulseTimeRaw.THcSignalHit.GetData()"},
487 {"negAdcPed", "Negative ADC pedestals", "frNegAdcPed.THcSignalHit.GetData()"},
488 {"negAdcPulseInt", "Negative ADC pulse integrals", "frNegAdcPulseInt.THcSignalHit.GetData()"},
489 {"negAdcPulseAmp", "Negative ADC pulse amplitudes", "frNegAdcPulseAmp.THcSignalHit.GetData()"},
490 {"negAdcPulseTime", "Negative ADC pulse times", "frNegAdcPulseTime.THcSignalHit.GetData()"},
491 {"negAdcSampPedRaw", "Negative Raw Samp ADC pedestals", "frNegAdcSampPedRaw.THcSignalHit.GetData()"},
492 {"negAdcSampPulseIntRaw", "Negative Raw Samp ADC pulse integrals", "frNegAdcSampPulseIntRaw.THcSignalHit.GetData()"},
493 {"negAdcSampPulseAmpRaw", "Negative Raw Samp ADC pulse amplitudes", "frNegAdcSampPulseAmpRaw.THcSignalHit.GetData()"},
494 {"negAdcSampPulseTimeRaw", "Negative Raw Samp ADC pulse times", "frNegAdcSampPulseTimeRaw.THcSignalHit.GetData()"},
495 {"negAdcSampPed", "Negative Samp ADC pedestals", "frNegAdcSampPed.THcSignalHit.GetData()"},
496 {"negAdcSampPulseInt", "Negative Samp ADC pulse integrals", "frNegAdcSampPulseInt.THcSignalHit.GetData()"},
497 {"negAdcSampPulseAmp", "Negative Samp ADC pulse amplitudes", "frNegAdcSampPulseAmp.THcSignalHit.GetData()"},
498 {"negAdcSampPulseTime", "Negative Samp ADC pulse times", "frNegAdcSampPulseTime.THcSignalHit.GetData()"},
499 { 0 }
500 };
501 DefineVarsFromList( vars, mode);
502 if (fOutputSampWaveform==1) {
503 RVarDef vars[] = {
504 {"adcNegSampWaveform", "FADC Neg ADCSample Waveform", "fNegAdcSampWaveform"},
505 {"adcPosSampWaveform", "FADC Pos ADCSample Waveform", "fPosAdcSampWaveform"},
506 { 0 }
507 };
508 DefineVarsFromList( vars, mode);
509 }
510 //
511 } //end debug statement
512
513 if (fSixGevData) {
514 RVarDef vars[] = {
515 {"apos", "Positive Raw ADC Amplitudes", "fA_Pos"},
516 {"aneg", "Negative Raw ADC Amplitudes", "fA_Neg"},
517 {"apos_p", "Positive Ped-subtracted ADC Amplitudes", "fA_Pos_p"},
518 {"aneg_p", "Negative Ped-subtracted ADC Amplitudes", "fA_Neg_p"},
519 {"tpos", "Positive Raw TDC", "fT_Pos"},
520 {"tneg", "Negative Raw TDC", "fT_Neg"},
521 {"ntdc_pos_hits", "Number of Positive Tube Hits", "fNTDCPosHits"},
522 {"ntdc_neg_hits", "Number of Negative Tube Hits", "fNTDCNegHits"},
523 {"posadchits", "Positive ADC hits", "fPosADCHits.THcSignalHit.GetPaddleNumber()"},
524 {"negadchits", "Negative ADC hits", "fNegADCHits.THcSignalHit.GetPaddleNumber()"},
525 {"postdchits", "Positive TDC hits", "fPosTDCHits.THcSignalHit.GetPaddleNumber()"},
526 {"negtdchits", "Negative TDC hits", "fNegTDCHits.THcSignalHit.GetPaddleNumber()"},
527 {"nGoodHits", "Total number of good hits", "fNGoodHits"},
528 {"posNpeSixGev", "Number of Positive PEs", "fPosNpeSixGev"},
529 {"negNpeSixGev", "Number of Negative PEs", "fNegNpeSixGev"},
530 {"posNpeSumSixGev", "Total Number of Positive PEs", "fPosNpeSumSixGev"},
531 {"negNpeSumSixGev", "Total Number of Negative PEs", "fNegNpeSumSixGev"},
532 {"npeSumSixGev", "Total Number of PEs", "fNpeSumSixGev"},
533 { 0 }
534 };
535 DefineVarsFromList( vars, mode);
536 } //end fSixGevData statement
537
538 RVarDef vars[] = {
539 {"posAdcCounter", "Positive ADC counter numbers", "frPosAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
540 {"negAdcCounter", "Negative ADC counter numbers", "frNegAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
541 {"negAdcSampleCounter", "Negative ADC Sample counter numbers", "frNegAdcSampPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
542 {"posAdcSampleCounter", "Positive ADC Sample counter numbers", "frPosAdcSampPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
543 {"posAdcErrorFlag", "Error Flag for When FPGA Fails", "fPosAdcErrorFlag.THcSignalHit.GetData()"},
544 {"negAdcErrorFlag", "Error Flag for When FPGA Fails", "fNegAdcErrorFlag.THcSignalHit.GetData()"},
545
546 {"numGoodPosAdcHits", "Number of Good Positive ADC Hits Per PMT", "fNumGoodPosAdcHits"}, // Aerogel occupancy
547 {"numGoodNegAdcHits", "Number of Good Negative ADC Hits Per PMT", "fNumGoodNegAdcHits"}, // Aerogel occupancy
548 {"totNumGoodPosAdcHits", "Total Number of Good Positive ADC Hits", "fTotNumGoodPosAdcHits"}, // Aerogel multiplicity
549 {"totNumGoodNegAdcHits", "Total Number of Good Negative ADC Hits", "fTotNumGoodNegAdcHits"}, // Aerogel multiplicity
550
551 {"totnumGoodAdcHits", "TotalNumber of Good ADC Hits Per PMT", "fTotNumGoodAdcHits"}, // Aerogel multiplicity
552 {"numTracksMatched", "Number of Tracks Matched Per Region", "fNumTracksMatched"},
553 {"numTracksFired", "Number of Tracks that Fired Per Region", "fNumTracksFired"},
554 {"totNumTracksMatched", "Total Number of Tracks Matched Per Region", "fTotNumTracksMatched"},
555 {"totNumTracksFired", "Total Number of Tracks that Fired", "fTotNumTracksFired"},
556
557 {"xAtAero", "Track X at Aero diffusion box", "fXAtAero"},
558 {"yAtAero", "Track Y at Aero diffusion box", "fYAtAero"},
559
560 {"posNpe", "Number of Positive PEs", "fPosNpe"},
561 {"negNpe", "Number of Negative PEs", "fNegNpe"},
562 {"posNpeSum", "Total Number of Positive PEs", "fPosNpeSum"},
563 {"negNpeSum", "Total Number of Negative PEs", "fNegNpeSum"},
564 {"npeSum", "Total Number of PEs", "fNpeSum"},
565
566 {"goodPosAdcPed", "Good Negative ADC pedestals", "fGoodPosAdcPed"},
567 {"goodPosAdcMult", "Good Positive ADC mult", "fGoodPosAdcMult"},
568 {"goodPosAdcPulseInt", "Good Negative ADC pulse integrals", "fGoodPosAdcPulseInt"},
569 {"goodPosAdcPulseIntRaw", "Good Negative ADC raw pulse integrals", "fGoodPosAdcPulseIntRaw"},
570 {"goodPosAdcPulseAmp", "Good Negative ADC pulse amplitudes", "fGoodPosAdcPulseAmp"},
571 {"goodPosAdcPulseTime", "Good Negative ADC pulse times", "fGoodPosAdcPulseTime"},
572 {"goodPosAdcTdcDiffTime", "Good Positive hodo Start - ADC pulse times", "fGoodPosAdcTdcDiffTime"},
573
574 {"goodNegAdcPed", "Good Negative ADC pedestals", "fGoodNegAdcPed"},
575 {"goodNegAdcMult", "Good Negative ADC Mult", "fGoodNegAdcMult"},
576 {"goodNegAdcPulseInt", "Good Negative ADC pulse integrals", "fGoodNegAdcPulseInt"},
577 {"goodNegAdcPulseIntRaw", "Good Negative ADC raw pulse integrals", "fGoodNegAdcPulseIntRaw"},
578 {"goodNegAdcPulseAmp", "Good Negative ADC pulse amplitudes", "fGoodNegAdcPulseAmp"},
579 {"goodNegAdcPulseTime", "Good Negative ADC pulse times", "fGoodNegAdcPulseTime"},
580 {"goodNegAdcTdcDiffTime", "Good Negative hodo Start - ADC pulse times", "fGoodNegAdcTdcDiffTime"},
581 { 0 }
582 };
583
584 return DefineVarsFromList(vars, mode);
585}
586//_____________________________________________________________________________
587inline
589{
590 // Clear the hit lists
591 fNhits = 0;
592 fTotNumAdcHits = 0;
600
601 fXAtAero = 0.0;
602 fYAtAero = 0.0;
603
604 fNpeSum = 0.0;
605 fPosNpeSum = 0.0;
606 fNegNpeSum = 0.0;
607
616
625
634
643
646
647 for (UInt_t ielem = 0; ielem < fNumPosAdcHits.size(); ielem++)
648 fNumPosAdcHits.at(ielem) = 0;
649 for (UInt_t ielem = 0; ielem < fNumNegAdcHits.size(); ielem++)
650 fNumNegAdcHits.at(ielem) = 0;
651 for (UInt_t ielem = 0; ielem < fNumGoodPosAdcHits.size(); ielem++)
652 fNumGoodPosAdcHits.at(ielem) = 0;
653 for (UInt_t ielem = 0; ielem < fNumGoodNegAdcHits.size(); ielem++)
654 fNumGoodNegAdcHits.at(ielem) = 0;
655 for (UInt_t ielem = 0; ielem < fNumTracksMatched.size(); ielem++)
656 fNumTracksMatched.at(ielem) = 0;
657 for (UInt_t ielem = 0; ielem < fNumTracksFired.size(); ielem++)
658 fNumTracksFired.at(ielem) = 0;
659
660 for (UInt_t ielem = 0; ielem < fGoodPosAdcPed.size(); ielem++) {
661 fGoodPosAdcPed.at(ielem) = 0.0;
662 fGoodPosAdcMult.at(ielem) = 0.0;
663 fGoodPosAdcPulseInt.at(ielem) = 0.0;
664 fGoodPosAdcPulseIntRaw.at(ielem) = 0.0;
665 fGoodPosAdcPulseAmp.at(ielem) = 0.0;
666 fGoodPosAdcPulseTime.at(ielem) = kBig;
667 fGoodPosAdcTdcDiffTime.at(ielem) = kBig;
668 fPosNpe.at(ielem) = 0.0;
669 }
670 for (UInt_t ielem = 0; ielem < fGoodNegAdcPed.size(); ielem++) {
671 fGoodNegAdcPed.at(ielem) = 0.0;
672 fGoodNegAdcMult.at(ielem) = 0.0;
673 fGoodNegAdcPulseInt.at(ielem) = 0.0;
674 fGoodNegAdcPulseIntRaw.at(ielem) = 0.0;
675 fGoodNegAdcPulseAmp.at(ielem) = 0.0;
676 fGoodNegAdcPulseTime.at(ielem) = kBig;
677 fGoodNegAdcTdcDiffTime.at(ielem) = kBig;
678 fNegNpe.at(ielem) = 0.0;
679 }
680
681 // 6 GeV variables
682 fNGoodHits = 0;
683 fNADCPosHits = 0;
684 fNADCNegHits = 0;
685 fNTDCPosHits = 0;
686 fNTDCNegHits = 0;
687 fNpeSumSixGev = 0.0;
688 fPosNpeSumSixGev = 0.0;
689 fNegNpeSumSixGev = 0.0;
694
695 for (UInt_t ielem = 0; ielem < fPosNpeSixGev.size(); ielem++)
696 fPosNpeSixGev.at(ielem) = 0.0;
697 for (UInt_t ielem = 0; ielem < fNegNpeSixGev.size(); ielem++)
698 fNegNpeSixGev.at(ielem) = 0.0;
699
700 for(Int_t itube = 0;itube < fNelem;itube++) {
701 fA_Pos[itube] = 0;
702 fA_Neg[itube] = 0;
703 fA_Pos_p[itube] = 0;
704 fA_Neg_p[itube] = 0;
705 fT_Pos[itube] = 0;
706 fT_Neg[itube] = 0;
707 }
708
709}
710
711//_____________________________________________________________________________
713{
714 // Get the Hall C style hitlist (fRawHitList) for this event
715 Bool_t present = kTRUE; // Suppress reference time warnings
716 if(fPresentP) { // if this spectrometer not part of trigger
717 present = *fPresentP;
718 }
719 fNhits = DecodeToHitList(evdata, !present);
720
721 if (fSixGevData) {
722 if(gHaCuts->Result("Pedestal_event")) {
724 fAnalyzePedestals = 1; // Analyze pedestals first normal events
725 return(0);
726 }
729 Print("");
730 fAnalyzePedestals = 0; // Don't analyze pedestals next event
731 }
732 }
733
734 Int_t ihit = 0;
735 UInt_t nrPosAdcHits = 0;
736 UInt_t nrNegAdcHits = 0;
737 UInt_t nrSampPosAdcHits = 0;
738 UInt_t nrSampNegAdcHits = 0;
739 fPosAdcSampWaveform.clear();
740 fNegAdcSampWaveform.clear();
741
742 while(ihit < fNhits) {
743 THcAerogelHit* hit = (THcAerogelHit*) fRawHitList->At(ihit);
744 Int_t npmt = hit->fCounter;
745 THcRawAdcHit& rawPosAdcHit = hit->GetRawAdcHitPos();
746 THcRawAdcHit& rawNegAdcHit = hit->GetRawAdcHitNeg();
747
748 if ( fUseSampWaveform == 0 ) {
749 for (UInt_t thit=0; thit<rawPosAdcHit.GetNPulses(); ++thit) {
750
751 ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPedRaw());
752 ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPed());
753
754 ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseIntRaw(thit));
755 ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseInt(thit));
756
757 ((THcSignalHit*) frPosAdcPulseAmpRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseAmpRaw(thit));
758 ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseAmp(thit));
759
760 ((THcSignalHit*) frPosAdcPulseTimeRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseTimeRaw(thit));
761 ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetPulseTime(thit)+fAdcTdcOffset);
762
763 if (rawPosAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 0);
764 if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 1);
765 if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0 && rawPosAdcHit.GetNSamples() >0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 2);
766
767 if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) {
768 Double_t PeakPedRatio= rawPosAdcHit.GetF250_PeakPedestalRatio();
769 Int_t NPedSamples= rawPosAdcHit.GetF250_NPedestalSamples();
770 Double_t AdcToC = rawPosAdcHit.GetAdcTopC();
771 Double_t AdcToV = rawPosAdcHit.GetAdcTomV();
772 if (fPedPosDefault[npmt-1] !=0) {
773 Double_t tPulseInt = AdcToC*(rawPosAdcHit.GetPulseIntRaw(thit) - fPedPosDefault[npmt-1]*PeakPedRatio);
774 ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(npmt, tPulseInt);
775 ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, fPedPosDefault[npmt-1]);
776 ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(npmt, float(fPedPosDefault[npmt-1])/float(NPedSamples)*AdcToV);
777
778 }
779 ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(npmt, 0.);
780 }
781 ++nrPosAdcHits;
784 fNumPosAdcHits.at(npmt-1) = npmt;
785 }
786 }
787 //
788 if (rawPosAdcHit.GetNSamples()>0 ) {
789 rawPosAdcHit.SetSampThreshold(fSampThreshold);
790 if (fSampNSA == 0) fSampNSA=rawPosAdcHit.GetF250_NSA();
791 if (fSampNSB == 0) fSampNSB=rawPosAdcHit.GetF250_NSB();
792 rawPosAdcHit.SetF250Params(fSampNSA,fSampNSB,4); // Set NPED =4
793 if (fSampNSAT != 2) rawPosAdcHit.SetSampNSAT(fSampNSAT);
794 rawPosAdcHit.SetSampIntTimePedestalPeak();
795 fPosAdcSampWaveform.push_back(float(npmt));
796 fPosAdcSampWaveform.push_back(float(rawPosAdcHit.GetNSamples()));
797 for (UInt_t thit = 0; thit < rawPosAdcHit.GetNSamples(); thit++) {
798 fPosAdcSampWaveform.push_back(rawPosAdcHit.GetSample(thit)); // ped subtracted sample (mV)
799 }
800 for (UInt_t thit = 0; thit < rawPosAdcHit.GetNSampPulses(); thit++) {
801 ((THcSignalHit*) frPosAdcSampPedRaw->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPedRaw());
802 ((THcSignalHit*) frPosAdcSampPed->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPed());
803
804 ((THcSignalHit*) frPosAdcSampPulseIntRaw->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseIntRaw(thit));
805 ((THcSignalHit*) frPosAdcSampPulseInt->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseInt(thit));
806
807 ((THcSignalHit*) frPosAdcSampPulseAmpRaw->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseAmpRaw(thit));
808 ((THcSignalHit*) frPosAdcSampPulseAmp->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseAmp(thit));
809 ((THcSignalHit*) frPosAdcSampPulseTimeRaw->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseTimeRaw(thit));
810 ((THcSignalHit*) frPosAdcSampPulseTime->ConstructedAt(nrSampPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseTime(thit)+fAdcTdcOffset);
811 //
812 if ( rawPosAdcHit.GetNPulses() ==0 || fUseSampWaveform ==1 ) {
813 ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPedRaw());
814 ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPed());
815
816 ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(nrPosAdcHits))->Set(npmt,rawPosAdcHit.GetSampPulseIntRaw(thit));
817 ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(npmt,rawPosAdcHit.GetSampPulseInt(thit));
818
819 ((THcSignalHit*) frPosAdcPulseAmpRaw->ConstructedAt(nrPosAdcHits))->Set(npmt,rawPosAdcHit.GetSampPulseAmpRaw(thit));
820 ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(npmt,rawPosAdcHit.GetSampPulseAmp(thit) );
821
822 ((THcSignalHit*) frPosAdcPulseTimeRaw->ConstructedAt(nrPosAdcHits))->Set(npmt,rawPosAdcHit.GetSampPulseTimeRaw(thit) );
823 ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(nrPosAdcHits))->Set(npmt, rawPosAdcHit.GetSampPulseTime(thit)+fAdcTdcOffset);
824 ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 3);
825 if (fUseSampWaveform ==1) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 0);
826 ++nrPosAdcHits;
829 fNumPosAdcHits.at(npmt-1) = npmt;
830 }
831 ++nrSampPosAdcHits;
832 }
833 }
834 //
835 if ( fUseSampWaveform == 0 ) {
836 for (UInt_t thit=0; thit<rawNegAdcHit.GetNPulses(); ++thit) {
837 ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPedRaw());
838 ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPed());
839
840 ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseIntRaw(thit));
841 ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseInt(thit));
842
843 ((THcSignalHit*) frNegAdcPulseAmpRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseAmpRaw(thit));
844 ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseAmp(thit));
845
846 ((THcSignalHit*) frNegAdcPulseTimeRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseTimeRaw(thit));
847 ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetPulseTime(thit));
848
849 if (rawNegAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 0);
850 if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 1);
851 if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0 && rawNegAdcHit.GetNSamples() >0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 2);
852
853
854 if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) {
855 Double_t PeakPedRatio= rawNegAdcHit.GetF250_PeakPedestalRatio();
856 Int_t NPedSamples= rawNegAdcHit.GetF250_NPedestalSamples();
857 Double_t AdcToC = rawNegAdcHit.GetAdcTopC();
858 Double_t AdcToV = rawNegAdcHit.GetAdcTomV();
859 if (fPedNegDefault[npmt-1] !=0) {
860 Double_t tPulseInt = AdcToC*(rawNegAdcHit.GetPulseIntRaw(thit) - fPedNegDefault[npmt-1]*PeakPedRatio);
861 ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(npmt, tPulseInt);
862 ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, fPedNegDefault[npmt-1]);
863 ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(npmt, float(fPedNegDefault[npmt-1])/float(NPedSamples)*AdcToV);
864
865 }
866 ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(npmt, 0.);
867 }
868
869 ++nrNegAdcHits;
872 fNumNegAdcHits.at(npmt-1) = npmt;
873 }
874 }
875 //
876 if (rawNegAdcHit.GetNSamples()>0 ) {
877 rawNegAdcHit.SetSampThreshold(fSampThreshold);
878 if (fSampNSA == 0) fSampNSA=rawNegAdcHit.GetF250_NSA();
879 if (fSampNSB == 0) fSampNSB=rawNegAdcHit.GetF250_NSB();
880 rawNegAdcHit.SetF250Params(fSampNSA,fSampNSB,4); // Set NPED =4
881 if (fSampNSAT != 2) rawNegAdcHit.SetSampNSAT(fSampNSAT);
882 rawNegAdcHit.SetSampIntTimePedestalPeak();
883 fNegAdcSampWaveform.push_back(float(npmt));
884 fNegAdcSampWaveform.push_back(float(rawNegAdcHit.GetNSamples()));
885 for (UInt_t thit = 0; thit < rawNegAdcHit.GetNSamples(); thit++) {
886 fNegAdcSampWaveform.push_back(rawNegAdcHit.GetSample(thit)); // ped subtracted sample (mV)
887 }
888 for (UInt_t thit = 0; thit < rawNegAdcHit.GetNSampPulses(); thit++) {
889 ((THcSignalHit*) frNegAdcSampPedRaw->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPedRaw());
890 ((THcSignalHit*) frNegAdcSampPed->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPed());
891 ((THcSignalHit*) frNegAdcSampPulseIntRaw->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseIntRaw(thit));
892 ((THcSignalHit*) frNegAdcSampPulseInt->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseInt(thit));
893
894 ((THcSignalHit*) frNegAdcSampPulseAmpRaw->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseAmpRaw(thit));
895 ((THcSignalHit*) frNegAdcSampPulseAmp->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseAmp(thit));
896 ((THcSignalHit*) frNegAdcSampPulseTimeRaw->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseTimeRaw(thit));
897 ((THcSignalHit*) frNegAdcSampPulseTime->ConstructedAt(nrSampNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseTime(thit));
898 //
899 if ( rawNegAdcHit.GetNPulses() ==0 || fUseSampWaveform ==1 ) {
900 ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPedRaw());
901 ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPed());
902
903 ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(nrNegAdcHits))->Set(npmt,rawNegAdcHit.GetSampPulseIntRaw(thit));
904 ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(npmt,rawNegAdcHit.GetSampPulseInt(thit));
905
906 ((THcSignalHit*) frNegAdcPulseAmpRaw->ConstructedAt(nrNegAdcHits))->Set(npmt,rawNegAdcHit.GetSampPulseAmpRaw(thit));
907 ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(npmt,rawNegAdcHit.GetSampPulseAmp(thit) );
908
909 ((THcSignalHit*) frNegAdcPulseTimeRaw->ConstructedAt(nrNegAdcHits))->Set(npmt,rawNegAdcHit.GetSampPulseTimeRaw(thit) );
910 ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(nrNegAdcHits))->Set(npmt, rawNegAdcHit.GetSampPulseTime(thit));
911 ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 3);
912 if (fUseSampWaveform ==1) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 0);
913 ++nrNegAdcHits;
916 fNumNegAdcHits.at(npmt-1) = npmt;
917 }
918 ++nrSampNegAdcHits;
919 }
920 }
921 //
922 ihit++;
923 }
924 return ihit;
925}
926
927//_____________________________________________________________________________
929{
930 return(0);
931}
932
933//_____________________________________________________________________________
935{
936 Double_t StartTime = 0.0;
937 if( fglHod ) StartTime = fglHod->GetStartTime();
938 Double_t OffsetTime = 0.0;
939 if( fglHod ) OffsetTime = fglHod->GetOffsetTime();
940 //cout << " starttime = " << StartTime << endl;
941 // Loop over the elements in the TClonesArray
942 for(Int_t ielem = 0; ielem < frPosAdcPulseInt->GetEntries(); ielem++) {
943
944 Int_t npmt = ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1;
945 Double_t pulsePed = ((THcSignalHit*) frPosAdcPed->ConstructedAt(ielem))->GetData();
946 Double_t pulseInt = ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(ielem))->GetData();
947 Double_t pulseIntRaw = ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(ielem))->GetData();
948 Double_t pulseAmp = ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(ielem))->GetData();
949 Double_t pulseTime = ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(ielem))->GetData();
950 Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
952 Bool_t pulseTimeCut = adctdcdiffTime > fAdcPosTimeWindowMin[npmt] && adctdcdiffTime < fAdcPosTimeWindowMax[npmt];
953
954 // By default, the last hit within the timing cut will be considered "good"
955 fGoodPosAdcMult.at(npmt) += 1;
956 if (pulseTimeCut) {
957 fGoodPosAdcPed.at(npmt) = pulsePed;
958 // cout << " out = " << npmt << " " << frPosAdcPulseInt->GetEntries() << " " <<fGoodPosAdcMult.at(npmt);
959 fGoodPosAdcPulseInt.at(npmt) = pulseInt;
960 fGoodPosAdcPulseIntRaw.at(npmt) = pulseIntRaw;
961 fGoodPosAdcPulseAmp.at(npmt) = pulseAmp;
962 fGoodPosAdcPulseTime.at(npmt) = pulseTime;
963 fGoodPosAdcTdcDiffTime.at(npmt) = adctdcdiffTime;
964
965 fPosNpe.at(npmt) = fPosGain[npmt]*fGoodPosAdcPulseInt.at(npmt);
966 fPosNpeSum += fPosNpe.at(npmt);
967
970 fNumGoodPosAdcHits.at(npmt) = npmt + 1;
971 }
972 }
973
974 // Loop over the elements in the TClonesArray
975 for(Int_t ielem = 0; ielem < frNegAdcPulseInt->GetEntries(); ielem++) {
976
977 Int_t npmt = ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1;
978 Double_t pulsePed = ((THcSignalHit*) frNegAdcPed->ConstructedAt(ielem))->GetData();
979 Double_t pulseInt = ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(ielem))->GetData();
980 Double_t pulseIntRaw = ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(ielem))->GetData();
981 Double_t pulseAmp = ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(ielem))->GetData();
982 Double_t pulseTime = ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(ielem))->GetData();
983 Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
985 Bool_t pulseTimeCut = adctdcdiffTime > fAdcNegTimeWindowMin[npmt] && adctdcdiffTime < fAdcNegTimeWindowMax[npmt];
986 fGoodNegAdcMult.at(npmt) += 1;
987
988 // By default, the last hit within the timing cut will be considered "good"
989 if (pulseTimeCut) {
990 fGoodNegAdcPed.at(npmt) = pulsePed;
991 fGoodNegAdcPulseIntRaw.at(npmt) = pulseIntRaw;
992 fGoodNegAdcPulseAmp.at(npmt) = pulseAmp;
993 fGoodNegAdcPulseInt.at(npmt) = pulseInt;
994 fGoodNegAdcPulseTime.at(npmt) = pulseTime;
995 fGoodNegAdcTdcDiffTime.at(npmt) = adctdcdiffTime;
996
997 fNegNpe.at(npmt) = fNegGain[npmt]*fGoodNegAdcPulseInt.at(npmt);
998 fNegNpeSum += fNegNpe.at(npmt);
999
1002 fNumGoodNegAdcHits.at(npmt) = npmt + 1;
1003 }
1004 }
1005
1007
1008 for(Int_t ihit=0; ihit < fNhits; ihit++) {
1009
1010 Int_t nPosTDCHits = 0;
1011 Int_t nNegTDCHits = 0;
1012 Int_t nPosADCHits = 0;
1013 Int_t nNegADCHits = 0;
1014
1015 // 6 GeV calculations
1016 Int_t adc_pos;
1017 Int_t adc_neg;
1018 Int_t tdc_pos = -1;
1019 Int_t tdc_neg = -1;
1020 if (fSixGevData) {
1021 THcAerogelHit* hit = (THcAerogelHit*) fRawHitList->At(ihit);
1022 Int_t npmt = hit->fCounter - 1;
1023
1024 // Sum positive and negative hits to fill tot_good_hits
1025 if(fPosNpe.at(npmt) > 0.3) {fNADCPosHits++; fNGoodHits++;}
1026 if(fNegNpe.at(npmt) > 0.3) {fNADCNegHits++; fNGoodHits++;}
1027
1028 // ADC positive hit
1029 if((adc_pos = hit->GetRawAdcHitPos().GetPulseInt()) > 0) {
1030 THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++);
1031 sighit->Set(hit->fCounter, adc_pos);
1032 }
1033 // ADC negative hit
1034 if((adc_neg = hit->GetRawAdcHitNeg().GetPulseInt()) > 0) {
1035 THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++);
1036 sighit->Set(hit->fCounter, adc_neg);
1037 }
1038 // TDC positive hit
1039 if(hit->GetRawTdcHitPos().GetNHits() > 0) {
1040 THcSignalHit *sighit = (THcSignalHit*) fPosTDCHits->ConstructedAt(nPosTDCHits++);
1041 tdc_pos = hit->GetRawTdcHitPos().GetTime()+fTdcOffset;
1042 sighit->Set(hit->fCounter, tdc_pos);
1043 }
1044 // TDC negative hit
1045 if(hit->GetRawTdcHitNeg().GetNHits() > 0) {
1046 THcSignalHit *sighit = (THcSignalHit*) fNegTDCHits->ConstructedAt(nNegTDCHits++);
1047 tdc_neg = hit->GetRawTdcHitNeg().GetTime()+fTdcOffset;
1048 sighit->Set(hit->fCounter, tdc_neg);
1049 }
1050 // For each TDC, identify the first hit that is positive.
1051 tdc_pos = -1;
1052 tdc_neg = -1;
1053 for(UInt_t thit=0; thit<hit->GetRawTdcHitPos().GetNHits(); thit++) {
1054 Int_t tdc = hit->GetRawTdcHitPos().GetTime(thit);
1055 if(tdc >=0 ) {
1056 tdc_pos = tdc;
1057 break;
1058 }
1059 }
1060 for(UInt_t thit=0; thit<hit->GetRawTdcHitNeg().GetNHits(); thit++) {
1061 Int_t tdc = hit->GetRawTdcHitNeg().GetTime(thit);
1062 if(tdc >= 0) {
1063 tdc_neg = tdc;
1064 break;
1065 }
1066 }
1067
1068 fA_Pos[npmt] = adc_pos;
1069 fA_Neg[npmt] = adc_neg;
1070 fA_Pos_p[npmt] = fA_Pos[npmt] - fPosPedMean[npmt];
1071 fA_Neg_p[npmt] = fA_Neg[npmt] - fNegPedMean[npmt];
1072 fT_Pos[npmt] = tdc_pos;
1073 fT_Neg[npmt] = tdc_neg;
1074
1075 if(fA_Pos[npmt] < 8000) fPosNpeSixGev[npmt] = fPosGain[npmt]*fA_Pos_p[npmt];
1076 else fPosNpeSixGev[npmt] = 100.0;
1077
1078 if(fA_Neg[npmt] < 8000) fNegNpeSixGev[npmt] = fNegGain[npmt]*fA_Neg_p[npmt];
1079 else fNegNpeSixGev[npmt] = 100.0;
1080
1083
1084 // Sum positive and negative hits to fill tot_good_hits
1085 if(fPosNpeSixGev[npmt] > 0.3) {fNADCPosHits++; fNGoodHits++;}
1086 if(fNegNpeSixGev[npmt] > 0.3) {fNADCNegHits++; fNGoodHits++;}
1087
1088 if(fT_Pos[npmt] > 0 && fT_Pos[npmt] < 8000) fNTDCPosHits++;
1089 if(fT_Neg[npmt] > 0 && fT_Neg[npmt] < 8000) fNTDCNegHits++;
1090 }
1091
1092 if (fPosNpeSumSixGev > 0.5 || fNegNpeSumSixGev > 0.5)
1094 else fNpeSumSixGev = 0.0;
1095 // If total hits are 0, then give a noticable ridiculous NPE
1096 if (fNhits < 1) fNpeSumSixGev = 0.0;
1097
1098 }
1099 return 0;
1100}
1101
1102//_____________________________________________________________________________
1104{
1105
1106 Int_t nTracks = tracks.GetLast() + 1;
1107
1108 for (Int_t itrack = 0; itrack < nTracks; itrack++) {
1109
1110 THaTrack* track = dynamic_cast<THaTrack*> (tracks[itrack]);
1111 if (track->GetIndex() != 0) continue; // Select the best track
1112
1113 Double_t trackChi2 = track->GetChi2();
1114 Int_t trackNDoF = track->GetNDoF();
1115 Double_t trackRedChi2 = trackChi2/trackNDoF;
1116 Double_t trackBeta = track->GetBeta();
1117 Double_t trackEnergy = track->GetEnergy();
1118 Double_t trackMom = track->GetP();
1119 Double_t trackENorm = trackEnergy/trackMom;
1120 Double_t trackDp = track->GetDp();
1121 Double_t trackXfp = track->GetX();
1122 Double_t trackYfp = track->GetY();
1123 Double_t trackTheta = track->GetTheta();
1124 Double_t trackPhi = track->GetPhi();
1125
1126 Bool_t trackRedChi2Cut = trackRedChi2 > fRedChi2Min && trackRedChi2 < fRedChi2Max;
1127 Bool_t trackBetaCut = trackBeta > fBetaMin && trackBeta < fBetaMax;
1128 Bool_t trackENormCut = trackENorm > fENormMin && trackENorm < fENormMax;
1129 Bool_t trackDpCut = trackDp > fDpMin && trackDp < fDpMax;
1130 fXAtAero = trackXfp + trackTheta * fDiffBoxZPos;
1131 fYAtAero = trackYfp + trackPhi * fDiffBoxZPos;
1132
1133 if (trackRedChi2Cut && trackBetaCut && trackENormCut && trackDpCut) {
1134
1135 // Project the track to the Aerogel diffuser box plane
1136
1137 // cout << "Aerogel Detector: " << GetName() << endl;
1138 // cout << "nTracks = " << nTracks << "\t" << "trackChi2 = " << trackChi2
1139 // << "\t" << "trackNDof = " << trackNDoF << "\t" << "trackRedChi2 = " << trackRedChi2 << endl;
1140 // cout << "trackBeta = " << trackBeta << "\t" << "trackEnergy = " << trackEnergy << "\t"
1141 // << "trackMom = " << trackMom << "\t" << "trackENorm = " << trackENorm << endl;
1142 // cout << "trackXfp = " << trackXfp << "\t" << "trackYfp = " << trackYfp << "\t"
1143 // << "trackTheta = " << trackTheta << "\t" << "trackPhi = " << trackPhi << endl;
1144 // cout << "fDiffBoxZPos = " << fDiffBoxZPos << "\t" << "fXAtAero = " << fXAtAero << "\t" << "fYAtAero = " << fYAtAero << endl;
1145 // cout << "=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:" << endl;
1146
1147
1148 for (Int_t iregion = 0; iregion < fNRegions; iregion++) {
1149
1150 if ((TMath::Abs(fRegionValue[GetIndex(iregion, 0)] - fXAtAero) < fRegionValue[GetIndex(iregion, 4)]) &&
1151 (TMath::Abs(fRegionValue[GetIndex(iregion, 1)] - fYAtAero) < fRegionValue[GetIndex(iregion, 5)]) &&
1152 (TMath::Abs(fRegionValue[GetIndex(iregion, 2)] - trackTheta) < fRegionValue[GetIndex(iregion, 6)]) &&
1153 (TMath::Abs(fRegionValue[GetIndex(iregion, 3)] - trackPhi) < fRegionValue[GetIndex(iregion, 7)])) {
1154
1156 fNumTracksMatched.at(iregion) = iregion + 1;
1157
1158 if (fNpeSum > fNpeThresh) {
1160 fNumTracksFired.at(iregion) = iregion + 1;
1161 } // NPE threshold cut
1162 } // Regional cuts
1163 } // Loop over regions
1164 } // Tracking cuts
1165 } // Track loop
1166
1167 return 0;
1168}
1169
1170//_____________________________________________________________________________
1171// Method for initializing pedestals in the 6 GeV era
1173{
1174 fNPedestalEvents = 0;
1175 fMinPeds = 0; // Do not calculate pedestals by default
1176
1178 fPosPedLimit = new Int_t [fNelem];
1179 fNegPedLimit = new Int_t [fNelem];
1182 fPosPedSum = new Int_t [fNelem];
1183 fPosPedSum2 = new Int_t [fNelem];
1184 fPosPedCount = new Int_t [fNelem];
1185 fNegPedSum = new Int_t [fNelem];
1186 fNegPedSum2 = new Int_t [fNelem];
1187 fNegPedCount = new Int_t [fNelem];
1188 fPosPed = new Double_t [fNelem];
1189 fPosThresh = new Double_t [fNelem];
1190 fNegPed = new Double_t [fNelem];
1191 fNegThresh = new Double_t [fNelem];
1192
1193 for(Int_t i = 0;i < fNelem; i++) {
1194 fPosPedSum[i] = 0;
1195 fPosPedSum2[i] = 0;
1196 fPosPedLimit[i] = 1000; // In engine, this are set in parameter file
1197 fPosPedCount[i] = 0;
1198 fNegPedSum[i] = 0;
1199 fNegPedSum2[i] = 0;
1200 fNegPedLimit[i] = 1000; // In engine, this are set in parameter file
1201 fNegPedCount[i] = 0;
1202 fPosPedMean[i] = 0; // Default pedestal values
1203 fNegPedMean[i] = 0; // Default pedestal values
1204 }
1205
1206}
1207
1208//_____________________________________________________________________________
1209// Method for accumulating pedestals in the 6 GeV era
1211{
1212 // Extract data from the hit list, accumulating into arrays for
1213 // calculating pedestals
1214
1215 Int_t nrawhits = rawhits->GetLast()+1;
1216 Int_t ihit = 0;
1217
1218 while(ihit < nrawhits) {
1219 THcAerogelHit* hit = (THcAerogelHit *) rawhits->At(ihit);
1220
1221 Int_t element = hit->fCounter - 1;
1222 Int_t adcpos = hit->GetRawAdcHitPos().GetPulseInt();
1223 Int_t adcneg = hit->GetRawAdcHitNeg().GetPulseInt();
1224 if(adcpos <= fPosPedLimit[element]) {
1225 fPosPedSum[element] += adcpos;
1226 fPosPedSum2[element] += adcpos*adcpos;
1227 fPosPedCount[element]++;
1228 if(fPosPedCount[element] == fMinPeds/5)
1229 fPosPedLimit[element] = 100 + fPosPedSum[element]/fPosPedCount[element];
1230 }
1231 if(adcneg <= fNegPedLimit[element]) {
1232 fNegPedSum[element] += adcneg;
1233 fNegPedSum2[element] += adcneg*adcneg;
1234 fNegPedCount[element]++;
1235 if(fNegPedCount[element] == fMinPeds/5)
1236 fNegPedLimit[element] = 100 + fNegPedSum[element]/fNegPedCount[element];
1237 }
1238 ihit++;
1239 }
1241 return;
1242}
1243
1244//_____________________________________________________________________________
1245// Method for calculating pedestals in the 6 GeV era
1247{
1248 // Use the accumulated pedestal data to calculate pedestals
1249 // Later add check to see if pedestals have drifted ("Danger Will Robinson!")
1250 // cout << "Plane: " << fPlaneNum << endl;
1251 for(Int_t i=0; i<fNelem;i++) {
1252
1253 // Positive tubes
1254 fPosPed[i] = ((Double_t) fPosPedSum[i]) / TMath::Max(1, fPosPedCount[i]);
1255 fPosThresh[i] = fPosPed[i] + 15;
1256 // Negative tubes
1257 fNegPed[i] = ((Double_t) fNegPedSum[i]) / TMath::Max(1, fNegPedCount[i]);
1258 fNegThresh[i] = fNegPed[i] + 15;
1259 // cout << i+1 << " " << fPosPed[i] << " " << fNegPed[i] << endl;
1260
1261 // Just a copy for now, but allow the possibility that fXXXPedMean is set
1262 // in a parameter file and only overwritten if there is a sufficient number of
1263 // pedestal events. (So that pedestals are sensible even if the pedestal events were
1264 // not acquired.)
1265 if(fMinPeds > 0) {
1266 if(fPosPedCount[i] > fMinPeds)
1267 fPosPedMean[i] = fPosPed[i];
1268 if(fNegPedCount[i] > fMinPeds)
1269 fNegPedMean[i] = fNegPed[i];
1270 }
1271 }
1272}
1273
1274//_____________________________________________________________________________
1276{
1277 return fNRegions * nValue + nRegion;
1278}
1279
1280//_____________________________________________________________________________
1281void THcAerogel::Print(const Option_t* opt) const
1282{
1284
1285 // Print out the pedestals
1286 if (fSixGevData) {
1287 cout << endl;
1288 cout << "Aerogel Pedestals" << endl;
1289 cout << "No. Neg Pos" << endl;
1290 for(Int_t i=0; i<fNelem; i++)
1291 cout << " " << i << "\t" << fNegPedMean[i] << "\t" << fPosPedMean[i] << endl;
1292 cout << endl;
1293 cout << " fMinPeds = " << fMinPeds << endl;
1294 cout << endl;
1295 }
1296}
1297//_____________________________________________________________________________
1299{
1300 MissReport(Form("%s.%s", GetApparatus()->GetName(), GetName()));
1301 return 0;
1302}
int Int_t
unsigned int UInt_t
const Data_t kBig
bool Bool_t
float Float_t
double Double_t
const Bool_t kTRUE
const char Option_t
Option_t Option_t TPoint TPoint const char mode
R__EXTERN class THaVarList * gHaVars
R__EXTERN class THaCutList * gHaCuts
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
Definition THcGlobals.h:11
R__EXTERN class THcDetectorMap * gHcDetectorMap
Definition THcGlobals.h:12
char * Form(const char *fmt,...)
void Clear(Option_t *option="") override
TObject * ConstructedAt(Int_t idx)
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
virtual const char * Here(const char *) const
virtual void Print(Option_t *opt="") const
virtual Int_t Result(const char *cutname="", EWarnMode mode=kWarn)
UInt_t GetTotNumChan() const
THaDetMap * fDetMap
THaApparatus * GetApparatus() const
Double_t GetChi2() const
Int_t GetNDoF() const
Double_t GetX() const
Double_t GetPhi() const
Double_t GetEnergy() const
Double_t GetDp() const
Double_t GetTheta() const
Double_t GetBeta() const
Double_t GetY() const
Int_t GetIndex() const
Double_t GetP() const
virtual THaVar * Find(const char *name) const
const void * GetValuePointer() const
Raw Aerogel Hit Info.
Class for an Aerogel detector consisting of pairs of PMT's attached to a diffuser box.
Definition THcAerogel.h:16
Double_t * fAdcNegTimeWindowMax
Definition THcAerogel.h:78
void DeletePedestalArrays()
TClonesArray * frPosAdcPedRaw
Definition THcAerogel.h:100
vector< Int_t > fNumPosAdcHits
Definition THcAerogel.h:136
TClonesArray * frPosAdcSampPulseIntRaw
Definition THcAerogel.h:120
TClonesArray * fPosADCHits
Definition THcAerogel.h:200
Double_t * fRegionValue
Definition THcAerogel.h:83
TClonesArray * frPosAdcSampPedRaw
Definition THcAerogel.h:119
Int_t * fPosPedLimit
Definition THcAerogel.h:177
vector< Double_t > fNegNpe
Definition THcAerogel.h:143
Int_t fTdcOffset
Definition THcAerogel.h:169
Double_t * fPosGain
Definition THcAerogel.h:97
vector< Double_t > fGoodPosAdcPed
Definition THcAerogel.h:144
TClonesArray * frNegAdcPulseInt
Definition THcAerogel.h:113
Float_t * fA_Pos
Definition THcAerogel.h:183
Double_t fRedChi2Max
Definition THcAerogel.h:61
Double_t fDpMin
Definition THcAerogel.h:66
Double_t * fNegSig
Definition THcAerogel.h:193
Int_t * fPedPosDefault
Definition THcAerogel.h:80
Double_t fENormMin
Definition THcAerogel.h:64
Int_t * fPedNegDefault
Definition THcAerogel.h:79
virtual void AccumulatePedestals(TClonesArray *rawhits)
static const Int_t MaxNumAdcPulse
Definition THcAerogel.h:49
Float_t * fT_Neg
Definition THcAerogel.h:188
vector< Int_t > fNumGoodNegAdcHits
Definition THcAerogel.h:139
vector< Double_t > fGoodPosAdcPulseAmp
Definition THcAerogel.h:148
Double_t * fPosSig
Definition THcAerogel.h:190
Int_t * fNegPedSum2
Definition THcAerogel.h:180
Double_t * fPosThresh
Definition THcAerogel.h:191
Double_t fXAtAero
Definition THcAerogel.h:69
vector< Double_t > fGoodNegAdcMult
Definition THcAerogel.h:152
TClonesArray * fPosAdcErrorFlag
Definition THcAerogel.h:116
Double_t * fPosPed
Definition THcAerogel.h:189
Double_t fPosNpeSum
Definition THcAerogel.h:94
vector< Double_t > fGoodPosAdcPulseIntRaw
Definition THcAerogel.h:147
Double_t fPosNpeSumSixGev
Definition THcAerogel.h:172
TClonesArray * frPosAdcSampPulseTime
Definition THcAerogel.h:126
TClonesArray * frNegAdcSampPulseAmp
Definition THcAerogel.h:133
Double_t * fNegPed
Definition THcAerogel.h:192
vector< Double_t > fGoodPosAdcTdcDiffTime
Definition THcAerogel.h:150
TClonesArray * frNegAdcPed
Definition THcAerogel.h:112
vector< Double_t > fPosNpeSixGev
Definition THcAerogel.h:203
Int_t * fPosPedSum2
Definition THcAerogel.h:176
TClonesArray * fNegAdcErrorFlag
Definition THcAerogel.h:117
virtual void Print(const Option_t *opt) const
Double_t fSampThreshold
Definition THcAerogel.h:55
Double_t * fNegPedMean
Definition THcAerogel.h:196
vector< Int_t > fNumNegAdcHits
Definition THcAerogel.h:137
TClonesArray * frNegAdcSampPulseTimeRaw
Definition THcAerogel.h:130
TClonesArray * frPosAdcSampPulseAmp
Definition THcAerogel.h:125
TClonesArray * fPosTDCHits
Definition THcAerogel.h:198
TClonesArray * frNegAdcSampPedRaw
Definition THcAerogel.h:127
TClonesArray * frPosAdcPulseAmpRaw
Definition THcAerogel.h:102
vector< Int_t > fNumTracksFired
Definition THcAerogel.h:141
virtual Int_t Decode(const THaEvData &)
TClonesArray * frPosAdcSampPulseTimeRaw
Definition THcAerogel.h:122
Double_t fNegNpeSum
Definition THcAerogel.h:95
Int_t fTotNumTracksFired
Definition THcAerogel.h:92
vector< Double_t > fGoodNegAdcPulseIntRaw
Definition THcAerogel.h:154
Int_t fTotNumGoodNegAdcHits
Definition THcAerogel.h:90
TClonesArray * frPosAdcSampPulseAmpRaw
Definition THcAerogel.h:121
TClonesArray * frNegAdcSampPulseInt
Definition THcAerogel.h:132
Int_t * fNegPedSum
Definition THcAerogel.h:179
virtual Int_t ApplyCorrections(void)
TClonesArray * frPosAdcSampPulseInt
Definition THcAerogel.h:124
TClonesArray * fNegTDCHits
Definition THcAerogel.h:199
Double_t fBetaMin
Definition THcAerogel.h:62
Double_t * fPosPedMean
Definition THcAerogel.h:195
Int_t fTotNumPosAdcHits
Definition THcAerogel.h:87
Double_t * fNegGain
Definition THcAerogel.h:98
Int_t GetIndex(Int_t nRegion, Int_t nValue)
THcHodoscope * fglHod
Definition THcAerogel.h:210
void DeleteArrays()
Int_t * fPosPedSum
Definition THcAerogel.h:175
vector< Double_t > fGoodPosAdcPulseInt
Definition THcAerogel.h:146
Bool_t * fPresentP
Definition THcAerogel.h:43
Double_t fNegNpeSumSixGev
Definition THcAerogel.h:173
Double_t * fNegThresh
Definition THcAerogel.h:194
Int_t fNPedestalEvents
Definition THcAerogel.h:170
vector< Double_t > fPosAdcSampWaveform
Definition THcAerogel.h:159
vector< Int_t > fNumTracksMatched
Definition THcAerogel.h:140
TClonesArray * frPosAdcPed
Definition THcAerogel.h:104
Int_t fTotNumTracksMatched
Definition THcAerogel.h:91
TClonesArray * frPosAdcSampPed
Definition THcAerogel.h:123
TClonesArray * frNegAdcSampPulseIntRaw
Definition THcAerogel.h:128
Int_t fUseSampWaveform
Definition THcAerogel.h:54
Int_t fNRegions
Definition THcAerogel.h:51
Double_t fENormMax
Definition THcAerogel.h:65
vector< Double_t > fPosNpe
Definition THcAerogel.h:142
Int_t fRegionsValueMax
Definition THcAerogel.h:52
Double_t fNpeSum
Definition THcAerogel.h:96
Int_t fDebugAdc
Definition THcAerogel.h:59
TClonesArray * frNegAdcPulseTimeRaw
Definition THcAerogel.h:111
Int_t fSixGevData
Definition THcAerogel.h:163
virtual void CalculatePedestals()
Int_t * fPosPedCount
Definition THcAerogel.h:178
Double_t fNpeThresh
Definition THcAerogel.h:71
TClonesArray * frNegAdcPedRaw
Definition THcAerogel.h:108
Int_t fTotNumGoodPosAdcHits
Definition THcAerogel.h:88
TClonesArray * frNegAdcPulseTime
Definition THcAerogel.h:115
Double_t fYAtAero
Definition THcAerogel.h:70
vector< Double_t > fGoodNegAdcPulseInt
Definition THcAerogel.h:153
Int_t fOutputSampWaveform
Definition THcAerogel.h:53
Double_t * fAdcNegTimeWindowMin
Definition THcAerogel.h:77
virtual Int_t FineProcess(TClonesArray &tracks)
vector< Double_t > fGoodNegAdcTdcDiffTime
Definition THcAerogel.h:157
vector< Double_t > fGoodPosAdcMult
Definition THcAerogel.h:145
Double_t * fAdcPosTimeWindowMin
Definition THcAerogel.h:75
Double_t fBetaMax
Definition THcAerogel.h:63
Double_t fNpeSumSixGev
Definition THcAerogel.h:174
virtual void InitializePedestals()
Int_t fTotNumAdcHits
Definition THcAerogel.h:85
TClonesArray * frPosAdcPulseTime
Definition THcAerogel.h:107
Int_t * fNegPedLimit
Definition THcAerogel.h:181
Int_t * fNegPedCount
Definition THcAerogel.h:182
TClonesArray * frNegAdcPulseAmp
Definition THcAerogel.h:114
TClonesArray * fNegADCHits
Definition THcAerogel.h:201
Int_t fNTDCPosHits
Definition THcAerogel.h:167
Int_t fSampNSB
Definition THcAerogel.h:58
TClonesArray * frPosAdcPulseAmp
Definition THcAerogel.h:106
Double_t fDiffBoxZPos
Definition THcAerogel.h:68
Float_t * fA_Neg
Definition THcAerogel.h:184
vector< Double_t > fNegAdcSampWaveform
Definition THcAerogel.h:158
Double_t fRedChi2Min
Definition THcAerogel.h:60
Int_t End(THaRunBase *run=0)
virtual ~THcAerogel()
Float_t * fA_Neg_p
Definition THcAerogel.h:186
Int_t fADC_RefTimeCut
Definition THcAerogel.h:45
virtual void Clear(Option_t *opt="")
Double_t fDpMax
Definition THcAerogel.h:67
TClonesArray * frNegAdcSampPulseTime
Definition THcAerogel.h:134
Int_t fSampNSAT
Definition THcAerogel.h:57
Double_t * fAdcPosTimeWindowMax
Definition THcAerogel.h:76
vector< Int_t > fNumGoodPosAdcHits
Definition THcAerogel.h:138
vector< Double_t > fGoodPosAdcPulseTime
Definition THcAerogel.h:149
Int_t fTotNumGoodAdcHits
Definition THcAerogel.h:86
Int_t fMinPeds
Definition THcAerogel.h:171
TClonesArray * frNegAdcPulseIntRaw
Definition THcAerogel.h:109
virtual Int_t ReadDatabase(const TDatime &date)
vector< Double_t > fGoodNegAdcPulseTime
Definition THcAerogel.h:156
Int_t fNGoodHits
Definition THcAerogel.h:164
Int_t fTotNumNegAdcHits
Definition THcAerogel.h:89
TClonesArray * frPosAdcPulseIntRaw
Definition THcAerogel.h:101
Float_t * fA_Pos_p
Definition THcAerogel.h:185
Float_t * fT_Pos
Definition THcAerogel.h:187
Int_t fSampNSA
Definition THcAerogel.h:56
virtual Int_t CoarseProcess(TClonesArray &tracks)
TClonesArray * frPosAdcPulseInt
Definition THcAerogel.h:105
Int_t fNADCPosHits
Definition THcAerogel.h:165
vector< Double_t > fGoodNegAdcPed
Definition THcAerogel.h:151
Int_t fNADCNegHits
Definition THcAerogel.h:166
vector< Double_t > fNegNpeSixGev
Definition THcAerogel.h:204
TClonesArray * frNegAdcPulseAmpRaw
Definition THcAerogel.h:110
Int_t fAnalyzePedestals
Definition THcAerogel.h:162
Int_t fNhits
Definition THcAerogel.h:42
Int_t fNTDCNegHits
Definition THcAerogel.h:168
TClonesArray * frNegAdcSampPed
Definition THcAerogel.h:131
vector< Double_t > fGoodNegAdcPulseAmp
Definition THcAerogel.h:155
Double_t fAdcTdcOffset
Definition THcAerogel.h:82
virtual Int_t DefineVariables(EMode mode=kDefine)
TClonesArray * frNegAdcSampPulseAmpRaw
Definition THcAerogel.h:129
TClonesArray * frPosAdcPulseTimeRaw
Definition THcAerogel.h:103
virtual Int_t FillMap(THaDetMap *detmap, const char *detectorname)
A standard Hall C spectrometer apparatus.
virtual Int_t DecodeToHitList(const THaEvData &evdata, Bool_t suppress=kFALSE)
Populate the hitlist from the raw event data.
TClonesArray * fRawHitList
Definition THcHitList.h:51
void CreateMissReportParms(const char *prefix) const
void InitHitList(THaDetMap *detmap, const char *hitclass, Int_t maxhits, Int_t tdcref_cut=0, Int_t adcref_cut=0)
Save the electronics module to detector mapping and initialize a hit array of hits of class hitclass.
void MissReport(const char *name) const
Generic hodoscope consisting of multiple planes with multiple paddles with phototubes on both ends.
Double_t GetStartTime() const
Double_t GetOffsetTime() const
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
Class representing a single raw ADC hit.
Definition THcRawAdcHit.h:7
Int_t GetSampPulseIntRaw(UInt_t iPulse=0) const
UInt_t GetNSampPulses() const
Double_t GetSampPulseInt(UInt_t iPulse=0) const
Int_t GetPedRaw() const
Gets raw signal pedestal. In channels.
Int_t GetSampPulseAmpRaw(UInt_t iPulse=0) const
Double_t GetSampPulseTime(UInt_t iPulse=0) const
UInt_t GetNPulses() const
Gets number of set pulses.
Int_t GetF250_NSB() const
UInt_t GetNSamples() const
Gets number of set samples.
Int_t GetSampPedRaw() const
void SetSampNSAT(Int_t nsat)
static constexpr Double_t GetAdcTopC()
void SetSampThreshold(Double_t thres)
Double_t GetPulseAmp(UInt_t iPulse=0) const
Gets pedestal subtracted pulse amplitude. In channels.
Double_t GetSample(UInt_t iSample=0) const
void SetSampIntTimePedestalPeak()
Int_t GetPulseAmpRaw(UInt_t iPulse=0) const
Gets raw pulse amplitude. In channels.
Double_t GetPed() const
Gets sample pedestal. In channels.
Double_t GetF250_PeakPedestalRatio() const
Int_t GetPulseTimeRaw(UInt_t iPulse=0) const
Gets raw pulse time. In subsamples.
Double_t GetSampPulseAmp(UInt_t iPulse=0) const
Double_t GetPulseTime(UInt_t iPulse=0) const
Int_t GetF250_NPedestalSamples() const
Int_t GetPulseIntRaw(UInt_t iPulse=0) const
Gets raw pulse integral. In channels.
Int_t GetSampPulseTimeRaw(UInt_t iPulse=0) const
Double_t GetSampPed() const
Int_t GetF250_NSA() const
static constexpr Double_t GetAdcTomV()
void SetF250Params(Int_t NSA, Int_t NSB, Int_t NPED)
Sets F250 parameters used for pedestal subtraction.
Double_t GetPulseInt(UInt_t iPulse=0) const
Gets pedestal subtracted pulse integral. In channels.
Int_t fCounter
Definition THcRawHit.h:53
THcRawAdcHit & GetRawAdcHitPos()
THcRawAdcHit & GetRawAdcHitNeg()
THcRawTdcHit & GetRawTdcHitNeg()
THcRawTdcHit & GetRawTdcHitPos()
Int_t GetTime(UInt_t iHit=0) const
Gets TDC time. In channels.
UInt_t GetNHits() const
Gets the number of set hits.
virtual void Set(Int_t paddle, Int_t data)
const char * GetName() const override
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
Int_t GetLast() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
Double_t Abs(Double_t d)
Double_t Max(Double_t a, Double_t b)
STL namespace.
void tracks()