Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MdcGeomSvc Class Reference

#include <MdcGeomSvc.h>

Inheritance diagram for MdcGeomSvc:

IMdcGeomSvc IMdcGeomSvc List of all members.

Public Member Functions

void Dump ()
void Dump ()
const MdcGeoEnd *const End (unsigned id)
const MdcGeoEnd *const End (unsigned id)
virtual StatusCode finalize ()
virtual StatusCode finalize ()
const MdcGeoGeneral *const GeneralLayer (unsigned id)
const MdcGeoGeneral *const GeneralLayer (unsigned id)
const int getGeneralLayerSize ()
const int getGeneralLayerSize ()
const int getLayerSize ()
const int getLayerSize ()
const int getSegmentNo ()
const int getSegmentNo ()
const int getSuperLayerSize ()
const int getSuperLayerSize ()
const int getWireSize ()
const int getWireSize ()
void handle (const Incident &inc)
void handle (const Incident &inc)
 this handle function is prepared for special use
virtual StatusCode initialize ()
virtual StatusCode initialize ()
const MdcGeoLayer *const Layer (unsigned id)
const MdcGeoLayer *const Layer (unsigned id)
 MdcGeomSvc (const std::string &name, ISvcLocator *svcloc)
 MdcGeomSvc (const std::string &name, ISvcLocator *svcloc)
const MdcGeoMisc *const Misc (void)
const MdcGeoMisc *const Misc (void)
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
const MdcGeoSuper *const SuperLayer (unsigned id)
const MdcGeoSuper *const SuperLayer (unsigned id)
const MdcGeoWire *const Wire (unsigned lyrid, unsigned wirid)
const MdcGeoWire *const Wire (unsigned id)
const MdcGeoWire *const Wire (unsigned lyrid, unsigned wirid)
const MdcGeoWire *const Wire (unsigned id)
 ~MdcGeomSvc ()
 ~MdcGeomSvc ()

Static Public Member Functions

bool getSagFlag (void)
bool getSagFlag (void)
const InterfaceID & interfaceID ()
const InterfaceID & interfaceID ()

Static Public Attributes

bool m_doSag = true
bool m_nomcalignment = true
bool m_readAlignParDataBase = true

Private Member Functions

void clean ()
void clean ()
void Fill ()
void Fill ()
const int getAlignParIndexEast (int lyr) const
const int getAlignParIndexEast (int lyr) const
const int getAlignParIndexWest (int lyr) const
const int getAlignParIndexWest (int lyr) const
void ReadAliParDataBase (vector< double > &Sx, vector< double > &Sy, vector< double > &Sz, vector< double > &Rx, vector< double > &Ry, vector< double > &Rz)
void ReadAliParDataBase (vector< double > &Sx, vector< double > &Sy, vector< double > &Sz, vector< double > &Rx, vector< double > &Ry, vector< double > &Rz)
void ReadFilePar ()
void ReadFilePar ()
void ReadTensionDataBase (std::vector< double > &wireTensionVec)
void ReadTensionDataBase (std::vector< double > &wireTensionVec)
void ReadWirePosDataBase (std::vector< vector< double > > &wirePosVec)
void ReadWirePosDataBase (std::vector< vector< double > > &wirePosVec)

Private Attributes

vector< MdcGeoEnd * > fEnd
vector< MdcGeoEnd * > fEnd
vector< MdcGeoGeneralfGenerals
vector< MdcGeoGeneralfGenerals
vector< MdcGeoLayer * > fLayers
vector< MdcGeoLayer * > fLayers
MdcGeoMisc fMisc
vector< MdcGeoSuper * > fSupers
vector< MdcGeoSuper * > fSupers
vector< MdcGeoWire * > fWires
vector< MdcGeoWire * > fWires
std::string m_alignFilePath
int m_mindex
IDataProviderSvc * m_pCalibDataSvc
IDataProviderSvc * m_pCalibDataSvc
bool m_updataalign
double m_wholeRotatX
double m_wholeRotatY
double m_wholeRotatZ
double m_wholeShiftX
double m_wholeShiftY
double m_wholeShiftZ
std::string m_wirePosFilePath
std::string m_wireTensionFilePath

Constructor & Destructor Documentation

MdcGeomSvc::MdcGeomSvc const std::string &  name,
ISvcLocator *  svcloc
 

00030                                                                    : Service(name, svcloc) {
00031     if(getenv("MDCGEOMSVCROOT")){
00032         m_alignFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/MdcAlignPar.dat");
00033         //std::cout<<" the MDC alignment file: "<<m_alignFilePath<<std::endl;
00034 
00035         m_wirePosFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/WirePosCalib.dat");
00036         //std::cout<<" the MDC wire position  file: "<<m_wirePosFilePath<<std::endl;
00037 
00038         m_wireTensionFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/mdcWireTension.dat");
00039         //std::cout<<" the MDC wire tension file: "<<m_wireTensionFilePath<<std::endl;
00040 
00041     }
00042     else {
00043         std::cout<<"A fatal error, contact wangjk..."<<std::endl;
00044     }
00045 
00046     declareProperty("doSag",      m_doSag = true);
00047     declareProperty("readAlignParDataBase", m_readAlignParDataBase = true);
00048     declareProperty("mcnoalignment",m_nomcalignment=true);
00049     declareProperty("wholeShiftX",m_wholeShiftX = 0.);
00050     declareProperty("wholeShiftY",m_wholeShiftY = 0.);
00051     declareProperty("wholeShiftZ",m_wholeShiftZ = 0.);
00052     declareProperty("wholeRotatX",m_wholeRotatX = 0.);
00053     declareProperty("wholeRotatY",m_wholeRotatY = 0.);
00054     declareProperty("wholeRotatZ",m_wholeRotatZ = 0.);
00055     declareProperty("alignFilePath",m_alignFilePath);
00056     declareProperty("wirePosFilePath",m_wirePosFilePath);
00057     declareProperty("wireTensionFilePath",m_wireTensionFilePath);
00058     
00059 
00060 }

