StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPmdMapUtil.cxx
1 /********************************************************
2  *
3  * $Id: StPmdMapUtil.cxx,v 1.11 2010/05/02 13:13:46 rashmi Exp $
4  *
5  * Author: Subhasis Chattopadhyay
6  *
7  *********************************************************
8  *
9  * Description: This the class of PMD Utillty which deals with maps of channel to sm,row,col.
10  * It can be used for reverse mapping as well.
11  *
12  *********************************************************
13  * $Log: StPmdMapUtil.cxx,v $
14  * Revision 1.11 2010/05/02 13:13:46 rashmi
15  * removed some couts
16  *
17  * Revision 1.10 2010/04/30 07:05:46 rashmi
18  * Fixed an array for nSmChainBoards
19  *
20  * Revision 1.9 2007/08/31 10:55:47 rashmi
21  * Changed initialization of channelOR,CR,chainR to -1
22  *
23  * Revision 1.8 2007/06/06 04:00:00 perev
24  * CleanUp
25  *
26  * Revision 1.7 2007/05/26 00:40:07 perev
27  * Initialization added
28  *
29  * Revision 1.6 2007/05/23 18:49:55 rashmi
30  * bug fix for unphysical year 23/05/07
31  *
32  * Revision 1.5 2007/05/21 04:38:11 rashmi
33  * functions for SMChain Combination information 21/05/07
34  *
35  * Revision 1.3 2005/12/07 20:35:45 perev
36  * iostream.h ==> iostream. WarnOff
37  *
38  * Revision 1.2 2005/01/27 13:10:08 subhasis
39  * New map for 2005 data
40  *
41  * Revision 1.1 2004/06/24 13:54:39 subhasis
42  * Maputils added
43  *
44  *
45  **********************************************************/
46 #include <iostream>
47 #include <strings.h>
48 #include <stdlib.h>
49 #include <TROOT.h>
50 #include<TMatrix.h>
51 #include<TArrayF.h>
52 #include <math.h>
53 #include "StPmdGeom.h"
54 #include "StPmdMapUtil.h"
55 #include "StChain.h"
56 ClassImp(StPmdMapUtil)
57 
59 {
60  memset(beg,0,end-beg);
61  mPmdGeom = new StPmdGeom();
62  StoreMapInfo();
63 }
64 
66 
67 void StPmdMapUtil::StoreMapInfo(Int_t runno1)
68 {
69  /*
70  int year = runno1/1000000;
71  int rn = (runno1/1000)%1000;
72  */
73  Int_t year=0;
74  Int_t rn = 0;
75  mPmdGeom->GetRunYear(runno1,rn,year);
76  // cout<<"runno, rn1 "<<runno1<<" "<<rn<<" "<<year<<endl;
77  cout<<"PMD runno, rn1 "<<runno1<<" "<<rn<<" "<<year<<endl;
78  if(year<4){
79  gMessMgr->Warning("Unphysical year");
80  return;
81  }
82 
84  Int_t sm=0,row=0,col=0;
85  //Initialize
86  //memset(m_ChannelInBoard [0][0],0,sizeof(m_ChannelInBoard ));
87  // memset(m_TempChannelInBoard[0][0],0,sizeof(m_TempChannelInBoard));
88  // memset(m_Chain [0][0],0,sizeof(m_Chain ));
89 
90  //Initializing channels to -1; channel=0 is a physical channel; RR 2007-08-30
91  for(Int_t ism=0;ism<PMD_CRAMS_MAX*2;ism++){
92  for(Int_t irow=0;irow<PMD_ROW_MAX;irow++){
93  for(Int_t icol=0;icol<PMD_COL_MAX;icol++){
94  m_ChannelInBoard[ism][irow][icol]=-1;
95  m_TempChannelInBoard[ism][irow][icol]=-1;
96  m_Chain[ism][irow][icol]=-1;
97  }
98  }
99  }
100 
101  for(Int_t Chain_No=1;Chain_No<=PMD_CHAIN_MAX;Chain_No++){
102  // Int_t AliveBoards = mPmdGeom->GetNBoardsChain(Chain_No);
103  for(Int_t CHANNEL=0;CHANNEL<PMD_CHAIN_CHANNEL_MAX;CHANNEL++){
104  Int_t channel=CHANNEL;
105  Int_t chtemp;
106 
107  int fail = 0;
108  if(year==5) {
109  fail = mPmdGeom->ChainMapping(Chain_No,channel,sm,col,row,chtemp);
110  } else if(year>5){
111  mPmdGeom->readBoardDetail(runno1);
112  fail = mPmdGeom->ChainMapping(Chain_No,channel,sm,col,row,chtemp,year);
113  }
114  if (sm <=0) fail +=10;
115  if (col<=0) fail +=20;
116  if (row<=0) fail +=40;
117  if (fail) continue;
118  if(chtemp==-1)continue;
119  // if(sm>12)cout<<"chain,ch,sm,col,row,chtemp,year "<<Chain_No<<" "<<channel<<" "<<sm-1<<" "<<col-1<<" "<<row-1<<" "<<chtemp<<" "<<year<<endl;
120  m_ChannelInBoard[sm-1][row-1][col-1]=channel;
121  m_TempChannelInBoard[sm-1][row-1][col-1]=chtemp;
122  m_Chain[sm-1][row-1][col-1]=Chain_No;
123  }
124  }
125 }
126 
128 {
129  Int_t sm,row,col;
130  //Initialize
131  memset(m_ChannelInBoard [0][0],0,sizeof(m_ChannelInBoard ));
132  memset(m_TempChannelInBoard[0][0],0,sizeof(m_TempChannelInBoard));
133  memset(m_Chain [0][0],0,sizeof(m_Chain ));
134 
135  for(Int_t Chain_No=1;Chain_No<=PMD_CHAIN_MAX;Chain_No++){
136  for(Int_t CHANNEL=0;CHANNEL<PMD_CHAIN_CHANNEL_MAX;CHANNEL++){
137  Int_t channel=CHANNEL;
138  Int_t chtemp;
139 
140  mPmdGeom->ChainMapping(Chain_No,channel,sm,col,row,chtemp);
141  m_ChannelInBoard[sm-1][row-1][col-1]=channel;
142  m_TempChannelInBoard[sm-1][row-1][col-1]=chtemp;
143  m_Chain[sm-1][row-1][col-1]=Chain_No;
144 
145  }
146  }
147 }
148 
149 void StPmdMapUtil::SetSMChainCombos(Int_t runno1){
150 
151  nSMChain = 0;
152  mPmdGeom->readBoardDetail(runno1);
153  Int_t rn,year;
154  mPmdGeom->GetRunYear(runno1,rn,year);
155  for(Int_t ichain = 0;ichain<48;ichain++){
156  for(Int_t ism = 0;ism < 24;ism++){
157  nBoardSMChain[ism][ichain] = 0;
158  }
159  }
160 
161  Int_t mapcheck;
162  for(Int_t ichain = 0;ichain<48;ichain++){
163  for(Int_t ibrd = 0;ibrd < 27;ibrd++){
164  Int_t channel = 10 + ibrd*64;
165  Int_t sm=0,col=0,row=0,chmod=0;
166  Int_t chain = ichain+1;
167  if (year==5){
168  mapcheck = mPmdGeom->ChainMapping(chain,channel,sm,col,row,chmod);
169  }else{
170  mapcheck = mPmdGeom->ChainMapping(chain,channel,sm,col,row,chmod,year);
171  }
172  if(mapcheck==kStOk && sm > 0) {
173  nBoardSMChain[sm-1][ichain]++;
174  SMChainExists[sm-1][ichain]=nSMChain+1;
175  if(nBoardSMChain[sm-1][ichain]==1) {
176  nSMChain++;
177  // cout<<nSMChain-1<<" "<<ichain+1<<" "<<ibrd+1<<" "<<sm<<endl;
178  FirstBoard[nSMChain-1] = ibrd+1;
179  SM_Combo[nSMChain-1] = sm;
180  Chain_Combo[nSMChain-1] = chain;
181  }
182  }
183  }
184  }
185 
186  /*
187  for (Int_t ismchain = 0; ismchain<nSMChain;ismchain++){
188  cout<<"ismchain="<<ismchain<<" chain="<<Chain_Combo[ismchain]<<" sm="<<SM_Combo[ismchain]<<" has number of boards = "<<nBoardSMChain[SM_Combo[ismchain]-1][Chain_Combo[ismchain]-1]<<" first board="<<FirstBoard[ismchain]<<endl;
189  }
190  */
191 }
virtual ~StPmdMapUtil()
A constructor.
void StoreMapInfo()
A destructor.
Definition: Stypes.h:41