StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPMDReader.cxx
1 /***************************************************************************
2  *$Id: StPMDReader.cxx,v 1.3 2004/05/14 21:44:31 perev Exp $
3  *
4  * StPMDReader.cxx
5  * Author: Susanta and Subhasis
6  ***************************************************************************
7  *
8  * Description: Offline Wrapper for DAQ PMD reader classes
9  **************************************************************************
10  *$Log: StPMDReader.cxx,v $
11  *Revision 1.3 2004/05/14 21:44:31 perev
12  *Check non existing PMDImpReader added
13  *
14  *Revision 1.2 2003/12/10 10:31:01 subhasis
15  *loop for No of channels read is changed to PMD_CRAMS_CH_MAX
16  *
17  **************************************************************************/
18 #include <string.h>
19 #include <stdio.h>
20 #include <errno.h>
21 #include <assert.h>
22 #include "StDAQReader.h"
23 #include "StPMDReader.h"
24 #include "StDaqLib/PMD/PMD_Reader.hh"
25 
26 typedef EventInfo DAQEventInfo;
27 
28 StPMDReader::StPMDReader(StDAQReader *daqr) {
29  fDAQReader = daqr;
30  fPMDImpReader = ::getPMDReader(daqr->getEventReader());
31 
32  getPMD_ADC();
33 
34 }
35 
36 
37 StPMDReader::~StPMDReader() {
38 }
39 
40 int StPMDReader::close() {
41  return 1;
42 }
43 
44 int StPMDReader::Update() {
45  delete fPMDImpReader;
46  fPMDImpReader = ::getPMDReader(fDAQReader->getEventReader());
47  getPMD_ADC();
48  // close();
49  return 1;
50 }
51 
52 /* int StPMDReader::getPMD_ADCD(int SEC,int CRAM, int BLOCK,int CHANNEL, unsigned short& ADC )
53  {
54 
55  if(!fPMDImpReader->getPMD_ADCD(SEC,CRAM,BLOCK,CHANNEL,ADC))return 0;
56  return 1; //1 is good
57  }
58 */
59 int StPMDReader::NPMDHits()
60  {
61  return (fPMDImpReader) ? fPMDImpReader->NPMDHits():0;
62  }
63 
64 void StPMDReader::getPMD_ADC()
65 {
66  if (fPMDImpReader) {mPmd = fPMDImpReader->getPMD_ADC();}
67  else {memset(&mPmd,0,sizeof(mPmd)); }
68 }
69 
70 int StPMDReader::getNoOfChannelsInCramBlock(int sec, int cram, int blk)
71 {
72  return mPmd.no_of_channels_in_cram_blk[sec][cram][blk] ;
73 }
74 
75 int StPMDReader::getAllPmdCpvData(int *adc)
76 {
77  int no_ch=0;
78  for(int sec=0; sec<PMD_SECTOR; sec++){
79  for(int cram=0; cram< PMD_CRAMS_MAX; cram++){
80  for(int blk=0; blk <PMD_CRAMS_BLOCK; blk++ ){
81  for( int ch=0; ch < PMD_CRAMS_CH_MAX; ch++, adc++){
82  *adc=mPmd.adc[sec][cram][blk][ch];
83  no_ch++;
84  }
85  }
86  }
87  }
88  return no_ch;
89 }
90 
91 int StPMDReader::getAllPmdCpvDataChannelByChannel(int sec, int cram, int blk, int channel)
92 {
93  return mPmd.adc[sec][cram][blk][channel];
94 }
95 
96 int StPMDReader::getNoOfChannelsInPmdChain(int chain_no)
97 {
98  int sec, cram, blk;
99  cram=chain_no; blk=0; // PMD is in Block0
100  if (chain_no < 12 )
101  sec=0;
102  else
103  sec=1;
104  return mPmd.no_of_channels_in_cram_blk[sec][cram][blk] ;
105 }
106 
107 int StPMDReader::getPmdChainData(int chain_no, int *data)
108 {
109  int sec, cram, blk, channel;
110  cram=chain_no; blk=0; //PMD is in Block0
111  if (chain_no < 12 )
112  sec=0;
113  else
114  sec=1;
115  for(channel=0; channel < PMD_CRAMS_CH_MAX; channel++ , data++){
116  *data= mPmd.adc[sec][cram][blk][channel];
117  }
118 
119  return mPmd.no_of_channels_in_cram_blk[sec][cram][blk] ;
120 }
121 
122 
123 int StPMDReader::getNoOfChannelsInCpvChain(int chain_no)
124 {
125  int sec, cram, blk;
126  cram=chain_no; blk=1; // CPV is in Block1
127  if (chain_no < 12 )
128  sec=0;
129  else
130  sec=1;
131  return mPmd.no_of_channels_in_cram_blk[sec][cram][blk] ;
132 }
133 
134 int StPMDReader::getCpvChainData(int chain_no, int *data)
135 {
136  int sec, cram, blk, channel;
137  cram=chain_no; blk=1; //CPV is in Block1
138  if (chain_no < 12 )
139  sec=0;
140  else
141  sec=1;
142  for(channel=0; channel <PMD_CRAMS_CH_MAX; channel++ , data++){
143  *data= mPmd.adc[sec][cram][blk][channel];
144  }
145 
146  return mPmd.no_of_channels_in_cram_blk[sec][cram][blk] ;
147 }
148 
149 int StPMDReader::getAllPmdCpvPed(int *ped)
150 {
151  int no_ch=0;
152  for(int sec=0; sec<PMD_SECTOR; sec++){
153  for(int cram=0; cram< PMD_CRAMS_MAX; cram++){
154  for(int blk=0; blk <PMD_CRAMS_BLOCK; blk++ ){
155  for( int ch=0; ch < PMD_CRAMS_CH_MAX; ch++, ped++){
156  *ped=mPmd.ped[sec][cram][blk][ch];
157  if(mPmd.ped[sec][cram][blk][ch]>0)no_ch++;
158  }
159  }
160  }
161  }
162  return no_ch;
163 }
164 int StPMDReader::getAllPmdCpvRms(int *rms)
165 {
166  int no_ch=0;
167  for(int sec=0; sec<PMD_SECTOR; sec++){
168  for(int cram=0; cram< PMD_CRAMS_MAX; cram++){
169  for(int blk=0; blk <PMD_CRAMS_BLOCK; blk++ ){
170  for( int ch=0; ch < PMD_CRAMS_CH_MAX; ch++, rms++){
171  *rms=mPmd.rms[sec][cram][blk][ch];
172  if(mPmd.rms[sec][cram][blk][ch]>0)no_ch++;
173  no_ch++;
174  }
175  }
176  }
177  }
178  return no_ch;
179 }