MdcGeomSvc::~MdcGeomSvc  ) 
 

00112                        {
00113     for(vector<MdcGeoLayer*>::iterator it1 = fLayers.begin(); it1 != fLayers.end(); it1++) delete *it1;
00114     for(vector<MdcGeoSuper*>::iterator it2 = fSupers.begin(); it2 != fSupers.end(); it2++) delete *it2;
00115     for(vector<MdcGeoWire*>::iterator it3 = fWires.begin(); it3 != fWires.end(); it3++) delete *it3;
00116     for(vector<MdcGeoEnd*>::iterator it4 = fEnd.begin(); it4 != fEnd.end(); it4++) delete *it4;  
00117     fGenerals.clear();
00118     fWires.clear();
00119     fLayers.clear();
00120     fSupers.clear();
00121     fEnd.clear();  
00122 }

MdcGeomSvc::MdcGeomSvc const std::string &  name,
ISvcLocator *  svcloc
 

MdcGeomSvc::~MdcGeomSvc  ) 
 


Member Function Documentation

void MdcGeomSvc::clean  )  [private]
 

void MdcGeomSvc::clean  )  [private]
 

00124                       {
00125     for(vector<MdcGeoLayer*>::iterator it1 = fLayers.begin(); it1 != fLayers.end(); it1++) delete *it1;
00126     for(vector<MdcGeoSuper*>::iterator it2 = fSupers.begin(); it2 != fSupers.end(); it2++) delete *it2;
00127     for(vector<MdcGeoWire*>::iterator it3 = fWires.begin(); it3 != fWires.end(); it3++) delete *it3;
00128     for(vector<MdcGeoEnd*>::iterator it4 = fEnd.begin(); it4 != fEnd.end(); it4++) delete *it4;
00129     fGenerals.clear();
00130     fWires.clear();
00131     fLayers.clear();
00132     fSupers.clear();
00133     fEnd.clear();
00134 }

void MdcGeomSvc::Dump  )  [virtual]
 

Implements IMdcGeomSvc.

void MdcGeomSvc::Dump  )  [virtual]
 

Implements IMdcGeomSvc.

00694 {}

const MdcGeoEnd* const MdcGeomSvc::End unsigned  id  ) 
 

const MdcGeoEnd *const MdcGeomSvc::End unsigned  id  ) 
 

00813                               {
00814         if (id < fEnd.size())     
00815             return  fEnd[id];
00816 
00817         return 0;
00818     }  

void MdcGeomSvc::Fill  )  [private]
 

void MdcGeomSvc::Fill  )  [private]
 

virtual StatusCode MdcGeomSvc::finalize  )  [virtual]
 

StatusCode MdcGeomSvc::finalize  )  [virtual]
 

00106                                   {
00107     MsgStream log(messageService(), name());
00108     log << MSG::INFO << name() << ": End of Run" << endreq;
00109     return StatusCode::SUCCESS;
00110 }

const MdcGeoGeneral* const MdcGeomSvc::GeneralLayer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

const MdcGeoGeneral *const MdcGeomSvc::GeneralLayer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

00800                                        {
00801         if (id < fGenerals.size()) 
00802             return & fGenerals[id];
00803 
00804         return 0;
00805     }

const int MdcGeomSvc::getAlignParIndexEast int  lyr  )  const [private]
 

const int MdcGeomSvc::getAlignParIndexEast int  lyr  )  const [private]
 

the Mdc small endplate east

the 1th ring east

the 2th ring east

the 3th ring east

the 4th ring east

the 5th ring east

the 6th ring east

the Mdc big endplate east

00696                                                        {
00698     if((lyr>=0) && (lyr<=16))  return 0;  
00700     else if((lyr>=17) && (lyr<=20)) return 1;
00702     else if((lyr>=21) && (lyr<=24)) return 2;
00704     else if((lyr>=25) && (lyr<=28)) return 3;
00706     else if((lyr>=29) && (lyr<=32)) return 4;
00708     else if((lyr>=33) && (lyr<=36)) return 5;
00710     else if((lyr>=37) && (lyr<=41)) return 6;
00712     else if(lyr>=42) return 7; 
00713     else std::cout<<" Hi, ERROR OCCUR !!!"<<std::endl;
00714     return -1;
00715 }

const int MdcGeomSvc::getAlignParIndexWest int  lyr  )  const [private]
 

const int MdcGeomSvc::getAlignParIndexWest int  lyr  )  const [private]
 

the Mdc small endplate west

the 1th ring west

the 2th ring west

the 3th ring west

the 4th ring west

the 5th ring west

the 6th ring west

the Mdc big endplate west

00718                                                        {
00720     if((lyr>=0) && (lyr<=16))  return 8;
00722     else if((lyr>=17) && (lyr<=20)) return 9;
00724     else if((lyr>=21) && (lyr<=24)) return 10;
00726     else if((lyr>=25) && (lyr<=28)) return 11;
00728     else if((lyr>=29) && (lyr<=32)) return 12;
00730     else if((lyr>=33) && (lyr<=36)) return 13;
00732     else if((lyr>=37) && (lyr<=41)) return 14;
00734     else if(lyr>=42) return 15;
00735     else std::cout<<" Hi, ERROR OCCUR !!!"<<std::endl;
00736     return -1;
00737 }

const int MdcGeomSvc::getGeneralLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

const int MdcGeomSvc::getGeneralLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

00685 {
00686     return fGenerals.size();
00687 }

const int MdcGeomSvc::getLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

const int MdcGeomSvc::getLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

00675 {
00676     return fLayers.size();
00677 }

bool MdcGeomSvc::getSagFlag void   )  [static]
 

bool MdcGeomSvc::getSagFlag void   )  [static]
 

00821                                 {
00822 
00823     return m_doSag;
00824 }  

const int MdcGeomSvc::getSegmentNo  ) 
 

const int MdcGeomSvc::getSegmentNo  ) 
 

