StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSstBarrel.cc
1 //$Id: StSstBarrel.cc,v 1.8 2016/06/10 19:26:55 bouchet Exp $
2 //
3 //$Log: StSstBarrel.cc,v $
4 //Revision 1.8 2016/06/10 19:26:55 bouchet
5 //coverity : FORWARD_NULL
6 //
7 //Revision 1.7 2016/06/08 20:52:57 bouchet
8 //coverity : PASS_BY_VALUE
9 //
10 //Revision 1.6 2016/05/29 19:34:51 bouchet
11 //coverity : CTOR_DTOR_LEAK fixed
12 //
13 //Revision 1.5 2016/05/27 15:21:13 bouchet
14 //cleanup cout
15 //
16 //Revision 1.4 2015/11/17 18:09:51 bouchet
17 //Long Zhou modification, move cout to LOG_DEBUG
18 //
19 //Revision 1.3 2015/07/21 14:29:22 bouchet
20 //removed unused variables
21 //
22 //Revision 1.2 2015/06/27 19:48:51 bouchet
23 //removed obsolete libraries : ssdConfiguration, ssdDimensions, ssdWafersPosition ; fixed static StSstBarrel name
24 //
25 //Revision 1.1 2015/06/23 16:26:19 jeromel
26 //First version created from the SSD code and reshaped
27 //
28 //Revision 1.6 2015/06/19 14:16:23 bouchet
29 //readNoiseFromTable() takes sstStripCalib data as input, not the structure
30 //
31 //Revision 1.5 2015/05/23 20:51:51 bouchet
32 //ADC hits set properly in writePointToContainer() ; cosmetics
33 //
34 //Revision 1.4 2015/04/21 18:26:08 bouchet
35 //typos between SSD and SST name fixed
36 //
37 //Revision 1.3 2015/04/20 20:09:20 bouchet
38 //added readNoiseFromTable() method using sstStripCalib table ; added includes for sstStripCalib and sstWafersPosition
39 //
40 //Revision 1.2 2015/04/20 19:01:25 bouchet
41 //removed some hard coded constants ; removed unused writePointToContainer() method
42 //
43 //Revision 1.1 2015/04/19 17:30:31 bouchet
44 //initial commit ; SST codes
45 //
46 
47 //fork from the SSD code, move along - see history therein
48 #include "StSstUtil/StSstBarrel.hh"
49 
50 #include "TFile.h"
51 #include "StEvent.h"
52 #include "StSstHit.h"
53 #include "StSstHitCollection.h"
54 #include "StarClassLibrary/StThreeVectorF.hh"
55 #include "tables/St_spa_strip_Table.h"
56 #include "tables/St_ssdPedStrip_Table.h"
57 //#include "tables/St_sstPedStrip_Table.h"
58 #include "tables/St_scf_cluster_Table.h"
59 #include "tables/St_scm_spt_Table.h"
60 #include "tables/St_sdm_calib_db_Table.h"
61 //new
62 #include "tables/St_sstDimensions_Table.h"
63 #include "tables/St_sstConfiguration_Table.h"
64 #include "tables/St_sstWafersPosition_Table.h"
65 #include "tables/St_sstStripCalib_Table.h"
66 #include "tables/St_sstSlsCtrl_Table.h"
67 //
68 #include "tables/St_sls_strip_Table.h"
69 #include "tables/St_ssdStripCalib_Table.h"
70 #include "tables/St_slsCtrl_Table.h"
71 #include "tables/St_sls_strip_Table.h"
72 #include "tables/St_spa_strip_Table.h"
73 #include "StSstUtil/StSstLadder.hh"
74 #include "StSstUtil/StSstWafer.hh"
75 #include "StSstUtil/StSstClusterControl.h"
76 #include "StSstDynamicControl.h"
77 #include "StSstStripList.hh"
78 #include "StSstStrip.hh"
79 #include "StSstUtil/StSstClusterList.hh"
80 #include "StSstUtil/StSstCluster.hh"
81 #include "StSstUtil/StSstPointList.hh"
82 #include "StSstUtil/StSstPoint.hh"
83 #include "SystemOfUnits.h"
84 #include "StarMagField.h"
85 #include "TMath.h"
86 #include "StMessMgr.h"
87 
88 #include "tables/St_ssdNoise_Table.h"
89 //new
90 #include "tables/St_sstGainCalibWafer_Table.h"
91 #include "tables/St_sstNoise_Table.h"
92 #include "tables/St_sstWaferConfiguration_Table.h"
93 
94 #include "StMcEvent/StMcSsdHitCollection.hh"
95 #include "StMcEvent.hh"
96 #include "StEventTypes.h"
97 #include "StMcEventTypes.hh"
98 #include "StSstUtil/StSstConsts.h"
99 
100 #include "TDataSetIter.h"
101 
102 StSstBarrel* StSstBarrel::fSstBarrel = 0;
103 //________________________________________________________________________________
107 StSstBarrel::StSstBarrel(sstDimensions_st *dimensions, sstConfiguration_st *config ) : mDebug(0)
108 {
109  memset (first, 0, last-first);
110  fSstBarrel = this;
111  setSstParameters(dimensions);
112  // Set the Lorentz shift for holes and electrons
113  setLorentzShift(dimensions);
114  if (config) {
115  mNLadder = config[0].nMaxLadders;
116  for (Int_t i=0;i<mNLadder;i++) {
117  mActiveLadders[i]=1;
118  if (config && config[0].ladderIsPresent[i]==0)
119  mActiveLadders[i]=0;
120  }
121  }
122  mLadders = new StSstLadder*[mNLadder];
123  for (Int_t iLad=0; iLad < mNLadder; iLad++){
124  mLadders[iLad] = new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
125  if (Debug()) mLadders[iLad]->SetDebug(Debug());
126  }
127 }
128 //________________________________________________________________________________
129 StSstBarrel::~StSstBarrel(){
130  delete [] mLadders;
131  fSstBarrel = 0;
132 }
133 //________________________________________________________________________________
134 void StSstBarrel::setSstParameters(sstDimensions_st *geom_par){
135  mDimensions = geom_par;
136  mSstLayer = 7; // historic : SVT was first 6 layers
137  // note to self --> change it later
138  mDetectorLargeEdge = 2.*geom_par[0].waferHalfActLength;
139  mDetectorSmallEdge = 2.*geom_par[0].waferHalfActWidth;
140  mNLadder = 20;
141  mNWaferPerLadder = geom_par[0].wafersPerLadder;
142  mNStripPerSide = geom_par[0].stripPerSide;
143  mStripPitch = geom_par[0].stripPitch;
144  mTheta = geom_par[0].stereoAngle;
145 }
146 //________________________________________________________________________________
147 void StSstBarrel::setLorentzShift(sstDimensions_st *geom_par){
148  Float_t center[3] = {0,0,0};
149  Float_t B[3] = {0,0,0};
150  //we take the BField at the point (0,0,0)
151  StarMagField::Instance()->BField(center,B);
152  //use the values from CMS
153  Float_t scale = 1.61;
154  Float_t tan_theta_h = scale*TMath::ATan(TMath::Tan(21*2*TMath::Pi()/360)*(B[2]/40.));
155  Float_t tan_theta_e = scale*TMath::ATan(TMath::Tan( 8*2*TMath::Pi()/360)*(B[2]/40.));
156  mShift_hole = geom_par[0].waferHalfThickness*tan_theta_h;
157  mShift_elec = geom_par[0].waferHalfThickness*tan_theta_e;
158 }
159 //________________________________________________________________________________
160 
161 void StSstBarrel::debugUnPeu (Int_t monladder, Int_t monwafer){
162  for (Int_t i=0;i<this->getNumberOfLadders();i++)
163  {
164  if (this->mLadders[i]->getLadderNumb()==monladder)
165  {
166  LOG_INFO<<" Ladder "<<monladder<<" found"<<endm;
167  this->mLadders[i]->debugUnPeu(monwafer);
168  }
169  }
170 }
171 //______________________________________________________________
172 void StSstBarrel::initLadders(St_sstWafersPosition *wafpos) {for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->initWafers(wafpos);}
173 //________________________________________________________________________________
174 void StSstBarrel::Reset() {for (Int_t iLad = 0; iLad < mNLadder; iLad++) mLadders[iLad]->Reset();}
175 //________________________________________________________________________________
176 Int_t StSstBarrel::readStripFromTable(St_spa_strip *spa_strip){
177  spa_strip_st *strip = spa_strip->GetTable();
178 
179  Int_t NumberOfStrip = 0;
180  Int_t idWaf = 0;
181  Int_t iWaf = 0;
182  Int_t iLad = 0;
183  Int_t nStrip = 0;
184  Int_t iSide = 0;
185  Float_t sigma = 3.0;
186  Int_t iPedestal = 120;
187  Int_t idMcHit[5] = {0,0,0,0,0};
188  Int_t idMcTrack[5] = {0,0,0,0,0};
189  Int_t e = 0;
190  for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
191  {
192  nStrip = (int)(strip[i].id_strip/100000.);
193  idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
194  iWaf = idWaferToWafer(idWaf);
195  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
196  iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
197  for (e = 0 ; e < 5;e++) {
198  idMcHit[e] = strip[i].id_mchit[e];
199  idMcTrack[e] = strip[i].id_mctrack[e];
200  }
201  StSstStrip *newStrip = new StSstStrip(nStrip, strip[i].adc_count, sigma, iPedestal, idMcHit,idMcTrack);
202  mLadders[iLad]->mWafers[iWaf]->addStrip(newStrip, iSide);
203  }
204  NumberOfStrip = spa_strip->GetNRows();
205  return NumberOfStrip;
206 }
207 //________________________________________________________________________________
208 Int_t StSstBarrel::writeNoiseToFile(St_spa_strip *spa_strip){
209  spa_strip_st *strip = spa_strip->GetTable();
210  St_ssdStripCalib *stripCal = new St_ssdStripCalib("ssdStripCalib",spa_strip->GetNRows());
211  ssdStripCalib_st noise_strip;
212  for (Int_t i = 0 ; i < spa_strip->GetNRows(); i++)
213  {
214  noise_strip.id=strip[i].id_strip;
215  noise_strip.pedestals=(short) strip[i].id_mchit[0];
216  noise_strip.rms=(short) strip[i].adc_count;
217  stripCal->AddAt(&noise_strip);
218  }
219  TFile f1("ssdStripCalib.root","NEW");
220  stripCal->Write();
221  f1.Close();
222  return spa_strip->GetNRows();
223 }
224 //-----------------------------------------------------------------------------------------
225 Int_t StSstBarrel::writeNewNoiseToFile3(St_ssdPedStrip *spa_ped_strip, char myLabel[]){
226  char *name =new char[100] ;
227  ssdPedStrip_st *strip = spa_ped_strip->GetTable();
228  St_ssdNoise *StripCal = new St_ssdNoise("ssdNoise",spa_ped_strip->GetNRows());
229  ssdNoise_st temp[mNLadder* mNWaferPerLadder];
230  memset(temp, 0, (mNLadder* mNWaferPerLadder)*sizeof(ssdNoise_st));
231  Int_t idWaf = 0;
232  Int_t iWaf = 0;
233  Int_t iLad = 0;
234  Int_t nStrip = 0;
235  Int_t iSide = 0;
236  Int_t wafer = 0;
237  Int_t N = spa_ped_strip->GetNRows();
238  for (Int_t i=0; i< N;i++) {
239  if (strip[i].id_strip>0 && strip[i].id_strip<=76818620) {
240  nStrip = (int)(strip[i].id_strip/100000.);
241  idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
242  iWaf = (int)((idWaf - mSstLayer*1000)/100 - 1);
243  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
244  iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
245  wafer = iLad*mNWaferPerLadder +iWaf;
246  if (iSide == 0) temp[wafer].rmsp[nStrip-1] = (unsigned char)strip[i].noise;
247  if (iSide == 1) temp[wafer].rmsn[nStrip-1] = (unsigned char)strip[i].noise;
248  }
249  }
250  for(Int_t i=0;i<mNLadder* mNWaferPerLadder;i++) {
251  temp[i].id = i;
252  StripCal->AddAt(&temp[i]);
253  }
254  sprintf(name,"%s%s%s","ssdNoise.",myLabel,".root");
255  TFile f1(name,"RECREATE","SSD ped and noise file",9);
256  StripCal->Write();
257  f1.Close();
258  return spa_ped_strip->GetNRows();
259 }
260 //________________________________________________________________________________
261 /*
262  Method to read pedestal data and save them into a root file
263 */
264 Int_t StSstBarrel::writeNoiseToFile(St_ssdPedStrip *spa_ped_strip, char myLabel[]){
265  char *name =new char[100] ;
266  ssdPedStrip_st *strip = spa_ped_strip->GetTable();
267  St_ssdStripCalib *stripCal = new St_ssdStripCalib("ssdStripCalib",spa_ped_strip->GetNRows());
268  ssdStripCalib_st noise_strip;
269  for (Int_t i = 0 ; i < spa_ped_strip->GetNRows(); i++)
270  {
271  noise_strip.id=strip[i].id_strip;
272  noise_strip.pedestals= (unsigned char) strip[i].pedestal;
273  noise_strip.rms=(unsigned char) strip[i].noise;
274  stripCal->AddAt(&noise_strip);
275  }
276  sprintf(name,"%s%s%s","ssdStripCalib.",myLabel,".root");
277  TFile f1(name,"RECREATE","SSD ped and noise file",9);
278  stripCal->Write();
279  f1.Close();
280  return spa_ped_strip->GetNRows();
281 }
282 //________________________________________________________________________________
286 Int_t StSstBarrel::readNoiseFromTable(St_sdm_calib_db *spa_noise, StSstDynamicControl *dynamicControl){
287  sdm_calib_db_st *noise = spa_noise->GetTable();
288 
289  Int_t NumberOfNoise = 0;
290  Int_t idWaf = 0;
291  Int_t iWaf = 0;
292  Int_t iLad = 0;
293  Int_t nStrip = 0;
294  Int_t iSide = 0;
295  for (Int_t i = 0 ; i < spa_noise->GetNRows(); i++)
296  {
297  nStrip = (int)(noise[i].id_strip/100000.);
298  idWaf = noise[i].id_strip-10000*((int)(noise[i].id_strip/10000.));
299  iWaf = idWaferToWafer(idWaf);
300  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
301  iSide = (noise[i].id_strip - nStrip*100000 - idWaf)/10000;
302  mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide,0, noise[i].n_sigma, dynamicControl);
303  }
304 
305  NumberOfNoise = spa_noise->GetNRows();
306  return NumberOfNoise;
307 }
308 //________________________________________________________________________________
312 Int_t StSstBarrel::readNoiseFromTable(St_ssdStripCalib *strip_calib, StSstDynamicControl *dynamicControl){
313  ssdStripCalib_st *noise = strip_calib->GetTable();
314 
315  Int_t NumberOfNoise = 0;
316  Int_t idWaf = 0;
317  Int_t iWaf = 0;
318  Int_t iLad = 0;
319  Int_t nStrip = 0;
320  Int_t iSide = 0;
321  for (Int_t i = 0 ; i < strip_calib->GetNRows(); i++)
322  {
323  if (noise[i].id>0 && noise[i].id<=76818620) {
324  nStrip = (int)(noise[i].id/100000.);
325  idWaf = noise[i].id-10000*((int)(noise[i].id/10000.));
326  iWaf = idWaferToWafer(idWaf);
327  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
328  iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
329  mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip, iSide, noise[i].pedestals, noise[i].rms, dynamicControl);
330  NumberOfNoise++;
331  }
332  }
333  return NumberOfNoise;
334 }
335 //---------------------------------------------------------------------------------------------
336 Int_t StSstBarrel::readNoiseDefault(StSstDynamicControl *dynamicControl){
337  Int_t rms = 48 ;
338  // the noise is coded as 16*rms then for each strip, noise = 60/16 = 3.75 adc
339  Int_t ped = 120 ;
340  Int_t NumberOfNoise = 0;
341  for(Int_t i=0;i<mNLadder;i++)
342  {
343  for(Int_t j=0;j<mNWaferPerLadder;j++)
344  {
345  for(Int_t k=0;k<mNStripPerSide;k++)
346  {
347  for(Int_t iSide=0;iSide<2;iSide++)
348  {
349  mLadders[i]->mWafers[j]->setPedestalSigmaStrip(k+1,iSide,ped,rms,dynamicControl);
350  NumberOfNoise++;
351  }
352  }
353  }
354  }
355  return NumberOfNoise;
356 }
357 //________________________________________________________________________________
361 Int_t StSstBarrel::readNoiseFromTable(St_ssdNoise *strip_noise, StSstDynamicControl *dynamicControl){
362  ssdNoise_st *noise = strip_noise->GetTable();
363 
364  Int_t NumberOfNoise = 0;
365  Int_t iWaf = 0;
366  Int_t iLad = 0;
367  Int_t nStrip = 0;
368  Int_t iSide = 0;
369  Int_t pedestal = 120;//constant, not used later
370  LOG_INFO << "size of m_noise3 table = " << (int)strip_noise->GetNRows() << endm;
371  for (Int_t i = 0 ; i < strip_noise->GetNRows(); i++)
372  {
373  iWaf = noise[i].id-(noise[i].id/mNWaferPerLadder)*mNWaferPerLadder;
374  iLad = noise[i].id/16;
375  for(nStrip=0;nStrip<mNStripPerSide;nStrip++){
376  iSide=0;
377  mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsp[nStrip], dynamicControl);
378  NumberOfNoise++;
379  iSide=1;
380  mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(nStrip+1, iSide, pedestal, noise[i].rmsn[nStrip], dynamicControl);
381  NumberOfNoise++;
382  }
383  }
384  return NumberOfNoise;
385 }
386 //________________________________________________________________________________
387 Int_t StSstBarrel::readNoiseFromTable(sstStripCalib_st *noise, StSstDynamicControl *dynamicControl){
388  Int_t NumberOfNoise = 0;
389  Int_t iWaf = 0;
390  Int_t iLad = 0;
391  Int_t iStrip = 0;
392  Int_t iSide = 0;
393  Int_t TotStripSide = kSstNumLadders * kSstNumSensorsPerLadder * kSstNumStripsOnSensor;
394  Int_t TotStripPerLadder = kSstNumSensorsPerLadder * kSstNumStripsOnSensor;
395 
396  /*
397  coding is : id = (491520)*side[0-1]/2 + ladder[0-19]*12288 + wafer[0-15]*768 + strip[0-767]
398  */
399 
400  for (Int_t i = 0 ; i < (2*TotStripSide); i++){
401  iSide = i/TotStripSide;
402  iLad = (i - (iSide*TotStripSide))/TotStripPerLadder;
403  iWaf = (i - iSide*TotStripSide - iLad*TotStripPerLadder)/kSstNumStripsOnSensor;
404  iStrip = i - iSide*TotStripSide - iLad*TotStripPerLadder - iWaf*kSstNumStripsOnSensor;
405  LOG_DEBUG <<" i/side/lad/waf/strip/ped/rms : " << i << " " << iSide << " " << iLad <<" " << iWaf <<" " << iStrip <<" " << (int)noise[0].pedestals[i] <<" "<< (int)noise[0].rms[i] << endm;
406  mLadders[iLad]->mWafers[iWaf]->setPedestalSigmaStrip(iStrip+1, iSide, (int)noise[0].pedestals[i], (int)noise[0].rms[i], dynamicControl);
407  NumberOfNoise++;
408  }
409  return NumberOfNoise;
410 }
411 //________________________________________________________________________________
412 
413 Int_t StSstBarrel::readClusterFromTable(St_scf_cluster *scf_cluster){
414  scf_cluster_st *cluster = scf_cluster->GetTable();
415 
416  Int_t NumberOfCluster = 0;
417  Int_t idWaf = 0;
418  Int_t iWaf = 0;
419  Int_t iLad = 0;
420  Int_t nCluster = 0;
421  Int_t nPCluster = 0;
422  Int_t nNCluster = 0;
423  Int_t iSide = 0;
424  Int_t idMcHit[5] = {0,0,0,0,0};
425  Int_t e = 0;
426  Int_t nStrip = 0;
427  Int_t nFirstStrip = 0;
428  Int_t nFirstAdc = 0;
429  Int_t nLastAdc = 0;
430  Int_t nAdcCount = 0;
431  Float_t nNoiseCount = 0;
432  Float_t nStripMean = 0;
433  Int_t nFlag = 0;
434 
435  for (Int_t i = 0 ; i < scf_cluster->GetNRows(); i++)
436  {
437  nCluster = (int)(cluster[i].id_cluster/100000.);
438  idWaf = (cluster[i].id_cluster-10000*((int)(cluster[i].id_cluster/10000.)));
439  iSide = (cluster[i].id_cluster-idWaf-nCluster*100000)/10000;
440  iWaf = idWaferToWafer(idWaf);
441  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
442  nFirstStrip = (int)(cluster[i].first_strip/100000.);
443  nStrip = cluster[i].n_strip;
444  nFirstAdc = cluster[i].first_adc_count;
445  nLastAdc = cluster[i].last_adc_count;
446  nAdcCount = cluster[i].adc_count;
447  nNoiseCount = cluster[i].noise_count;
448  nStripMean = cluster[i].strip_mean;
449  nFlag = cluster[i].flag;
450  for (e = 0 ; e < 5; e++) idMcHit[e] = cluster[i].id_mchit[e];
451  StSstCluster *newCluster = new StSstCluster(nCluster, nFirstStrip, nStrip, nAdcCount, nFirstAdc, nLastAdc, nNoiseCount, nStripMean, nFlag, idMcHit);
452  if (iSide == 0)
453  {nPCluster++;}
454  else
455  {nNCluster++;}
456  mLadders[iLad]->mWafers[iWaf]->addCluster(newCluster, iSide);
457  }
458 
459  NumberOfCluster = scf_cluster->GetNRows();
460  return NumberOfCluster;
461 }
462 //________________________________________________________________________________
463 Int_t StSstBarrel::writeClusterToTable(St_scf_cluster *scf_cluster){
464  scf_cluster_st cluster;
465  Int_t currRecord = 0;
466  Int_t i = 0;
467 
468  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
469  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
470  {
471  Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
472  StSstClusterList *clusterP = mLadders[iLad]->mWafers[iWaf]->getClusterP();
473  StSstClusterList *clusterN = mLadders[iLad]->mWafers[iWaf]->getClusterN();
474 
475  StSstCluster *pClusterP = clusterP->first();
476  while (pClusterP)
477  {
478  cluster.id = currRecord + 1;
479  cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
480  cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
481  cluster.n_strip = pClusterP->getClusterSize();
482  cluster.adc_count = pClusterP->getTotAdc();
483  cluster.first_adc_count = pClusterP->getFirstAdc();
484  cluster.last_adc_count = pClusterP->getLastAdc();
485  cluster.noise_count = (int)pClusterP->getTotNoise();
486  cluster.flag = pClusterP->getFlag();
487  cluster.strip_mean = pClusterP->getStripMean();
488  for (i = 0 ; i < 5 ; i++)
489  cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
490  scf_cluster->AddAt(&cluster);
491  currRecord++;
492  pClusterP = clusterP->next(pClusterP);
493  }
494 
495  StSstCluster *pClusterN = clusterN->first();
496  while (pClusterN)
497  {
498  cluster.id = currRecord + 1;
499  cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
500  cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
501  cluster.n_strip = pClusterN->getClusterSize();
502  cluster.adc_count = pClusterN->getTotAdc();
503  cluster.first_adc_count = pClusterN->getFirstAdc();
504  cluster.last_adc_count = pClusterN->getLastAdc();
505  cluster.noise_count = (int)pClusterN->getTotNoise();
506  cluster.flag = pClusterN->getFlag();
507  cluster.strip_mean = pClusterN->getStripMean();
508  for (i = 0 ; i < 5 ; i++)
509  cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
510  scf_cluster->AddAt(&cluster);
511  currRecord++;
512  pClusterN = clusterN->next(pClusterN);
513  }
514  }
515  return currRecord;
516 }
517 //________________________________________________________________________________
518 Int_t StSstBarrel::writeClusterToTable(St_scf_cluster *scf_cluster,St_spa_strip *spa_strip){
519  scf_cluster_st cluster;
520  spa_strip_st *on_strip = spa_strip->GetTable();
521  Int_t currRecord = 0;
522  Int_t i = 0;
523  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
524  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
525  {
526  Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
527  StSstClusterList *clusterP = mLadders[iLad]->mWafers[iWaf]->getClusterP();
528  StSstClusterList *clusterN = mLadders[iLad]->mWafers[iWaf]->getClusterN();
529 
530  StSstCluster *pClusterP = clusterP->first();
531  while (pClusterP)
532  {
533  cluster.id = currRecord + 1;
534  cluster.id_cluster = 10000*(10*pClusterP->getNCluster() + 0)+idCurrentWaf;
535  cluster.first_strip = 10000*(10*pClusterP->getFirstStrip()+ 0)+idCurrentWaf;
536  cluster.n_strip = pClusterP->getClusterSize();
537  cluster.adc_count = pClusterP->getTotAdc();
538  cluster.first_adc_count = pClusterP->getFirstAdc();
539  cluster.last_adc_count = pClusterP->getLastAdc();
540  cluster.noise_count = (Int_t) pClusterP->getTotNoise();
541  cluster.flag = pClusterP->getFlag();
542  cluster.strip_mean = pClusterP->getStripMean();
543  for (i = 0 ; i < 5 ; i++)
544  {
545  cluster.id_mchit[i] = pClusterP->getIdMcHit(i);
546  if(cluster.id_mchit[i] == 0){
547  cluster.id_mctrack[i]=0;
548  }
549  else{
550  for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
551  if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
552  cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
553  }
554  }
555  }
556  }
557  scf_cluster->AddAt(&cluster);
558  currRecord++;
559  pClusterP = clusterP->next(pClusterP);
560  }
561 
562  StSstCluster *pClusterN = clusterN->first();
563  while (pClusterN)
564  {
565  cluster.id = currRecord + 1;
566  cluster.id_cluster = 10000*(10*pClusterN->getNCluster() + 1)+idCurrentWaf;
567  cluster.first_strip = 10000*(10*pClusterN->getFirstStrip() + 1)+idCurrentWaf;
568  cluster.n_strip = pClusterN->getClusterSize();
569  cluster.adc_count = pClusterN->getTotAdc();
570  cluster.first_adc_count = pClusterN->getFirstAdc();
571  cluster.last_adc_count = pClusterN->getLastAdc();
572  cluster.noise_count = (Int_t) pClusterN->getTotNoise();
573  cluster.flag = pClusterN->getFlag();
574  cluster.strip_mean = pClusterN->getStripMean();
575  for (i = 0 ; i < 5 ; i++)
576  {
577  cluster.id_mchit[i] = pClusterN->getIdMcHit(i);
578  if(cluster.id_mchit[i] == 0)cluster.id_mctrack[i]=0;
579  else{
580  for(Int_t j = 0 ; j < spa_strip->GetNRows(); j++){
581  if(cluster.id_mchit[i] == on_strip[j].id_mchit[i]){
582  cluster.id_mctrack[i] = on_strip[j].id_mctrack[i];
583  }
584  }
585  }
586  }
587  scf_cluster->AddAt(&cluster);
588  currRecord++;
589  pClusterN = clusterN->next(pClusterN);
590  }
591  }
592  return currRecord;
593 }
594 /***********************************************************/
595 Int_t StSstBarrel::writePointToContainer(St_scm_spt *scm_spt, StSstHitCollection* ssdHitColl,St_scf_cluster *scf_cluster,StSstDynamicControl *mDynamicControl){
596  Float_t convMeVToAdc = (int)pow(2.0,mDynamicControl->getnbitEncoding())/(mDynamicControl->getpairCreationEnergy()*mDynamicControl->getadcDynamic()*mDynamicControl->getnElectronInAMip());
597  scm_spt_st spt;
598  StSstHit *currentSstHit;
599  scf_cluster_st *on_cluster = scf_cluster->GetTable();
600  // table size is 148 bytes
601  Int_t i = 0, inContainer = 0, inTable = 0 ;
602  StThreeVectorF gPos; StThreeVectorF gPosError;
603  Int_t hw; Float_t q ; unsigned char c;
604  c =0;
605  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
606  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
607  {
608  Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);
609  StSstPointList *sptList = mLadders[iLad]->mWafers[iWaf]->getPoint();
610  StSstPoint *pSpt = sptList->first();
611 
612  while (pSpt){
613  for (i = 0 ; i < 5 ; i++)
614  {
615  spt.id_mchit[i] = pSpt->getNMchit(i);
616  spt.id_mctrack[i] = 0;
617  spt.id_track[i] = 0;
618  //we look on the clusters table to get the IdMctrack info
619  if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
620  else {
621  for(Int_t j = 0 ; j < scf_cluster->GetNRows(); j++){
622  if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
623  spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
624  }
625  }
626  }
627  }
628 
629  //now we fill StEvent and get the correct IdTruth
630  if (ssdHitColl){ // If Available, Fill the StEvent Container
631  for (i = 0 ; i < 3 ; i++){
632  gPos[i] = pSpt->getXg(i);
633  gPosError[i] = 0.0;
634  }
635  hw = idCurrentWaf;
636  q = pSpt->getDe(0);
637  currentSstHit = new StSstHit(gPos,gPosError,hw,q,c);
638  currentSstHit->setIdTruth(spt.id_mctrack[0],100);// need to check first = most probable!
639 
640  //looking for the correct clusters...
641  Int_t Id_P_Side = pSpt->getIdClusterP();
642  Int_t Id_N_Side = pSpt->getIdClusterN();
643 
644  StSstClusterList *currentListP_j = mLadders[iLad]->mWafers[iWaf]->getClusterP();
645  StSstCluster *cluster_P_j = currentListP_j->first();
646  do{
647  if(cluster_P_j->getNCluster()==Id_P_Side)
648  break;
649  cluster_P_j = currentListP_j->next(cluster_P_j);
650  }
651  while(cluster_P_j!=currentListP_j->last());
652 
653  StSstClusterList *currentListN_j = mLadders[iLad]->mWafers[iWaf]->getClusterN();
654  StSstCluster *cluster_N_j = currentListN_j->first();
655  do{
656  if(cluster_N_j->getNCluster()==Id_N_Side)
657  break;
658  cluster_N_j = currentListN_j->next(cluster_N_j);
659  }
660  while(cluster_N_j!=currentListN_j->last());
661 
662  // encode the hardware position
663  // 2^3 detector ID number (8)
664  // 2^4 4-12 num_wafer (0-319)
665  // 2^13 13-22 cebtral strip of the n-side cluster
666  // 2^23 23-27 strip of the p-side cluster relat. to n-side (-15,+16)
667  // 2^28 28-29 n-side cluster size(1-4)
668  // 2^30 30-31 p-side cluster size(1-4)
669  hw =
670  8
671  + 16 * idWaferToWaferNumb(idCurrentWaf)
672  + 8192 * (int)cluster_N_j->getStripMean()
673  + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
674  + 268435456 * (int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
675  + 1073741824 * (int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
676  currentSstHit->setHardwarePosition(hw);
677  currentSstHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1),pSpt->getXl(2));
678  currentSstHit->setADC((int)convMeVToAdc*(pSpt->getDe(0)+pSpt->getDe(1)),(int)convMeVToAdc*(pSpt->getDe(0)-pSpt->getDe(1)));
679  inContainer += ssdHitColl->addHit(currentSstHit);
680  }// Container condition
681 
682  if (1) {//Jerome is Happy, Fill the Table
683  spt.flag = pSpt->getFlag();
684  spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
685  spt.id_cluster = pSpt->getNCluster();
686  spt.id_globtrk = 0;
687  spt.id_match = pSpt->getNMatched();
688  for (i = 0 ; i < 5 ; i++)
689  {
690  spt.id_mchit[i] = pSpt->getNMchit(i);
691  spt.id_mctrack[i] = 0;
692  spt.id_track[i] = 0;
693  }
694  spt.id_wafer = idCurrentWaf;
695  for (i = 0 ; i < 3 ; i++)
696  {
697  spt.cov[i] = 0;
698  spt.res[i] = 0;
699  spt.x[i] = pSpt->getXg(i);
700  spt.xl[i] = pSpt->getXl(i);
701  }
702  for (i = 0 ; i < 2 ; i++)
703  {
704  spt.mom2[i] = 0;
705  spt.de[i] = pSpt->getDe(i);
706  }
707  scm_spt->AddAt(&spt);
708  }
709  inTable++;
710  pSpt = sptList->next(pSpt);
711  }// End of Point Loop
712  }
713  return inTable;
714 }
715 
716 /***********************************************************/
717 Int_t StSstBarrel::writePointToContainer(St_scm_spt *scm_spt, StSstHitCollection* sstHitColl,St_scf_cluster *scf_cluster,StSstDynamicControl *mDynamicControl,StMcEvent *mcEvent){
718  vector<const StMcSsdHit*> hitCol;
719  StMcSsdHitCollection *myCol;
720  int totRatio, idTruth;
721  Float_t convMeVToAdc = (int)pow(2.0,mDynamicControl->getnbitEncoding())/(mDynamicControl->getpairCreationEnergy()*mDynamicControl->getadcDynamic()*mDynamicControl->getnElectronInAMip());
722  if(mcEvent)
723  {
724  LOG_DEBUG << "McEvent exists" << endm;
725  myCol = mcEvent->ssdHitCollection();
726  if ((myCol))
727  {
728  for (unsigned int iLadder=0; iLadder<myCol->numberOfLadders(); iLadder++) {
729  for (unsigned int iWafer = 0; iWafer < myCol->ladder(iLadder)->numberOfWafers(); iWafer++) {
730  for (StMcSsdHitIterator iter = myCol->ladder(iLadder)->wafer(iWafer)->hits().begin();
731  iter != myCol->ladder(iLadder)->wafer(iWafer)->hits().end();
732  iter++) {
733  const StMcSsdHit *hit = dynamic_cast<const StMcSsdHit *> (*iter);
734  assert(hit);
735  hitCol.push_back(hit);
736  }
737  }
738  }
739  }
740  }
741  else{LOG_INFO<< "No sstMcHitCollection" <<endm;
742  }
743  scm_spt_st spt;
744  StSstHit *currentSstHit;
745  scf_cluster_st *on_cluster = scf_cluster->GetTable();
746  // table size is 148 bytes
747  Int_t i = 0, inContainer = 0, inTable = 0;
748  StThreeVectorF gPos; StThreeVectorF gPosError;
749  Int_t hw; Float_t q ; unsigned char c;
750  c =0;
751  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
752  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
753  {
754  Int_t idCurrentWaf = mSstLayer*1000 + (iWaf+1)*100 + (iLad+1);//decode the wafer id
755  StSstPointList *sptList = mLadders[iLad]->mWafers[iWaf]->getPoint();//loop over StSstPoint list
756  StSstPoint *pSpt = sptList->first();
757  totRatio = 0;
758  while (pSpt){
759  if(mcEvent){
760 
761  //we look only idMcTrack for simulation
762  //jb : we fill StEvent after getting the IdMctrack
763  //jb : as it was done too for the strip and clusters --> see StSpaBarrel.cc and StScfBarrel.cc
764  //printf("Now we find the idMcTrack from the cluster\n");
765  int idClusP = 0;
766  int idClusN = 0;
767  for (i = 0 ; i < 5 ; i++)
768  {
769  spt.id_mchit[i] = pSpt->getNMchit(i);
770  spt.id_mctrack[i] = 0;
771  spt.id_track[i] = 0;
772  //we look on the clusters table to get the IdMctrack info
773  if (spt.id_mchit[i] == 0) spt.id_mctrack[i]=0;
774  else {
775  int j =0;
776  for(j = 0 ; j < scf_cluster->GetNRows(); j++){
777  if(spt.id_mchit[i] == on_cluster[j].id_mchit[i]){
778  spt.id_mctrack[i] = on_cluster[j].id_mctrack[i];
779  idClusP = 10000*(10*pSpt->getIdClusterP() + 0)+idCurrentWaf;
780  idClusN = 10000*(10*pSpt->getIdClusterN() + 1)+idCurrentWaf;
781  break;
782  }
783  }
784  Calculation_Ratio(idCurrentWaf,idClusP,idClusN,hitCol,&totRatio,&idTruth);
785  }
786  }
787  }
788  //now we fill StEvent and get the correct IdTruth
789  if (sstHitColl){ // If Available, Fill the StEvent Container
790  for (i = 0 ; i < 3 ; i++){
791  gPos[i] = pSpt->getXg(i);
792  gPosError[i] = 0.0;
793  }
794  hw = idCurrentWaf;
795  q = pSpt->getDe(0);
796  currentSstHit = new StSstHit(gPos,gPosError,hw,q,c);
797  //qATruth is set with the ratio chargeCLUSTER/chargeGEANT
798  currentSstHit->setIdTruth(idTruth,(int)totRatio);
799  // Start of Point Loop
800 
801  //looking for the correct clusters...
802  Int_t Id_P_Side = pSpt->getIdClusterP();
803  Int_t Id_N_Side = pSpt->getIdClusterN();
804 
805  StSstClusterList *currentListP_j = mLadders[iLad]->mWafers[iWaf]->getClusterP();
806  StSstCluster *cluster_P_j = currentListP_j->first();
807 
808  do{
809  if(cluster_P_j->getNCluster()==Id_P_Side)
810  break;
811  cluster_P_j = currentListP_j->next(cluster_P_j);
812  }
813  while(cluster_P_j!=currentListP_j->last());
814 
815  StSstClusterList *currentListN_j = mLadders[iLad]->mWafers[iWaf]->getClusterN();
816  StSstCluster *cluster_N_j = currentListN_j->first();
817  do{
818  if(cluster_N_j->getNCluster()==Id_N_Side)
819  break;
820  cluster_N_j = currentListN_j->next(cluster_N_j);
821  }
822  while(cluster_N_j!=currentListN_j->last());
823 
824  // encode the hardware position
825  // 2^3 detector ID number (8)
826  // 2^4 4-12 num_wafer (0-319)
827  // 2^13 13-22 cebtral strip of the n-side cluster
828  // 2^23 23-27 strip of the p-side cluster relat. to n-side (-15,+16)
829  // 2^28 28-29 n-side cluster size(1-4)
830  // 2^30 30-31 p-side cluster size(1-4)
831  hw =
832  8
833  + 16 * idWaferToWaferNumb(idCurrentWaf)
834  + 8192 * (int)cluster_N_j->getStripMean()
835  + 8388608 * ((int)cluster_P_j->getStripMean() - (int)cluster_N_j->getStripMean() +15)
836  + 268435456 * (int)((cluster_N_j->getClusterSize() > 3) ? 3 : cluster_N_j->getClusterSize()-1)
837  + 1073741824 * (int)((cluster_P_j->getClusterSize() > 3) ? 3 : cluster_P_j->getClusterSize()-1);
838  currentSstHit->setHardwarePosition(hw);
839  //local position in 3D
840  currentSstHit->setLocalPosition(pSpt->getXl(0),pSpt->getXl(1),pSpt->getXl(2));
841  //save TotAdc of each cluster
842  currentSstHit->setADC((int)convMeVToAdc*(pSpt->getDe(0)+pSpt->getDe(1)),(int)convMeVToAdc*(pSpt->getDe(0)-pSpt->getDe(1)));
843  inContainer += sstHitColl->addHit(currentSstHit);
844  }// Container condition
845 
846  if (1) {//Jerome is Happy, Fill the Table
847  spt.flag = pSpt->getFlag();
848  spt.id = 10000*(pSpt->getNPoint())+idCurrentWaf;
849  spt.id_cluster = pSpt->getNCluster();
850  spt.id_globtrk = 0;
851  spt.id_match = pSpt->getNMatched();
852  for (i = 0 ; i < 5 ; i++)
853  {
854  spt.id_mchit[i] = pSpt->getNMchit(i);
855  spt.id_mctrack[i] = 0;
856  spt.id_track[i] = 0;
857  }
858  spt.id_wafer = idCurrentWaf;
859  for (i = 0 ; i < 3 ; i++)
860  {
861  spt.cov[i] = 0;
862  spt.res[i] = 0;
863  spt.x[i] = pSpt->getXg(i);
864  spt.xl[i] = pSpt->getXl(i);
865  }
866  for (i = 0 ; i < 2 ; i++)
867  {
868  spt.mom2[i] = 0;
869  spt.de[i] = pSpt->getDe(i);
870  }
871  scm_spt->AddAt(&spt);
872  }
873  inTable++;
874  pSpt = sptList->next(pSpt);
875  }// End of Point Loop
876  }
877  if (hitCol.size()>0 )hitCol.clear();
878  return inTable;
879 }
880 //________________________________________________________________________________
881 void StSstBarrel::Calculation_Ratio(int idWafer,int idClusterP,int idClusterN,vector<const StMcSsdHit*> hitCol, int *ratio, int *idTruth)
882 {
883  Float_t charge[2] = {0,0};
884  int DominatorP = 0;
885  int DominatorN = 0;
886  Float_t adc_DominatorP = 0;
887  Float_t adc_DominatorN = 0;
888  vector<StSstStrip*> ListstripP;
889  vector<StSstStrip*> ListstripN;
890  vector<int> GTrackP(5,0),GTrackN(5,0);
891  int isSplittedP=0,isSplittedN =0;
892  Int_t lad = idWaferToLadderNumb(idWafer);
893  Int_t waf = (int)((idWafer - mSstLayer*1000)/100)-1;
894  // now p-side
895  StSstCluster *pClusterP = mLadders[lad]->mWafers[waf]->getClusterP()->first();
896  while (pClusterP){
897  int idP = 10000*(10*pClusterP->getNCluster() + 0)+idWafer;
898  if(idP==idClusterP){
899  charge[0] = pClusterP->getTotAdc();
900  if(pClusterP->getFlag()==1){
901  //splitted cluster
902  isSplittedP = isSplit(pClusterP,0,lad,waf);
903  }
904  for(Int_t e =0 ;e<5;e++)GTrackP.push_back(pClusterP->getIdMcHit(e));
905  //now we loop over the strips of that cluster
906  StSstStripList *stripP = StSstBarrel::Instance()->mLadders[lad]->mWafers[waf]->getStripP();
907  int lastScan =0;//lastScan : a same strips can be used by 2 adjacents clusters : it must be count twice
908  for(int kk=pClusterP->getFirstStrip();kk<pClusterP->getFirstStrip()+pClusterP->getClusterSize();kk++)
909  {
910  StSstStrip *pStripP = stripP->first();
911  while (pStripP)
912  {
913  if((pStripP->getNStrip()==kk)&&(pStripP->getNStrip()!=lastScan))
914  {
915  lastScan = pStripP->getNStrip();
916  ListstripP.push_back(pStripP);
917  }
918  pStripP = stripP->next(pStripP);
919  }
920  }
921  break;
922  }
923  pClusterP = mLadders[lad]->mWafers[waf]->getClusterP()->next(pClusterP);
924  }
925  // now n-side
926  StSstCluster *pClusterN = mLadders[lad]->mWafers[waf]->getClusterN()->first();
927  while (pClusterN){
928  int idN = 10000*(10*pClusterN->getNCluster() + 1)+idWafer;
929  if(idN==idClusterN){
930  charge[1] = pClusterN->getTotAdc();
931  if(pClusterN->getFlag()==1){
932  //splitted cluster
933  isSplittedN = isSplit(pClusterN,1,lad,waf);
934  }
935  for(Int_t e =0 ;e<5;e++)GTrackN.push_back(pClusterN->getIdMcHit(e));
936  //now we loop over the strips of that cluster
937  StSstStripList *stripN = mLadders[lad]->mWafers[waf]->getStripN();
938  int lastScan =0;//lastScan : a same strip can be used by 2 adjacents clusters : it must be count twice
939  for(int kk=pClusterN->getFirstStrip();kk<pClusterN->getFirstStrip()+pClusterN->getClusterSize();kk++)
940  {
941  StSstStrip *pStripN = stripN->first();
942  while (pStripN)
943  {
944  if((pStripN->getNStrip()==kk)&&(pStripN->getNStrip()!=lastScan))
945  {
946  lastScan = pStripN->getNStrip();
947  ListstripN.push_back(pStripN);
948  }
949  pStripN = stripN->next(pStripN);
950  }
951  }
952  break;
953  }
954  pClusterN = mLadders[lad]->mWafers[waf]->getClusterN()->next(pClusterN);
955  }
956 
957  // find dominator from cluster
958  DominatorP = FindMcHit(GTrackP,hitCol);
959  DominatorN = FindMcHit(GTrackN,hitCol);
960  if(DominatorP!=DominatorN) {
961  *ratio = 0;
962  *idTruth = 0;
963  return;
964  }
965  if((ListstripN.size()>0)&&(ListstripP.size()>0))
966  {
967  unsigned int min ,max;
968  // side P
969  min=0;
970  max=0;
971  if(isSplittedP==1){
972  min = 0;
973  max = ListstripP.size()-1;}
974  else
975  if(isSplittedP==2){
976  min = 1;
977  max = ListstripP.size();}
978  else{
979  min = 0;
980  max = ListstripP.size();}
981  for(unsigned int ee = min;ee<max;ee++){
982  StSstStrip* tempoStripP = ListstripP[ee];
983  if(DominatorP == tempoStripP->getIdMcTrack(0))
984  {
985  adc_DominatorP += tempoStripP->getDigitSig();
986  }
987  else {
988  }
989  }
990 
991  //side N
992  min =0;
993  max =0;
994  if(isSplittedN==1){
995  min = 0;
996  max = ListstripN.size()-1;
997  }
998  else
999  if(isSplittedN==2){
1000  min = 1;
1001  max = ListstripN.size();
1002  }
1003  else{
1004  min = 0;
1005  max = ListstripN.size();
1006  }
1007  for(unsigned int ee = min;ee<max;ee++){
1008  StSstStrip *tempoStripN = ListstripN[ee];
1009  if(DominatorN == tempoStripN->getIdMcTrack(0))
1010  {
1011  adc_DominatorN += tempoStripN->getDigitSig();
1012  }
1013  else {
1014  }
1015  }
1016  }
1017  //find the Dominant contributor
1018  float ratioP = 0 ;
1019  float ratioN = 0 ;
1020  if(charge[0]!=0) ratioP = adc_DominatorP/charge[0];
1021  if(charge[1]!=0) ratioN = adc_DominatorN/charge[1];
1022  if(DominatorP == DominatorN){
1023  *ratio = (int)(100*(ratioP*ratioN));
1024  *idTruth = DominatorP;
1025  }
1026  else{
1027  *ratio = 0;
1028  *idTruth = 0;
1029  }
1030  if(ListstripP.size()>0) ListstripP.clear();
1031  if(ListstripN.size()>0) ListstripN.clear();
1032  if(GTrackP.size()>0) GTrackP.clear();
1033  if(GTrackN.size()>0) GTrackN.clear();
1034 }
1035 //__________________________________________________________________
1036 Int_t StSstBarrel::FindMcHit(const vector<int> &tempo,const vector<const StMcSsdHit*> &hitCol)
1037 {
1038  float ChargeTrack = 0.0;
1039  int idTrack =0;
1040  for(int e=0;e<5;e++){
1041  for (unsigned int hit = 0 ; hit<hitCol.size();hit++){
1042  const StMcSsdHit* currHit = hitCol[hit];
1043  if((tempo[e]>0)&&(currHit->key() == tempo[e])&&(currHit->dE()>ChargeTrack)){
1044  ChargeTrack = currHit->dE();
1045  idTrack = currHit->parentTrack()->key();
1046  }
1047  }
1048  }
1049  return idTrack;
1050 }
1051 //________________________________________________________________________________________
1052 Int_t StSstBarrel::isSplit(StSstCluster *currentCluster,int iSide,int lad,int waf){
1053  StSstCluster *firstClus;
1054  StSstCluster *lastClus;
1055  StSstCluster *nextClus;
1056  StSstCluster *prevClus;
1057  int isSplitted =0 ;
1058  if(iSide ==0){
1059  firstClus = mLadders[lad]->mWafers[waf]->getClusterP()->first();
1060  lastClus = mLadders[lad]->mWafers[waf]->getClusterP()->last();
1061  }
1062  else {
1063  firstClus = mLadders[lad]->mWafers[waf]->getClusterN()->first();
1064  lastClus = mLadders[lad]->mWafers[waf]->getClusterN()->last();
1065  }
1066  if(currentCluster->getNCluster() == firstClus->getNCluster()){
1067  isSplitted=1;
1068  }
1069  else if(currentCluster->getNCluster() == lastClus->getNCluster()){
1070  isSplitted=2;
1071  }
1072  else {
1073  nextClus = currentCluster->getNextCluster();
1074  if(nextClus->getFirstStrip() == ((currentCluster->getFirstStrip()+currentCluster->getClusterSize()-1))) {
1075  isSplitted =1;
1076  prevClus = currentCluster->getPrevCluster();
1077  if(currentCluster->getFirstStrip() == ((prevClus->getFirstStrip()+prevClus->getClusterSize()-1))) {
1078  isSplitted=2;
1079  }
1080  }
1081  }
1082  return isSplitted;
1083 }
1084 //___________________________________________________________________
1085 void StSstBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster){
1086  Int_t wafNumbOfCluster[2];
1087  wafNumbOfCluster[0] = 0;
1088  wafNumbOfCluster[1] = 0;
1089 
1090  for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1091  for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1092  {
1093  mLadders[iLad]->mWafers[iWaf]->doClusterisation(wafNumbOfCluster, mClusterControl);
1094  barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1095  barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1096  }
1097 }
1098 //________________________________________________________________________________
1099 void StSstBarrel::doSideClusterisation(Int_t *barrelNumbOfCluster,Int_t WafStatus[20][16]){
1100  Int_t wafNumbOfCluster[2];
1101  wafNumbOfCluster[0] = 0;
1102  wafNumbOfCluster[1] = 0;
1103  for (Int_t iLad = 0 ; iLad < mNLadder; iLad++)
1104  for (Int_t iWaf = 0 ; iWaf < mNWaferPerLadder; iWaf++)
1105  {
1106  if(WafStatus[iLad][iWaf]!=0){
1107  mLadders[iLad]->mWafers[iWaf]->doClusterisation(wafNumbOfCluster, mClusterControl);
1108  barrelNumbOfCluster[0] += wafNumbOfCluster[0];
1109  barrelNumbOfCluster[1] += wafNumbOfCluster[1];
1110  }
1111  }
1112 }
1113 //_______________________________________________________________________________________
1114 Int_t StSstBarrel::doClusterMatching(Float_t *CalibArray){
1115  Int_t NumberOfPackage = 0;
1116  Int_t nSolved = 0;
1117  Int_t nPerfect = 0;
1118 
1119  for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1120  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1121  {
1122  //mLadders[iLad]->mWafers[iWaf]->doLorentzShift(mDimensions,mShift_hole,mShift_elec);
1123  NumberOfPackage += mLadders[iLad]->mWafers[iWaf]->doFindPackage(mDimensions, mClusterControl);
1124  nPerfect = mLadders[iLad]->mWafers[iWaf]->doSolvePerfect(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1125  if (!nPerfect) continue;
1126  mLadders[iLad]->mWafers[iWaf]->doStatPerfect(nPerfect, mClusterControl);
1127  nSolved += mLadders[iLad]->mWafers[iWaf]->doSolvePackage(mDimensions, mClusterControl,CalibArray[(iLad*mNWaferPerLadder)+iWaf]);
1128  }
1129  }
1130  LOG_INFO<<"**** Remark: "<<nSolved<<" solved packages ****" << endm;
1131  return NumberOfPackage;
1132 }
1133 //________________________________________________________________________________
1134 void StSstBarrel::convertDigitToAnalog(StSstDynamicControl *dynamicControl){
1135  long nElectronInAMip = dynamicControl->getnElectronInAMip();
1136  long adcDynamic = dynamicControl->getadcDynamic();
1137  Double_t pairCreationEnergy = dynamicControl->getpairCreationEnergy();
1138 
1139  const Int_t NAdcChannel = (int)pow(2.0,dynamicControl->getnbitEncoding());
1140  const Double_t convFactor = (pairCreationEnergy*adcDynamic*nElectronInAMip)/NAdcChannel;
1141  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1142  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1143  mLadders[iLad]->mWafers[iWaf]->convertDigitToAnalog(convFactor);
1144 }
1145 //________________________________________________________________________________
1146 void StSstBarrel::convertUFrameToOther(){
1147  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1148  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1149  {
1150  mLadders[iLad]->mWafers[iWaf]->convertUFrameToLocal(mDimensions);
1151  mLadders[iLad]->mWafers[iWaf]->convertLocalToGlobal();
1152  }
1153 }
1154 //________________________________________________________________________________
1155 void StSstBarrel::convertGlobalFrameToOther(){
1156  for (Int_t iLad = 0; iLad < mNLadder; iLad++){
1157  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1158  {
1159  mLadders[iLad]->mWafers[iWaf]->convertGlobalToLocal();
1160  mLadders[iLad]->mWafers[iWaf]->convertLocalToUFrame(mDetectorLargeEdge, mDetectorSmallEdge, mTheta);
1161  }
1162  }
1163 }
1164 //________________________________________________________________________________
1165 void StSstBarrel::sortListStrip(){
1166  StSstStripList *currentList = 0;
1167  Int_t isSorted = 0;
1168  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1169  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1170  {
1171  currentList = mLadders[iLad]->mWafers[iWaf]->getStripP();
1172  isSorted = currentList->isSorted();
1173  if (!isSorted) currentList->sortStrip();
1174 
1175  currentList = mLadders[iLad]->mWafers[iWaf]->getStripN();
1176  isSorted = currentList->isSorted();
1177  if (!isSorted) currentList->sortStrip();
1178  }
1179  return;
1180 }
1181 //________________________________________________________________________________
1182 void StSstBarrel::sortListCluster(){
1183  StSstClusterList *currentList = 0;
1184  Int_t isSorted = 0;
1185  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1186  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)
1187  {
1188  currentList = mLadders[iLad]->mWafers[iWaf]->getClusterP();
1189  isSorted = currentList->isSorted();
1190  if (!isSorted) currentList->sortCluster();
1191 
1192  currentList = mLadders[iLad]->mWafers[iWaf]->getClusterN();
1193  isSorted = currentList->isSorted();
1194  if (!isSorted) currentList->sortCluster();
1195  }
1196 }
1197 
1198 StSstBarrel::StSstBarrel(const StSstBarrel & originalBarrel)
1199 {
1200  mSstLayer = originalBarrel.mSstLayer;
1201  mNLadder = originalBarrel.mNLadder;
1202  mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1203  mNStripPerSide = originalBarrel.mNStripPerSide;
1204 
1205  mLadders = new StSstLadder*[mNLadder];
1206  for (Int_t iLad=0; iLad < mNLadder; iLad++)
1207  mLadders[iLad] = new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
1208 }
1209 
1210 StSstBarrel& StSstBarrel::operator=(const StSstBarrel & originalBarrel)
1211 {
1212  mSstLayer = originalBarrel.mSstLayer;
1213  mNLadder = originalBarrel.mNLadder;
1214  mNWaferPerLadder = originalBarrel.mNWaferPerLadder;
1215  mNStripPerSide = originalBarrel.mNStripPerSide;
1216 
1217  mLadders = new StSstLadder*[mNLadder];
1218  for (Int_t iLad=0; iLad < mNLadder; iLad++)
1219  mLadders[iLad] = new StSstLadder(iLad,mSstLayer,mNWaferPerLadder,mNStripPerSide);
1220  return *this;
1221 }
1222 
1223 Int_t StSstBarrel::idWaferToWaferNumb(Int_t idWafer)
1224 {
1225  Int_t iW = (int)((idWafer - mSstLayer*1000)/100);
1226  Int_t iL = idWafer - mSstLayer*1000 - iW*100;
1227  return ((iL-1)*mNWaferPerLadder + iW -1);
1228 }
1229 
1230 Int_t StSstBarrel::idWaferToLadderNumb(Int_t idWafer)
1231 {
1232  Int_t iW = (int)((idWafer - mSstLayer*1000)/100);
1233  Int_t iL = idWafer - mSstLayer*1000 - iW*100;
1234  return iL-1;
1235 }
1236 
1237 Int_t StSstBarrel::waferNumbToIdWafer(Int_t waferNumb)
1238 {
1239  Int_t iL = 1+(int)((waferNumb)/mNWaferPerLadder);
1240  Int_t iW = waferNumb-((iL-1)*mNWaferPerLadder)+1;
1241  return mSstLayer*1000 + iW*100 + iL;
1242 }
1243 
1244 Int_t StSstBarrel::isActiveLadder(Int_t iLadder)
1245 {
1246  return mActiveLadders[iLadder];
1247 }
1248 void StSstBarrel::renumHitAfterRemove() {
1249  Int_t iLast = 0;
1250  Int_t iNewLast = 0;
1251  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1252  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1253  iNewLast = mLadders[iLad]->mWafers[iWaf]->getPoint()->renumHits(iLast);
1254  iLast = iNewLast;
1255  }
1256 }
1257 //________________________________________________________________________________
1258 StSstPointList *StSstBarrel::getInactiveHitList() {
1259  StSstPointList *inactiveHits = new StSstPointList();
1260  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1261  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1262  //fill the list of hits in inactive wafer areas
1263  StSstPointList *currDeadList = mLadders[iLad]->mWafers[iWaf]->getDeadHits(mDetectorLargeEdge, mDetectorSmallEdge, mStripPitch);
1264  if(currDeadList->getSize()>0){
1265  }
1266  inactiveHits = inactiveHits->addPointList(currDeadList);
1267  delete currDeadList;
1268  }
1269  inactiveHits->sortPoint();
1270  return inactiveHits;
1271 }
1272 //________________________________________________________________________________
1273 void StSstBarrel::convertToStrip(Double_t pairCreationEnergy,
1274  Int_t nstripInACluster,
1275  Double_t parDiffP,
1276  Double_t parDiffN,
1277  Double_t parIndRightP,
1278  Double_t parIndRightN,
1279  Double_t parIndLeftP,
1280  Double_t parIndLeftN) {
1281 
1282  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1283  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1284  mLadders[iLad]->mWafers[iWaf]->convertToStrip(mStripPitch,
1285  mNStripPerSide,
1286  pairCreationEnergy,
1287  nstripInACluster,
1288  parDiffP,
1289  parDiffN,
1290  parIndRightP,
1291  parIndRightN,
1292  parIndLeftP,
1293  parIndLeftN,
1294  mShift_hole,
1295  mShift_elec);
1296  }
1297 }
1298 //________________________________________________________________________________
1299 void StSstBarrel::addNoiseToStrip(slsCtrl_st *ctrl)
1300 {
1301  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1302  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++) {
1303  StSstWafer *wafer = mLadders[iLad]->mWafers[iWaf];
1304  wafer->sortNoise();
1305  wafer->sortStrip();
1306  wafer->addNoiseToStripSignal(ctrl[0].nElectronInAMip,ctrl[0].adcDynamic);
1307  }
1308 }
1309 //________________________________________________________________________________
1310 Int_t StSstBarrel::readStripFromTable(St_sls_strip *sls_strip)
1311 {
1312  sls_strip_st *strip = sls_strip->GetTable();
1313 
1314  Int_t idWaf = 0, iWaf = 0, iLad = 0;
1315  Int_t nStrip = 0;
1316  Int_t iSide = 0;
1317  Int_t i = 0;
1318  Int_t idMcHit[5] = {0,0,0,0,0};
1319  Int_t e = 0;
1320  Int_t my_counterP =0;
1321  Int_t my_counterN =0;
1322  for (i = 0 ; i < sls_strip->GetNRows(); i++)
1323  {
1324  nStrip = (int)(strip[i].id_strip/100000.);
1325  idWaf = strip[i].id_strip-10000*((int)(strip[i].id_strip/10000.));
1326  iWaf = (int)((idWaf - mSstLayer*1000)/100)-1;
1327  iLad = idWaf - mSstLayer*1000 - (iWaf+1)*100-1;
1328  iSide = (strip[i].id_strip - nStrip*100000 - idWaf)/10000;
1329  if(iSide==0) my_counterP++;
1330  if(iSide==1) my_counterN++;
1331  for (e = 0 ; e < 5;e++) idMcHit[e] = strip[i].id_mchit[e];
1332  StSstStrip *newStrip = new StSstStrip(nStrip, i, strip[i].adc_count, strip[i].de, idMcHit);
1333  mLadders[iLad]->mWafers[iWaf]->addStrip(newStrip, iSide);
1334  }
1335  return sls_strip->GetNRows();
1336 }
1337 //________________________________________________________________________________
1338 Int_t StSstBarrel::readNoiseFromTable(St_ssdStripCalib *strip_calib)
1339 {
1340  ssdStripCalib_st *noise = strip_calib->GetTable();
1341  Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1342  Int_t nElectronInAMip = 22500;
1343  Int_t adcDynamic = 20;
1344  const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(float)(NAdcChannel);
1345  LOG_DEBUG << "AdctoE = " << AdctoE << endm;
1346 
1347  Int_t idWaf = 0, iWaf = 0, iLad = 0;
1348  Int_t nStrip = 0;
1349  Int_t iSide = 0;
1350  Int_t i = 0;
1351  Int_t ent = 0 ;
1352  for (i = 0 ; i < strip_calib->GetNRows(); i++)
1353  {
1354  if (noise[i].id>0 && noise[i].id<=76818620) {
1355  nStrip = (int)(noise[i].id/100000.);
1356  idWaf = noise[i].id-10000*((int)(noise[i].id/10000.));
1357  iWaf = (int)((idWaf - mSstLayer*1000)/100)-1;
1358  iLad = idWaf - mSstLayer*1000 - (iWaf+1)*100-1;
1359  iSide = (noise[i].id - nStrip*100000 - idWaf)/10000;
1360  StSpaNoise *newStrip = new StSpaNoise(nStrip ,(int)(noise[i].pedestals*AdctoE),(int)((noise[i].rms*AdctoE)/16.));
1361  mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1362  ent++;
1363  }
1364  }
1365  return ent;
1366 }
1367 //________________________________________________________________________________
1368 Int_t StSstBarrel::readConditionDbFromTable(St_sdm_condition_db *sdm_condition)
1369 {
1370  sdm_condition_db_st *condition = sdm_condition->GetTable();
1371 
1372  Int_t idWaf = 0, iWaf = 0, iLad = 0;
1373  Int_t nStrip = 0;
1374  Int_t iSide = 0;
1375 
1376  Int_t i = 0;
1377  for (i = 0 ; i < sdm_condition->GetNRows(); i++)
1378  {
1379  if (!(condition[i].is_active))
1380  {
1381  nStrip = (int)(condition[i].id_strip/100000.);
1382  idWaf = condition[i].id_strip-10000*((int)(condition[i].id_strip/10000.));
1383  iWaf = idWaferToWaferNumb(idWaf);
1384  iLad = (int)(idWaf - mSstLayer*1000 - (iWaf+1)*100 - 1);
1385  iSide = (condition[i].id_strip - nStrip*100000 - idWaf)/10000;
1386  mLadders[iLad]->mWafers[iWaf]->setIsActive(condition[i].is_active, iSide, nStrip);
1387  }
1388  }
1389  return sdm_condition->GetNRows();
1390 }
1391 //________________________________________________________________________________
1392 Int_t StSstBarrel::writeStripToTable(St_spa_strip *spa_strip)
1393 {
1394  spa_strip_st out_strip;
1395 
1396  Int_t currRecord = 0;
1397  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1398  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1399  {
1400  Int_t idCurrentWaf = mSstLayer*1000 +((iWaf+1)*100)+(iLad+1);
1401  StSstStripList *stripP = mLadders[iLad]->mWafers[iWaf]->getStripP();
1402  StSstStripList *stripN = mLadders[iLad]->mWafers[iWaf]->getStripN();
1403 
1404  StSstStrip *pStripP = stripP->first();
1405  while (pStripP)
1406  {
1407  out_strip.id = currRecord + 1;
1408  out_strip.adc_count = pStripP->getDigitSig();
1409  out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1410  for (Int_t i = 0 ; i < 5 ; i++)
1411  {
1412  out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1413  }
1414  spa_strip->AddAt(&out_strip);
1415  currRecord++;
1416  pStripP = stripP->next(pStripP);
1417  }
1418 
1419  StSstStrip *pStripN = stripN->first();
1420  while (pStripN)
1421  {
1422 
1423  out_strip.id = currRecord + 1;
1424  out_strip.adc_count = pStripN->getDigitSig();
1425  out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1426  for (Int_t i = 0 ; i < 5 ; i++)
1427  {
1428  out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1429  }
1430  spa_strip->AddAt(&out_strip);
1431  currRecord++;
1432  pStripN = stripN->next(pStripN);
1433  }
1434 
1435  }
1436  return currRecord;
1437 }
1438 //________________________________________________________________________________
1439 Int_t StSstBarrel::writeStripToTable(St_spa_strip *spa_strip,St_sls_strip *sls_strip )
1440 {
1441  spa_strip_st out_strip;
1442  sls_strip_st *strip = sls_strip->GetTable();
1443  Int_t currRecord = 0;
1444  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1445  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++)
1446  {
1447  Int_t idCurrentWaf = mSstLayer*1000 +((iWaf+1)*100)+(iLad+1);
1448  StSstStripList *stripP = mLadders[iLad]->mWafers[iWaf]->getStripP();
1449  StSstStripList *stripN = mLadders[iLad]->mWafers[iWaf]->getStripN();
1450  StSstStrip *pStripP = stripP->first();
1451  while (pStripP)
1452  {
1453  out_strip.id = currRecord + 1;
1454  out_strip.adc_count = pStripP->getDigitSig();
1455  out_strip.id_strip = 10000*(10*pStripP->getNStrip() + 0)+idCurrentWaf;
1456  for (Int_t i = 0 ; i < 5 ; i++)
1457  {
1458  out_strip.id_mchit[i] = pStripP->getIdMcHit(i);
1459  if(out_strip.id_mchit[i]==0) {
1460  out_strip.id_mctrack[i]=0;}
1461  else {
1462  for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1463  if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1464  out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1465  }
1466  }
1467  }
1468  spa_strip->AddAt(&out_strip);
1469  currRecord++;
1470  pStripP = stripP->next(pStripP);
1471  }
1472 
1473  StSstStrip *pStripN = stripN->first();
1474  while (pStripN)
1475  {
1476  out_strip.id = currRecord + 1;
1477  out_strip.adc_count = pStripN->getDigitSig();
1478  out_strip.id_strip = 10000*(10*pStripN->getNStrip() + 1)+idCurrentWaf;
1479  for (Int_t i = 0 ; i < 5 ; i++)
1480  {
1481  out_strip.id_mchit[i] = pStripN->getIdMcHit(i);
1482  if(out_strip.id_mchit[i]==0) {
1483  out_strip.id_mctrack[i]=0;}
1484  else {
1485  for(Int_t j = 0 ; j < sls_strip->GetNRows(); j++){
1486  if(out_strip.id_mchit[i] == strip[j].id_mchit[i])
1487  out_strip.id_mctrack[i] = strip[j].id_mctrack[i];
1488  }
1489  }
1490  }
1491  spa_strip->AddAt(&out_strip);
1492  currRecord++;
1493  pStripN = stripN->next(pStripN);
1494  }
1495  }
1496  return currRecord;
1497 }
1498 //________________________________________________________________________________
1499 void StSstBarrel::doDaqSimulation(slsCtrl_st *ctrl){
1500  for (Int_t iLad = 0; iLad < mNLadder; iLad++)
1501  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder ; iWaf++) {
1502  mLadders[iLad]->mWafers[iWaf]->convertAnalogToDigit(ctrl[0].nElectronInAMip,
1503  ctrl[0].adcDynamic,
1504  ctrl[0].nbitEncoding,
1505  ctrl[0].daqCutValue);
1506  mLadders[iLad]->mWafers[iWaf]->pedestalSubstraction();
1507  mLadders[iLad]->mWafers[iWaf]->zeroSubstraction();
1508  mLadders[iLad]->mWafers[iWaf]->updateStripList();
1509  }
1510 }
1511 //____________________________________________________________________
1512 Int_t StSstBarrel::readNoiseDefaultForSimu(){
1513  Int_t rms = 48;
1514  // the noise is coded as 16*rms then for each strip, noise = 60/16 = 3.75 adc
1515  Int_t ped = 120 ;
1516  Int_t NAdcChannel = (int)pow(2.0,10.0*1.0);
1517  Int_t nElectronInAMip = 22500;
1518  Int_t adcDynamic = 20;
1519  const Float_t AdctoE = (adcDynamic*nElectronInAMip)/(float)(NAdcChannel);
1520  Int_t NumberOfNoise = 0;
1521  for(Int_t iLad=0;iLad<mNLadder;iLad++)
1522  {
1523  for(Int_t iWaf=0;iWaf<mNWaferPerLadder;iWaf++)
1524  {
1525  for(Int_t NStrip=0;NStrip<mNStripPerSide;NStrip++)
1526  {
1527  for(Int_t iSide=0;iSide<2;iSide++)
1528  {
1529  StSpaNoise *newStrip = new StSpaNoise(NStrip+1 ,(int)(ped*AdctoE),(int)((rms*AdctoE)/16.));
1530  mLadders[iLad]->mWafers[iWaf]->addNoiseToStripSignal(newStrip,iSide);
1531  NumberOfNoise++;
1532  }
1533  }
1534  }
1535  }
1536  return NumberOfNoise;
1537 }
StSstBarrel(sstDimensions_st *dimensions, sstConfiguration_st *config=0)
Definition: StSstBarrel.cc:107
StSstClusterList * getClusterP()
Returns the P-side cluster list attached to this wafer.
Definition: StSstWafer.hh:72
Int_t readNoiseFromTable(St_sdm_calib_db *spa_noise, StSstDynamicControl *dynamicControl)
Definition: StSstBarrel.cc:286
StSstStripList * getStripP()
Returns the P-side strip list attached to this wafer.
Definition: StSstWafer.hh:77
Int_t doFindPackage(sstDimensions_st *dimensions, StSstClusterControl *clusterControl)
Definition: StSstWafer.cc:441
void addCluster(StSstCluster *ptr, Int_t iSide)
Attaches the ptr cluster on the iSide of the wafer.
Definition: StSstWafer.cc:176
StSstPointList * getPoint()
Returns the point list attached to this wafer.
Definition: StSstWafer.hh:80
void addStrip(StSstStrip *ptr, Int_t iSide)
Definition: StSstWafer.cc:165
StSstClusterList * getClusterN()
Returns the N-side cluster list attached to this wafer.
Definition: StSstWafer.hh:73
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
Definition: StMcEvent.hh:169
void sortStrip()
Definition: StSstWafer.cc:207
StSstStripList * getStripN()
Returns the N-side strip list attached to this wafer.
Definition: StSstWafer.hh:78
void doClusterisation(Int_t *numberOfCluster, StSstClusterControl *clusterControl)
Definition: StSstWafer.cc:232