StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtInverseProducts.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtInverseProducts.cc,v 1.5 2003/09/02 17:59:08 perev Exp $
4  *
5  * Author: Selemon Bekele
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtInverseProducts.cc,v $
13  * Revision 1.5 2003/09/02 17:59:08 perev
14  * gcc 3.2 updates + WarnOff
15  *
16  * Revision 1.4 2000/11/30 20:45:56 caines
17  * Dynamically calc prob values, use database
18  *
19  * Revision 1.2 2000/07/11 18:36:15 caines
20  * Updates to save more of sequence for fitting
21  *
22  * Revision 1.1 2000/06/15 20:04:54 caines
23  * Initial versions of sequence adjusting codes
24  *
25  **************************************************************************/
26 #include <Stiostream.h>
27 #include "Stiostream.h"
28 #include <stdlib.h>
29 #include <math.h>
30 
31 #include "StSequence.hh"
32 #include "StSvtClassLibrary/StSvtHybridData.hh"
33 #include "StSvtInverseProducts.hh"
34 
35 
36 StSvtInverseProducts::StSvtInverseProducts()
37 {
38  ResetBuffer();
39 }
40 
41 StSvtInverseProducts::~StSvtInverseProducts()
42 {}
43 
44 void StSvtInverseProducts::SetProbTable(StSvtProbValues* probValues)
45 {
46  for( int j = 0; j < MAX_ADC_COUNTS; j++)
47  mProbTable[j] = probValues->GetProbValue(j);
48 }
49 
50 
51 void StSvtInverseProducts::FindInvProducts(StSvtHybridData* hybridData, int anode, int pedOffSet)
52 {
53  StSequence* mSequence;
54  unsigned char* adcValue;
55  int mNumOfSequence,status;
56  int startTBin, length;
57  double mProdOfInvProb;
58 
59  status = hybridData->getListSequences(anode,mNumOfSequence,mSequence);
60 
61  for(int mSeq = 0; mSeq < mNumOfSequence; mSeq++)
62  {
63  startTBin = mSequence[mSeq].startTimeBin;
64  length = mSequence[mSeq].length;
65  adcValue = mSequence[mSeq].firstAdc;
66 
67  for(int i = 0; i < length ; i++)
68  {
69  // Now actually calcs products not inverse products for speed
70  mProdOfInvProb = 1;
71  for(int j = i - 1; j<= i+1; j++)
72  {int k;
73  if(j == -1 || j == length)
74  k = 0;
75  else{
76  k = (int)adcValue[j] - pedOffSet;
77  }
78  if( k >= 0 && k < (MAX_ADC_COUNTS-1)) mProdOfInvProb *= mProbTable[k];
79  else if(k >= -(MAX_ADC_COUNTS-1) && k < 0) mProdOfInvProb *= 1/(1 - 1/mProbTable[abs(k)]);
80  else if(k > (MAX_ADC_COUNTS-1) ) mProdOfInvProb *= mProbTable[MAX_ADC_COUNTS - 1];
81  else mProdOfInvProb *= 1/(1 - 1/mProbTable[MAX_ADC_COUNTS - 1]);
82  }
83 
84  mBuffer[i + startTBin] = log10(mProdOfInvProb);
85 
86  }
87  }
88 
89 }
90 
91 double StSvtInverseProducts::GetBuffer(int timeBin)
92 {
93  return mBuffer[timeBin];
94 }
95 
96 
97 void StSvtInverseProducts::ResetBuffer()
98 {
99  for(int mTBin = 0; mTBin <128; mTBin++)
100  mBuffer[mTBin] = 0;
101 
102 }
103