00690 {
00691     return fEnd.size();
00692 }   

const int MdcGeomSvc::getSuperLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

const int MdcGeomSvc::getSuperLayerSize  )  [virtual]
 

Implements IMdcGeomSvc.

00680 {
00681     return fSupers.size();
00682 }

const int MdcGeomSvc::getWireSize  )  [virtual]
 

Implements IMdcGeomSvc.

const int MdcGeomSvc::getWireSize  )  [virtual]
 

Implements IMdcGeomSvc.

00670 {
00671     return fWires.size();
00672 }

void MdcGeomSvc::handle const Incident &  inc  ) 
 

void MdcGeomSvc::handle const Incident &  inc  ) 
 

this handle function is prepared for special use

00741                                           {
00742     MsgStream log( messageService(), name() );
00743     log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00744     IDataProviderSvc* m_eventSvc;
00745     Gaudi::svcLocator()->service("EventDataSvc", m_eventSvc, true);
00746     SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader");
00747     if (!eventHeader) { 
00748     log << MSG::FATAL << "Could not find Event Header" << endreq;
00749       }
00750     if (m_updataalign) return;
00751     if (inc.type() == "NewRun" ){
00752         log << MSG::DEBUG << "Begin Event" << endreq;
00753         clean();
00754         m_updataalign = true;
00755     if(m_nomcalignment&&m_mindex==0) {  
00756         int   RunNo=eventHeader->runNumber();
00757         if(RunNo<0)  m_readAlignParDataBase=false ;
00758            else   m_readAlignParDataBase=true;
00759         m_mindex+=1;
00760     cout<<"m__RunNo="<<RunNo<<"m_mindex="<<m_mindex<<endl;
00761         }
00762    //std::cout<<"############"<<m_readAlignParDataBase<<std::endl;
00763         ReadFilePar();          
00764     }
00765 }

virtual StatusCode MdcGeomSvc::initialize  )  [virtual]
 

StatusCode MdcGeomSvc::initialize  )  [virtual]
 

00072                                     {
00073     MsgStream log(messageService(), name());
00074     log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00075 
00076     StatusCode sc = Service::initialize();
00077     if ( sc.isFailure() ) return sc;
00078     m_mindex=0; 
00079     m_updataalign = false;
00080     IIncidentSvc* incsvc;
00081     sc = service("IncidentSvc", incsvc);
00082     int priority = 100;
00083     if( sc.isSuccess() ){
00084         incsvc -> addListener(this, "NewRun", priority);
00085     }
00086 
00087     //    ReadFilePar(); //  get geometry data from file SimUtil/dat/Mdc.txt
00088     // Fill();  //  get geometry data from Database
00089 
00090     sc = service("CalibDataSvc", m_pCalibDataSvc, true);
00091 
00092     if ( !sc.isSuccess() ) {
00093         log << MSG::ERROR 
00094             << "Could not get IDataProviderSvc interface of CalibXmlCnvSvc" 
00095             << endreq;
00096         return sc;
00097     } else {
00098         log << MSG::DEBUG 
00099             << "Retrieved IDataProviderSvc interface of CalibXmlCnvSvc" 
00100             << endreq;
00101     }
00102      ReadFilePar(); 
00103     return StatusCode::SUCCESS;
00104 }

const InterfaceID& IMdcGeomSvc::interfaceID  )  [inline, static, inherited]
 

00017 { return IID_IMdcGeomSvc; } 

const InterfaceID& IMdcGeomSvc::interfaceID  )  [inline, static, inherited]
 

00017 { return IID_IMdcGeomSvc; } 

const MdcGeoLayer* const MdcGeomSvc::Layer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

const MdcGeoLayer *const MdcGeomSvc::Layer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

00784                                 {
00785         if (id < fLayers.size())
00786             return  fLayers[id];
00787 
00788         return 0;
00789     }

const MdcGeoMisc* const MdcGeomSvc::Misc void   ) 
 

const MdcGeoMisc *const MdcGeomSvc::Misc void   ) 
 

00808                     {
00809     return & fMisc;
00810 }

virtual StatusCode MdcGeomSvc::queryInterface const InterfaceID &  riid,
void **  ppvUnknown
[virtual]
 

StatusCode MdcGeomSvc::queryInterface const InterfaceID &  riid,
void **  ppvUnknown
[virtual]
 

00062                                                                                    {
00063 
00064     if ( IID_IMdcGeomSvc.versionMatch(riid) ) { 
00065         *ppvInterface = static_cast<IMdcGeomSvc*> (this); 
00066     } else { 
00067         return Service::queryInterface(riid, ppvInterface) ; 
00068     }
00069     return StatusCode::SUCCESS;
00070 }

void MdcGeomSvc::ReadAliParDataBase vector< double > &  Sx,
vector< double > &  Sy,
vector< double > &  Sz,
vector< double > &  Rx,
vector< double > &  Ry,
vector< double > &  Rz
[private]
 

void MdcGeomSvc::ReadAliParDataBase vector< double > &  Sx,
vector< double > &  Sy,
vector< double > &  Sz,
vector< double > &  Rx,
vector< double > &  Ry,
vector< double > &  Rz
[private]
 

00639                                                                    {
00640     MsgStream log(messageService(), name());
00641     std::string fullPath = "/Calib/MdcAlign";
00642     log << MSG::INFO<<"ReadAliParDataBase() alignParPath = "<<fullPath<< endreq;
00643     cout << "Read alignment parameters from Calibration Database!" << endl;
00644 
00645     SmartDataPtr<CalibData::MdcAlignData> alignpar(m_pCalibDataSvc, fullPath);
00646     if( ! alignpar){
00647         log << MSG::ERROR << "can not get MdcAlignConst via SmartPtr" 
00648             << endreq;
00649         return;
00650     }
00651     double tmp1,tmp2,tmp3,tmp4,tmp5,tmp6;
00652     for(int k=0;k<16;k++){
00653         tmp1 = alignpar->getdxEP(k);
00654         tmp2 = alignpar->getdyEP(k);
00655         tmp3 = alignpar->getdzEP(k);
00656         tmp4 = alignpar->getrxEP(k);
00657         tmp5 = alignpar->getryEP(k);
00658         tmp6 = alignpar->getrzEP(k);
00659 
00660         Sx.push_back(m_wholeShiftX+tmp1);
00661         Sy.push_back(m_wholeShiftY+tmp2);
00662         Sz.push_back(m_wholeShiftZ+tmp3);
00663         Rx.push_back(m_wholeRotatX+tmp4);
00664         Ry.push_back(m_wholeRotatY+tmp5);
00665         Rz.push_back(m_wholeRotatZ+tmp6);
00666     }
00667 
00668 }

