StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TPCV2P0_CPP_SR.cxx
1 /***************************************************************************
2  * $Id: TPCV2P0_CPP_SR.cxx,v 1.8 2007/12/24 06:04:32 fine Exp $
3  * Author: M.J. LeVine
4  ***************************************************************************
5  * Description: TPC reader for raw cluster pointer banks (TPCCPPR)
6  *
7  *
8  * change log
9  * 06-May-99 MJL code cloned from Jeff's ADCR_SR
10  * 22-Jun-99 MJL added TPCV2P0_CPP_SR::getAsicParams(struct ASIC_params *);
11  * 29-Aug-99 MJL #include <Stiostream.h> for HP platform
12  * 03-Feb-00 MJL print ASCI params so PT Barnum's clientele can grock them
13  *
14  ***************************************************************************
15  * $Log: TPCV2P0_CPP_SR.cxx,v $
16  * Revision 1.8 2007/12/24 06:04:32 fine
17  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
18  *
19  * Revision 1.7 2003/09/02 17:55:33 perev
20  * gcc 3.2 updates + WarnOff
21  *
22  * Revision 1.6 2000/02/03 21:18:36 levine
23  * change printout of ASIC parameters to idiot-proof mode
24  *
25  * Revision 1.5 2000/01/04 20:55:04 levine
26  * Implemented memory-mapped file access in EventReader.cxx. Old method
27  * (via seeks) is still possible by setting mmapp=0 in
28  *
29  * getEventReader(fd,offset,(const char *)logfile,mmapp);
30  *
31  *
32  * but memory-mapped access is much more effective.
33  *
34  * Revision 1.4 1999/09/02 21:47:12 fisyak
35  * HP corrections
36  *
37  * Revision 1.3 1999/07/02 04:43:24 levine
38  * Many changes -
39  * navigates to head of TPCP bank independent of position.
40  * move declarations out of loops where they were upsetting some compilers
41  * suppress output from class libraries with run-time switch EventReader.verbose
42  * added TPCV2P0_CPP_SR::getAsicParams()
43  *
44  *
45  **************************************************************************/
46 
47 #include <Stiostream.h>
48 
49 #include "StDaqLib/GENERIC/EventReader.hh"
50 #include "TPCV2P0.hh"
51 // TPC V1.0 Raw Reader
52 // change log
53 // 03-Jun-99 MJL added return TRUE to TPCV2P0_CPP_SR::initialize()
54 // 21-Jun-99 MJL test for existence of CPP bank before printing ASIC params (line 38)
55 // 23-Jun-99 MJL most output now supressed with EventReader.verbose
56 
57 using namespace OLDEVP;
58 
59 TPCV2P0_CPP_SR::TPCV2P0_CPP_SR(int s, TPCV2P0_Reader *det)
60 {
61  // cout << "Constructing TPCV2P0_CPP_SR" << endl;
62  sector = s-1; // convert the sector into internal representation
63  detector = det;
64 
65  // NULLS in banks array
66  memset((char *)banks, 0, sizeof(banks));
67 }
68 
69 int TPCV2P0_CPP_SR::initialize()
70 {
71  // get a sector reader for PADK
72  // printf("TPCV2P0_CPP_SR::initialize() sector %d\n",sector);
73  padkr = detector->getPADKReader(sector);
74  if (!padkr) return FALSE;
75  // printf("TPCV2P0_CPP_SR::initialize() SUCCESS sector %d\n",sector);
76 
77  // store pointers to the CPP banks
78  for(int rcb = 0; rcb < 6; rcb++)
79  {
80  for(int mz = 0; mz < 3; mz++)
81  {
82  banks[rcb][mz] = detector->getBankTPCCPPR(sector,rcb,mz);
83  classname(Bank_TPCCPPR) *cpp = banks[rcb][mz];
84  if (cpp)
85  if (detector->ercpy->verbose)
86  printf("ASIC params sec%d RB%d MZ %d:\
87 \nLow threshold: >%d ADC counts in >%d consecutive bins\
88 \nHigh threshold: >%d ADC counts in >%d of these bins\n",
89  sector+1, rcb+1, mz+1,
90  cpp->asic_params.thresh_lo,
91  cpp->asic_params.n_seq_lo,
92  cpp->asic_params.thresh_hi,
93  cpp->asic_params.n_seq_hi);
94  }
95  }
96  return TRUE;
97 }
98 
99 int TPCV2P0_CPP_SR::getAsicParams(ASIC_params *params)
100 {
101  for(int rcb = 0; rcb < 6; rcb++) {
102  for(int mz = 0; mz < 3; mz++) {
103  classname(Bank_TPCCPPR) *cpp = banks[rcb][mz];
104  if (cpp) {
105  *params = cpp->asic_params;
106  return TRUE;
107  }
108  }
109  }
110  return FALSE;
111 }
112 
113 TPCV2P0_CPP_SR::~TPCV2P0_CPP_SR()
114 {
115  // cout << "Deleting TPCV2P0_CPP_SR" << endl;
116 }
117 
118 int TPCV2P0_CPP_SR::getClusters(int PadRow, int Pad,
119  int *nClusters, struct ASIC_Cluster **clusters)
120 {
121  // Return a pointer to the cluster array for this (padrow,pad)
122  int i, mz, rb;
123  PADK_entry ent;
124 
125  // check pad, padrow for validity
126  if (PadRow==0 || PadRow>TPC_PADROWS) {
127  if (detector->ercpy->verbose)
128  printf(" %s %d padrow not a legal value: %d\n", __FILE__,__LINE__,PadRow);
129  return -1;
130  }
131  padkr->get(PadRow, Pad, &ent);
132  if(((mz=ent.mz) == 0) || ((rb=ent.rb) == 0)) {
133  if (detector->ercpy->verbose)
134  printf(" %s %d mz: %d rb: %d\n", __FILE__,__LINE__,rb,mz);
135  if (detector->ercpy->verbose)
136  printf(" PadRow %d, Pad %d\n", PadRow, Pad);
137  return -1;
138  }
139  if (!(void *)banks[rb-1][mz-1]) {
140  if (detector->ercpy->verbose)
141  printf(" %s %d no CPP bank for rb: %d mz: %d\n", __FILE__,__LINE__,rb,mz);
142  if (detector->ercpy->verbose) printf(" PadRow %d, Pad %d\n", PadRow, Pad);
143  return -1;
144  //test for CPPR bank for this RB, Mezz
145  }
146 
147  clusters[Pad-1] = (ASIC_Cluster *)(banks[rb-1][mz-1]->entry + 32*ent.offset);
148  for (i=0; i<31; i++) { //loop over ASIC sequences
149  if (clusters[Pad-1][i].start_time_bin < 0) break;
150  }
151 
152  *nClusters = i; //set number of valid clusters in array
153  return 0;
154 }
155 
156 
157 int TPCV2P0_CPP_SR::MemUsed()
158 {
159  return 0;
160 }
161 
162 
163 
Definition: rb.hh:21
Definition: TPCV1P0.hh:217