00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "StFmsDbMaker.h"
00024 #include "St_db_Maker/St_db_Maker.h"
00025 #include "StMessMgr.h"
00026 #include "tables/St_fmsDetectorPosition_Table.h"
00027 #include "tables/St_fmsChannelGeometry_Table.h"
00028 #include "tables/St_fmsMap_Table.h"
00029 #include "tables/St_fmsPatchPanelMap_Table.h"
00030 #include "tables/St_fmsQTMap_Table.h"
00031 #include "tables/St_fmsGain_Table.h"
00032 #include "tables/St_fmsGainCorrection_Table.h"
00033 StFmsDbMaker* gStFmsDbMaker=NULL;
00034
00035 ClassImp(StFmsDbMaker)
00036
00037 StFmsDbMaker::StFmsDbMaker(const Char_t *name) : StMaker(name), mDebug(0),mChannelGeometry(0),mDetectorPosition(0),mMap(0),mmMap(0),mPatchPanelMap(0),
00038 mQTMap(0),mGain(0),mmGain(0),mGainCorrection(0),mmGainCorrection(0){gStFmsDbMaker = this;}
00039 StFmsDbMaker::~StFmsDbMaker() {deleteArrays(); gStFmsDbMaker = 0;}
00040 Int_t StFmsDbMaker::Init(){LOG_DEBUG<<"StFmsDbMaker Init Start"<<endm; return StMaker::Init();}
00041 Int_t StFmsDbMaker::Make(){LOG_DEBUG<<"StFmsDbMaker Make"<<endm; return kStOK;}
00042 void StFmsDbMaker::Clear(const Char_t*){LOG_DEBUG<<"StFmsDbMaker Clear"<<endm; StMaker::Clear();}
00043 Int_t StFmsDbMaker::Finish(){LOG_DEBUG<<"StFmsDbMaker Finish"<<endm; return kStOK;}
00044
00045 Int_t StFmsDbMaker::InitRun(Int_t runNumber) {
00046 LOG_DEBUG << "StFmsDbMaker::InitRun - run = " << runNumber << endm;
00047 deleteArrays();
00048
00050 if(mDebug>0) {
00051 St_db_Maker* dbmaker = (St_db_Maker*)GetMaker("db");
00052 LOG_INFO << "StFmsDbMaker::InitRun - Date&time from St_db_Maker="<<dbmaker->GetDate()<<","<< dbmaker->GetTime() << endm;
00053 }
00054
00055 TDataSet *DBgeom = 0;
00056 TDataSet *DBmapping = 0;
00057 TDataSet *DBcalibration = 0;
00058 DBgeom = GetInputDB("Geometry/fms");
00059 DBmapping = GetInputDB("Calibrations/fms/mapping");
00060 DBcalibration= GetInputDB("Calibrations/fms");
00061 if(!DBgeom) {LOG_ERROR << "StFmsDbMaker::InitRun - No Geometry/fms"<<endm; return kStFatal;}
00062 if(!DBmapping) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/mapping"<<endm; return kStFatal;}
00063 if(!DBcalibration) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms"<<endm; return kStFatal;}
00064
00066 St_fmsChannelGeometry *dbChannelGeometry = 0;
00067 St_fmsDetectorPosition *dbDetectorPosition = 0;
00068 St_fmsMap *dbMap = 0;
00069 St_fmsPatchPanelMap *dbPatchPanelMap = 0;
00070 St_fmsQTMap *dbQTMap = 0;
00071 St_fmsGain *dbGain = 0;
00072 St_fmsGainCorrection *dbGainCorrection = 0;
00073 dbChannelGeometry = (St_fmsChannelGeometry*) DBgeom->Find("fmsChannelGeometry");
00074 dbDetectorPosition = (St_fmsDetectorPosition*) DBgeom->Find("fmsDetectorPosition");
00075 dbMap = (St_fmsMap*) DBmapping->Find("fmsMap");
00076 dbPatchPanelMap = (St_fmsPatchPanelMap*) DBmapping->Find("fmsPatchPanelMap");
00077 dbQTMap = (St_fmsQTMap*) DBmapping->Find("fmsQTMap");
00078 dbGain = (St_fmsGain*) DBcalibration->Find("fmsGain");
00079 dbGainCorrection = (St_fmsGainCorrection*) DBcalibration->Find("fmsGainCorrection");
00080 if(!dbChannelGeometry){LOG_ERROR << "StFmsDbMaker::InitRun - No Geometry/fms/fmsChannelGeometry" <<endm; return kStFatal;}
00081 if(!dbDetectorPosition){LOG_ERROR << "StFmsDbMaker::InitRun - No Geometry/fms/fmsDetectorPosition" <<endm; return kStFatal;}
00082 if(!dbMap) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/mapping/fmsMap" <<endm; return kStFatal;}
00083 if(!dbPatchPanelMap) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/mapping/fmsPatchPanelMap"<<endm; return kStFatal;}
00084 if(!dbQTMap) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/mapping/fmsQTMap" <<endm; return kStFatal;}
00085 if(!dbGain) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/fmsGain" <<endm; return kStFatal;}
00086 if(!dbGainCorrection) {LOG_ERROR << "StFmsDbMaker::InitRun - No Calibration/fms/fmsGainCorrection" <<endm; return kStFatal;}
00087
00089 fmsChannelGeometry_st *tChannelGeometry = 0;
00090 tChannelGeometry = (fmsChannelGeometry_st*) dbChannelGeometry->GetTable();
00091 Int_t max = dbChannelGeometry->GetNRows();
00092 mMaxDetectorId = 0;
00093 for(Int_t i=0; i<max; i++){
00094 if(mMaxDetectorId < tChannelGeometry[i].detectorId) mMaxDetectorId = tChannelGeometry[i].detectorId;
00095 }
00096 mChannelGeometry = new fmsChannelGeometry_st[mMaxDetectorId+1];
00097 memset(mChannelGeometry,0,sizeof(fmsChannelGeometry_st)*(mMaxDetectorId+1));
00098 for(Int_t i=0; i<max; i++){
00099 memcpy(&mChannelGeometry[tChannelGeometry[i].detectorId], &tChannelGeometry[i], sizeof(fmsChannelGeometry_st));
00100 }
00101 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Geometry/fms/fmsChannelGeometry with maxDetectorId = "<<mMaxDetectorId<< endm;
00102
00104 fmsDetectorPosition_st *tDetectorPosition = 0;
00105 tDetectorPosition = (fmsDetectorPosition_st*) dbDetectorPosition->GetTable();
00106 mDetectorPosition = new fmsDetectorPosition_st[mMaxDetectorId+1];
00107 memset(mDetectorPosition,0,sizeof(fmsDetectorPosition_st)*(mMaxDetectorId+1));
00108 max = dbDetectorPosition->GetNRows();
00109 for(Int_t i=0; i<max; i++){
00110 memcpy(&mDetectorPosition[tDetectorPosition[i].detectorId], &tDetectorPosition[i], sizeof(fmsDetectorPosition_st));
00111 }
00112 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Geometry/fms/fmsDetectorPosition with "<<max<<" detectors"<< endm;
00113
00115 mPatchPanelMap = (fmsPatchPanelMap_st*) dbPatchPanelMap->GetTable();
00116 mMaxModule = dbPatchPanelMap->GetNRows();
00118 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Calibration/fms/mapping/fmsPatchPanelMap with mMaxModule = "<<mMaxModule<< endm;
00119
00121 mQTMap = (fmsQTMap_st*) dbQTMap->GetTable();
00122 mMaxNS = dbQTMap->GetNRows();
00123 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Calibration/fms/mapping/fmsQTMap with mMaxNS = "<<mMaxNS<< endm;
00124
00126 mMap = (fmsMap_st*) dbMap->GetTable();
00127 mMaxMap = dbMap->GetNRows();
00128 mmMap = new fmsMap_st* [mMaxDetectorId+1];
00129 memset(mmMap,0,sizeof(fmsMap_st*)*(mMaxDetectorId+1));
00130 memset(mReverseMapDetectorId,0,sizeof(mReverseMapDetectorId));
00131 memset(mReverseMapChannel,0,sizeof(mReverseMapChannel));
00132 for(Int_t i=0; i<mMaxMap; i++){
00133 Int_t d=mMap[i].detectorId;
00134 Int_t c=mMap[i].ch;
00135 if(d<0 || d>mMaxDetectorId){
00136 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/mapping/fmsMap detectorId="<<d<<" exceed max="<<mMaxDetectorId<<endm;
00137 return kStFatal;
00138 }
00139 if(c<1 || c>maxChannel(d)){
00140 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/mapping/fmsMap ch="<<c<<" exceed max="<<maxChannel(d)<<endm;
00141 return kStFatal;
00142 }
00143 if(mmMap[d]==0){
00144 mmMap[d] = new fmsMap_st [maxChannel(d)];
00145 memset(mmMap[d],0,sizeof(fmsMap_st)*maxChannel(d));
00146 }
00147 memcpy(&mmMap[d][c-1],&mMap[i],sizeof(fmsMap_st));
00148
00149 Int_t crt,slot,ch;
00150 getMap(d,c,&crt,&slot,&ch);
00151 mReverseMapDetectorId[crt][slot][ch]=d;
00152 mReverseMapChannel[crt][slot][ch]=c;
00153 }
00154
00155 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Geometry/fms/mapping/fmsMap with mMaxMap = "<<mMaxMap<< endm;
00156
00158 mGain = (fmsGain_st*) dbGain->GetTable();
00159 mMaxGain = dbGain->GetNRows();
00160 mmGain = new fmsGain_st* [mMaxDetectorId+1];
00161 memset(mmGain,0,sizeof(fmsGain_st*)*(mMaxDetectorId+1));
00162 for(Int_t i=0; i<mMaxGain; i++){
00163 Int_t d=mGain[i].detectorId;
00164 Int_t c=mGain[i].ch;
00165 if(maxChannel(d)<1){
00166 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGain invalid max number of channel = "<<maxChannel(d)<<endm;
00167 continue;
00168 }
00169 if(d<0 || d>mMaxDetectorId){
00170 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGain detectorId="<<d<<" exceed max = "<<mMaxDetectorId<<endm;
00171 continue;
00172 }
00173 if(c<1 || c>maxChannel(d)){
00174 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGain detectorId="<<d<<" ch="<<c<<" exceed max = "<<maxChannel(d)<<endm;
00175 continue;
00176 }
00177 if(mmGain[d]==0){
00178 mmGain[d] = new fmsGain_st [maxChannel(d)];
00179 memset(mmGain[d],0,sizeof(fmsGain_st)*maxChannel(d));
00180 }
00181 memcpy(&mmGain[d][c-1],&mGain[i],sizeof(fmsGain_st));
00182 }
00183 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Calibration/fms/fmsGain with mMaxGain = "<<mMaxGain<< endm;
00184
00186 mGainCorrection = (fmsGainCorrection_st*) dbGainCorrection->GetTable();
00187 mMaxGainCorrection = dbGainCorrection->GetNRows();
00188 mmGainCorrection = new fmsGainCorrection_st* [mMaxDetectorId+1];
00189 memset(mmGainCorrection,0,sizeof(fmsGainCorrection_st*)*(mMaxDetectorId+1));
00190 for(Int_t i=0; i<mMaxGainCorrection; i++){
00191 Int_t d=mGainCorrection[i].detectorId;
00192 Int_t c=mGainCorrection[i].ch;
00193 if(maxChannel(d)<1){
00194 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGainCorrection invalid max number of channel = "<<maxChannel(d)<<endm;
00195 continue;
00196 }
00197 if(d<0 || d>mMaxDetectorId){
00198 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGainCorrection detectorId="<<d<<" exceed max="<<mMaxDetectorId<<endm;
00199 continue;
00200 }
00201 if(c<1 || c>maxChannel(d)){
00202 LOG_ERROR << "StFmsDbMaker::InitRun - Calibration/fms/fmsGainCorrection ch="<<c<<" exceed max="<<maxChannel(d)<<endm;
00203 continue;
00204 }
00205 if(mmGainCorrection[d]==0){
00206 mmGainCorrection[d] = new fmsGainCorrection_st [maxChannel(d)];
00207 memset(mmGainCorrection[d],0,sizeof(fmsGainCorrection_st)*maxChannel(d));
00208 }
00209 memcpy(&mmGainCorrection[d][c-1],&mGainCorrection[i],sizeof(fmsGainCorrection_st));
00210 }
00211 LOG_DEBUG << "StFmsDbMaker::InitRun - Got Geometry/fms/fmsGainCorrection with mMaxGainCorrection = "<<mMaxGainCorrection<< endm;
00212
00214 if(mDebug>0){
00215 dumpFmsChannelGeometry();
00216 dumpFmsDetectorPosition();
00217 dumpFmsMap();
00218 dumpFmsPatchPanelMap();
00219 dumpFmsQTMap();
00220 dumpFmsGain();
00221 dumpFmsGainCorrection();
00222 }
00223 return kStOK;
00224 }
00225
00226 void StFmsDbMaker::deleteArrays(){
00227 if(mChannelGeometry) delete [] mChannelGeometry;
00228 if(mDetectorPosition) delete [] mDetectorPosition;
00229 if(mmMap){
00230 for(Int_t d=0; d<=mMaxDetectorId; d++){
00231 if(mmMap[d]) delete [] mmMap[d];
00232 }
00233 delete [] mmMap;
00234 }
00235
00236 if(mmGain){
00237 for(Int_t d=0; d<=mMaxDetectorId; d++){
00238 if(mmGain[d]) delete [] mmGain[d];
00239 }
00240 delete [] mmGain;
00241 }
00242 if(mmGainCorrection){
00243 for(Int_t d=0; d<=mMaxDetectorId; d++){
00244 if(mmGainCorrection[d]) delete [] mmGainCorrection[d];
00245 }
00246 delete [] mmGainCorrection;
00247 }
00248 }
00249
00251 StThreeVectorF StFmsDbMaker::getStarXYZ(Int_t detectorId,Float_t FmsX, Float_t FmsY)
00252 {
00253 Float_t x = 0;
00254 Float_t y = 0;
00255 Float_t z = 0;
00256 y = mDetectorPosition[detectorId].yoffset - FmsY*mDetectorPosition[detectorId].ywidth;
00257 z = mDetectorPosition[detectorId].zoffset;
00258 if(northSouth(detectorId) == 0)
00259 x = mDetectorPosition[detectorId].xoffset - FmsX*mDetectorPosition[detectorId].xwidth;
00260 else
00261 x = mDetectorPosition[detectorId].xoffset + FmsX*mDetectorPosition[detectorId].xwidth;
00262 return StThreeVectorF(x,y,z);
00263 }
00264 Float_t StFmsDbMaker::getPhi(Int_t detectorId,Float_t FmsX, Float_t FmsY){ return (getStarXYZ(detectorId,FmsX,FmsY)).phi();}
00265 Float_t StFmsDbMaker::getEta(Int_t detectorId,Float_t FmsX, Float_t FmsY, Float_t Vertex) { return (getStarXYZ(detectorId,FmsX,FmsY)).pseudoRapidity();}
00266
00267 void StFmsDbMaker::setDebug(Int_t debug) {mDebug = debug;}
00268
00270 fmsDetectorPosition_st* StFmsDbMaker::DetectorPosition() {if(mDetectorPosition) return mDetectorPosition; return 0;}
00271 fmsChannelGeometry_st* StFmsDbMaker::ChannelGeometry() {if(mChannelGeometry) return mChannelGeometry; return 0;}
00272 fmsMap_st* StFmsDbMaker::Map() {if(mMap) return mMap; return 0;}
00273 fmsPatchPanelMap_st* StFmsDbMaker::PatchPanelMap() {if(mPatchPanelMap) return mPatchPanelMap; return 0;}
00274 fmsQTMap_st* StFmsDbMaker::QTMap() {if(mQTMap) return mQTMap; return 0;}
00275 fmsGain_st* StFmsDbMaker::Gain() {if(mGain) return mGain; return 0;}
00276 fmsGainCorrection_st* StFmsDbMaker::GainCorrection() {if(mGainCorrection) return mGainCorrection; return 0;}
00277
00279 Int_t StFmsDbMaker::maxDetectorId() {return mMaxDetectorId;}
00280 Int_t StFmsDbMaker::eastWest(Int_t detectorId){
00281 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0) return mChannelGeometry[detectorId].ew;
00282 else{
00283 LOG_WARN<<"StFmsDbMaker::eastWest: Corresponding channel geometry not found."<<endm;
00284 return -1;
00285 }
00286 }
00287
00288 Int_t StFmsDbMaker::northSouth(Int_t detectorId){
00289 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0) return mChannelGeometry[detectorId].ns;
00290 else{
00291 LOG_WARN<<"StFmsDbMaker::northSouth: Corresponding channel geometry not found."<<endm;
00292 return -1;
00293 }
00294 }
00295
00296 Int_t StFmsDbMaker::type(Int_t detectorId){
00297 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0) return mChannelGeometry[detectorId].type;
00298 else{
00299 LOG_WARN<<"StFmsDbMaker::type: Corresponding channel geometry not found."<<endm;
00300 return -1;
00301 }
00302 }
00303
00304 Int_t StFmsDbMaker::nRow(Int_t detectorId){
00305 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0) return mChannelGeometry[detectorId].nY;
00306 else{
00307 LOG_WARN<<"StFmsDbMaker::nRow: Corresponding channel geometry not found."<<endm;
00308 return -1;
00309 }
00310 }
00311
00312 Int_t StFmsDbMaker::nColumn(Int_t detectorId){
00313 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0)
00314 return mChannelGeometry[detectorId].nX;
00315 else{
00316 LOG_WARN<<"StFmsDbMaker::nColumn: Corresponding channel geometry not found."<<endm;
00317 return -1;
00318 }
00319 }
00320
00321 Int_t StFmsDbMaker::maxChannel(Int_t detectorId){
00322 if(detectorId>=0 && detectorId<=mMaxDetectorId && mChannelGeometry[detectorId].nX>0)
00323 return mChannelGeometry[detectorId].nX*mChannelGeometry[detectorId].nY;
00324 else{
00325 LOG_WARN<<"StFmsDbMaker::maxChannel: Corresponding channel geometry not found."<<endm;
00326 return -1;
00327 }
00328 }
00329
00330 Int_t StFmsDbMaker::detectorId(Int_t ew, Int_t ns, Int_t type){
00331 for(Int_t i=0; i<=mMaxDetectorId; i++)
00332 if((mChannelGeometry+i)){
00333 if(mChannelGeometry[i].ew == ew && mChannelGeometry[i].ns == ns && mChannelGeometry[i].type == type)
00334 return mChannelGeometry[i].detectorId;
00335 }
00336 LOG_WARN<<"StFmsDbMaker::detectorId: Corresponding channel geometry not found."<<endm;
00337 return -1;
00338 }
00339
00340 Int_t StFmsDbMaker::getRowNumber(Int_t detectorId, Int_t ch){
00341 if(maxChannel(detectorId)>0) return mChannelGeometry[detectorId].nY - (ch-1)/mChannelGeometry[detectorId].nX;
00342 return -1;
00343 }
00344
00345 Int_t StFmsDbMaker::getColumnNumber(Int_t detectorId, Int_t ch){
00346 if(maxChannel(detectorId)>0) return (ch-1)%mChannelGeometry[detectorId].nX + 1;
00347 return -1;
00348 }
00349
00350 Int_t StFmsDbMaker::getChannelNumber(Int_t detectorId, Int_t row, Int_t column){
00351 if(maxChannel(detectorId)>0) return column + mChannelGeometry[detectorId].nX * (mChannelGeometry[detectorId].nY - row);
00352 return -1;
00353 }
00354
00355 StThreeVectorF StFmsDbMaker::getDetectorOffset(Int_t detectorId){
00356 if(detectorId>=0 && detectorId<=mMaxDetectorId && maxChannel(detectorId)>0)
00357 return StThreeVectorF(mDetectorPosition[detectorId].xoffset, mDetectorPosition[detectorId].yoffset, mDetectorPosition[detectorId].zoffset);
00358 return StThreeVectorF(0, 0, 0);
00359 }
00360
00361 Float_t StFmsDbMaker::getXWidth(Int_t detectorId){
00362 if(detectorId>=0 && detectorId<=mMaxDetectorId)
00363 return mDetectorPosition[detectorId].xwidth; return -1;
00364 }
00365
00366 Float_t StFmsDbMaker::getYWidth(Int_t detectorId){
00367 if(detectorId>=0 && detectorId<=mMaxDetectorId)
00368 return mDetectorPosition[detectorId].ywidth; return -1;
00369 }
00370
00372 Int_t StFmsDbMaker::maxMap() {return mMaxMap;}
00373 void StFmsDbMaker::getMap(Int_t detectorId, Int_t ch, Int_t* qtCrate, Int_t* qtSlot, Int_t* qtChannel){
00374 if(detectorId<0 || detectorId>mMaxDetectorId || ch<1 || ch>maxChannel(detectorId) || mmMap[detectorId]==0 ){
00375 *qtCrate=0; *qtSlot=0; *qtChannel=0;
00376 return;
00377 }
00378 *qtCrate = mmMap[detectorId][ch-1].qtCrate;
00379 *qtSlot = mmMap[detectorId][ch-1].qtSlot;
00380 *qtChannel = mmMap[detectorId][ch-1].qtChannel;
00381 }
00382 void StFmsDbMaker::getReverseMap(Int_t qtCrate, Int_t qtSlot, Int_t qtChannel, Int_t* detectorId, Int_t* ch){
00383 if(qtCrate==0 && qtSlot==0 && qtChannel==0) {
00384 *detectorId = 0;
00385 *ch = 0;
00386 }else{
00387 *detectorId = mReverseMapDetectorId[qtCrate][qtSlot][qtChannel];
00388 *ch = mReverseMapChannel[qtCrate][qtSlot][qtChannel];
00389 }
00390 }
00391
00393 Int_t StFmsDbMaker::maxModule() {return mMaxModule;}
00394
00396 Int_t StFmsDbMaker::maxNS() {return mMaxNS;}
00397
00399 Int_t StFmsDbMaker::maxGain() {return mMaxGain;}
00400 Int_t StFmsDbMaker::maxGainCorrection() {return mMaxGainCorrection;}
00401 Float_t StFmsDbMaker::getGain(Int_t detectorId, Int_t ch){
00402 if(detectorId<0 || detectorId>mMaxDetectorId || ch<1 || ch>maxChannel(detectorId) || mmGain[detectorId]==0) return 0;
00403 return mmGain[detectorId][ch-1].gain;
00404 }
00405 Float_t StFmsDbMaker::getGainCorrection(Int_t detectorId, Int_t ch){
00406 if(detectorId<0 || detectorId>mMaxDetectorId || ch<1 || ch>maxChannel(detectorId) || mmGainCorrection[detectorId]==0) return 0;
00407 return mmGainCorrection[detectorId][ch-1].corr;
00408 }
00409
00411 void StFmsDbMaker::dumpFmsChannelGeometry(const Char_t* filename) {
00412 FILE* fp;
00413 LOG_INFO << "Writing "<<filename<<endm;
00414 if((fp=fopen(filename,"w"))){
00415 fprintf(fp,"maxDetectorId = %d\n",maxDetectorId());
00416 fprintf(fp," i detiid ew ns type nRow nCol maxCh\n");
00417 for(Int_t i=0; i<mMaxDetectorId+1; i++){
00418 fprintf(fp,"%5d%7d%4d%5d%5d%5d%5d%6d\n",
00419 i,detectorId(eastWest(i),northSouth(i),type(i)),eastWest(i),northSouth(i),type(i),
00420 nRow(i),nColumn(i),maxChannel(i));
00421 }
00422 for(Int_t i=0; i<mMaxDetectorId+1; i++){
00423 fprintf(fp,"DetectorId=%d\n",i);
00424 fprintf(fp,"detiid ch getCh getRow getCol\n");
00425 for(Int_t j=1; j<=maxChannel(i); j++){
00426 fprintf(fp,"%6d%4d%8d%8d%7d\n",
00427 i,j,getChannelNumber(i,getRowNumber(i,j),getColumnNumber(i,j)),getRowNumber(i,j),getColumnNumber(i,j));
00428 }
00429 }
00430 fclose(fp);
00431 }
00432 }
00433
00434 void StFmsDbMaker::dumpFmsDetectorPosition(const Char_t* filename) {
00435 FILE* fp;
00436 LOG_INFO << "Writing "<<filename<<endm;
00437 if((fp=fopen(filename,"w"))){
00438 fprintf(fp,"maxDetectorId = %d\n",maxDetectorId());
00439 fprintf(fp," detiid zoffset xoffset yoffset xwidth ywidth\n");
00440 for(Int_t i=0; i<mMaxDetectorId+1; i++)
00441 if((mDetectorPosition+i))
00442 fprintf(fp,"%8d%10.1f%10.2f%8.1f%10.3f%10.3f\n", i,getDetectorOffset(i).z(),getDetectorOffset(i).x(),getDetectorOffset(i).y(),getXWidth(i),getYWidth(i));
00443 fclose(fp);
00444 }
00445 }
00446
00447 void StFmsDbMaker::dumpFmsMap(const Char_t* filename) {
00448 FILE* fp;
00449 LOG_INFO << "Writing "<<filename<<endm;
00450 if((fp=fopen(filename,"w"))){
00451 fprintf(fp,"maxMap = %d\n",maxMap());
00452 fprintf(fp," i DetId ch crt slt qtch getmap() getReverseMap\n");
00453 for(Int_t i=0; i<mMaxMap; i++){
00454 Int_t d=mMap[i].detectorId;
00455 Int_t c=mMap[i].ch;
00456 Int_t crt,slot,ch,dd,cc;
00457 getMap(d,c,&crt,&slot,&ch);
00458 getReverseMap(crt,slot,ch,&dd,&cc);
00459 fprintf(fp,"%5d%6d%6d%5d%5d%5d%5d%5d%5d%5d%5d\n",
00460 i,d,c,mMap[i].qtCrate,mMap[i].qtSlot,mMap[i].qtChannel,crt,slot,ch,dd,cc);
00461 if(mMap[i].qtCrate>0 && (d-dd!=0 || c-cc!=0)) fprintf(fp,"Problem in reverse map!\n");
00462 }
00463 fclose(fp);
00464 }
00465 }
00466
00467 void StFmsDbMaker::dumpFmsPatchPanelMap(const Char_t* filename) {
00468 FILE* fp;
00469 LOG_INFO << "Writing "<<filename<<endm;
00470 if((fp=fopen(filename,"w"))){
00471 fprintf(fp," mod channel ppPanel ppRow ppColumn\n");
00472 for(Int_t i=0; i<mMaxModule; i++)
00473 for(Int_t j=0; j<maxChannel(i+8); j++)
00474 fprintf(fp,"%5d%8d%8d%6d%9d\n",i+1,j+1,mPatchPanelMap[i].ppPanel[j],mPatchPanelMap[i].ppRow[j],mPatchPanelMap[i].ppColumn[j]);
00475 fclose(fp);
00476 }
00477 }
00478
00479 void StFmsDbMaker::dumpFmsQTMap(const Char_t* filename) {
00480 FILE* fp;
00481 LOG_INFO << "Writing "<<filename<<endm;
00482 if((fp=fopen(filename,"w"))){
00483 fprintf(fp,"ns ppPanel row column crate slot channel\n");
00484 for(Int_t ns=0; ns<2; ns++)
00485 for(Int_t pp=0; pp<2; pp++)
00486 for(Int_t row=0; row<20; row++)
00487 for(Int_t col=0; col<16; col++){
00488 if(mQTMap[ns].qtCrate[pp][row][col]==0 && mQTMap[ns].qtSlot[pp][row][col]==0 && mQTMap[ns].qtChannel[pp][row][col]==0)
00489 fprintf(fp,"-1 -1 -1 -1 -1 -1 -1\n");
00490 else
00491 fprintf(fp,"%2d%8d%6d%7d%6d%5d%8d\n",ns+1, pp+1, row+1, col+1,mQTMap[ns].qtCrate[pp][row][col],mQTMap[ns].qtSlot[pp][row][col],
00492 mQTMap[ns].qtChannel[pp][row][col]);
00493 }
00494 fclose(fp);
00495 }
00496 }
00497
00498 void StFmsDbMaker::dumpFmsGain(const Char_t* filename) {
00499 FILE* fp;
00500 LOG_INFO << "Writing "<<filename<<endm;
00501 if((fp=fopen(filename,"w"))){
00502 fprintf(fp,"maxGain = %d\n",maxGain());
00503 fprintf(fp," i DetId ch gain getGain()\n");
00504 for(Int_t i=0; i<mMaxGain; i++){
00505 Int_t d=mGain[i].detectorId;
00506 Int_t c=mGain[i].ch;
00507 fprintf(fp,"%5d%6d%6d%8.3f%11.3f\n",
00508 i,d,c,mGain[i].gain,getGain(d,c));
00509 }
00510 fclose(fp);
00511 }
00512 }
00513
00514 void StFmsDbMaker::dumpFmsGainCorrection(const Char_t* filename) {
00515 FILE* fp;
00516 LOG_INFO << "Writing "<<filename<<endm;
00517 if((fp=fopen(filename,"w"))){
00518 fprintf(fp,"maxGainCorrection = %d\n",maxGainCorrection());
00519 fprintf(fp," i DetId ch gain getGainCorrection()\n");
00520 for(Int_t i=0; i<mMaxGainCorrection; i++){
00521 Int_t d=mGainCorrection[i].detectorId;
00522 Int_t c=mGainCorrection[i].ch;
00523 fprintf(fp,"%5d%6d%6d%8.3f%21.3f\n",
00524 i,d,c,mGainCorrection[i].corr,getGainCorrection(d,c));
00525 }
00526 fclose(fp);
00527 }
00528 }
00529