void MdcGeomSvc::ReadFilePar  )  [private]
 

void MdcGeomSvc::ReadFilePar  )  [private]
 

test

read alignment file

test the service for(int m=0;m<16;m++) std::cout<<" Rz["<<m<<"] is: "<<Rz[m]<<std::endl;

signalLayer is the index of this signalLayer in all the layers

in this loop we read the file and store them into according vectors

wireNo is the total wire number of this layer, including both signal wire& field wire

CLHEP says that: static const double radian = 1.; static const double degree = (3.14159265358979323846/180.0)*radian static const double deg = degree;

Variables used here are as follows, MdcGeoGeneral hlh; MdcGeoSuper* suph; MdcGeoLayer* lh; MdcGeoWire* wh; MdcGeoEnd* end;

attention, it is 2*twopi means 4*pi

calculate the phi angle of the sense wire of the first cell of the layer

Wirst is the the global number of the first signal wire of this layer in all the signal wire

wh is signal wire

caluculate misaligned wire position

attention wLength[lyr] not the true length of the wire

test std::cout<<" wireId: "<<wireId<<" backward position:"<< wh->Backward()<<" forward position: "<<wh->Forward()<<std::endl;

set the tension and wire sag

because of just before have fLayers.push_back(lh); so use it2 = fLayers.end()-1 to get the MdcGeoLayer which have just push_back into the stack

