2 #define TRG_VERSION 0x32
17 #ifndef OLD_DAQ_READER
18 #include <DAQ_READER/daq_dta.h>
21 #include "daqFormats.h"
22 #include "l3BankUtils.h"
26 #ifndef OLD_DAQ_READER
27 #include <DAQ_EMC/daq_emc.h>
32 barrelCalib = BarrelCalib;
33 endcapCalib = EndcapCalib;
36 nBarrelTowers = barrelCalib->getNTowers();
41 nEndcapTowers = endcapCalib->getNTowers();
45 nTotalTowers = nBarrelTowers + nEndcapTowers;
49 endcapTower = tower + nBarrelTowers;
51 for (
int i=0; i<nBarrelTowers; i++) {
52 barrelTower[i].setTowerInfo(barrelCalib->getTowerInfo(i));
55 for (
int i=0; i<nEndcapTowers; i++) {
56 endcapTower[i].setTowerInfo(endcapCalib->getTowerInfo(i));
68 int gl3EMC::readFromEvpReader(
evpReader *evp,
char *mem)
70 int gl3EMC::readFromEvpReader(
daqReader *rdr,
char *mem)
75 int ret = emcReader(mem);
81 daq_dta *dd = rdr->det(
"emc_pseudo")->get(
"legacy");
85 LOG(NOTE,
"No EMC data present...",0,0,0,0,0);
89 #ifndef OLD_DAQ_READER
95 for(i=0;i<nBarrelTowers;i++) {
96 barrelTower[i].setADC(0);
97 barrelTower[i].setNTracks(0);
100 for(i=0;i<nEndcapTowers;i++) {
101 endcapTower[i].setADC(0);
102 endcapTower[i].setNTracks(0);
107 if(nBarrelTowers < BTOW_MAXFEE * BTOW_DATSIZE) {
108 LOG(WARN,
"nBarrelTowers = %d, smaller than %d",nBarrelTowers,BTOW_MAXFEE * BTOW_DATSIZE,0,0,0);
113 if(nEndcapTowers < ETOW_MAXFEE * ETOW_DATSIZE) {
114 LOG(WARN,
"nEndcapTowers = %d, smaller than %d",nEndcapTowers,ETOW_MAXFEE * ETOW_DATSIZE,0,0,0);
120 #ifdef OLD_DAQ_READER
125 LOG(DBG,
"Reading BTOW data",0,0,0,0,0);
126 for(i=0;i<BTOW_MAXFEE*BTOW_DATSIZE;i++) {
129 int id = barrelCalib->daqToId(daqid);
131 #ifdef OLD_DAQ_READER
133 LOG(DBG,
"i=%d id=%d adc=%d",daqid,
id,emc.btow[i]);
135 if(pEMC->btow[i] != 0)
136 LOG(DBG,
"i=%d id=%d adc=%d",daqid,
id,pEMC->btow[i]);
139 if(
id >= nBarrelTowers)
continue;
141 #ifdef OLD_DAQ_READER
142 barrelTower[id].setADC(emc.btow[i]);
144 barrelTower[id].setADC(pEMC->btow[i]);
146 barrelTower[id].setNTracks(0);
153 #ifdef OLD_DAQ_READER
158 LOG(DBG,
"Reading etow data",0,0,0,0,0);
159 for(i=0;i<ETOW_MAXFEE;i++) {
160 for(j=0;j<ETOW_DATSIZE;j++) {
162 int daqid = i + j*ETOW_MAXFEE;
163 int id = endcapCalib->daqToId(daqid);
165 if(
id >= nEndcapTowers)
continue;
167 #ifdef OLD_DAQ_READER
168 if(emc.etow[i][j] != 0)
169 LOG(DBG,
"etow: i=%d j=%d daqid=%d id=%d adc=%d",i,j,daqid,
id, emc.etow[i][j]);
171 if(pEMC->etow[i][j] != 0)
172 LOG(DBG,
"etow: i=%d j=%d daqid=%d id=%d adc=%d",i,j,daqid,
id, pEMC->etow[i][j]);
175 #ifdef OLD_DAQ_READER
176 endcapTower[id].setADC(emc.etow[i][j]);
178 endcapTower[id].setADC(pEMC->etow[i][j]);
180 endcapTower[id].setNTracks(0);
189 int gl3EMC::readRawData(
L3_P *l3p)
194 if (l3p->emc[0].len > 10000) {
195 LOG(ERR,
"Illegal length of BTOW contribution",0,0,0,0,0);
199 if (l3p->emc[3].len > 10000) {
200 LOG(ERR,
" ---> ERROR <--- Illegal length of ETOW contribution\n",0,0,0,0,0);
205 if (l3p->emc[0].len) {
206 if (readEMCSECP((
EMCSECP*)offlen2ptr(l3p, l3p->emc[0]))) {
209 for (
int i=0; i < nBarrelTowers; i++) {
210 barrelTower[i].setADC(0);
211 barrelTower[i].setNTracks(0);
216 if (l3p->emc[3].len) {
217 ret = readEMCSECP((
EMCSECP*)offlen2ptr(l3p, l3p->emc[3]));
225 LOG(ERR,
"Error reading endcap",0,0,0,0,0);
227 for (
int i=0; i < nEndcapTowers; i++) {
228 endcapTower[i].setADC(0);
229 endcapTower[i].setNTracks(0);
234 for (
int i=0; i < nBarrelTowers; i++) {
235 Ebarrel += barrelTower[i].getEnergy();
239 for (
int i=0; i < nEndcapTowers; i++) {
240 Eendcap += endcapTower[i].getEnergy();
243 Etotal = Ebarrel + Eendcap;
249 int gl3EMC::readEMCSECP(
EMCSECP* secp)
252 enum {barrel, endcap} secpType;
262 if(strncmp(secp->bh.bank_type, CHAR_EMCSECP, 8) == 0) {
268 }
else if (strncmp(secp->bh.bank_type, CHAR_EECSECP, 8) == 0) {
275 LOG(ERR,
"Unknown bank type '%s'", secp->bh.bank_type,0,0,0,0);
286 int nFibers = (swap32(secp->bh.length)-10)/2;
288 for (
int i=0; i<nFibers; i++) {
289 EMCRBP* rbp = (
EMCRBP*)offlen2ptr(secp, secp->fiber[i]);
292 int nBANKS = (swap32(rbp->bh.length)-10)/2;
295 LOG(ERR,
"EMC data coming in without BTOW bank?!?!?\n",0,0,0,0,0);
300 offlen2ptr(rbp, rbp->banks[0]);
302 if (!dataBank)
continue;
309 unsigned short*
data = (
unsigned short*)
310 (((
char *)dataBank) + 40 + 4 + 128);
313 for(
int c=0; c<nCrates; c++) {
315 unsigned short cr_count = data[c+30*0];
316 unsigned short cr_errflag = data[c+30*1];
320 if (secpType == barrel && c<15) {
324 if (cr_count != 164) errFlags |= 1;
325 if (cr_errflag) errFlags |= 1;
335 for (
int daqid=0; daqid < calib->getNTowers(); daqid++) {
336 int id = calib->daqToId(daqid);
338 twr[id].setADC(data[daqid]);
339 twr[id].setNTracks(0);
348 int gl3EMC::matchTracks(
gl3Event *event)
350 LOG(ERR,
"matchTracks currently not available",0,0,0,0,0);
378 for (
int i=0; i<nBarrelTowers; i++) {
379 barrelTower[i].setADC(0);
382 for (
int i=0; i<nEndcapTowers; i++) {
383 endcapTower[i].setADC(0);