StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSstLadder.cc
1 //$Id: StSstLadder.cc,v 1.6 2016/05/29 19:35:06 bouchet Exp $
2 //
3 //$Log: StSstLadder.cc,v $
4 //Revision 1.6 2016/05/29 19:35:06 bouchet
5 //coverity : CTOR_DTOR_LEAK fixed
6 //
7 //Revision 1.5 2015/07/21 14:27:43 bouchet
8 //removed unused variable ; cleanup
9 //
10 //Revision 1.4 2015/07/06 13:46:21 bouchet
11 //revert to initial (and correct) decoding of iLad,iWaf
12 //
13 //Revision 1.3 2015/07/02 18:18:46 bouchet
14 //fixed the decoding of sstWafersPosition table
15 //
16 //Revision 1.2 2015/06/24 17:37:21 smirnovd
17 //StSstUtil: Prepend included headers with path to submodule
18 //
19 //Revision 1.1 2015/06/23 16:26:20 jeromel
20 //First version created from the SSD code and reshaped
21 //
22 //Revision 1.1 2015/04/19 17:30:32 bouchet
23 //initial commit ; SST codes
24 //
25 //fork from the SSD code, move along - see history therein
26 #include "StSstUtil/StSstLadder.hh"
27 #include "St_base/Stiostream.h"
28 #include "tables/St_sstWaferConfiguration_Table.h"
29 
30 StSstLadder::StSstLadder(Int_t rLadderNumb,Int_t rSstLayer,Int_t rNWaferPerLadder,Int_t rNStripPerSide) : mDebug(0)
31 {
32  // Note iWaf = 0->15 whereas iW = 1->16 !
33  // mLadderNumb = iLad = 0->19 whereas iL = 1->20 !
34  memset (first, 0, last-first);
35  mLadderNumb = rLadderNumb;
36  mSstLayer = rSstLayer;
37  mNWaferPerLadder = rNWaferPerLadder;
38  mNStripPerSide = rNStripPerSide;
39 
40  Int_t nWafer = mNWaferPerLadder;
41  Int_t idWaf = 0;
42 
43  mWafers = new StSstWafer*[nWafer];
44  for (Int_t iWaf=0; iWaf < nWafer; iWaf++)
45  {
46  idWaf = waferNumbToIdWafer(iWaf);
47  mWafers[iWaf] = new StSstWafer(idWaf);
48  if (Debug()) mWafers[iWaf]->SetDebug(Debug());
49  }
50 }
51 
52 StSstLadder::~StSstLadder(){
53  delete [] mWafers;
54 }
55 
56 void StSstLadder::initWafers(St_sstWafersPosition *Position)
57 {
58  //init is done for 0<iWaf<16
59  //idWafer is the old convention : idWafer = 7000 + (wafer[1-16]*100) + ladder[1-20]
60  // --> 7101 <= idWafer <= 8620
61  Int_t idWafer = 0;
62  Int_t iWaf = 0;
63  Int_t iLad = 0;
64  sstWafersPosition_st *position = Position->GetTable();
65  Int_t N = 320;
66  for (Int_t i = 0; i < N; i++){
67  iWaf = i%16;
68  iLad = i/16;
69  idWafer = 7000 + (iWaf+1)*100 + (iLad)+1;
70  if (mLadderNumb == idWafer%100-1){
71  Double_t rr[3] = {position[0].driftDirection[i*3], position[0].driftDirection[i*3+1], position[0].driftDirection[i*3+2]};
72  Double_t nn[3] = {position[0].normalDirection[i*3], position[0].normalDirection[i*3+1], position[0].normalDirection[i*3+2]};
73  Double_t tr[3] = {position[0].transverseDirection[i*3], position[0].transverseDirection[i*3+1], position[0].transverseDirection[i*3+2]};
74  Double_t cr[3] = {position[0].centerPosition[i*3], position[0].centerPosition[i*3+1], position[0].centerPosition[i*3+2]};
75  mWafers[iWaf]->init(idWafer,rr,nn,tr,cr);
76  }
77  }
78 }
79 
80 void StSstLadder::Reset(){
81  for (Int_t iWaf = 0; iWaf < mNWaferPerLadder; iWaf++)mWafers[iWaf]->Reset();
82 }
83 
84 
85 Int_t StSstLadder::idWaferToWaferNumb(Int_t idWafer)
86 {
87  Int_t iW = (int)((idWafer - mSstLayer*1000)/100);
88  return (iW-1);
89 }
90 
91 Int_t StSstLadder::waferNumbToIdWafer(Int_t waferNumb)
92 {
93  Int_t iL = mLadderNumb+1; // iL:1->20
94  Int_t iW = waferNumb+1; // iW:1->16
95  return mSstLayer*1000 + iW*100 + iL;
96 }
97 
98 void StSstLadder::debugUnPeu(Int_t monwafer)
99 {
100  for (Int_t j=0;j<this->getWaferPerLadder();j++)
101  {
102  if (this->mWafers[j]->getIdWafer()==this->waferNumbToIdWafer(monwafer))
103  {
104  cout<<" Wafer "<<monwafer<<" found with id :"<<this->mWafers[j]->getIdWafer()<<endl;
105  this->mWafers[j]->debugStrips();
106  this->mWafers[j]->debugClusters();
107  }
108  }
109 
110 }