00137                             {
00138     std::string geometryFilePath = getenv("MDCSIMROOT");
00139     geometryFilePath += "/dat/Mdc.txt";
00140     std::ifstream inFile(geometryFilePath.c_str() );
00141 
00142     if(!inFile.good()){
00143         std::cout<<"Error, mdc parameters file not exist"<<std::endl; 
00144         return;
00145     }
00146     std::string alignFilePath;
00147     std::string wirePosFilePath;
00148     std::string wireTensionFilePath;
00149     if (!m_updataalign) {
00150         alignFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/MdcAlignPar.dat");
00151         wirePosFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/WirePosCalib.dat");
00152         wireTensionFilePath = std::string(getenv("MDCGEOMSVCROOT"))+std::string("/share/mdcWireTension.dat");
00153     } else {
00154         alignFilePath = m_alignFilePath;
00155         wirePosFilePath = m_wirePosFilePath;
00156         wireTensionFilePath = m_wireTensionFilePath;
00157     }
00158     std::ifstream alignFile(alignFilePath.c_str()); 
00159     std::ifstream wirePosFile(wirePosFilePath.c_str());
00160     std::ifstream wireTensionFile(wireTensionFilePath.c_str());
00161 
00162     if(!wirePosFile){
00163         std::cout<<"Error, mdc wire position file not exist..."<<std::endl;
00164     }
00165 
00166     if(!wireTensionFile){
00167         std::cout<<"Error, mdc wire tension file not exist..."<<std::endl;
00168     }
00169 
00170       std::vector<double> wireTensionVec;
00171     //cout << __FILE__ << "    " << __LINE__ << "  readdb = " << m_readAlignParDataBase
00172     //    << "   update align = " << m_updataalign << endl;
00173     if (m_readAlignParDataBase && m_updataalign) {
00174         ReadTensionDataBase(wireTensionVec);
00175     }else {
00176         cout << "Read wireTension from file:" << wireTensionFilePath.c_str() << endl;
00177         int idd;
00178         double tension;
00179         for(int ii=0; ii<6796; ii++){
00180             wireTensionFile>>idd>>tension;
00181 
00182             if(getSagFlag()){
00183                 wireTensionVec.push_back(tension);
00184             }
00185             else { 
00186                 tension = DBL_MAX;
00187                 wireTensionVec.push_back(tension);
00188             }
00189         }
00190     }
00191 
00192     std::vector<vector<double> > wirePosVec(6796);
00193     if (m_readAlignParDataBase && m_updataalign) {
00194         ReadWirePosDataBase(wirePosVec);
00195     } else {
00196         cout << "Read wirePosition from file:" << wirePosFilePath.c_str() << endl;
00197         double dxe,dye,dze,dxw,dyw,dzw;
00198         int wid;
00199         std::string title; 
00200         getline(wirePosFile, title);
00201         wirePosFile.seekg(1,ios::cur);
00202         for(int j=0; j<6796; j++){
00203             wirePosFile>>wid>>dxe>>dye>>dze>>dxw>>dyw>>dzw; 
00204             wirePosVec[j].push_back(dxe);
00205             wirePosVec[j].push_back(dye);
00206             wirePosVec[j].push_back(dze);
00207             wirePosVec[j].push_back(dxw);
00208             wirePosVec[j].push_back(dyw);
00209             wirePosVec[j].push_back(dzw);
00211             /*
00212                for(int jj=0;jj<6;jj++){
00213                std::cout<<" wid: "<<wid<<" dxe: "<<wirePosVec[j][0]<<" dye: "<<wirePosVec[j][1]<<" dze: "<<wirePosVec[j][2]<<" dxw: "<<wirePosVec[j][3]<<" dyw: "<<wirePosVec[j][4]<<" dzw: "<<wirePosVec[j][5]<<std::endl;
00214                }
00215                */
00216         }
00217     }
00218 
00219     double signalWireR, fieldWireR;
00220     int TLayerNo, TWireNo,TSignalLayerNo,fSignalLayer[50];  
00221     int i,wireNo, firstWire,segmentNo,signalLayer;
00222     double length, nomphi, phi, r,nomaadiv2, aadiv2,
00223            nomaa, aa, nomrotateCell, rotateCell, wlength, innerR, outR, z;
00224     std::string layer, name, line;
00225 
00226     vector<int> WireNo, fSegmentNo;
00227     vector<double> wLength, R, nomPhi, Phi,nomadiv2, adiv2, First, 
00228         noma, a, nomebusing, ebusing, nomsigma, sigma, nomdeltaz, deltaz,
00229         nomRotate, Rotate, fLength, fInnerR, fOutR, fZ;
00230     vector<string> LayerName, fName;  
00231     vector<double> Sx,Sy,Sz,Rx,Ry,Rz;
00232     double tmp1,tmp2,tmp3,tmp4,tmp5,tmp6;
00233 
00235 
00236     if (m_readAlignParDataBase && m_updataalign) {
00237         ReadAliParDataBase(Sx, Sy, Sz, Rx, Ry, Rz);
00238     } else {
00239         cout << "Read alignment parameters from file:" << alignFilePath.c_str() << endl;
00240         getline(alignFile, line);
00241         alignFile.seekg(1,ios::cur);
00242         for(int k=0;k<16;k++){
00243             alignFile>>line>>tmp1>>tmp2>>tmp3>>tmp4>>tmp5>>tmp6;   
00244             //changed by luot 10.03.12
00245             //if (!m_updataalign) {
00246             //    tmp1 = 0.0;
00247             //    tmp2 = 0.0;
00248             //    tmp3 = 0.0;
00249             //    tmp4 = 0.0;
00250             //    tmp5 = 0.0;
00251             //    tmp6 = 0.0;
00252             //}
00253             Sx.push_back(m_wholeShiftX+tmp1);
00254             Sy.push_back(m_wholeShiftY+tmp2);
00255             Sz.push_back(m_wholeShiftZ+tmp3);
00256             Rx.push_back(m_wholeRotatX+tmp4);
00257             Ry.push_back(m_wholeRotatY+tmp5);
00258             Rz.push_back(m_wholeRotatZ+tmp6);
00259         }
00262     }
00263 
00264     getline(inFile, line);
00265     inFile>>TLayerNo>>TWireNo>>TSignalLayerNo>>signalWireR>>fieldWireR;
00266     inFile.seekg(1,ios::cur);
00267     getline(inFile, line);
00268     for( i=0; i<TSignalLayerNo; i++){
00269         inFile>>signalLayer;
00271         fSignalLayer[i]=signalLayer-1;
00272     }
00273 
00274     inFile.seekg(1,ios::cur);
00275     getline(inFile, line);
00276     getline(inFile, line);
00277 
00278     int i_east,i_west;   
00279     double delta_rotateCell;
00281     for( i=0; i<TLayerNo; i++){
00282         i_east=getAlignParIndexEast(i);
00283         i_west=getAlignParIndexWest(i); 
00284 
00285         inFile>>layer>>wireNo>>wlength>>r>>nomphi>>firstWire>>nomrotateCell;
00286         getline(inFile, line);
00287 
00290         nomaadiv2=2*pi*nomrotateCell/wireNo; 
00291         //aadiv2=2*pi*rotateCell/wireNo+0.5*(Rz[i_west]-Rz[i_east]);
00292         nomaa=2*r*sin(nomaadiv2);
00293         delta_rotateCell=(Rz[i_west]-Rz[i_east])*wireNo/(4*pi);
00294         rotateCell=nomrotateCell+delta_rotateCell;
00295         aadiv2=2*pi*rotateCell/wireNo;
00296         aa=2*r*sin(aadiv2);
00297 
00298         double shiftPhi=twopi/wireNo;
00299         nomphi*=deg;
00300         if(nomphi<0) nomphi += shiftPhi; //By definition, phi of first wire must >=0
00301         phi=nomphi+Rz[i_east];
00302         LayerName.push_back(layer);
00303         WireNo.push_back(wireNo);
00304         wLength.push_back(wlength);
00305         R.push_back(r);
00306         nomPhi.push_back(nomphi);
00307         Phi.push_back(phi);
00308         //nomadiv2.push_back(nomaadiv2);
00309         //adiv2.push_back(aadiv2);
00310         First.push_back(firstWire);
00311         //noma.push_back(nomaa);
00312         a.push_back(aa);
00317 
00318         nomebusing.push_back(atan(nomaa/wlength));
00319         ebusing.push_back(atan(aa/wlength));
00320 
00321         //if(aa==0.0) sigma.push_back(0.0);
00322         //else  sigma.push_back(0.13*wlength/aa);
00323         //nomdeltaz.push_back(r*(1.0-cos(nomaadiv2)));
00324         //deltaz.push_back(r*(1.0-cos(aadiv2)));
00325         nomRotate.push_back(nomrotateCell);
00326         Rotate.push_back(rotateCell);
00327     }
00328 
00329     getline(inFile, line);
00330     inFile>>segmentNo;  
00331     inFile.seekg(1,ios::cur);
00332     getline(inFile, line);
00333     getline(inFile, line);
00334 
00335     for(i=0; i<segmentNo; i++){
00336         inFile>>length>>innerR>>outR>>z>>name;
00337         getline(inFile,line);
00338         fLength.push_back(length);
00339         fInnerR.push_back(innerR);
00340         fOutR.push_back(outR);
00341         fZ.push_back(z);
00342         fName.push_back(name);
00343     }
00344 
00351 
00352     //MdcGeoGeneral include signal wire and field wire
00353     MdcGeoGeneral hlh;
00354     double a1,a2,a3,nomphi0,phi0,cellphi;
00355     double noma1,noma2,noma3;
00356     for(i=0;i<TLayerNo;i++){
00357         i_east=getAlignParIndexEast(i);
00358         i_west=getAlignParIndexWest(i);
00359         hlh.Id(i);
00360         hlh.LayerName(LayerName[i]);    
00361         hlh.Radius(R[i]);
00362         hlh.Length(wLength[i]);
00363         hlh.NCell(WireNo[i]/2);
00364         //east endcap rotates away from designed position by Phi considering misalignment,
00365         //nomPhi without considering misalignment 
00366         hlh.Offset(Phi[i]);
00367         hlh.nomOffset(nomPhi[i]);
00368         hlh.Phi(Phi[i]);    
00369         hlh.nomPhi(nomPhi[i]);
00370         hlh.First((int)First[i]); 
00371         HepPoint3D offF(Sx[i_west],Sy[i_west],Sz[i_west]); 
00372         HepPoint3D offB(Sx[i_east],Sy[i_east],Sz[i_east]);
00373         hlh.OffF(offF);
00374         hlh.OffB(offB);
00375         hlh.TwistF(Rz[i_west]);
00376         hlh.TwistB(Rz[i_east]);
00377         //west endcap rotates away from designed position by Rotate considering misalignment,
00378         //nomRotate without considering misalignment 
00379         hlh.Shift(Rotate[i]);
00380         hlh.nomShift(nomRotate[i]);
00381         hlh.SxEast(Sx[i_east]);
00382         hlh.SxWest(Sx[i_west]);
00383         hlh.SyEast(Sy[i_east]);
00384         hlh.SyWest(Sy[i_west]);
00385         hlh.SzEast(Sz[i_east]);
00386         hlh.SzWest(Sz[i_west]);
00387 
00388         hlh.RxEast(Rx[i_east]);
00389         hlh.RxWest(Rx[i_west]);
00390         hlh.RyEast(Ry[i_east]);
00391         hlh.RyWest(Ry[i_west]);
00392         hlh.RzEast(Rz[i_east]);
00393         hlh.RzWest(Rz[i_west]);
00394         fGenerals.push_back(hlh);
00395     }
00396 
00397     MdcGeoSuper *suph;
00398     for(i=0;i<TSignalLayerNo;i++){
00399         //MdcGeoLayer only represent signal wires
00400         MdcGeoLayer *lh = new MdcGeoLayer();
00401         // lh is a signalwire layer 
00402         int lyr=fSignalLayer[i];
00403         // the value of lyr starts from 1,because the first layer of MDC is field
00404         // wire
00405         i_east=getAlignParIndexEast(lyr);
00406         i_west=getAlignParIndexWest(lyr);
00407         lh->SLayer(lyr+1);  
00408         if(i%4==0){
00409             suph = new MdcGeoSuper();
00410             suph->LowerR(R[lyr-1]);
00411             if(i==40){
00412                 suph->UpperR(R[lyr+5]);
00413             }
00414             else {
00415                 suph->UpperR(R[lyr+7]);
00416             }
00417             switch(i/4){
00418                 case 0: suph->Type(-1); break;
00419                 case 1: suph->Type( 1); break;
00420                 case 2: suph->Type( 0); break;
00421                 case 3: suph->Type( 0); break;
00422                 case 4: suph->Type( 0); break;
00423                 case 5: suph->Type(-1); break;
00424                 case 6: suph->Type( 1); break;
00425                 case 7: suph->Type(-1); break;
00426                 case 8: suph->Type( 1); break;
00427                 case 9: suph->Type( 0); break;
00428                 case 10: suph->Type(0); break;
00429                 default: break;
00430             }
00431             suph->Id(i/4);
00432             fSupers.push_back(suph);
00433         }
00435         cellphi=2*twopi/WireNo[lyr];
00437         phi0=Phi[lyr]+abs(First[lyr]-1)*(cellphi/2);
00438         nomphi0=nomPhi[lyr]+abs(First[lyr]-1)*(cellphi/2);
00439         lh->Id(i);
00440         int wircount=0;
00441         for(int wk=0; wk<i; wk++){
00442             int lyrwk=fSignalLayer[wk];
00443             wircount=wircount + WireNo[lyrwk]/2;
00444         };
00447         lh->Wirst(wircount);
00448         lh->Slant(ebusing[lyr]);
00449         lh->nomSlant(nomebusing[lyr]);
00450         lh->Radius(R[lyr]);
00451         lh->Length(wLength[lyr]);
00452         lh->RCSiz1(R[lyr]-R[lyr-1]);
00453         lh->RCSiz2(R[lyr+1]-R[lyr]);
00454         lh->PCSiz(R[lyr]*cellphi);
00455         lh->NCell(WireNo[lyr]/2);
00456         lh->Offset(phi0);
00457         lh->Shift(Rotate[lyr]);
00458         lh->nomOffset(nomphi0);
00459         lh->nomShift(nomRotate[lyr]);
00460 
00461         vector<MdcGeoSuper*>::iterator it1 = fSupers.end()-1;
00462         lh->Sup(* it1);
00463         fLayers.push_back(lh);
00464         int geo = -1;
00465         if (i < 8) {
00466             geo = i * 2 + 1;
00467         } else if (i < 20) {
00468             geo = i * 2 + 2;
00469         } else if (i < 36) {
00470             geo = i * 2 + 3;
00471         } else {
00472             geo = i * 2 + 4;
00473         } 
00474         lh->Gen(geo);
00475 
00476         for(int j=0;j<WireNo[lyr]/2;j++){
00478             MdcGeoWire *wh = new MdcGeoWire();
00479             const int wireId = wircount+j;
00480             wh->Id(wireId);
00481 
00483             a1 = R[lyr]*cos(phi0+j*cellphi)+Sx[i_east]+wirePosVec[wireId][0];
00484             a2 = R[lyr]*sin(phi0+j*cellphi)+Sy[i_east]+wirePosVec[wireId][1];
00485             a3 = wLength[lyr]/2+wirePosVec[wireId][2]+Sz[i_east];
00486             //a3 = wLength[lyr]/2+wirePosVec[wireId][2];
00487             //MDC rotate around x firstly;
00488             double xb = a1;
00489             double yb = a2 * cos(Rx[i_east]) + a3 * sin(Rx[i_east]);
00490             double zb = a3 * cos(Rx[i_east]) - a2 * sin(Rx[i_east]);
00491 
00492             //then MDC rotate around y;
00493             double xbnew = xb * cos(Ry[i_east]) - zb * sin(Ry[i_east]);
00494             double ybnew = yb;
00495             double zbnew = xb * sin(Ry[i_east]) + zb * cos(Ry[i_east]);
00497             noma1 = R[lyr]*cos(nomphi0+j*cellphi);
00498             noma2 = R[lyr]*sin(nomphi0+j*cellphi);
00500             noma3 = wLength[lyr]/2;
00501             //HepPoint3D pb(a1,a2,a3);
00502             HepPoint3D pb(xbnew,ybnew,zbnew);
00503             HepPoint3D nompb(noma1,noma2,noma3);
00504             HepPoint3D wireposb(wirePosVec[wireId][0],wirePosVec[wireId][1],wirePosVec[wireId][2]);
00505             wh->Backward(pb);
00506             wh->nomBackward(nompb);
00507             wh->BWirePos(wireposb);
00508 
00509             //double g1 = noma1*cos(Rz[i_east]) - noma2*sin(Rz[i_east]) + Sx[i_east] + wirePosVec[wireId][0];
00510             //double g2 = noma2*cos(Rz[i_east]) + noma1*sin(Rz[i_east]) + Sy[i_east] + wirePosVec[wireId][1];
00511             //double g3 = noma3 + wirePosVec[wireId][2];
00512             //HepPoint3D backward_test(g1,g2,g3);
00513 
00514             a1 = R[lyr]*cos(phi0+(j+lh->Shift())*cellphi)+Sx[i_west]+wirePosVec[wireId][3];
00515             a2 = R[lyr]*sin(phi0+(j+lh->Shift())*cellphi)+Sy[i_west]+wirePosVec[wireId][4];
00516             //a3 = -wLength[lyr]/2+wirePosVec[wireId][5];
00517             a3 = -wLength[lyr]/2+wirePosVec[wireId][5]+Sz[i_west];
00518             //MDC rotate around x firstly;
00519             double xf = a1;
00520             double yf = a2 * cos(Rx[i_west]) + a3 * sin(Rx[i_west]);
00521             double zf = a3 * cos(Rx[i_west]) - a2 * sin(Rx[i_west]);
00522 
00523             //then MDC rotate around y;
00524             double xfnew = xf * cos(Ry[i_west]) - zf * sin(Ry[i_west]);
00525             double yfnew = yf;
00526             double zfnew = xf * sin(Ry[i_west]) + zf * cos(Ry[i_west]);
00527 
00528             noma1 = R[lyr]*cos(nomphi0+(j+lh->nomShift())*cellphi);
00529             noma2 = R[lyr]*sin(nomphi0+(j+lh->nomShift())*cellphi);
00530             noma3 = -wLength[lyr]/2;
00531             //HepPoint3D pf(a1,a2,a3);
00532             HepPoint3D pf(xfnew, yfnew, zfnew);
00533             HepPoint3D nompf(noma1,noma2,noma3);
00534             HepPoint3D wireposf(wirePosVec[wireId][3],wirePosVec[wireId][4],wirePosVec[wireId][5]);
00535             wh->Forward(pf);
00536             wh->nomForward(nompf);
00537             wh->FWirePos(wireposf);
00538 
00539             //double f1 = noma1*cos(Rz[i_west]) - noma2*sin(Rz[i_west]) + Sx[i_west] + wirePosVec[wireId][3];
00540             //double f2 = noma2*cos(Rz[i_west]) + noma1*sin(Rz[i_west]) + Sy[i_west] + wirePosVec[wireId][4];
00541             //double f3 = noma3 + wirePosVec[wireId][5];
00542             //HepPoint3D forward_test(f1,f2,f3);
00545             wh->Layer(i);
00546             wh->Cell(j);
00547             wh->Stat(0);
00548             wh->Slant(ebusing[lyr]);
00549             wh->nomSlant(nomebusing[lyr]);
00550 
00552             wh->Tension(wireTensionVec[wireId]);
00553             //std::cout<<"  wh->Tension: "<< wh->Tension()<<std::endl;
00554             //std::cout<<" wire sag: "<<wh->Sag(wireId)<<std::endl;
00555 
00559             vector<MdcGeoLayer*>::iterator it2 = fLayers.end()-1;
00560             wh->Lyr(* it2);
00561             fWires.push_back(wh);
00562         }
00563     }
00564 
00565     fMisc.OuterR(fOutR[1]);
00566     fMisc.InnerR(fInnerR[2]);
00567     fMisc.OuterTk(fOutR[1]-fInnerR[1]);
00568     fMisc.InnerTk(fOutR[2]-fInnerR[2]);
00569     fMisc.NSWire(fWires.size());
00570     fMisc.NFWire(TWireNo-fWires.size());
00571 
00572     fMisc.LayerNo(TLayerNo);
00573     fMisc.WireNo(TWireNo);
00574     fMisc.SLayerNo(TSignalLayerNo);
00575     fMisc.SWireR(signalWireR);
00576     fMisc.FWireR(fieldWireR);
00577 
00578     for(i=0;i<segmentNo;i++){
00579         MdcGeoEnd * end=new MdcGeoEnd();
00580         end->Id(i);
00581         end->Length(fLength[i]);
00582         end->InnerR(fInnerR[i]);
00583         end->OutR(fOutR[i]);
00584         end->Z(fZ[i]);
00585         end->Name(fName[i]);
00586         fEnd.push_back(end);
00587     }
00588 }

