Warning, file /epic-lfhcal-tbana/NewStructure/HGCROC.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006 #include "HGCROC.h"
0007 #include <cassert>
0008 #include <iostream>
0009
0010 ClassImp(Hgcroc)
0011
0012
0013
0014
0015
0016 std::vector<int> Hgcroc::GetADCWaveform(void) const{
0017 return adc_waveform;
0018 }
0019
0020
0021
0022
0023
0024 bool Hgcroc::IsSaturatedADC() const{
0025 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0026 if (adc_waveform.at(k) > 1022)
0027 return true;
0028 }
0029 return false;
0030 }
0031
0032
0033
0034
0035
0036 bool Hgcroc::IsSaturatedTOT() const{
0037 for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0038 if (tot_waveform.at(k) > 4090)
0039 return true;
0040 }
0041 return false;
0042 }
0043
0044
0045
0046
0047
0048
0049 int Hgcroc::IsBelowPed(double pedSig) const{
0050 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0051 if ( adc_waveform.at(k) < (pedestal - pedSig))
0052 return k;
0053 }
0054 return -1;
0055 }
0056
0057
0058
0059
0060
0061 int Hgcroc::GetMaxSampleADC (void){
0062 Double_t maxADC = -1000;
0063 int nMaxADC = 0;
0064 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0065 if (maxADC < adc_waveform.at(k)){
0066 maxADC = adc_waveform.at(k);
0067 nMaxADC = k;
0068 }
0069 }
0070 return nMaxADC;
0071 }
0072
0073
0074
0075
0076
0077 int Hgcroc::GetFirstSampleAboveTh (void){
0078 int nFirst = 0;
0079 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0080 if (adc_waveform.at(k) > GetPedestal() +10){
0081 nFirst = k;
0082 break;
0083 }
0084 }
0085 return nFirst;
0086 }
0087
0088
0089
0090
0091
0092 std::vector<int> Hgcroc::GetTOAWaveform(void) const{
0093 return toa_waveform;
0094 }
0095
0096
0097
0098
0099
0100 int Hgcroc::GetFirstTOASample (void){
0101 int nSampTOA = 0;
0102 for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0103 if (toa_waveform.at(k) > 0){
0104 nSampTOA = k;
0105 break;
0106 }
0107 }
0108 return nSampTOA;
0109 }
0110
0111
0112
0113
0114
0115 std::vector<int> Hgcroc::GetTOTWaveform(void) const{
0116 return tot_waveform;
0117 }
0118
0119
0120
0121
0122
0123 int Hgcroc::GetNsample(void) const{
0124 return Nsample;
0125 }
0126
0127
0128
0129
0130
0131 double Hgcroc::GetCorrectedTOT(void) const{
0132 return TOT;
0133 }
0134
0135
0136
0137
0138
0139 double Hgcroc::GetRawTOT(void) const{
0140 double tot = 0;
0141 for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0142 if (tot_waveform.at(k) > 0){
0143 tot = tot_waveform.at(k);
0144 break;
0145 }
0146 }
0147 return tot;
0148 }
0149
0150
0151
0152
0153
0154 double Hgcroc::GetMaxTOT(void) const{
0155 double tot = 0;
0156 for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0157 if (tot_waveform.at(k) > tot){
0158 tot = tot_waveform.at(k);
0159 }
0160 }
0161 return tot;
0162 }
0163
0164
0165
0166
0167
0168
0169 double Hgcroc::GetMeanADC(double pedestal) const{
0170 if (adc_waveform.size() == 0) return 0;
0171 double sum = 0;
0172 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0173 sum += (adc_waveform.at(k) - pedestal);
0174 }
0175 return sum / (double)adc_waveform.size();
0176 }
0177
0178
0179
0180
0181
0182 double Hgcroc::GetRawTOA(void) const{
0183 double toa = 0;
0184 for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0185 if (toa_waveform.at(k) > 0){
0186 toa = toa_waveform.at(k);
0187 break;
0188 }
0189 }
0190 return toa;
0191 }
0192
0193
0194
0195
0196
0197 double Hgcroc::GetCorrectedTOA(void) const{
0198 return TOA;
0199 }
0200
0201
0202
0203
0204
0205
0206 int Hgcroc::GetCorrectedFirstTOASample(double toAOffset) {
0207 int nSampTOA = GetFirstTOASample();
0208 int rawTOA = (int)GetRawTOA();
0209
0210 if (rawTOA > 1 && toAOffset != -1000.){
0211 if ((rawTOA-toAOffset) < 0)
0212 nSampTOA++;
0213 }
0214 return nSampTOA;
0215 }
0216
0217
0218
0219
0220
0221 int Hgcroc::GetPedestal(void) const{
0222 return pedestal;
0223 }
0224
0225
0226
0227
0228
0229 void Hgcroc::SetADCWaveform(std::vector<int> v){
0230 adc_waveform=v;
0231 }
0232
0233
0234
0235
0236
0237 void Hgcroc::AppendWaveformADC(int a){
0238 adc_waveform.push_back(a);
0239 }
0240
0241
0242
0243
0244
0245
0246 void Hgcroc::ResetADCWaveformPoint(int s, int a){
0247 assert(0<=s && s<(int)adc_waveform.size());
0248 adc_waveform.at(s)=a;
0249 }
0250
0251
0252
0253
0254
0255 void Hgcroc::SetTOAWaveform(std::vector<int> v){
0256 toa_waveform=v;
0257 }
0258
0259
0260
0261
0262
0263 void Hgcroc::AppendWaveformTOA(int a){
0264 toa_waveform.push_back(a);
0265 }
0266
0267
0268
0269
0270
0271
0272 void Hgcroc::ResetTOAWaveformPoint(int s, int a){
0273 assert(0<=s && s<(int)toa_waveform.size());
0274 toa_waveform.at(s)=a;
0275 }
0276
0277
0278
0279
0280
0281 void Hgcroc::SetTOTWaveform(std::vector<int> v){
0282 tot_waveform=v;
0283 }
0284
0285
0286
0287
0288
0289 void Hgcroc::AppendWaveformTOT(int a){
0290 tot_waveform.push_back(a);
0291 }
0292
0293
0294
0295
0296
0297
0298 void Hgcroc::ResetTOTWaveformPoint(int s, int a){
0299 assert(0<=s && s<(int)tot_waveform.size());
0300 tot_waveform.at(s)=a;
0301 }
0302
0303
0304
0305
0306
0307 void Hgcroc::SetNsample(int n){
0308 Nsample=n;
0309 }
0310
0311
0312
0313
0314
0315 void Hgcroc::SetCorrectedTOT(double tot){
0316 TOT=tot;
0317 }
0318
0319
0320
0321
0322
0323
0324 int Hgcroc::SetCorrectedTOA(int offset){
0325 int rawTOA = (int)GetRawTOA();
0326
0327 if (rawTOA > 1){
0328 int toacorr = (rawTOA-offset)%1024;
0329 int nSampTOA = (int)GetFirstTOASample();
0330 if (rawTOA-offset < 0)
0331 nSampTOA++;
0332 double toacorrf = double((-1)*nSampTOA*1024-toacorr);
0333 TOA=toacorrf;
0334 return nSampTOA;
0335
0336 } else {
0337 TOA = -10e5;
0338 return 0;
0339 }
0340 return 0;
0341 }
0342
0343
0344
0345
0346
0347 int Hgcroc::GetLinearizedRawTOA(){
0348 int rawTOA = (int)GetRawTOA();
0349 if (rawTOA == 0)
0350 return -10e5;
0351 int nSampTOA = (int)GetFirstTOASample();
0352
0353 return (-1)*nSampTOA*1024-rawTOA;
0354 }
0355
0356
0357
0358
0359
0360 void Hgcroc::SetPedestal(int ped){
0361 pedestal=ped;
0362 }
0363
0364
0365
0366
0367
0368
0369
0370 void Hgcroc::PrintWaveFormDebugInfo( double pedMeanH, double pedMeanL, double pedSig){
0371 Setup* setupT = Setup::GetInstance();
0372 int layer = setupT->GetLayer(CellID);
0373 int chInLayer = setupT->GetChannelInLayer(CellID);
0374 int roCh = setupT->GetROchannel(CellID);
0375 std::cout << "Cell ID:" << CellID<< "\t" << layer <<"\t" << chInLayer << "\t RO channel:\t" << roCh << "\t" << pedMeanH << "\t" << pedMeanL << "\t" << pedSig;
0376 std::cout << "\n \tADC-wave " ;
0377 for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0378 std::cout << adc_waveform.at(k) << "\t" ;
0379 }
0380 std::cout << "\n \tTOT-Wave ";
0381 for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0382 std::cout << tot_waveform.at(k) << "\t" ;
0383 }
0384 std::cout << "\n \tTOA-Wave ";
0385 for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0386 std::cout << toa_waveform.at(k) << "\t" ;
0387 }
0388 std::cout <<"\n\t\t\t";
0389 for (int k = 0; k < (int)toa_waveform.size(); k++ )
0390 std::cout <<"\t";
0391 std::cout << " integ: "<<GetIntegratedADC() <<"\t"<< GetRawTOT() << "\t" << GetRawTOA() << "\t nTOA = " << GetFirstTOASample() << "\t nTh = " << GetFirstSampleAboveTh() << "\t nMax = " << GetMaxSampleADC() << std::endl;
0392
0393 }