Back to home page

EIC code displayed by LXR

 
 

    


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 #include "HGCROC.h"
0002 #include <cassert>
0003 #include <iostream>
0004 
0005 ClassImp(Hgcroc)
0006 std::vector<int> Hgcroc::GetADCWaveform(void) const{
0007   return adc_waveform;
0008 }
0009 
0010 bool Hgcroc::IsSaturatedADC() const{
0011   for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0012     if (adc_waveform.at(k) > 1022)
0013       return true;
0014   }
0015   return false;
0016 }
0017 
0018 int Hgcroc::IsBelowPed(double pedSig) const{
0019   for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0020     if ( adc_waveform.at(k) < (pedestal - pedSig))
0021       return k;
0022   }
0023   return -1;
0024 }
0025 
0026 
0027 int Hgcroc::GetMaxSampleADC (void){
0028   Double_t maxADC = -1000;
0029   int nMaxADC   = 0;
0030   for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0031     if (maxADC < adc_waveform.at(k)){
0032       maxADC  = adc_waveform.at(k);
0033       nMaxADC = k;
0034     }
0035   }
0036   return nMaxADC;
0037 }
0038 
0039 
0040 int Hgcroc::GetFirstSampleAboveTh (void){
0041   int nFirst   = 0;
0042   for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0043     if (adc_waveform.at(k) > GetPedestal() +10){
0044       nFirst = k;
0045       break;
0046     }
0047   }
0048   return nFirst;
0049 }
0050 
0051 std::vector<int> Hgcroc::GetTOAWaveform(void) const{
0052   return toa_waveform;
0053 }
0054 
0055 int Hgcroc::GetFirstTOASample (void){
0056   int nSampTOA  = 0;
0057   for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0058     if (toa_waveform.at(k) > 0){
0059       nSampTOA = k;
0060       break;
0061     }
0062   }
0063   return nSampTOA;
0064 }
0065 
0066 
0067 std::vector<int> Hgcroc::GetTOTWaveform(void) const{
0068   return tot_waveform;
0069 }
0070 
0071 int Hgcroc::GetNsample(void) const{
0072   return Nsample;
0073 }
0074 
0075 double Hgcroc::GetCorrectedTOT(void) const{
0076   return TOT;
0077 }
0078 
0079 // Gets first TOT fired for the waveform 
0080 double Hgcroc::GetRawTOT(void) const{
0081   double tot = 0;
0082   for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0083     if (tot_waveform.at(k) > 0){
0084       tot = tot_waveform.at(k);
0085       break;
0086     }
0087   }
0088   return tot;
0089 }
0090 
0091 // Gets first TOA fired for the waveform 
0092 double Hgcroc::GetRawTOA(void) const{
0093   double toa = 0;
0094   for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0095     if (toa_waveform.at(k) > 0){
0096       toa = toa_waveform.at(k);
0097       break;
0098     }
0099   }
0100   return toa;
0101 }
0102 
0103 double Hgcroc::GetCorrectedTOA(void) const{
0104   return TOA;
0105 }
0106 
0107 int Hgcroc::GetCorrectedFirstTOASample(double toAOffset) {
0108   int nSampTOA  = GetFirstTOASample();
0109   int rawTOA    = (int)GetRawTOA();
0110   // only calculate if the waveform actually had an intrinsic TOA
0111   if (rawTOA > 1 && toAOffset != -1000.){
0112     if ((rawTOA-toAOffset) < 0)
0113       nSampTOA++; 
0114   }
0115   return nSampTOA;
0116 }
0117 
0118 
0119 int Hgcroc::GetPedestal(void) const{
0120   return pedestal;
0121 }
0122 
0123 void Hgcroc::SetADCWaveform(std::vector<int> v){
0124   adc_waveform=v;
0125 }
0126 
0127 void Hgcroc::AppendWaveformADC(int a){
0128   adc_waveform.push_back(a);
0129 }
0130 
0131 void Hgcroc::ResetADCWaveformPoint(int s, int a){
0132   assert(0<=s && s<(int)adc_waveform.size());
0133   adc_waveform.at(s)=a;
0134 }
0135 
0136 void Hgcroc::SetTOAWaveform(std::vector<int> v){
0137   toa_waveform=v;
0138 }
0139 
0140 void Hgcroc::AppendWaveformTOA(int a){
0141   toa_waveform.push_back(a);
0142 }
0143 
0144 void Hgcroc::ResetTOAWaveformPoint(int s, int a){
0145   assert(0<=s && s<(int)toa_waveform.size());
0146   toa_waveform.at(s)=a;
0147 }
0148 
0149 void Hgcroc::SetTOTWaveform(std::vector<int> v){
0150   tot_waveform=v;
0151 }
0152 
0153 void Hgcroc::AppendWaveformTOT(int a){
0154   tot_waveform.push_back(a);
0155 }
0156 
0157 void Hgcroc::ResetTOTWaveformPoint(int s, int a){
0158   assert(0<=s && s<(int)tot_waveform.size());
0159   tot_waveform.at(s)=a;
0160 }
0161 
0162 void Hgcroc::SetNsample(int n){
0163   Nsample=n;
0164 }
0165 
0166 void Hgcroc::SetCorrectedTOT(double tot){
0167   TOT=tot;
0168 }
0169 
0170 int Hgcroc::SetCorrectedTOA(int offset){
0171   int rawTOA    = (int)GetRawTOA();
0172   // only calculate if the waveform actually had an intrinsic TOA
0173   if (rawTOA > 1){
0174     int toacorr   = (rawTOA-offset)%1024;
0175     int nSampTOA  = (int)GetFirstTOASample();
0176     if (rawTOA-offset < 0)
0177       nSampTOA++;
0178     double toacorrf  = double((-1)*nSampTOA*1024-toacorr);
0179     TOA=toacorrf;
0180     return nSampTOA;
0181   // otherwise return default values
0182   } else {
0183     TOA = -10e5;
0184     return 0;
0185   }
0186   return 0;
0187 }
0188 
0189 int Hgcroc::GetLinearizedRawTOA(){
0190   int rawTOA    = (int)GetRawTOA();
0191   if (rawTOA == 0)
0192     return -10e5;
0193   int nSampTOA  = (int)GetFirstTOASample();
0194   
0195   return (-1)*nSampTOA*1024-rawTOA;
0196 }
0197 
0198 void Hgcroc::SetPedestal(int ped){
0199   pedestal=ped;
0200 }
0201 
0202 void Hgcroc::PrintWaveFormDebugInfo( double pedMeanH, double pedMeanL, double pedSig){
0203     Setup* setupT = Setup::GetInstance();
0204     int layer     = setupT->GetLayer(CellID);
0205     int chInLayer = setupT->GetChannelInLayer(CellID);          
0206     int roCh      = setupT->GetROchannel(CellID);
0207     std::cout << "Cell ID:" << CellID<< "\t" << layer <<"\t" << chInLayer << "\t RO channel:\t" << roCh << "\t" << pedMeanH << "\t" << pedMeanL << "\t" << pedSig;
0208     std::cout << "\n \tADC-wave " ;
0209     for (int k = 0; k < (int)adc_waveform.size(); k++ ){
0210       std::cout << adc_waveform.at(k) << "\t" ;
0211     }
0212     std::cout << "\n \tTOT-Wave ";
0213     for (int k = 0; k < (int)tot_waveform.size(); k++ ){
0214       std::cout << tot_waveform.at(k) << "\t" ;
0215     }
0216     std::cout << "\n \tTOA-Wave ";
0217     for (int k = 0; k < (int)toa_waveform.size(); k++ ){
0218       std::cout << toa_waveform.at(k) << "\t" ;
0219     }
0220   std::cout <<"\n\t\t\t";
0221   for (int k = 0; k < (int)toa_waveform.size(); k++ )
0222     std::cout <<"\t";  
0223   std::cout << " integ: "<<GetIntegratedADC() <<"\t"<< GetRawTOT() << "\t" << GetRawTOA() << "\t nTOA = " << GetFirstTOASample() << "\t nTh = " << GetFirstSampleAboveTh() << "\t nMax = " << GetMaxSampleADC()  << std::endl;
0224 
0225 }