void MdcGeomSvc::ReadTensionDataBase std::vector< double > &  wireTensionVec  )  [private]
 

void MdcGeomSvc::ReadTensionDataBase std::vector< double > &  wireTensionVec  )  [private]
 

00590                                                                       {
00591     std::string fullPath = "/Calib/MdcAlign";
00592     MsgStream log(messageService(), name());
00593     log << MSG::INFO<<"ReadTensionDataBase() wireTensionPath = "<<fullPath<< endreq;
00594     cout << "Read wireTension from Calibration Database!" << endl;
00595 
00596     SmartDataPtr<CalibData::MdcAlignData> tension(m_pCalibDataSvc, fullPath);
00597     if( ! tension){
00598         log << MSG::ERROR << "can not get MdcAlignConst via SmartPtr" 
00599             << endreq;
00600         return;
00601     }
00602     for(int i=0;i<6796;i++){
00603         double tens = tension->gettension(i);
00604         wireTensionVec.push_back(tens);
00605     }
00606 }

void MdcGeomSvc::ReadWirePosDataBase std::vector< vector< double > > &  wirePosVec  )  [private]
 

void MdcGeomSvc::ReadWirePosDataBase std::vector< vector< double > > &  wirePosVec  )  [private]
 

00607                                                                            {
00608     std::string fullPath = "/Calib/MdcAlign";
00609     MsgStream log(messageService(), name());
00610     log << MSG::INFO<<"ReadWirePosDataBase() wirePositionPath = "<<fullPath<< endreq;
00611 
00612     cout << "Read wirePosition from Calibration Database!" << endl;
00613     SmartDataPtr<CalibData::MdcAlignData> wirepos(m_pCalibDataSvc, fullPath);
00614     if( ! wirepos){
00615         log << MSG::ERROR << "can not get MdcAlignConst via SmartPtr" 
00616             << endreq;
00617         return;
00618     }
00619     double dxe,dye,dze,dxw,dyw,dzw;
00620     for(int j=0; j<6796; j++){
00621 
00622         dxe = wirepos->getdxWireEast(j);
00623         dye = wirepos->getdyWireEast(j);
00624         dze = wirepos->getdzWireEast(j);
00625         dxw = wirepos->getdxWireWest(j);
00626         dyw = wirepos->getdyWireWest(j);
00627         dzw = wirepos->getdzWireWest(j);
00628 
00629         wirePosVec[j].push_back(dxe);
00630         wirePosVec[j].push_back(dye);
00631         wirePosVec[j].push_back(dze);
00632         wirePosVec[j].push_back(dxw);
00633         wirePosVec[j].push_back(dyw);
00634         wirePosVec[j].push_back(dzw);
00635     }
00636 
00637 }

