9 StFgtDb::printFgtDumpCSV1(TString fname,
int myDate,
int myTime) {
12 fd.open(fname.Data());
17 cout<<
"Saving FGT output in "<<fname.Data()<<endl;
19 fd<<
"# FGT mapping, timeStamp "<< myDate<<
" "<<myTime<<
"\n";
20 fd<<
"# electId,geoID, RDO(1;2),ARM(0-4),APV(0-9;12-21),chan(0-127), disk(1-6),quad(A-D),layer(P;R),strip(P:0-719;R0-279+400-679), ordinate(rad;cm),lowSpan(cm;rad),upSpan(cm;rad), geoName, stat,ped(ADC),sigPed(ADC)\n";
26 for (
int rdo=1;rdo<=2;rdo++){
27 for (
int arm=0;arm<6;arm++){
28 for (
int apv=0;apv<=21;apv++){
29 if ((apv==10)||(apv==11))
continue;
31 for (
int channel=0;channel<128;channel++){
34 int geoId=fgtDb->getGeoIdFromElecCoord(rdo, arm, apv, channel);
35 if (geoId<0)
continue;
37 Short_t disk,quad,quad2,strip; Char_t layer;
38 Double_t ordinate, lowerSpan, upperSpan;
39 StFgtGeom::decodeGeoId(geoId,disk,quad,layer,strip);
41 StFgtGeom::getPhysicalCoordinate(geoId,disk,quad2,layer,ordinate,lowerSpan,upperSpan);
43 double ped=fgtDb->getPedestalFromElecCoord(rdo,arm,apv,channel);
44 double pedSig=fgtDb->getPedestalSigmaFromElecCoord(rdo,arm,apv,channel);
45 Short_t stat=fgtDb->getStatusFromElecCoord(rdo,arm,apv,channel);
46 int electId = StFgtGeom::getElectIdFromElecCoord(rdo,arm,apv,channel);
47 std::string geoName=fgtDb->getGeoNameFromElecCoord(rdo,arm,apv,channel);
50 fd<<electId<<
", "<<geoId<<
", "<<rdo<<
", "<<arm<<
", "<<apv<<
", "<<channel<<
", "<<disk+1<<
", "<<quad<<
", "<<layer<<
", "<<strip<<
", "<<ordinate<<
", "<<lowerSpan<<
", "<<upperSpan<<
", "<<geoName.data()<<
", "<<stat<<
", "<<ped<<
", "<<pedSig<<
"\n";
58 fd<<
"# FGT mapping end, nTry= "<<nTry<<
" nMap="<< nMap<<
" from StFgtDb\n";
64 cout <<
"Error opening file";
72 Int_t StFgtDb::getElecCoordFromGeoId(
73 Int_t geoId, Int_t& rdo, Int_t& arm, Int_t& apv, Int_t& channel
76 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
78 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getElecCoordFromGeoId." << endm;
87 Int_t elecId = m_rmap->Mapping[ geoId ];
89 StFgtGeom::decodeElectronicId( elecId, rdo, arm, apv, channel );
94 Int_t StFgtDb::getElecCoordFromGeoName(
95 const std::string & geoName,
96 Int_t& rdo, Int_t& arm, Int_t& apv, Int_t& channel
100 StFgtGeom::translateGeoNameToGeoId( geoName );
112 getElecCoordFromGeoId( geoId, rdo, arm, apv, channel );
117 Double_t StFgtDb::getPedestalFromGeoId( Int_t geoId )
119 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
121 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getPedestalFromGeoId." << endm;
125 Int_t elecId = m_rmap->Mapping[ geoId ];
126 return m_pedestal->AdcPedestal[ elecId ];
129 Double_t StFgtDb::getPedestalFromElecId( Int_t elecId)
131 if ( elecId < 0 || elecId >= kFgtNumElecIds )
133 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getPedestalFromElecId." << endm;
137 return m_pedestal->AdcPedestal[ elecId ];
140 Double_t StFgtDb::getPedestalSigmaFromGeoId( Int_t geoId )
142 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
144 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getPedestalSigmaFromGeoId." << endm;
148 Int_t elecId = m_rmap->Mapping[ geoId ];
149 return m_pedestal->AdcPedestalRMS[ elecId ];
152 Double_t StFgtDb::getPedestalSigmaFromElecId( Int_t elecId )
154 if ( elecId < 0 || elecId >= kFgtNumElecIds )
156 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getPedestalSigmaFromElecId." << endm;
160 return m_pedestal->AdcPedestalRMS[ elecId ];
163 Char_t StFgtDb::getPedestalStatusFromGeoId( Int_t geoId )
165 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
167 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getPedestalStatusFromGeoId." << endm;
168 return kFgtErrorChar;
171 Int_t elecId = m_rmap->Mapping[ geoId ];
172 return m_pedestal->Status[ elecId ];
175 Char_t StFgtDb::getPedestalStatusFromElecId( Int_t elecId )
177 if ( elecId < 0 || elecId >= kFgtNumElecIds )
179 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getPedestalStatusFromElecId." << endm;
180 return kFgtErrorChar;
183 return m_pedestal->Status[ elecId ];
186 Char_t StFgtDb::getStatusFromGeoId( Int_t geoId )
188 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
190 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getStatusFromGeoId." << endm;
191 return kFgtErrorChar;
194 Int_t elecId = m_rmap->Mapping[ geoId ];
195 return m_status->Status[ elecId ];
198 Char_t StFgtDb::getStatusFromElecId( Int_t elecId )
200 if ( elecId < 0 || elecId >= kFgtNumElecIds )
202 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getStatusFromElecId." << endm;
203 return kFgtErrorChar;
206 return m_status->Status[ elecId ];
209 Double_t StFgtDb::getGainFromGeoId( Int_t geoId )
211 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
213 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getGainFromGeoId." << endm;
217 Int_t elecId = m_rmap->Mapping[ geoId ];
218 return m_gain->Gain[ elecId ];
221 Double_t StFgtDb::getGainFromElecId( Int_t elecId )
223 if ( elecId < 0 || elecId >= kFgtNumElecIds )
225 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getGainFromElecId." << endm;
229 return m_gain->Gain[ elecId ];
232 Char_t StFgtDb::getGainStatusFromGeoId( Int_t geoId )
234 if ( geoId < 0 || geoId >= kFgtNumGeoIds )
236 LOG_DEBUG <<
"GeoId " << geoId <<
" out of range in StFgtDb::getGainStatusFromGeoId." << endm;
237 return kFgtErrorChar;
240 Int_t elecId = m_rmap->Mapping[ geoId ];
241 return m_gain->Status[ elecId ];
244 Char_t StFgtDb::getGainStatusFromElecId( Int_t elecId )
246 if ( elecId < 0 || elecId >= kFgtNumElecIds )
248 LOG_DEBUG <<
"Electronic ID " << elecId <<
" out of range in StFgtDb::getGainStatusFromElecId." << endm;
249 return kFgtErrorChar;
252 return m_gain->Status[ elecId ];
255 Double_t StFgtDb::getMapping(
256 Int_t rdo, Int_t arm, Int_t apv, Int_t channel
259 Short_t disc, quadrant;
261 Double_t ordinate, lowerSpan, upperSpan;
263 if ( getPhysCoordFromElecCoord(
264 rdo, arm, apv, channel,
265 disc, quadrant, layer,
266 ordinate, lowerSpan, upperSpan
276 Int_t rdo, Int_t arm, Int_t apv, Int_t channel
279 Short_t disc, quadrant;
281 Double_t ordinate, lowerSpan, upperSpan;
285 getPhysCoordFromElecCoord(
286 rdo, arm, apv, channel,
287 disc, quadrant, layer,
288 ordinate, lowerSpan, upperSpan
291 return (layer ==
'R');
298 void StFgtDb::getStarXYZ(Short_t disc, Short_t quad, Double_t r, Double_t phi, TVector3 &xyz, Int_t opt, fgtAlignment_st* par){
300 if(disc<0 || disc>=kFgtNumDiscs)
return;
301 if(quad<0 || quad>=kFgtNumQuads)
return;
302 TVector3 org(r*cos(phi),r*sin(phi),StFgtGeom::getDiscZ(disc));
303 if(opt==0) {xyz=org;
return;}
304 fgtAlignment_st* alg;
305 if(opt==1) { alg = m_alignment;}
309 TVector3 center; StFgtGeom::getQuadCenterXYZ(disc,quad,center);
310 TVector3 local=org-center;
315 rot.SetXEulerAngles(alg->phi[i], alg->theta[i], alg->psi[i]);
316 TVector3 rotated = local.Transform(rot);
318 TVector3 global=rotated+center;
320 TVector3 offset(alg->xoff[i],alg->yoff[i],alg->zoff[i]);
322 xyz = global + offset;