StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EMC_Reader.cxx
1 #include "EMC_Reader.hh"
2 #include <assert.h>
3 #include "EMC_BarrelReader.hh"
4 #include "EMC_SmdReader.hh"
5 #define MAX_ADC 0xFFF
6 
7 using namespace OLDEVP;
8 
9 void EMC_Reader::ProcessEvent(const Bank_EMCP * EmcPTR, const Bank_TRGP * TrgPTR)
10 {
11  // will process the event to fill the arrays for different detectors.
12  //Towers
13  EMC_BarrelReader* barreltowerreader = new EMC_BarrelReader(ercpy, const_cast<Bank_EMCP *>(EmcPTR));
14  int towerresult = barreltowerreader->ProcessBarrelTower(EmcPTR, TrgPTR);
15  mTheTowerAdcR=barreltowerreader->getBTOWERADCR();
16  if(!towerresult)
17  {
18  cout<<" Barrel TOWER processing is not successful**"<<endl;
19  mTowerPresent=false;
20  } // 0 is bad
21  else
22  {
23  mTowerPresent=true;
24  }
25 
26  delete barreltowerreader;
27  barreltowerreader=0;
28 
29  if(EmcPTR) {
30  //SMDs
31  EMC_SmdReader* barrelsmdreader = new EMC_SmdReader(ercpy, const_cast<Bank_EMCP *>(EmcPTR));
32  int smdresult = barrelsmdreader->ProcessBarrelSmd(EmcPTR);
33  mTheSmdAdcR=barrelsmdreader->getBSMDADCR();
34 
35  if(!smdresult)
36  {
37  cout<<" Barrel SMD processing is not successful**"<<endl;
38  mSmdPresent=false;
39  } // 0 is bad
40  else
41  {
42  mSmdPresent=true;
43  }
44  delete barrelsmdreader;
45  barrelsmdreader=0;
46  }
47 }
48 
49 //EMC_Reader::~EMC_Reader(){}
50 
52 {
53  mSmdPresent=false;
54  mTowerPresent=true;
55  printf(" SP in EMC_Reader\n");
56  pBankEMCP = pEMCP; //copy into class data member for use by other methods
57  ercpy = er; // squirrel away pointer eventreader for our friends
58 
59  printf("This is the EMC_Reader ctor in %s.\n",__FILE__);
60 
61  if(pBankEMCP) {
62  pBankEMCP->header.BankType[7]=0;
63  cout<<"header bank type "<<pBankEMCP->header.BankType<<endl;
64 
65  if (!pBankEMCP->test_CRC())
66  printf("CRC error in EMCP: %s %d\n",__FILE__,__LINE__) ;
67  if (pBankEMCP->swap() < 0)
68  printf("swap error in EMCP: %s %d\n",__FILE__,__LINE__) ;
69 
70  pBankEMCP->header.CRC = 0;
71  int Token = pBankEMCP->header.Token;
72 
73  Bank_DATAP *dp = (Bank_DATAP *)ercpy->getDATAP();
74  if(Token !=dp->header.Token)
75  printf("Token mismatch between global %d and RICH %d\n",dp->header.Token,Token);
76  }
77 
78  ProcessEvent(pBankEMCP, pTRGP);
79 }
81 {
82  if(mTowerPresent)
83  {
84  if(strncmp(mTheTowerAdcR.BankType,"TOWRADCR",8))
85  {
86  cout<<"EMC_Reader::NTowerHits() -> error in header"<<endl;
87  return 0;
88  }
89  int nhits=mTheTowerAdcR.NTowerHits;
90  return nhits;
91  }
92  else
93  return 0;
94 }
96 {
97  if(mSmdPresent)
98  {
99  if(strncmp(mTheSmdAdcR.BankType,"BSMDADCR",8))
100  {
101  cout<<" error in header name**"<<endl;
102  return 0;
103  }
104  int nhits=mTheSmdAdcR.NSmdHits;
105  return nhits;
106  }
107  else
108  return 0;
109 }
110 
111 int EMC_Reader::getTowerADC(int module,int eta, int sub,unsigned short& ADC )
112 {
113  //
114  // module, eta and sub begins with 1
115  // see StEmcTowerInput.cxx
116  //
117  if(mTowerPresent)
118  {
119  if(strncmp(mTheTowerAdcR.BankType,"TOWRADCR",8))
120  {
121  cout<<" error in header name**"<<endl;
122  return 0;
123  }
124  else
125  {
126  ADC=mTheTowerAdcR.TowerMatrix[module-1][eta-1][sub-1];
127  return 1; // 1 is good
128  }
129  }
130  else
131  return 0; // 0 is bad
132 }
133 
134 int EMC_Reader::getTowerADC(int index, unsigned short& ADC )
135 {
136  //
137  // index is daq index (0-4799)
138  //
139  if(mTowerPresent)
140  {
141  if(strncmp(mTheTowerAdcR.BankType,"TOWRADCR",8))
142  {
143  cout<<" error in header name**" << endl;
144  return 0;
145  }
146  ADC = mTheTowerAdcR.TowerADCArray[index];
147  return 1; // 1 is good
148  }
149  else
150  return 0;
151 }
152 
153 int EMC_Reader::getSMDE_ADC(int modInd,int stripInd,unsigned short& ADC )
154 {
155  //
156  // modInd and stripInd are indexes - 1-oct-2001
157  // see StEmcSmdInput.cxx
158  //
159  if(mSmdPresent)
160  {
161  if(strncmp(mTheSmdAdcR.BankType,"BSMDADCR",8))
162  {
163  cout<<" getSMDE_ADC::error in header name**"<<endl;
164  return 0;
165  }
166  else
167  {
168  ADC = mTheSmdAdcR.SmdE_ADCMatrix[modInd-1][stripInd-1];
169  return 1; // 1 is good
170  }
171  }
172  else
173  return 0;
174 }
175 
176 int EMC_Reader::getSMDP_ADC(int modInd,int binInd,int stripInd,unsigned short& ADC )
177 {
178  //
179  // modInd, binInd and stripInd are indexes starting with 1- 1-oct-2001
180  // see StEmcSmdInput.cxx
181  //
182  if(mSmdPresent)
183  {
184  if(strncmp(mTheSmdAdcR.BankType,"BSMDADCR",8))
185  {
186  cout<<" getSMDE_ADC::error in header name**"<<endl;
187  return 0;
188  }
189  else
190  {
191  ADC=mTheSmdAdcR.SmdP_ADCMatrix[modInd-1][binInd-1][stripInd-1];
192  return 1; // 1 is good
193  }
194  }
195  else
196  return 0;
197 }
198 
199 int EMC_Reader::getSMD_ADC(int index, int fiber,unsigned short& ADC )
200 {
201  // index and fiber is index starting with 0
202  if(mSmdPresent)
203  {
204  if(strncmp(mTheSmdAdcR.BankType,"BSMDADCR",8))
205  {
206  cout<<" getSMD_ADC::error in header name**"<<endl;
207  return 0;
208  }
209  else
210  {
211  ADC=mTheSmdAdcR.SMDADCArray[fiber][index];
212  return 1; // 1 is good
213  }
214  }
215  else
216  return 0;
217 }
218 
219 int EMC_Reader::getSMD_TIMEBIN(int fiber, unsigned int& TimeBin)
220 {
221  if(mSmdPresent)
222  {
223  if(strncmp(mTheSmdAdcR.BankType,"BSMDADCR",8))
224  {
225  //cout<<" getSMDE_ADC::error in header name**"<<endl;
226  TimeBin=999;
227  return 0;
228  }
229  else
230  {
231  TimeBin=mTheSmdAdcR.TimeBin[fiber];
232  return 1; // 1 is good
233  }
234  }
235  else
236  return 0;
237 }
238 bool EMC_Reader::isTowerPresent()
239 {
240  return mTowerPresent;
241 }
242 bool EMC_Reader::isSmdPresent()
243 {
244  return mSmdPresent;
245 }
247 {
248  return mTheTowerAdcR;
249 }
250 Bank_BSMDADCR& EMC_Reader::getSMD_ADCR()
251 {
252  return mTheSmdAdcR;
253 }
int getSMD_TIMEBIN(int, unsigned int &)
Get SMD time bin (capacitor number) for a given fiber (RDO)
Definition: EMC_Reader.cxx:219
int NTowerHits()
Return number of valid hits on towers.
Definition: EMC_Reader.cxx:80
Bank_BTOWERADCR & getBTOWERADCR()
EMC_Reader destructor.
Definition: EMC_Reader.cxx:246
int NSmdHits()
Return number of valid hits on SMD.
Definition: EMC_Reader.cxx:95
int getSMD_ADC(int, int, unsigned short &)
Get SMD ADC for a given index and fiber (RDO) number.
Definition: EMC_Reader.cxx:199
int getSMDP_ADC(int, int, int, unsigned short &)
Get ADC for SMDP with given module, eta and sub.
Definition: EMC_Reader.cxx:176
int getTowerADC(int, int, int, unsigned short &)
Get ADC value for one tower with given module, eta and sub.
Definition: EMC_Reader.cxx:111
EMC_Reader(EventReader *er, Bank_EMCP *pEMCP, Bank_TRGP *pTRGP)
EMC_Reader constructor.
Definition: EMC_Reader.cxx:51
int getSMDE_ADC(int, int, unsigned short &)
Get ADC for SMDE with given module and stip number.
Definition: EMC_Reader.cxx:153