StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuRHICfUtil.cxx
1 #include "StMuRHICfUtil.h"
2 
3 #include "StEvent/StEvent.h"
4 #include "StEvent/StEventTypes.h"
5 #include "StEvent/StTriggerData.h"
6 #include "StEvent/StRHICfCollection.h"
7 #include "StEvent/StRHICfRawHit.h"
8 #include "StEvent/StRHICfHit.h"
9 #include "StEvent/StRHICfPoint.h"
10 
11 #include "StMuEvent.h"
12 #include "StMuDst.h"
13 #include "StMuRHICfCollection.h"
14 #include "StMuRHICfRawHit.h"
15 #include "StMuRHICfHit.h"
16 #include "StMuRHICfPoint.h"
17 
18 
19 ClassImp(StMuRHICfUtil)
20 
22 {
23 }
24 
25 StMuRHICfUtil::~StMuRHICfUtil()
26 {
27 }
28 
29 StMuRHICfCollection* StMuRHICfUtil::getMuRHICf(StRHICfCollection* coll)
30 {
31  if(!coll) return NULL;
32 
34  fillMuRHICf(muColl, coll);
35  return muColl;
36 }
37 
38 StRHICfCollection* StMuRHICfUtil::getRHICf(StMuRHICfCollection* muColl)
39 {
40  if(!muColl) return NULL;
41 
43  fillRHICf(coll, muColl);
44  return coll;
45 }
46 
47 void StMuRHICfUtil::fillMuRHICf(StMuRHICfCollection* muColl, StRHICfCollection* coll)
48 {
49  if(!coll) return;
50  if(!muColl) return;
51 
52  StMuRHICfRawHit* muRHICfRawHit = muColl -> addRawHit();
53  StRHICfRawHit* rhicfRawHit = coll -> rawHitCollection();
54 
55  muRHICfRawHit -> setRHICfRunNumber(coll->getRHICfRunNumber());
56  muRHICfRawHit -> setRHICfEventNumber(coll->getRHICfEventNumber());
57  muRHICfRawHit -> setRunType(coll->getRunType());
58  muRHICfRawHit -> setBunchNumber(coll->getBunchNumber());
59  muRHICfRawHit -> setTriggerNumber(coll->getTriggerNumber());
60  muRHICfRawHit -> setRunTime(0, coll->getRunTime(0));
61  muRHICfRawHit -> setRunTime(1, coll->getRunTime(1));
62  muRHICfRawHit -> setRunTRGM(coll->getRunTRGM());
63 
64  fillMuRHICfRawHit(muRHICfRawHit, rhicfRawHit);
65 
66  StRHICfHit* rhicfHit = coll -> hitCollection();
67  if(rhicfHit){
68  StMuRHICfHit* muRHICfHit = muColl -> addHit();
69  fillMuRHICfHit(muRHICfHit, rhicfHit);
70  }
71 
72  for (unsigned i(0); i < coll->numberOfPoints(); ++i){
73  StRHICfPoint* rhicfPoint = coll->pointCollection()[i];
74  StMuRHICfPoint* muRHICfPoint = muColl->addPoint();
75 
76  if(rhicfPoint && muRHICfPoint){
77  fillMuRHICfPoint(muRHICfPoint, rhicfPoint);
78  }
79  }
80 }
81 
82 void StMuRHICfUtil::fillRHICf(StRHICfCollection* coll, StMuRHICfCollection* muColl)
83 {
84  if(!muColl) return;
85  if(!coll) return;
86 
87  StMuRHICfRawHit* muRHICfRawHit = muColl -> getRawHit();
88  StRHICfRawHit* rhicfRawHit = coll -> rawHitCollection();
89 
90  coll -> setRHICfRunNumber(muRHICfRawHit->getRHICfRunNumber());
91  coll -> setRHICfEventNumber(muRHICfRawHit->getRHICfEventNumber());
92  coll -> setRunType(muRHICfRawHit->getRunType());
93  coll -> setBunchNumber(muRHICfRawHit->getBunchNumber());
94  coll -> setTriggerNumber(muRHICfRawHit->getTriggerNumber());
95  coll -> setRunTime(0, muRHICfRawHit->getRunTime(0));
96  coll -> setRunTime(1, muRHICfRawHit->getRunTime(1));
97  coll -> setRunTRGM(muRHICfRawHit->getRunTRGM());
98 
99  fillRHICfRawHit(rhicfRawHit, muRHICfRawHit);
100 
101  StMuRHICfHit* muRHICfHit = muColl -> getHit();
102  if(muRHICfHit){
103  StRHICfHit* rhicfHit = coll -> hitCollection();
104  fillRHICfHit(rhicfHit, muRHICfHit);
105  }
106 
107  for(unsigned i(0); i < muColl->numberOfPoints(); ++i){
108  StMuRHICfPoint* muRHICfPoint = muColl->getPoint(i);
109  StRHICfPoint* rhicfPoint = new StRHICfPoint();
110 
111  if(muRHICfPoint && rhicfPoint){
112  fillRHICfPoint(rhicfPoint, muRHICfPoint);
113  coll -> addPoint(rhicfPoint);
114  }
115  }
116 }
117 
118 Int_t StMuRHICfUtil::checkGSOBarSize(Int_t tower)
119 {
120  if(tower==0){return kRHICfNbarSmall;}
121  else if(tower==1){return kRHICfNbarLarge;}
122  else{return 0;}
123 }
124 
125 void StMuRHICfUtil::fillMuRHICfRawHit(StMuRHICfRawHit* muRHICfRawHit, StRHICfRawHit* rhicfRawHit)
126 {
127  for(int it=0; it<kRHICfNtower; it++){
128  for(int il=0; il<kRHICfNlayer; il++){
129  for(int ixy=0; ixy<kRHICfNxy; ixy++){
130  for(int ich=0; ich<checkGSOBarSize(it); ich++){
131  Int_t gsoBarADC = rhicfRawHit -> getGSOBarADC(it, il, ixy, ich);
132  muRHICfRawHit -> setGSOBarADC(it, il, ixy, ich, gsoBarADC);
133  }
134  }
135  }
136  for(int ip=0; ip<kRHICfNplate; ip++){
137  for(int ir=0; ir<2; ir++){
138  Int_t plateADC = rhicfRawHit -> getPlateADC(it, ip, ir);
139  Int_t plateADCD = rhicfRawHit -> getPlateADCDelay(it, ip, ir);
140  muRHICfRawHit -> setPlateADC(it, ip, ir, plateADC);
141  muRHICfRawHit -> setPlateADCDelay(it, ip, ir, plateADCD);
142  }
143  }
144  }
145  for(Int_t idx=0; idx<kRHICfNtdc; idx++){
146  if(idx<kRHICfNcad0){muRHICfRawHit -> setCAD0(idx, rhicfRawHit->getCAD0(idx));}
147  if(idx<kRHICfNgpi0){muRHICfRawHit -> setGPI0(idx, rhicfRawHit->getGPI0(idx));}
148  if(idx<kRHICfNgpi1){muRHICfRawHit -> setGPI1(idx, rhicfRawHit->getGPI1(idx));}
149  muRHICfRawHit -> setTDC(idx, rhicfRawHit->getTDC(idx));
150  }
151 }
152 
153 void StMuRHICfUtil::fillMuRHICfHit(StMuRHICfHit* muRHICfHit, StRHICfHit* rhicfHit)
154 {
155  if(!muRHICfHit->isSaveDataArray()){
156  for(int it=0; it<kRHICfNtower; it++){
157  for(int il=0; il<kRHICfNlayer; il++){
158  for(int ixy=0; ixy<kRHICfNxy; ixy++){
159  for(int ich=0; ich<checkGSOBarSize(it); ich++){
160  muRHICfHit -> setGSOBarEnergy(it, il, ixy, ich, rhicfHit->getGSOBarEnergy(it, il, ixy, ich));
161  }
162  }
163  }
164  for(int ip=0; ip<kRHICfNplate; ip++){
165  muRHICfHit -> setPlateEnergy(it, ip, rhicfHit->getPlateEnergy(it, ip));
166  }
167  }
168  }
169  // save the detailed hit data
170  else if(muRHICfHit->isSaveDataArray()){
171  muRHICfHit -> initDataArray();
172 
173  for(int it=0; it<kRHICfNtower; it++){
174  muRHICfHit -> setL20(it, rhicfHit->getL20(it));
175  muRHICfHit -> setL90(it, rhicfHit->getL90(it));
176  muRHICfHit -> setMultiHitNum(it, rhicfHit->getMultiHitNum(it));
177  muRHICfHit -> setGSOMaxLayer(it, 0, rhicfHit->getGSOMaxLayer(it, 0));
178  muRHICfHit -> setGSOMaxLayer(it, 1, rhicfHit->getGSOMaxLayer(it, 1));
179 
180  for(int il=0; il<kRHICfNlayer; il++){
181  for(int ixy=0; ixy<kRHICfNxy; ixy++){
182  muRHICfHit -> setMaxPeakBin(it, il, ixy, rhicfHit->getMaxPeakBin(it, il, ixy));
183  muRHICfHit -> setSingleHitNum(it, il, ixy, rhicfHit->getSingleHitNum(it, il, ixy));
184  muRHICfHit -> setSingleHitPos(it, il, ixy, rhicfHit->getSingleHitPos(it, il, ixy));
185  muRHICfHit -> setSinglePeakHeight(it, il, ixy, rhicfHit->getSinglePeakHeight(it, il, ixy));
186  muRHICfHit -> setSingleFitChi2(it, il, ixy, rhicfHit->getSingleFitChi2(it, il, ixy));
187  muRHICfHit -> setMultiFitChi2(it, il, ixy, rhicfHit->getMultiFitChi2(it, il, ixy));
188 
189  for(int ich=0; ich<checkGSOBarSize(it); ich++){
190  muRHICfHit -> setGSOBarEnergy(it, il, ixy, ich, rhicfHit->getGSOBarEnergy(it, il, ixy, ich));
191  }
192 
193  for(int io=0; io<2; io++){
194  muRHICfHit -> setMultiHitPos(it, il, ixy, io, rhicfHit->getMultiHitPos(it, il, ixy, io));
195  muRHICfHit -> setMultiPeakHeight(it, il, ixy, io, rhicfHit->getMultiPeakHeight(it, il, ixy, io));
196  muRHICfHit -> setMultiPeakRaw(it, il, ixy, io, rhicfHit->getMultiPeakRaw(it, il, ixy, io));
197  muRHICfHit -> setMultiEnergySum(it, il, ixy, io, rhicfHit->getMultiEnergySum(it, il, ixy, io));
198  }
199  }
200  }
201  for(int ip=0; ip<kRHICfNplate; ip++){
202  muRHICfHit -> setPlateEnergy(it, ip, rhicfHit->getPlateEnergy(it, ip));
203  }
204  }
205  }
206 }
207 
208 void StMuRHICfUtil::fillMuRHICfPoint(StMuRHICfPoint* muRHICfPoint, StRHICfPoint* rhicfPoint)
209 {
210  muRHICfPoint -> setTowerIdx(rhicfPoint->getTowerIdx());
211  muRHICfPoint -> setPID(rhicfPoint->getPID());
212  muRHICfPoint -> setTowerSumEnergy(rhicfPoint->getTowerSumEnergy(0), rhicfPoint->getTowerSumEnergy(1));
213  muRHICfPoint -> setPointPos(rhicfPoint->getPointPos(0), rhicfPoint->getPointPos(1));
214  muRHICfPoint -> setPointEnergy(rhicfPoint->getPointEnergy(0), rhicfPoint->getPointEnergy(1));
215 }
216 
217 void StMuRHICfUtil::fillRHICfRawHit(StRHICfRawHit* rhicfRawHit, StMuRHICfRawHit* muRHICfRawHit)
218 {
219  for(int it=0; it<kRHICfNtower; it++){
220  for(int il=0; il<kRHICfNlayer; il++){
221  for(int ixy=0; ixy<kRHICfNxy; ixy++){
222  for(int ich=0; ich<checkGSOBarSize(it); ich++){
223  Int_t gsoBarADC = muRHICfRawHit -> getGSOBarADC(it, il, ixy, ich);
224  rhicfRawHit -> setGSOBarADC(it, il, ixy, ich, gsoBarADC);
225  }
226  }
227  }
228  for(int ip=0; ip<kRHICfNplate; ip++){
229  for(int ir=0; ir<2; ir++){
230  Int_t plateADC = muRHICfRawHit -> getPlateADC(it, ip, ir);
231  Int_t plateADCD = muRHICfRawHit -> getPlateADCDelay(it, ip, ir);
232  rhicfRawHit -> setPlateADC(it, ip, ir, plateADC);
233  rhicfRawHit -> setPlateADCDelay(it, ip, ir, plateADCD);
234  }
235  }
236  }
237  for(Int_t idx=0; idx<kRHICfNtdc; idx++){
238  if(idx<kRHICfNcad0){rhicfRawHit -> setCAD0(idx, muRHICfRawHit->getCAD0(idx));}
239  if(idx<kRHICfNgpi0){rhicfRawHit -> setGPI0(idx, muRHICfRawHit->getGPI0(idx));}
240  if(idx<kRHICfNgpi1){rhicfRawHit -> setGPI1(idx, muRHICfRawHit->getGPI1(idx));}
241  rhicfRawHit -> setTDC(idx, muRHICfRawHit->getTDC(idx));
242  }
243 }
244 
245 void StMuRHICfUtil::fillRHICfHit(StRHICfHit* rhicfHit, StMuRHICfHit* muRHICfHit)
246 {
247  if(!rhicfHit->isSaveDataArray()){
248  for(int it=0; it<kRHICfNtower; it++){
249  for(int il=0; il<kRHICfNlayer; il++){
250  for(int ixy=0; ixy<kRHICfNxy; ixy++){
251  for(int ich=0; ich<checkGSOBarSize(it); ich++){
252  rhicfHit -> setGSOBarEnergy(it, il, ixy, ich, muRHICfHit->getGSOBarEnergy(it, il, ixy, ich));
253  }
254  }
255  }
256  for(int ip=0; ip<kRHICfNplate; ip++){
257  rhicfHit -> setPlateEnergy(it, ip, muRHICfHit->getPlateEnergy(it, ip));
258  }
259  }
260  }
261  // save the detailed hit data
262  else if(rhicfHit->isSaveDataArray()){
263  rhicfHit -> initDataArray();
264 
265  for(int it=0; it<kRHICfNtower; it++){
266  rhicfHit -> setL20(it, muRHICfHit->getL20(it));
267  rhicfHit -> setL90(it, muRHICfHit->getL90(it));
268  rhicfHit -> setMultiHitNum(it, muRHICfHit->getMultiHitNum(it));
269  rhicfHit -> setGSOMaxLayer(it, 0, muRHICfHit->getGSOMaxLayer(it, 0));
270  rhicfHit -> setGSOMaxLayer(it, 1, muRHICfHit->getGSOMaxLayer(it, 1));
271 
272  for(int il=0; il<kRHICfNlayer; il++){
273  for(int ixy=0; ixy<kRHICfNxy; ixy++){
274  rhicfHit -> setMaxPeakBin(it, il, ixy, muRHICfHit->getMaxPeakBin(it, il, ixy));
275  rhicfHit -> setSingleHitNum(it, il, ixy, muRHICfHit->getSingleHitNum(it, il, ixy));
276  rhicfHit -> setSingleHitPos(it, il, ixy, muRHICfHit->getSingleHitPos(it, il, ixy));
277  rhicfHit -> setSinglePeakHeight(it, il, ixy, muRHICfHit->getSinglePeakHeight(it, il, ixy));
278  rhicfHit -> setSingleFitChi2(it, il, ixy, muRHICfHit->getSingleFitChi2(it, il, ixy));
279  rhicfHit -> setMultiFitChi2(it, il, ixy, muRHICfHit->getMultiFitChi2(it, il, ixy));
280 
281  for(int ich=0; ich<checkGSOBarSize(it); ich++){
282  rhicfHit -> setGSOBarEnergy(it, il, ixy, ich, muRHICfHit->getGSOBarEnergy(it, il, ixy, ich));
283  }
284 
285  for(int io=0; io<2; io++){
286  rhicfHit -> setMultiHitPos(it, il, ixy, io, muRHICfHit->getMultiHitPos(it, il, ixy, io));
287  rhicfHit -> setMultiPeakHeight(it, il, ixy, io, muRHICfHit->getMultiPeakHeight(it, il, ixy, io));
288  rhicfHit -> setMultiPeakRaw(it, il, ixy, io, muRHICfHit->getMultiPeakRaw(it, il, ixy, io));
289  rhicfHit -> setMultiEnergySum(it, il, ixy, io, muRHICfHit->getMultiEnergySum(it, il, ixy, io));
290  }
291  }
292  }
293  for(int ip=0; ip<kRHICfNplate; ip++){
294  rhicfHit -> setPlateEnergy(it, ip, muRHICfHit->getPlateEnergy(it, ip));
295  }
296  }
297  }
298 }
299 
300 void StMuRHICfUtil::fillRHICfPoint(StRHICfPoint* rhicfPoint, StMuRHICfPoint* muRHICfPoint)
301 {
302  rhicfPoint -> setTowerIdx(muRHICfPoint->getTowerIdx());
303  rhicfPoint -> setPID(muRHICfPoint->getPID());
304  rhicfPoint -> setTowerSumEnergy(muRHICfPoint->getTowerSumEnergy(0), muRHICfPoint->getTowerSumEnergy(1));
305  rhicfPoint -> setPointPos(muRHICfPoint->getPointPos(0), muRHICfPoint->getPointPos(1));
306  rhicfPoint -> setPointEnergy(muRHICfPoint->getPointEnergy(0), muRHICfPoint->getPointEnergy(1));
307 }