const MdcGeoSuper* const MdcGeomSvc::SuperLayer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

const MdcGeoSuper *const MdcGeomSvc::SuperLayer unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

00792                                      {
00793         if (id < fSupers.size())
00794             return  fSupers[id];
00795 
00796         return 0;
00797     }

const MdcGeoWire* const MdcGeomSvc::Wire unsigned  lyrid,
unsigned  wirid
[virtual]
 

Implements IMdcGeomSvc.

const MdcGeoWire* const MdcGeomSvc::Wire unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

const MdcGeoWire *const MdcGeomSvc::Wire unsigned  lyrid,
unsigned  wirid
[virtual]
 

Implements IMdcGeomSvc.

00776                                                   {
00777         if ((lyrid <fLayers.size()) && ((int) wirid < Layer(lyrid)->NCell()))
00778             return fWires[Layer(lyrid)->Wirst() + wirid];
00779 
00780         return 0;
00781     }

const MdcGeoWire *const MdcGeomSvc::Wire unsigned  id  )  [virtual]
 

Implements IMdcGeomSvc.

00768                                {
00769         if (id < fWires.size())
00770             return  fWires[id];
00771 
00772         return 0;
00773     }


Member Data Documentation

vector<MdcGeoEnd*> MdcGeomSvc::fEnd [private]
 

