StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DetectorReader.cxx
1 /***************************************************************************
2  * $Id: DetectorReader.cxx,v 1.24 2007/12/27 21:55:04 perev Exp $
3  * Author: Jeff Landgraf
4  ***************************************************************************
5  * Description: Detector Factory
6  *
7  *
8  * change log
9  * 02-Jul-99 MJL add #includes for other detectors
10  * 08-Jul-99 MJL separate RICH_Reader
11  * 14-Jan-00 HH add FTPC
12  *
13  ***************************************************************************
14  * $Log: DetectorReader.cxx,v $
15  * Revision 1.24 2007/12/27 21:55:04 perev
16  * EEMCreader created even if no EEMC bank. TRG info assumed(Pibero)
17  *
18  * Revision 1.23 2007/12/24 06:04:16 fine
19  * introduce OLDEVP namespace to allow ole and new EVP library concurrently
20  *
21  * Revision 1.22 2007/11/30 01:22:36 genevb
22  * Update for 2008 BEMC from A. Kocoloski
23  *
24  * Revision 1.21 2007/08/07 19:44:09 perev
25  * Gene scalers added
26  *
27  * Revision 1.20 2007/05/25 13:37:46 jeromel
28  * /DEBUG//
29  *
30  * Revision 1.19 2007/05/24 20:56:38 jeromel
31  * (Pointer to) method returns FALSE instead of NULL fixed (+ one debug statement to remove later)
32  *
33  * Revision 1.18 2004/11/11 20:06:58 jeromel
34  * Message format change only (explicit)
35  *
36  * Revision 1.17 2004/08/07 02:43:32 perev
37  * more test for corruption added
38  *
39  * Revision 1.16 2004/02/18 20:31:14 ward
40  * There was a big mess. I am trying to fix it.
41  *
42  * Revision 1.14 2004/02/18 20:17:48 ward
43  * Access SSD data in makers.
44  *
45  * Revision 1.13 2003/03/24 18:12:15 ward
46  * Full support for EEMC from Herbert Ward.
47  *
48  * Revision 1.12 2002/12/09 18:54:23 ward
49  * EMC stuff from Subhassis.
50  *
51  * Revision 1.11 2002/01/17 17:29:26 jeromel
52  *
53  * Files: CVS: DetectorReader.cxx EventReader.cxx EventReader.hh CVS: RecHeaderFormats.hh CVS: ----------------------------------------------------------------------
54  * Modifications for FPD support
55  *
56  * Revision 1.10 2001/07/10 18:12:47 jeromel
57  * Changes commited for Frank Geurts (TOF) after approval from Herb Ward
58  * on Tue, 10 Jul 2001 11:19:48 and review by Victor.
59  * Changes implements TOF DAQ Reader.
60  *
61  * Revision 1.9 2001/06/19 21:07:54 jeromel
62  * Activate getFTPCReader (Janet S.)
63  *
64  * Revision 1.8 2000/06/30 21:51:15 perev
65  * L3 stuff added
66  *
67  * Revision 1.7 2000/06/13 17:29:30 jml
68  * Adding L3 Detector reader and template L3 Reader
69  *
70  * Revision 1.6 2000/06/06 21:46:59 jml
71  * Added code for SVTV1P0
72  *
73  * Revision 1.5 2000/01/18 17:56:08 levine
74  * Added FTPC call to TPC-like detectors
75  *
76  * Revision 1.3 1999/07/26 17:00:02 levine
77  * changes to RICH file organization
78  *
79  * Revision 1.2 1999/07/10 21:31:17 levine
80  * Detectors RICH, EMC, TRG now have their own (defined by each detector) interfaces.
81  * Existing user code will not have to change any calls to TPC-like detector
82  * readers.
83  *
84  * Revision 1.1 1999/07/02 22:26:55 levine
85  * moved from TPC directory. Now is the factory for all detector readers.
86  * Detector groups do not have to touch this file - only add functionality
87  * to their own directory tree.
88  *
89  * Revision 1.2 1999/07/02 04:43:22 levine
90  * Many changes -
91  * navigates to head of TPCP bank independent of position.
92  * move declarations out of loops where they were upsetting some compilers
93  * suppress output from class libraries with run-time switch
94  * EventReader.verbose
95  *
96  *
97  **************************************************************************/
98 #include "StDaqLib/GENERIC/EventReader.hh"
99 #include "TPC/TPCV1P0_Reader.hh"
100 #include "TPC/TPCV2P0_Reader.hh"
101 #include "TRG/TRG_Reader.hh"
102 #include "SVT/SVTV1P0_Reader.hh"
103 #include "SSD/SSD_Reader.hh"
104 #include "EMC/EMC_Reader.hh"
105 #include "EEMC/EEMC_Reader.hh"
106 #include "PMD/PMD_Reader.hh"
107 #include "RICH/RICH_Reader.hh"
108 #include "FTPC/FTPV1P0_Reader.hh"
109 #include "L3/L3_Reader.hh"
110 #include "TOF/TOF_Reader.hh"
111 #include "FPD/FPD_Reader.hh"
112 #include "SC/SC_Reader.hh"
113 
114 using namespace OLDEVP;
115 
116 DetectorReader *getDetectorReader(EventReader *er, string det)
117 {
118  DetectorReader *dr;
119  // this switch handles all "TPC-like" detectors
120  if(det == "TPC")
121  {
122  Bank_TPCPV1P0 *pTPCP;
123  pTPCP = (Bank_TPCPV1P0 *)er->findBank("TPCP");
124  if (!pTPCP) dr = NULL;
125  else dr = new TPCV1P0_Reader(er,pTPCP);
126 
127  }
128  else if (det == "TPCV1P0")
129  {
130  Bank_TPCPV1P0 *pTPCP;
131  pTPCP = (Bank_TPCPV1P0 *)er->findBank("TPCP");
132  if (!pTPCP) dr = NULL;
133  else dr = new TPCV1P0_Reader(er,pTPCP);
134  }
135  else if (det == "TPCV2P0")
136  {
137  Bank_TPCPV2P0 *pTPCP;
138  pTPCP = (Bank_TPCPV2P0 *)er->findBank("TPCP");
139  if (!pTPCP) dr = NULL;
140  else dr = new TPCV2P0_Reader(er,pTPCP);
141  }
142  else if (det == "SVT")
143  {
144  Bank_SVTPV1P0 *pSVTP;
145  pSVTP = (Bank_SVTPV1P0 *)er->findBank("SVTP");
146  if (!pSVTP) dr = NULL;
147  else dr = new SVTV1P0_Reader(er,pSVTP);
148  }
149  else if (det == "FTPC")
150  {
151  Bank_FTPPV1P0 *pFTPP;
152  pFTPP = (Bank_FTPPV1P0 *)er->findBank("FTPP");
153  if (!pFTPP) dr = NULL;
154  else dr = new FTPV1P0_Reader(er,pFTPP);
155  }
156  else
157  {
158  dr = NULL;
159  }
160 
161  return dr;
162 }
163 
164 DetectorReader *getFTPCReader(EventReader *er)
165 {
166  string det="FTPC";
167  DetectorReader *detReader=getDetectorReader(er,det);
168  return detReader;
169 }
170 
171 RICH_Reader *getRICHReader(EventReader *er)
172 {
173  Bank_RICP *pRICP;
174  pRICP = (Bank_RICP *)er->findBank("RICP");
175  if (pRICP) {
176  if (!pRICP->test_CRC()) printf("DetectorReader - getRICHReader: CRC error in RICP: %s %d\n",
177  __FILE__,__LINE__) ;
178  if (pRICP->swap() < 0) printf("DetectorReader - getRICHReader: swap error in RICP: %s %d\n",
179  __FILE__,__LINE__) ;
180  pRICP->header.CRC = 0;
181  return new RICH_Reader(er,pRICP);
182  }
183  return NULL;
184 }
185 
186 EEMC_Reader *getEEMCReader(EventReader *er)
187 {
188  Bank_EEMCP *pEEMCP;
189  pEEMCP = (Bank_EEMCP *)er->findBank("EECP");
190  if (pEEMCP) {
191  if (!pEEMCP->test_CRC()) printf("DetectorReader - getEMCReader: CRC error in EEMCP: %s %d\n",
192  __FILE__,__LINE__) ;
193  if (pEEMCP->swap() < 0) printf("DetectorReader - getEMCReader: swap error in EEMCP: %s %d\n",
194  __FILE__,__LINE__) ;
195  pEEMCP->header.CRC = 0;
196  }
197  return new EEMC_Reader(er,pEEMCP);
198 }
199 SSD_Reader *getSSDReader(EventReader *er)
200 {
201  printf("DetectorReader - getSSDReader: before instantiation of SSD_Reader.\n");
202  return new SSD_Reader(er);
203  return NULL;
204 }
205 EMC_Reader *getEMCReader(EventReader *er)
206 {
207  // SMD data is here, also towers for year < 2008
208  Bank_EMCP *pEMCP;
209  pEMCP = (Bank_EMCP *)er->findBank("EMCP");
210 
211  // towers are now in trg block
212  Bank_TRGP *pTRGP;
213  pTRGP = (Bank_TRGP *)er->findBank("TRGP");
214 
215  if (pEMCP) {
216  if (!pEMCP->test_CRC()) printf("DetectorReader - getEMCReader: CRC error in EMCP: %s %d\n",
217  __FILE__,__LINE__) ;
218  if (pEMCP->swap() < 0) printf("DetectorReader - getEMCReader: swap error in EMCP: %s %d\n",
219  __FILE__,__LINE__) ;
220  pEMCP->header.CRC = 0;
221  }
222 
223  return new EMC_Reader(er,pEMCP,pTRGP);
224 }
225 PMD_Reader *getPMDReader(EventReader *er)
226 {
227  Bank_PMDP *pPMDP;
228  pPMDP = (Bank_PMDP *)er->findBank("PMDP");
229  if (pPMDP) {
230  if (!pPMDP->test_CRC()) printf("DetectorReader - getPMDReader: CRC error in PMDP: %s %d\n",
231  __FILE__,__LINE__) ;
232  if (pPMDP->swap() < 0) printf("DetectorReader - getPMDReader: swap error in PMDP: %s %d\n",
233  __FILE__,__LINE__) ;
234  pPMDP->header.CRC = 0;
235  return new PMD_Reader(er,pPMDP);
236  }
237  return NULL;
238 }
239 TRG_Reader *getTRGReader(EventReader *er)
240 {
241  Bank_TRGP *pTRGP;
242  pTRGP = (Bank_TRGP *)er->findBank("TRGP");
243  //printf("DEBUG In getTRGReader - pointer to TRGP is %p = %s\n",
244  // (void *) pTRGP,
245  // pTRGP?"TRUE":"FALSE");
246  if (pTRGP) {
247  if (!pTRGP->test_CRC()) {printf("DetectorReader - getTRGReader: CRC error in TRGP: %s %d\n",
248  __FILE__,__LINE__) ; return NULL;}
249  if (pTRGP->swap() < 0) {printf("DetectorReader - getTRGReader: swap error in TRGP: %s %d\n",
250  __FILE__,__LINE__) ; return NULL;}
251  pTRGP->header.CRC = 0;
252  TRG_Reader *r = new TRG_Reader(er,pTRGP);
253  if (!r->GetErr()) return r;
254  (void) printf("DetectorReader - getTRGReader: Error => deleting implementation (check will cause event to be skipped)\n");
255  delete r;
256  return NULL;
257  }
258  return NULL;
259 }
260 
261 L3_Reader *getL3Reader(EventReader *er)
262 {
263  Bank_L3_P *pL3P;
264  pL3P = (Bank_L3_P *)er->findBank("L3_P");
265  if(pL3P)
266  {
267  if(!pL3P->test_CRC()) printf("DetectorReader - getL3Reader: CRC error in L3P: %s %d\n",
268  __FILE__,__LINE__);
269  if(pL3P->swap() < 0) printf("DetectorReader - getL3Reader: swap error in L3P: %s %d\n",
270  __FILE__,__LINE__);
271  pL3P->header.CRC = 0;
272  return new L3_Reader(er,pL3P);
273  }
274  return NULL;
275 }
276 
277 TOF_Reader *getTOFReader(EventReader *er)
278 {
279  Bank_TOFP *pTOFP;
280  pTOFP = (Bank_TOFP *)er->findBank("TOFP");
281  if (pTOFP) {
282  if (!pTOFP->test_CRC()) printf("DetectorReader - getTOFReader: CRC error in TOFP: %s %d\n",
283  __FILE__,__LINE__) ;
284  if (pTOFP->swap() < 0) printf("DetectorReader - getTOFReader: swap error in TOFP: %s %d\n",
285  __FILE__,__LINE__) ;
286  pTOFP->header.CRC = 0;
287  return new TOF_Reader(er,pTOFP);
288  }
289  return NULL;
290 }
291 
292 FPD_Reader *getFPDReader(EventReader *er)
293 {
294  Bank_FPDP *pFPDP;
295  pFPDP = (Bank_FPDP *)er->findBank("FPDP");
296  if (pFPDP) {
297  if (!pFPDP->test_CRC()) printf("DetectorReader - getFPDReader: CRC error in FPDP: %s %d\n",
298  __FILE__,__LINE__) ;
299  if (pFPDP->swap() < 0) printf("DetectorReader - getFPDReader: swap error in FPDP: %s %d\n",
300  __FILE__,__LINE__) ;
301  pFPDP->header.CRC = 0;
302  return new FPD_Reader(er,pFPDP);
303  }
304  return NULL;
305 }
306 
307 SC_Reader *getSCReader(EventReader *er)
308 {
309  return new SC_Reader(er);
310  return FALSE;
311 }
312