forked from JeffersonLab/SBS-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSBSGEMModule.cxx
6185 lines (4790 loc) · 263 KB
/
SBSGEMModule.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include "SBSGEMModule.h"
#include "TDatime.h"
#include "THaEvData.h"
#include "THaApparatus.h"
#include "THaRun.h"
#include "TRotation.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TF1.h"
#include "TGraphErrors.h"
#include "TClonesArray.h"
#include <algorithm>
#include <iomanip>
using namespace std;
//using namespace SBSGEMModule;
//This should not be hard-coded, I think, but read in from the database (or perhaps not, if it never changes? For now we keep it hard-coded)
// const int APVMAP[128] = {1, 33, 65, 97, 9, 41, 73, 105, 17, 49, 81, 113, 25, 57, 89, 121, 3, 35, 67, 99, 11, 43, 75, 107, 19, 51, 83, 115, 27, 59, 91, 123, 5, 37, 69, 101, 13, 45, 77, 109, 21, 53, 85, 117, 29, 61, 93, 125, 7, 39, 71, 103, 15, 47, 79, 111, 23, 55, 87, 119, 31, 63, 95, 127, 0, 32, 64, 96, 8, 40, 72, 104, 16, 48, 80, 112, 24, 56, 88, 120, 2, 34, 66, 98, 10, 42, 74, 106, 18, 50, 82, 114, 26, 58, 90, 122, 4, 36, 68, 100, 12, 44, 76, 108, 20, 52, 84, 116, 28, 60, 92, 124, 6, 38, 70, 102, 14, 46, 78, 110, 22, 54, 86, 118, 30, 62, 94, 126};
SBSGEMModule::SBSGEMModule( const char *name, const char *description,
THaDetectorBase* parent ):
THaSubDetector(name,description,parent)
{
// FIXME: To database
//Set Default values for fZeroSuppress and fZeroSuppressRMS:
fZeroSuppress = kTRUE;
fZeroSuppressRMS = 5.0; //threshold in units of RMS:
fNegSignalStudy = kFALSE;
fPedestalMode = kFALSE;
fPedHistosInitialized = kFALSE;
fSubtractPedBeforeCommonMode = false; //only affects the pedestal-mode analysis
//Default online zero suppression to FALSE: actually I wonder if it would be better to use this in
// Moved this to MPDModule, since this should be done during the decoding of the raw APV data:
fOnlineZeroSuppression = kFALSE;
fCommonModeFlag = 0; //"sorting" method
fCommonModeOnlFlag = 3; // 3 = Danning method during GMn, 4 = Danning method during GEn
//Default: discard highest and lowest 28 strips for "sorting method" common-mode calculation:
fCommonModeNstripRejectHigh = 28;
fCommonModeNstripRejectLow = 28;
fCommonModeNumIterations = 3;
fCommonModeMinStripsInRange = 10;
fMakeCommonModePlots = false;
fCommonModePlotsInitialized = false;
fCommonModePlots_DBoverride = false;
fMakeEventInfoPlots = false;
fEventInfoPlotsInitialized = false;
fPedSubFlag = 1; //default to online ped subtraction, as that is the mode we will run in most of the time
fTrigTime = 0.0;
fMaxTrigTimeCorrection = 25.0;
fTrigTimeSlope = 1.0; //slope of GEM time versus trig time correlation
//Set default values for decode map parameters:
fN_APV25_CHAN = 128;
fN_MPD_TIME_SAMP = 6;
fMPDMAP_ROW_SIZE = 9;
//We should probably get rid of this as it's not used, only leads to confusion:
fNumberOfChannelInFrame = 129;
fSamplePeriod = 24.0; //nanoseconds:
fSigma_hitshape = 0.0004; //0.4 mm; controls cluster-splitting algorithm
// for( Int_t i = 0; i < N_MPD_TIME_SAMP; i++ ){
// fadc[i] = NULL;
// }
//Default clustering parameters:
fThresholdSample = 50.0;
fThresholdStripSum = 250.0;
fThresholdClusterSum = 500.0;
fThresholdSampleDeconv = 50.0;
fThresholdDeconvADCMaxCombo = 75.0;
fThresholdClusterSumDeconv = 150.0;
fADCasymCut = 1.1;
fTimeCutUVdiff = 30.0;
fCorrCoeffCut = -1.1;
fCorrCoeffCutDeconv = -1.1;
fADCasymSigma = 0.06;
fADCratioSigma = 0.1;
fTimeCutUVsigma = 3.0; //ns
fTimeCutUVdiffDeconv = 40.0; //ns
fTimeCutUVsigmaDeconv = 7.0;
fTimeCutUVdiffFit = 30.0;
fTimeCutUVsigmaFit = 3.0;
fFiltering_flag1D = 0; //"soft" cuts
fFiltering_flag2D = 0; //"soft" cuts
// default these offsets to zero:
fUStripOffset = 0.0;
fVStripOffset = 0.0;
fMakeEfficiencyPlots = true;
fEfficiencyInitialized = false;
// We want to change the default values for these dummy channels to accommodate up to 40 MPDs per VTP:
// fChan_CM_flags = 512; //default to 512:
// fChan_TimeStamp_low = 513;
// fChan_TimeStamp_high = 514;
// fChan_MPD_EventCount = 515;
// fChan_MPD_Debug = 516;
//Start dummy channels at 640 by default, to accommodate up to 40 MPDs per VTP crate
fChan_CM_flags = 640; //default to 640 (so as not to step on up to 40 MPDs per VTP crate):
fChan_TimeStamp_low = 641;
fChan_TimeStamp_high = 642;
fChan_MPD_EventCount = 643;
fChan_MPD_Debug = 644;
UInt_t MAXNSAMP_PER_APV = fN_APV25_CHAN * fN_MPD_TIME_SAMP;
//arrays to hold raw data from one APV card:
fStripAPV.resize( MAXNSAMP_PER_APV );
fRawStripAPV.resize( MAXNSAMP_PER_APV );
fRawADC_APV.resize( MAXNSAMP_PER_APV );
fPedSubADC_APV.resize( MAXNSAMP_PER_APV );
fCommonModeSubtractedADC_APV.resize( MAXNSAMP_PER_APV );
fCM_online.resize( fN_MPD_TIME_SAMP );
//default to
//fMAX2DHITS = 250000;
fMAX2DHITS = 10000;
fRMS_ConversionFactor = sqrt(fN_MPD_TIME_SAMP); //=2.45
fIsMC = false; //need to set default value!
fAPVmapping = SBSGEM::kUVA_XY; //default to UVA X/Y style APV mapping, but require this in the database::
InitAPVMAP();
fModuleGain = 1.0;
// std::cout << "SBSGEMModule constructor invoked, name = " << name << std::endl;
//Number of sigmas for defining common-mode max for online zero suppression
fCommonModeRange_nsigma = 5.0;
fSuppressFirstLast = 0; // suppress strips peaking in first or last time sample by default:
//fUseStripTimingCuts = false;
fStripTau = 56.0; //ns, default value. Eventually load this from DB. This is not actually used as of yet.
fUseStripTimingCuts = 0;
fUseTSchi2cut = false;
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_central[axis] = 87.0; //ns
fStripMaxTcut_width[axis] = 4.5; //sigmas
fStripMaxTcut_sigma[axis] = 7.0; //ns, for purpose of "hit quality chi2" calculation
fStripMaxTcut_central_deconv[axis] = 50.0; //ns
fStripMaxTcut_width_deconv[axis] = 4.5; //number of sigmas
fStripMaxTcut_sigma_deconv[axis] = 15.0; //ns
fStripMaxTcut_central_fit[axis] = 20.0; //ns
fStripMaxTcut_width_fit[axis] = 4.5; //sigmas
fStripMaxTcut_sigma_fit[axis] = 10.0; //ns
fHitTimeMean[axis] = 87.0;
fHitTimeSigma[axis] = 7.0;
fHitTimeMeanDeconv[axis] = 50.0;
fHitTimeSigmaDeconv[axis] = 15.0;
fHitTimeMeanFit[axis] = 20.0;
fHitTimeSigmaFit[axis] = 10.0;
}
fSigmaHitTimeAverageCorrected = 5.0; //ns
fStripAddTcut_width = 50.0; //this one we keep in ns
fStripAddCorrCoeffCut = 0.25;
fStripTSchi2Cut = 10.0; //not yet clear what is a good value for this.
fGoodStrip_TSfrac_mean.resize( fN_MPD_TIME_SAMP );
fGoodStrip_TSfrac_sigma.resize( fN_MPD_TIME_SAMP );
//Define some defaults for these:
double fracmean_default[6] = {0.055, 0.135, 0.203, 0.224, 0.208, 0.174};
double fracsigma_default[6] = {0.034, 0.039, 0.019, 0.021, 0.032, 0.035};
for( int isamp=0; isamp<fN_MPD_TIME_SAMP; isamp++ ){
if( isamp < fN_MPD_TIME_SAMP && isamp < 6 ){
fGoodStrip_TSfrac_mean[isamp] = fracmean_default[isamp];
fGoodStrip_TSfrac_sigma[isamp] = fracsigma_default[isamp];
}
}
fPulseShapeInitialized = false;
fMeasureCommonMode = true;
fNeventsCommonModeLookBack = 15;
fCorrectCommonMode = false;
fCorrectCommonModeMinStrips = 20;
fCorrectCommonMode_Nsigma = 5.0;
fCommonModeBinWidth_Nsigma = 1.0; //Bin width +/- 1 sigma by default
fCommonModeScanRange_Nsigma = 4.0; //Scan window +/- 4 sigma
fCommonModeStepSize_Nsigma = 0.2; //sigma/5 for step size:
fCommonModeDanningMethod_NsigmaCut = 3.0; //Default to 3 sigma
fClusteringFlag = 0; //"standard" clustering based on sum of six time samples on a strip
//fDeconvolutionFlag = 1; //Set "keep strip" flag based on deconvoluted ADC samples
fDeconvolutionFlag = 0; //Default should be zero
fStoreAll1Dclusters = false;
return;
}
SBSGEMModule::~SBSGEMModule() {
// if( fStrip ){
// fadc0 = NULL;
// fadc1 = NULL;
// fadc2 = NULL;
// fadc3 = NULL;
// fadc4 = NULL;
// fadc5 = NULL;
// for( Int_t i = 0; i < N_MPD_TIME_SAMP; i++ ){
// delete fadc[i];
// fadc[i] = NULL;
// }
// delete fPedestal;
// fPedestal = NULL;
// delete fStrip;
// fStrip = NULL;
// }
delete fStripTimeFunc;
}
Int_t SBSGEMModule::ReadDatabase( const TDatime& date ){
std::cout << "[SBSGEMModule::ReadDatabase]" << std::endl;
Int_t status;
FILE* file = OpenFile( date );
if( !file ) return kFileError;
std::vector<Double_t> rawpedu,rawpedv;
std::vector<Double_t> rawrmsu,rawrmsv;
//UShort_t layer;
//I think we can set up the entire database parsing in one shot here (AJRP). Together with the call to ReadGeometry, this should define basically everything we need.
//After loading, we will run some checks on the loaded information:
//copying commented structure of DBRequest here for reference (see VarDef.h):
// struct DBRequest {
// const char* name; // Key name
// void* var; // Pointer to data (default to Double*)
// VarType type; // (opt) data type (see VarType.h, default Double_t)
// UInt_t nelem; // (opt) number of array elements (0/1 = 1 or auto)
// Bool_t optional; // (opt) If true, missing key is ok
// Int_t search; // (opt) Search for key along name tree
// const char* descript; // (opt) Key description (if 0, same as name)
// };
// default these offsets to zero:
fUStripOffset = 0.0;
fVStripOffset = 0.0;
//std::cout << "Before loadDB, fCommonModePlotsInitialized = " << fCommonModePlotsInitialized << std::endl;
int cmplots_flag = fMakeCommonModePlots ? 1 : 0;
int zerosuppress_flag = fZeroSuppress ? 1 : 0;
int negsignalstudy_flag = fNegSignalStudy ? 1 : 0;
int onlinezerosuppress_flag = fOnlineZeroSuppression ? 1 : 0;
int eventinfoplots_flag = fMakeEventInfoPlots ? 1 : 0;
int usestriptimingcuts = fUseStripTimingCuts;
int useTSchi2cut = fUseTSchi2cut ? 1 : 0;
int suppressfirstlast = fSuppressFirstLast;
int usecommonmoderollingaverage = fMeasureCommonMode ? 1 : 0;
int correctcommonmode = fCorrectCommonMode ? 1 : 0;
std::vector<double> TSfrac_mean_temp;
std::vector<double> TSfrac_sigma_temp;
//For parsing "strip" timing cuts:
std::vector<double> t0_temp, tsigma_temp, tcut_temp;
std::vector<double> t0_deconv_temp, tsigma_deconv_temp, tcut_deconv_temp;
std::vector<double> t0_fit_temp, tsigma_fit_temp, tcut_fit_temp;
//For parsing "hit" timing cuts:
std::vector<double> t0hit_temp, tsigmahit_temp;
std::vector<double> t0hit_deconv_temp, tsigmahit_deconv_temp;
std::vector<double> t0hit_fit_temp, tsigmahit_fit_temp;
const DBRequest request[] = {
{ "chanmap", &fChanMapData, kIntV, 0, 0, 0}, // mandatory: decode map info
{ "apvmap", &fAPVmapping, kUInt, 0, 1, 1}, //optional, allow search up the tree if all modules in a setup have the same APV mapping
{ "pedu", &rawpedu, kDoubleV, 0, 1, 0}, // optional raw pedestal info (u strips)
{ "pedv", &rawpedv, kDoubleV, 0, 1, 0}, // optional raw pedestal info (v strips)
{ "rmsu", &rawrmsu, kDoubleV, 0, 1, 0}, // optional pedestal rms info (u strips)
{ "rmsv", &rawrmsv, kDoubleV, 0, 1, 0}, // optional pedestal rms info (v strips)
{ "layer", &fLayer, kUShort, 0, 0, 0}, // mandatory: logical tracking layer must be specified for every module:
{ "nstripsu", &fNstripsU, kUInt, 0, 0, 1}, //mandatory: number of strips in module along U axis
{ "nstripsv", &fNstripsV, kUInt, 0, 0, 1}, //mandatory: number of strips in module along V axis
{ "uangle", &fUAngle, kDouble, 0, 0, 1}, //mandatory: Angle of "U" strips wrt X axis
{ "vangle", &fVAngle, kDouble, 0, 0, 1}, //mandatory: Angle of "V" strips wrt X axis
{ "uoffset", &fUStripOffset, kDouble, 0, 1, 1}, //optional: position of first U strip
{ "voffset", &fVStripOffset, kDouble, 0, 1, 1}, //optional: position of first V strip
{ "upitch", &fUStripPitch, kDouble, 0, 0, 1}, //mandatory: Pitch of U strips
{ "vpitch", &fVStripPitch, kDouble, 0, 0, 1}, //mandatory: Pitch of V strips
{ "ugain", &fUgain, kDoubleV, 0, 1, 0}, //(optional): Gain of U strips by APV card (ordered by strip position, NOT by order of appearance in decode map)
{ "vgain", &fVgain, kDoubleV, 0, 1, 0}, //(optional): Gain of V strips by APV card (ordered by strip position, NOT by order of appearance in decode map)
{ "modulegain", &fModuleGain, kDouble, 0, 1, 1},
{ "threshold_sample", &fThresholdSample, kDouble, 0, 1, 1}, //(optional): threshold on max. ADC sample to keep strip (baseline-subtracted)
{ "threshold_stripsum", &fThresholdStripSum, kDouble, 0, 1, 1}, //(optional): threshold on sum of ADC samples on a strip (baseline-subtracted)
{ "threshold_clustersum", &fThresholdClusterSum, kDouble, 0, 1, 1}, //(optional): threshold on sum of all ADCs over all strips in a cluster (baseline-subtracted)
{ "threshold_sample_deconv", &fThresholdSampleDeconv, kDouble, 0, 1, 1 },
{ "threshold_maxcombo_deconv", &fThresholdDeconvADCMaxCombo, kDouble, 0, 1, 1 },
{ "threshold_clustersum_deconv", &fThresholdClusterSumDeconv, kDouble, 0, 1, 1 },
{ "ADCasym_cut", &fADCasymCut, kDouble, 0, 1, 1}, //(optional): filter 2D hits by ADC asymmetry, |Asym| < cut
{ "deltat_cut", &fTimeCutUVdiff, kDouble, 0, 1, 1}, //(optional): filter 2D hits by U/V time difference
{ "corrcoeff_cut", &fCorrCoeffCut, kDouble, 0, 1, 1},
{ "filterflag1D", &fFiltering_flag1D, kInt, 0, 1, 1},
{ "filterflag2D", &fFiltering_flag2D, kInt, 0, 1, 1},
{ "peakprominence_minsigma", &fThresh_2ndMax_nsigma, kDouble, 0, 1, 1}, //(optional): reject overlapping clusters with peak prominence less than this number of sigmas
{ "peakprominence_minfraction", &fThresh_2ndMax_fraction, kDouble, 0, 1, 1}, //(optional): reject overlapping clusters with peak prominence less than this fraction of height of nearby higher peak
{ "maxnu_charge", &fMaxNeighborsU_totalcharge, kUShort, 0, 1, 1}, //(optional): cluster size restriction along U for total charge calculation
{ "maxnv_charge", &fMaxNeighborsV_totalcharge, kUShort, 0, 1, 1}, //(optional): cluster size restriction along V for total charge calculation
{ "maxnu_pos", &fMaxNeighborsU_hitpos, kUShort, 0, 1, 1}, //(optional): cluster size restriction for position reconstruction
{ "maxnv_pos", &fMaxNeighborsV_hitpos, kUShort, 0, 1, 1}, //(optional): cluster size restriction for position reconstruction
{ "sigmahitshape", &fSigma_hitshape, kDouble, 0, 1, 1}, //(optional): width parameter for cluster-splitting algorithm
{ "zerosuppress", &zerosuppress_flag, kUInt, 0, 1, 1}, //(optional, search): toggle offline zero suppression (default = true).
{ "zerosuppress_nsigma", &fZeroSuppressRMS, kDouble, 0, 1, 1}, //(optional, search):
{ "do_neg_signal_study", &negsignalstudy_flag, kUInt, 0, 1, 1}, //(optional, search): toggle doing negative signal analysis
{ "onlinezerosuppress", &onlinezerosuppress_flag, kUInt, 0, 1, 1}, //(optional, search)
{ "commonmode_meanU", &fCommonModeMeanU, kDoubleV, 0, 1, 0}, //(optional, don't search)
{ "commonmode_meanV", &fCommonModeMeanV, kDoubleV, 0, 1, 0}, //(optional, don't search)
{ "commonmode_rmsU", &fCommonModeRMSU, kDoubleV, 0, 1, 0}, //(optional, don't search)
{ "commonmode_rmsV", &fCommonModeRMSV, kDoubleV, 0, 1, 0}, //(optional, don't search)
{ "commonmode_flag", &fCommonModeFlag, kInt, 0, 1, 1}, //optional, search up the tree
{ "commonmode_online_flag", &fCommonModeOnlFlag, kInt, 0, 1, 1}, //optional, search up the tree
{ "commonmode_nstriplo", &fCommonModeNstripRejectLow, kInt, 0, 1, 1}, //optional, search up the tree:
{ "commonmode_nstriphi", &fCommonModeNstripRejectHigh, kInt, 0, 1, 1}, //optional, search:
{ "commonmode_niter", &fCommonModeNumIterations, kInt, 0, 1, 1},
{ "commonmode_minstrips", &fCommonModeMinStripsInRange, kInt, 0, 1, 1},
{ "commonmode_range_nsigma", &fCommonModeRange_nsigma, kDouble, 0, 1, 1},
{ "commonmode_danning_nsigma_cut", &fCommonModeDanningMethod_NsigmaCut, kDouble, 0, 1, 1 },
{ "plot_common_mode", &cmplots_flag, kInt, 0, 1, 1},
{ "plot_event_info", &eventinfoplots_flag, kInt, 0, 1, 1},
{ "chan_cm_flags", &fChan_CM_flags, kUInt, 0, 1, 1}, //optional, search up the tree: must match the value in crate map!
{ "chan_timestamp_low", &fChan_TimeStamp_low, kUInt, 0, 1, 1},
{ "chan_timestamp_high", &fChan_TimeStamp_high, kUInt, 0, 1, 1},
{ "chan_event_count", &fChan_MPD_EventCount, kUInt, 0, 1, 1},
{ "pedsub_online", &fPedSubFlag, kInt, 0, 1, 1},
{ "max2Dhits", &fMAX2DHITS, kUInt, 0, 1, 1}, //optional, search up tree
{ "usestriptimingcut", &fUseStripTimingCuts, kInt, 0, 1, 1 },
{ "useTSchi2cut", &useTSchi2cut, kInt, 0, 1, 1 },
{ "maxstrip_t0", &t0_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_t0_deconv", &t0_deconv_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_t0_fit", &t0_fit_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tcut", &tcut_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tcut_deconv", &tcut_deconv_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tcut_fit", &tcut_fit_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tsigma", &tsigma_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tsigma_deconv", &tsigma_deconv_temp, kDoubleV, 0, 1, 1 },
{ "maxstrip_tsigma_fit", &tsigma_fit_temp, kDoubleV, 0, 1, 1 },
{ "addstrip_tcut", &fStripAddTcut_width, kDouble, 0, 1, 1 },
{ "addstrip_ccor_cut", &fStripAddCorrCoeffCut, kDouble, 0, 1, 1 },
{ "goodstrip_TSfrac_mean", &TSfrac_mean_temp, kDoubleV, 0, 1, 1 },
{ "goodstrip_TSfrac_sigma", &TSfrac_sigma_temp, kDoubleV, 0, 1, 1 },
{ "suppressfirstlast", &suppressfirstlast, kInt, 0, 1, 1 },
{ "use_commonmode_rolling_average", &usecommonmoderollingaverage, kInt, 0, 1, 1 },
{ "commonmode_nevents_lookback", &fNeventsCommonModeLookBack, kUInt, 0, 1, 1 },
{ "correct_common_mode", &correctcommonmode, kInt, 0, 1, 1 },
{ "correct_common_mode_minstrips", &fCorrectCommonModeMinStrips, kUInt, 0, 1, 1 },
{ "correct_common_mode_nsigma", &fCorrectCommonMode_Nsigma, kDouble, 0, 1, 1 },
{ "commonmode_binwidth_nsigma", &fCommonModeBinWidth_Nsigma, kDouble, 0, 1, 1 },
{ "commonmode_scanrange_nsigma", &fCommonModeScanRange_Nsigma, kDouble, 0, 1, 1 },
{ "commonmode_stepsize_nsigma", &fCommonModeStepSize_Nsigma, kDouble, 0, 1, 1 },
{ "deconvolution_tau", &fStripTau, kDouble, 0, 1, 1 },
{ "CMbiasU", &fCMbiasU, kDoubleV, 0, 1, 1 },
{ "CMbiasV", &fCMbiasV, kDoubleV, 0, 1, 1 },
{ "clustering_flag", &fClusteringFlag, kInt, 0, 1, 1 },
{ "deconvolution_flag", &fDeconvolutionFlag, kInt, 0, 1, 1 },
{ "maxtrigtime_correction", &fMaxTrigTimeCorrection, kDouble, 0, 1, 1 },
{ "trigtime_slope", &fTrigTimeSlope, kDouble, 0, 1, 1 },
{ "ADCasym_sigma", &fADCasymSigma, kDouble, 0, 1, 1 },
{ "deltat_sigma", &fTimeCutUVsigma, kDouble, 0, 1, 1 },
{ "deltat_cut_deconv", &fTimeCutUVdiffDeconv, kDouble, 0, 1, 1 },
{ "deltat_sigma_deconv", &fTimeCutUVsigmaDeconv, kDouble, 0, 1, 1 },
{ "deltat_cut_fit", &fTimeCutUVdiffFit, kDouble, 0, 1, 1 },
{ "deltat_sigma_fit", &fTimeCutUVsigmaFit, kDouble, 0, 1, 1 },
{ "corrcoeff_cut_deconv", &fCorrCoeffCutDeconv, kDouble, 0, 1, 1 },
{ "ADCratio_sigma", &fADCratioSigma, kDouble, 0, 1, 1 },
{ "HitTimeMean", &t0hit_temp, kDoubleV, 0, 1, 1 },
{ "HitTimeSigma", &tsigmahit_temp, kDoubleV, 0, 1, 1 },
{ "HitTimeMeanDeconv", &t0hit_deconv_temp, kDoubleV, 0, 1, 1 },
{ "HitTimeSigmaDeconv", &tsigmahit_deconv_temp, kDoubleV, 0, 1, 1 },
{ "HitTimeMeanFit", &t0hit_fit_temp, kDoubleV, 0, 1, 1 },
{ "HitTimeSigmaFit", &tsigmahit_fit_temp, kDoubleV, 0, 1, 1 },
{ "sigma_tcorr", &fSigmaHitTimeAverageCorrected, kDouble, 0, 1, 1 },
{0}
};
status = LoadDB( file, date, request, fPrefix, 1 ); //The "1" after fPrefix means search up the tree
if( status != 0 ){
fclose(file);
return status;
}
if( !fCommonModePlots_DBoverride ) fMakeCommonModePlots = cmplots_flag != 0;
fZeroSuppress = zerosuppress_flag != 0;
fOnlineZeroSuppression = onlinezerosuppress_flag != 0;
fNegSignalStudy = negsignalstudy_flag != 0;
fMakeEventInfoPlots = eventinfoplots_flag != 0;
//fUseStripTimingCuts = usestriptimingcuts != 0;
fUseTSchi2cut = useTSchi2cut != 0;
fSuppressFirstLast = suppressfirstlast;
//fMeasureCommonMode = usecommonmoderollingaverage != 0;
fMeasureCommonMode = true; //we're not turning this off
fCorrectCommonMode = correctcommonmode != 0;
if( fUseTSchi2cut && TSfrac_mean_temp.size() == fN_MPD_TIME_SAMP && TSfrac_sigma_temp.size() == fN_MPD_TIME_SAMP ){
fGoodStrip_TSfrac_mean = TSfrac_mean_temp;
fGoodStrip_TSfrac_sigma = TSfrac_sigma_temp;
}
// std::cout << "After loadDB, fCommonModePlotsInitialized = " << fCommonModePlotsInitialized << std::endl;
if( /*fAPVmapping < SBSGEM::kINFN ||*/ fAPVmapping > SBSGEM::kMC ) {
std::cout << "Warning in SBSGEMModule::Decode for module " << GetParent()->GetName() << "." << GetName() << ": invalid APV mapping choice, defaulting to UVA X/Y." << std::endl
<< " Analysis results may be incorrect" << std::endl;
fAPVmapping = SBSGEM::kUVA_XY;
}
//prevent the user from defining something silly for the common-mode stuff:
fCommonModeNstripRejectLow = std::min( 50, std::max( 0, fCommonModeNstripRejectLow ) );
fCommonModeNstripRejectHigh = std::min( 50, std::max( 0, fCommonModeNstripRejectHigh ) );
fCommonModeNumIterations = std::min( 10, std::max( 2, fCommonModeNumIterations ) );
fCommonModeMinStripsInRange = std::min( fN_APV25_CHAN-25, std::max(1, fCommonModeMinStripsInRange ) );
double x = fSamplePeriod/fStripTau;
fDeconv_weights[0] = exp( x - 1.0 )/x; //~1.32
fDeconv_weights[1] = -2.0*exp(-1.0)/x; //~ -1.72
fDeconv_weights[2] = exp(-1.0-x)/x; //0.56
//std::cout << GetName() << " fThresholdStripSum " << fThresholdStripSum
//<< " fThresholdSample " << fThresholdSample << std::endl;
if( fIsMC ){
fCommonModeFlag = -1;
fPedestalMode = false;
fOnlineZeroSuppression = true;
fAPVmapping = SBSGEM::kMC;
}
fPxU = cos( fUAngle * TMath::DegToRad() );
fPyU = sin( fUAngle * TMath::DegToRad() );
fPxV = cos( fVAngle * TMath::DegToRad() );
fPyV = sin( fVAngle * TMath::DegToRad() );
fAPVch_by_Ustrip.clear();
fAPVch_by_Vstrip.clear();
fMPDID_by_Ustrip.clear();
fMPDID_by_Vstrip.clear();
fADCch_by_Ustrip.clear();
fADCch_by_Vstrip.clear();
//Count APV cards by axis. Each APV card must have one decode map entry:
fNAPVs_U = 0;
fNAPVs_V = 0;
fMPDmap.clear();
Int_t nentry = fChanMapData.size()/fMPDMAP_ROW_SIZE;
fCommonModeResultContainer_by_APV.resize( nentry );
fCommonModeRollingAverage_by_APV.resize( nentry );
fCommonModeRollingRMS_by_APV.resize( nentry );
fNeventsRollingAverage_by_APV.resize( nentry );
fCMbiasResultContainer_by_APV.resize( nentry );
fCommonModeOnlineBiasRollingAverage_by_APV.resize( nentry );
fCommonModeOnlineBiasRollingRMS_by_APV.resize( nentry );
fNeventsOnlineBias_by_APV.resize( nentry );
for( Int_t mapline = 0; mapline < nentry; mapline++ ){
mpdmap_t thisdata;
thisdata.crate = fChanMapData[0+mapline*fMPDMAP_ROW_SIZE];
thisdata.slot = fChanMapData[1+mapline*fMPDMAP_ROW_SIZE];
thisdata.mpd_id = fChanMapData[2+mapline*fMPDMAP_ROW_SIZE];
thisdata.gem_id = fChanMapData[3+mapline*fMPDMAP_ROW_SIZE];
thisdata.adc_id = fChanMapData[4+mapline*fMPDMAP_ROW_SIZE];
thisdata.i2c = fChanMapData[5+mapline*fMPDMAP_ROW_SIZE];
thisdata.pos = fChanMapData[6+mapline*fMPDMAP_ROW_SIZE];
thisdata.invert = fChanMapData[7+mapline*fMPDMAP_ROW_SIZE];
thisdata.axis = fChanMapData[8+mapline*fMPDMAP_ROW_SIZE];
thisdata.index = mapline;
//Populate relevant quantities mapped by strip index:
for( int ich=0; ich<fN_APV25_CHAN; ich++ ){
int strip = GetStripNumber( ich, thisdata.pos, thisdata.invert );
if( thisdata.axis == SBSGEM::kUaxis ){
fAPVch_by_Ustrip[strip] = ich;
fMPDID_by_Ustrip[strip] = thisdata.mpd_id;
fADCch_by_Ustrip[strip] = thisdata.adc_id;
} else {
fAPVch_by_Vstrip[strip] = ich;
fMPDID_by_Vstrip[strip] = thisdata.mpd_id;
fADCch_by_Vstrip[strip] = thisdata.adc_id;
}
}
if( thisdata.axis == SBSGEM::kUaxis ){
fNAPVs_U++;
} else {
fNAPVs_V++;
}
fMPDmap.push_back(thisdata);
fEventCount_by_APV.push_back( 0 );
fT0_by_APV.push_back( 0 );
fTcoarse_by_APV.push_back( 0 );
fTfine_by_APV.push_back( 0 );
fTimeStamp_ns_by_APV.push_back( 0 );
//fCommonModeRollingFirstEvent_by_APV[mapline] = 0.0;
fCommonModeResultContainer_by_APV[mapline].resize( fNeventsCommonModeLookBack*fN_MPD_TIME_SAMP );
fCommonModeRollingAverage_by_APV[mapline] = 0.0;
fCommonModeRollingRMS_by_APV[mapline] = 10.0;
fNeventsRollingAverage_by_APV[mapline] = 0; //Really will be the number of time samples = 6 * number of events
fCMbiasResultContainer_by_APV[mapline].resize( fNeventsCommonModeLookBack*fN_MPD_TIME_SAMP );
fCommonModeOnlineBiasRollingAverage_by_APV[mapline] = 0.0;
fCommonModeOnlineBiasRollingRMS_by_APV[mapline] = 10.0;
fNeventsOnlineBias_by_APV[mapline] = 0;
}
//if a different number of decode map entries is counted than the expectation based on the number of strips,
//e.g., because we commented out one or more decode map entries, then we go with the larger of the two numbers.
//This isn't perfectly idiot-proof, but prevents the kind of undefined behavior we want to avoid:
//if( fNAPVs_U != fNstripsU/fN_APV25_CHAN ){
fNAPVs_U = std::max( fNAPVs_U, fNstripsU/fN_APV25_CHAN );
//}
fNAPVs_V = std::max( fNAPVs_V, fNstripsV/fN_APV25_CHAN );
//resize vectors that hold APV-card specific parameters:
// fUgain.resize( fNAPVs_U );
// fVgain.resize( fNAPVs_V );
// fCommonModeMeanU.resize( fNAPVs_U );
// fCommonModeMeanV.resize( fNAPVs_V );
// fCommonModeRMSU.resize( fNAPVs_U );
// fCommonModeRMSV.resize( fNAPVs_V );
std::cout << fName << " mapped to " << nentry << " APV25 chips, module gain = " << fModuleGain << std::endl;
//Geometry info is required to be present in the database for each module:
Int_t err = ReadGeometry( file, date, true );
if( err ) {
fclose(file);
return err;
}
//Initialize all pedestals to zero, RMS values to default:
fPedestalU.clear();
fPedestalU.resize( fNstripsU );
fPedRMSU.clear();
fPedRMSU.resize( fNstripsU );
// std::cout << "got " << rawpedu.size() << " u pedestal mean values and " << rawrmsu.size() << " u pedestal rms values" << std::endl;
// std::cout << "got " << rawpedv.size() << " v pedestal mean values and " << rawrmsv.size() << " v pedestal rms values" << std::endl;
// for( int i=0; i<rawpedu.size(); i++ ){
// cout << i << ", " << rawpedu[i] << endl;
// }
for ( UInt_t istrip=0; istrip<fNstripsU; istrip++ ){
fPedestalU[istrip] = 0.0;
fPedRMSU[istrip] = 10.0; //placeholder to be replaced by value from database
if( rawpedu.size() == fNstripsU ){
fPedestalU[istrip] = rawpedu[istrip];
}else if( rawpedu.size() == fNstripsU/128 ){
fPedestalU[istrip] = rawpedu[istrip/128];
}else if(!rawpedu.empty()){
fPedestalU[istrip] = rawpedu[0];
}
if( rawrmsu.size() == fNstripsU ){
fPedRMSU[istrip] = rawrmsu[istrip];
}else if( rawrmsu.size() == fNstripsU/128 ){
fPedRMSU[istrip] = rawrmsu[istrip/128];
}else if(!rawrmsu.empty()){
fPedRMSU[istrip] = rawrmsu[0];
}
}
//Initialize all pedestals to zero, RMS values to default:
fPedestalV.clear();
fPedestalV.resize( fNstripsV );
fPedRMSV.clear();
fPedRMSV.resize( fNstripsV );
for( UInt_t istrip=0; istrip<fNstripsV; istrip++ ){
fPedestalV[istrip] = 0.0;
fPedRMSV[istrip] = 10.0;
if( rawpedv.size() == fNstripsV ){
fPedestalV[istrip] = rawpedv[istrip];
}else if( rawpedv.size() == fNstripsV/128 ){
fPedestalV[istrip] = rawpedv[istrip/128];
}else if(!rawpedv.empty()){
fPedestalV[istrip] = rawpedv[0];
}
if( rawrmsv.size() == fNstripsV ){
fPedRMSV[istrip] = rawrmsv[istrip];
}else if( rawrmsv.size() == fNstripsV/128 ){
fPedRMSV[istrip] = rawrmsv[istrip/128];
}else if(!rawrmsv.empty()){
fPedRMSV[istrip] = rawrmsv[0];
}
}
// //resize all the "decoded strip" arrays to their maximum possible values for this module:
UInt_t nstripsmax = fNstripsU + fNstripsV;
fStrip.resize( nstripsmax );
fAxis.resize( nstripsmax );
fADCsamples.resize( nstripsmax );
fRawADCsamples.resize( nstripsmax );
fADCsamples_deconv.resize( nstripsmax );
//The lines below are problematic and unnecessary
for( unsigned int istrip=0; istrip<nstripsmax; istrip++ ){
fADCsamples[istrip].resize( fN_MPD_TIME_SAMP );
fRawADCsamples[istrip].resize( fN_MPD_TIME_SAMP );
fADCsamples_deconv[istrip].resize( fN_MPD_TIME_SAMP );
}
fADCsums.resize( nstripsmax );
fADCsumsDeconv.resize( nstripsmax );
fStripADCavg.resize( nstripsmax );
fStripIsU.resize( nstripsmax );
fStripIsV.resize( nstripsmax );
fStripOnTrack.resize( nstripsmax );
fStripIsNeg.resize( nstripsmax );
fStripIsNegU.resize( nstripsmax );
fStripIsNegV.resize( nstripsmax );
fStripIsNegOnTrack.resize( nstripsmax );
fStripIsNegOnTrackU.resize( nstripsmax );
fStripIsNegOnTrackV.resize( nstripsmax );
fStripRaw.resize( nstripsmax );
fStripEvent.resize( nstripsmax );
fStripCrate.resize( nstripsmax );
fStripMPD.resize( nstripsmax );
fStripADC_ID.resize( nstripsmax );
fStripTrackIndex.resize( nstripsmax );
fKeepStrip.resize( nstripsmax );
fMaxSamp.resize( nstripsmax );
fMaxSampDeconv.resize( nstripsmax );
fMaxSampDeconvCombo.resize( nstripsmax );
fADCmax.resize( nstripsmax );
fADCmaxDeconv.resize( nstripsmax );
fADCmaxDeconvCombo.resize( nstripsmax );
fTmean.resize( nstripsmax );
fTmeanDeconv.resize( nstripsmax );
fTsigma.resize( nstripsmax );
fStripTdiff.resize( nstripsmax );
fStripTSchi2.resize( nstripsmax );
fStripTSprob.resize( nstripsmax );
fStripCorrCoeff.resize( nstripsmax );
fStripTfit.resize( nstripsmax );
fTcorr.resize( nstripsmax );
//Storing these by individual strip is redundant but convenient:
fStrip_ENABLE_CM.resize( nstripsmax );
fStrip_CM_GOOD.resize( nstripsmax );
fStrip_BUILD_ALL_SAMPLES.resize( nstripsmax );
fStripUonTrack.resize( nstripsmax );
fStripVonTrack.resize( nstripsmax );
fADCsamples1D.resize( nstripsmax * fN_MPD_TIME_SAMP );
fRawADCsamples1D.resize( nstripsmax * fN_MPD_TIME_SAMP );
fADCsamplesDeconv1D.resize( nstripsmax * fN_MPD_TIME_SAMP );
//default all common-mode mean and RMS values to 0 and 10 respectively if they were
// NOT loaded from the DB and/or they are loaded with the wrong size:
if( fCommonModeMeanU.size() != fNAPVs_U ){
fCommonModeMeanU.resize( fNAPVs_U );
for( unsigned int iAPV=0; iAPV<fNAPVs_U; iAPV++ ){
fCommonModeMeanU[iAPV] = 0.0;
}
}
if( fCommonModeRMSU.size() != fNAPVs_U ){
fCommonModeRMSU.resize( fNAPVs_U );
for( unsigned int iAPV=0; iAPV<fNAPVs_U; iAPV++ ){
fCommonModeRMSU[iAPV] = 10.0;
}
}
//default all common-mode mean and RMS values to 0 and 10 respectively if they were
// NOT loaded from the DB and/or they were loaded with the wrong size:
if( fCommonModeMeanV.size() != fNAPVs_V ){
fCommonModeMeanV.resize( fNAPVs_V );
for( unsigned int iAPV=0; iAPV<fNAPVs_V; iAPV++ ){
fCommonModeMeanV[iAPV] = 0.0;
}
}
if( fCommonModeRMSV.size() != fNAPVs_V ){
fCommonModeRMSV.resize( fNAPVs_V );
for( unsigned int iAPV=0; iAPV<fNAPVs_V; iAPV++ ){
fCommonModeRMSV[iAPV] = 10.0;
}
}
// Initialize default "CM correction bias" values to zero if they were not loaded from the DB:
if( fCMbiasU.size() != fNAPVs_U ){
fCMbiasU.resize( fNAPVs_U );
for( unsigned int iAPV=0; iAPV<fNAPVs_U; iAPV++ ){
fCMbiasU[iAPV] = 0.0;
}
}
if( fCMbiasV.size() != fNAPVs_V ){
fCMbiasV.resize( fNAPVs_V );
for( unsigned int iAPV=0; iAPV<fNAPVs_V; iAPV++ ){
fCMbiasV[iAPV] = 0.0;
}
}
//default all gains to 1 if they were not loaded from the DB and/or if they were loaded with the
//wrong size:
if( fUgain.size() != fNAPVs_U ){
fUgain.resize(fNAPVs_U);
for( unsigned int iAPV=0; iAPV<fNAPVs_U; iAPV++ ){
fUgain[iAPV] = 1.0;
}
}
//Multiply in Module gain:
for( unsigned int iAPV=0; iAPV<fNAPVs_U; iAPV++ ){
fUgain[iAPV] *= fModuleGain;
}
if( fVgain.size() != fNAPVs_V ){
fVgain.resize(fNAPVs_V);
for( unsigned int iAPV=0; iAPV<fNAPVs_V; iAPV++ ){
fVgain[iAPV] = 1.0;
}
}
for( unsigned int iAPV=0; iAPV<fNAPVs_V; iAPV++ ){
fVgain[iAPV] *= fModuleGain;
}
if( fPedestalMode ){
fZeroSuppress = false;
fOnlineZeroSuppression = false;
//fPedSubFlag = 0;
}
//Add parsing of timing cut arguments now:
//All timing cut arguments have default values so we can parse them individually:
if( t0_temp.size() > 0 ){
if( t0_temp.size() == 1 ){
fStripMaxTcut_central[0] = fStripMaxTcut_central[1] = t0_temp[0];
} else if( t0_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_central[axis] = t0_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut center (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tcut_temp.size() > 0 ){
if( tcut_temp.size() == 1 ){
fStripMaxTcut_width[0] = fStripMaxTcut_width[1] = tcut_temp[0];
} else if( tcut_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_width[axis] = tcut_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut width (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigma_temp.size() > 0 ){
if( tsigma_temp.size() == 1 ){
fStripMaxTcut_sigma[0] = fStripMaxTcut_sigma[1] = tsigma_temp[0];
} else if( tsigma_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_sigma[axis] = tsigma_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut sigma (must be 1 or 2). Fix database");
return kInitError;
}
}
//Deconvoluted strip time cuts:
//All timing cut arguments have default values so we can parse them individually:
if( t0_deconv_temp.size() > 0 ){
if( t0_deconv_temp.size() == 1 ){
fStripMaxTcut_central_deconv[0] = fStripMaxTcut_central_deconv[1] = t0_deconv_temp[0];
} else if( t0_deconv_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_central_deconv[axis] = t0_deconv_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut center deconv (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tcut_deconv_temp.size() > 0 ){
if( tcut_deconv_temp.size() == 1 ){
fStripMaxTcut_width_deconv[0] = fStripMaxTcut_width_deconv[1] = tcut_deconv_temp[0];
} else if( tcut_deconv_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_width_deconv[axis] = tcut_deconv_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut width (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigma_deconv_temp.size() > 0 ){
if( tsigma_deconv_temp.size() == 1 ){
fStripMaxTcut_sigma_deconv[0] = fStripMaxTcut_sigma_deconv[1] = tsigma_deconv_temp[0];
} else if( tsigma_deconv_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_sigma_deconv[axis] = tsigma_deconv_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut center (must be 1 or 2). Fix database");
return kInitError;
}
}
//Fit strip time cuts:
//All timing cut arguments have default values so we can parse them individually:
if( t0_fit_temp.size() > 0 ){
if( t0_fit_temp.size() == 1 ){
fStripMaxTcut_central_fit[0] = fStripMaxTcut_central_fit[1] = t0_fit_temp[0];
} else if( t0_fit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_central_fit[axis] = t0_fit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut fit center (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tcut_fit_temp.size() > 0 ){
if( tcut_fit_temp.size() == 1 ){
fStripMaxTcut_width_fit[0] = fStripMaxTcut_width_fit[1] = tcut_fit_temp[0];
} else if( tcut_fit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_width_fit[axis] = tcut_fit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut width (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigma_fit_temp.size() > 0 ){
if( tsigma_fit_temp.size() == 1 ){
fStripMaxTcut_sigma_fit[0] = fStripMaxTcut_sigma_fit[1] = tsigma_fit_temp[0];
} else if( tsigma_fit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fStripMaxTcut_sigma_fit[axis] = tsigma_fit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for max strip tcut center (must be 1 or 2). Fix database");
return kInitError;
}
}
//Parsing hit time mean and sigma: standard
if( t0hit_temp.size() != 0 ){
if( t0hit_temp.size() == 1 ){
fHitTimeMean[1] = fHitTimeMean[0] = t0hit_temp[0];
} else if( t0hit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fHitTimeMean[axis] = t0hit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for hit time mean (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigmahit_temp.size() != 0 ){
if( tsigmahit_temp.size() == 1 ){
fHitTimeSigma[1] = fHitTimeSigma[0] = tsigmahit_temp[0];
} else if( tsigmahit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fHitTimeSigma[axis] = tsigmahit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for hit time sigma (must be 1 or 2). Fix database");
return kInitError;
}
}
//Parsing hit time mean and sigma: deconvoluted:
if( t0hit_deconv_temp.size() != 0 ){
if( t0hit_deconv_temp.size() == 1 ){
fHitTimeMeanDeconv[1] = fHitTimeMeanDeconv[0] = t0hit_deconv_temp[0];
} else if( t0hit_deconv_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fHitTimeMeanDeconv[axis] = t0hit_deconv_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for hit time mean (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigmahit_deconv_temp.size() != 0 ){
if( tsigmahit_deconv_temp.size() == 1 ){
fHitTimeSigmaDeconv[1] = fHitTimeSigmaDeconv[0] = tsigmahit_deconv_temp[0];
} else if( tsigmahit_deconv_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fHitTimeSigmaDeconv[axis] = tsigmahit_deconv_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for hit time sigma (must be 1 or 2). Fix database");
return kInitError;
}
}
//cluster time mean and sigma parsing: fit times
if( t0hit_fit_temp.size() != 0 ){
if( t0hit_fit_temp.size() == 1 ){
fHitTimeMeanFit[1] = fHitTimeMeanFit[0] = t0hit_fit_temp[0];
} else if( t0hit_fit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){
fHitTimeMeanFit[axis] = t0hit_fit_temp[axis];
}
} else {
Error(Here("ReadDatabase"), "Incorrect number of values for hit time mean (must be 1 or 2). Fix database");
return kInitError;
}
}
if( tsigmahit_fit_temp.size() != 0 ){
if( tsigmahit_fit_temp.size() == 1 ){
fHitTimeSigmaFit[1] = fHitTimeSigmaFit[0] = tsigmahit_fit_temp[0];
} else if( tsigmahit_fit_temp.size() == 2 ){
for( int axis=0; axis<2; axis++ ){