vector<MdcGeoEnd*> MdcGeomSvc::fEnd [private]
 

vector<MdcGeoGeneral> MdcGeomSvc::fGenerals [private]
 

vector<MdcGeoGeneral> MdcGeomSvc::fGenerals [private]
 

vector<MdcGeoLayer*> MdcGeomSvc::fLayers [private]
 

vector<MdcGeoLayer*> MdcGeomSvc::fLayers [private]
 

MdcGeoMisc MdcGeomSvc::fMisc [private]
 

vector<MdcGeoSuper*> MdcGeomSvc::fSupers [private]
 

vector<MdcGeoSuper*> MdcGeomSvc::fSupers [private]
 

vector<MdcGeoWire*> MdcGeomSvc::fWires [private]
 

vector<MdcGeoWire*> MdcGeomSvc::fWires [private]
 

std::string MdcGeomSvc::m_alignFilePath [private]
 

bool MdcGeomSvc::m_doSag = true [static]
 

int MdcGeomSvc::m_mindex [private]
 

bool MdcGeomSvc::m_nomcalignment = true [static]
 

IDataProviderSvc* MdcGeomSvc::m_pCalibDataSvc [private]
 

IDataProviderSvc* MdcGeomSvc::m_pCalibDataSvc [private]
 

bool MdcGeomSvc::m_readAlignParDataBase = true [static]
 

bool MdcGeomSvc::m_updataalign [private]
 

double MdcGeomSvc::m_wholeRotatX [private]
 

double MdcGeomSvc::m_wholeRotatY [private]
 

double MdcGeomSvc::m_wholeRotatZ [private]
 

double MdcGeomSvc::m_wholeShiftX [private]
 

double MdcGeomSvc::m_wholeShiftY [private]
 

double MdcGeomSvc::m_wholeShiftZ [private]
 

std::string MdcGeomSvc::m_wirePosFilePath [private]
 

std::string MdcGeomSvc::m_wireTensionFilePath [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 16:25:48 2011 for BOSS6.5.5 by  doxygen 1.3.9.1