StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtPedSub.cc
1 /***************************************************************************
2  *
3  * $Id: StSvtPedSub.cc,v 1.8 2003/09/02 17:59:08 perev Exp $
4  *
5  * Author: Helen Caines
6  ***************************************************************************
7  *
8  * Description: SVT Pedestal Subtraction Code
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtPedSub.cc,v $
13  * Revision 1.8 2003/09/02 17:59:08 perev
14  * gcc 3.2 updates + WarnOff
15  *
16  * Revision 1.7 2001/07/22 20:31:28 caines
17  * Better tuning for real data. Common mode noise calc and sub. Avoid overlapping seq. Fill histograms only in debug
18  *
19  * Revision 1.6 2000/11/30 20:45:56 caines
20  * Dynamically calc prob values, use database
21  *
22  * Revision 1.5 2000/08/28 22:12:39 caines
23  * Error accessing timebucket in Ped. subtraction
24  *
25  * Revision 1.4 2000/08/21 12:57:30 caines
26  * Now opens and reads in ped using CalibMaker
27  *
28  * Revision 1.3 2000/07/16 22:32:23 caines
29  * Now also saves RAW data
30  *
31  * Revision 1.2 2000/07/03 02:07:56 perev
32  * StEvent: vector<TObject*>
33  *
34  * Revision 1.1 2000/06/15 20:04:54 caines
35  * Initial versions of sequence adjusting codes
36  *
37  *
38  **************************************************************************/
39 #include "StSvtPedSub.h"
40 #include "StSequence.hh"
41 #include "StSvtClassLibrary/StSvtHybridData.hh"
42 #include "StSvtClassLibrary/StSvtHybridPed.hh"
43 #include "StSvtClassLibrary/StSvtHybridCollection.hh"
44 #include "StMessMgr.h"
45 #include <Stiostream.h>
46 
47 StSvtPedSub::StSvtPedSub( StSvtHybridCollection *PedPointer)
48 {
49  mPed = NULL;
50  mSvtPed = PedPointer;
51 }
52 
53 
54 
55 //_____________________________________________________________________________
56 
57 
58 int StSvtPedSub::SubtractPed( StSvtHybridData* fData, int Index, int PedOffset)
59 {
60 
61 
62  int nAnodes, anodeID, nSeq, iseq, time, newAdc, status;
63  StSequence* Seq;
64  int* anodeList;
65 
66  anodeList = NULL;
67 
68  nAnodes = fData->getAnodeList(anodeList);
69  mPed = (StSvtHybridPed *) mSvtPed->at(Index);
70 
71  if (!mPed) return 0;
72 
73  for (int ianode=0;ianode<nAnodes;ianode++) {
74 
75  anodeID = anodeList[ianode];
76  Seq = NULL;
77  nSeq = 0;
78 
79  status = fData->getSequences(anodeID,nSeq,Seq);
80  for (iseq=0;iseq<nSeq;iseq++) {
81  for (time=0; time<Seq[iseq].length; time++) {
82 
83  // if ((anodeID == 180) && (time == 64) )
84  //gMessMgr->Debug() << "ped = " << mPed->getPixelContent(anodeID,Seq[iseq].startTimeBin+time) << endm;
85 
86  // Actually subtract the pedestal per pixel. PedOffset
87  //allows undershoot to be seen
88  newAdc= (int)Seq[iseq].firstAdc[time]-
89  (int) mPed->getPixelContent(anodeID,Seq[iseq].startTimeBin+time)
90  +PedOffset;
91 
92  //Check adc hasn't gone -ve
93  if( newAdc < 0) newAdc=0;
94  else if( newAdc >= 256) newAdc=255;
95  Seq[iseq].firstAdc[time]= newAdc;
96 
97  }
98  }
99  }
100 
101  return 0;
102 }
103 
104 
105 //_____________________________________________________________________________
106 
107