diff --git a/StRoot/Stv/Factory/Factory.cxx b/StRoot/Stv/Factory/Factory.cxx deleted file mode 100644 index d890d8890e3..00000000000 --- a/StRoot/Stv/Factory/Factory.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include "FactoryT.h" -double FactoryB::fgTotal=0; -FactoryB::FactoryB(const char* name): TNamed(name,"") -{ -fCurCount=0; fMaxCount = 1000000;fUseCount=0;fFastDel=0; -fInstCount=0;fFreeCount=0; -} diff --git a/StRoot/Stv/Factory/FactoryT.h b/StRoot/Stv/Factory/FactoryT.h deleted file mode 100644 index 94e17e7e5d7..00000000000 --- a/StRoot/Stv/Factory/FactoryT.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef Factory_H -#define Factory_H - -#include "TNamed.h" -#include - -/*! - Abstract base class defining a factory mechanism -

- This class defines the concept of factory, an agent responsible for the - creation or instantiation of a given type of class. The class is templated. - The template represents the base class to be intanstiated and served by the - factory. Implementation (derived class) may serve objects from class derived - based on the "Abstract" template class. -*/ -class FactoryB : public TNamed -{ -protected: - - FactoryB(const char *name); - - virtual ~FactoryB() - {;} - -public: - ///Clear/delete all objects owned by this factory - virtual void clear()=0; - - ///Reset this factory - virtual void reset()=0; - - ///Free an object for reuse - virtual void free(void *obj)=0; - - ///Free an object for reuse - static void Free(void *obj); - static int Alive(void *obj); - - void setFastDelete() {fFastDel=1;} - void setMaxIncrementCount(unsigned int maxCount) {fMaxCount=maxCount;} - unsigned int getMaxIncrementCount() const {return fMaxCount; } - unsigned int getCurrentSize() const {return fCurCount; } - unsigned int getCurrentCount() const {return fCurCount; } -protected: - unsigned int fMaxCount; - unsigned int fCurCount; - unsigned int fUseCount; - unsigned int fFastDel; - unsigned int fInstCount; - unsigned int fFreeCount; -static double fgTotal; -}; - -template -class FactoryT : public FactoryB -{ -public: - - FactoryT(const char *name): FactoryB(name) - {;} - - virtual ~FactoryT() - {;} - - ///Free an object for reuse - virtual void free(Abstract *obj)=0; - virtual void free(void *obj)=0; - - ///Get a pointer to instance of objects served by this factory. - virtual Abstract *getInstance()=0; - -}; - -inline void FactoryB::Free(void *obj) -{ - void **v = ((void**)obj) - 1; - if (!*v) v--; - assert((*v)!=(void*)0xFF); - assert(((*(int*)v)&3)==0); - FactoryB *f = (FactoryB*)((*v)); - f->free(obj); -} -inline int FactoryB::Alive(void *obj) -{ - void **v = ((void**)obj) - 1; - if (!*v) v--; - return ((*v)!=(void*)0xFF); -} - -#endif diff --git a/StRoot/Stv/Factory/StvFactory.h b/StRoot/Stv/Factory/StvFactory.h deleted file mode 100644 index b8dc71b7679..00000000000 --- a/StRoot/Stv/Factory/StvFactory.h +++ /dev/null @@ -1,207 +0,0 @@ -#ifndef StvFactory_H -#define StvFactory_H -#include -#include -#include -#include "FactoryT.h" -/*! - Abstract base class defining a factory mechanism -

- This class defines the concept of factory, an agent responsible for the - creation or instantiation of a given type of class. The class is templated. - The template represents the base class to be intanstiated and served by the - factory. Implementation (derived class) may serve objects from class derived - based on the "Factorized" template class. -*/ - - -//______________________________________________________________________________ -template -class StvHolder { -public: - StvHolder(); -public: - StvHolder *fNext; - FactoryB *fFact; - Object fObj; -}; - -//______________________________________________________________________________ -template -class StvBlock { -public: -enum {kSize=100}; - StvBlock(StvBlock **bTop,StvHolder **hTop,char *buf); -void reset(StvBlock **bTop,StvHolder **hTop); -unsigned int getSize() const {return kSize;} - -StvBlock *fNext; -char *fBuff; -StvHolder fArr[kSize]; -}; - - -//______________________________________________________________________________ -template -class StvFactory : public FactoryT -{ -public: -void free(Abstract *obj); -void free(void *obj) { free((Abstract*)obj);} - ///Clear/delete all objects owned by this factory -void clear(); -void print(); - - ///Reset this factory -void reset(); - - ///Get a pointer to instance of objects served by this factory. -Abstract* getInstance(); -static StvFactory* myInstance(); - -protected: - StvFactory(); - ~StvFactory(){this->clear();} - -StvBlock *fBTop; -StvHolder *fHTop; - -}; -//______________________________________________________________________________ -//______________________________________________________________________________ -//______________________________________________________________________________ -template -StvBlock::StvBlock(StvBlock **bTop,StvHolder **hTop,char *buf) -{ - fBuff=buf; - this->reset(bTop,hTop); -} -template -void StvBlock::reset(StvBlock **bTop,StvHolder **hTop) -{ - fNext=*bTop; *bTop=this; - for (int i=0;i -StvHolder::StvHolder() -{ - char *b = (char*)&fNext; - memset(b,0,((char*)&fObj)-b); -} -//______________________________________________________________________________ -//______________________________________________________________________________ -template -StvFactory::StvFactory():FactoryT("") -{ - fHTop=0;fBTop=0; - this->SetName(typeid(*this).name()); - printf("*** FactoryT created *** %s\n",this->GetName()); -} -template -StvFactory* StvFactory::myInstance() -{ - static StvFactory* my=0; - if (!my) my = new StvFactory; - return my; -} -//______________________________________________________________________________ -template -Abstract *StvFactory::getInstance() -{ - enum {FENCE = sizeof(double)+2*sizeof(long)+1}; - if (!fHTop) { - assert ("StvFactory::getInstance() - Too many instances" && - this->fCurCount < this->fMaxCount); - - if (this->fFastDel) { - unsigned int nBuf = sizeof(StvBlock) + FENCE; - char *cBuf = new char[nBuf]; - cBuf[nBuf-1]=46; - new((StvBlock*)cBuf) StvBlock(&fBTop,&fHTop,cBuf); - assert(cBuf[nBuf-1]==46); - } else { - new StvBlock(&fBTop,&fHTop, 0); - } - this->fCurCount += fBTop->getSize(); - this->fgTotal += sizeof(StvBlock)*1e-6; - } - this->fInstCount++; - StvHolder *h = fHTop; - fHTop = h->fNext; - h->fNext=0; - h->fObj.reset(); - this->fUseCount++; - assert(!h->fFact || (unsigned long)h->fFact == 0xFF); - h->fFact = this; //set factory addres - return &h->fObj; -} -//______________________________________________________________________________ -template -void StvFactory::free(Abstract *obj) -{ - static const unsigned int shift = (char*)(&(((StvHolder*)1)->fObj))-(char*)1; - obj->unset(); - StvHolder* h = (StvHolder*)((char*)obj-shift); - assert(h->fFact == this); - h->fNext = fHTop; h->fFact = (FactoryB*)0xFF; - fHTop=h; - this->fUseCount--; this->fFreeCount++; -} - -//______________________________________________________________________________ -template -void StvFactory::clear() -{ - double sz=0; - StvBlock* b = fBTop; - while (b) { - StvBlock* d = b; - b=b->fNext; - if (this->fFastDel) {delete [] d->fBuff;} else { delete d;} - sz += sizeof(StvBlock); - this->fgTotal -= sizeof(StvBlock)*1e-6; - } - fBTop=0; fHTop=0; this->fCurCount=0; this->fUseCount=0; - printf("*** %s::clear() %g MegaBytes Total %g Inst/Free=%d %d\n" - ,this->GetName(),sz*1e-6 - ,this->fgTotal*1e-6,this->fInstCount,this->fFreeCount); - this->fInstCount=0; this->fFreeCount=0; -} -//______________________________________________________________________________ -template -void StvFactory::print() -{ - double sz=0; - StvBlock* b = fBTop; - while (b) { - b=b->fNext; - sz += sizeof(StvBlock); - this->fgTotal -= sizeof(StvBlock)*1e-6; - } - this->fCurCount=0; this->fUseCount=0; - printf("*** %s::print() %g MegaBytes Total %g Inst/Free=%d %d \n" - ,this->GetName(),sz*1e-6 - ,this->fgTotal ,this->fInstCount,this->fFreeCount); -} -//______________________________________________________________________________ -template -void StvFactory::reset() -{ - if (!this->fUseCount) return; - - typedef StvBlock B_t; - B_t* b = fBTop; - fBTop=0;fHTop=0; - while (b) { - B_t* n = b->fNext; - b->reset(&fBTop,&fHTop); - b=n; - } - this->fUseCount=0; -} -#endif diff --git a/StRoot/Stv/StvConst.cxx b/StRoot/Stv/StvConst.cxx deleted file mode 100644 index 46fa178fa32..00000000000 --- a/StRoot/Stv/StvConst.cxx +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include -#include "StMaker.h" -#include "StvConst.h" - -const StvConst *StvConst::mgConst=0; - -//______________________________________________________________________________ -StvConst::StvConst() -{ - mFw = 0; - assert(!mgConst); - mgConst = this; - StMaker *mk = StMaker::GetChain(); - St_StvKonst *tb = (St_StvKonst*)mk->GetDataBase("Calibrations/tracker/StvKonst"); - assert(tb); - int nCols = tb->GetNumberOfColumns(); - assert(nCols); - tb->Print(); - -// check table for zeros. All the fields either float or int - int *row = (int*)tb->GetTable(); - for (int i=0;iGetTable()); -} -//______________________________________________________________________________ -const StvKonst_st *StvConst::At(int idx) const -{ - if (!mFw) { - mFw = new StvKonst_st; - *mFw = *this; - memcpy(&mFw->mMinSeedHits,&mFw->mMinSeedHitsFw, - (char*)&mMinSeedHitsFw-(char*)&mMinSeedHits); - assert(mFw->mZMax==mFw->mZMaxFw); - } - switch(idx) { - case 0: return this; - case 1: return mFw; - default: assert(0 && "Wring index in StvConst::At(indedx)"); - } -} - diff --git a/StRoot/Stv/StvConst.h b/StRoot/Stv/StvConst.h deleted file mode 100644 index 1cdd101ee20..00000000000 --- a/StRoot/Stv/StvConst.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __StvConst_h_ -#define __StvConst_h_ -#include "TNamed.h" -#include "tables/St_StvKonst_Table.h" - -class StvConst : protected StvKonst_st -{ -public: -StvConst(); -virtual ~StvConst(){mFw=0;} -static const StvConst *Inst(){ return mgConst;} -const StvKonst_st *At(int idx) const; -private: - -mutable StvKonst_st *mFw; -static const StvConst *mgConst; -ClassDef(StvConst,0)// -}; -#endif //__StvConst_h_ - - diff --git a/StRoot/Stv/StvDiver.cxx b/StRoot/Stv/StvDiver.cxx deleted file mode 100644 index 38d61b0990b..00000000000 --- a/StRoot/Stv/StvDiver.cxx +++ /dev/null @@ -1,650 +0,0 @@ -#include "StvDiver.h" -#include "TSystem.h" -#include "TGeoManager.h" -#include "TGeoVolume.h" -#include "TVirtualMCStack.h" -#include "TGeant3TGeo.h" -#include "StarVMC/GeoTestMaker/StVMCApplication.h" -#include "StarVMC/GeoTestMaker/StMCStack.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StvUtil/StvDebug.h" -#include "StvUtil/StvNodePars.h" -#include "StarMagField.h" -#include "StvUtil/StvELossTrak.h" -#include "THelixTrack.h" -#include "TRandom.h" -#include "StvToolkit.h" - -enum DiverCons { kNearBeam=1 }; - - - -class MyRandom : public TRandom -{ -public: -virtual Double_t Rndm(Int_t i = 0) {return 0.5;} -virtual Double_t Gaus(Double_t mean = 0, Double_t sigma = 1) {return 0.0;} -}; -static MyRandom* gMyRandom=0; -static const double gMyPiMass=0.1396; -static const int gMyPiPdg =9999; - -enum {kNMany = 10}; -StvDiver* StvDiver::mgInst = 0; - -ClassImp(StvDiver) - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StvDiver::StvDiver(const char *name):TNamed(name,"") -{ - assert(!mgInst); - memset(mBeg,0,mEnd-mBeg+1); -} -//_____________________________________________________________________________ -StvDiver* StvDiver::Inst() -{ - if (mgInst) return mgInst; - mgInst = new StvDiver("Diver"); - mgInst->Init(); - return mgInst; -} -//_____________________________________________________________________________ -int StvDiver::Init() -{ - gMyRandom = new MyRandom; - mHelix = new THelixTrack; - mELoss = 0; - StVMCApplication *app = (StVMCApplication*)TVirtualMCApplication::Instance(); - assert(app); - mSteps = ( StvMCStepping*)app->GetStepping(); - assert(mSteps); - mSteps->Set(mHelix); - mGen = (StvMCPrimaryGenerator*)app->GetPrimaryGenerator(); - mFld = (StvMCField* )app->GetField(); - mSteps->Set(mFld); - - TVirtualMC::GetMC()->DefineParticle( gMyPiPdg,"MyPi+",kPTHadron,gMyPiMass, 1,1e+10 - ,"pType", 0., 0, 1, 0, 1, 1, 1, 0, 1, 1); - TVirtualMC::GetMC()->DefineParticle(-gMyPiPdg,"MyPi-",kPTHadron,gMyPiMass,-1,1e+10 - ,"pType", 0., 0, 1, 0, 1, 1, 1, 0, 1, 1); - return 0; -} -//_____________________________________________________________________________ -StvELossTrak *StvDiver::TakeELoss() -{ - StvELossTrak *el=mELoss; mELoss=0;mSteps->Set(mELoss); return el; -} -//_____________________________________________________________________________ -void StvDiver::SetRZmax(double rMax,double zMax) -{ - StVMCApplication *app = (StVMCApplication*)TVirtualMCApplication::Instance(); - app->SetRZmax(rMax,zMax); -} - -//_____________________________________________________________________________ -void StvDiver::Reset() -{ - mSteps->Reset(); -} -//_____________________________________________________________________________ -void StvDiver::SetOpt(int opt) -{ - mSteps->SetOpt(opt); -} -//_____________________________________________________________________________ -void StvDiver::SetTarget(const double target[3],int nTarget) -{ - mSteps->SetTarget(target,nTarget); -} -//_____________________________________________________________________________ -int StvDiver::Dive() -{ -static StvToolkit* kit = StvToolkit::Inst(); - mGen->Set(mInpPars,mDir); - - -// ****************** Replacing ROOT random by empty one. Dangerous -// ****************** At the end of method it is returned back - assert(gRandom != gMyRandom); - TRandom *myRandom = gRandom; - gRandom = gMyRandom; - - assert(fabs(mInpPars->_hz)<0.01); - mELoss = kit->GetELossTrak(); mSteps->Set(mELoss); - mELoss->Reset(mDir); - int myExit = 0; - mInpPars->get(mHelix); - mInpErrs->Get(mHelix); - mHlxDeri[0][0]=0; //Mark this matrix is not filled - if (!mDir) mHelix->Backward(); - StvNodePars tmpPars; - for (int iMany=0; iMany ProcessEvent(); - myExit = mSteps->GetExit(); - if (myExit & StvDiver::kDiveBreak) break; - double pos[4]; - mSteps->CurrentPosition().GetXYZT(pos); - auto &mom = mSteps->CurrentMomentum(); - mOutPars->_x = pos[0]; - mOutPars->_y = pos[1]; - mOutPars->_z = pos[2]; - mOutPars->_psi = mom.Phi(); - mOutPars->_ptin = -mSteps->Charge()/mom.Pt(); - mOutPars->_tanl = mom[2]*fabs(mOutPars->_ptin); - mOutPars->_hz = mFld->GetHz(pos); - mOutPars->ready(); - mOutErrs->Set(mHelix,mOutPars->_hz); - assert(mOutErrs->mPP>0); - mOutPars->convert(*mOutDeri,mHlxDeri); - if (!mDir) { - mOutPars->reverse(); - mOutDeri->Reverse(); - mOutErrs->Backward(); - assert(mOutErrs->mPP>0); - } - if (!(myExit&StvDiver::kDiveMany)) break; - if ( (myExit&StvDiver::kDiveHits)) break; - if ( (myExit&StvDiver::kDiveDca )) break; -// Too many attempts. Move blindly forward and continue. - double bigStep = mOutPars->getRxy(); - bigStep = 0.1 + bigStep/200; //Estimate bigstep - double dcaStep = mHelix->Path(0.,0.); - if (dcaStep>0 && dcaStepMove(bigStep); - tmpPars.set(mHelix,mOutPars->_hz); - if (!mDir) tmpPars.reverse(); //account direction - mGen->Set(&tmpPars,mDir); - } - assert (myExit >1 || mInpPars->_ptin * mOutPars->_ptin >=0); - gRandom = myRandom; - - return mSteps->GetExit(); -} -//_____________________________________________________________________________ -void StvDiver::Set(const StvNodePars *inpar,const StvFitErrs *inerr,int idir) -{ - mInpPars= inpar; - mInpErrs= inerr; - mDir = idir; - mSteps->SetDir(mDir); - mGen->Set(inpar,idir); -} -//_____________________________________________________________________________ -void StvDiver::Set(StvNodePars *otpar,StvFitErrs *oterr,StvFitDers *deriv) -{ - mOutPars = otpar; - mOutErrs = oterr; - mOutDeri = deriv; - mSteps->Set(&mHlxDeri); - -} -//_____________________________________________________________________________ -double StvDiver::GetLength() const -{ - return TVirtualMC::GetMC()->TrackLength(); -} - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -ClassImp(StvMCInitApp) - -//_____________________________________________________________________________ -StvMCInitApp::StvMCInitApp() -{} -//_____________________________________________________________________________ -int StvMCInitApp::Fun() -{ - StVMCApplication *app = (StVMCApplication*)TVirtualMCApplication::Instance(); - TVirtualMC *myMC = new TGeant3TGeo("C++ Interface to Geant3"); - Info("Init","TGeant3TGeo has been created."); - StvMCConstructGeometry *geo = new StvMCConstructGeometry(app->GetName()); - app->SetConstructGeometry(geo); - app->SetPrimaryGenerator(new StvMCPrimaryGenerator()); - app->SetField(new StvMCField); - StvMCStepping *steps = new StvMCStepping(""); - app->SetStepping(steps); - - app->SetDebug(0); - myMC->SetStack(new StMCStack(1)); - myMC->Init(); - myMC->BuildPhysics(); - ((TGeant3*)myMC)->SetDEBU(0,0,0); - ((TGeant3*)myMC)->SetMaxNStep(-1000); - - Gcphys_t* gcphys = ((TGeant3*)myMC)->Gcphys(); if (gcphys){} - - Info("Init","switch off physics"); - myMC->SetProcess("DCAY", 0); - myMC->SetProcess("ANNI", 0); - myMC->SetProcess("BREM", 0); - myMC->SetProcess("COMP", 0); - myMC->SetProcess("HADR", 0); - myMC->SetProcess("MUNU", 0); - myMC->SetProcess("PAIR", 0); - myMC->SetProcess("PFIS", 0); - myMC->SetProcess("PHOT", 0); - myMC->SetProcess("RAYL", 0); - myMC->SetProcess("LOSS", 4); // no fluctuations - // myMC->SetProcess("LOSS 1"); // with delta electron above dcute - myMC->SetProcess("DRAY", 0); - myMC->SetProcess("MULS", 0); - myMC->SetProcess("STRA", 0); - myMC->SetCut("CUTGAM", 1e-3 ); - myMC->SetCut("CUTELE", 1e-3 ); - myMC->SetCut("CUTHAD", .001 ); - myMC->SetCut("CUTNEU", .001 ); - myMC->SetCut("CUTMUO", .001 ); - myMC->SetCut("BCUTE", .001 ); - myMC->SetCut("BCUTM", .001 ); - myMC->SetCut("DCUTE", 1e-3 ); - myMC->SetCut("DCUTM", .001 ); - myMC->SetCut("PPCUTM", .001 ); - myMC->SetCut("TOFMAX", 50.e-6); - - return 0; -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -ClassImp(StvMCStepping) - -//_____________________________________________________________________________ -StvMCStepping::StvMCStepping(const char *name,const char *tit) - : StMCStepping(name,tit) -{ - memset(fFist,0,fLast-fFist); - fNTarget = 2; - fNearBeam = kNearBeam; - fHALLVolu = gGeoManager->FindVolumeFast("HALL"); -} -//_____________________________________________________________________________ -StvMCStepping::~StvMCStepping() -{ -} -//_____________________________________________________________________________ -void StvMCStepping::Reset() -{ - memset(fFist,0,fMidl-fFist); - fNTarget = 2; -} -//_____________________________________________________________________________ -void StvMCStepping::SetTarget(const double *target,int nTarget) -{ - memcpy(fTarget,target,sizeof(double)*nTarget); - fNTarget = nTarget; -} -//_____________________________________________________________________________ -void StvMCStepping::SetOpt(int opt) -{ - fOpt = opt; - fNTarget = (fOpt&StvDiver::kTarg3D)? 3:2; -} -//_____________________________________________________________________________ -void StvMCStepping::Print(const Option_t* opt) const -{ -StMCStepping::Print(opt); -} -//_____________________________________________________________________________ -int StvMCStepping::Fun() -{ -static StTGeoProxy *tgh = StTGeoProxy::Instance(); -//static const StTGeoHitShape *hitShape = tgh->GetHitShape(); -static TVirtualMC *virtualMC = TVirtualMC::GetMC(); -static const TVirtualMCApplication *virtApp = TVirtualMCApplication::Instance(); -const double Rmax = virtApp->TrackingRmax(); -const double Zmax = virtApp->TrackingZmax(); - - - TString ts,modName; - fKount++; - -double prevLen = fPrevLength; - Case(); - -static const char *myDebug = gSystem->Getenv("StvDEBUG"); -if (myDebug) { - double pos[4],b[3]; - fCurrentPosition.GetXYZT(pos); - fField->FunDD(pos,b); - StvDebug::Count("BZvsZ",pos[2],b[2]); - double Br = sqrt(b[0]*b[0]+b[1]*b[1]); - double Ba = sqrt(b[2]*b[2]+Br*Br); - StvDebug::Count("BRvsZ",pos[2],Br); - StvDebug::Count("BAvsZ",pos[2],Ba); - StvDebug::Count("TanVsZ",pos[2],Br/b[2]); - printf("Fun(%d): Z=%g Hz=%g Hr=%g path = %s\n" - ,fKount,pos[2],b[2],Br,gGeoManager->GetPath()); -} - - - -int meAgain = (fNode==fPrevNode); -if (meAgain) meAgain = (fPrevPath == tgh->GetPath()); -if (!meAgain) {fPrevNode = fNode; fPrevPath == tgh->GetPath();} - - if (fabs(fCurrentPosition.Z()) >Zmax) fKaze = kOUTtrack; - if (fCurrentPosition.Pt() >Rmax) fKaze = kOUTtrack; - - assert(fCurrentLength< 10000); - assert(fEnterLength < 10000); - -// StTGeoProxy::Instance()->Print(KazeAsString(fKaze)); -// printf("fEnterLength=%g fCurrentLength=%g Rxy=%g Z=%g\n\n" -// , fEnterLength, fCurrentLength,fCurrentPosition.Perp(),fCurrentPosition.Z()); - -SWITCH: int myKaze = fKaze; -//========================= - -// printf("KASE=%d Pos(%g %g %g) In %s\n",fKaze -// ,fCurrentPosition.X(),fCurrentPosition.Y(),fCurrentPosition.Z() -// ,gGeoManager->GetPath()); - - - - switch (fKaze) { - case kNEWtrack:; - - case kENTERtrack:;{ - double *X = &fCurrentPosition[0]; - fHitted = ((!meAgain) && tgh->IsHitted(X)); - if (fVolume==fHALLVolu) {fKaze=kENDEDtrack; break;} -// int outSide = hitShape->Outside(fCurrentPosition.Z(),fCurrentPosition.Perp()); -// if (outSide && ((fOpt&(StvDiver::kTarg2D|StvDiver::kTarg3D))==0)) {fKaze=kENDEDtrack; break;} - if ((fExit = BegVolume())) fKaze=kENDEDtrack;} - break; - - - case kOUTtrack: - case kENDEDtrack: - fExit=StvDiver::kDiveBreak; - virtualMC->StopTrack(); - break; - - case kCONTINUEtrack: - case kIgnore: - break; - - case kEXITtrack: - { - fExit = EndVolume(); - if (!fExit) break; - fPrevPath =""; - if (fExit & StvDiver::kDiveHits) fPrevPath = tgh->GetPath(); - virtualMC->StopTrack(); - } - break; - - default: - Error("Case","Unexpected case %x == %s",fCase,fCasName.Data()); - assert(0); - } - if (fKaze!=myKaze) goto SWITCH; - if (fExit) return 0; - if (fKaze!=fLastKaze) {fLastNumb=0; fLastKaze=fKaze; return 0;} - fLastNumb++; if (fLastNumb<100) return 0; - fLastNumb=0; - fExit =StvDiver::kDiveMany; - fExit |= TooMany(); - virtualMC->StopTrack(); - return 0; -} -//_____________________________________________________________________________ -int StvMCStepping::BegVolume() -{ - - fPrevMat = fMaterial; - fELossTrak->Set(fMaterial,fEnterMomentum.Vect().Mag()); - fTooManyLength = fCurrentLength; - return (IsDca00(0)); -} -//_____________________________________________________________________________ -int StvMCStepping::EndVolume() -{ - double pos[4]={0},mom[4]={0}; - - int isDca = (IsDca00(1)); - if (isDca&StvDiver::kDiveBreak) return isDca; - fTooManyLength = fCurrentLength; - double dL = fCurrentLength-fEnterLength; - if (dL<1e-6) return isDca; - fCurrentPosition.GetXYZT(pos); - fCurrentMomentum.GetXYZT(mom); - double pt = fCurrentMomentum.Pt(); - double nowRho = -fField->GetHz(pos)/pt*fCharge; - double wasRho = fHelix->GetRho(); - -assert(nowRho*wasRho> -1./(200*200)); - fELossTrak->Add(dL); - -#if 0 -{//????????????????? - double E0 = fStartMomentum.E(); - double E1 = fCurrentMomentum.E(); - double dE = fabs(E1-E0); -assert(dEELoss())<0.3*dE+kStMCSMinEabs); -}//????????????????? -#endif - - if ((fOpt&StvDiver::kDoErrs)) { //Errors and derivatives requested - fHelix->Set((2*wasRho+nowRho)/3); - if (!(*fDeriv)[0][0]) { //first time - fHelix->Move(dL,*fDeriv); - } else { - StvHlxDers T,R; - fHelix->Move(dL,T); - Multiply(R,T,*fDeriv); - *fDeriv=R; - } - } - - fHelix->Set(pos,mom,nowRho); - return isDca; -} -//_____________________________________________________________________________ -int StvMCStepping::IsDca00(int begEnd) -{ - fCurrentSign = 0; - for (int itg = 0; itgGetHz(pos)/pt*fCharge; - fHelix->Set(pos,mom,rho); - return 0; - } - - case 1:; // EndVolume -// case 2: // Continue volume - { // end volume - double dL = fCurrentLength-fEnterLength; - if (dL<1e-6) return 0; //Too small step, ignore it - - int ans = 0; - if (IsOverstep()>0) {//Over step DCA00 point? - ans |= StvDiver::kDiveDca; - if ((fOpt&StvDiver::kTarg2D)==0) return ans;} - else { fStartSign = fCurrentSign; } - - - if ((fOpt & StvDiver::kTargHit) && fHitted ) {//We are in hitted volume - ans |= StvDiver::kDiveHits; - } - if (!ans) {return 0;} //Nothing interesting(ni figa), get out -// -// Now there are Hit or Dca cases - THelixTrack th(*fHelix); - double dcaL = (ans & StvDiver::kDiveDca)? th.Path(fTarget[0],fTarget[1]) : dL/2; - if (dcaL< 0) return StvDiver::kDiveBreak; //Crazy case - - double nowP = fCurrentMomentum.P(); - double wasP = fEnterMomentum.P(); - double medP = (wasP*(dL-dcaL)+nowP*dcaL)/dL; - // Update end position - th.Move(dcaL); - fCurrentLength=fEnterLength+dcaL; - fCurrentPosition.SetVect(TVector3(th.Pos())); - fCurrentMomentum.SetVectM(TVector3(th.Dir())*medP,fMass); - return ans; - } - } - return StvDiver::kDiveBreak; -} -//_____________________________________________________________________________ -int StvMCStepping::TooMany() -{ - double dL = fCurrentLength-fTooManyLength; - if (dL<1e-6) return 0; - fEnterLength = fTooManyLength; - return EndVolume(); -} -//_____________________________________________________________________________ -int StvMCStepping::IsOverstep() const -{ -/// return 0=no overstep -/// 1=overstep of nearest to (0,0) point -/// -1=overstep of far to (0,0) point - - if ((fStartSign<0) == (fCurrentSign<0)) return 0; - const double *p = fHelix->Pos(); - const double *d = fHelix->Dir(); - double rho = fHelix->GetRho(); - double cosl= fHelix->GetCos(); - double dis = fabs((d[0]*p[1]-d[1]*p[0])*rho/cosl); - return (dis<1)? 1:-1; -} - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -void StvMCStepping::Finish(const char *opt) -{ -} -ClassImp(StvMCConstructGeometry) - -//_____________________________________________________________________________ -StvMCConstructGeometry::StvMCConstructGeometry(const char *gy) - : GCall(gy,"StvMCConstructGeometry") -{ -} -//_____________________________________________________________________________ -int StvMCConstructGeometry::Fun() -{ - TVirtualMC *myMC = TVirtualMC::GetMC(); - myMC->SetRootGeometry(); - Info("Init","switch off physics"); - myMC->SetProcess("DCAY", 0); - myMC->SetProcess("ANNI", 0); - myMC->SetProcess("BREM", 0); - myMC->SetProcess("COMP", 0); - myMC->SetProcess("HADR", 0); - myMC->SetProcess("MUNU", 0); - myMC->SetProcess("PAIR", 0); - myMC->SetProcess("PFIS", 0); - myMC->SetProcess("PHOT", 0); - myMC->SetProcess("RAYL", 0); - myMC->SetProcess("LOSS", 4); // no fluctuations - // myMC->SetProcess("LOSS 1"); // with delta electron above dcute - myMC->SetProcess("DRAY", 0); - myMC->SetProcess("MULS", 0); - myMC->SetProcess("STRA", 0); - myMC->SetCut("CUTGAM", 1e-3 ); - myMC->SetCut("CUTELE", 1e-3 ); - myMC->SetCut("CUTHAD", .001 ); - myMC->SetCut("CUTNEU", .001 ); - myMC->SetCut("CUTMUO", .001 ); - myMC->SetCut("BCUTE", .001 ); - myMC->SetCut("BCUTM", .001 ); - myMC->SetCut("DCUTE", 1e-3 ); - myMC->SetCut("DCUTM", .001 ); - myMC->SetCut("PPCUTM", .001 ); - myMC->SetCut("TOFMAX", 50.e-6); - - - - return 0; -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -ClassImp(StvMCPrimaryGenerator); -//_____________________________________________________________________________ -StvMCPrimaryGenerator::StvMCPrimaryGenerator() -{ - mPars=0; - mDir=0; // direction of moving 1=along track; 0=opposite -} - -//_____________________________________________________________________________ -int StvMCPrimaryGenerator::Fun() -{ - - // Add one primary particle to the user stack (derived from TVirtualMCStack). - // Track ID (filled by stack) - // Option: to be tracked - - int toBeDone = 1; - - // Particle type - int pdg = (mPars->getCharge()>0)? gMyPiPdg:-gMyPiPdg; - // Particle momentum - double p[3]={0}; - mPars->getMom(p); - - if (!mDir) { pdg = -pdg; p[0]=-p[0]; p[1]=-p[1];p[2]=-p[2];} - - // Polarization -static const double polx = 0.,poly = 0.,polz = 0.; - - // Position -static const double tof = 0.; - - double e = sqrt(gMyPiMass*gMyPiMass + mPars->getP2()); - // Add particle to stack - assert(e>1e-6); - int ntr=1; - TVirtualMC::GetMC()->GetStack()->Clear(); - TVirtualMC::GetMC()->GetStack()->PushTrack( - toBeDone,-1,pdg,p[0], p[1], p[2],e - ,mPars->_x, mPars->_y, mPars->_z,tof - ,polx,poly,polz, kPPrimary, ntr, 1.,0); - return 0; -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -ClassImp(StvMCField) -//_____________________________________________________________________________ -StvMCField::StvMCField() -{ - mX[2] = 3e33; - mH[2] = 3e33; - mFild = StarMagField::Instance(); -} -//_____________________________________________________________________________ -int StvMCField::FunDD(const double *x,double *b) -{ - do { - if (fabs(x[2]-mX[2])>0.01) break; - if (fabs(x[1]-mX[1])>0.01) break; - if (fabs(x[0]-mX[0])>0.01) break; - if (b) memcpy(b,mH,sizeof(mH)); - return 0; - } while(0); - memcpy(mX,x,sizeof(mX)); - mFild->BField(mX,mH); - if (fabs(mH[2]) < 1e-5) mH[2]=1e-5; - if (b) memcpy(b,mH,sizeof(mH)); - return 0; -} -//_____________________________________________________________________________ -double StvMCField::GetHz(const double *x) -{ -static const Double_t EC = 2.99792458e-4; - FunDD(x,0); - return mH[2]*EC; -} diff --git a/StRoot/Stv/StvDiver.h b/StRoot/Stv/StvDiver.h deleted file mode 100644 index abbbc8d4491..00000000000 --- a/StRoot/Stv/StvDiver.h +++ /dev/null @@ -1,183 +0,0 @@ -/// \File StvDiver.h -/// \author Victor Perev 01/2010 -#ifndef StvDiver_HH -#define StvDiver_HH -#include "TNamed.h" -#include "StvUtil/StvNodePars.h" -#include "StarVMC/GeoTestMaker/GCall.h" -#include "StarVMC/GeoTestMaker/StMCStepping.h" -#include "StvUtil/StvNodePars.h" - -class StvMCStepping; -class StvMCPrimaryGenerator; -class StvELossTrak; -class StarMagField; -class StvMCField; -class TGeoMaterial; -class THelixTrack; -class StvFitErrs; -class StvNodePars; -/// \class StvDiver -class StvDiver : public TNamed -{ -protected: - StvDiver(const char *name=""); - virtual ~StvDiver(){;} -int Init(); -public: -static StvDiver* Inst(); - -enum StvDiverFlags {kDiveOk =0,kDiveHits=1,kDiveDca=2,kDiveBreak=4,kDiveMany=8}; -enum StvDiverOpt {kTargHit=1,kTarg2D =2,kTarg3D =4,kDoErrs =8}; -public: -void Reset(); -int Dive(); -void Set(const StvNodePars *inpar,const StvFitErrs *inerr,int idir); -void Set( StvNodePars *otpar, StvFitErrs *oterr,StvFitDers *deriv); -void SetTarget(const double *target,int nTarget=3); -void SetOpt(int opt); -double GetLength() const; - StvELossTrak *TakeELoss(); -void SetRZmax(double rMax,double zMax); - -protected: -static StvDiver *mgInst; - -char mBeg[1]; -int mDir; -const StvNodePars *mInpPars; -const StvFitErrs *mInpErrs; - StvNodePars *mOutPars; - StvFitErrs *mOutErrs; - StvFitDers *mOutDeri; //Out derivatives in StvFitPars notation - THelixTrack *mHelix; - StvELossTrak *mELoss; - StvHlxDers mHlxDeri; //Internal derivatives in StHelixTrack notation - StvMCStepping *mSteps; - StvMCField *mFld; -StvMCPrimaryGenerator *mGen; - -char mEnd[1]; -ClassDef(StvDiver,0); -}; -// Class StMCInitApp -// ------------------ - -class StvMCInitApp : public GCall -{ -public: - StvMCInitApp(); - ~StvMCInitApp(){} - // methods - int Fun(); -protected: - ClassDef(StvMCInitApp,0) // -}; - -// Class StvMCStepping -// ------------------ - - -class StvMCStepping : public StMCStepping -{ -public: - StvMCStepping(const char *name="",const char *tit=""); -virtual ~StvMCStepping(); - // methods - -virtual int Fun(); -void Reset (); -int GetExit() const {return fExit;} -void Set(StvELossTrak *eLoss) {fELossTrak = eLoss;} -void Set(THelixTrack *helx ) {fHelix = helx ;} -void Set(StvHlxDers *deriv) {fDeriv = deriv ;} -void Set(StvMCField *field) {fField = field ;} -void SetOpt(int opt); -void SetTarget(const double *target,int nTarget=3); - - - int BegVolume(); - int EndVolume(); - int IsDca00(int begEnd); - int IsOverstep() const; - int TooMany(); - -void FillHelix(); -void Print (const Option_t* opt=0) const; -void Finish(const Option_t* opt=0); - - -protected: -char fFist[1]; -int fOpt; -int fKount; -int fExit; -int fLastKaze; -int fLastNumb; -int fHitted; -int fNTarget; -float fNearBeam; -float fStartSign; -float fCurrentSign; -float fTooManyLength; -double fTarget[3]; -char fMidl[1]; -THelixTrack *fHelix; -StvHlxDers *fDeriv; //Derivative matrix in THelixTrack notation -StvELossTrak *fELossTrak; //Energy loss calculator -StvMCField *fField; //Mag field calculator -const TGeoMaterial *fPrevMat; -TGeoVolume *fHALLVolu; -TGeoNode *fPrevNode; -char fLast[1]; -TString fCurrPath; //Path in current Dive() -TString fPrevPath; //Path in previous Dive() -private: - -ClassDef(StvMCStepping,0) // -}; - -class StvMCConstructGeometry : public GCall -{ - public: - StvMCConstructGeometry(const char *gy); - virtual ~StvMCConstructGeometry(){} - // methods - int Fun(); - private: - - protected: - // data members - - ClassDef(StvMCConstructGeometry,0) // -}; - - -class StvMCPrimaryGenerator : public GCall { - public: - StvMCPrimaryGenerator(); - ~StvMCPrimaryGenerator() {} - - void Set(const StvNodePars *pars,int idir) {mPars=pars; mDir =idir;} - virtual int Fun(); - protected: - const StvNodePars *mPars; - int mDir; // direction of moving 1=along track; 0=opposite - ClassDef(StvMCPrimaryGenerator,0) //StvMCPrimaryGenerator -}; - - -class StvMCField : public GCall { - public: - StvMCField(); - ~StvMCField() {} - virtual int FunDD(const double *x,double *b); - double GetHz(const double X[3]); - protected: - double mH[3],mX[3]; - StarMagField *mFild; // - - ClassDef(StvMCField,0) // -}; - -#endif diff --git a/StRoot/Stv/StvDraw.cxx b/StRoot/Stv/StvDraw.cxx deleted file mode 100644 index 24ff538a6ac..00000000000 --- a/StRoot/Stv/StvDraw.cxx +++ /dev/null @@ -1,311 +0,0 @@ -#include -#include "TSystem.h" -#include "TBrowser.h" -#include "TCernLib.h" -#include "TVector3.h" -#include "StvDraw.h" -#include "Stv/StvTrack.h" -#include "Stv/StvNode.h" -#include "Stv/StvHit.h" -#include "StvUtil/StvNodePars.h" -#include "Stv/StvStl.h" -#include "THelixTrack.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - -#include "Stv/StvToolkit.h" -static Color_t gMyColors[] = {kRed,kBlue,kMagenta,kCyan}; - -StvDraw *StvDraw::fgStvDraw=0; -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StvDraw::StvDraw(const char *name):StDraw3D(name) -{ - fgStvDraw = this; mNDoIt=0;mNPow2=1;mIColor=0; - SetBkColor(kWhite); -} -//_____________________________________________________________________________ -TObject *StvDraw::Hits(const std::vector &hits, EDraw3DStyle sty) -{ -if (!hits.size()) return 0; -const std::vector&vc = (std::vector&)hits; -return Hits(vc,sty); -} - - -//_____________________________________________________________________________ -TObject *StvDraw::Hits(const std::vector &hits, EDraw3DStyle sty) -{ - int n = hits.size(); if (!n) return 0; - std::vector vec(n*3); - const float *f;float *v=&vec[0]; - for (int i=0;ix();v[0]=f[0];v[1]=f[1];v[2]=f[2];v+=3; - } - vec.resize(v-&vec[0]); - TObject *to = Points(vec,sty); - DoIt(); -// ProcessEvents(); - return to; -} -//_____________________________________________________________________________ -TObject *StvDraw::Hits(const std::vector &hits, EDraw3DStyle sty) -{ - int n = hits.size(); if (!n) return 0; - std::vector vec(n*3); - const float *f;float *v=&vec[0]; - for (int i=0;i vec(nHits*3); - int n =0; - for (int i=0;i &hits, EDraw3DStyle sty) -{ -const std::vector&vc = (std::vector&)hits; -return Trak(helx,vc,sty); -} -//_____________________________________________________________________________ -void StvDraw::Road(const THelixTrack &helx,const std::vector &hits - , EDraw3DStyle sty, double wide) -{ - int n = hits.size(); - if (!n) return; - - TVector3 A(hits.front()->x()); - TVector3 B(hits.back ()->x()); - StvConstHits unHits; - Near((StvConstHits&)hits,unHits,wide); - Hits(unHits,kUnusedHit); - Trak(helx,hits,sty); -} -//_____________________________________________________________________________ -TObject *StvDraw::Trak(const THelixTrack &helx - ,const std::vector &hits - ,EDraw3DStyle sty) -{ - int n = hits.size(); if (n<=1) return 0; - Hits(hits ,kUsedHit); - if (helx.GetCos()<=0) {DoIt(); return 0;} - - const float *f = 0; - f = hits.front()->x(); - double fst[3]={f[0],f[1],f[2]}; - f = hits.back()->x(); - double lst[3]={f[0],f[1],f[2]}; - - std::vector myTrak; - THelixTrack th(helx); - - double l = th.Path(fst); th.Move(l); - l = th.Path(lst); - double dl = l/100; - for (int i=0;i<=100;i++) { - const double *x = th.Pos(); - for (int j=0;j<3;j++) {myTrak.push_back(x[j]);} th.Move(dl); - } - Hits(hits ,kUsedHit); - TObject *to = Line(myTrak,sty); - DoIt(); - return to; -} -//_____________________________________________________________________________ -TObject *StvDraw::Trak(const std::vector &pnts, EDraw3DStyle sty,Color_t color) -{ - int n = pnts.size(); if (!n) return 0; - StDraw3DStyle myStyle = Style(sty); - if (!color) { - myStyle.Col() = gMyColors[mIColor]; - mIColor = (mIColor+1)%(sizeof(gMyColors)/sizeof(gMyColors[0])); - } - return Line(pnts, myStyle.Col(),myStyle.Sty(),myStyle.Siz() ); -} -//_____________________________________________________________________________ -void StvDraw::Trak(const StvTrack *tk, int dir, EDraw3DStyle sty) -{ - StvConstHits myHits,ihHits; - StvPoints myPoits; - const StvNode *lNode=0,*rNode; - StvNodeConstIter itBeg,itEnd,it; - - if (dir) { //fit in ==> out - itBeg = tk->begin(); itEnd = tk->end(); - } else {//fit out ==> in - itBeg = tk->end(); --itBeg; itEnd = tk->begin();--itEnd; - } - -// StvNodeConstIter itBeg =(dir==0)? tk->rbegin():tk->begin(); -// StvNodeConstIter itEnd =(dir==0)? tk->rend() :tk->end(); - - for (it=itBeg; it!=itEnd; (dir)? ++it:--it) {//Main loop - rNode = *it; - if (rNode->mFE[dir].mHH<0) continue; //this node is not filled - if (fabs(rNode->mFP[dir]._cosCA)<=0) continue; //this node is not filled - - const StvHit *hit = rNode->GetHit(); - if (hit) { - if (rNode->GetXi2(dir)<1000) {myHits+=hit;} else {ihHits+=hit;}} - - if (!lNode) { myPoits+=rNode->GetFP(dir).P;} - else { Join(lNode,rNode,myPoits,dir);} - - const double *P = rNode->GetFP(dir).P; - if (hit) {// make connection to hit - const float *H = hit->x(); - float con[6] = {(float)H[0],(float)H[1],(float)H[2],(float)P[0],(float)P[1],(float)P[2]}; - Line (2,con); - } - {// only short line to mark node - const double *D = &rNode->GetFP(dir)._cosCA; - float con[6] = {(float)P[0] ,(float)P[1] ,(float)P[2] - ,float(P[0]-D[1]*0.1),float(P[1]+D[0]*0.1),(float)P[2]}; - Line (2,con); - } - lNode = rNode; - } - Hits(myHits,kUsedHit); - Hits(ihHits,kUnusedHit); - Trak(myPoits,sty,0); - -} -//_____________________________________________________________________________ -void StvDraw::Zhow(const StvTrack *tk){Inst()->Road(tk,10); Wait();} -//_____________________________________________________________________________ -void StvDraw::Road(const StvTrack *tk, double wide, EDraw3DStyle sty) -{ - Trak(tk, sty); - StvConstHits unHits; - Near(tk,unHits,wide); - if (!unHits.size()) return; - Hits(unHits,kUnusedHit); -} -//_____________________________________________________________________________ -void StvDraw::Near(const StvConstHits &inHits,StvConstHits &unHits,double wide) -{ - THelixFitter hf; - int nh = inHits.size(); - for (int ih = 0;ihx(); hf.Add(f[0],f[1],f[2]); - } - hf.Fit(); - THelixTrack th(hf); - - StVoidArr *vHits = StTGeoProxy::Inst()->GetAllHits(); - int nHits = vHits->size(); - unHits.resize(0); - for (int ih=0;ihx());; - double d[3] = {Hit[0],Hit[1],Hit[2]}; - double s = th.Path(d); th.Move(s); - double dis2 = (Hit - TVector3(th.Pos())).Mag2(); - if (dis2 > wide*wide) continue; - unHits.push_back(hit); - } //End hit loop -} -//_____________________________________________________________________________ -void StvDraw::Near(const StvTrack *tk,StvConstHits &unHits,double wide) -{ - StvConstHits inHits; - for (StvNodeConstIter it=tk->begin(); it!=tk->end(); ++it) { - const StvNode *node = *it; - const StvHit *hit = node->GetHit(); - if (!hit) continue; - inHits.push_back(hit); - } - Near(inHits,unHits,wide); -} - -//_____________________________________________________________________________ -void StvDraw::Join(const StvNode *left,const StvNode *rite,StvPoints &poits,int dir) -{ -static const double maxStep=0.1; - const StvNodePars &lFP = left->GetFP(dir); - const StvNodePars &rFP = rite->GetFP(dir); - THelixTrack hLeft; - lFP.get(&hLeft); - double lenL = hLeft.Path(rFP.P); - - int nStep = fabs(lenL)/maxStep; if (nStep <3) nStep = 3; - double step = lenL/nStep; - for (int is=0;is<=nStep;is++) { - poits +=hLeft.Pos(); - hLeft.Move(step); - } -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -void StvDraw::Show(const StvTrack *tk,int dir){Inst()->Trak(tk,dir); Wait();} -//_____________________________________________________________________________ -void StvDraw::Klear(){Inst()->Clear();} -//_____________________________________________________________________________ -void StvDraw::DoIt() -{ - mNDoIt++; if (mNDoIt<=mNPow2) return; - mNPow2<<=1; - UpdateModified(); ProcessEvents(); -} -//_____________________________________________________________________________ -void StvDraw::Clear(const char *) -{ - mNDoIt=0; mNPow2=1; - StDraw3D::Clear(); -} -//_____________________________________________________________________________ -int StvDraw::ProcessEvents() -{ - int ans = gSystem->ProcessEvents(); - return ans; -} -//_____________________________________________________________________________ -void StvDraw::Wait() -{ - if (Jnst()) Jnst()->UpdateModified(); - fprintf(stderr,"StvDraw::Waiting...\n"); - while(!ProcessEvents()){gSystem->Sleep(200);}; -} -//_____________________________________________________________________________ -void StvDraw::KBrowse(const TObject *to) -{ - new TBrowser("StvDraw",(TObject*)to); -} -//_____________________________________________________________________________ -void StvDraw::All(const char *opt) -{ - if (!opt || !*opt) opt = "THh"; - - if (strstr(opt,"T")) { - StvTracks &tks = StvToolkit::Inst()->GetTracks(); - int nTk = 0; - for (StvTrackConstIter it=tks.begin(); it!=tks.end(); ++it) { - const StvTrack *tk = *it; - nTk++; - Trak(tk); - } } - - if (strstr(opt,"h")) { - StVoidArr *vHits = StTGeoProxy::Inst()->GetAllHits(); - std::vector sHits; - for (int ihit=0;ihit<(int)vHits->size();ihit++) { - const StvHit *stvHit = (StvHit*)(*vHits)[ihit]; - if (stvHit->isUsed()) continue; - sHits.push_back(stvHit); - } - Hits(sHits,kUnusedHit); - } -} - diff --git a/StRoot/Stv/StvDraw.h b/StRoot/Stv/StvDraw.h deleted file mode 100644 index 2c3ad4d8ec4..00000000000 --- a/StRoot/Stv/StvDraw.h +++ /dev/null @@ -1,63 +0,0 @@ - -#ifndef StvDraw_HH -#define StvDraw_HH -#include "StDraw3D.h" - -class StvHit; -class StvHits; -class StvConstHits; -class StvNode; -class StvTrack; -class THelixTrack; -class StvPoints; -class TVector3; -class StvDraw : public StDraw3D -{ -public: - - ///Default constructor. - StvDraw(const char *opt="TIFC,TPCFEE,TPCM"); - ~StvDraw(){;} - void Clear(const char *opt=""); -TObject *Hits(const std::vector< StvHit*> &hits, EDraw3DStyle sty=kUsedHit); -TObject *Hits(const std::vector &hits, EDraw3DStyle sty=kUsedHit); -TObject *Hits(const StvHits &hits, EDraw3DStyle sty=kUsedHit); -TObject *Hits(const std::vector &hits, EDraw3DStyle sty=kUsedHit); -TObject *Hits(int nHits, const TVector3 *hits, EDraw3DStyle sty=kUsedHit); - -TObject *Trak(const THelixTrack &helx,const std::vector &hits, EDraw3DStyle sty=kGlobalTrack); -TObject *Trak(const THelixTrack &helx,const std::vector< StvHit*> &hits, EDraw3DStyle sty=kGlobalTrack); - void Road(const THelixTrack &helx,const std::vector &hits, EDraw3DStyle sty=kGlobalTrack,double wide=10); -TObject *Trak(const std::vector &pnts, EDraw3DStyle sty=kGlobalTrack,Color_t col=kRed); - void Trak(const StvTrack *tk, int dir = 2, EDraw3DStyle sty=kGlobalTrack); - - void Road(const StvTrack *tk, double wide=5,EDraw3DStyle sty=kGlobalTrack); - void All(const char *opt); - - void DoIt(); - void Near(const StvConstHits &inhits,StvConstHits &unhits, double wide=10); - void Near(const StvTrack *tk,StvConstHits &unhits, double wide=10); - - -static int ProcessEvents(); -static StvDraw *Inst() {if (!fgStvDraw) fgStvDraw=new StvDraw(); return fgStvDraw;} -static StvDraw *Jnst() {return fgStvDraw;} -static void Wait(); -static void Show(const StvTrack *tk, int dir=0); -static void Zhow(const StvTrack *tk); -static void Klear(); -static void KBrowse(const TObject *to); -private: - void Join(const StvNode *left,const StvNode *rite,StvPoints &poits,int dir=2); -private: -int mNDoIt; -int mNPow2; -int mIColor; //Current color index when it is changing in cycle -static StvDraw *fgStvDraw; - -}; - -inline TObject *StvDraw::Hits( const StvHits &hits, EDraw3DStyle sty) - { return Hits((const std::vector&)hits,sty);} - -#endif diff --git a/StRoot/Stv/StvEnum.h b/StRoot/Stv/StvEnum.h deleted file mode 100644 index cf10bdd4bc6..00000000000 --- a/StRoot/Stv/StvEnum.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __StvEnum_h_ -#define __StvEnum_h_ -///Permanent constants only -enum StvEnum { kKalmanErrFact=9, kBigMom=3, kBigMom2=kBigMom*kBigMom}; - -#endif //__StvEnum_h_ - - diff --git a/StRoot/Stv/StvFitter.cxx b/StRoot/Stv/StvFitter.cxx deleted file mode 100644 index d8d47b354b2..00000000000 --- a/StRoot/Stv/StvFitter.cxx +++ /dev/null @@ -1,899 +0,0 @@ -#include -#include -#include -#include "TMath.h" -#include "TMatrixD.h" -#include "TVectorD.h" -#include "TCernLib.h" -#include "StvFitter.h" -#include "StvUtil/StvNodePars.h" -#include "StvHit.h" -#include "StvUtil/StvDebug.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - -StvFitter *StvFitter::mgFitter=0; -#define VDOT(a,b) ( a[0]*b[0]+a[1]*b[1]+a[2]*b[2]) -#define DIST(a,b) ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])) -#define DDOT(a,b,c) ((a[0]-b[0])*c[0]+(a[1]-b[1])*c[1]+(a[2]-b[2])*c[2]) -#define VADD(a,b) { a[0]+=b[0];a[1]+=b[1];a[2]+=b[2];} - -enum {kDeltaFactor = 21,kTooBigErrFactor = 100*100}; - -static const double kXtraBigXi2 = 9e9; - -static inline double MyXi2(const double G[3],double dA,double dB) -{ - double Gdet = G[0]*G[2]-G[1]*G[1]; - if (Gdet < 1e-11) return kXtraBigXi2; - double Xi2 = (G[2]*dA*dA-2*G[1]*dA*dB+G[0]*dB*dB)/Gdet; - if (Xi2 > kXtraBigXi2) Xi2 = kXtraBigXi2; - return Xi2; -} - -class TCLx -{ -public: -static int trsinv2x2(const double *pM,double *pMi); -static int trsinv3x3(const double *pM,double *pMi); -static int trsinv4x4(const double *pM,double *pMi); -static int trsinv5x5(const double *pM,double *pMi); -static void Test(); -}; - -#include -#include - -//______________________________________________________________________________ -int TCLx::trsinv2x2(const double *pM,double *pMi) -{ - double F[3]={pM[0],0,pM[2]}; - if (F[0]<1e-20) F[0]=1e-20;if (F[2]>1e+20) F[2]=1e+20; - F[0] =1./F[0]; F[2] =1./F[2]; - F[1] = sqrt(F[0]*F[2]); - for (int i=0;i<3;i++) {pMi[i] = pM[i]*F[i];} - - const double det = pMi[0] * pMi[2] - pMi[1] * pMi[1]; - - if (det<=3e-33) return 1; - const double s = 1./det; - - const double tmp = s*pMi[2]; - pMi[1] = -pMi[1]*s; - pMi[2] = s*pMi[0]; - pMi[0] = tmp; - for (int i=0;i<3;i++) {pMi[i] = pMi[i]*F[i];} - return 0; -} -//______________________________________________________________________________ -int TCLx::trsinv3x3(const double *pM,double *pMi) -{ -// 0 -// 1 2 -// 3 4 5 -// -// 0 1 2 -// 3 4 5 -// 6 7 8 -// -// 2=>3 -// 3=>1 -// 4=>2 -// 5=>4 -// 6=>3 -// 7=>4 -// 8=>5 - - const double c00 = pM[2] * pM[5] - pM[4] * pM[4]; - const double c10 = pM[4] * pM[3] - pM[1] * pM[5]; - const double c20 = pM[1] * pM[4] - pM[2] * pM[3]; - const double c11 = pM[5] * pM[0] - pM[3] * pM[3]; - const double c21 = pM[3] * pM[1] - pM[4] * pM[0]; - const double c22 = pM[0] * pM[2] - pM[1] * pM[1]; - - const double t0 = fabs(pM[0]); - const double t1 = fabs(pM[1]); - const double t2 = fabs(pM[3]); - double det; - double tmp; - if (t0 >= t1) { - if (t2 >= t0) { - tmp = pM[3]; - det = c21*c10-c11*c20; - } else { - tmp = pM[0]; - det = c11*c22-c21*c21; - } - } else if (t2 >= t1) { - tmp = pM[3]; - det = c21*c10-c11*c20; - } else { - tmp = pM[1]; - det = c20*c21-c10*c22; - } - - if (det<=0) return -1; - if (det<=3e-33) return 1; - - const double s = tmp/det; - - pMi[0] = s*c00; - pMi[1] = s*c10; - pMi[2] = s*c11; - pMi[3] = s*c20; - pMi[4] = s*c21; - pMi[5] = s*c22; - return 0; -} -//______________________________________________________________________________ -// GFij are indices for a 4x4 matrix. - -// 0 -// 1 2 -// 3 4 5 -// 6 7 8 9 -#define GF00 0 - -#define GF10 1 -#define GF11 2 - -#define GF20 3 -#define GF21 4 -#define GF22 5 - -#define GF30 6 -#define GF31 7 -#define GF32 8 -#define GF33 9 - -//______________________________________________________________________________ -int TCLx::trsinv4x4(const double *pM,double *pMi) -{ - // Find all NECESSARY 2x2 dets: (18 of them) - - const Double_t det2_12_01 = pM[GF10]*pM[GF21] - pM[GF11]*pM[GF20]; - const Double_t det2_12_02 = pM[GF10]*pM[GF22] - pM[GF21]*pM[GF20]; - const Double_t det2_12_03 = pM[GF10]*pM[GF32] - pM[GF31]*pM[GF20]; - const Double_t det2_12_13 = pM[GF11]*pM[GF32] - pM[GF31]*pM[GF21]; - const Double_t det2_12_23 = pM[GF21]*pM[GF32] - pM[GF31]*pM[GF22]; - const Double_t det2_12_12 = pM[GF11]*pM[GF22] - pM[GF21]*pM[GF21]; - const Double_t det2_13_01 = pM[GF10]*pM[GF31] - pM[GF11]*pM[GF30]; - const Double_t det2_13_02 = pM[GF10]*pM[GF32] - pM[GF21]*pM[GF30]; - const Double_t det2_13_03 = pM[GF10]*pM[GF33] - pM[GF31]*pM[GF30]; - const Double_t det2_13_12 = pM[GF11]*pM[GF32] - pM[GF21]*pM[GF31]; - const Double_t det2_13_13 = pM[GF11]*pM[GF33] - pM[GF31]*pM[GF31]; - const Double_t det2_13_23 = pM[GF21]*pM[GF33] - pM[GF31]*pM[GF32]; - const Double_t det2_23_01 = pM[GF20]*pM[GF31] - pM[GF21]*pM[GF30]; - const Double_t det2_23_02 = pM[GF20]*pM[GF32] - pM[GF22]*pM[GF30]; - const Double_t det2_23_03 = pM[GF20]*pM[GF33] - pM[GF32]*pM[GF30]; - const Double_t det2_23_12 = pM[GF21]*pM[GF32] - pM[GF22]*pM[GF31]; - const Double_t det2_23_13 = pM[GF21]*pM[GF33] - pM[GF32]*pM[GF31]; - const Double_t det2_23_23 = pM[GF22]*pM[GF33] - pM[GF32]*pM[GF32]; - - // Find all NECESSARY 3x3 dets: (16 of them) - - const Double_t det3_012_012 = pM[GF00]*det2_12_12 - pM[GF10]*det2_12_02 - + pM[GF20]*det2_12_01; - const Double_t det3_012_013 = pM[GF00]*det2_12_13 - pM[GF10]*det2_12_03 - + pM[GF30]*det2_12_01; - const Double_t det3_012_023 = pM[GF00]*det2_12_23 - pM[GF20]*det2_12_03 - + pM[GF30]*det2_12_02; - const Double_t det3_012_123 = pM[GF10]*det2_12_23 - pM[GF20]*det2_12_13 - + pM[GF30]*det2_12_12; - const Double_t det3_013_013 = pM[GF00]*det2_13_13 - pM[GF10]*det2_13_03 - + pM[GF30]*det2_13_01; - const Double_t det3_013_023 = pM[GF00]*det2_13_23 - pM[GF20]*det2_13_03 - + pM[GF30]*det2_13_02; - const Double_t det3_013_123 = pM[GF10]*det2_13_23 - pM[GF20]*det2_13_13 - + pM[GF30]*det2_13_12; - const Double_t det3_023_023 = pM[GF00]*det2_23_23 - pM[GF20]*det2_23_03 - + pM[GF30]*det2_23_02; - const Double_t det3_023_123 = pM[GF10]*det2_23_23 - pM[GF20]*det2_23_13 - + pM[GF30]*det2_23_12; - const Double_t det3_123_012 = pM[GF10]*det2_23_12 - pM[GF11]*det2_23_02 - + pM[GF21]*det2_23_01; - const Double_t det3_123_013 = pM[GF10]*det2_23_13 - pM[GF11]*det2_23_03 - + pM[GF31]*det2_23_01; - const Double_t det3_123_023 = pM[GF10]*det2_23_23 - pM[GF21]*det2_23_03 - + pM[GF31]*det2_23_02; - const Double_t det3_123_123 = pM[GF11]*det2_23_23 - pM[GF21]*det2_23_13 - + pM[GF31]*det2_23_12; - - // Find the 4x4 det: - - const Double_t det = pM[GF00]*det3_123_123 - pM[GF10]*det3_123_023 - + pM[GF20]*det3_123_013 - pM[GF30]*det3_123_012; - - if (det<=3e-33) return 1; - - const Double_t oneOverDet = 1.0/det; - const Double_t mn1OverDet = - oneOverDet; - - pMi[GF00] = det3_123_123 * oneOverDet; - pMi[GF10] = det3_023_123 * mn1OverDet; - pMi[GF20] = det3_013_123 * oneOverDet; - pMi[GF30] = det3_012_123 * mn1OverDet; - - pMi[GF11] = det3_023_023 * oneOverDet; - pMi[GF21] = det3_013_023 * mn1OverDet; - pMi[GF31] = det3_012_023 * oneOverDet; - - pMi[GF22] = det3_013_013 * oneOverDet; - pMi[GF32] = det3_012_013 * mn1OverDet; - - pMi[GF33] = det3_012_012 * oneOverDet; - return 0; - -} -// GMij are indices for a 5x5 matrix. - -// 0 -// 1 2 -// 3 4 5 -// 6 7 8 9 -// 10 11 12 13 14 -#define GM00 0 - -#define GM10 1 -#define GM11 2 - -#define GM20 3 -#define GM21 4 -#define GM22 5 - -#define GM30 6 -#define GM31 7 -#define GM32 8 -#define GM33 9 - -#define GM40 10 -#define GM41 11 -#define GM42 12 -#define GM43 13 -#define GM44 14 - -//______________________________________________________________________________ -int TCLx::trsinv5x5(const double *pMp,double *pMi) -{ - double F[5],pM[15]; - for (int i=0,li=0;i< 5;li+=++i) { - F[i] = sqrt(pMp[li+i]); - if (F[i]<1e-10) F[i]=1e-10; - if (F[i]>1e+10) F[i]=1e+10; - } - - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++) { - pM[li+j] = pMp[li+j]/F[i]/F[j]; - } } - // Find all NECESSARY 2x2 dets: (30 of them) - - const Double_t det2_23_01 = pM[GM20]*pM[GM31] - pM[GM21]*pM[GM30]; - const Double_t det2_23_02 = pM[GM20]*pM[GM32] - pM[GM22]*pM[GM30]; - const Double_t det2_23_03 = pM[GM20]*pM[GM33] - pM[GM32]*pM[GM30]; - const Double_t det2_23_04 = pM[GM20]*pM[GM43] - pM[GM42]*pM[GM30]; - const Double_t det2_23_12 = pM[GM21]*pM[GM32] - pM[GM22]*pM[GM31]; - const Double_t det2_23_13 = pM[GM21]*pM[GM33] - pM[GM32]*pM[GM31]; - const Double_t det2_23_14 = pM[GM21]*pM[GM43] - pM[GM42]*pM[GM31]; - const Double_t det2_23_23 = pM[GM22]*pM[GM33] - pM[GM32]*pM[GM32]; - const Double_t det2_23_24 = pM[GM22]*pM[GM43] - pM[GM42]*pM[GM32]; - const Double_t det2_23_34 = pM[GM32]*pM[GM43] - pM[GM42]*pM[GM33]; - const Double_t det2_24_01 = pM[GM20]*pM[GM41] - pM[GM21]*pM[GM40]; - const Double_t det2_24_02 = pM[GM20]*pM[GM42] - pM[GM22]*pM[GM40]; - const Double_t det2_24_03 = pM[GM20]*pM[GM43] - pM[GM32]*pM[GM40]; - const Double_t det2_24_04 = pM[GM20]*pM[GM44] - pM[GM42]*pM[GM40]; - const Double_t det2_24_12 = pM[GM21]*pM[GM42] - pM[GM22]*pM[GM41]; - const Double_t det2_24_13 = pM[GM21]*pM[GM43] - pM[GM32]*pM[GM41]; - const Double_t det2_24_14 = pM[GM21]*pM[GM44] - pM[GM42]*pM[GM41]; - const Double_t det2_24_23 = det2_23_24; - const Double_t det2_24_24 = pM[GM22]*pM[GM44] - pM[GM42]*pM[GM42]; - const Double_t det2_24_34 = pM[GM32]*pM[GM44] - pM[GM42]*pM[GM43]; - const Double_t det2_34_01 = pM[GM30]*pM[GM41] - pM[GM31]*pM[GM40]; - const Double_t det2_34_02 = pM[GM30]*pM[GM42] - pM[GM32]*pM[GM40]; - const Double_t det2_34_03 = pM[GM30]*pM[GM43] - pM[GM33]*pM[GM40]; - const Double_t det2_34_04 = pM[GM30]*pM[GM44] - pM[GM43]*pM[GM40]; - const Double_t det2_34_12 = pM[GM31]*pM[GM42] - pM[GM32]*pM[GM41]; - const Double_t det2_34_13 = pM[GM31]*pM[GM43] - pM[GM33]*pM[GM41]; - const Double_t det2_34_14 = pM[GM31]*pM[GM44] - pM[GM43]*pM[GM41]; - const Double_t det2_34_23 = det2_23_34; - - const Double_t det2_34_24 = pM[GM32]*pM[GM44] - pM[GM43]*pM[GM42]; - const Double_t det2_34_34 = pM[GM33]*pM[GM44] - pM[GM43]*pM[GM43]; - - // Find all NECESSARY 3x3 dets: (40 of them) - - const Double_t det3_123_012 = pM[GM10]*det2_23_12 - pM[GM11]*det2_23_02 + pM[GM21]*det2_23_01; - const Double_t det3_123_013 = pM[GM10]*det2_23_13 - pM[GM11]*det2_23_03 + pM[GM31]*det2_23_01; - const Double_t det3_123_014 = pM[GM10]*det2_23_14 - pM[GM11]*det2_23_04 + pM[GM41]*det2_23_01; - const Double_t det3_123_023 = pM[GM10]*det2_23_23 - pM[GM21]*det2_23_03 + pM[GM31]*det2_23_02; - const Double_t det3_123_024 = pM[GM10]*det2_23_24 - pM[GM21]*det2_23_04 + pM[GM41]*det2_23_02; - const Double_t det3_123_034 = pM[GM10]*det2_23_34 - pM[GM31]*det2_23_04 + pM[GM41]*det2_23_03; - const Double_t det3_123_123 = pM[GM11]*det2_23_23 - pM[GM21]*det2_23_13 + pM[GM31]*det2_23_12; - const Double_t det3_123_124 = pM[GM11]*det2_23_24 - pM[GM21]*det2_23_14 + pM[GM41]*det2_23_12; - const Double_t det3_123_134 = pM[GM11]*det2_23_34 - pM[GM31]*det2_23_14 + pM[GM41]*det2_23_13; - const Double_t det3_123_234 = pM[GM21]*det2_23_34 - pM[GM31]*det2_23_24 + pM[GM41]*det2_23_23; - const Double_t det3_124_012 = pM[GM10]*det2_24_12 - pM[GM11]*det2_24_02 + pM[GM21]*det2_24_01; - const Double_t det3_124_013 = pM[GM10]*det2_24_13 - pM[GM11]*det2_24_03 + pM[GM31]*det2_24_01; - const Double_t det3_124_014 = pM[GM10]*det2_24_14 - pM[GM11]*det2_24_04 + pM[GM41]*det2_24_01; - const Double_t det3_124_023 = pM[GM10]*det2_24_23 - pM[GM21]*det2_24_03 + pM[GM31]*det2_24_02; - const Double_t det3_124_024 = pM[GM10]*det2_24_24 - pM[GM21]*det2_24_04 + pM[GM41]*det2_24_02; - const Double_t det3_124_034 = pM[GM10]*det2_24_34 - pM[GM31]*det2_24_04 + pM[GM41]*det2_24_03; - const Double_t det3_124_123 = pM[GM11]*det2_24_23 - pM[GM21]*det2_24_13 + pM[GM31]*det2_24_12; - const Double_t det3_124_124 = pM[GM11]*det2_24_24 - pM[GM21]*det2_24_14 + pM[GM41]*det2_24_12; - const Double_t det3_124_134 = pM[GM11]*det2_24_34 - pM[GM31]*det2_24_14 + pM[GM41]*det2_24_13; - const Double_t det3_124_234 = pM[GM21]*det2_24_34 - pM[GM31]*det2_24_24 + pM[GM41]*det2_24_23; - const Double_t det3_134_013 = pM[GM10]*det2_34_13 - pM[GM11]*det2_34_03 + pM[GM31]*det2_34_01; - const Double_t det3_134_014 = pM[GM10]*det2_34_14 - pM[GM11]*det2_34_04 + pM[GM41]*det2_34_01; - const Double_t det3_134_023 = pM[GM10]*det2_34_23 - pM[GM21]*det2_34_03 + pM[GM31]*det2_34_02; - const Double_t det3_134_024 = pM[GM10]*det2_34_24 - pM[GM21]*det2_34_04 + pM[GM41]*det2_34_02; - const Double_t det3_134_034 = pM[GM10]*det2_34_34 - pM[GM31]*det2_34_04 + pM[GM41]*det2_34_03; - const Double_t det3_134_123 = pM[GM11]*det2_34_23 - pM[GM21]*det2_34_13 + pM[GM31]*det2_34_12; - const Double_t det3_134_124 = pM[GM11]*det2_34_24 - pM[GM21]*det2_34_14 + pM[GM41]*det2_34_12; - const Double_t det3_134_134 = pM[GM11]*det2_34_34 - pM[GM31]*det2_34_14 + pM[GM41]*det2_34_13; - const Double_t det3_134_234 = pM[GM21]*det2_34_34 - pM[GM31]*det2_34_24 + pM[GM41]*det2_34_23; - const Double_t det3_234_012 = pM[GM20]*det2_34_12 - pM[GM21]*det2_34_02 + pM[GM22]*det2_34_01; - const Double_t det3_234_013 = pM[GM20]*det2_34_13 - pM[GM21]*det2_34_03 + pM[GM32]*det2_34_01; - const Double_t det3_234_014 = pM[GM20]*det2_34_14 - pM[GM21]*det2_34_04 + pM[GM42]*det2_34_01; - const Double_t det3_234_023 = pM[GM20]*det2_34_23 - pM[GM22]*det2_34_03 + pM[GM32]*det2_34_02; - const Double_t det3_234_024 = pM[GM20]*det2_34_24 - pM[GM22]*det2_34_04 + pM[GM42]*det2_34_02; - const Double_t det3_234_034 = pM[GM20]*det2_34_34 - pM[GM32]*det2_34_04 + pM[GM42]*det2_34_03; - const Double_t det3_234_123 = pM[GM21]*det2_34_23 - pM[GM22]*det2_34_13 + pM[GM32]*det2_34_12; - const Double_t det3_234_124 = pM[GM21]*det2_34_24 - pM[GM22]*det2_34_14 + pM[GM42]*det2_34_12; - const Double_t det3_234_134 = pM[GM21]*det2_34_34 - pM[GM32]*det2_34_14 + pM[GM42]*det2_34_13; - const Double_t det3_234_234 = pM[GM22]*det2_34_34 - pM[GM32]*det2_34_24 + pM[GM42]*det2_34_23; - - // Find all NECESSARY 4x4 dets: (25 of them) - - const Double_t det4_0123_0123 = pM[GM00]*det3_123_123 - pM[GM10]*det3_123_023 - + pM[GM20]*det3_123_013 - pM[GM30]*det3_123_012; - const Double_t det4_0123_0124 = pM[GM00]*det3_123_124 - pM[GM10]*det3_123_024 - + pM[GM20]*det3_123_014 - pM[GM40]*det3_123_012; - const Double_t det4_0123_0134 = pM[GM00]*det3_123_134 - pM[GM10]*det3_123_034 - + pM[GM30]*det3_123_014 - pM[GM40]*det3_123_013; - const Double_t det4_0123_0234 = pM[GM00]*det3_123_234 - pM[GM20]*det3_123_034 - + pM[GM30]*det3_123_024 - pM[GM40]*det3_123_023; - const Double_t det4_0123_1234 = pM[GM10]*det3_123_234 - pM[GM20]*det3_123_134 - + pM[GM30]*det3_123_124 - pM[GM40]*det3_123_123; - const Double_t det4_0124_0124 = pM[GM00]*det3_124_124 - pM[GM10]*det3_124_024 - + pM[GM20]*det3_124_014 - pM[GM40]*det3_124_012; - const Double_t det4_0124_0134 = pM[GM00]*det3_124_134 - pM[GM10]*det3_124_034 - + pM[GM30]*det3_124_014 - pM[GM40]*det3_124_013; - const Double_t det4_0124_0234 = pM[GM00]*det3_124_234 - pM[GM20]*det3_124_034 - + pM[GM30]*det3_124_024 - pM[GM40]*det3_124_023; - const Double_t det4_0124_1234 = pM[GM10]*det3_124_234 - pM[GM20]*det3_124_134 - + pM[GM30]*det3_124_124 - pM[GM40]*det3_124_123; - const Double_t det4_0134_0134 = pM[GM00]*det3_134_134 - pM[GM10]*det3_134_034 - + pM[GM30]*det3_134_014 - pM[GM40]*det3_134_013; - const Double_t det4_0134_0234 = pM[GM00]*det3_134_234 - pM[GM20]*det3_134_034 - + pM[GM30]*det3_134_024 - pM[GM40]*det3_134_023; - const Double_t det4_0134_1234 = pM[GM10]*det3_134_234 - pM[GM20]*det3_134_134 - + pM[GM30]*det3_134_124 - pM[GM40]*det3_134_123; - const Double_t det4_0234_0234 = pM[GM00]*det3_234_234 - pM[GM20]*det3_234_034 - + pM[GM30]*det3_234_024 - pM[GM40]*det3_234_023; - const Double_t det4_0234_1234 = pM[GM10]*det3_234_234 - pM[GM20]*det3_234_134 - + pM[GM30]*det3_234_124 - pM[GM40]*det3_234_123; - const Double_t det4_1234_0123 = pM[GM10]*det3_234_123 - pM[GM11]*det3_234_023 - + pM[GM21]*det3_234_013 - pM[GM31]*det3_234_012; - const Double_t det4_1234_0124 = pM[GM10]*det3_234_124 - pM[GM11]*det3_234_024 - + pM[GM21]*det3_234_014 - pM[GM41]*det3_234_012; - const Double_t det4_1234_0134 = pM[GM10]*det3_234_134 - pM[GM11]*det3_234_034 - + pM[GM31]*det3_234_014 - pM[GM41]*det3_234_013; - const Double_t det4_1234_0234 = pM[GM10]*det3_234_234 - pM[GM21]*det3_234_034 - + pM[GM31]*det3_234_024 - pM[GM41]*det3_234_023; - const Double_t det4_1234_1234 = pM[GM11]*det3_234_234 - pM[GM21]*det3_234_134 - + pM[GM31]*det3_234_124 - pM[GM41]*det3_234_123; - - // Find the 5x5 det: - - const Double_t det = pM[GM00]*det4_1234_1234 - pM[GM10]*det4_1234_0234 + pM[GM20]*det4_1234_0134 - - pM[GM30]*det4_1234_0124 + pM[GM40]*det4_1234_0123; - - if (det<= 0) return -1; - if (det<=3e-33) return 1; - - const Double_t oneOverDet = 1.0/det; - const Double_t mn1OverDet = - oneOverDet; - - pMi[GM00] = det4_1234_1234 * oneOverDet; - pMi[GM10] = det4_0234_1234 * mn1OverDet; - pMi[GM20] = det4_0134_1234 * oneOverDet; - pMi[GM30] = det4_0124_1234 * mn1OverDet; - pMi[GM40] = det4_0123_1234 * oneOverDet; - - pMi[GM11] = det4_0234_0234 * oneOverDet; - pMi[GM21] = det4_0134_0234 * mn1OverDet; - pMi[GM31] = det4_0124_0234 * oneOverDet; - pMi[GM41] = det4_0123_0234 * mn1OverDet; - - pMi[GM22] = det4_0134_0134 * oneOverDet; - pMi[GM32] = det4_0124_0134 * mn1OverDet; - pMi[GM42] = det4_0123_0134 * oneOverDet; - - pMi[GM33] = det4_0124_0124 * oneOverDet; - pMi[GM43] = det4_0123_0124 * mn1OverDet; - - pMi[GM44] = det4_0123_0123 * oneOverDet; - - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++) { - pMi[li+j] = pMi[li+j]/F[i]/F[j]; - } } - return 0; -} -#include "TCernLib.h" -#include "TRandom.h" - -//______________________________________________________________________________ -void TCLx::Test() -{ - int nErr = 0; - double e[15],e1inv[15],e2inv[15]; - for (int i=0,li=0;i< 5;li+=++i) { - e[li+i] = gRandom->Rndm()*10+10; - for (int j=0;jRndm(); - } } - - for (int N=2;N<=5;N++) { - TCL::trsinv(e,e1inv,N); - switch (N) { - case 2:TCLx::trsinv2x2(e,e2inv); break; - case 3:TCLx::trsinv3x3(e,e2inv); break; - case 4:TCLx::trsinv4x4(e,e2inv); break; - case 5:TCLx::trsinv5x5(e,e2inv); break; - default: assert(0); - } - int l = (N*N+N)/2; - for (int i=0;i ard(nE2+nP2*2+1); - double *a = &ard[0]; - double *P1sP2 = a; a+=nP2; //=P1-P2 - double *Ptmp = a; a+=nP2; //=tmp vector - double *E1aE2i = a; a+=nE2; //=(E1+E2)**(-1) - *a = 1946; - - if (P2) { TCL::vsub (P1,P2,P1sP2,nP1);} - else { TCL::ucopy(P1, P1sP2,nP1);} - TCL::vadd (E1,E2,E1aE2i,nE1); - if (nP1delta(); mDelta *= kDeltaFactor; - -} -//______________________________________________________________________________ -void StvFitter::Prep() -{ - mDelta = mInPars->delta(); mDelta *= kDeltaFactor; - mHit = 0; mHitPlane = 0; - double myTan = mInPars->_tanl; - mCos2L = 1./(1+myTan*myTan); - mCosL = sqrt(mCos2L); - mSinL = myTan*mCosL; - mCosP = mInPars->_cosCA; - mSinP = mInPars->_sinCA; - - mTkPars = *mInPars; -// Track Frame - mDcaFrame[0][0] = mCosL*mCosP; - mDcaFrame[0][1] = mCosL*mSinP; - mDcaFrame[0][2] = mSinL; - - mDcaFrame[1][0] = -mSinP; - mDcaFrame[1][1] = mCosP; - mDcaFrame[1][2] = 0; - - mDcaFrame[2][0] = -mSinL*mCosP; - mDcaFrame[2][1] = -mSinL*mSinP; - mDcaFrame[2][2] = mCosL; - -} -//______________________________________________________________________________ -double StvFitter::Xi2(const StvHit *hit) -{ - if (mHit == hit) return mXi2; - mFailed = 0; - mHit = hit; - const float *errMtx=mHit->errMtx(); - if (!mHit->IsHit()) mKase=2; //Hit is a vertex - - mHitPlane = mHit->detector(); - -// restore old parameters for nhits>1 - mTkPars._x = mInPars->_x; mTkPars._y = mInPars->_y; mTkPars._z = mInPars->_z; - -// Hit position - const float *hP = mHit->x(); - -// Track direction - double *tD = mDcaFrame[0]; -// Start track position - double *tP = &mTkPars._x; - - -// Distance to DCA along track in xy -//mDeltaL = DDOT(hP,tP,tD); -// DCA track position - switch (mKase) { - case 0: { - mHitErrCalc = (StvHitErrCalculator*)mHitPlane->GetHitErrCalc(); - assert(mHitErrCalc); - mHitErrCalc->SetTrack(tD); -// const StHitPlane *hp = hit->detector(); -// const Mtx33F_t &hD = hp->GetDir(hit->x()); -// int ans = mHitErrCalc->CalcDcaErrs(hit->x(),hD,mHitErrs); - int ans = mHitErrCalc->CalcDcaErrs(hit,mHitErrs); - if (ans) {mXi2 = 1e11; return mXi2;} - assert(mHitErrs[0]>=1e-8); - assert(mHitErrs[1]*mHitErrs[1]<=mHitErrs[0]*mHitErrs[2]); - assert(mHitErrs[2]>=1e-8); - }; break; - - case 1: assert(0 && "Wrong case 1"); - - case 2: { - double d[6]={errMtx[0],errMtx[1],errMtx[2] - ,errMtx[3],errMtx[4],errMtx[5]}; - TCL::trasat(mDcaFrame[1],d,mHitErrs,2,3); } - } - assert(mHitErrs[0]>0); - assert(mHitErrs[2]>0); - assert(mHitErrs[2]*mHitErrs[0]>mHitErrs[1]*mHitErrs[1]); - -// Hit position wrt track - double dca[3] = {hP[0]-tP[0],hP[1]-tP[1],hP[2]-tP[2]}; - - mDcaT=VDOT(mDcaFrame[0],dca); - mDcaP=VDOT(mDcaFrame[1],dca); - mDcaL=VDOT(mDcaFrame[2],dca); -// small account non zero distance to hit along track - double dS = mDcaT*mCosL; - mDcaP-= 0.5*mTkPars._curv*dS*dS; - - double G[3] = {mInErrs->mHH,mInErrs->mHZ,mInErrs->mZZ}; - if (mKase==0) {// Include Hit Errs -//VP?? if (G[0]+G[2]>(mHitErrs[0]+mHitErrs[2])*kTooBigErrFactor) mFailed = kBigErrs; - for (int j=0;j<3;j++) {G[j]+=mHitErrs[j];} - }// end Include Hit Errs - -// (BB*dX*dX-2*BA*dX*dY+AAdY*dY)/det - mXi2 = MyXi2(G,mDcaP,mDcaL); - return mXi2 ; -} -//______________________________________________________________________________ -double StvFitter::Xi2() -{ - mFailed = 0; - double inErr = mInErrs->mHH+mInErrs->mZZ; - double jnErr = mJnErrs->mHH+mJnErrs->mZZ; - if (jnErr>inErr) {//Not good order - const StvNodePars *swp = mInPars; mInPars=mJnPars; mJnPars=swp; - const StvFitErrs *swe = mInErrs; mInErrs=mJnErrs; mJnErrs=swe; - } - - StvFitPars F = (*mInPars-*mJnPars); - double Zero[5]= {0}; - mXi2 = JoinTwo(5,F.Arr() ,mInErrs->Arr() - ,5,Zero ,mJnErrs->Arr() - ,mQQPars.Arr(),mQQErrs.Arr()); - mFailed = (mXi2>kXtraBigXi2); - return mXi2; -} -//______________________________________________________________________________ -int StvFitter::Update() -{ -static int nCall=0; nCall++; -StvDebug::Break(nCall); - if(mFailed>0) return mFailed; - mFailed = 0; - switch (mKase) { - case 0: mFailed = Hpdate(); break; //Hit+Track - case 1: mFailed = Jpdate(); break; //Track join - case 2: mFailed = Vpdate(); break; //Vertex+track - } - - double fak = 1.; - for (int i=0;i<5;i++) { - double f = fabs(mQQPars[i])/mDelta[i]; - if (fak1.) { mFailed = kBigVari; TCL::vscale(mQQPars,1./fak,mQQPars,5);} - - *mOtPars+= mQQPars; - mOtErrs->SetHz(mOtPars->_hz); - return mFailed; -} -//______________________________________________________________________________ -int StvFitter::Hpdate() -{ -/// this is Update for track+hit fit - - mTkErrs = *mInErrs; - - -// New Z ortogonal to X (track direction) - StvFitPars myHitPars(mDcaP, mDcaL ); - StvFitErrs myHitErrs(mHitErrs[0],mHitErrs[1],mHitErrs[2]); - StvFitPars myTrkPars; - - double myXi2 = JoinTwo(2,myHitPars.Arr(),myHitErrs.Arr() - ,5,myTrkPars.Arr(),mTkErrs.Arr() - , mQQPars.Arr(),mOtErrs->Arr()); - mFailed = (myXi2>kXtraBigXi2); - *mOtPars = mTkPars; - - return mFailed; -} -//______________________________________________________________________________ -int StvFitter::Vpdate() -{ -/// this is Update for track+vertex fit -static int nCall=0; nCall++; - mTkErrs = *mInErrs; - -// New Z ortogonal to X (track direction) - StvFitPars myHitPars(mDcaP, mDcaL ); - StvFitPars myTrkPars; - - double myXi2 = JoinVtx(2,myHitPars.Arr(),mHitErrs - ,5,myTrkPars.Arr(),mTkErrs.Arr() - , mQQPars.Arr(),mOtErrs->Arr()); - if (myXi2){} - *mOtPars = mTkPars; - for (int i=0;i<3;i++) {mOtErrs->Arr()[i]+=mHitErrs[i];} - return 0; -} -//______________________________________________________________________________ -int StvFitter::Jpdate() -{ -/// this is Update for sub track+sub track fit (join) - *mOtPars = *mJnPars; - *mOtErrs = mQQErrs; - return mFailed; -} -//______________________________________________________________________________ -double StvFitter::TooBig(StvFitPars &fp, int *mask) const -{ - double fakt = 0; - int msk=0; - for (int i=0;i<5;i++) { - double f = fabs(fp[i])/mDelta[i]; - if (fakt>f) continue; - fakt=f; msk|= 1< -#include -#include -#include -#include "TNamed.h" -#include "StvUtil/StvNodePars.h" - -class StvHit; -class StvNodePars; -class StvHitErrs; -class StHitPlane; -class StvHitErrCalculator; - - -class StvFitter : public TNamed { -public: -enum E_Failed {kBigVari=-1,kBigErrs=-99}; - -public: -StvFitter(const char *name="DefaultFitter"); - void Set(const StvNodePars *inPars, const StvFitErrs *inErrs - , StvNodePars *otPars=0, StvFitErrs *otErrs=0); - void Set(const StvNodePars *inPars, const StvFitErrs *inErrs - ,const StvNodePars *jnPars, const StvFitErrs *jnErrs - , StvNodePars *otPars, StvFitErrs *otErrs); - int IsFailed() const {return mFailed;} -const double *GetHitErrs() const {return mHitErrs;} - void Prep(); - -double Xi2(const StvHit *hit); //Xi2 for hit or vertex -double Xi2(); //Xi2 for 2 subtracks joining -double GetXi2() {return mXi2;} //evaluated Xi2 -int Update(); -static StvFitter *Inst() {return mgFitter;} - -private: -double TooBig(StvFitPars &fp, int *mask) const; -private: -int Hpdate(); //Update Hit fit -int Jpdate(); //Updatejoin fit -int Vpdate(); //Update vertex fit -// static double JoinTwo(int nP1,const double *P1,const double *E1 -// ,int nP2,const double *P2,const double *E2 -// , double *PJ, double *EJ -// ,int mode=0); -static void Test(); -protected: - char mBeg[1]; - char mFailed; //Fail flag. Something completely wrong - char mKase; //0=fit to hit,1=refit,2=fit to vertex -const StvNodePars *mInPars; //1st input params -const StvFitErrs *mInErrs; //1st input params errors -const StvNodePars *mJnPars; //2nd input params -const StvFitErrs *mJnErrs; //2nd input params errors - StvNodePars *mOtPars; //Output params - StvFitErrs *mOtErrs; //Output errors -const StvHit *mHit; -const StHitPlane *mHitPlane; - StvHitErrCalculator *mHitErrCalc; - StvNodePars mTkPars; - StvFitErrs mTkErrs; - StvFitPars mQQPars; - StvFitErrs mQQErrs; - StvFitPars mDelta; //typical deltas for parameters in current env - double mHitErrs[3]; - double mCos2L,mCosL,mSinL,mCosP,mSinP,mXi2,mDeltaL; - double mDcaT,mDcaP,mDcaL; - double mDcaFrame[3][3]; - char mEnd[1]; -static StvFitter *mgFitter; -}; -#endif //__StvFitter_h_ - - diff --git a/StRoot/Stv/StvHit.cxx b/StRoot/Stv/StvHit.cxx deleted file mode 100644 index 04767792917..00000000000 --- a/StRoot/Stv/StvHit.cxx +++ /dev/null @@ -1,101 +0,0 @@ -//StvHit.cxx -//M.L. Miller (Yale Software) -//04/01 -//Rewritten V.Perev 01/2010 -#include -#include -#include "TError.h" -#include "TCernLib.h" -#include "Stiostream.h" -#include "StvHit.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - - -//_____________________________________________________________________________ -StvHit::StvHit() -{ - reset(); -} - -// //_____________________________________________________________________________ -// StvHit::StvHit(const StvHit &h) -// { -// memcpy(mBeg,h.mBeg,mEnd-mBeg+1); -// } -// -// //_____________________________________________________________________________ -// const StvHit& StvHit::operator=(const StvHit & h) -// { -// memcpy(mBeg,h.mBeg,mEnd-mBeg+1); -// return *this; -// } -// -//_____________________________________________________________________________ -StvHit::~StvHit() -{} -//_____________________________________________________________________________ -void StvHit::reset() -{ - memset(mBeg,0,mEnd-mBeg+1); - mMaxTimes = 1; -static unsigned int myCount=0; - mCount = ++myCount; -} -//_____________________________________________________________________________ -void StvHit::set(const void *stHit,const float *gx) -{ - memcpy(mGlo,gx,sizeof(mGlo)); - msthit = stHit; - return; -} -//_____________________________________________________________________________ -double StvHit::err2() const -{ - return ((StvHitErrCalculator*)(mDetector->GetHitErrCalc()))->Trace(mGlo); -} -//_____________________________________________________________________________ -int StvHit::detectorId() const -{ return (int)detector()->GetDetId(); } -//_____________________________________________________________________________ -void StvVertex::set(const float *x,const float matrix[6]) -{ - memcpy(mGlo,x ,sizeof(mGlo)); - memcpy(mErr,matrix,sizeof(mErr)); -} -//_____________________________________________________________________________ -void StvVertex::reset() -{ - memset(mErr,0,sizeof(mErr)); mKount=0; - StvHit::reset(); -} -//_____________________________________________________________________________ - void StvHit::setTimesUsed(int n) -{ - if (!mDetector) return; - mTimesUsed=n; -} -//_____________________________________________________________________________ - void StvHit::addTimesUsed() -{ - if (!mDetector) return; - mTimesUsed++; - assert(mTimesUsed<=mMaxTimes); -} -//_____________________________________________________________________________ - void StvHit::subTimesUsed() -{ - if (!mDetector) return; - mTimesUsed--; - assert(mTimesUsed>=0); -} - - - - - - - - - - diff --git a/StRoot/Stv/StvHit.h b/StRoot/Stv/StvHit.h deleted file mode 100644 index c70e46037d0..00000000000 --- a/StRoot/Stv/StvHit.h +++ /dev/null @@ -1,173 +0,0 @@ -/*! \class StvHit - StvHit is a simple class that encapsulates a three dimensional position - measurement. The measurement is represented in a frame - that is 'local' to the detector plane from which it arose. -

- It is assumed - that all hits come from a detector that can be composed of discrete planes. - Each plane is characterized by two values: position and refAngle. In the - mid-rapidity region of STAR (SVT, TPC, EMC, etc) the position corresponds to - the magnitude of a vector pointing from the origin to the center of the plane. - The refAngle is the azimuthal defined by the aforemention vector and the - STAR global x-axis. All hits store the position and refAngle of the detector - plane from which they came. -

- Within each detector plane, the hit is characterized by two more numbers: - y and z. The y value corresponds to the distance along the plane (e.g., - padrow) w.r.t. the center of the plane. The z value corresponds to the STAR - global coordinate. -

- While it only takes two values (y and z) two specify the hit location within - a plane (once the location of the plane is known) StvHit stores one more - value: x. This value of x corresponds to the magnitude of a vector pointing - from the origin to the detector plane perpendicular to the plane. So, - for planes with no tilt w.r.t. the origin (e.g., TPC pad-planes), x will be - identical to position. Actually, this is not even quite true for tpc hits, as - distortion corrections can make x slightly different than position. However, - by storing both x and position, we allow for the separation of information - that depends only on material location (track fitting) from that which - depends only on hit location (track finding). -

- StvHit stores information that represents a full error matrix. For efficiency - purposes this is stored as a collection of discreet floats instead of a - matrix. Because the error matrix is always symmetric, we must store only six - values. These are denoted by s_ij, where s_ij corresponds to the (i,j) - component of the matrix. -

- StvHit also stores a pointer to an StHit that it corresponds to. - Additionally, StvHit stores a pointer to the StDetector object from which its - measurement arose. - - \author M.L. Miller (Yale Software) - */ - -#ifndef StvHit_HH -#define StvHit_HH -#include "assert.h" -#include "math.h" -class StHitPlane; -class StvHit -{ -public: - - ///Default constructor. - StvHit(); -// StvHit(const StvHit&); -// const StvHit& operator=(const StvHit& ); - ///Default destructor. - ~StvHit(); - - ///Return the global x, y, z values. - const float *x() const {return mGlo;} - float getRxy() const {return sqrt(mGlo[0]*mGlo[0]+mGlo[1]*mGlo[1]);} - ///Return the type of class - virtual int IsHit() const {return 1;} - int IsCombo() const {return mCombo;} - void SetCombo(int combo) {mCombo = combo;} - - ///Return components of the error matrix. - virtual const float *errMtx() const {return 0;} - virtual float *errMtx() {return 0;} - virtual double err2() const; - ///Return a const pointer to the StHitPlane object from which the hit - ///arose. - const StHitPlane* detector() const {return mDetector;} - int detectorId() const; - int idTru() const {return mIdTru;}; - ///Return a const pointer to the StHit object corresponding to this StvHit - ///instance - //const StHit* stHit() const - const void *stHit() const {return msthit;} - void setStHit(const void *stHit) { msthit=stHit;} - void setIdTru(int idTru) { mIdTru=idTru;} - - ///Set the global position one function call - void set(const StHitPlane* detector) {mDetector = detector;} - void set(const void *stHit,const float x[3]); - ///Set the global position and error - virtual void set(const float *x,const float *err){assert(0);} - virtual void addCount() {assert(0);} - virtual void setCount(int kount) {assert(0);} - virtual int getCount() const {assert(0);} - - ///Set the position error matrix for the measurement from an float array - ///object. - virtual void setError(const float errMx[6]){ assert(0);} - - ///Set the number of times used - ///Return the number of times this hit was assigned to a track - void setMaxTimes(int set) {mMaxTimes = set;} - void setTimesUsed(int set=0); - void addTimesUsed(); - void subTimesUsed(); - ///Return a boolean that marks whether or not this hit is assigned to a - ///track >= than max times. - virtual int timesUsed() const { return mTimesUsed;} - int isUsed() const {return mTimesUsed>=mMaxTimes;} - virtual void reset(); - void unset(){;} -protected: - char mBeg[1]; - unsigned char mMaxTimes; - unsigned char mTimesUsed; - unsigned char mCombo; - float mGlo[3]; //global position - const void *msthit; - const StHitPlane *mDetector; - int mIdTru; - // drift velocities cm/mksec( 0 for non driting ) - char mEnd[1]; -public: - int mCount; -}; - -class StvHitRr : public StvHit -{ -public: - - ///Default constructor. - StvHitRr(){mErr[0] = -999;} - ///Default destructor. - ~StvHitRr(){;} - ///Set the position error matrix for the measurement from an float array - ///object. - - const float *errMtx() const {return mErr;} - float *errMtx() {return mErr;} - virtual double err2() const {return mErr[0]+mErr[2];} - -protected: - float mErr[6]; //error matrix -}; - - -class StvVertex : public StvHit -{ -public: - - ///Default constructor. - StvVertex(){;} - ///Default destructor. - ~StvVertex(){;} - ///Set the position error matrix for the measurement from an float array - ///object. - virtual int IsHit() const {return 0;} - void reset(); - void set(const float *x,const float *err); - virtual int timesUsed() const { return 0;} - virtual void addTimesUsed(int){;} - virtual void setTimesUsed(int){;} - - virtual void addCount() {mKount++ ;} - virtual void setCount(int kount) {mKount=kount ;} - virtual int getCount() const {return mKount;} - - const float *errMtx() const {return mErr;} - float *errMtx() {return mErr;} - - -protected: - float mErr[6]; //error matrix - int mKount; -}; -#endif diff --git a/StRoot/Stv/StvHitCounter.cxx b/StRoot/Stv/StvHitCounter.cxx deleted file mode 100644 index 4238dd4938a..00000000000 --- a/StRoot/Stv/StvHitCounter.cxx +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include "StvConst.h" - -#include "Stv/StvHitCounter.h" - -//_____________________________________________________________________________ -StvHitCounter::StvHitCounter() -{ - Clear(); -// mMinTotHits =6; //Min number hits for track -// mMinGoodHits=3; //Min number good hits for track -// mMinContHits=2; //Min length of good hit sequence -// mMaxContNits=13; //Max length of acceptable non hit sequence -// mMaxTotNits =15; //Max number of acceptable non hits -} -//_____________________________________________________________________________ -void StvHitCounter::SetCons(const StvKonst_st* kons) -{ - mKons = kons; - mMinTotHits = mKons->mMinTotHits; - mMinGoodHits = mKons->mMinGoodHits; - mMinContHits = mKons->mMinContHits; - mMaxContNits = mKons->mMaxContNits; - mMaxTotNits = mKons->mMaxTotNits; -} -//_____________________________________________________________________________ -int StvHitCounter::MaxNitSeq() const -{ - if (nContNits>mContNits) return nContNits; - else return mContNits; -} -//_____________________________________________________________________________ -int StvHitCounter::MaxHitSeq() const -{ - if (nContHits>mContHits) return nContHits; - else return mContHits; -} -//_____________________________________________________________________________ -void StvHitCounter::AddHit() -{ - nPossHits++; nTotHits++;nContHits++; - if (!nContNits) return; - if (nContHitsmMaxContNits) nSeqLong++; - if (mContNits=mMinContHits)? nGoodHits+nContHits : nGoodHits; - if (nG mMaxTotNits) rej+=4; - - return rej; -} -//_____________________________________________________________________________ -int StvHitCounter::Skip() const -{ - int rej = 0; - if (nContNits>mMaxContNits) rej+= 1; - if (nTotNits > mMaxTotNits) rej+= 2; - return rej ; -} -//_____________________________________________________________________________ -double StvHitCounter::Eff() const -{ - double p = nTotHits/(nPossHits+1e-6); - double q = 1-p; - return p +1*sqrt(p*q/(nPossHits+1e-6)); -} diff --git a/StRoot/Stv/StvHitCounter.h b/StRoot/Stv/StvHitCounter.h deleted file mode 100644 index f3fe2e94fe2..00000000000 --- a/StRoot/Stv/StvHitCounter.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * \file StvHitCounter.h - * \brief Definition StvHitCounter - * - */ -#include -#ifndef StvHitCounter_H -#define StvHitCounter_H 1 -class StvKonst_st; - -/// Hit counting -class StvHitCounter -{ -public: -StvHitCounter(); -void Clear() {memset(mBeg,0,mMed-mBeg+1);} -void SetCons(const StvKonst_st*); - -void AddHit(); -void AddNit(); -int Reject() const; -int Skip() const; -double Eff() const; -int MaxNitSeq() const; //Length of longesr Nits sequence -int MaxHitSeq() const; //Length of longesr Hits sequence -public: -char mBeg[1] ; -const StvKonst_st *mKons; -int nPossHits; // Number of possible hits; -int nTotHits ; // Total number of hits -int nGoodHits; // Number of good hits (hits in sequences > kContHits -int nSeqHits ; // Number of hit sequences -int nSeqShort; // Number of too short hit sequences -int nTotNits ; // Total number of Non Hits(Nits) -int nSeqNits ; // Number of Non Hit(Nit) sequences -int nSeqLong ; // Number of too long Non Hit(Nit) sequences -int nContHits; // Number of hits in current Hit sequence -int nContNits; // Number of nits in current nonHit sequence -int mContHits; // Number of hits in maximal Hit sequence -int mContNits; // Number of nits in maximal nonHit sequence -char mMed[1] ; -int mMinTotHits; //Min number hits for track -int mMinGoodHits; //Min number good hits for track -int mMinContHits; //Min length of good hit sequence -int mMaxContNits; //Max length of acceptable non hit sequence -int mMaxTotNits; //Max number of acceptable non hits -char mEnd[1] ; -}; - -#endif - diff --git a/StRoot/Stv/StvHitter.cxx b/StRoot/Stv/StvHitter.cxx deleted file mode 100644 index cd1168b61e7..00000000000 --- a/StRoot/Stv/StvHitter.cxx +++ /dev/null @@ -1,95 +0,0 @@ -#include "StvHitter.h" -#include "Stv/StvHit.h" -#include "TGeoManager.h" -#include "TGeoVolume.h" -#include "StvHitter.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StvUtil/StvNodePars.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StarRoot/StMultiKeyMap.h" - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StvHitter::StvHitter() -{ - fMultiIter = new StMultiKeyMapIter(0); -} -//_____________________________________________________________________________ -StvHitter::~StvHitter() -{ - delete fMultiIter; -} -//_____________________________________________________________________________ -void StvHitter::Reset() -{ - mHitPlane=0; -} -//_____________________________________________________________________________ -const StvHits *StvHitter::GetHits(const StvNodePars *pars - ,const StvFitErrs *errs, const float gate[4]) -{ -enum {kLittleBit = 5}; - -static int nCall=0; nCall++; -static StTGeoProxy * const myProxy = StTGeoProxy::Inst(); - mHits.clear(); - const StHitPlane *myHitPlane = myProxy->GetCurrentHitPlane(); - if (!myHitPlane) return 0; //no sensitive volume there - - if (mHitPlane == myHitPlane) return 0; //hit plane was already used - int nHits = myHitPlane->GetNHits(); - if (!nHits) return &mHits; //it is sensitive but no hits - - mHitPlane = myHitPlane; - - mHitMap = mHitPlane->GetHitMap(); - float xNode[3]={(float)pars->_x,(float)pars->_y,(float)pars->_z}; - mOrg = mHitPlane->GetOrg(xNode); - mDir = &mHitPlane->GetDir(xNode); - - - float tau =0,den=0; - float const *ort =(*mDir)[0]; - float mom[3]={(float)pars->_cosCA,(float)pars->_sinCA,(float)pars->_tanl}; - - for (int j=0;j<3;j++) {tau+=(mOrg[j]-xNode[j])*ort[j]; - den+= mom[j] *ort[j];} - if (fabs(den)<1e-2) return 0; // track is parallel to hit plane - tau/=den; - for (int j=0;j<3;j++) {xNode[j]+=mom[j]*tau;} - - double myGate[2]; -// Obtain track errs - double cos2 = den*den/(1.+mom[2]*mom[2]); - - double totRr = (errs->mHH+errs->mZZ)/cos2; - totRr = sqrt(totRr); - for (int j=0;j<2;j++) { - myGate[j] = gate[j]*totRr; - if (myGate[j]>gate[j+2]) myGate[j]=gate[j+2];} - - float lNode[3],lim[2][2]; - mHitPlane->ToLocal(xNode,lNode); - for (int j=0;j<2;j++) {lim[0][j]=lNode[1+j]-myGate[j]; - lim[1][j]=lNode[1+j]+myGate[j];} - - fMultiIter->Set(mHitMap->GetTop(),lim[0],lim[1]); - for (StMultiKeyNode *node=0;(node = *(*fMultiIter)) ;++(*fMultiIter)) - { - StvHit *nexHit = (StvHit*)node->GetObj(); - if (nexHit->isUsed()) continue; - mHits.push_back(nexHit); - } - return &mHits; -} -//_____________________________________________________________________________ -const StHitPlane* StvHitter::GetHitPlane() const {return mHitPlane;} - -//_____________________________________________________________________________ -StDetectorId StvHitter::GetDetId() const -{ - if (!mHitPlane) return (StDetectorId)0; - return mHitPlane->GetDetId(); -} - - diff --git a/StRoot/Stv/StvHitter.h b/StRoot/Stv/StvHitter.h deleted file mode 100644 index 386350d23aa..00000000000 --- a/StRoot/Stv/StvHitter.h +++ /dev/null @@ -1,43 +0,0 @@ -/// \File StvHitter.h -/// \author Victor Perev 04/2010 -#ifndef StvHitter_HH -#define StvHitter_HH -#include "TNamed.h" -#include "StEvent/StEnumerations.h" -#include "StvStl.h" - - -class StvSeedFinder; -class StvHit; -class StHitPlane; -class StvNodePars; -class StMultiKeyMap; -class StMultiKeyMapIter; -class StvNodePars; -class StvFitErrs; -typedef float Mtx33F_t[3][3]; - -/// \class StvHitter, local hit provider -class StvHitter -{ -public: - StvHitter(); - ~StvHitter(); -void Reset(); -const StvHits *GetHits(const StvNodePars *np, const StvFitErrs *ne,const float gate[2]); -const StHitPlane* GetHitPlane() const; - StDetectorId GetDetId() const; -private: -private: -const StHitPlane *mHitPlane; -const StMultiKeyMap *mHitMap; -const float *mOrg; //xyz of origine of hit plane -const Mtx33F_t *mDir; //orts of hit plane, local x,y,x orts -StMultiKeyMapIter *fMultiIter; - -StvHits mHits; -public: -StvSeedFinder *mSF; -}; - -#endif diff --git a/StRoot/Stv/StvKalmanTrackFinder.cxx b/StRoot/Stv/StvKalmanTrackFinder.cxx deleted file mode 100644 index 599f5d513da..00000000000 --- a/StRoot/Stv/StvKalmanTrackFinder.cxx +++ /dev/null @@ -1,485 +0,0 @@ -#include -#include -#include - -#include "TMath.h" -#include "TCernLib.h" - -#include "StvSeedFinder.h" -#include "StvKalmanTrackFinder.h" - -#include "StvToolkit.h" -#include "StMultiKeyMap.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "Stv/StvHit.h" -#include "StvUtil/StvNodePars.h" -#include "StvUtil/StvELossTrak.h" -#include "StvUtil/StvDebug.h" -#include "StvTester.h" -#include "Stv/StvEnum.h" -#include "Stv/StvConst.h" -#include "Stv/StvDiver.h" -#include "Stv/StvHitter.h" -#include "Stv/StvFitter.h" -#include "Stv/StvTrackFitter.h" -#include "Stv/StvDraw.h" -#include "Stv/StvStl.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "Stv/StvHitCounter.h" -ClassImp(StvKalmanTrackFinder) - -int ThruFgt(const StvNodePars &par); ///??????????????????????????????? - -typedef std::vector StvNodeVec; -typedef std::map StvNodeMap; -typedef StvNodeMap::iterator StvNodeMapIter ; - -//_____________________________________________________________________________ -StvKalmanTrackFinder::StvKalmanTrackFinder(const char *name):StvTrackFinder(name) -{ - memset(mBeg,0,mEnd-mBeg+1); - mDive = StvDiver::Inst(); - mHitter = new StvHitter(); - mHitCounter = new StvHitCounter(); - } -//_____________________________________________________________________________ -void StvKalmanTrackFinder::Clear(const char*) -{ - StvTrackFinder::Clear(""); -} -//_____________________________________________________________________________ -void StvKalmanTrackFinder::Reset() -{ -} -//_____________________________________________________________________________ -void StvKalmanTrackFinder::SetCons(const StvKonst_st* k) -{ - mKons = k; - double rMax,zMin,zMax; - StTGeoProxy::Inst()->GetHitShape()->Get(zMin,zMax,rMax); - if (zMax < -zMin) zMax = -zMin; - mDive->SetRZmax(rMax,zMax); - mHitCounter->SetCons(mKons); - mDive->SetRZmax(mKons->mRxyMax,mKons->mZMax); -} -//_____________________________________________________________________________ -int StvKalmanTrackFinder::FindTracks() -{ -static int nCall = 0; nCall++; -static int nTally = 0; -static StvToolkit *kit = StvToolkit::Inst(); -enum {kRepeatSeedFinder = 2}; - - int nTrk = 0,nTrkTot=0,nAdded=0,nHits=0,nSeed=0,nSeedTot=0; - StvSeedFinders *seedFinders = kit->SeedFinders(); - double aveRes=0,aveXi2=0,aveHits=0; - mCurrTrak = 0; - - for (int seedFinder=0;seedFinder<(int)seedFinders->size();seedFinder++) { //Loop over seed finders - mSeedFinder = (*seedFinders)[seedFinder]; - for (int repeat =0;repeatAgain(repeat); - while ((mSeedHelx = mSeedFinder->NextSeed())) - { - nSeed++; nTally++; - if (!mCurrTrak) mCurrTrak = kit->GetTrack(); - mCurrTrak->CutTail(); //Clean track from previous failure - -//============================= - nAdded = FindTrack(0); -//============================= - - if (!nAdded) {mSeedFinder->FeedBack(0); continue;} - mCurrTrak->CutEnds(); //remove ends without hits - int ans = 0,fail=13; -// Refit track - int nFitHits = mCurrTrak->GetNHits(); - do { - if (!mRefit) continue; - if(nFitHits<3) break; -//============================= - if(nFitHits>3)ans = Refit(1); -//============================= - if (ans) break; - StvTrack refiTrak(*mCurrTrak); - nHits = mCurrTrak->GetNHits(); - if (nHits<3) break; -//============================= - nAdded = FindTrack(1); -//============================= - if (nAdded<=0) continue;; - nHits = mCurrTrak->GetNHits(); - if (nHits<3) break; -// few hits added. Refit track to beam again -//============================= - ans = Refit(0); -//============================= - if (ans) { - *mCurrTrak = refiTrak; - } - - } while((fail=0)); - - nHits = mCurrTrak->GetNHits(); - if (nHits < mKons->mMinHits) fail+=100; ; - if (fail) nHits=0; - if (fail) {//Track is failed, release hits & continue - mSeedFinder->FeedBack(0); - mCurrTrak->CutTail(); continue; - } - StvNode *node = MakeDcaNode(mCurrTrak); if(node){}; - - mSeedFinder->FeedBack(mCurrTrak); - - mCurrTrak->AddId(10*seedFinder+repeat); - mCurrTrak->SetUsed(); - kit->GetTracks().push_back(mCurrTrak); - nTrk++;nTrkTot++; - aveHits+= nHits; - aveRes += mCurrTrak->GetRes(); - aveXi2 += mCurrTrak->GetXi2(); - mCurrTrak=0; - } - nSeedTot+=nSeed; - Info("FindTracks:","SeedFinder(%s) Seeds=%d Tracks=%d ratio=%d\n" - ,mSeedFinder->GetName(),nSeed,nTrk,(100*nTrk)/(nSeed+1)); - - if (!nTrk ) break; - }//End of repeat - }//End of seed finders - - if (nTrkTot) {aveHits/=nTrkTot;aveRes/=nTrkTot; aveXi2/=nTrkTot;} - Info("FindTracks","tracks=%d aveHits = %g aveRes = %g aveXi2=%g",nTrkTot,aveHits,aveRes,aveXi2); - return nTrkTot; -} -//_____________________________________________________________________________ -int StvKalmanTrackFinder::FindTrack(int idir) -{ - -static int nCall=0; nCall++; -static int nTally=0; -static StvToolkit *kit = StvToolkit::Inst(); -static StvFitter *fitt = StvFitter::Inst(); -StvNodePars par[2]; -StvFitErrs err[2]; -int mySkip=0,idive = 0,nNode=0,nHits=0,nTotHits=0; -double totLen=0; -StvNode *curNode=0,*preNode=0,*innNode=0,*outNode=0; -const StHitPlane *prevHitPlane=0; -mHitCounter->Clear(); - - if (mCurrTrak->empty()) {//Track empty, Backward tracking, to beam - assert(!idir); - double Hz = kit->GetHz(mSeedHelx->Pos()); - par[0].set(mSeedHelx,Hz); //Set seed pars into par[0] and err[0] - err[0].Set(mSeedHelx,Hz); err[0]*= kKalmanErrFact; - par[0].reverse(); //Seed direction OutIn but track direction is allways InOut - err[0].Backward(); - - } else {//Forward or backward tracking - - curNode =(idir)? mCurrTrak->back(): mCurrTrak->front(); - par[0] = curNode->GetFP(); err[0] = curNode->GetFE(); //Set outer node pars into par[0] - nTotHits = mCurrTrak->GetNFits(idir); - } - -// Skip too big curvature or pti - if (fabs(par[0]._curv)>mKons->mMaxCurv) return 0; - if (fabs(par[0]._ptin)>mKons->mMaxPti) return 0; - -// skip P too small - { double t = par[0]._tanl, pti = par[0]._ptin; - if ((t*t+1.)< mKons->mMinP2*pti*pti) return 0; - } - fitt->Set(par, err, par+1,err+1); - mHitter->Reset(); - StvFitDers derivFit; - mDive->Reset(); -// We need here to find a hit and calulate errs. No Dca yet - mDive->SetOpt(StvDiver::kTargHit | StvDiver::kDoErrs); - mDive->Set(par+0,err+0,idir); - mDive->Set(par+1,err+1,&derivFit); //Output of diving in par[1] - - - while((idive & StvDiver::kDiveHits) || idive==0) { - - do {//Stop tracking? - idive = 99; - if (!nNode) continue; //No nodes yet, OK - mySkip = mHitCounter->Skip(); - if (mySkip) break; //Skip stop tracking, - } while ((idive=0)); - if (idive) break; - -//+++++++++++++++++++++++++++++++++++++ - nTally++; - idive = mDive->Dive(); -//+++++++++++++++++++++++++++++++++++++ - if (idive & StvDiver::kDiveBreak) break; - if (idive & StvDiver::kDiveDca ) break; - - double deltaL = mDive->GetLength(); - totLen+=deltaL; - par[0]=par[1]; err[0]=err[1]; //pars again in par[0] - // Stop tracking when too big Z or Rxy - if (fabs(par[0]._z) > mKons->mZMax ) break; - if (par[0].getRxy() > mKons->mRxyMax) break; - if (fabs(par[0]._curv)>mKons->mMaxCurv) break; - if (fabs(par[0]._ptin)>mKons->mMaxPti) break; - - - const StvHits *localHits = 0; - if (idive & StvDiver::kDiveHits) { - float gate[4]={mKons->mCoeWindow,mKons->mCoeWindow - ,mKons->mMaxWindow,mKons->mMaxWindow}; - localHits = mHitter->GetHits(par,err,gate); - } - - -// Create and add node to myTrak - preNode = curNode; - curNode = kit->GetNode(); - assert(preNode != curNode); - assert(curNode != mCurrTrak->front()); - assert(curNode != mCurrTrak->back ()); - - if (!idir) {mCurrTrak->push_front(curNode);innNode=curNode;outNode=preNode;} - else {mCurrTrak->push_back(curNode);innNode=preNode;outNode=curNode;} - if (outNode){} - nNode++; - if (nNode>256) { //Something very wrong - Error("FindTrack","Too many nodes =200 Skip track"); - return 0; - } - - curNode->mLen = (!idir)? totLen:-totLen; - // Set prediction - - StvELossTrak *eld = mDive->TakeELoss(); - if (par[0].getP2() < kBigMom2) { - innNode->SetELoss(eld,idir); - err[0].Add(eld,par[0],0); - err[0].Recov(); - } else { - kit->FreeELossTrak(eld); - } - - - curNode->SetXDive(par[0]); - curNode->SetPre(par[0],err[0],0); - innNode->SetDer(derivFit,idir); - - if (!localHits) continue; //Never hits in curNode - curNode->SetHitPlane(mHitter->GetHitPlane()); - - if (!localHits->size()) {//No hits in curNode - mHitCounter->AddNit(); continue; - } - if (prevHitPlane == mHitter->GetHitPlane()) continue; - prevHitPlane = mHitter->GetHitPlane(); - - fitt->Prep(); - double minXi2[2]={1e11,1e11},myXi2; - StvHit *minHit[2]={0}; - minXi2[0] = mKons->mXi2Hit,myXi2=3e33; - int minIdx = -1; - for (int ihit=0;ihit<(int)localHits->size();ihit++) { - StvHit *hit = (*localHits)[ihit]; - myXi2 = fitt->Xi2(hit); - if (nTotHits > 5 && fitt->IsFailed() == -99) { // Too big track errs - mySkip = 4; break; //Track Errors too big, stop tracking - } - if (myXi2 > minXi2[0]) continue; - minXi2[1]=minXi2[0]; minXi2[0] = myXi2; - minHit[1]=minHit[0]; minHit[0] = hit; minIdx = ihit; - } - if (minIdx){}; - - if (mySkip) break; //Track Errors too big - - - curNode->SetMem(minHit ,minXi2); - if (minHit[0] ) { // Fit succesful - - myXi2 = fitt->Xi2(minHit[0]); - int iuerr = fitt->Update(); - if (iuerr<=0 || (nHits<3)) { //Hit accepted - mHitCounter->AddHit(); - nHits++;nTotHits++;assert(nHits<256); - curNode->SetHE(fitt->GetHitErrs()); - curNode->SetFit(par[1],err[1],0); - par[0]=par[1]; - err[0]=err[1]; - } else { minHit[0]=0;} - } else {//No Hit or ignored - myXi2 = 1e11; - mHitCounter->AddNit(); - } - curNode->SetHit(minHit[0]); - curNode->SetXi2(myXi2,0); - - } // End Dive&Fitter loop - - mCurrTrak->SetTypeEnd(mySkip); - if (!idir) { - double eff = mHitCounter->Eff(); if (eff){} - int myReject = mHitCounter->Reject(); - if (myReject) { - - mCurrTrak->CutTail(); return 0; } - } - if (nHits>3) { - double tlen = mCurrTrak->GetLength(); - assert(tlen >0.0 && tlen<1500); - } - - - return nHits; - -} -//_____________________________________________________________________________ -int StvKalmanTrackFinder::Swim(int idir, int opt, const double target[3] - ,const StvNodePars *inpPar,const StvFitErrs *inpErr - , StvNodePars *outPar, StvFitErrs *outErr - , StvFitDers *derivFit) -{ - -static int nCall=0; nCall++; - - mDive->Reset(); - mDive->Set(inpPar,inpErr,idir); - mDive->Set(outPar,outErr,derivFit); //Output of diving in par[1] - mDive->SetOpt(opt); - int nTg = (opt & StvDiver::kTarg3D)? 3:2; - if (target) mDive->SetTarget(target,nTg); - - -//+++++++++++++++++++++++++++++++++++++ - - int idive = mDive->Dive(); - -//+++++++++++++++++++++++++++++++++++++ - return idive; - -} -//_____________________________________________________________________________ -StvNode *StvKalmanTrackFinder::MakeDcaNode(StvTrack *tk) -{ -static StvToolkit *kit = StvToolkit::Inst(); - - StvNode *start = tk->front(); -// We search DCA point + errors only (no hits) - int opt = StvDiver::kTarg2D | StvDiver::kDoErrs; - StvNodePars dcaPars; - StvFitErrs dcaErrs; - StvFitDers dcaDers; - int iSwim = Swim(0,opt,0 - ,&(start->GetFP()),&(start->GetFE()) - ,&dcaPars,&dcaErrs,&dcaDers); - if (!(iSwim & StvDiver::kDiveDca)) return 0; - - StvNode *dcaNode = kit->GetNode(); - tk->push_front(dcaNode); - dcaNode->mLen = start->mLen + mDive->GetLength(); - // Set prediction - StvELossTrak *eld = mDive->TakeELoss(); - if (dcaPars.getP2()SetELoss(eld,0); - dcaErrs.Add(eld,dcaPars,0); - -// double p0 = start->GetFP().getP(); -// double p1 = dcaPars.getP(); -// double PiMASS=0.13956995; -// double e0 = sqrt(p0*p0+PiMASS*PiMASS); -// double e1 = sqrt(p1*p1+PiMASS*PiMASS); -//???assert(e1>e0); -//??assert(fabs((e1-e0)-eld->ELoss()) <0.3*eld->ELoss()+kOneMEV); - - } else { - kit->FreeELossTrak(eld); - } - dcaNode->SetPre(dcaPars,dcaErrs,0); - dcaNode->SetDer(dcaDers,0); - dcaNode->SetXi2(1e11,0); - dcaNode->SetType(StvNode::kDcaNode); - double testDca = TCL::vdot(&dcaPars._cosCA,dcaPars.P,2); - assert(fabs(testDca)<1e-4); - - return dcaNode; -} -//_____________________________________________________________________________ -int StvKalmanTrackFinder::FindPrimaries(const StvHits &vtxs) -{ -static StvToolkit *kit = StvToolkit::Inst(); - - StvTracks &traks = kit->GetTracks(); - int goodCount= 0, plus=0, minus=0; - int nVertex = vtxs.size(); - if (!nVertex) return 0; - int nTracks = 0; - for (StvTrackIter it=traks.begin(); it!=traks.end() ;++it) { - StvTrack *track = *it; nTracks++; - double dca00 = track->ToBeam(); - if (dca00 > mKons->mDca2dZeroXY) { - continue; - } - int bestVertex=-1; double bestXi2 = mKons->mXi2Vtx; - for (int iVertex=0;iVertexFit(track,vertex,0)) continue; - double Xi2 = mTrackFitter->GetXi2(); - if (Xi2>=bestXi2) continue; -// Found better Xi2 - bestXi2 = Xi2; bestVertex=iVertex; - }//End vertex loop - - if(bestVertex<0) continue; - StvNode *node = kit->GetNode(); - StvHit *hit = vtxs[bestVertex]; - hit->addCount(); - mTrackFitter->Fit(track,hit,node); - track->push_front(node); - track->SetPrimary(bestVertex+1); - node->SetType(StvNode::kPrimNode); - node->SetHit(hit); - node->SetXi2(bestXi2,0); - goodCount++; - if (track->GetCharge()>0) { plus++; } else { minus++; } - - }//End track loop - return goodCount; -} -//_____________________________________________________________________________ -int StvKalmanTrackFinder::Refit(int idir) -{ - return mTrackFitter->Refit(mCurrTrak,idir); -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -//_____________________________________________________________________________ -//_____________________________________________________________________________ -//_____________________________________________________________________________ -// int checkfgt(double x0, double y0, double x1, double y1){ -// static const double z=67.399; //disc1 z -// double x=x0+x1*z; -// double y=y0+y1*z; -// double r=sqrt(x*x+y*y); -// if(r>12.0 && r<38.0) return 1; -// return 0; -// } - -int ThruFgt(const StvNodePars &par) -{ -static const double kZ=67.399; //disc1 z -static const double kRmin =12.0; -static const double kRmax =38.0; - double t = (kZ-par._z)/par._tanl; - if (t<0) return 0; - double myX = par._x + par._cosCA*t; - double myY = par._y + par._sinCA*t; - double rr = myX*myX+myY*myY; - if (rrkRmax*kRmax) return 0; - return 1; -} diff --git a/StRoot/Stv/StvKalmanTrackFinder.h b/StRoot/Stv/StvKalmanTrackFinder.h deleted file mode 100644 index f3d92d2ddcf..00000000000 --- a/StRoot/Stv/StvKalmanTrackFinder.h +++ /dev/null @@ -1,57 +0,0 @@ -/// \File StvKalmanTrackFinder.h -/// \author Victor Perev 01/2010 -#ifndef StvKalmanTrackFinder_HH -#define StvKalmanTrackFinder_HH -#include "StvTrackFinder.h" - -class StvSeedFinder; -class StvDiver; -class StvPars; -class StvTrack; -class StvDiver; -class StvHitter; -class StvHitVector; -class StvNodePars; -class StvFitErrs; -class StvFitDers; -class StvHitCounter; -class StvKonst_st; -/// \class StvKalmanTrackFinder - -class StvKalmanTrackFinder : public StvTrackFinder -{ -public: - StvKalmanTrackFinder(const char *name="KalmanTrackFinder"); - ~StvKalmanTrackFinder(){;} - void SetCons(const StvKonst_st*); - int FindTracks(); - int Refit(int idir); - int FindTrack(int idir); -StvNode *MakeDcaNode(StvTrack *tk); - int FindPrimaries(const StvHits &vtxs); - int Swim(int idir,int opt, const double target[3] - ,const StvNodePars *inpPar,const StvFitErrs *inpErr - , StvNodePars *outPar, StvFitErrs *outErr - , StvFitDers *derivFit); - void Reset(); - void Clear(const char *opt=""); - - -protected: -char mBeg[1]; -int mMinHits; /*Min number of hits allowed MidEta*/ -int mNorHits; /*Normal number of hits allowed MidEta*/ -int mGoodHits; /*Min umber of Good hits in track MidEta*/ -const StvKonst_st *mKons; - StvHitCounter *mHitCounter; - StvSeedFinder *mSeedFinder; -const THelixTrack *mSeedHelx; - StvTrack *mCurrTrak; -StvDiver *mDive; -StvHitter *mHitter; -char mEnd[1]; -private: -ClassDef(StvKalmanTrackFinder,0); -}; - -#endif diff --git a/StRoot/Stv/StvKalmanTrackFitter.cxx b/StRoot/Stv/StvKalmanTrackFitter.cxx deleted file mode 100644 index cd0b596f838..00000000000 --- a/StRoot/Stv/StvKalmanTrackFitter.cxx +++ /dev/null @@ -1,676 +0,0 @@ -#include -#include -#include - -#include "TMath.h" - -#include "TCernLib.h" -#include "TSystem.h" -#include "StvKalmanTrackFitter.h" -#include "Stv/StvToolkit.h" -#include "Stv/StvHit.h" -#include "StvUtil/StvNodePars.h" -#include "StvUtil/StvDebug.h" -#include "StvUtil/StvELossTrak.h" -#include "Stv/StvFitter.h" -#include "Stv/StvEnum.h" -#include "Stv/StvConst.h" -#include "Stv/StvStl.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "Stv/StvConst.h" -ClassImp(StvKalmanTrackFitter) -#define DIST2(a,b) ((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])) - -static const int kXtendFactor = 10;//Xi2 factor that fit sure failed -static const double kPiMass=0.13956995; -static const double kMinP = 0.01,kMinE = sqrt(kMinP*kMinP+kPiMass*kPiMass); -static const double kMaxCorr = 0.1; -//_____________________________________________________________________________ -StvKalmanTrackFitter::StvKalmanTrackFitter():StvTrackFitter("StvKalmanTrackFitter") -{ - memset(mBeg,0,mEnd-mBeg+1); -} -//_____________________________________________________________________________ -void StvKalmanTrackFitter::Clear(const char*) -{ - StvTrackFitter::Clear(""); -} -//_____________________________________________________________________________ -void StvKalmanTrackFitter::SetCons(const StvKonst_st *kons) -{ - mKons = kons; -} -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Refit(StvTrack *trak,int dir, int lane, int mode) -{ -/// refit or smouthe track, using the previous Kalman. -/// dir=0 moving from out to in -/// dir=1 moving from in to out -/// mode=0 No join -/// mode=1 Join -/// fit direction is imagined from left to rite -static int nCall=0; nCall++; - -static StvFitter *fitt = StvFitter::Inst(); - -//term LEFT here: Curren Kalman chain of fits from left to rite -// Rite here: Previous Kalman chain, allready fitted, in different direction. -// It was made from rite to left - - int jane=1-lane; - int nFitLeft=0; // number of fits made by this pass excluding current node - int nFitRite=0; // number of fits made during previous - // pass in different direction, including current node - int wasFitted=0; // this node was fitted in previous pass - mNHits = trak->GetNFits(jane); - if (mode&1) {//Join of two lanes - nFitRite = mNHits;} - else {//no join. lanes independent - jane=lane; - } - int nErr = 0; - - StvNodeIter it,itBeg,itEnd; - if (dir) { //fit in ==> out - itBeg = trak->begin(); itEnd = trak->end(); - } else {//fit out ==> in - itBeg = trak->end(); --itBeg; itEnd = trak->begin();--itEnd; - } - - - double myXi2=3e33; - StvNode *node=0,*preNode=0,*innNode=0,*outNode=0; - if(innNode){}; if(outNode){}; - int iNode=0,iFailed=0; - - for (it=itBeg; it!=itEnd; (dir)? ++it:--it) {//Main loop - preNode=node; - node = *it; iNode++; - if (!dir) { innNode = node; outNode = preNode;} - else { outNode = node; innNode = preNode;} -enum myCase {kNull=0,kLeft=1,kRite=2,kHit=4,kFit=8 }; - node->GetFE(lane).mHH = -1; - node->GetFE(lane).mZZ = -1; - -// if (node->GetType()==StvNode::kDcaNode) { -// printf("DCAInit lane=%d err=%g\n",jane,sqrt(node->mFE[jane].mPP)); -// assert(!(nFitLeft*nFitRite)); -// } - - int kase = 0; - if (nFitLeft) kase|=kLeft; - if (mode && nFitRite) kase|=kRite; - const StvHit *hit = node->GetHit(); - wasFitted = (mode&1)? node->IsFitted(jane):0; -// if (wasFitted ) kase|=kHit; - if (hit) kase|=kHit; - -// Imaginary we are always coming from left to right. -// kLeft = left fits only, no hit -// kLeft+kHit = Left fits only, now hit, -// kRite = No left, no hit, rite fits only -// kLeft+kRite = left fits, no hit, rite fits -// kHit+kRite = No left fits, now hit, rite fits -// kLeft+kRite+kHit = Left fits,now hit, rite fits - node->SetXi2(3e33,lane); - switch (kase) {// 1st switch, fill PREDICTION - - default: assert(0 && "Wrong Case1"); - - case kRite|kHit: // No left, now Hit, rite fits - case kNull|kHit: // No left, now Hit, No rite - { // Empty leading node -// It was not fits before(left) but shoulf be now. -// get params from previous dir and set huge errors - node->mPP[lane] = node->mFP[2]; //prediction from opposite fit - node->mPE[lane] = node->mFE[2]; - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - - node->mPE[lane]*=kKalmanErrFact; //Big errors - node->mPE[lane].Recov(); //But not too big - break; - } - - case kRite: // No left, no Hit, rite fits - case kNull: - { // Empty leading node -// It was not fits before(left) get params from previous dir -// and set huge errors - node->mPP[lane] = node->mFP[2]; //prediction from opposite fit - node->mPE[lane] = node->mFE[2]; //Big errors - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - break; - } - case kLeft: // Left fits only, no Hit - case kLeft| kHit: // Left fits only, now Hit - case kLeft|kRite : // Left fits, no Hit, Rite fits - case kLeft|kRite|kHit: // Left fits,now Hit, Rite fits - { -// It was fits before. Propagate it - Propagate(node,preNode,dir,lane); //prediction from last fit - break; - } - - }//End 1st prediction switch - -// if (node->GetType()==StvNode::kDcaNode) { -// printf("DCA1st lane=%d err=%g\n",lane,sqrt(node->mPE[lane].mPP)); -// } - switch (kase) {// 2nd switch, fill FITD - - case kNull: // No fits no Hit - case kLeft: // Left fits only, no Hit - case kRite: // Rite fits only, no Hit - case kLeft|kRite: // Left fits, no Hit, Rite fits - { -// No hit. Fit = Prediction - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - node->SetFit(node->mPP[lane],node->mPE[lane],lane); - break; - } - - case kNull| kHit: // Left fits only, now Hit - case kLeft| kHit: // Left fits only, now Hit - case kRite| kHit: // No left, now Hit, rite fits - case kLeft|kRite|kHit: // Left fits,now Hit, Rite fits - { -// Fit it -static int nQQQQ=0; nQQQQ++; -StvDebug::Break(nQQQQ);//??????????? - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - fitt->Set(node->mPP+lane,node->mPE+lane,node->mFP+lane,node->mFE+lane); - fitt->Prep(); - - myXi2 = fitt->Xi2(hit); iFailed = fitt->IsFailed(); -// ================================================= - node->SetXi2(myXi2,lane); - if (iFailed == StvFitter::kBigErrs) iFailed = 0; - if (iFailed ) nErr+=1; //Fit is bad yet - if (myXi2> mKons->mXi2Hit) nErr+=10; //Fit is bad yet - if ( myXi2> mKons->mXi2Hit*kXtendFactor) { // Fit failed. Hit not accepted - if (--mNHits <3) return 1; - node->SetHit(0); hit = 0; nFitLeft--; -// No hit anymore. Fit = Prediction - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - node->SetFit(node->mPP[lane],node->mPE[lane],lane); - break; - } - iFailed = fitt->Update(); if (iFailed) nErr+=100; - nFitLeft++; kase|=kLeft; - node->mFP[2] = node->mFP[lane]; - node->mFE[2] = node->mFE[lane]; - - break; - } - - default: assert(0 && "Wrong Case2"); - - }//end 2nd switch -// if (node->GetType()==StvNode::kDcaNode) { -// printf("DCA2nd lane=%d err=%g\n",lane,sqrt(node->mFE[lane].mPP)); -// } - - if (!mode) continue; - - switch (kase) {// 3rd switch,JOIN - - case kNull: // No fits no Hit - case kRite: // Rite fits only, no Hit -// No hit. No own ifo yet. Get everything from opposite fit - { - assert(node->mFE[jane].mHH>0); - assert(node->mFE[jane].mZZ>0); - node->SetFit(node->mFP[jane],node->mFE[jane],2); - break; - } - - case kLeft: // Left fits only, no Hit -// No hit. No own info yet. Get everything from opposite fit - { - node->SetFit(node->mFP[lane],node->mFE[lane],2); - break; - } - - default: - { - assert(node->mPE[lane].mHH>0); - assert(node->mPE[lane].mZZ>0); - assert(node->mPE[jane].mHH>0); - assert(node->mPE[jane].mZZ>0); - fitt->Set(node->mPP+lane ,node->mPE+lane - ,node->mPP+jane ,node->mPE+jane - ,node->mFP+2 ,node->mFE+2 ); - node->SetXi2(3e33,2); - myXi2 = fitt->Xi2(); iFailed = fitt->IsFailed(); -// ============================================== - node->SetXi2(myXi2/5*2,3); - if (iFailed ) nErr+=1000; - if (myXi2 > mKons->mXi2Joi) nErr+=10000; - iFailed = fitt->Update(); - if (iFailed) nErr+=100000; - if (myXi2 > mKons->mXi2Joi*kXtendFactor || iFailed>0) { //Joining is impossible. Stop joining - mode = 0; //No more joinings - node->SetFit(node->mFP[lane],node->mFE[lane],2); - break; - } - myXi2 = fitt->GetXi2(); - if (!hit) break; - - -// Fit hit to join data - StvNodePars myPars(node->mFP[2]); - StvFitErrs myErrs(node->mFE[2]); - assert(node->mFE[2].mHH>0); - assert(node->mFE[2].mZZ>0); - - fitt->Set(&myPars,&myErrs,node->mFP+2,node->mFE+2); - fitt->Prep(); - - myXi2 = fitt->Xi2(hit); iFailed = fitt->IsFailed(); -// ================================================= - if (iFailed== StvFitter::kBigErrs) iFailed=0; - node->SetXi2(myXi2,2); - if (iFailed ) nErr+=1000000; //Fit is bad yet - if (myXi2> mKons->mXi2Hit) nErr+=10000000; //Fit is bad yet - if (myXi2> mKons->mXi2Hit*kXtendFactor) { // Fit failed. Hit not accepted - node->SetHit(0); hit = 0; nFitLeft--; mNHits--; -// No hit anymore. Fit = Prediction - node->SetFit(myPars,myErrs,2); - break; - } - iFailed = fitt->Update(); if (iFailed) nErr+=100000000; - break; - } - - }//End 3rd case -// if (node->GetType()==StvNode::kDcaNode) { -// printf("DCA3rd lane=%d err=%g\n",2,sqrt(node->mFE[2].mPP)); -// } - - nFitRite-= wasFitted; - assert(node->mFE[lane].mHH>0); - assert(node->mFE[lane].mZZ>0); - - - }//endMainLoop - - return -nErr; -} -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Refit(StvTrack *tk, int idir) -{ -static int nCall=0;nCall++; -static const double kEps = 1.e-2,kEPS=1e-1; - - int ans=0,anz=0,lane = 1; - int& nHits = NHits(); - nHits = tk->GetNHits(); - int nBegHits = nHits; - int nRepair =(nHits-5)*0.1; - int state = 0; - StvNode *tstNode = (idir)? tk->front(): tk->back(); - int nIters = 0,nDrops=0; - for (int repair=0;repair<=nRepair;repair++) { //Repair loop - int converged = 0; - for (int refIt=0; refIt<10; refIt++) { //Fit iters - nIters++; - ans = Refit(tk,idir,lane,1); -// ================================== - nHits=NHits(); - if (nHits < mKons->mMinHits) break; - if (ans>0) break; //Very bad - - StvNodePars lstPars(tstNode->GetFP()); //Remeber params to compare after refit - anz = Refit(tk,1-idir,1-lane,1); -// ========================================== - nHits=NHits(); - if (nHits < mKons->mMinHits) break; - if (anz>0) break; - - double dif = lstPars.diff(tstNode->GetFP(),tstNode->GetFE()); - double eps = (ans || anz)? kEPS:kEps; - if ( dif < eps) { //Fit converged - converged = 1; break; } - - }// End Fit iters - - state = (ans!=0) + 10*((anz!=0) + 10*((!converged) - + 10*((tk->GetXi2()>mKons->mXi2Trk)+10*(nHits < mKons->mMinHits)))); - if (!state) break; - if (nHits < mKons->mMinHits) break; - StvNode *badNode=tk->GetNode(StvTrack::kMaxXi2); -// StvNode *badNode=tk->GetMaxKnnNode(); - if (!badNode) break; - badNode->SetHit(0); nDrops++; - nHits--; if (nHits < mKons->mMinHits) { state = 1000000; break;} - }//End Repair loop - - - if (ans<=0) state &= (-2); - if (anz<=0) state &= (-4); - - nHits = tk->GetNHits(); - nDrops = nBegHits-nHits; - return state; - -} - -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Propagate(StvNode *node,StvNode *preNode,int dir,int lane) -{ -static int nCall=0; nCall++; -static const char* PropagateHelix = gSystem->Getenv("PropagateHelix"); -StvDebug::Break(nCall); - StvFitDers derFit; - - StvNode *innNode=0,*outNode=0; - if (innNode){}; if (outNode){}; - if (!dir) {innNode = node; outNode=preNode;} - else {outNode = node; innNode=preNode;} - - double saveCurv = node->mFP[lane]._curv; - node->mFP[lane]._curv = (2*saveCurv+preNode->mFP[lane]._curv)/3; - -double dS=0; -if (PropagateHelix) //Propagate with THelixTrack ????? HACK -{ - THelixTrack myHlx; - preNode->mFP[lane].get(&myHlx); - const StvNodePars &prePars = preNode->mFP[lane]; - assert(preNode->mFE[lane].mHH>0); - const StvFitErrs &preErrs = preNode->mFE[lane]; - prePars.get(&myHlx); - preErrs.Get(&myHlx); - double Xnode[3]; - if (node->mHit) { TCL::ucopy(node->mHit->x(),Xnode,3);} - else { TCL::ucopy(node->mXDive ,Xnode,3);} - - double dS = myHlx.Path(Xnode); - StvHlxDers derHlx; -// reset ELossData for may be new momentum - innNode->ResetELoss(preNode->mFP[lane],dir); - const StvELossTrak *el = innNode->GetELoss(); - double dP = 0; - if (el) {//account energy loss - double P = sqrt(prePars.getP2()); - dP = el->PLoss(P)*(-dS); - } - if (dP > kMaxCorr) dP = kMaxCorr; - if (dP <-kMaxCorr) dP =-kMaxCorr; - double rho = prePars._curv; - double dRho = -rho*(dP); - myHlx.Set(rho+dRho/3); - dS = myHlx.Path(Xnode); - myHlx.Move(dS,derHlx); - myHlx.Set(rho+dRho); - node->mPP[lane].set(&myHlx,node->GetHz()); - node->mPE[lane].Set(&myHlx,node->GetHz()); - node->mPE[lane].Recov(); - node->mPE[lane].Add(el,node->mPP[lane],dS); - node->mPP[lane].convert(derFit,derHlx); - innNode->SetDer(derFit,lane); - - } -else - { - StvNodePars pars = preNode->mFP[lane]; - double p = pars.getP(); - - const StvELossTrak *el = innNode->GetELoss(); - double dPP = 0,dPdP0=0; - if (el) { - innNode->ResetELoss(preNode->mFP[lane],dir); - dPP = el->PLoss(p)*(el->TotLen())/p; - if (dPP > kMaxCorr) dPP = kMaxCorr; - dPP/=el->TotLen(); - } - - double Xnode[3]; - if (node->mHit) { TCL::ucopy(node->mHit->x(),Xnode,3);} - else { TCL::ucopy(node->mXDive ,Xnode,3);} - - dS = pars.move(Xnode,dPP,dir); - if ((dS>0)!=(dir>0)) { - pars = preNode->mFP[lane]; - dS = pars.move(node->mXDive,dPP,dir); - } - -//assert((dS>0)==(dir>0)); - node->mPP[lane] = pars; - - pars.Deriv(dS,derFit); - if (el) { - dPdP0 = el->dPLossdP0(p); - if (fabs(dPdP0)>0) pars.Deriv(dS,dPdP0,derFit); - } - StvFitErrs &nowErrs = node->mPE[lane]; - const StvFitErrs &preErrs = preNode->mFE[lane]; -assert(preErrs.mHH>0); -assert(preErrs.mZZ>0); - nowErrs = preErrs*derFit; -assert(nowErrs.mHH>0); -assert(preErrs.mZZ>0); - nowErrs.Add(el,pars,dS); -assert(nowErrs.mHH>0); -assert(preErrs.mZZ>0); - innNode->SetDer(derFit,lane); - } - - node->mFP[lane]._curv = saveCurv; - - return 0; - -} -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Fit(const StvTrack *trak,const StvHit *vtx,StvNode *node) -{ -static int nCall = 0; nCall++; -static StvToolkit *kit = StvToolkit::Inst(); -static StvFitter *fitt = StvFitter::Inst(); -enum {kDeltaZ = 100};//?????? - - const StvNode *lastNode = trak->GetNode(StvTrack::kDcaPoint); - if (!lastNode) return 1; - if (fabs(vtx->x()[2]-lastNode->GetFP()._z) > kDeltaZ) return 2; - THelixTrack th; - lastNode->GetFP().get(&th); - lastNode->GetFE().Get(&th); - const float *h = vtx->x(); - double d[3]={h[0],h[1],h[2]}; - double len = th.Path(d); - double x[3]; - th.Eval(len,x); - mDca3 = DIST2(d,x); - StvFitDers derivFit; - StvHlxDers derivHlx; - if (node) {th.Move(len,derivHlx);} else {th.Move(len);} - double Hz = kit->GetHz(th.Pos()); - StvNodePars par[2]; par[0].set(&th,Hz); - StvFitErrs err[2]; err[0].Set(&th,Hz); - fitt->Set(par+0,err+0,par+1,err+1); - fitt->Prep(); - mXi2 = fitt->Xi2(vtx); - if (!node) return 0; - - fitt->Update(); - assert(err[1].mHH>0); - assert(err[1].mZZ>0); - - - mXi2 = fitt->GetXi2(); - node->SetPre(par[0],err[0],0); - node->SetFit(par[1],err[1],0); - par[1].convert(derivFit,derivHlx); - node->SetDer(derivFit,0); - return 0; -} -//_____________________________________________________________________________ -THelixTrack* StvKalmanTrackFitter::GetHelix() const {return mHelx;} - -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Helix(StvTrack *trak,int mode) -{ -static int nCall=0;nCall++; -enum {kUseErrs=1, kUpdate=2, kPrint=4}; -// mode &1 use err -// mode &2 = update track -// mode &4 = print - - if (!mode ) mode = kPrint; - mXi2 = 0; - if (!mHelx) mHelx = new THelixFitter; - mHelx->Clear(); - StvFitDers Fstv; - StvHlxDers Fhlx; - THelixFitter& hlx = *mHelx; - StvNode *node=0,*preNode=0; if (preNode){}; - for (StvNodeIter it=trak->begin();it!=trak->end(); ++it) { - node = *it; - const StvHit *hit= node->GetHit(); - if (!hit) continue; - hlx.Add(hit->x()[0],hit->x()[1],hit->x()[2]); - if(mode&kUseErrs) { //Account errors - double cos2li = node->GetFP()._tanl; cos2li = (1+cos2li*cos2li); - const double *rr = node->GetHE(); - assert(rr[0]>0);assert(rr[2]>0);assert(rr[0]*rr[2]>rr[1]*rr[1]); - hlx.AddErr( rr[0],rr[2]*cos2li); - } - } - mXi2 = 3e33; if (hlx.Used()<3) return 1; - mXi2 =hlx.Fit(); - if(mode&kUseErrs) { hlx.MakeErrs();} - double dL = hlx.Path(trak->front()->GetFP().P); - hlx.Move(dL); - if ((mode&(kUpdate|kPrint))==0) return 0; - node=0; - double dHit[3],tstXi2=0,myXi2=0; - -// Loop for Print,compare & update - double totLen=0; - THelixTrack myHlx(hlx); - int iNode = -1; - for (StvNodeIter it=trak->begin();it!=trak->end(); ++it) { - iNode++;preNode=node; node = *it; - StvNodePars sFP = node->GetFP(0); - const StvHit *hit = node->GetHit(); - const float *hix = (hit)? hit->x():0; - - const double *X = node->mXDive; - if (hit) {for (int i=0;i<3;i++) {dHit[i]=hix[i];};X = dHit;} - double dS = myHlx.Path(X); myHlx.Move(dS,Fhlx); - totLen+=dS; - StvNodePars hFP; hFP.set(&myHlx,sFP._hz); - hFP.convert(Fstv,Fhlx); -//?? StvFitErrs sFE = node->GetFE(2); - StvFitErrs hFE; hFE.Set(&myHlx,sFP._hz); - - - myXi2 = 6e6; - if (hix) {//Hit is there. Calculate Xi2i etc... - StvNodePars iFP(hFP); iFP._x=hix[0];iFP._y=hix[1];iFP._z=hix[2]; - StvFitPars fp = hFP-iFP; - - const double *hRR = node->GetHE(); - myXi2 = fp.mH /(hFE.mHH+hRR[0]) *fp.mH; - myXi2+= fp.mZ /(hFE.mZZ+hRR[2]) *fp.mZ; - - tstXi2 += myXi2; - } - - if (mode&kUpdate) { //Update - node->mLen = totLen; - node->SetPre(hFP,hFE,0); - node->SetFit(hFP,hFE,0); - node->SetXi2(myXi2,0); - } - - if (mode&kPrint) { //Print Helix - printf("HelixPars(%g) Xi2i=%g ",totLen,myXi2); hFP.print(); - if (mode&1) hFE.Print("HelixErrs"); - } - - }//end of hit loop - - tstXi2/=hlx.Ndf();if (tstXi2){}; - double qwe = mXi2; if (qwe){};//only to see it in gdb - - - return 0; -} -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Check(StvTrack *trak) -{ -static int nCall = 0; nCall++; - if (trak->size()<10) return 0; - Helix(trak,1); - StvNode *node = trak->GetNode(StvTrack::kFirstPoint); -// StvNode *node = trak->front(); - double s = mHelx->Path(node->GetFP().P); - mHelx->Move(s); - const StvFitErrs &fe = node->GetFE(); - StvFitErrs my; - my.Set(mHelx,fe.mHz); - - -#define OLEG(a,b) (2*fabs(a-b)/(fabs(a)+fabs(b)+1e-11)) - int ierr = 0; - for (int i=0,li=0;i< 5;li+=++i) { - if (OLEG(my[li+i],fe[li+i])<0.3) continue; - ierr = ierr*10+i+1; - printf(" Err.%d = %g != %g\n",i,fe[li+i],my[li+i]); - }; -// assert(!ierr); - return ierr; -} -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Check(const StvNodePars &parA,const StvFitErrs &errA, - const StvNodePars &parB,const StvFitErrs &errB) -{ - THelixTrack helx; - parA.get(&helx); - errA.Get(&helx); - double s = helx.Path(parB.P); - helx.Move(s); - StvFitErrs my; - my.Set(&helx,errB.mHz); - int ierr = 0; - for (int i=0,li=0;i< 5;li+=++i) { - if (OLEG(my[li+i],errB[li+i])<0.1) continue; - ierr = ierr*10+i+1; - printf(" Err.%d = %g != %g\n",i,errB[li+i],my[li+i]); - }; - int rxy = parB.getRxy(); - printf("%3d Propagate HHold=%g HHnow=%g(%g) len=%g\n",rxy,errA.mHH,errB.mHH,my.mHH,s); - printf(" ZZold=%g ZZnow=%g(%g) \n", errA.mZZ,errB.mZZ,my.mZZ ); - -// assert(!ierr); - return ierr; -} - -//_____________________________________________________________________________ -int StvKalmanTrackFitter::Clean(StvTrack *trak) -{ - int nErr = 0; - - for (StvNodeIter it=trak->begin();it!=trak->end();++it) - { - int fail = 0; - StvNode *node = *it; - StvHit *hit = node->GetHit(); - if (!hit) continue; - const StvNodePars &np = node->GetFP(); - if (fabs(np._ptin) > mKons->mMaxPti) fail+= 1; - if (fabs(np._curv) > mKons->mMaxCurv) fail+= 2; - if ( np.diff(hit->x())> mKons->mMaxRes) fail+= 4; - if (!fail) continue; - node->SetXi2(3e33);node->SetHit(0); nErr++; - } - return nErr; -} - diff --git a/StRoot/Stv/StvKalmanTrackFitter.h b/StRoot/Stv/StvKalmanTrackFitter.h deleted file mode 100644 index a20fd4252ce..00000000000 --- a/StRoot/Stv/StvKalmanTrackFitter.h +++ /dev/null @@ -1,42 +0,0 @@ -/// \File StvKalmanTrackFitter.h -/// \author Victor Perev 9/2010 -#ifndef StvKalmanTrackFitter_HH -#define StvKalmanTrackFitter_HH -#include "StvTrackFitter.h" - -/// \class StvKalmanTrackFitter -class StvTrack; -class StvNode; -class THelixTrack; -class THelixFitter; -class StvKonst_st; -class StvKalmanTrackFitter : public StvTrackFitter -{ -public: - StvKalmanTrackFitter(); - void SetCons(const StvKonst_st* kons); - virtual ~StvKalmanTrackFitter(){;} - virtual int Refit(StvTrack *trak,int idir); - virtual int Refit(StvTrack *trak,int dir,int lane,int mode=1); - virtual int Fit(const StvTrack *trak,const StvHit *vtx,StvNode *node); - int Propagate(StvNode *node,StvNode *preNode,int dir,int lane); - virtual int Helix(StvTrack *trak,int mode); - virtual int Clean(StvTrack *trak); - virtual int Check(StvTrack *trak); - virtual int Check(const StvNodePars &parA,const StvFitErrs &errA, - const StvNodePars &parB,const StvFitErrs &errB); - virtual THelixTrack* GetHelix() const; - virtual void Clear(const char *opt=""); - - -protected: -char mBeg[1]; -const StvKonst_st *mKons; -THelixFitter *mHelx; -char mEnd[1]; - -ClassDef(StvKalmanTrackFitter,0); -}; - - -#endif diff --git a/StRoot/Stv/StvNode.cxx b/StRoot/Stv/StvNode.cxx deleted file mode 100644 index 47843d40081..00000000000 --- a/StRoot/Stv/StvNode.cxx +++ /dev/null @@ -1,230 +0,0 @@ -//StvKalmanTrack.cxx -/* - * $Id: StvNode.cxx,v 1.38 2016/12/09 21:21:41 perev Exp $ - * - * /author Victor Perev - */ - -#include -#include -#include -#include "TString.h" - -#include "Stv/StvToolkit.h" -#include "Stv/StvNode.h" -#include "Stv/StvHit.h" -#include "StvUtil/StvDebug.h" -#include "StvUtil/StvELossTrak.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - - -//______________________________________________________________________________ -void StvNode::reset() -{ -static int myCount=0; - assert(mBeg[0]=='@'); - memset(mBeg,0,mEnd-mBeg+1); - mId = ++myCount; - StvDebug::Break(mId); - mXi2[0] = 3e33;mXi2[1] = 3e33;mXi2[2] = 3e33; -} -//______________________________________________________________________________ -void StvNode::unset() -{ -static StvToolkit *kit = StvToolkit::Inst(); - if (mELoss) kit->FreeELossTrak(mELoss); - mELoss = 0; - assert(mBeg[0]!='@'); - memset(mBeg,'@',mEnd-mBeg+1); -} -//______________________________________________________________________________ -StvNode &StvNode::operator=(const StvNode &from) -{ -static StvToolkit* kit=StvToolkit::Inst(); - memcpy(mBeg,from.mBeg,mEnd-mBeg+1); - if (mELoss) { //Recreate ELossTrak - mELoss = kit->GetELossTrak(); - *mELoss = *from.mELoss; - } - return *this; -} - -//______________________________________________________________________________ -void StvNode::SetPre(StvNodePars &par,StvFitErrs &err,int dir) -{ - assert(err.mHH>0); - mPP[dir]=par;mPE[dir]=err; - mFP[dir]=par;mFE[dir]=err; - mFP[ 2]=par;mFE[ 2]=err; -} -//______________________________________________________________________________ -void StvNode::SetFit(StvNodePars &par,StvFitErrs &err,int dir) -{ - assert(err.mHH>0); - mFP[dir]=par;mFE[dir]=err; - if (dir==2) return; - mFP[2]=par;mFE[2]=err; -} -//______________________________________________________________________________ -StDetectorId StvNode::GetDetId() const -{ - const StHitPlane *hp = GetHitPlane(); if (!hp) return kUnknownId; - return hp->GetDetId(); -} -//________________________________________________________________________________ -double StvNode::GetTime() const -{ - return 0; -} -//________________________________________________________________________________ -void StvNode::Print(const char *opt) const -{ -static const char *txt = "X Y Z Pt Cu H R E Ep L Ps Tl P[ E[ Pa "; -static const char *hhh = "x y z r e "; - if (!opt || !opt[0]) opt = "_"; - TString myOpt(opt);myOpt+=" "; - int dir = myOpt.Index("="); - dir = (dir<0)? 2:myOpt[dir+1]-'0'; - int djr = dir; if (djr>3) djr-=4; - double val,err[2]; - const StvNodePars &fp= mFP[dir]; - const StvFitErrs &fe= mFE[dir]; - int dkr = (dir<2)? dir:0; - const StvFitErrs &pe= mPE[dkr]; -//const StvNodePars &pp= mPP[dkr]; - StvHit *hit = GetHit(); - TString ts; - if (mHitPlane) ts = "h"; - if (hit) ts = "H"; - if (GetType()==kDcaNode ) ts='D'; - if (GetType()==kPrimNode) ts='P'; - - printf("%p(%s)",(void*)this,ts.Data()); - printf("\t%s=%g","Xi2",GetXi2(djr)); - int iopt=0; - const char *myopt = myOpt.Data(); char*e; - for (int i=0;txt[i];i++) { - if (txt[i]==' ') continue; - int nc = 2; if (txt[i+1]=='[') nc = 4; - TString ts(txt+i,nc); - err[0]=-999;val=-999; - const char *cal = 0; - if ((iopt=myOpt.Index(ts))<0) continue; - int idx =(txt[i+1]=='[') ? strtol(myopt+iopt+2,&e,10):0; - - {//Single letter request - if (ts=="X ") {val = fp._x;} - else if (ts=="Y ") {val = fp._y;} - else if (ts=="Z ") {val = fp._z;} - else if (ts=="R ") {val = fp.getRxy();} - else if (ts=="Ps") {val = fp._psi ;} - else if (ts=="Tl") {val = fp._tanl ;} - else if (ts=="Pt") {val = fp.getPt() ;} - else if (ts=="Cu") {val = fp._curv;} - else if (ts=="E ") {err[0] = sqrt(fe.mHH); err[1] = sqrt(fe.mZZ);} - else if (ts=="Ep") {err[0] = sqrt(pe.mHH); err[1] = sqrt(pe.mZZ);} - else if (ts=="L ") {val = GetLen();} - else if (ts=="H ") {val = fp._hz;} - else if (ts=="P[") {val = fp[idx];} - else if (ts=="E[") {val = fe[idx];} - else if (ts=="Pa") {cal = (mHitPlane)? mHitPlane->GetPath():"";} - if (!cal && val==-999 && err[0]==-999) continue; - printf("\t%s=",ts.Data()); - if (cal) { printf("%s ",cal);} - if (fabs(val+999)>1e-6) { printf("%g",val);} - if (err[0]>-999) { printf("HH(%7.2g) ZZ(%7.2g)",err[0],err[1]);} - } - }//end for i - - if (hit) { - printf(" hit(%p) ",(void*)hit); - for (int i=0; hhh[i];i++) { - err[0]=-999;val=-999; - if (hhh[i]==' ') continue; - if ((iopt=myOpt.Index(TString(hhh+i,2)))<0) continue; - if (hhh[i+1]==' ') {//Single letter request - if (hhh[i]=='r') { val = hit->getRxy();} - else if (hhh[i]=='e') {err[0] = sqrt(mHrr[0]); err[1] = sqrt(mHrr[2]);} - else {val = hit->x()[i/2];} - if (fabs(val+999)>1e-6) {printf("\th%c=%g",hhh[i],val);} - if (err[0]>-999) {printf("\thh=%7.2g zz=%7.2g",err[0],err[1]);} - } else if (txt[i+1]=='[') {// now print by index - - int idx = strtol(myopt+i+2,&e,10); - TString tnam(myopt+i,e-(myopt+i)+1); - if (txt[i]=='e') {val = mHrr[idx];} - printf("\t%s=%g",tnam.Data(),val); - } - } - } - - printf("\n"); - return; -} -//________________________________________________________________________________ -void StvNode::SetDer(const StvFitDers &der, int dir) -{ - mDer[ dir]=der; - mDer[1-dir]=der; - mDer[1-dir].Reverse(); -} -//________________________________________________________________________________ -void StvNode::SetHit(StvHit *hit) -{ - mHit = hit; - if (!mHit) return; - assert(!mHit->isUsed()); -} -//________________________________________________________________________________ -void StvNode::SetMem(StvHit *hit[2],double xi2[2]) -{ - memcpy(memHit,hit,sizeof(memHit)); - memXi2[0]=xi2[0];memXi2[1]=xi2[1]; -} -//________________________________________________________________________________ -void StvNode::UpdateDca() -{ - const StvNodePars &P = mFP[2]; - double dL = -( P._x*P._cosCA+P._y*P._sinCA) - /(1+(-P._x*P._sinCA+P._y*P._cosCA)*P._curv); - if (fabs(dL)<1e-6) return; - THelixTrack hlx; - mFP[2].get(&hlx); - mFE[2].Get(&hlx); - dL = hlx.Path(0.,0.); - hlx.Move(dL); - mFP[2].set(&hlx,mFP[2]._hz); - mFE[2].Set(&hlx,mFP[2]._hz); -} -//________________________________________________________________________________ -int StvNode::Check(const char *tit, int dirs) const -{ - if (!tit) tit=""; - int nerr=0,ans; - for (int k=0;k<5;k++) { - TString ts; - if (tit[0]) {ts=tit; ts+="/par["; ts+=k;ts+="]"; } - int itst = (((1&k)+1)&dirs); - if (k==4) itst = 1; - if (!itst) continue; - ans = mPP[k].check(ts); if (ans) nerr++; - ans = mPE[k].Check(ts); if (ans) nerr++; - } - return nerr; -} -//________________________________________________________________________________ -int StvNode::ResetELoss(const StvNodePars &pars,int dir) -{ -static const double kSmaP =0.01; -static const double kBigP =3 ,kSmaDiff=1e-2; - - if (!mELoss) return 0; - double p = pars.getP(); - if (p>kBigP) p=kBigP; - if (pP(); - if (fabs(myP-p)Update(dir,p); - return 0; -} - diff --git a/StRoot/Stv/StvNode.h b/StRoot/Stv/StvNode.h deleted file mode 100644 index 8f32af97bba..00000000000 --- a/StRoot/Stv/StvNode.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef StvNode_H -#define StvNode_H 1 -#define STI_NODE_DEBUG - -#include -#include -#include -#include "StvUtil/StvNodePars.h" -#include "StEvent/StEnumerations.h" - -class StvHit; -class StHitPlane; -class StvELossTrak; - - -/*! \class StvNode - Work class used to handle Kalman filter information while - constructing track nodes. A node may or may not own a hit - depending whether it lies on a measurement layer where a hit - was found. A node can have 0, 1, or many children. - Nodes are nominally sequenced outside-in i.e. with decreasing - radius (or independent variable). The order can however be reversed. - In anycase, the order should always be monotonically increasing - or decreasing. - \author Claude A Pruneau -*/ -class StvNode -{ -public: -friend class StvTrack; -enum ENodeType {kRegNode=0,kDcaNode=1,kPrimNode=2}; - -public: - StvNode(){mBeg[0]='@';} - StvNode(const StvNode &node); - virtual ~StvNode(){mId=-1;}; - StvNode &operator=(const StvNode &from); - /// Resets the node to a "null" un-used state - void reset(); - void unset(); - const StvNodePars &GetFP() const {return mFP[2];} - const StvFitErrs &GetFE() const {return mFE[2];} - - StvNodePars &GetPP(int dir) {return mPP[dir];} - StvFitErrs &GetPE(int dir) {return mPE[dir];} - StvNodePars &GetFP(int dir) {return mFP[dir];} - StvFitErrs &GetFE(int dir) {return mFE[dir];} - const StvNodePars &GetFP(int dir) const {return mFP[dir];} - const double *GetHE() const {return mHrr ;} - void SetHE(const double he[3]) - {mHrr[0]=he[0]; mHrr[1]=he[1];mHrr[2]=he[2];} - - /// Extract state information from this node in TPT representation. - void GetGlobalTpt (float x[6],float e[15]); - - /// Calculates and returns the momentum and error of the track at this node. The momentum is - /// in the local reference frame of this node. - void GetMomentum(double p[3], double e[6]=0) const; - /// Calculates and returns the Z mag field in the current point. - /// units: PGeV = Hz*Radcurv_in_CM - double GetHz() const {return mFP[2]._hz;} - double GetTime() const; - int IsFitted(int dir) const { return (mHit && mXi2[dir]<1000);} - - StvHit *GetHit() const { return mHit;} - void SetHit(StvHit *hit); - void SetMem(StvHit *hit[2],double xi2[2]); - const StHitPlane *GetHitPlane() const { return mHitPlane ;} - void SetHitPlane(const StHitPlane *hitPlane) { mHitPlane=hitPlane;} - void SetELoss(StvELossTrak *el,int ) { mELoss=el ;} - const StvELossTrak *GetELoss() const { return mELoss ;} - - double GetXi2(int dir=2) const { return mXi2[dir] ;} - double GetLen() const { return mLen ;} - void SetXi2(double Xi2,int dir=2) { mXi2[dir]=Xi2; mXi2[2]=Xi2;} - void SetPre(StvNodePars &par,StvFitErrs &err,int dir); - void SetFit(StvNodePars &par,StvFitErrs &err,int dir); - void SetDer(const StvFitDers &der, int dir); - void SetXDive(const double xdive[3]) {memcpy(mXDive,xdive,sizeof(mXDive));} - int ResetELoss(const StvNodePars &pars,int dir); - StvNode::ENodeType GetType() const {return (StvNode::ENodeType)mType;} - void SetType(StvNode::ENodeType ty) {mType =(char)ty;} -StDetectorId GetDetId() const; -void UpdateDca(); - int Check(const char *tit="",int dirs=3) const; -void Print(const char *opt) const; - private: - - public: - - char mBeg[1]; - char mType; //0=regular,1=dca,2=primary - double mXDive[3]; // xyz from Diver -const StHitPlane *mHitPlane; -StvHit *mHit; -StvHit *memHit[2]; - float memXi2[2]; - -/// Z mag field in units PGev = Hz*Rcm - mutable double mHz; -/// indices of arrays 0=moving in, 1=moving out,2=join result of in & out - StvNodePars mFP[4]; // Fitted Parameters - StvNodePars mPP[2]; // Predicted Parameters+last id for helix - StvFitErrs mFE[4]; // Fitted errors - StvFitErrs mPE[2]; // Predicted errors - StvFitDers mDer[2]; // Derivative matrix 0=from outer to this; 1=from this to outer - double mHrr[3]; // Hit errors in DCA frame - float mXi2[4]; // Xi2 of fit to hit,join,helix - float mLen; // Length - StvELossTrak *mELoss; //EnergyLoss&MCS from the upper node - char mEnd[1]; -public: - int mId; //for debug only -}; - -#endif - diff --git a/StRoot/Stv/StvSeedFinder.cxx b/StRoot/Stv/StvSeedFinder.cxx deleted file mode 100644 index 5be665176c6..00000000000 --- a/StRoot/Stv/StvSeedFinder.cxx +++ /dev/null @@ -1,234 +0,0 @@ -#include "StvSeedFinder.h" -#include "TSystem.h" -#include "TVector3.h" -#include "TSystem.h" -#include "StvUtil/StvDebug.h" -#include "StvDraw.h" -#include "StvTrack.h" -#include "StvNode.h" -#include "StvHit.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "vector" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StvUtil/StvKNNUtil.h" -#include "Stv/StvConst.h" - -//Constants for THelixFitter (Approx) -static const double kBAD_XI2cm2 = 0.9*0.9 // max Xi2 in cm**2 without errs - , kBAD_XI2 = 50 // max Xi2 (with errs) - , kBAD_RHO=0.1 // max curvature - , kMIN_Rxy=50; // minimal radius for seed hits - -ClassImp(StvSeedFinder) - -//_____________________________________________________________________________ -StvSeedFinder::StvSeedFinder(const char *name):TNamed(name,"") -{ - fDraw=0; - fMinHits = 5; - fMaxHits = 10; - fSgn = 1; - fIdTruth = 0; - SetVtx(0); -} -//_____________________________________________________________________________ -void StvSeedFinder::SetCons(const StvKonst_st *kons) -{ - fMinHits= kons->mMinSeedHits; - fMaxHits= kons->mMaxSeedHits; -} -//_____________________________________________________________________________ -void StvSeedFinder::Clear(const char*) -{ - SetVtx(0); - fSeedHits.clear(); - if(fDraw) fDraw->Clear(); -} -//_____________________________________________________________________________ -void StvSeedFinder::SetVtx(const float vtx[3]) -{ - if (vtx) { memcpy(fVtx,vtx,sizeof(fVtx)); return; } - memset(fVtx,0,sizeof(fVtx)); - fVtx[2]= 3e33; -} -//_____________________________________________________________________________ -void StvSeedFinder::Show() -{ - if (!fDraw) fDraw = NewDraw(); - StvConstHits &ch = (StvConstHits &)fSeedHits; - fDraw->Road(fHelix,ch,kGlobalTrack,10.); - fDraw->UpdateModified(); - fDraw->Wait(); -} -//_____________________________________________________________________________ -void StvSeedFinder::ShowRest(EDraw3DStyle style) -{ - if (!fDraw) fDraw = NewDraw(); - std::vector myHits; - const StVoidArr *hitArr = StTGeoProxy::Inst()->GetSeedHits(); - int nHits = hitArr->size(); - for (int iHit=0;iHitisUsed()) continue; - myHits.push_back(stiHit); - } - fDraw->Hits(myHits,style); - fDraw->UpdateModified(); - fDraw->Wait(); -} -//_____________________________________________________________________________ -void StvSeedFinder::ShowIn() -{ - if (!fDraw) fDraw = NewDraw(); - std::vector myHits; - const StVoidArr *hitArr = StTGeoProxy::Inst()->GetSeedHits(); - int nHits = hitArr->size(); - for (int iHit=0;iHitx())) continue; - myHits.push_back(stiHit); - } - fDraw->Hits(myHits,kUnusedHit); - fDraw->UpdateModified(); - fDraw->Wait(); -} -//_____________________________________________________________________________ -StvDraw *StvSeedFinder::NewDraw() -{ - StvDraw *dr = new StvDraw(); - dr->SetBkColor(kWhite); - return dr; -} - -//_____________________________________________________________________________ -const THelixTrack *StvSeedFinder::Approx() -{ -static int nCall=0; nCall++; -// Loop over nodes and collect global xyz - - fHelix.Clear(); - THelixFitter circ; - int nNode=fSeedHits.size(); - const float *fBeg = fSeedHits.front()->x(); - const float *fEnd = fSeedHits.back ()->x(); - double r2Beg = fBeg[0]*fBeg[0]+fBeg[1]*fBeg[1]; - double r2End = fEnd[0]*fEnd[0]+fEnd[1]*fEnd[1]; - if (fSgn*r2Beg < fSgn*r2End) return 0; - - for (int iNode = 0; iNodex()[0],hit->x()[1],hit->x()[2]); - } - fXi2[0] =circ.Fit(); - if (fXi2[0]>kBAD_XI2cm2) return 0; //Xi2 too bad, no updates - if (fabs(circ.GetRho()) >kBAD_RHO) return 0; //Too big curvature - - const double dBeg[3]={fBeg[0],fBeg[1],fBeg[2]}; - double l = circ.Path(dBeg); circ.Move(l); - -// Now refit with errors - for (int iNode = 0; iNodex(); - const double dx[3]={fx[0],fx[1],fx[2]}; - double l = circ.Path(dx); circ.Move(l); -// Set position for helix - fHelix.Add(dx[0],dx[1],dx[2]); -// Set position errors for helix - const StHitPlane *hp = hit->detector(); - StvHitErrCalculator* myHitErrCalc = (StvHitErrCalculator*)hp->GetHitErrCalc(); - myHitErrCalc->SetTrack(circ.Dir()); - double hRR[3]; -// const Mtx33F_t &hd = hp->GetDir(fx); -// int ans = myHitErrCalc->CalcDcaErrs(fx,hd,hRR); - int ans = myHitErrCalc->CalcDcaErrs(hit,hRR); - if (ans) {// touching case - fHelix.AddErr( 1.,1.); - } else { - double cos2l = circ.GetCos(); cos2l*=cos2l; - if (hRR[0]<1e-4) hRR[0]=1.; - fHelix.AddErr( hRR[0],hRR[2]/cos2l); - } - } - fXi2[1] =fHelix.Fit(); - if (fXi2[1]>kBAD_XI2) return 0; //Xi2 too bad, no updates - fHelix.MakeErrs(); - if (fSgn>0) { - l = fHelix.Path(dBeg); - l-= 0.1; fHelix.Move(l); - } else { - const double dEnd[3]={fEnd[0],fEnd[1],fEnd[2]}; - l = fHelix.Path(dEnd); - l+= 0.1; fHelix.Move(l); - fHelix.Backward(); - } - return &fHelix; -} -#include "StarRoot/TIdTruUtil.h" -//_____________________________________________________________________________ -void StvSeedFinder::FeedBack(const StvTrack *tk) -{ - if (StvDebug::Debug()<2) return; - TIdTruUtil idu; - - for (int ih=0;ih<(int)fSeedHits.size();ih++) { - auto *hit = fSeedHits[ih]; - idu.Add(hit->idTru()); - } - double qua = idu.GetQua()*100; - if (!idu.GetIdTru()) qua=0; - StvDebug::Count("SeedAllQua",qua); - if (!tk) { // - StvDebug::Count("SeedBadXi2:Xi2E",fXi2[1],fXi2[0]); - StvDebug::Count("SeedBadQua",qua); - - } else { - StvDebug::Count("GooXi2:Xi2E",fXi2[1],fXi2[0]); - - StvDebug::Count("SeedGooQua",qua); - double tqua = tk->GetQua()*100; - StvDebug::Count("GlobGooQua",tqua); - StvDebug::Count("GlobGooQua::SeedGooQua",qua,tqua); - const StvNode *node = tk->GetNode(StvTrack::kFirstPoint); - double P[3]; - node->GetFP().getMom(P); - - double eta = TVector3(P).Eta(); - int nHits = tk->GetNHits(kPxlId); - nHits += tk->GetNHits(kIstId); - nHits += tk->GetNHits(kSstId); - StvDebug::Count("GoodEta",eta); - if (nHits>=2) StvDebug::Count("HftEta",eta); - } -} - -//_____________________________________________________________________________ -void StvSeedFinders::Clear() -{ - for (int i=0;i<(int)size();i++) {(*this)[i]->Clear();} -} - -//_____________________________________________________________________________ -void StvSeedFinders::Reset() -{ - for (int i=0;i<(int)size();i++) {(*this)[i]->Reset();} -} -//_____________________________________________________________________________ -void StvSeedFinders::SetCons(const StvKonst_st *kons) -{ - for (int i=0;i<(int)size();i++) {(*this)[i]->SetCons(kons);} -} -//_____________________________________________________________________________ -void StvSeedFinders::SetVtx(const float vtx[3]) -{ - for (int i=0;i<(int)size();i++) {(*this)[i]->SetVtx(vtx);} -} - -//_____________________________________________________________________________ -void StvSeedFinders::Add(StvSeedFinder *sf) -{ - push_back(sf); -} - - diff --git a/StRoot/Stv/StvSeedFinder.h b/StRoot/Stv/StvSeedFinder.h deleted file mode 100644 index 98dbb8caa30..00000000000 --- a/StRoot/Stv/StvSeedFinder.h +++ /dev/null @@ -1,81 +0,0 @@ -/// \File StvSeedFinder.h -/// \author Victor Perev 01/2010 -#ifndef StvSeedFinder_HH -#define StvSeedFinder_HH -#include -#include -#include "THelixTrack.h" -#include "TNamed.h" -#include "StvStl.h" -#include "StDraw3D.h" - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -//#define KNNDEBUG 1 - - -/// \class StvSeedFinder -class StvDraw; -class StvHit; -class StvTrack; -class StvKonst_st; - - -class THelixTrack; -class StvSeedFinder : public TNamed -{ -public: - StvSeedFinder(const char *name); - virtual ~StvSeedFinder(){;} - void SetCons(const StvKonst_st *kons); - virtual const THelixTrack *NextSeed() =0; - virtual void Reset() =0; - virtual void Clear(const char* opt=""); - virtual int Again(int){return 0;} - virtual void FeedBack(const StvTrack *tk); - virtual void SetSgn(int sgn=1){fSgn = sgn;} - virtual void SetVtx(const float vtx[3]); - void SetIdTruth() { fIdTruth = 1; } - virtual int IfVtx() const {return fVtx[2]<1e11;} - -virtual const StvHits *GetHits() const {return &fSeedHits;} - - virtual void Show(); - virtual void ShowRest(EDraw3DStyle style = kUnusedHit); - virtual void ShowIn(); - virtual int Reject(const float *x) {return 0;} - - double GetXi2(int i=1) const {return fXi2[i];} - void KNNMiMax(double &mi,double &ma); - - -static StvDraw *NewDraw(); -protected: - const THelixTrack* Approx(); -protected: -int fMinHits; //Min number of hits accepted -int fMaxHits; //Max number hits fo seed -int fSgn; -int fIdTruth; -StvHits fSeedHits; -THelixFitter fHelix; -StvDraw *fDraw; -float fVtx[3]; //Vertex if already known -double fXi2[2]; //Xi2[0] without hit errs,[1] with hit errs -ClassDef(StvSeedFinder,0); -}; - -class StvSeedFinders : public std::vector -{ public: - void Clear(); - void Reset(); - void Add(StvSeedFinder *sf); - void SetCons(const StvKonst_st *kons); - void SetVtx(const float vtx[3]); -}; - - -#endif diff --git a/StRoot/Stv/StvStl.cxx b/StRoot/Stv/StvStl.cxx deleted file mode 100644 index f79ad9c3a73..00000000000 --- a/StRoot/Stv/StvStl.cxx +++ /dev/null @@ -1,29 +0,0 @@ -// $Id: StvStl.cxx,v 1.6 2015/12/12 01:58:25 perev Exp $ -// -// -// Class StvStl some stl containers for Stv objects -// ------------------ -#include -#include "StvStl.h" -#include "StvHit.h" -//_____________________________________________________________________________ -StvPoints &StvPoints::operator+=(const float add[3]) -{ push_back(add[0]); push_back(add[1]); push_back(add[2]);return *this;} -//_____________________________________________________________________________ -StvPoints &StvPoints::operator+=(const double add[3]) -{ push_back(add[0]); push_back(add[1]); push_back(add[2]);return *this;} - -//_____________________________________________________________________________ -void StvHits::Print(const char *txt) -{ - if (txt && txt[0]) printf("StvHits(%s)\n",txt); - for (int i=0;i<(int)size();i++) { - auto *stvHit = (*this)[i]; - const float *x = stvHit->x(); - double r = sqrt(x[0]*x[0]+x[1]*x[1]); - int idTru = stvHit->idTru(); - - - printf("%3d - idTru = %d Rxy=%g x=%g y=%g z=%g\n",i,idTru,r,x[0],x[1],x[2]); - } -} diff --git a/StRoot/Stv/StvStl.h b/StRoot/Stv/StvStl.h deleted file mode 100644 index 3498009732d..00000000000 --- a/StRoot/Stv/StvStl.h +++ /dev/null @@ -1,55 +0,0 @@ - -#ifndef StvStl_HH -#define StvStl_HH -#include -#include -class StvVoids : public std::vector -{ -public: -StvVoids &operator+=(void *add) {push_back(add);return *this;} -}; -class StvHit; -class StvHits : public std::vector -{ -public: -StvHits &operator+=( StvHit *add) {push_back(add);return *this;} -StvHits &operator+=(const StvHits &add); -StvHits &operator+=(const std::vector &add); -void Print(const char *txt=""); -}; -class StvConstHits : public std::vector -{ -public: -StvConstHits &operator+=(const StvHit *add) {push_back(add);return *this;} -}; - -class StvPoints : public std::vector{ -public: -StvPoints &operator+=(const float add[3]); -StvPoints &operator+=(const double add[3]); -}; - -class StvNode; -typedef std::list::iterator StvNodeIter; -typedef std::list::const_iterator StvNodeConstIter; -typedef std::list::reverse_iterator StvBakwNodeIter; -class StvNodes : public std::list{ -public: -}; -class StvTrack; -typedef std::list::iterator StvTrackIter; -typedef std::list::const_iterator StvTrackConstIter; -class StvTracks : public std::list{ -public: -}; -//_____________________________________________________________________________ -inline StvHits &StvHits::operator+=(const StvHits &add) -{ insert(end(),add.begin(),add.end()); return *this;} -//_____________________________________________________________________________ -inline StvHits &StvHits::operator+=(const std::vector &add) -{ - const StvHits &myAdd = (const StvHits &)add; - (*this)+=myAdd; - return *this; -} -#endif diff --git a/StRoot/Stv/StvTester.cxx b/StRoot/Stv/StvTester.cxx deleted file mode 100644 index ebfddc9fd99..00000000000 --- a/StRoot/Stv/StvTester.cxx +++ /dev/null @@ -1,179 +0,0 @@ -#include -#include -#include -#include "TMath.h" -#include "TMatrixD.h" -#include "TVectorD.h" -#include "TCernLib.h" -#include "TGeoManager.h" -#include "StvTester.h" -#include "StvTrack.h" -#include "StvNode.h" -#include "StvUtil/StvNodePars.h" -#include "StvHit.h" -#include "StvUtil/StvDebug.h" -#include "StvUtil/StvELossTrak.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - -StvTester *StvTester::mgTester=0; -static const double piMass=0.13956995; -static const double kAccu=1e-3; -//______________________________________________________________________________ -StvTester::StvTester(const char *name):TNamed(name,"") -{ - memset(mBeg,0,mEnd-mBeg+1); - mEl = new StvELossTrak; - assert(!mgTester); - mgTester = this; -} -//______________________________________________________________________________ -StvTester *StvTester::Inst() -{ - if (!mgTester) mgTester = new StvTester(); - return mgTester; -} -//______________________________________________________________________________ -int StvTester::TestIt(const char* tit,const StvTrack *tk) -{ - int iErr=0; -#if 0 -static int nCall = 0; nCall++; - int n=0,pora=0; - const StvNode *curNode,*preNode=0; - double pCur,pPre=0,pBeg[2],pErr,lenTot=0,eAcc[2]={0}; - double len=0,pLos,pDlt,pct,sample=0; - - for (StvNodeConstIter it=tk->begin();it!=tk->end();++it) { - curNode = (*it); n++; -// const StvHit *hit = curNode->GetHit(); - const StvNodePars &par = curNode->GetFP(); - const StvFitErrs &err = curNode->GetFE(); - pCur = sqrt(par.getP2()); - pErr = sqrt(err.mPP/par.getCos2L()); - do { //Pseudo loop - if (!preNode){pBeg[0] = pCur;pBeg[1]=pCur; break;} - { //test 1` - pLos = PLoss(curNode,preNode,&len); - sample += len; - eAcc[0]+=pLos; eAcc[1]+=pLos; - pora = sample>555; - pDlt = pBeg[1] - pCur; - - if ( pora && (eAcc[2] > pErr || fabs(pDlt) > pErr)) { - pct = fabs(eAcc[1]-pDlt)/(pCur)*100; - if (pct>1) - {iErr|=1;Error(tit,"P=%g Len=%4.1f dP=%g Loss=%g dif=%4.1f%%" - ,pCur,sample,pDlt,eAcc[1],pct);} - sample=0;eAcc[1]=0;pBeg[1]=pCur; pora = 0; - } - }//end test1 - - - { //Now TEST2 - - const StvELossData &dat = preNode->GetELoss(); - double pLos2 = (dat.mdPP) *len*pPre; - if (1 || fabs(pLos2-pLos) > pErr) { - pct = fabs(pLos2-pLos)/(pLos2+pLos)*200; - printf("===== Rxy=%g Z=%g StvPLoss = %g InDive = %g dif=%1.1f%%\n" - ,par.getRxy(),par._z,pLos,pLos2,pct); } - - } - } while(0); - - assert(fabs(len)<400); - lenTot += len; - assert(fabs(lenTot)<400); - preNode = curNode; - pPre = pCur; - } - pDlt = pBeg[0]-pCur; - if ( eAcc[0] > pErr || fabs(pDlt) > pErr) { - pct = fabs(pDlt-eAcc[0])/(pCur)*100; - if (pct>1) - {iErr+=1000;Error(tit,"P=%g Len=%4.1f dP=%g Loss=%g dif=%4.1f%% ****" - ,pCur,lenTot,pDlt,eAcc[0],pct);} - - } -#endif - return iErr; -} -//______________________________________________________________________________ -double StvTester::DeltaLen(const StvNode* curNode,const StvNode* preNode,double *lenXY) const -{ - const StvNodePars &parA = preNode->GetFP(); - const StvNodePars &parB = curNode->GetFP(); - - const double *x1 = &parA._x; - const double *x2 = &parB._x; - double dlen = sqrt(pow(x1[0]-x2[0],2) + pow(x1[1]-x2[1],2)); - double curv = 0.5*fabs(parA._curv+parB._curv); - double dsin = (0.5*dlen*curv); - if (dsin>0.9) dsin=0.9; - dlen = (dsin<0.01)? dlen*(1.+dsin*dsin/6) : 2*asin(dsin)/curv; - if (lenXY) *lenXY = dlen; - dlen =sqrt(dlen*dlen + pow(x1[2]-x2[2],2)); - - return dlen; -} -//______________________________________________________________________________ -double StvTester::PLoss(const StvNode* curNode,const StvNode* preNode, double *len) const -{ -#if 0 -static int nCall = 0; nCall++; - const StvNodePars &parA = preNode->GetFP(); - const StvNodePars &parB = curNode->GetFP(); - THelixTrack curHlx,preHlx; - double momA = sqrt(parA.getP2()); - double momB = sqrt(parB.getP2()); - - parA.get(&preHlx); - parB.get(&curHlx); - double lenA = preHlx.Path(curHlx.Pos()); - double lenB = curHlx.Path(preHlx.Pos()); - double totLen = (fabs(lenA)+fabs(lenB))/2; - double step = 0.1; - if (parA.getRxy()<60 || parB.getRxy()<60) step = 0.01; - int nSteps = int(totLen/step+1); - double stepA = fabs(lenA/nSteps); - double stepB = fabs(lenB/nSteps); - curHlx.Move(lenB); - mEl->Reset(); - for (int iStep=0;iStepFindNode(myX[0],myX[1],myX[2]); - assert(geoNode); - TGeoVolume *geoVolu = geoNode->GetVolume(); - TGeoMaterial *geoMate = geoVolu->GetMaterial(); - double a = geoMate->GetA(); - double z = geoMate->GetZ(); - double d = geoMate->GetDensity(); - double x0 = geoMate->GetRadLen(); - double p = momA*(1-wt)+momB*wt; - mEl->Set (a, z, d, x0, p, piMass, +1.0); - double s = stepA*(1-wt)+stepB*wt; - mEl->Add(s); - curHlx.Move(stepB); - preHlx.Move(stepA); - } - assert(fabs(totLen)<400); - if (len) *len = totLen; - double dP0 = totLen*momB*mEl->dPovPLen(); - double dP1 = mEl->dEdX()*totLen*sqrt(momA*momA+piMass*piMass)/momA; - if ( fabs(dP0-dP1)/(dP0+dP1)*200>1) { - printf ("PLoss dP0=%g dP1=%g\n",dP0,dP1); - } - return dP0; -#endif -return 0; -} - - - - - - - diff --git a/StRoot/Stv/StvTester.h b/StRoot/Stv/StvTester.h deleted file mode 100644 index 4461c1f3108..00000000000 --- a/StRoot/Stv/StvTester.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __StvTester_h_ -#define __StvTester_h_ -#include -#include -#include -#include -#include "TNamed.h" -#include "StvUtil/StvNodePars.h" - -class StvELossTrak; -class StvTrack; -class StvNode; -class StvTester : public TNamed { -private: -StvTester(const char *name="DefaultTester"); -public: -static StvTester *Inst(); -int TestIt(const char *tit,const StvTrack *tk); -private: -double DeltaLen(const StvNode* curNode,const StvNode* preNode,double *lenXY=0) const; -double PLoss (const StvNode* curNode,const StvNode* preNode,double *len =0) const; - -protected: - char mBeg[1]; - StvELossTrak *mEl; - char mEnd[1]; -static StvTester *mgTester; -ClassDef(StvTester,0); -}; - -#endif //__StvTester_h_ - - diff --git a/StRoot/Stv/StvToolkit.cxx b/StRoot/Stv/StvToolkit.cxx deleted file mode 100644 index 095363807a5..00000000000 --- a/StRoot/Stv/StvToolkit.cxx +++ /dev/null @@ -1,216 +0,0 @@ -#include -#include -#include -#include "StvToolkit.h" -#include "Stv/Factory/StvFactory.h" -#include "Stv/StvHit.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "StvUtil/StvELossTrak.h" -#include "Stv/StvStl.h" -#include "Stv/StvDraw.h" -#include "StarMagField.h" -#include "StvMaker/StvHitLoader.h" -#include "Stv/StvSeedFinder.h" -#include "Stv/StvTrackFinder.h" - -class StvHitFactory : public StvFactory {public:}; -class StvHitRrFactory : public StvFactory {public:}; -class StvNodeFactory : public StvFactory {public:}; -class StvTrackFactory : public StvFactory {public:}; -class StvELossTrakFactory : public StvFactory {public:}; -class StvVertexFactory : public StvFactory {public:}; - - -StvToolkit *StvToolkit::mgInstance = 0; - -//_____________________________________________________________________________ -StvToolkit::StvToolkit() -{ - assert(!mgInstance); - mgInstance = this; - memset(mBeg,0,mEnd-mBeg+1); - mX[0] = -999999; - mTraks = new StvTracks; -} - -//_____________________________________________________________________________ -StvToolkit * StvToolkit::Inst() -{ - if (!mgInstance) mgInstance = new StvToolkit(); - - return mgInstance; -} - -//_____________________________________________________________________________ -StvHit *StvToolkit::GetHit() -{ - if (!mHitFactory) { - mHitFactory = (StvHitFactory*)StvHitFactory::myInstance(); - mHitFactory->setMaxIncrementCount(4000000); - mHitFactory->setFastDelete(); - } - return mHitFactory->getInstance(); -} -//_____________________________________________________________________________ -StvHit *StvToolkit::GetHitRr() -{ - if (!mHitRrFactory) { - mHitRrFactory = (StvHitRrFactory*)StvHitRrFactory::myInstance(); - mHitRrFactory->setMaxIncrementCount(4000000); - mHitRrFactory->setFastDelete(); - } - return mHitRrFactory->getInstance(); -} -//_____________________________________________________________________________ -StvHit *StvToolkit::GetVertex() -{ - if (!mVertexFactory) { - mVertexFactory = (StvVertexFactory*)StvVertexFactory::myInstance(); - mVertexFactory->setMaxIncrementCount(100); - mVertexFactory->setFastDelete(); - } - return mVertexFactory->getInstance(); -} -//_____________________________________________________________________________ -void StvToolkit::FreeHit(StvHit *&stiHit) -{ - if (!stiHit) return; - if (stiHit->errMtx()) { StvHitRrFactory::Free(stiHit);} - else { StvHitFactory::Free(stiHit);} - stiHit=0; -} -//_____________________________________________________________________________ -StvTrack *StvToolkit::GetTrack() -{ - if (!mTrackFactory) { - mTrackFactory = (StvTrackFactory*)StvTrackFactory::myInstance(); - mTrackFactory->setMaxIncrementCount(40000); - } - return mTrackFactory->getInstance(); -} -//_____________________________________________________________________________ -StvELossTrak *StvToolkit::GetELossTrak() -{ - if (!mELossTrakFactory) { - mELossTrakFactory = (StvELossTrakFactory*)StvELossTrakFactory::myInstance(); - mELossTrakFactory->setMaxIncrementCount(4000000); - } - return mELossTrakFactory->getInstance(); -} -//_____________________________________________________________________________ -void StvToolkit::FreeTrack(StvTrack *&stiTrack) -{ - StvTrackFactory::Free(stiTrack); stiTrack=0; -} -//_____________________________________________________________________________ -void StvToolkit::FreeELossTrak(StvELossTrak *&stiELossTrak) -{ - StvELossTrakFactory::Free(stiELossTrak); stiELossTrak=0; -} -//_____________________________________________________________________________ -StvNode *StvToolkit::GetNode() -{ - if (!mNodeFactory) { - mNodeFactory = (StvNodeFactory*)StvNodeFactory::myInstance(); - mNodeFactory->setMaxIncrementCount(4000000); - mNodeFactory->setFastDelete(); - } - return mNodeFactory->getInstance(); -} -//_____________________________________________________________________________ -void StvToolkit::FreeNode(StvNode *&stiNode) -{ - StvNodeFactory::Free(stiNode); stiNode=0; -} -//_____________________________________________________________________________ -StvTracks &StvToolkit::GetTracks(){return *mTraks;} -//_____________________________________________________________________________ -void StvToolkit::Show() const -{ - StvToolkit *This = (StvToolkit*)this; - for (StvTrackConstIter it = This->GetTracks().begin(); - it!= This->GetTracks().end(); ++it) { - const StvTrack *tk = *it;tk->Show(); - } -} -//_____________________________________________________________________________ -void StvToolkit::Clear(const char*) -{ -//if (StvDraw::Jnst()) StvDraw::Jnst()->Clear(); - if (mTraks) mTraks->clear(); - if (mHitLoader) mHitLoader->Clear(); - if (mSeedFinders) mSeedFinders->Clear(); - if (mTrakFinder) mTrakFinder->Clear(); - - if (mTrackFactory) mTrackFactory->clear(); - if (mELossTrakFactory) mELossTrakFactory->clear(); - if (mNodeFactory) mNodeFactory->clear(); - if (mHitFactory) mHitFactory->clear(); - if (mHitRrFactory) mHitRrFactory->clear(); - if (mVertexFactory) mVertexFactory->clear(); - StvTrack::mgId=0; -} -/*! Calculate/return the z component of mag field -

- Calculate/return the z component of mag field -

- Field is calcualated via StarMagField class and cashed. -*/ -//_____________________________________________________________________________ -void StvToolkit::Print(const char*) -{ - if (mTrackFactory) mTrackFactory->print(); - if (mELossTrakFactory)mELossTrakFactory->print(); - if (mNodeFactory) mNodeFactory->print(); - if (mHitFactory) mHitFactory->print(); - if (mVertexFactory) mVertexFactory->print(); -} -//_____________________________________________________________________________ -void StvToolkit::Reset() -{ - if (mSeedFinders) mSeedFinders->Reset(); - if (mTrakFinder) mTrakFinder->Reset(); - -} -//______________________________________________________________________________ -double StvToolkit::GetHz(const double *x) const -{ - static const Double_t EC = 2.99792458e-4; - do { - if (fabs(x[0]-mX[0])>1e-3) break; - if (fabs(x[1]-mX[1])>1e-3) break; - if (fabs(x[2]-mX[2])>1e-3) break; - return mH[2]; - }while(0); - memcpy(mX,x,sizeof(mX)); - - StarMagField::Instance()->BField(mX,mH); - mH[0]*= EC;mH[1]*= EC;mH[2]*= EC; - if (fabs(mH[2]) < 3e-33) mH[2]=3e-33; - return mH[2]; -} -//______________________________________________________________________________ -double StvToolkit::GetHz(const float *x) const -{ double xx[3]={x[0],x[1],x[2]}; - return GetHz(xx); -} -//______________________________________________________________________________ -double StvToolkit::GetHA(const double *x) const -{ - static const Double_t EC = 2.99792458e-4; - double h[3]; - StarMagField::Instance()->BField(x,h); - double ha = (fabs(h[0])+fabs(h[1])+fabs(h[2]))*EC; - return ha; -} -//______________________________________________________________________________ -double StvToolkit::GetHA(const float *x) const -{ double xx[3]={x[0],x[1],x[2]}; - return GetHA(xx); -} -//______________________________________________________________________________ -int StvToolkit::Alive(void *obj) -{ - return FactoryB::Alive(obj); -} diff --git a/StRoot/Stv/StvToolkit.h b/StRoot/Stv/StvToolkit.h deleted file mode 100644 index d46e171c302..00000000000 --- a/StRoot/Stv/StvToolkit.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file StvToolkit.h - */ -#ifndef StvToolkit_H -#define StvToolkit_H 1 - -/** - * @class StvToolkit - * @brief Definition of toolkit - */ -class StvGeoLoader; -class StvHitLoader; -class StvSeedFinder; -class StvSeedFinders; -class StvTrackFinder; -class StvEventFiller; -class StvHit; -class StvHitFactory; -class StvHitRrFactory; -class StvVertexFactory; - -class StvNode; -class StvNodeFactory; - -class StvTrack; -class StvTrackFactory; -class StvTracks; - -class StvELossTrak; -class StvELossTrakFactory; - -class StvToolkit -{ -protected: - StvToolkit(); -public: -void Clear(const char* opt=""); -void Print(const char* opt=""); -void Reset(); - -void Init (); -void Finish(); - -StvGeoLoader *GeoLoader(); -StvHitLoader *HitLoader() const {return mHitLoader ;} -StvSeedFinders *SeedFinders() const {return mSeedFinders;} -StvTrackFinder *TrackFinder() const {return mTrakFinder;} -StvEventFiller *EventFiller() const {return mEventFiller;} -double GetHz(const double *x) const; -double GetHz(const float *x) const; -double GetHA(const double *x) const; -double GetHA(const float *x) const; - -StvTracks &GetTracks(); -void Show() const; - - -// Factories for Stv objects -StvHit *GetHit(); -StvHit *GetHitRr(); -StvHit *GetVertex(); -void FreeHit(StvHit* &stiHit ); -StvNode *GetNode(); -void FreeNode(StvNode* &stiNode); -StvTrack *GetTrack(); -void FreeTrack(StvTrack* &stiTrak); -StvELossTrak *GetELossTrak(); -void FreeELossTrak(StvELossTrak* &stiELossTrak); - - -void SetHitLoader (StvHitLoader *loadHits ){ mHitLoader = loadHits ;} -void SetSeedFinders(StvSeedFinders *seedFinders){ mSeedFinders = seedFinders;} -void SetTrackFinder(StvTrackFinder *trackFinder){ mTrakFinder = trackFinder;} -void SetEventFiller(StvEventFiller *eventFiller){ mEventFiller = eventFiller;} - -public: -static StvToolkit* Inst(); -static int Alive(void *obj); - -protected: -char mBeg[1]; -StvGeoLoader *mGeoLoader; -StvHitLoader *mHitLoader; -StvSeedFinders *mSeedFinders; -StvTrackFinder *mTrakFinder; -StvTracks *mTraks; -StvEventFiller *mEventFiller; -StvHitFactory *mHitFactory; -StvHitRrFactory *mHitRrFactory; -StvNodeFactory *mNodeFactory; -StvTrackFactory *mTrackFactory; -StvELossTrakFactory *mELossTrakFactory; -StvVertexFactory *mVertexFactory; -// Mag field -mutable double mX[3],mH[3]; -char mEnd[1]; - -protected: -static StvToolkit* mgInstance; -}; - -#endif - diff --git a/StRoot/Stv/StvTrack.cxx b/StRoot/Stv/StvTrack.cxx deleted file mode 100644 index b7386a5a06d..00000000000 --- a/StRoot/Stv/StvTrack.cxx +++ /dev/null @@ -1,457 +0,0 @@ -#include -#include -#include -#include -#include - -#include "Stv/StvHit.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "Stv/StvDraw.h" -#include "Stv/StvToolkit.h" -#include "StvUtil/StvKNNUtil.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -int StvTrack::mgId=0; - -//______________________________________________________________________________ -StvTrack::StvTrack() -{ - mId = -1; -} - -//______________________________________________________________________________ -StvTrack::~StvTrack() -{ - unset(); -} -//______________________________________________________________________________ -void StvTrack::reset() -{ - mId = ++mgId; - mPrimary=0; - memset(mBeg,0,mEnd-mBeg+1); - clear(); -} -//______________________________________________________________________________ -void StvTrack::unset() -{ -static StvToolkit *kit = StvToolkit::Inst(); - for (StvNodeIter it = begin();it != end();++it) - { - StvNode *node = *it; - kit->FreeNode(node); - } - clear(); -} -//______________________________________________________________________________ -int StvTrack::GetNPoss(StDetectorId detectorId) const -{ - int n=0; - for (StvNodeConstIter it = begin(); it !=end();++it) { - const StvNode *node = *it; - const StHitPlane *hp = node->GetHitPlane(); - if (!hp) continue; - if (detectorId && hp->GetDetId()!=detectorId) continue; - n++; - } - return n; -} -//______________________________________________________________________________ -int StvTrack::GetNHits(StDetectorId detectorId) const -{ - int n=0; - for (StvNodeConstIter it = begin(); it !=end();++it) { - const StvNode *node = *it; - if (!node->GetHit()) continue; - if (node->GetXi2()>1000) continue; - if (detectorId) { - const StHitPlane *hp = node->GetHitPlane(); - if (!hp) continue; - if (hp->GetDetId()!=detectorId) continue; - } - n++; - } - return n; -} -//______________________________________________________________________________ -int StvTrack::GetNFits(int dir) const -{ - int n=0; - for (StvNodeConstIter it = begin(); it !=end();++it) { - const StvNode *node = *it; - if (node->IsFitted(dir)) n++; - } - return n; -} -//______________________________________________________________________________ -int StvTrack::SetUsed() -{ - int n = 0; - for (StvNodeConstIter it = begin(); it !=end();++it) { - StvNode *node = *it; - StvHit *hit = node->GetHit(); - if (!hit) continue; - if (!hit->detector()) continue; - if (node->GetXi2()<1000 && !hit->isUsed()) { - hit->addTimesUsed();n++; } - else { - node->SetHit(0); - } - } - return n; -} -//______________________________________________________________________________ -int StvTrack::SetUnused() -{ - int n = 0; - for (StvNodeConstIter it = begin(); it !=end();++it) { - StvNode *node = *it; - StvHit *hit = node->GetHit(); - if (!hit) continue; - if (!hit->detector()) continue; - hit->setTimesUsed(0);n++; - if (node->GetXi2()>1000) node->SetHit(0); - } - - return n; -} -//______________________________________________________________________________ -StvNode *StvTrack::GetNode(EPointType noTy) -{ - StvNode *node=0,*foundNode=0;int n=0; - double maxXi2 = 0; - if (noTy!=kLastPoint) { - for (StvNodeIter it = begin();it != end();++it) { - node = *it; n++; - switch(noTy) { - case kDcaPoint: if (n>2) return 0; - if (node->GetType()==StvNode::kDcaNode) {return node;} - break; - - case kPrimPoint: - if (node->GetType()==StvNode::kPrimNode) {return node;} - return 0; - - case kFirstPoint: - if (node->GetType()!=StvNode::kRegNode) break; - if (!node->GetHit()) break; - if ( node->GetXi2()>1000) break; - return node; - case kMaxXi2: - if (node->GetType()!=StvNode::kRegNode) break; - if (!node->GetHit()) break; - if ( node->GetXi2()GetXi2(); break; - - default: assert("Wrong Node type" && 0); - }//end switch - }//end loop - } else { - for (StvBakwNodeIter it = rbegin();it != rend();++it) { - node = *it; n++; - if (node->GetType()!=StvNode::kRegNode) continue; - if (!node->GetHit()) continue; - if ( node->GetXi2()>1000) continue; - return node; - } - }// end if - - return foundNode; - -} -//______________________________________________________________________________ -const StvNode *StvTrack::GetNode(EPointType noTy) const -{ return ((StvTrack*)this)->GetNode(noTy); } -//_____________________________________________________________________________ -double StvTrack::GetLength(EPointType ept) const -{ - const StvNodePars *pre=0; - double len = 0; - for (StvNodeConstIter it = begin();it != end();++it) - { - StvNode *node = *it; - if (!pre) { - StvNode::ENodeType ty = node->GetType(); - if (ty == StvNode::kPrimNode) { - if (ept!=kPrimPoint) continue; - pre = &(node->GetFP(2)); continue; - } - if (ty == StvNode::kDcaNode) { - if (ept!=kDcaPoint) continue; - pre = &(node->GetFP(2)); continue; - } - if (ty != StvNode::kRegNode) continue; - if (node->GetXi2()>1000) continue; - pre = &(node->GetFP(2)); continue; - } - const double *x1 = &pre->_x; - const double *x2 = &node->GetFP(2)._x; - double dlen = sqrt(pow(x1[0]-x2[0],2) + pow(x1[1]-x2[1],2)); - double curv = 0.5*fabs(pre->_curv+node->GetFP(2)._curv); - double dsin = (0.5*dlen*curv); - if (dsin>0.9) dsin=0.9; - dlen = (dsin<0.1)? dlen*(1.+dsin*dsin/6) : 2*asin(dsin)/curv; - len +=sqrt(dlen*dlen + pow(x1[2]-x2[2],2)); - pre = &(node->GetFP(2)); - } - return len; - -} -//_____________________________________________________________________________ -double StvTrack::GetXi2() const -{ - double Xi2 = 0; - int nd=0; - for (StvNodeConstIter it = begin();it != end();++it) - { - const StvNode *node = *it; - if (!node->GetHit()) continue; - if (node->GetXi2()>1000) continue; - nd++; Xi2+=node->GetXi2(); - } - nd = nd*2-5; - - return (nd>0)? Xi2/nd:0; - -} -//_____________________________________________________________________________ -double StvTrack::GetXi2Aux() const -{ - if (!mXi2Aux) mXi2Aux = GetXi2(); - return mXi2Aux; -} -//_____________________________________________________________________________ -double StvTrack::GetXi2P() const -{ - if (!IsPrimary()) return 0; - const StvNode *node = GetNode(kPrimPoint); - assert(node); - double Xi2 = node->GetXi2(); - assert(Xi2<1000.); - return Xi2; -} - -//_____________________________________________________________________________ -void StvTrack::CutTail(const StvNode *start) -{ -static StvToolkit *kit = StvToolkit::Inst(); - if (empty()) return; - if (!start) start = front(); - StvNodeIter tail = begin(); - int kase=0; - for (StvNodeIter it = begin();it != end();++it) - { - StvNode *node = *it; - switch (kase) { - case 0: if (node !=start) break; - kase=1; tail=it; - case 1: node->SetHit(0); - kit->FreeNode(node); - } - } - assert(kase); - erase(tail,end()); -} -//_____________________________________________________________________________ -void StvTrack::CutEnds() -{ -static StvToolkit *kit = StvToolkit::Inst(); - StvNodeIter it =begin(); - int nDel=0; - for (; it != end();++it) - { - StvNode *node = *it; - if (node->GetHit()) break; - nDel ++;kit->FreeNode(node); - } - if (nDel) {erase(begin(),it);} - - it = end(); --it; - nDel=0; - for (; it !=begin();--it) - { - StvNode *node = *it; - if (node->GetHit()) break; - nDel ++; kit->FreeNode(node); - } - if (nDel) { ++it; erase(it,end());} -} -//_____________________________________________________________________________ -double StvTrack::GetRes() const -{ - int nRes=0; double res = 0; - for (StvNodeConstIter it=begin();it!=end(); ++it) { - StvNode *node = *it; - const StvHit *hit= node->GetHit(); - if (!hit) continue; - TVector3 dif,dir; - const StvNodePars &fp = node->GetFP(); - for (int i=0;i<3;i++) { dif[i]=fp.P[i]-hit->x()[i];} - dir[0]= fp._cosCA; - dir[1]= fp._sinCA; - dir[2]= fp._tanl; - dir = dir.Unit(); - res += (dif.Cross(dir)).Mag(); nRes++; - } - return (nRes)? res/nRes:0.; -} - - -//_____________________________________________________________________________ -void StvTrack::Show() const -{ -StvHits showHits; -StvPoints showTrak; - for (StvNodeConstIter it = begin();it != end();++it) - { - const StvNode *node = *it; - const StvHit *hit = node->GetHit(); - showTrak += node->GetFP().P; - if (hit) showHits+=(StvHit*)hit; - } - StvDraw::Inst()->Trak(showTrak,kGlobalTrack); - StvDraw::Inst()->Hits(showHits,kUsedHit ); -} -//_____________________________________________________________________________ -int StvTrack::Check(const char *tit, int dirs) const -{ -if (!tit) tit = ""; - int n = -1,nerr=0; - for (StvNodeConstIter it = begin();it != end();++it) - { - n++; - const StvNode *node = *it; - TString ts; - if (tit[0]) {ts = tit; ts+="#"; ts+=n; - char mybuf[40]={0}; sprintf(mybuf," node=%p ",(void*)node); - ts+=mybuf; - } - int fail = node->Check(ts,dirs); - if (fail) nerr++; - } - return nerr; -} -//_____________________________________________________________________________ -void StvTrack::Print(const char *opt) const -{ - if (!opt) opt = ""; - printf("Track %p\n",(void*)this); - - int n=0; - for (StvNodeConstIter it=begin();it!=end();++it) { - const StvNode *node = (*it); -// const StvHit *hit = node->GetHit(); -// if (!hit && strchr(opt,'H')) continue; - n++;printf("%3d - ",n); - node->Print(opt); - } -} -//_____________________________________________________________________________ -double StvTrack::ToBeam() const -{ - const StvNode *node = GetNode(kDcaPoint); - if (!node) return 3e33; - return node->GetFP().getRxy(); -} -//_____________________________________________________________________________ -int StvTrack::GetCharge() const -{ - const StvNode *node = front(); - return node->GetFP().getCharge(); -} -//_____________________________________________________________________________ -void StvTrack::Reverse() -{ reverse(); } -//______________________________________________________________________________ -double StvTrack::GetXi2W() const -{ - if (mXi2W>0) return mXi2W; - mXi2W = 0; - for (auto it = begin();it != end();++it) - { - auto *node = *it; - if (node->GetType()!=StvNode::kRegNode) continue; - if (!(node->GetHit())) continue; - double Xi2 = node->GetXi2(); - if ( Xi2>1000) continue; - if ( Xi2 < mXi2W) continue; - mXi2W = Xi2; - } - return mXi2W; -} -//_____________________________________________________________________________ -StvTrack &StvTrack::operator=(const StvTrack &from) -{ -static StvToolkit *kit = StvToolkit::Inst(); - for (auto it = begin();it != end();++it) - { - StvNode *node = *it; kit->FreeNode(node); - } - clear(); - memcpy(mBeg,from.mBeg,mEnd-mBeg+1); - for (StvNodeConstIter it=from.begin();it!=from.end();++it) { - const StvNode *node = (*it); - StvNode *myNode = kit->GetNode(); - *myNode = *node; push_back(myNode); - } - return *this; -} -//______________________________________________________________________________ -StvNode *StvTrack::GetMaxKnnNode() -{ - StvNode *node=0;int n=0; - float var[2]; - const StvHit *hit=0; - StvKNNUtil knn(2,5); - for (StvNodeIter it = begin();it != end();++it) - { - node = *it; n++; - if (node->GetType()!=StvNode::kRegNode) continue; - if (!(hit=node->GetHit())) continue; - if ( node->GetXi2()>1000) continue; - const StvNodePars &par = node->GetFP(); - const double cosL = par.getCosL(); - const float *fx = hit->x(); - var[1] = (fx[2]-par._z)*cosL; - var[0] = ((fx[0]-par._x)*(-par._sinCA)+(fx[1]-par._y)*(par._cosCA)); - knn.Add((ULong_t)node,var); - } - knn.GetWost((ULong_t*)&node); - return node; -} -#include "StarRoot/TIdTruUtil.h" -#include "StEvent/StRnDHit.h" -//_____________________________________________________________________________ -double StvTrack::GetQua() const -{ - - TIdTruUtil idt; - const StvHit *hit=0; - - for (StvNodeConstIter it = begin();it != end();++it) - { - StvNode *node = *it; - if (node->GetType()!=StvNode::kRegNode) continue; - if (!(hit=node->GetHit())) continue; - if ( node->GetXi2()>1000) continue; - int idTru = hit->idTru(); -#ifdef kFtsIdentifier - if (!idTru && hit->detectorId()==kFtsId) { - auto *rndHit = (StRnDHit*)hit->stHit(); - int id0 = rndHit->extraByte0(); - int id1 = rndHit->extraByte1(); - assert (id0 && id1); - idt.Add(id0,50); - idt.Add(id1,50); - continue; - } -#endif - idt.Add(idTru); - } - if (!idt.GetIdTru()) return 0; - return idt.GetQua(); - -} - - - diff --git a/StRoot/Stv/StvTrack.h b/StRoot/Stv/StvTrack.h deleted file mode 100644 index fd526cd02cd..00000000000 --- a/StRoot/Stv/StvTrack.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * \file StvTrack.h - * \brief Definition StvTrack - * - */ -#ifndef StvTrack_H -#define StvTrack_H 1 - -#include "StEvent/StEnumerations.h" -#include "Stv/StvStl.h" - -class StvHit; -class StvTrack: public StvNodes -{ - public: - enum EPointType {kDcaPoint,kFirstPoint,kLastPoint,kPrimPoint,kMaxXi2}; - public: - StvTrack(); - StvTrack &operator=(const StvTrack &from); - StvTrack(const StvTrack &from) {*this=from;} - -/// Destructor - virtual ~StvTrack(); - void reset(); - void unset(); - - /// Set Type of End tracking - void SetTypeEnd (int tyEnd) {mTypeEnd = tyEnd;} - - /// returns node related ipt 0=DCA node, 1=1st point. 2=last point, 3=Primary vertex - StvNode *GetNode(EPointType poTy); -const StvNode *GetNode(EPointType poTy) const; - /// Returns node with biggest KNN distance - StvNode *GetMaxKnnNode() ; - /// Returns the number of hits associated and used in the fit of this track. - int GetNHits(StDetectorId detectorId=kUnknownId) const; - /// Return the number of possible hits with this track. - int GetNPoss(StDetectorId detectorId=kUnknownId) const; - /// Returns the number of fits associated direction.0=OutIn,1=InOut,2=Joined - int GetNFits(int dir) const; - - /// Returns the End Type i.e reason of the end of tracking - /// 0=Dca,1 = too many continues nits,2 = too many total nits - int GetTypeEnd () const {return mTypeEnd;} - - /// Returns the quality of track for montecarlo case -double GetQua() const; - - /// Delete all the nodes started form given - void CutTail(const StvNode *start=0); - - /// Delete all the hitless nodes a the the begining and at the end - void CutEnds(); - - /*! - Returns the track length (in centimeters) from the : - - first point (kFirstPoint) default; - - DCA point (kDcaPoint) ; - - Primary vertex (kPrimPoint) ; - to the last point on track. - */ - double GetLength(EPointType ept=kFirstPoint) const; - int GetCharge() const; - - void Reverse(); // Inverese node order. For debug only -double GetXi2() const; // chi2/ndf of fit, all nodes -double GetXi2P() const; // chi2 of fit to primary vertex -double GetXi2W() const; // chi2 of the worst node -double GetRes() const; // Average residual -double GetXi2Aux() const; // chi2/ndf of fit, special version or track ordering all nodes - - void SetFlag(int flag) {mFlag = flag;} - int GetFlag() const {return mFlag;} - int GetId() const {return mId ;} - void AddId(int info) {mId+=1000000*info;} - - void SetPrimary(int iprim) {mPrimary = iprim;} - int IsPrimary() const {return mPrimary ;} - void Print(const char *opt) const; - - int SetUsed(); - int SetUnused(); - - double ToBeam() const; - int Check(const char *tit="",int dirs=3) const; - void Show() const; - -protected: -unsigned char mBeg[1]; -unsigned char mPrimary; -unsigned char mTypeEnd; // Type of end tracking. 0=Dca, - int mFlag; -mutable float mXi2W; -mutable float mXi2Aux; -unsigned char mEnd[1]; -unsigned int mId; -public: -static int mDebug; // Debug level -static int mgId; // static track counter - -}; - -#endif - diff --git a/StRoot/Stv/StvTrackFinder.cxx b/StRoot/Stv/StvTrackFinder.cxx deleted file mode 100644 index c1345cf092f..00000000000 --- a/StRoot/Stv/StvTrackFinder.cxx +++ /dev/null @@ -1,49 +0,0 @@ -#include "StvTrackFinder.h" -#include "TSystem.h" -#include "StvDraw.h" -#include "vector" -ClassImp(StvTrackFinder) -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StvTrackFinder::~StvTrackFinder() -{ DoShow(0); -} -//_____________________________________________________________________________ -void StvTrackFinder::Show() -{ - if (!fDraw) return; - if(fShowTrak.size())fDraw->Trak(fShowTrak,kGlobalTrack); -//if(fShowTrak.size())fDraw->Line(fShowTrak,kGlobalTrack); - if(fShowTrakHits.size() )fDraw->Hits(fShowTrakHits ,kUsedHit ); - if(fShowFreeHits.size() )fDraw->Hits(fShowFreeHits ,kUnusedHit); - fShowTrak.clear();fShowTrakHits.clear();fShowFreeHits.clear(); - fDraw->UpdateModified(); -// fDraw->SetDrawOption("{view:all}"); - fDraw->ProcessEvents(); -} -//_____________________________________________________________________________ -StvDraw *StvTrackFinder::NewDraw() -{ - StvDraw *dr = new StvDraw(); - dr->SetBkColor(kWhite); -// dr->Style(kUsedHit).Siz() *=2; - dr->Style(kUnusedHit).Siz()*=20; - return dr; -} -//_____________________________________________________________________________ -void StvTrackFinder::DoShow(int lev) -{ - if (fDoShow == lev) return; - fDoShow = lev; - if (fDoShow) {if (!fDraw) fDraw=NewDraw();} - else { delete fDraw;fDraw=0 ;fShowTrak.clear(); - fShowTrakHits.clear();fShowFreeHits.clear();} -} -//_____________________________________________________________________________ -void StvTrackFinder::Clear(const char*) -{ -// if (fDraw) fDraw->Clear(); -// fShowTrak.clear(); -// fShowTrakHits.clear(); -// fShowFreeHits.clear(); -} diff --git a/StRoot/Stv/StvTrackFinder.h b/StRoot/Stv/StvTrackFinder.h deleted file mode 100644 index f7f26cd2161..00000000000 --- a/StRoot/Stv/StvTrackFinder.h +++ /dev/null @@ -1,50 +0,0 @@ -/// \File StvTrackFinder.h -/// \author Victor Perev 01/2010 -#ifndef StvTrackFinder_HH -#define StvTrackFinder_HH -#include "StvStl.h" -#include "TNamed.h" - -/// \class StvTrackFinder -class StvHit; -class StvDraw; -class StvPoints; -class StvHits; -class StvKonst_st; -class StvTrackFitter; -class StvTrackFinder : public TNamed -{ -public: - StvTrackFinder(const char *name):TNamed(name,""){fDraw=0;fDoShow=0;mRefit=1;} - virtual ~StvTrackFinder(); - virtual int FindTracks() =0; - virtual int FindPrimaries(const StvHits &vtxs) =0; - virtual void Reset() =0; - virtual void Clear(const char *opt=""); - virtual void SetCons(const StvKonst_st*)=0; - virtual void SetFitter(StvTrackFitter *fitter){mTrackFitter = fitter;} - void AddPoint(const double pt[3]); - void AddHits(const double pt[3]); - virtual StvNode *MakeDcaNode(StvTrack *tk)=0; - void Show(); - void DoShow(int lev); - int DoShow() const {return fDoShow;}; - void SetRefit(int r=1) {mRefit = r;} - -protected: -static StvDraw *NewDraw(); -protected: -StvTrackFitter *mTrackFitter; -int mRefit; //refit flag -int fDoShow; -StvDraw *fDraw; -StvPoints fShowTrak; -StvHits fShowTrakHits; -StvHits fShowFreeHits; -private: - -ClassDef(StvTrackFinder,0); -}; - - -#endif diff --git a/StRoot/Stv/StvTrackFitter.cxx b/StRoot/Stv/StvTrackFitter.cxx deleted file mode 100644 index fc08f3d7a2d..00000000000 --- a/StRoot/Stv/StvTrackFitter.cxx +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include "StvTrackFitter.h" -ClassImp(StvTrackFitter) -//______________________________________________________________________________ -StvTrackFitter::StvTrackFitter(const char *name):TNamed(name,"") -{ - Clear(); -} -//______________________________________________________________________________ -StvTrackFitter::~StvTrackFitter() -{;} - -//______________________________________________________________________________ -void StvTrackFitter::Clear(const char *) -{ - memset(mBeg,0,mEnd-mBeg+1); - mXi2=3e33; -} diff --git a/StRoot/Stv/StvTrackFitter.h b/StRoot/Stv/StvTrackFitter.h deleted file mode 100644 index f268319f909..00000000000 --- a/StRoot/Stv/StvTrackFitter.h +++ /dev/null @@ -1,51 +0,0 @@ -/// \File StvTrackFitter.h -/// \author Victor Perev 9/2010 -#ifndef StvTrackFitter_HH -#define StvTrackFitter_HH -#include "TNamed.h" - -/// \class StvTrackFitter -class THelixTrack; -class StvTrack; -class StvNode; -class StvHit; -class StvNodePars; -class StvFitErrs; -class StvKonst_st; -class StvTrackFitter : public TNamed -{ -public: - StvTrackFitter(const char *name); - virtual ~StvTrackFitter(); - virtual void SetCons(const StvKonst_st*)=0; - virtual int Refit(StvTrack *trak,int dir)=0; - virtual int Refit(StvTrack *trak,int dir,int lane, int mode=1)=0; - virtual void Clear(const char *opt=""); - virtual int Fit(const StvTrack *trak,const StvHit *vtx,StvNode *node)=0; - virtual int Helix(StvTrack *trak,int mode)=0; - virtual int Check(StvTrack *trak) {return 0;} - virtual int Check(const StvNodePars &parA,const StvFitErrs &errA, - const StvNodePars &parB,const StvFitErrs &errB) {return 0;} - virtual int Clean(StvTrack *trak)=0; - virtual THelixTrack* GetHelix() const {return 0;} - int GetNDF() const {return mNDF ;} - double GetDca3() const {return mDca3;} - double GetXi2() const {return mXi2 ;} - int Failed() const {return mFailed;} - int& NHits() {return mNHits;} - -protected: -char mBeg[1]; -char mFailed; -int mNHits; -int mNDF; -double mXi2; -double mDca3; -char mEnd[1]; -private: - -ClassDef(StvTrackFitter,0); -}; - - -#endif diff --git a/StRoot/Stv/StvVertexFinder.cxx b/StRoot/Stv/StvVertexFinder.cxx deleted file mode 100644 index 0ed3035340e..00000000000 --- a/StRoot/Stv/StvVertexFinder.cxx +++ /dev/null @@ -1,35 +0,0 @@ -#include "Stiostream.h" -#include "StvVertexFinder.h" -#include "Stv/StvHit.h" -#include "StvToolkit.h" - -//______________________________________________________________________________ -StvVertexFinder::StvVertexFinder(const char* name): TNamed(name,"") -{ - mResulted=0; - cout <<"StvVertexFinder::StvVertexFinder() -I- Started :" << name<GetVertex(); - for (int j=0;j<9;j++) {Xf[j]=Xd[j];} - hit->set(Xf,Xf+3); - mResult.push_back(hit);} - return mResult; -} diff --git a/StRoot/Stv/StvVertexFinder.h b/StRoot/Stv/StvVertexFinder.h deleted file mode 100755 index 2489a171320..00000000000 --- a/StRoot/Stv/StvVertexFinder.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef StvVertexFinder_H -#define StvVertexFinder_H 1 -#include -#include -#include "StvStl.h" - -class StEvent; -class StvHit; -class StvKonst_st; - -/*! -An abstract class defining the interface to the vertex finder. -*/ -class StvVertexFinder : public TNamed -{ -public: - StvVertexFinder(const char* name); - virtual ~StvVertexFinder(); - /// Find the vertex(es) associated with the given event - virtual int Fit(StEvent*)=0; // fit the vertex - virtual int GetVertex(int index,double xyz[3],double err[6]) =0; - virtual void Clear(const char * opt=0); - void SetCons(const StvKonst_st *kons){mKons = kons;} - -const StvHits &Result(); - -protected: - StvVertexFinder();//not implemented - const StvKonst_st *mKons; - int mResulted; - StvHits mResult; -}; - -#endif diff --git a/StRoot/Stv/mytags.txt b/StRoot/Stv/mytags.txt deleted file mode 100644 index 19036c886d1..00000000000 --- a/StRoot/Stv/mytags.txt +++ /dev/null @@ -1,5 +0,0 @@ -Fri Oct 27. Tag = StvKutta_1_00 -This version is full but still efficiency significantly les than Tag Stv1_01 -The last was done THelixTrack errs ==> Thelix3d ones fixed and tested - -============================================================================ diff --git a/StRoot/StvMaker/StvEventFiller.h b/StRoot/StvMaker/StvEventFiller.h deleted file mode 100755 index e32c3ef344f..00000000000 --- a/StRoot/StvMaker/StvEventFiller.h +++ /dev/null @@ -1,36 +0,0 @@ -//StvEventFiller.h -/*************************************************************************** - * - * $Id: StvEventFiller.h,v 1.4 2015/11/11 01:51:04 perev Exp $ - * It is base class for Transfer internal Stv structures into - * current experiment ones - * Author: Victor Perev, Jun 2010 - * - *************************************************************************** - */ -#ifndef StvEventFiller_HH -#define StvEventFiller_HH - -class StEvent; -class StvKonst_st; -class StvEventFiller -{ -public: - StvEventFiller(){mEvent=0;mTracks=0;mPullEvent=0;} - virtual ~StvEventFiller(){;} - void Set(StEvent* e,StvTracks* tk) { mEvent=e; mTracks = tk;} - void Set(StvPullEvent* pull) { mPullEvent=pull;} - virtual void fillEvent()=0; -virtual void fillEventPrimaries()=0; - void SetCons(const StvKonst_st *kons); -protected: - int mMinHits; - int mNorHits; - int mGoodHits; - StEvent* mEvent; - StvTracks* mTracks; - StvPullEvent* mPullEvent; - -}; - -#endif diff --git a/StRoot/StvMaker/StvFtsHitLoader.cxx.C b/StRoot/StvMaker/StvFtsHitLoader.cxx.C deleted file mode 100644 index 453049bf442..00000000000 --- a/StRoot/StvMaker/StvFtsHitLoader.cxx.C +++ /dev/null @@ -1,59 +0,0 @@ -// $Id: StvFtsHitLoader.cxx.C,v 1.1 2016/11/29 16:58:51 perev Exp $ -/*! -\author V Perev 2015 - -A StvFtsHitLoader loads Stv hits using StFtsHits. - - */ -#include "StEvent/StEnumerations.h" -#include "StvFtsHitLoader.h" -#include "StEvent/StFtsHit.h" -#include "Stv/StvHit.h" -#include "Stv/StvToolkit.h" -#include "TCernLib.h" - -static const double kFtsAccu = 0.9; - -ClassImp(StvFtsHitLoader) -//_____________________________________________________________________________ -int StvFtsHitLoader::MakeStvHit(const StHit *stHit,UInt_t upath, int &sure - ,StvHit *stvHit) -{ - int num = 0; -#ifdef kFtsIdentifier -static StvToolkit *kit = StvToolkit::Inst(); - auto detId = stHit->detector(); - if (detId != kFtsId) return StvHitLoader::MakeStvHit(stHit,upath,sure,stvHit); - assert(!stvHit); - - StThreeVectorF dRdPdZ = stHit->positionError(); - StThreeVectorF fx = stHit->position(); - double Rxy = sqrt(fx[0]*fx[0]+fx[1]*fx[1]); - double dRxy = dRdPdZ[0]*sqrt(12.); - double dPhi = dRdPdZ[1]*sqrt(12.); - - int nStp = dRxy/kFtsAccu+1; - double stp = dRxy/nStp; - double r = Rxy+0.5*(-dRxy+stp); - StFtsHit hit(*(StFtsHit*)stHit); - for (int iStp=0;iStpGetHitRr(); - int ans = StvHitLoader::MakeStvHit(&hit,upath,sure,stvHit); - stvHit->setStHit(stHit); - if (!ans) continue; - num += ans; - double cFi = fx[0]/Rxy,sFi = fx[1]/Rxy; - double T[2][2]= {{cFi,-fx[1]},{sFi,+fx[0]}}; - double gRFi[3] = {stp*stp/12,0,dPhi*dPhi/12}; - double gMtx[3]; - TCL::trasat(T[0],gRFi,gMtx,2,2); - float *e = stvHit->errMtx(); - memset(e+3,0,sizeof(e[0])*3); - TCL::ucopy(gMtx,e,3); e[3]=0; e[4]= 0; - e[5] = dRdPdZ[2]*dRdPdZ[2]; - } -#endif - return num; -} diff --git a/StRoot/StvMaker/StvFtsHitLoader.h.C b/StRoot/StvMaker/StvFtsHitLoader.h.C deleted file mode 100644 index 99e063c2fbf..00000000000 --- a/StRoot/StvMaker/StvFtsHitLoader.h.C +++ /dev/null @@ -1,20 +0,0 @@ -//StvFtsHitLoader.h - -#ifndef StvFtsHitLoader_HH -#define StvFtsHitLoader_HH -#include "StvHitLoader.h" - -class StvFtsHitLoader : public StvHitLoader - -{ - public: - - StvFtsHitLoader(const char* name = "StFtsHitsLoader"):StvHitLoader(name){} - virtual ~StvFtsHitLoader(){;} - protected: - int MakeStvHit(const StHit *stHit,UInt_t upath,int &sure,StvHit *stvHit=0); - private: - ClassDef(StvFtsHitLoader,0) -}; - -#endif diff --git a/StRoot/StvMaker/StvHitLoader.cxx b/StRoot/StvMaker/StvHitLoader.cxx deleted file mode 100644 index 8ee60466db8..00000000000 --- a/StRoot/StvMaker/StvHitLoader.cxx +++ /dev/null @@ -1,354 +0,0 @@ -// $Id: StvHitLoader.cxx,v 1.33 2017/01/19 16:56:01 perev Exp $ -/*! -\author V Perev 2010 - -A StvHitLoader loads Stv hits. -
-Main tasks: -

    -
  • Loop over StHits; -
  • Make & fill according StvHits; -
  • Fill StTGeoHelpr containers by StvHits; -
- - -*/ -#include -#include -#include -#include "TGeoManager.h" -#include "TCernLib.h" -#include "StEvent/StRnDHit.h" //???TempoHack??? -#include "StvHitLoader.h" -#include "StvStEventHitSelector.h" -#include "Stv/StvHit.h" -#include "Stv/StvToolkit.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StEvent.h" -#include "StHit.h" -#include "StEventUtilities/StEventHelper.h" -#include "StEventUtilities/StEventHitIter.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvDraw.h" -#include "Stv/StvStl.h" -#include "StvStEventHitSelector.h" -#include "Stv/StvToolkit.h" -ClassImp(StvHitLoader) - -StMatrixF Hack1to6(const StHit *stHit); - -//_____________________________________________________________________________ -StvHitLoader::StvHitLoader(const char *name) : TNamed(name,"") - -{ - mHitIter = new StEventHitIter(); - mHitSelector = 0; mHitLoadActor = 0; mNDets = 0; - memset(mMaxTimes,0,sizeof(mMaxTimes)); -} - -//_____________________________________________________________________________ -StvHitLoader::~StvHitLoader() -{ - delete mHitIter; -} - -//_____________________________________________________________________________ -void StvHitLoader::Clear(const char*) -{ - StTGeoProxy::Inst()->ClearHits(); -} - -//_____________________________________________________________________________ -Int_t StvHitLoader::Finish() -{ - return 0; -} - -//_____________________________________________________________________________ -Int_t StvHitLoader::Init() -{ - mNDets=0; - for (int id=1; idIsActive((StDetectorId)id)) continue; - mHitIter->AddDetector((StDetectorId)id); - mNDets++; - } - return mNDets; -} -//_____________________________________________________________________________ -int StvHitLoader::AddDetector(StDetectorId did) -{ - if (!StTGeoProxy::Inst()->IsActive((StDetectorId)did)) { - Warning("AddDetector","DetectorId=%d not active, ignored",(int)did); - return 13; - } - mHitIter->AddDetector((StDetectorId)did); - mNDets++; - return 0; -} -void StvHitLoader::SetHitSelector() -{ - mHitSelector = new StvStEventHitSelector; -} - -//_____________________________________________________________________________ -int StvHitLoader::LoadHits(const StEvent *stev) -{ -enum {kFCF_CHOPPED=256 // 0x100 cluster is chopped from its neighbour: OFFLINE use only - ,kFCF_SANITY =512}; // 0x200 cluster extents not sane -static int nCall=0; nCall++; -static int myGraph=0; -static StTGeoProxy* tgp = StTGeoProxy::Inst(); - tgp->SetHitLoadActor(mHitLoadActor); - -StvDraw *myDraw=0; -StvHits *myHits=0; -if (myGraph) { //create canvas - myDraw = new StvDraw(); - myHits = new StvHits; - if (myHits) {/*noopt*/} -} - mHitIter->Reset(stev); - int nSel = (mHitSelector)? mHitSelector->Edit(stev):-1; - if (!nSel) return 0; - const StHit *stHit=0; - StDetectorId didOld = kUnknownId; - int nTotHits = 0,nTotHitz=0,nTotGits=0, nHits=0,nHitz=0,nGits=0; - - for (; ; ++(*mHitIter)) { - stHit=*(*mHitIter); -// If hit selector is ON and hit is not marked, ignore it - StDetectorId did = mHitIter->DetectorId(); - - if (did != didOld || !stHit) { - if (didOld) { - Info("LoadHits","Loaded %d good, recovered %d and failed %d %s hits" - ,nHits,nHits-nGits,nHitz,StTGeoProxy::DetName(didOld)); - } - didOld = did; - - if (!stHit) break; - Info("LoadHits","Start %s hits",StTGeoProxy::DetName(did)); - if (mHitLoadActor) mHitLoadActor->SetDetId(did); - nHits=0; nHitz=0,nGits=0; - } - if (nSel> 0 && (!stHit->TestBit(StvStEventHitSelector::kMarked))) continue; // ignore not selected hit - if (stHit->flag() & kFCF_CHOPPED || stHit->flag() & kFCF_SANITY) continue; // ignore hits marked by AfterBurner as chopped o - mDetId = did; - int sure=0; - int nStvHits = MakeStvHit(stHit,mHitIter->UPath(),sure); -// if (!sure && mStvHit) { //Non reliable hit -// double rxy = sqrt(pow(mStvHit->x()[0],2)+pow(mStvHit->x()[1],2)); -// StvDebug::Count("OrphanHits",mStvHit->x()[2],rxy); -// } - - if (nStvHits) { - nHits+=nStvHits;nTotHits+=nStvHits;nGits+=sure;nTotGits+=sure; - if (mMaxTimes[mDetId]>1) mStvHit->setMaxTimes(mMaxTimes[mDetId]); - } - else {nHitz++;nTotHitz++;} - } - int nIniHits = tgp->InitHits(); - assert(nTotHits==nIniHits); - Info("LoadHits","Loaded %d good, recovered %d and failed %d of all hits" - ,nTotHits,nTotHits-nTotGits,nTotHitz); - return nTotHits; -} - -//_____________________________________________________________________________ -int StvHitLoader::MakeStvHit(const StHit *stHit,UInt_t upath, int &sure) -{ -static StTGeoProxy *tgh = StTGeoProxy::Inst(); -static StvToolkit *kit = StvToolkit::Inst(); - assert(stHit); - mStvHit = 0; - // StDetectorId did = stHit->detector(); - StDetectorId did = mDetId; - if (!did) { -static int knt=0;knt++; - printf("StvHitLoader::MakeStvHit(%d) No DETID***\n",knt); - return 0; - } - assert(did); - do { //May be errors exists - if (did==kTpcId) break; - StMatrixF errF(3,3); - int layer = -1; - do { - if (did != kFtsId) break; - layer = ((StRnDHit*)stHit)->layer(); - if (layer>6) break; - errF = Hack1to6(stHit); - } while(0); - if (errF[0][0]<=0) { - errF = stHit->covariantMatrix(); - } - assert(did!=kFtsId || errF[0][0]>1e-8); - if (errF[0][0]+errF[1][1]+errF[2][2]<1e-8) break; - assert(fabs(errF[0][1]-errF[1][0])<1e-8); - assert(fabs(errF[0][2]-errF[2][0])<1e-8); - assert(fabs(errF[1][2]-errF[2][1])<1e-8); - mStvHit = kit->GetHitRr(); - if (layer>6) mStvHit->SetCombo(1); - float *e = mStvHit->errMtx(); - for (int i=0,li=0;i< 3;li+=++i) { - for (int j=0;j<=i;j++) { e[li+j] = errF[i][j];}} - assert(e[0]>1e-8 && e[0]<64); - assert(e[0]*e[2]> e[1]*e[1] ); - assert(e[2]>1e-8 && e[2]<64); - assert(e[2]*e[5]>=e[4]*e[4] ); - assert(e[5]>= 0 && e[5]<64); - assert(e[0]*e[5]>=e[3]*e[3] ); - } while(0); - - if (!mStvHit) mStvHit= kit->GetHit(); - - int idTru = stHit->idTruth(); - if (idTru<0 && idTru>10000) idTru=0; - UInt_t hard = stHit->hardwarePosition(); - if (!hard) hard = upath; - StThreeVectorF v3f = stHit->position(); - const float *xyz = v3f.xyz(); - mStvHit->set(stHit,xyz); - mStvHit->setIdTru(idTru); - int seed = 1; - if (did == kTpcId) { // Special case for TPCHit. Prompt info added -// enum {zPrompt = 205,rMiddle=124}; - enum {zPrompt = 205,rMiddle=0}; - hard <<=1; hard |= (fabs(xyz[2]) > zPrompt); - if (xyz[0]*xyz[0]+xyz[1]*xyz[1] >rMiddle*rMiddle) seed = 1; - } else { -// the hits outside and with small mag field not for seed - const float* x = mStvHit->x(); - assert(fabs(x[0])+fabs(x[1])>1); - if (fabs(x[2])>250) { - static StvToolkit *tk = StvToolkit::Inst(); - if (tk->GetHA(x)<1./1000) seed = 0; - } } -//VP if (mStvHit->IsCombo()) seed = 0; - hard *= (unsigned int)kMaxDetectorId; hard+=(unsigned int)did; - - const StHitPlane *hp = tgh->AddHit(mStvHit,mDetId,xyz,hard,seed); - sure = tgh->IsGoodHit(); - if (!hp) { StvToolkit::Inst()->FreeHit(mStvHit); mStvHit = 0; return 0;} - - if (did == kTpcId && fabs(xyz[2])<200) {// TPC hit check for being in sector - const float* org = hp->GetOrg(xyz); - const float* ort = (fabs(org[2])<209)? hp->GetDir(xyz)[0]:hp->GetDir(xyz)[2]; - double art = atan2(ort[1],ort[0])*180/M_PI; - double arg = atan2(org[1],org[0])*180/M_PI; - assert(fabs(art-arg)<1.e-3); - - double dang = (atan2(ort[1],ort[0])-atan2(xyz[1],xyz[0]))*57.3; - if (dang> 180) dang-=360; - if (dang<-180) dang+=360; - if (fabs(dang)>17) printf("dang = %g\n",dang); - assert(fabs(dang)<31); - } - mStvHit->set(hp); - -#if 0 -static int nnn=0;nnn++; -printf("%d *** StvHitLoader::MakeStvHit %g %g %g ***\n",nnn - ,mStvHit->x()[0],mStvHit->x()[1],mStvHit->x()[2]); -StvDebug::Count("ZHits",mStvHit->x()[2]); -StvDebug::Count("XYHits",mStvHit->x()[1],mStvHit->x()[1]); -StvDebug::Count("ZXHits",mStvHit->x()[2],mStvHit->x()[0]); -StvDebug::Count("ZYHits",mStvHit->x()[2],mStvHit->x()[1]); -#endif - return 1; -} - -//_____________________________________________________________________________ -int StvHitLoader::TpcHitTest(const StHit *stHit) -{ - enum {nbpads = 73,maxpads=100}; - int tpads[maxpads] = { 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, - 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, - 7, 8, 8, 8, 9, 9, 9,10,10,10, - 11,11,11,12,12,12,13,13,13,14, - 14,15,16,17,18,19,20,21,22,23, - 24,25,26,27,28,29,30,31,32,33, - 34,35,36,37,38,39,40,41,42,43, - 44,45,45}; - - int isdets[maxpads] = { 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, - 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, - 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, - 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2}; - - - StThreeVectorF v3f = stHit->position(); - TGeoNode *node = gGeoManager->FindNode(v3f[0],v3f[1],v3f[2]); - assert(node); - if (strncmp("TPA",node->GetName(),3)) return -1; - int numbv[3]; - for (int i=0;i<3;i++) { - node = gGeoManager->GetMother(i); - numbv[2-i] = node->GetNumber(); - } -//int tpgv = numbv[0]; -//int tpss = numbv[1]; -//int sector= tpss+12*(tpgv-1) ; - int tpad = numbv[2]; - int isdet = 0; - - if (tpad > nbpads) tpad -= nbpads; - isdet = isdets[tpad-1]; - tpad = tpads [tpad-1]; - if (isdet) { - Warning("TpcHitTest","TpcHit(%g,%g,%g) isdet=%d WRONG WRONG WRONG" - ,v3f[0],v3f[1],v3f[2], isdet); - } - return isdet; -} -//_____________________________________________________________________________ -void StvHitLoader::SetMaxTimes(int maxTimes,const char *detector) -{ - StDetectorId id = kUnknownId; - if (detector[0]!='*') { - id = detectorIdByName(detector); - assert(id); - } - SetMaxTimes(maxTimes,id); -} -//_____________________________________________________________________________ -void StvHitLoader::SetMaxTimes(int maxTimes,StDetectorId id) -{ - if (id) {mMaxTimes[id] = maxTimes; return; } - for (int i=1;i<=kMaxDetectorId;i++) { mMaxTimes[i]=maxTimes;} -} - -//_____________________________________________________________________________ -StMatrixF Hack1to6(const StHit *stHit) -{ -// X = R*cos(Fi), Y=R*sin(Fi), Z = z -// dX/dR = ( cos(Fi) ,sin(Fi),0) -// dX/dFi = (-R*sin(Fi), R*cos(Fi),0) -// dX/dZ = ( 0, 0,1) - - auto hiPos = stHit->position(); - auto hiErr = stHit->positionError(); - double Rxy = sqrt(hiPos[0]*hiPos[0]+hiPos[1]*hiPos[1]); - double cosFi = hiPos[0]/Rxy; - double sinFi = hiPos[1]/Rxy; - double T[3][3] = {{cosFi,-Rxy*sinFi,0} - ,{sinFi, Rxy*cosFi,0} - ,{ 0, 0,1}}; - double Ginp[6] = { hiErr[0]*hiErr[0] - , 0,hiErr[1]*hiErr[1] - , 0, 0,hiErr[2]*hiErr[2]}; - double Gout[6]; - - TCL::trasat(T[0],Ginp,Gout,3,3); - StMatrixF mtxF(3,3); - - for (int i=0,li=0;i< 3;li+=++i) { - for (int j=0;j<=i;j++) {mtxF[i][j] = Gout[li+j]; mtxF[j][i] = mtxF[i][j];}} - - return mtxF; -} diff --git a/StRoot/StvMaker/StvHitLoader.h b/StRoot/StvMaker/StvHitLoader.h deleted file mode 100644 index 6646910f499..00000000000 --- a/StRoot/StvMaker/StvHitLoader.h +++ /dev/null @@ -1,49 +0,0 @@ -//StvHitLoader.h - -#ifndef StvHitLoader_HH -#define StvHitLoader_HH - -#include - -#include "TNamed.h" -#include "StEvent/StEnumerations.h" - - -class StEvent; -class StHit; -class StvHit; -class StEventHitIter; -class StActorFunctor; -class StvStEventHitSelector; -class StvHitLoader : public TNamed -{ - public: - - StvHitLoader(const char* name = "StHitsLoader"); - virtual ~StvHitLoader(); - void Clear(const char* opt=""); - int Init(); - void SetHitSelector(); - void SetHitActor(StActorFunctor *act) {mHitLoadActor=act;} - int LoadHits(const StEvent *stev); - int Finish(); - int AddDetector(StDetectorId did); - int NumDetectors() const {return mNDets;}; - void SetMaxTimes(int maxTimes,const char *detectcor="*"); - void SetMaxTimes(int maxTimes,StDetectorId detiD); - protected: -virtual int MakeStvHit(const StHit *stHit,UInt_t upath,int &sure); - - int TpcHitTest(const StHit *stHit); - private: - int mNDets; - StDetectorId mDetId; - StvHit *mStvHit; - StEventHitIter *mHitIter; - StvStEventHitSelector *mHitSelector; - StActorFunctor *mHitLoadActor; - int mMaxTimes[kMaxDetectorId+1]; - ClassDef(StvHitLoader,0) -}; - -#endif diff --git a/StRoot/StvMaker/StvMaker.cxx b/StRoot/StvMaker/StvMaker.cxx deleted file mode 100644 index 51c58592e1f..00000000000 --- a/StRoot/StvMaker/StvMaker.cxx +++ /dev/null @@ -1,647 +0,0 @@ -// $Id: StvMaker.cxx,v 1.61 2017/09/29 16:54:51 perev Exp $ -/*! -\author V Perev 2010 - -A maker StvMaker is a steering maker for Stv package. -
-Main tasks: -
    -
  • Create StvHits; -
  • Make tracks; -
  • Make Primary vertices; -
  • Make Primary tracks; -
  • Save produced data into StEvent. -
-More detailed:
-
    -
  • On Init: -
      -
    • Detectors initialization. - - SetAttr("useEventFiller" ,kTRUE); // default On - SetAttr("useTracker" ,kTRUE); // default On - SetAttr("useVertexFinder" ,kTRUE); // default On - SetAttr("makePulls" ,kFALSE); // default Off - - SetAttr("noTreeSearch",kFALSE); // treeSearch default ON -
    - -
  • On InitRun: -
      -
    • Build detectors; -
    • Init seed finder; -
    • Init hit loader; -
    • Init tracker; -
    • Init StEvent filler; -
    • Init vertex finder; -
    -
  • In Make: -
      -
    • Load hits; -
    • Find seeds; -
    • Create global tracks; -
    • Save tracks into StEvent; -
    • Find vertecies; -
    • Create and assign primaries tracks; -
    • Save primary tracks into StEvent; - -*/ -#include -#include -#include -#include "TSystem.h" -#include "TROOT.h" -#include "TFile.h" -#include "TTree.h" -#include "TTable.h" -#include "TCernLib.h" -#include "TGeoManager.h" -#include "StDetectorId.h" -#include "StEvent.h" -#include "StEnumerations.h" -#include "StChainOpt.h" -#include "StvMaker.h" -#include "StarVMC/GeoTestMaker/StVMCApplication.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -//#include "StvMCInitApp.h" -#include "Stv/StvConst.h" -#include "Stv/StvHit.h" -#include "StvUtil/StvPullEvent.h" -#include "Stv/StvDiver.h" -#include "StvHitLoader.h" -//#include "StvFtsHitLoader.h" -//#include "StvUtil/StvFtsHitErrCalculator.h" -#include "Stv/StvToolkit.h" -#include "Stv/StvSeedFinder.h" -#include "Stv/StvKalmanTrackFinder.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvFitter.h" -#include "Stv/StvKalmanTrackFitter.h" -#include "StvStEventFiller.h" -#include "StvStarVertexFinder.h" -#include "StvTpcActive.h" -#include "Stv/StvTrack.h" -#include "Stv/StvNode.h" -#include "StvStEventMaker.h" -#include "TString.h" -#include "TObjString.h" - -/// Definion of minimal primary vertex errors. -/// Typical case,vertex got from simulations with zero errors. -/// But zero errors could to unpredicted problems -/// Now minimal possible error is 1 micron -static const float MIN_VTX_ERR2 = 1e-4*1e-4; -enum {kMidEta=1,kForwEta=2}; - -ClassImp(StvMaker) -//_____________________________________________________________________________ -StvMaker::StvMaker(const char *name) : StMaker(name) - -{ - assert(strcmp(gProgName,"root.exe")==0); - memset(mBeg,0,mEnd-mBeg+1); - cout <<"StvMaker::StvMaker() -I- Starting"<Clear(); - StMaker::Clear(); -} - -//_____________________________________________________________________________ -Int_t StvMaker::Finish() -{ - StTGeoProxy::Inst()->Finish(); - return StMaker::Finish(); -} - -//_____________________________________________________________________________ -Int_t StvMaker::Init() -{ -// Add maker immediately after Input maker to cleanup StEvent - StvStEventMaker *mk =StvStEventMaker::Inst(); - if (mk) mk->Init(); - return StMaker::Init(); -} - -//_____________________________________________________________________________ -Int_t StvMaker::InitDetectors() -{ - - StTGeoProxy *tgh = StTGeoProxy::Inst(); - -// Check is Stv is running in fit hit error utility - - mFETracks = IAttr("fiterr"); - if (mFETracks>0) SetAttr(".privilege",1,""); - -// TGeo herlper is ready, add error calculators - int actTpc = IAttr("activeTpc"); - mEtaRegion = 0; - if (actTpc) { //TPC error calculators - mHitLoader[0]->AddDetector(kTpcId); - - mEtaRegion|= kMidEta; - - const char* innOutNames[] = {"StvTpcInnerHitErrs" ,"StvTpcOuterHitErrs" - ,"StvTpcInnerPromptErrs" ,"StvTpcOuterPromptErrs",0}; - const char* innOut = 0; - for (int io=0;(innOut=innOutNames[io]);io++) { - TTable *tt = 0; - StvHitErrCalculator *hec = 0; - int nDo = !!mFETracks; - for (int iDo=0; iDo<=nDo; iDo++) { - TString myName(innOut); if (mFETracks && !iDo) myName+="FE"; - switch (io) { - case 0:; case 1: hec = new StvTpcHitErrCalculator(myName); break; - case 2:; case 3: hec = new StvHitErrCalculator (myName); break; - default: assert(0 && "Wrong tpcActive value"); - } - TString ts("Calibrations/tracker/"); - ts+=myName; - tt = (TTable*)GetDataBase(ts); - if (!tt) Error("Make","Table %s NOT FOUND",ts.Data()); - } - assert(tt); - hec->SetPars((double*)tt->GetArray()); - StvTpcSelector*sel = new StvTpcSelector(innOut); - int nHP = tgh->SetHitErrCalc(kTpcId,hec,sel); - Info("Init","%s: %d HitPlanes",innOut,nHP); - assert(nHP); - } - -// After 2009 tpcegeo3 is used - mHitLoader[0]->SetHitActor(new StvTpcHitActor); - } - - if (IAttr("activeEtr")) { //Etr error calculators - mHitLoader[0]->AddDetector(kEtrId); - TString myName("EtrHitErrs"); if (mFETracks) myName+="FE"; - StvHitErrCalculator *hec = new StvHitErrCalculator(myName,2); - double etrPars[StvHitErrCalculator::kMaxPars]={9e-4,9e-4}; - hec->SetPars(etrPars); - int nHP = tgh->SetHitErrCalc(kEtrId,hec,0); - Info("Init","%s: %d HitPlanes","EtrHitErrs",nHP); - assert(nHP); - } - - if (IAttr("activeFgt")) { // FGT error calculator - mHitLoader[1]->AddDetector(kFgtId); - mEtaRegion |= kForwEta; - TString myName("FgtHitErrs"); if (mFETracks) myName+="FE"; - StvHitErrCalculator *hec = new StvHitErrCalculator(myName, 2); - Double_t fgtPars[ StvHitErrCalculator::kMaxPars]={ - 9e-4,9e-4, - }; - hec -> SetPars( fgtPars ); - Int_t nHP = tgh->SetHitErrCalc(kFgtId,hec,0); - Info("Init","%s: %d Hitplanes", "FgtHitErrs", nHP); - } - if (IAttr("activeSst")) { // Sst error calculator - mHitLoader[0]->AddDetector(kSstId); - - } - if (IAttr("activeIst")) { // IST error calculator - mHitLoader[0]->AddDetector(kIstId); - mEtaRegion |= kMidEta; - TString myName("IstHitErrs"); if (mFETracks) myName+="FE"; - StvHitErrCalculator *hec = new StvHitErrCalculator(myName, 2); - TString ts("Calibrations/tracker/Stv");ts+=myName; - TTable *tt = (TTable*)GetDataBase(ts); - if (!tt) Error("Make","Table %s NOT FOUND",ts.Data()); - assert(tt); - hec->SetPars((double*)tt->GetArray()); - Int_t nHP = tgh->SetHitErrCalc(kIstId,hec,0); - Info("Init","%s: %d Hitplanes", "IstHitErrs", nHP); - } - - if (IAttr("activePxl")) { // PXL error calculator - mHitLoader[0]->AddDetector(kPxlId); - TString myName("PxlHitErrs"); if (mFETracks) myName+="FE"; - StvHitErrCalculator *hec = new StvHitErrCalculator(myName, 2); - TString ts("Calibrations/tracker/Stv");ts+=myName; - TTable *tt = (TTable*)GetDataBase(ts); - if (!tt) Error("Make","Table %s NOT FOUND",ts.Data()); - assert(tt); - hec->SetPars((double*)tt->GetArray()); - Int_t nHP = tgh->SetHitErrCalc(kPxlId,hec,0); - Info("Init","%s: %d Hitplanes", "PxlHitErrs", nHP); - } -#ifndef kFtsIdentifier -#error -#endif -#ifdef kFtsIdentifier - if (IAttr("activeFts")) { // FTS error calculator - mHitLoader[1]->AddDetector(kFtsId); - TString myName("FtsHitErrs"); - auto *hec = (StvHitErrCalculator*)gROOT->ProcessLineFast("new StvFtsHitErrCalculator()"); - Int_t nHP = tgh->SetHitErrCalc(kFtsId,hec,0); - Info("Init","%s: %d Hitplanes", "FtsHitErrs", nHP); - } -#endif - -// In case of fithiterr utility working, selects special hits to speedup - if (mFETracks) mHitLoader[0]->SetHitSelector(); - - return kStOk; -} - -//_____________________________________________________________________________ -Int_t StvMaker::InitRun(int run) -{ -static int initialized = 0; - if (initialized) return 0; - -// Geometry via DBMaker - TDataSet *myGeo = GetDataBase("VmcGeometry"); if (myGeo){}; - assert (gGeoManager); - - - StTGeoProxy *tgh = StTGeoProxy::Inst(); - if (*SAttr("HitLoadOpt")) tgh->SetOpt(IAttr("HitLoadOpt")); - -// What is the geo version - TString geoName(gGeoManager->GetName()); geoName.ToLower(); - -// Activate detectors -#ifdef kFtsIdentifier - if (IAttr("activeFts")) { int nakt = tgh->SetActive(kFtsId ); - assert(nakt); - SetAttr("activeTpc",0); - tgh->ls("SscA"); - } -#endif - if (IAttr("activeTpc")) { assert(tgh->SetActive(kTpcId,1,new StvTpcActive));} - if (IAttr("activeEtr")) { assert(tgh->SetActive(kEtrId ));} - if (IAttr("activeFgt")) { assert(tgh->SetActive(kFgtId ));} - if (IAttr("activeSst")) { assert(tgh->SetActive(kSstId ));} - if (IAttr("activeIst")) { assert(tgh->SetActive(kIstId ));} - if (IAttr("activePxl")) { assert(tgh->SetActive(kPxlId ));} - if (IAttr("activePixel")){assert(tgh->SetActive(kPxlId ));} - -// Now Initialize TGeo proxy - tgh->Init(1+2+4); - - if (IAttr("activeTpc")) { //prompt hits for geo >=y2009 - StvTpcPrompt promp; - tgh->InitHitPlane(&promp); - -// TPC has non standard TGeo. Edit it - StvTpcEdit tpce; - int nEdit = tgh->Edit(kTpcId,&tpce); //Disable fake padrows - Info("InitDetectors","%d fake TPC padrows disabled",nEdit); - }//End Tpc special - - - tgh->InitLayers(); - tgh->InitHitShape(); - - tgh->Summary(); - - - StVMCApplication *app = new StVMCApplication("StVMC", "StVMC application"); - StvMCInitApp *ini = new StvMCInitApp(); - app->SetInit(ini); - app->Init(); - - -// Choose seed finders - assert(gSystem->Load("StvSeed.so")>=0); - const char *seedAtt[2]={"seedFinders","SeedFinders.fw"}; - mMaxTimes = IAttr("setMaxTimes"); - for (int jreg=0;jreg<2; jreg++) { //0=midEta,1=forwardEta - mHitLoader[jreg] = new StvHitLoader; - if (mMaxTimes>1)mHitLoader[jreg]->SetMaxTimes(mMaxTimes); - mSeedFinders[jreg] = new StvSeedFinders; - if (IAttr("useEventFiller")) - mEventFiller[jreg]= new StvStEventFiller; - if (IAttr("useVertexFinder")) - mVertexFinder[jreg] = new StvStarVertexFinder("GenericVertex"); - mTrackFinder[jreg] = new StvKalmanTrackFinder; - mTrackFitter[jreg] = new StvKalmanTrackFitter; - int iRefit = IAttr("Refit"); - mTrackFinder[jreg]->SetRefit(iRefit); - - - TString seeds = SAttr(seedAtt[jreg]); - if (!seeds.Length()) seeds = "Default"; - TObjArray *tokens = seeds.Tokenize(" .,"); - int seedErr=0; - const char *seedNick[]={"CA" ,"Default" ,"KNN" ,"Fts" ,0}; - const char *seedNews[]={"new StvCASeedFinder","new StvDefaultSeedFinder","new StvKNSeedFinder","new StvDefaultSeedFinder",0}; - - - for (int idx=0;idx<=tokens->GetLast();idx++) { - TString &chunk = ((TObjString*)tokens->At(idx))->String(); - for (int nick=0;seedNick[nick];nick++) { - if (chunk.CompareTo(seedNick[nick],TString::kIgnoreCase)!=0) continue; - if (nick==0) { - assert(gSystem->Load("Vc.so")>=0); - assert(gSystem->Load("TPCCATracker.so") >=0); - } - StvSeedFinder *mySeedFinder = (StvSeedFinder*)gROOT->ProcessLineFast(seedNews[nick],&seedErr); - if (IAttr("truthSeedFinder")) mySeedFinder->SetIdTruth(); - if (TString(seedNick[nick])=="Fts") mySeedFinder->SetSgn(-1); - assert(mySeedFinder && !seedErr); - mSeedFinders[jreg]->Add(mySeedFinder); - Info("InitRun","Added %s seed finder",mySeedFinder->GetName()); - } - }; - delete tokens; - }//end of Eta regions - - - InitDetectors(); - - - int reg = 0; - do { - if (mHitLoader[reg] && mHitLoader[reg]->NumDetectors()==0) mHitLoader[reg]=0; ; - if (mHitLoader[reg]) break; - mSeedFinders[reg] = 0; - mEventFiller[reg] = 0; - mTrackFinder[reg] = 0; - mTrackFitter[reg] = 0; - } while (0); - - reg = 1; - do { - if (mHitLoader[reg] && mHitLoader[reg]->NumDetectors()==0) mHitLoader[reg]=0; ; - if (mHitLoader[reg]) break; - mSeedFinders[reg] = 0; - mEventFiller[reg] = 0; - mTrackFinder[reg] = 0; - mTrackFitter[reg] = 0; - mVertexFinder[reg]= 0; - } while(0); - - - InitPulls(); - - new StvFitter(); - - return StMaker::InitRun(run); -} - -//_____________________________________________________________________________ -Int_t StvMaker::Make() -{ -static const StvConst *kons = new StvConst(); -static StvToolkit* kit = StvToolkit::Inst(); - cout <<"StvMaker::Make() -I- Starting on new event"<(GetInputDS("StEvent")); - - if (!event) return kStWarn; - - for (int reg=0;reg<2;reg++) { //Loop over eta regions - const auto *par = kons->At(reg); - if (mHitLoader[reg]){ - mSeedFinders [reg]->SetCons(par); - mEventFiller [reg]->SetCons(par); - mTrackFitter [reg]->SetCons(par); - mCurTrackFitter = mTrackFitter[reg]; - mTrackFinder [reg]->SetCons(par); - mCurTrackFinder = mTrackFinder[reg]; - mCurTrackFinder->SetFitter(mCurTrackFitter); - } - if (mVertexFinder[reg]) - mVertexFinder[reg]->SetCons(par); - - if (mHitLoader[reg]) { - mHitLoader[reg]->LoadHits(event); - kit->SetSeedFinders(mSeedFinders[reg] ); - kit->Reset(); - int n = (nVtx)? nVtx:1; - for (int i=0;ix():0; - mSeedFinders[reg]->SetVtx(V); - int nTks = mTrackFinder[reg]->FindTracks(); - if (mMaxTimes>1) nTks = CleanGlobalTracks(); - TestGlobalTracks(); - mToTracks += nTks; - } - } - if (mEventFiller[reg]) { - mEventFiller[reg]->Set(event,&kit->GetTracks()); - mEventFiller[reg]->fillEvent(); - } - - do {//pseudo loop - if (!mVertexFinder[reg]) break; - nVtx = mVertexFinder[reg]->Fit(event); - if (!nVtx) break; - Info("Make","VertexFinder found %d vertices",nVtx); - vertexes = &mVertexFinder[reg]->Result(); - if (!vertexes->size()) break; - //Set minimal errors - for (size_t i=0;isize();i++) { - StvHit *vtx=(*vertexes)[i]; - float *vtxErr = vtx->errMtx(); - if (vtxErr[5]>MIN_VTX_ERR2) continue; - memset(vtxErr,0,sizeof(vtxErr[0])*6); - vtxErr[0]=MIN_VTX_ERR2; - vtxErr[2]=MIN_VTX_ERR2; - vtxErr[5]=MIN_VTX_ERR2; - } - } while(0); - //cout << "StvMaker::Make() -I- Got Vertex; extend Tracks"<FindPrimaries(*vertexes); - if (mEventFiller[reg]) - mEventFiller[reg]->fillEventPrimaries(); - } - }//end regions - if (mPullTTree) {FillPulls();} - - cout<< "StvMaker::Make() -I- Done"<Clear(); - StTGeoProxy::Inst()->Clear(); - if (mFETracks && mToTracks>mFETracks) return kStEOF; - return kStOK; -} -//_____________________________________________________________________________ -Int_t StvMaker::InitPulls() -{ - if (!IAttr("makePulls")) return 0; - - const StChainOpt *bfc = GetChainOpt(); - assert(bfc); - TFile *tfile = GetTFile(); - if (!tfile) { - TString ts = bfc->GetFileIn(); - ts= gSystem->BaseName(ts); - int ext = ts.Index("."); - if (ext>0) ts.Replace(ext,999,""); - ts +=".stipull.root"; - tfile = mPullFile = new TFile(ts,"RECREATE","TTree Stv Pulls ROOT file"); - } - tfile->cd(); - mPullTTree = new TTree("StvPulls","TTree Stv pulls"); - mPullTTree->SetAutoSave(10000000); // autosave when 0.01 Gbyte written - mPullEvent = new StvPullEvent; - TBranch *branch = mPullTTree->Branch("event", mPullEvent->ClassName(),&mPullEvent, 16000,99); - branch->SetAutoDelete(kFALSE); - if (mEventFiller[0])mEventFiller[0]->Set(mPullEvent); - if (mEventFiller[1])mEventFiller[1]->Set(mPullEvent); - return 0; -} -//_____________________________________________________________________________ -Int_t StvMaker::FillPulls() -{ - StEvtHddr *hddr = GetEvtHddr(); - mPullEvent->mRun = hddr->GetRunNumber(); - mPullEvent->mEvt = hddr->GetEventNumber(); - mPullEvent->mDate = hddr->GetDateTime(); //DAQ time (GMT) - const StvHit *vertex = 0; int nMaxTks=0,ivertex=0; - if (mVertexFinder[0] && mVertexFinder[0]->Result().size()) { - int nVtx = mVertexFinder[0]->Result().size(); - for (int iv=0;ivResult()[iv]; - if (nMaxTks > hit->getCount()) continue; - nMaxTks = hit->getCount(); - vertex = hit; ivertex = iv+1; - } } - mPullEvent->mChi2 = 0; - memset(mPullEvent->mVtx,0,sizeof(mPullEvent->mVtx)); - memset(mPullEvent->mEtx,0,sizeof(mPullEvent->mEtx)); - if (vertex) { - mPullEvent->mIVtx = ivertex; - mPullEvent->mVtx[0] = vertex->x()[0]; - mPullEvent->mVtx[1] = vertex->x()[1]; - mPullEvent->mVtx[2] = vertex->x()[2]; - TCL::ucopy(vertex->errMtx(),mPullEvent->mEtx,6); - } - mPullEvent->Finish(); - mPullTTree->Fill(); - mPullEvent->Clear(); - return kStOK; -} -//_____________________________________________________________________________ -int StvMaker::GeoTest() -{ - int ierr=0; - if (!gGeoManager) return 1; - for (int phi = 60,sect=1;phi>=-360+90;phi -=30,sect++) - { - double x = 100*cos(phi*3.1415/180); - double y = 100*sin(phi*3.1415/180); - double z = 100.; - TGeoNode *node = gGeoManager->FindNode(x,y,z);if(node){}; - TGeoNode *parn = gGeoManager->GetMother(1); - if (sect != parn->GetNumber()) ierr++; - - const char *path = gGeoManager->GetPath(); - printf("Sector=%d path=%s\n",sect,path); - - - } - for (int phi = 120,sect=13;sect<=24;phi +=30,sect++) - { - double x = 100*cos(phi*3.1415/180); - double y = 100*sin(phi*3.1415/180); - double z = -100.; - TGeoNode *node = gGeoManager->FindNode(x,y,z);if(node){}; - TGeoNode *parn = gGeoManager->GetMother(1); - if (sect-12 != parn->GetNumber()) ierr++; - const char *path = gGeoManager->GetPath(); - printf("Sector=%d path=%s\n",sect,path); - } -return ierr; -} -//________________________________________________________________________________ -static bool TrackCompareStatus(const StvTrack *a, const StvTrack *b) -{ - int nA = a->GetNHits(); - int nB = b->GetNHits(); - if (nA!=nB) return (nA > nB); - return (a->GetXi2Aux() GetXi2Aux()); -// return (a->GetXi2W()GetXi2W()); -} -//_____________________________________________________________________________ -int StvMaker::CleanGlobalTracks() -{ -static StvToolkit *kit = StvToolkit::Inst(); - StvTracks &trackContainer = kit->GetTracks(); - - for (auto it = trackContainer.begin(); it!=trackContainer.end(); ++it) - { - auto* kTrack = *it; - kTrack->SetUnused(); - } - trackContainer.sort(TrackCompareStatus ); - - for (auto it = trackContainer.begin(); it!=trackContainer.end();) - { - auto* kTrack =*it; - int nHits=0,nNits=0; - for (auto nodeIt =kTrack->begin();nodeIt!=kTrack->end();nodeIt++) - { - auto *node = *nodeIt; - StvHit *hit = node->GetHit(); if (!hit) continue; - if (hit->timesUsed()) { nNits++; node->SetHit(0) ;} - else { nHits++; hit->setTimesUsed(1);} - } - if (nHits<4) { it = trackContainer.erase(it); continue; } - StvNode *dcaNode = kTrack->GetNode(StvTrack::kDcaPoint); - if (dcaNode) { - kTrack->remove(dcaNode); - } - - - int ans = mCurTrackFitter->Refit(kTrack,1); - if (ans || kTrack->GetNHits()<4) { it = trackContainer.erase(it); continue; } - mCurTrackFinder->MakeDcaNode(kTrack); - ++it; - } - - for (auto it = trackContainer.begin(); it!=trackContainer.end(); ++it) - { - auto* kTrack = *it; - for (auto nodeIt =kTrack->begin();nodeIt!=kTrack->end();nodeIt++) - { - auto *node = *nodeIt; - auto *hit = node->GetHit(); if (!hit) continue; - assert(hit->timesUsed()==1); - } - } - return trackContainer.size(); -} - -//_____________________________________________________________________________ -int StvMaker::TestGlobalTracks() const -{ -static StvToolkit *kit = StvToolkit::Inst(); - StvTracks &trackContainer = kit->GetTracks(); - - for (auto it = trackContainer.begin(); it!=trackContainer.end(); ++it) - { - auto* kTrack = *it; - int nHits = kTrack->GetNHits(); - StvDebug::Count("IdQua_vs_NHits",nHits,kTrack->GetQua()*100); - } - return 0; -} diff --git a/StRoot/StvMaker/StvMaker.h b/StRoot/StvMaker/StvMaker.h deleted file mode 100644 index d74beaba0f1..00000000000 --- a/StRoot/StvMaker/StvMaker.h +++ /dev/null @@ -1,73 +0,0 @@ -//StvMaker.h - -#ifndef StvMaker_HH -#define StvMaker_HH - -#include - -#include "StMaker.h" -#include "StEvent/StEnumerations.h" - -class TFile; -class TTree; -class StvPullEvent; -class StEvent; -class StvHit; -class StvHitLoader; -class StvTrack; -class StvTrackContainer; -class StvTrackFinder; -class StvTrackFitter; -class StvTrackNode; -class StvTrack; -class StvToolkit; -class StvVertexFinder; -class StvEventFiller; -class StvSeedFinders; - -class StvMaker : public StMaker -{ - public: - - StvMaker(const char* name = "Stv"); - virtual ~StvMaker(); - virtual void Clear(const char* opt=""); - virtual int Init(); - int InitDetectors(); - int InitPulls(); - int FillPulls(); - virtual int InitRun(int); - virtual int Make(); - virtual int Finish(); - int CleanGlobalTracks(); - int TestGlobalTracks() const; - - virtual const char* GetCVS() const - {static const char cvs[]="Tag $Name: $ $Id: StvMaker.h,v 1.9 2018/01/28 00:49:01 perev Exp $ built " __DATE__ " " __TIME__; return cvs;} - - - - protected: - int GeoTest(); -private: - char mBeg[1]; - int mEtaRegion; //bit0:TpcLike medium eta,bit1:Forward eta - StvHitLoader *mHitLoader[2]; - StvSeedFinders *mSeedFinders[2]; - StvEventFiller *mEventFiller[2]; - StvTrackFinder *mTrackFinder[2]; - StvTrackFinder *mCurTrackFinder; - StvTrackFitter *mCurTrackFitter; - StvTrackFitter *mTrackFitter[2]; - StvVertexFinder *mVertexFinder[2]; - TFile *mPullFile; - StvPullEvent *mPullEvent; - TTree *mPullTTree; - int mMaxTimes; //max times hit reused - int mFETracks; //max number of track requested if fit hit errs - int mToTracks; //total tracks created, if > mFETracks, stop - char mEnd[1]; - ClassDef(StvMaker,0) -}; - -#endif diff --git a/StRoot/StvMaker/StvStEventFiller.cxx b/StRoot/StvMaker/StvStEventFiller.cxx deleted file mode 100755 index c3ff1f9a4fe..00000000000 --- a/StRoot/StvMaker/StvStEventFiller.cxx +++ /dev/null @@ -1,1610 +0,0 @@ -/*************************************************************************** - * - * $Id: StvStEventFiller.cxx,v 1.43 2016/11/29 17:13:20 perev Exp $ - * - * Author: Manuel Calderon de la Barca Sanchez, Mar 2002 - *************************************************************************** - * - * $Log: StvStEventFiller.cxx,v $ - * Revision 1.43 2016/11/29 17:13:20 perev - * HideFts - * - * Revision 1.42 2016/11/28 01:38:51 perev - * Change max hits 1000>256 (loopers) - * - * Revision 1.41 2015/12/12 00:57:10 perev - * Separate mid and forward rapidity - * - * Revision 1.40 2015/11/11 01:57:06 perev - * Added SetCons(const StvKonst_st *kons) - * Now old constants like kMinHits, kGood hits etc become variable defined by SetCons - * It allows have to StEventFiller's with different constants - * Typical use case: mid rapidity (Tpc,Hft ..) and separately forward, big rapidity - * with different constants - * - * Revision 1.39 2015/10/30 19:39:33 perev - * do not fill detector id == 0 - * - * Revision 1.38 2015/06/18 02:17:14 perev - * Fix printout of counting used hits - * - * Revision 1.37 2015/06/10 17:28:21 perev - * Print of used hits (from Sti) added - * - * Revision 1.36 2013/10/31 16:11:19 perev - * test for minDca ==> fabs(minDca) - * - * Revision 1.35 2013/10/02 19:12:31 perev - * MaxTrackLen = 1500 now - * - * Revision 1.34 2013/09/27 20:35:46 perev - * Return fix topology map - * - * Revision 1.33 2013/07/02 04:07:48 perev - * add dca00 to pull tree - * - * Revision 1.32 2013/06/23 23:31:58 perev - * Assert++ - * - * Revision 1.31 2013/06/16 00:44:58 perev - * Cleanup - * - * Revision 1.30 2013/05/24 16:34:38 perev - * Introduction hit filter in case HitFitErr - * - * Revision 1.29 2013/05/20 18:38:52 perev - * Cleanup - * - * Revision 1.28 2013/04/20 22:02:42 perev - * Rename StTGeoHelper ==> StTGeoProxy - * - * Revision 1.27 2013/04/15 00:41:42 perev - * outdated assert removed - * - * Revision 1.26 2013/04/10 03:37:25 perev - * account non Tpc hits with waight =2 - * - * Revision 1.25 2013/03/20 20:52:07 perev - * Remove StuTopTopologyMap... - * - * Revision 1.24 2013/03/08 19:18:37 perev - * not setting huge impact if no vertice - * - * Revision 1.23 2013/02/20 00:26:59 perev - * remove deleteing Emc data in fillEvent() - * - * Revision 1.22 2013/02/16 01:25:10 perev - * fix double count in nallhits - * - * Revision 1.21 2012/10/21 22:56:56 perev - * Add IdTruth into pulls - * - * Revision 1.20 2012/06/21 01:10:54 perev - * Cleanup - * - * Revision 1.19 2012/05/15 17:54:13 perev - * Avoid Dca node in fillFitTraits - * - * Revision 1.18 2012/04/27 01:43:08 perev - * Use totFitsPointNumber for flag setting - * - * Revision 1.17 2012/04/10 22:42:13 perev - * Cleanup - * - * Revision 1.16 2012/03/22 00:19:14 perev - * Cleanup - * - * Revision 1.15 2012/02/23 18:13:15 perev - * Cleanup - * - * Revision 1.14 2011/11/18 23:34:40 perev - * Global impact fixed - * - * Revision 1.13 2011/10/26 20:35:39 perev - * Temporary fix primary hit ignored - * - * Revision 1.12 2011/10/07 19:35:46 perev - * StTrack::mKey short==>int - * - * Revision 1.11 2011/08/31 19:50:17 perev - * fix assert for small rxy - * - * Revision 1.10 2011/08/19 02:40:43 perev - * Add errors - * - * Revision 1.9 2011/08/13 23:00:50 perev - * wrong order o vtx accounted - * - * Revision 1.8 2011/07/19 20:05:37 perev - * Dca00 for primary into StvPull - * - * Revision 1.7 2011/05/04 17:57:37 perev - * Typo fixed - * - * Revision 1.6 2011/04/03 20:45:11 perev - * Cleanup - * - * Revision 1.5 2011/02/05 21:57:55 perev - * Test for +ve error matrix added - * - * Revision 1.4 2010/12/20 20:33:48 perev - * Cleanup of mTrackNumber in StvPulls - * - * Revision 1.3 2010/12/16 21:50:40 perev - * Primary track fit - * - * Revision 1.2 2010/09/29 23:39:25 perev - * Intereface fillPulls(...) chamnged - * - * Revision 1.1 2010/07/06 20:27:53 perev - * Alpha version of Stv (Star Tracker Virtual) - * - * Revision 1.2 2010/07/03 16:27:15 perev - * Last time name Stv - * - * Revision 1.1 2010/06/22 19:34:28 perev - * EventFiller added - * - * Revision 2.90 2010/01/27 21:43:49 perev - * Add _nPrimTracks for case of fiterr - * - * Revision 2.89 2009/10/18 22:47:29 perev - * assert instead of skip - * - * Revision 2.88 2009/10/16 14:56:02 fisyak - * Add check that pHit exists - * - * Revision 2.87 2009/10/15 03:29:30 perev - * Add primary vertex number and charge(GVB) - * - * Revision 2.86 2009/08/19 21:27:57 perev - * Account time of flight for StvPulls - * - * Revision 2.85 2009/03/16 13:50:14 fisyak - * Move out all Stv Chairs into StDetectorDb - * - * Revision 2.84 2008/08/22 13:32:52 fisyak - * add one more digit in trakc flag, mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0) - * - * Revision 2.83 2008/04/03 20:04:05 fisyak - * Straighten out DB access via chairs - * - * Revision 2.82 2007/10/17 15:32:35 fisyak - * rename Hft => Pxl - * - * Revision 2.81 2007/04/16 22:47:18 perev - * aux.mPt is +ve - * - * Revision 2.80 2007/03/21 17:51:36 fisyak - * adjust for ROOT 5.14 - * - * Revision 2.79 2006/12/19 19:46:09 perev - * Filling pull tracks added - * - * Revision 2.78 2006/12/18 01:30:39 perev - * fillPulls reorganized - * - * Revision 2.77 2006/08/31 03:25:58 fisyak - * Make cut for EEMC pointing track based on StTrackDetectorInfo instead of StTrackFitTraits - * - * Revision 2.76 2006/08/29 22:18:37 fisyak - * move filling of StTrackDetectorInfo into fillTrack - * - * Revision 2.75 2006/08/28 17:02:23 fisyak - * Add +x11 short tracks pointing to EEMC, clean up StvDedxCalculator - * - * Revision 2.74 2006/06/16 21:28:57 perev - * FillStHitErr method added and called - * - * Revision 2.73 2006/05/31 03:59:04 fisyak - * Add Victor's dca track parameters, clean up - * - * Revision 2.72 2006/04/07 18:00:30 perev - * Back to the latest Stv - * - * Revision 2.69 2006/02/14 18:56:18 perev - * setGlobalDca==>setDca - * - * Revision 2.68 2006/01/19 22:29:57 jeromel - * kMaxId -> kMaxDetectorId - * - * Revision 2.67 2005/12/08 00:06:27 perev - * BugFix, Instead of vertex, first hit was used - * - * Revision 2.66 2005/08/18 22:31:47 perev - * More tests - * - * Revision 2.65 2005/08/17 22:04:36 perev - * PoinCount cleanup - * - * Revision 2.64 2005/08/16 21:09:06 perev - * remeve 5fit cut - * - * Revision 2.63 2005/08/16 20:37:23 perev - * remove small pt cut - * - * Revision 2.62 2005/08/14 01:24:40 perev - * test for nhits<5 removed - * - * Revision 2.61 2005/08/04 04:04:19 perev - * Cleanup - * - * Revision 2.60 2005/07/21 21:50:24 perev - * First/last point of track filled from node now - * - * Revision 2.59 2005/07/20 17:34:08 perev - * MultiVertex - * - * Revision 2.58 2005/05/12 18:32:20 perev - * Temprary hack, save residuals - * - * Revision 2.57 2005/04/11 17:42:39 perev - * Temporary residuals saving added - * - * Revision 2.56 2005/03/24 17:51:16 perev - * print error code added - * - * Revision 2.55 2005/03/17 06:33:20 perev - * TPT like errors implemented - * - * Revision 2.54 2005/02/25 17:43:15 perev - * StTrack::setKey(...StvTrack::getId()) now - * - * Revision 2.53 2005/02/17 23:19:03 perev - * NormalRefangle + Error reseting - * - * Revision 2.52 2005/02/07 18:34:16 fisyak - * Add VMC dead material - * - * Revision 2.51 2005/01/17 03:56:56 pruneau - * change track container to vector - * - * Revision 2.50 2005/01/17 01:32:13 perev - * parameters protected - * - * Revision 2.49 2004/12/21 20:46:00 perev - * Cleanup. All known bugs fixed - * - * Revision 2.48 2004/12/02 22:14:53 calderon - * Only fill the fitTraits.chi2[1] data member for primaries. - * It holds node->getChi2() from the innerMostHitNode, which will be the - * vertex for primaries. - * - * Revision 2.47 2004/12/02 04:18:06 pruneau - * chi2[1] now set to incremental chi2 at inner most hit or vertex - * - * Revision 2.46 2004/12/01 15:35:46 pruneau - * removed throw and replaced with continue - * - * Revision 2.45 2004/11/08 15:34:16 pruneau - * fix of the chi2 calculation - * - * Revision 2.44 2004/10/27 03:25:54 perev - * Version V3V - * - * Revision 2.43 2004/10/26 06:45:41 perev - * version V2V - * - * Revision 2.42 2004/10/14 02:21:34 calderon - * Updated code in StTrackDetectorInfo, now only increment the reference count - * for globals, not for primaries. So fillTrackDetectorInfo changed to reflect - * this. - * - * Revision 2.41 2004/10/01 01:13:51 calderon - * Added bug fix from Marco: - * flag%100 -> flag/100. - * - * Revision 2.40 2004/08/17 20:04:28 perev - * small leak fixed, delete physicalHelix,originD - * - * Revision 2.39 2004/08/17 04:53:05 calderon - * When filling fit traits for primary tracks, set the new flag - * mPrimaryVertexUsedInFit. - * - * Revision 2.38 2004/08/10 14:21:13 calderon - * Use the firstHit from the dynamic_cast, to avoid a compiler warning - * for an unused variable. - * - * Revision 2.37 2004/08/06 22:23:29 calderon - * Modified the code to use the setNumberOfxxxPoints(unsigned char,StDetectorId) - * methods of StTrack, StTrackDetectorInfo, StTrackFitTraits, and to use - * the maxPointCount(unsigned int detId) method of StvTrack. - * - * Revision 2.36 2004/08/06 02:29:20 andrewar - * Modifed call to getMaxPointCount - * - * Revision 2.35 2004/08/05 05:25:25 calderon - * Fix the assignment of the first point for primaries. Now, - * the logic for both globals and primaries is that the first - * point is the first element of the stHits() vector that - * can actually be casted to an StHit (the vertex will fail this test, - * all other hits coming from detectors will satisfy it). - * - * Revision 2.34 2004/07/30 18:49:18 calderon - * For running in production, Yuri's dEdx Maker will fill the Pid Traits, - * so the filling of Pid Traits in the filler is no longer needed: - * it actually causes confusion because the V0 finders will loop over - * the PID traits vector and find the first one, so they won't find - * the trait created by the dEdx Maker. It is best to just comment - * out the filling of the Pid Traits here. - * - * Revision 2.33 2004/07/07 19:33:48 calderon - * Added method fillFlags. Flags tpc, tpc+svt (globals and primaries) and flags -x02 tracks with less than 5 total fit points - * - * Revision 2.32 2004/04/21 21:36:24 calderon - * Correction in the comments about the encoded method. - * - * Revision 2.31 2004/03/31 00:27:29 calderon - * Modifications for setting the fit points based on the chi20 condition. - * - * Revision 2.28 2004/03/19 19:33:23 andrewar - * Restored primary filling logic. Now taking parameters at the - * vertex for Primary tracks. - * - * Revision 2.27 2004/01/27 23:40:46 calderon - * The filling of the impactParameter() for global tracks is done now - * only after finding the vertex. The - * StPhysicalHelix::distance(StThreeVectorD) method is used for both globals - * and primaries, the only difference is where the helix is obtained: - * - globals - helix from StTrack::geometry(), which was filled from the - * innermost hit node, which should be a hit at the time. - * - primaries - helix from innermost hit node, which should be the vertex - * at the time it is called. - * - * Revision 2.26 2003/12/11 03:44:29 calderon - * set the length right again, it had dissappeared from the code... - * - * Revision 2.25 2003/11/26 04:02:53 calderon - * track->getChi2() returns the sum of chi2 for all sti nodes. In StEvent, - * chi2(0) should be chi2/dof, so we need to divide by - * dof=track->getPointCount()-5; - * - * Revision 2.24 2003/09/07 03:49:10 perev - * gcc 3.2 + WarnOff - * - * Revision 2.23 2003/09/02 17:59:59 perev - * gcc 3.2 updates + WarnOff - * - * Revision 2.22 2003/08/21 21:21:56 andrewar - * Added trap for non-finite dEdx. Added logic to fillGeometry so - * info is for innerMostHitNode on a detector, not vertex (note: - * Primaries only) - * - * Revision 2.21 2003/08/05 18:26:15 andrewar - * DCA track update logic modified. - * - * Revision 2.20 2003/07/01 20:25:28 calderon - * fillGeometry() - use node->getX(), as it should have been since the - * beginning - * impactParameter() - always use the innermos hit node, not just for globals - * removed extra variables which are no longer used. - * - * Revision 2.19 2003/05/15 03:50:26 andrewar - * Disabled call to filldEdxInfo for the SVT. Checks need to be - * applied to make sure the detector is active before calculator - * is called, but for the review filling this info is unnecessary. - * - * Revision 2.18 2003/05/14 00:04:35 calderon - * The array of 15 floats containing the covariance matrix has a different - * order in Stv than in StEvent. In Stv the array is counted starting from - * the first row, column go to next column until you hit the diagonal, - * jump to next row starting from first column. In StEvent the array is - * counted starting from the first row, column go to the next row until you - * hit the end, jump to next column starting from diagonal. - * The filling of the fitTraits was fixed to reflect this. - * - * Revision 2.17 2003/05/12 21:21:39 calderon - * switch back to getting the chi2 from track->getChi2() - * Covariance matrix is still obtained from node->get(), and the values - * are not as expected in StEvent, so this will still need to change. - * - * Revision 2.16 2003/05/08 22:23:33 calderon - * Adding a check for finiteness of node origin and node curvature. If any - * of the numbers is not finite, the code will abort(). - *local - * Revision 2.15 2003/04/29 18:48:52 pruneau - * *** empty log message *** - * - * Revision 2.14 2003/04/29 15:28:10 andrewar - * Removed hacks to get helicity right; switch now done at source - * (StvNode). - * - * Revision 2.13 2003/04/25 21:42:47 andrewar - * corrected DCA bug and added temp fix for helicity problem. This will - * have to be modified when the helicity convention in StvStKalmanTrack - * is updated. - * - * Revision 2.12 2003/04/04 14:48:34 pruneau - * *** empty log message *** - * - * Revision 2.11 2003/03/14 19:02:55 pruneau - * various updates - DCA is a bitch - * - * Revision 2.10 2003/03/13 21:20:10 pruneau - * bug fix in filler fixed. - * - * Revision 2.9 2003/03/13 18:59:44 pruneau - * various updates - * - * Revision 2.8 2003/03/13 16:01:48 pruneau - * remove various cout - * - * Revision 2.7 2003/03/13 15:15:52 pruneau - * various - * - * Revision 2.6 2003/03/12 17:58:05 pruneau - * fixing stuff - * - * Revision 2.5 2003/02/25 16:56:20 pruneau - * *** empty log message *** - * - * Revision 2.4 2003/02/25 14:21:10 pruneau - * *** empty log message *** - * - * Revision 2.3 2003/01/24 06:12:28 pruneau - * removing centralized io - * - * Revision 2.2 2003/01/23 05:26:02 pruneau - * primaries rec reasonable now - * - * Revision 2.1 2003/01/22 21:12:15 calderon - * Restored encoded method, uses enums but stores the value in constructor - * as a data member so bit operations are only done once. - * Fixed warnings. - * - * Revision 2.0 2002/12/04 16:50:59 pruneau - * introducing version 2.0 - * - * Revision 1.21 2002/09/20 02:19:32 calderon - * Quick hack for getting code for review: - * The filler now checks the global Dca for the tracks and only fills - * primaries when dca<3 cm. - * Also removed some comments so that the production log files are not swamped - * with debug info. - * - * Revision 1.20 2002/09/12 22:27:15 andrewar - * Fixed signed curvature -> StHelixModel conversion bug. - * - * Revision 1.19 2002/09/05 05:47:36 pruneau - * Adding Editable Parameters and dynamic StvOptionFrame - * - * Revision 1.18 2002/08/29 21:09:22 andrewar - * Fixed seg violation bug. - * - * Revision 1.17 2002/08/22 21:46:00 pruneau - * Made a fix to StvStEventFiller to remove calls to StHelix and StPhysicalHelix. - * Currently there is one instance of StHelix used a calculation broker to - * get helix parameters such as the distance of closest approach to the main - * vertex. - * - * Revision 1.16 2002/08/19 19:33:00 pruneau - * eliminated cout when unnecessary, made helix member of the EventFStvStEventFilleriller - * - * Revision 1.15 2002/08/12 21:39:56 calderon - * Introduced fillPidTraits, which uses the values obtained from - * Andrews brand new dEdxCalculator to create two instances of an - * StTrackPidTraits object and pass it to the track being filled. - * - * Revision 1.14 2002/08/12 15:29:21 andrewar - * Added dedx calculators - * - * Revision 1.13 2002/06/28 23:30:56 calderon - * Updated with changes debugging for number of primary tracks added. - * Merged with Claude's latest changes, but restored the tabs, othewise - * cvs diff will not give useful information: everything will be different. - * - * Revision 1.12 2002/06/26 23:05:31 pruneau - * changed macro - * - * Revision 1.11 2002/06/25 15:09:16 pruneau - * *** empty log message *** - * - * Revision 1.10 2002/06/18 18:08:34 pruneau - * some cout statements removed/added - * - * Revision 1.9 2002/06/05 20:31:15 calderon - * remove some redundant statements, the call to - * StTrackNode::addTrack() - * already calls - * track->SetNode(this), so I don't need to do it again - * - * Revision 1.8 2002/05/29 19:14:45 calderon - * Filling of primaries, in - * StvStEventFiller::fillEventPrimaries() - * - * Revision 1.7 2002/04/16 19:46:44 pruneau - * must catch exception - * - * Revision 1.6 2002/04/16 13:11:30 pruneau - * *** empty log message *** - * - * Revision 1.5 2002/04/09 16:03:13 pruneau - * Included explicit extension of tracks to the main vertex. - * - * Revision 1.4 2002/04/03 16:35:03 calderon - * Check if primary vertex is available in StvStEventFiller::impactParameter(), - * if not, return DBL_MAX; - * - * Revision 1.3 2002/03/28 04:29:49 calderon - * First test version of Filler - * Currently fills only global tracks with the following characteristics - * -Flag is set to 101, as most current global tracks are. This is not - * strictly correct, as this flag is supposed to mean a tpc only track, so - * really need to check if the track has svt hits and then set it to the - * appropriate flag (501 or 601). - * -Encoded method is set with bits 15 and 1 (starting from bit 0). Bit 1 - * means Kalman fit. - * Bit 15 is an as-yet unused track-finding bit, which Thomas said ITTF - * could grab. - * -Impact Parameter calculation is done using StHelix and the primary vertex - * from StEvent - * -length is set using getTrackLength, which might still need tweaking - * -possible points is currently set from getMaxPointCount which returns the - * total, and it is not - * what we need for StEvent, so this needs to be modified - * -inner geometry (using the innermostHitNode -> Ben's transformer -> - * StPhysicalHelix -> StHelixModel)StvStEventFiller - * -outer geometry, needs inside-out pass to obtain good parameters at - * outermostHitNode - * -fit traits, still missing the probability of chi2 - * -topology map, filled from StuFixTopoMap once StDetectorInfo is properly set - * - * This version prints out lots of messages for debugging, should be more quiet - * when we make progress. - * - **************************************************************************/ -//ROOT -#include "RVersion.h" -#include "TCernLib.h" -#include "TVectorD.h" -#include "TMatrixD.h" -//std -#include "Stiostream.h" -#include -#include - -// SCL -#include "StPhysicalHelix.hh" -#include "StThreeVector.hh" -#include "StThreeVectorF.hh" -#include "PhysicalConstants.h" -#include "SystemOfUnits.h" -#include "StTrackDefinitions.h" -#include "StTrackMethod.h" -#include "StDedxMethod.h" - -//StEvent -#include "StPrimaryVertex.h" -#include "StEventTypes.h" -#include "StDetectorId.h" -#include "StHelix.hh" -#include "StDcaGeometry.h" -#include "StHit.h" - - -#include "StEventUtilities/StEventHelper.h" -#include "Stv/StvConst.h" -#include "Stv/StvStl.h" -#include "Stv/StvHit.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "StvUtil/StvPullEvent.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StvUtil/StvDebug.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -//#include "StDetectorDbMaker/StvKalmanTrackFitterParameters.h" - -//StvMaker -#include "StvMaker/StvStEventFiller.h" - -#include "TMath.h" - -#include -std::map gTrkNodeMap; -typedef std::map::iterator TkMapIter; - -#include "StEventUtilities/StuFixTopoMap.cxx" -//_____________________________________________________________________________ -inline StThreeVectorF position(const StvNode *node) -{ - const double *d = node->GetFP().P; - return StThreeVectorF(d[0],d[1],d[2]); -} -//_____________________________________________________________________________ -inline StThreeVectorF position(const StvHit *hit ) -{ - const float *f = hit->x(); - return StThreeVectorF(f[0],f[1],f[2]); -} -//_____________________________________________________________________________ -inline int getCharge(const StvNode *node) -{ - return node->GetFP().getCharge(); -} -//_____________________________________________________________________________ -inline double getCurvature(const StvNode *node) -{ - return node->GetFP()._curv; -} -//_____________________________________________________________________________ -inline double getPhi(const StvNode *node) -{ - return node->GetFP()._psi; -} -//_____________________________________________________________________________ -inline double getDip(const StvNode *node) -{ - return atan(node->GetFP()._tanl); -} -//_____________________________________________________________________________ -inline StThreeVectorF getMom(const StvNode *node) -{ - double p[3]; - node->GetFP().getMom(p); return StThreeVectorF(p[0],p[1],p[2]); -} -//_____________________________________________________________________________ -inline int getHelicity(const StvNode *node) -{ - double curv = node->GetFP()._curv; - return (curv < 0) ? -1 : 1; -} - -//_____________________________________________________________________________ -inline double NICE(double ang) -{ return fmod(ang+M_PI*11,M_PI*2)-M_PI;} -//______________________________________________________________________________ -/** - returns the node information in TPT representation - double x[6], : state, for a definition, in radial implementation - rad - radius at start (cm). See also comments - phi - azimuthal angle (in rad) - z - z-coord. (cm) - psi - azimuthal angle of pT vector (in rads) - tanl - tan(dip) =pz/pt - q/pt - - double cc[15] : error matrix of the state "x" rad is fixed - code definition adopted here, where: - - Units - ______|________________|____________ - phi*R | 0 1 2 3 4 | deg*cm - z0 | 1 5 6 7 8 | cm - tanl | 2 6 9 10 11 | 1 covar(i) - psi | 3 7 10 12 13 | deg - q/pt | 4 8 11 13 14 | e*1/(GeV/c) - ----------------------------------- - - and where phi = atan2(y0,x0)*(180 deg/pi) - R = sqrt(x0*x0 + y0*y0) - q/pt = icharge*invpt; (This is what the - radius of curvature actually - determines) -PhiPhi PhiZ PhiTan PhiPsi PhiPt - ZZ ZTan ZPsi ZPt - TanTan TanPsi TanPt - PsiPsi PsiPt - PtPt - - -*/ - -//_____________________________________________________________________________ -void getTpt(const StvNode *node,float x[6],float e[15]) -{ - enum {jRad=0,jPhi,jZ,jTan,jPsi,jPti}; -static const double DEG = 180./M_PI; -static double fak[6] = {1,DEG,1,1,DEG,1}; -static const int toUpp[15] = {0, - 1, 5, - 2, 6, 9, - 3, 7, 10, 12, - 4, 8, 11, 13, 14}; - - double xx[6],ee[15]; - const StvNodePars &fp = node->GetFP(); - if (node->GetType()==StvNode::kPrimNode) {fp.GetPrimial(xx,ee,&node->GetFE());} - else {fp.GetRadial (xx,ee,&node->GetFE());} - - for (int i=0;i<6;i++) {x[i] = (float)(xx[i]);} - if (!e) return; - - x[0] = (float)xx[0]; - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++) { - e[toUpp[li+j]] = (float)(ee[li+j]*fak[i+1]*fak[j+1]); - } } -} -//_____________________________________________________________________________ -void getDcaLocal(const StvNode *node,float yz[2],float yzErr[2]) -{ -static int nCall=0; nCall++; - const StvNodePars &fp = node->GetFP(); - double myTan = fp._tanl; - double cos2L = 1./(1+myTan*myTan); - double cosL = sqrt(cos2L); - double sinL = myTan*cosL; - double cosP = fp._cosCA; - double sinP = fp._sinCA; -// Track Frame - TMatrixD dcaFrame(3,3); - - dcaFrame[0][0] = cosL*cosP; - dcaFrame[0][1] = cosL*sinP; - dcaFrame[0][2] = sinL; - - dcaFrame[1][0] = -sinP; - dcaFrame[1][1] = cosP; - dcaFrame[1][2] = 0; - - dcaFrame[2][0] = -sinL*cosP; - dcaFrame[2][1] = -sinL*sinP; - dcaFrame[2][2] = cosL; - - StvHit *hit=node->GetHit(); - assert(hit); - const double *hrr=node->GetHE(); - double d[3]={ hit->x()[0]-fp._x, hit->x()[1]-fp._y,hit->x()[2]-fp._z}; - TVectorD dif(3,d); - TVectorD loc = dcaFrame*dif; - yz[0]= loc[1]; yz[1]= loc[2] ; - - yzErr[0] = (hrr[0] - node->GetFE().mHH); - yzErr[1] = (hrr[2] - node->GetFE().mZZ); - for (int j=0;j<2;j++){yzErr[j] = (yzErr[j]>1e-6)? sqrt(yzErr[j]):1e-3;} - - -} - -//_____________________________________________________________________________ -StvStEventFiller::StvStEventFiller() -{ - mMinHits = 5; mNorHits = 10; mGoodHits = 15; - mGloPri = 0; - mPullEvent=0; - - unsigned short bit = 1 << tpcOther; // shifting the "1" exactly tpcOther places to the left - mStvEncoded = kITKalmanFitId + bit; // adding that to the proper fitting Id - -} - -//_____________________________________________________________________________ -StvStEventFiller::~StvStEventFiller() -{ - cout <<"StvStEventFiller::~StvStEventFiller()"< - In addition to the StGlobalTrack, we need to create the following objects (owned by it): - StTrackTopologyMap - StTrackFitTraits - StTrackGeometry (2 are needed, one at first point, one at last point) - (note: StHelixModel is implementation of the StTrackGeometry abstract class) - - The track also owns a container of PidTraits, this algorithm will not fill this container. - - And set up links to: - StTrackDetectorInfo (owned by StEvent, StSPtrVecTrackDetectorInfo) - StTrackNode (owned by StEvent, StSPtrVecTrackNode) - These links are - track -> detector info - track <-> track node - - Skeleton of the algorithm: - \n - StSPtrVecTrackNode& trNodeVec = mEvent->trackNodes(); \n - StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo(); \n - for (trackIterator trackIt = mTracks->begin(); trackIt != mTracks->end(); ++trackIt) { \n - StvTrack* kTrack = (*trackIt).second; // the container is a , need second entry of \n -\n - StTrackDetectorInfo* detInfo = new StTrackDetectorInfo();\n - fillDetectorInfo(detInfo,kTrack);\n - detInfoVec.push_back(detInfo);\n - \n - StTrackNode* trackNode = new StTrackNode;\n - trNodeVec.push_back(trackNode);\n - \n - StGlobalTrack* gTrack = new StGlobalTrack();\n - fillGlobalTrack(gTrack,kTrack);\n - \n - // set up relationships between objects\n - gTrack->setDetectorInfo(detInfo);\n - gTrack->setNode(trackNode);\n - trackNode->AddTrack(gTrack);\n - }\n - - The creation of the various objects needed by StGlobalTrack are taken care of in the methods: - fillTopologyMap(), fillGeometry(), fillFitTraits(), which are called within fillGlobalTrack(). - -*/ -//_____________________________________________________________________________ -void StvStEventFiller::fillEvent() -{ - //cout << "StvStEventFiller::fillEvent() -I- Started"<trackNodes(); - StSPtrVecTrackDetectorInfo& detInfoVec = mEvent->trackDetectorInfo(); - int errorCount=0; - - memset(mUsedHits,0,sizeof(mUsedHits)); - memset(mUsedGits,0,sizeof(mUsedGits)); - int fillTrackCount1=0; - int fillTrackCount2=0; - int fillTrackCountG=0; - StErrorHelper errh; - mTrackNumber=0; - for (StvTrackConstIter trackIt = mTracks->begin(); trackIt!=mTracks->end();++trackIt) - { - const StvTrack* kTrack = (*trackIt); - if (!accept(kTrack)) continue; // get rid of riff-raff - mTrackNumber++; - StTrackDetectorInfo* detInfo = new StTrackDetectorInfo; - fillDetectorInfo(detInfo,kTrack,true); //3d argument used to increase/not increase the refCount. MCBS oct 04. - // track node where the new StTrack will reside - StTrackNode* trackNode = new StTrackNode; - // actual filling of StTrack from StvTrack - StGlobalTrack* gTrack = new StGlobalTrack; - { - fillTrackCount1++; - fillTrack(gTrack,kTrack,detInfo); - // filling successful, set up relationships between objects - detInfoVec.push_back(detInfo); - //cout <<"Setting key: "<<(unsigned short)(trNodeVec.size())<setKey(kTrack->GetId()); - gTrack->setIdTruth(); - trackNode->addTrack(gTrack); - trNodeVec.push_back(trackNode); - // reuse the utility to fill the topology map - // this has to be done at the end as it relies on - // having the proper track->detectorInfo() relationship - // and a valid StDetectorInfo object. - //cout<<"Tester: Event Track Node Entries: "<entries()<entries(global)<1) - cout << "StvStEventFiller::fillEvent() -E- Track Node has no entries!! -------------------------" << endl; - int ibad = gTrack->bad(); - errh.Add(ibad); - if (ibad) { -//VP printf("GTrack error: %s\n",errh.Say(ibad).Data()); -//VP throw runtime_error("StvStEventFiller::fillEvent() StTrack::bad() non zero"); - } - fillTrackCount2++; - fillPulls(kTrack,gTrack,0); - -assert(gTrack->fitTraits().numberOfFitPoints(kTpcId)<=gTrack->numberOfPossiblePoints(kTpcId)); -assert(gTrack->fitTraits().numberOfFitPoints( )<=gTrack->numberOfPossiblePoints( )); - if (gTrack->fitTraits().numberOfFitPoints()4) - cout << "There were "<trackDetectorInfo(); - cout << "StvStEventFiller::fillEventPrimaries() -I- Tracks in container:" << mTracks->size() << endl; - int mVertN=0; - int noPipe=0; - int ifcOK=0; - int fillTrackCount1=0; - int fillTrackCount2=0; - int fillTrackCountG=0; - StErrorHelper errh; - const StvTrack *kTrack = 0; - StPrimaryTrack *pTrack = 0; - StGlobalTrack *gTrack = 0; - StTrackNode *nTRack = 0; - mTrackNumber=0; - for (StvTrackConstIter tkIter= mTracks->begin(); tkIter!=mTracks->end();++tkIter) { - kTrack = *tkIter; - if (!accept(kTrack)) continue; - nTRack = gTrkNodeMap[kTrack]; - if (!nTRack) continue; - mTrackNumber++; - assert(nTRack->entries()<=10); - assert(nTRack->entries(global)==1); - - //double globalDca = nTRack->track(global)->impactParameter(); - //Even though this is filling of primary tracks, there are certain - // quantities that need to be filled for global tracks that are only known - // after the vertex is found, such as dca. Here we can fill them. - // - gTrack = static_cast(nTRack->track(global)); - assert(gTrack->key()==kTrack->GetId()); - float minDca = 1e10; //We do not know which primary. Use the smallest one - - pTrack = 0; - for (mVertN=0; (vertex = mEvent->primaryVertex(mVertN));mVertN++) { - StThreeVectorD vertexPosition = vertex->position(); -//VP double zPrim = vertexPosition.z(); - // loop over StvKalmanTracks - float globalDca = impactParameter(gTrack,vertexPosition); - if (fabs(minDca) > fabs(globalDca)) minDca = globalDca; - - if (kTrack->IsPrimary()!=mVertN+1) continue; - - fillTrackCount1++; - // detector info - StTrackDetectorInfo* detInfo = new StTrackDetectorInfo; - fillDetectorInfo(detInfo,kTrack,false); //3d argument used to increase/not increase the refCount. MCBS oct 04. - pTrack = new StPrimaryTrack; - pTrack->setKey( gTrack->key()); - - fillTrack(pTrack,kTrack, detInfo); - // set up relationships between objects - detInfoVec.push_back(detInfo); - - nTRack->addTrack(pTrack); // StTrackNode::addTrack() calls track->setNode(this); - vertex->addDaughter(pTrack); - fillPulls(kTrack,pTrack,1); - fillTrackCount2++; - int ibad = pTrack->bad(); - errh.Add(ibad); - if (ibad) { -//VP printf("PTrack error: %s\n",errh.Say(ibad).Data()); -//VP throw runtime_error("StvStEventFiller::fillEventPrimaries() StTrack::bad() non zero"); - } - if (pTrack->fitTraits().numberOfFitPoints()geometry()->momentum().mag()<0.1) break; - StDcaGeometry *myDca = gTrack->dcaGeometry(); - if (!myDca) break; - - fillTrackCountG++; - break; - } //end of verteces - if (fabs(minDca)<1000) { - gTrack->setImpactParameter(minDca); - if (pTrack) pTrack->setImpactParameter(minDca); - } - - } // kalman track loop - gTrkNodeMap.clear(); // need to reset for the next event - cout <<"StvStEventFiller::fillEventPrimaries() -I- Primaries (1):"<< fillTrackCount1<< " (2):"<< fillTrackCount2<< " no pipe node:"<getPointCount() later? -//_____________________________________________________________________________ -void StvStEventFiller::fillDetectorInfo(StTrackDetectorInfo* detInfo, const StvTrack* track, bool refCountIncr) -{ - //cout << "StvStEventFiller::fillDetectorInfo() -I- Started"<setNumberOfPoints(np,(StDetectorId)(i)); - assert((int)detInfo->numberOfPoints((StDetectorId)(i)) == np); - } - for (StvNodeConstIter it = track->begin();it!=track->end();++it) - { - node = (*it); - - - if (node->GetType() != StvNode::kRegNode) continue; - const StvHit *stiHit = GetHit(node); - if (!stiHit) continue; - - -// Count used hits for tracks tpc hits >10 - if (nTotHits >= mNorHits) { - int gid = node->GetDetId(); - if (mUsedHits[0]=mGoodHits) { - if (mUsedGits[0]stHit(); - FillStHitErr(hh,node); - - detInfo->addHit(hh,refCountIncr); - if (!refCountIncr) continue; - hh->setFitFlag(1); - } - node = track->GetNode(StvTrack::kLastPoint); - detInfo->setLastPoint (position(node)); - - node = track->GetNode(StvTrack::kFirstPoint); - detInfo->setFirstPoint (position(node)); - -} -//_____________________________________________________________________________ -void StvStEventFiller::fillGeometry(StTrack* gTrack, const StvTrack* track, bool outer) -{ - //cout << "StvStEventFiller::fillGeometry() -I- Started"<type() == primary) needType = StvTrack::kPrimPoint; - const StvNode* node = track->GetNode(needType); - assert(node); - StvHit *ihit = node->GetHit(); - StThreeVectorF nodpos(position(node)); - StThreeVectorF hitpos(position(ihit)); - - - // making some checks. Seems the curvature is infinity sometimes and - // the origin is sometimes filled with nan's... - - StTrackGeometry* geometry =new StHelixModel(short(getCharge(node)), - getPhi(node), - fabs(getCurvature(node)), - getDip(node), - nodpos, - getMom(node), - getHelicity(node)); - - if (outer) - gTrack->setOuterGeometry(geometry); - else - gTrack->setGeometry(geometry); - - - return; -} - -//_____________________________________________________________________________ -// void StvStEventFiller::fillTopologyMap(StTrack* gTrack, const StvTrack* track){ -// cout << "StvStEventFiller::fillTopologyMap()" << endl; -// int map1,map2; -// map1 = map2 = 0; -// // change: add code to set the bits appropriately here - -// StTrackTopologyMap topomap(map1,map2); -// gTrack->setTopologyMap(topomap); -// return; -// } - -//_____________________________________________________________________________ -void StvStEventFiller::fillFitTraits(StTrack* gTrack, const StvTrack* track) -{ -static int nCall=0; nCall++; - // mass - // this makes no sense right now... double massHyp = track->getMass(); // change: perhaps this mass is not set right? - unsigned short geantIdPidHyp = 9999; - //if (.13< massHyp<.14) - geantIdPidHyp = 9; - // chi square and covariance matrix, plus other stuff from the - // innermost track node - StvTrack::EPointType needNode = (track->IsPrimary())? StvTrack::kPrimPoint : StvTrack::kFirstPoint; - const StvNode* node = track->GetNode(needNode); - assert(node); - - float x[6],covMFloat[15]; - getTpt(node,x,covMFloat); - float chi2[2]; - //get chi2/dof - chi2[0] = track->GetXi2(); - chi2[1] = -999; // change: here goes an actual probability, need to calculate? - // December 04: The second element of the array will now hold the incremental chi2 of adding - // the vertex for primary tracks - if (gTrack->type()==primary) { - node = track->GetNode(StvTrack::kPrimPoint); - assert(!node->GetDetId()); - chi2[1]=node->GetXi2(); - } - - // setFitTraits uses assignment operator of StTrackFitTraits, which is the default one, - // which does a memberwise copy. Therefore, constructing a local instance of - // StTrackFitTraits is fine, as it will get properly copied. - StTrackFitTraits fitTraits(geantIdPidHyp,0,chi2,covMFloat); - // Now we have to use the new setters that take a detector ID to fix - // a bug. There is no encoding anymore. - - int dets[kMaxDetectorId][3]; - getAllPointCount(track,dets); - for (int i=1;itype()==primary) { - fitTraits.setPrimaryVertexUsedInFit(true); - } - gTrack->setFitTraits(fitTraits); - return; -} - -///_____________________________________________________________________________ -/// data members from StEvent/StTrack.h -/// The track flag (mFlag accessed via flag() method) definitions with ITTF -///(flag definition in EGR era can be found at http://www.star.bnl.gov/STAR/html/all_l/html/dst_track_flags.html) -/// -/// mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0) -/// x indicates the detectors included in the fit and -/// yy indicates the status of the fit. -/// Positive mFlag values are good fits, negative values are bad fits. -/// -/// The first digit indicates which detectors were used in the refit: -/// -/// x=1 -> TPC only -/// x=3 -> TPC + primary vertex -/// x=5 -> SVT + TPC -/// x=6 -> SVT + TPC + primary vertex -/// x=7 -> FTPC only -/// x=8 -> FTPC + primary -/// x=9 -> TPC beam background tracks -/// -/// The last two digits indicate the status of the refit: -/// = +x01 -> good track -/// -/// = -x01 -> Bad fit, outlier removal eliminated too many points -/// = -x02 -> Bad fit, not enough points to fit -/// = -x03 -> Bad fit, too many fit iterations -/// = -x04 -> Bad Fit, too many outlier removal iterations -/// = -x06 -> Bad fit, outlier could not be identified -/// = -x10 -> Bad fit, not enough points to start -/// -/// = -x11 -> Short track pointing to EEMC - -void StvStEventFiller::fillFlags(StTrack* gTrack) { - if (gTrack->type()==global) { - gTrack->setFlag(101); //change: make sure flag is ok - } - else if (gTrack->type()==primary) { - gTrack->setFlag(301); - } - const StTrackFitTraits &fitTrait = gTrack->fitTraits(); - int totFitPoints = fitTrait.numberOfFitPoints(); - const StTrackDetectorInfo *dinfo = gTrack->detectorInfo(); - if (dinfo) { - Int_t NoTpcFitPoints = dinfo->numberOfPoints(kTpcId); - // Check that it could be TPC pile-up track, i.e. in the same half TPC (West East) - // there are more than 2 hits with wrong Z -position - Int_t flag = TMath::Abs(gTrack->flag()); - if (NoTpcFitPoints >= 11) { - const StTrackDetectorInfo *dinfo = gTrack->detectorInfo(); - const StPtrVecHit& hits = dinfo->hits(kTpcId); - Int_t Nhits = hits.size(); - Int_t NoWrongSignZ = 0; - for (Int_t i = 0; i < Nhits; i++) { - const StTpcHit *hit = (StTpcHit *) hits[i]; - if ((hit->position().z() < -1.0 && hit->sector() <= 12) || - (hit->position().z() > 1.0 && hit->sector() > 12)) NoWrongSignZ++; - } - if (NoWrongSignZ >= 2) - gTrack->setFlag((flag%1000) + 1000); // +1000 - } - if (totFitPoints < mMinHits ) { - // hadrcoded number correspondant to __MIN_HITS_TPC__ 11 in StMuFilter.cxx - //keep most sig. digit, set last digit to 2, and set negative sign - gTrack->setFlag(-(((flag/100)*100)+2)); // -x02 - if (gTrack->geometry()) { - const StThreeVectorF &momentum = gTrack->geometry()->momentum(); - if (momentum.pseudoRapidity() > 0.5) { - const StPtrVecHit& hits = dinfo->hits(); - Int_t Nhits = hits.size(); - for (Int_t i = 0; i < Nhits; i++) { - const StHit *hit = hits[i]; - if (hit->position().z() > 150.0 -#ifdef kFtsIdentifier - ||hit->detector()==kFtsId -#endif - ) - { - gTrack->setFlag((((flag/100)*100)+11)); // +x11 - return; - } - } - } - } - } - } -} -//_____________________________________________________________________________ -void StvStEventFiller::fillTrack(StTrack* gTrack, const StvTrack* track,StTrackDetectorInfo* detInfo ) -{ - - //cout << "StvStEventFiller::fillTrack()" << endl; - // encoded method = 16 bits = 12 fitting and 4 finding, for the moment use: - // kKalmanFitId - // bit 15 for finding, (needs to be changed in StEvent). - // change: make sure bits are ok, are the bits set up one in each position and nothing else? - // this would mean that the encoded method is wasting space! - // the problem is that in principle there might be combinations of finders for each tracking detector - // but the integrated tracker will use only one for all detectors maybe - // so need this bit pattern: - // finding 100000000000 - // fitting 0010 - // 32768 + 2 = 32770; - // - // above is no longer used, instead use kITKalmanfitId as fitter and tpcOther as finding method - - gTrack->setEncodedMethod(mStvEncoded); - double tlen = track->GetLength(); - assert(tlen >0.0 && tlen<1500.); - gTrack->setLength(tlen);// someone removed this, grrrr!!!! - - // Follow the StDetectorId.h enumerations... - // can't include them from here in order not to - // create a package dependence... - int dets[kMaxDetectorId][3]; - getAllPointCount(track,dets); - for (int i=1;isetNumberOfPossiblePoints(np,(StDetectorId)i); - assert((int)gTrack->numberOfPossiblePoints((StDetectorId)i)==np); - } - - fillGeometry(gTrack, track, false); // inner geometry - fillGeometry(gTrack, track, true ); // outer geometry - fillFitTraits(gTrack, track); - gTrack->setDetectorInfo(detInfo); - StuFixTopoMap(gTrack); - fillFlags(gTrack); - if (!track->GetNode(StvTrack::kPrimPoint)) fillDca(gTrack,track); - return; -} -//_____________________________________________________________________________ -bool StvStEventFiller::accept(const StvTrack* track) -{ -// int nPossiblePoints = track->getMaxPointCount(0); -// int nMeasuredPoints = track->getPointCount (0); - int n=0; - for (StvNodeConstIter it = track->begin(); it !=track->end();++it) { - const StvNode *node = *it; - if (!node->IsFitted(2)) continue; - if (node->GetDetId()==kTpcId) { n++;} else {n+=2;} - - } - if (n < mMinHits ) return 0; - if(track->GetLength()<=0) return 0; - return 1; -} -//_____________________________________________________________________________ -double StvStEventFiller::impactParameter(StTrack* track, StThreeVectorD &vertex) -{ - StPhysicalHelixD helix = track->geometry()->helix(); - - //cout <<"PHelix: "<(stTrack); - assert(gTrack); - - const StvNode *tNode = track->GetNode(StvTrack::kDcaPoint); - if (!tNode) return; - const StvNodePars &pars = tNode->GetFP(); - const StvFitErrs &errs = tNode->GetFE(); - StvImpact myImp; - double signA = errs.Sign(); - if (signA<=0) { - Warning("fillDca","-TIVE input errors %g, SKIPPED",signA); - return; - } - pars.GetImpact(&myImp,&errs); - - double signB = StvFitErrs::EmxSign(5,&myImp.mImpImp); - if (signB<=0) { - Warning("fillDca","-TIVE DCA errors %g %g, SKIPPED",signA,signB); - return; - } - StDcaGeometry *dca = new StDcaGeometry; - gTrack->setDcaGeometry(dca); - dca->set(&myImp.mImp,&myImp.mImpImp); - assert(fabs(pars.getRxy()-fabs(dca->params()[0]))<1e-2*(1+pars.getRxy())); - stTrack->setImpactParameter(myImp.mImp); - -} -//_____________________________________________________________________________ -void StvStEventFiller::FillStHitErr(StHit *hh,const StvNode *node) -{ -#if 0 - double stiErr[6],stErr[6]; - memcpy(stiErr,node->hitErrs(),sizeof(stiErr)); - double alfa = node->getAlpha(); - double c = cos(alfa); - double s = sin(alfa); - double T[3][3]={{c,-s, 0} - ,{s, c, 0} - ,{0, 0, 1}}; - - TCL::trasat(T[0],stiErr,stErr,3,3); - StThreeVectorF f3(sqrt(stErr[0]),sqrt(stErr[2]),sqrt(stErr[5])); - hh->setPositionError(f3); -#endif //0 -} -//_____________________________________________________________________________ -void StvStEventFiller::fillPulls(const StvTrack* track, const StTrack *stTrack,int gloPri) -{ -static int nCall=0; nCall++; - //cout << "StvStEventFiller::fillDetectorInfo() -I- Started"<GetNode(pty); - if (!node) return; - - const StvNodePars &fp = node->GetFP(); - const StvFitErrs &fe = node->GetFE(); - int dets[kMaxDetectorId][3]; - getAllPointCount(track,dets); - StvPullTrk aux; - aux.mVertex = (unsigned char)track->IsPrimary(); - aux.mTrackNumber=track->GetId();; - aux.nAllHits = dets[0][2]; - aux.nTpcHits = dets[kTpcId][2]; - aux.nSsdHits = dets[kSsdId][2]; - aux.nFtpcHits = dets[kFtpcEastId][2]+dets[kFtpcWestId][2]; - aux.mL = (unsigned char)track->GetLength(); - aux.mTypeEnd = (unsigned char)track->GetTypeEnd(); - aux.mChi2 = track->GetXi2(); - aux.mChi2P = track->GetXi2P(); - - - aux.mCurv = fp._curv; - aux.mPt = fp.getPt(); - aux.mPsi = fp._psi; - aux.mDip = atan(fp._tanl); - StThreeVectorD v3(fp.P); - aux.mRxy = v3.perp(); - aux.mPhi = v3.phi(); - aux.mZ = v3.z(); - - aux.mPtErr = sqrt(fe.mPP)*aux.mPt*aux.mPt; - aux.mPsiErr = sqrt(fe.mAA); - aux.mDipErr = sqrt(fe.mLL); - aux.mRxyErr = sqrt(fe.mHH); - aux.mZErr = sqrt(fe.mZZ); - - aux.mIdTruTk = stTrack->idTruth(); - aux.mQaTruTk = stTrack->qaTruth(); - - mPullEvent->Add(aux,gloPri); - if (!gloPri) { - double ar[7]; - ar[0] = aux.mRxy*cos(aux.mPhi); - ar[1] = aux.mRxy*sin(aux.mPhi); - ar[2] = aux.mZ; - ar[3] = cos(aux.mDip)*cos(aux.mPsi); - ar[4] = cos(aux.mDip)*sin(aux.mPsi); - ar[5] = sin(aux.mDip); - ar[6] = aux.mCurv; - THelixTrack th(ar,ar+3,ar[6]); - double dL = th.Path(0.,0.); - th.Eval(dL,ar,ar+3); - aux.mDca00 = (-ar[0]*ar[4]+ar[1]*ar[3])/cos(aux.mDip); - } - - double len=0,preRho,preXy[2]; int myNode=0; - for (StvNodeConstIter tNode=track->begin();tNode!=track->end();++tNode) - { - const StvNode *node = (*tNode); - const StvHit *stiHit = GetHit(node); - if (!stiHit) continue; - StHit *hh = (StHit*)stiHit->stHit(); - assert(hh); - const StvNodePars &fp = node->GetFP(); - double dL = (stiHit->x()[0]-fp._x)*fp._cosCA - + (stiHit->x()[1]-fp._y)*fp._sinCA; - double myX = fp._x+dL*fp._cosCA; - double myY = fp._y+dL*fp._sinCA; - if (myNode) { - dL = sqrt(pow(preXy[0]-myX,2)+pow(preXy[1]-myY,2)); - double rho = 0.5*(preRho+fabs(fp._curv)); - double mySin = 0.5*dL*rho; if (mySin>0.99) break; - if (mySin>0.01) dL = 2*asin(mySin)/rho; - len+=dL; - } - myNode++;preXy[0]=myX; preXy[1]=myY; preRho = fabs(fp._curv); - - fillPulls(len,hh,stiHit,node,track,dets,gloPri); - - - if (gloPri) continue; - fillPulls(len,hh,stiHit,node,track,dets,2); - } -} -//_____________________________________________________________________________ - void StvStEventFiller::fillPulls(double len - ,StHit *stHit,const StvHit *stiHit - ,const StvNode *node - ,const StvTrack *track - ,int dets[1][3],int gloPriRnd) -{ - double x,y,z,r; - - -//const StvFitErrs &fe = node->GetFE(); - const StvNodePars &fp = node->GetFP(); - float yz[2],yzErr[2]; - getDcaLocal(node,yz,yzErr); - - StvPullHit aux; - aux.mIdTruth = stHit->idTruth(); - aux.mQaTruth = stHit->qaTruth(); - -// local frame -// local HIT - aux.mVertex = (unsigned char)track->IsPrimary(); -// aux.nHitCand = node->getHitCand(); -// aux.iHitCand = node->getIHitCand(); -// if (!aux.nHitCand) aux.nHitCand=1; - aux.lYHit = yz[0]; - aux.lZHit = yz[1]; - aux.lYHitErr = sqrt(node->GetHE()[0]); - aux.lZHitErr = sqrt(node->GetHE()[2]); - aux.lYPulErr = yzErr[0]; - aux.lZPulErr = yzErr[1]; - aux.lYPul = aux.lYHit/aux.lYPulErr; if (fabs(aux.lYPul)>10) aux.lYPul=10; - aux.lZPul = aux.lZHit/aux.lZPulErr; if (fabs(aux.lZPul)>10) aux.lZPul=10; - aux.lLen = len; - -// global frame - -// global Hit - const StHitPlane *hitPlane = stiHit->detector(); -// assert(hitPlane); - if (!hitPlane) return; //Temporary??????? - const float *n = hitPlane->GetDir(stiHit->x())[0]; - aux.gPhiHP = atan2(n[1],n[0]); - aux.gLamHP = asin(n[2]); - - x = stiHit->x()[0]; y = stiHit->x()[1]; z = stiHit->x()[2]; - r = sqrt(x*x+y*y); - - aux.gRHit = r; - aux.gPHit = atan2(y,x);aux.gPHit = NICE(aux.gPHit); - aux.gZHit = z; - - -// global Fit - x = fp._x; y = fp._y;z = fp._z; - r = sqrt(x*x+y*y); - aux.gRFit = r; - aux.gPFit = (atan2(y,x));aux.gPFit=NICE(aux.gPFit); - aux.gZFit = z; - - - - aux.gPsi = fp._psi; - aux.gDip = atan(fp._tanl); - - // invariant - aux.mCurv = fp._curv; - aux.mPt = fabs(1./fp._ptin); - aux.mCharge = stHit->charge(); - aux.mChi2 = node->GetXi2(); - aux.mDetector=node->GetDetId(); - aux.mTrackNumber=track->GetId(); - aux.nAllHits = dets[0][2]; - aux.nTpcHits = dets[kTpcId][2]; - aux.nFtpcHits = dets[kFtpcEastId][2]+dets[kFtpcWestId][2]; - aux.nSsdHits = dets[kSsdId][2]; - mPullEvent->Add(aux,gloPriRnd); - -} -//_____________________________________________________________________________ -const StvHit* StvStEventFiller::GetHit(const StvNode *node) const -{ - const StvHit* h = node->GetHit(); - if (!h) return 0; - if (node->GetType() != StvNode::kRegNode) return 0; - int detId= node->GetDetId(); - if (!detId) return 0; - if (!h->stHit()) return 0; - const StHitPlane *hitPlane = h->detector(); - if (!hitPlane) return 0; - if (node->GetXi2()>1000) return 0; - return h; -} - -//_____________________________________________________________________________ -void StvStEventFiller::getAllPointCount(const StvTrack *track,int count[1][3]) -{ -// output array actually is count[maxDetId+1][3] -// count[0] all detectors -// count[detId] for particular detector -// count[detId][0] == number of possible points -// count[detId][1] == number of measured points -// count[detId][2] == number of fitted points -enum {kPP=0,kMP=1,kFP=2}; - - memset(count[0],0,(kMaxDetectorId)*3*sizeof(int)); - StvNodeConstIter it; - - for (it=track->begin();it!=track->end();it++){ - const StvNode *node = (*it); - int detId= node->GetDetId(); - if (!detId) continue; - if (!node->GetHitPlane()) continue; -//fill possible points - count[0][kPP]++; count[detId][kPP]++; - const StvHit* h = GetHit(node); - if (!h ) continue; - count[0][kMP]++; count[detId][kMP]++; - count[0][kFP]++; count[detId][kFP]++; - } -} - -//_____________________________________________________________________________ -void StvEventFiller::SetCons(const StvKonst_st *kons) -{ - mMinHits=kons->mMinHits; - mNorHits=kons->mNorHits; - mGoodHits=kons->mGoodHits; -} diff --git a/StRoot/StvMaker/StvStEventFiller.h b/StRoot/StvMaker/StvStEventFiller.h deleted file mode 100755 index db3fb70fa6a..00000000000 --- a/StRoot/StvMaker/StvStEventFiller.h +++ /dev/null @@ -1,115 +0,0 @@ -//StvStEventFiller.h -/*************************************************************************** - * - * $Id: StvStEventFiller.h,v 1.8 2015/11/11 01:52:57 perev Exp $ - * - * Author: Manuel Calderon de la Barca Sanchez, Mar 2002 - * Author: Victor Perev, Jun 2010 - *************************************************************************** - * - * $Log: StvStEventFiller.h,v $ - * Revision 1.8 2015/11/11 01:52:57 perev - * Remove non used method setUseAux - * - * Revision 1.7 2015/06/10 17:28:08 perev - * Print of used hits (from Sti) added - * - * Revision 1.6 2013/10/02 20:23:00 perev - * kMinFitPoints 10 ==> 11 to be like Sti - * - * Revision 1.5 2012/10/21 22:57:22 perev - * Add IdTruth into pulls - * - * Revision 1.4 2012/04/27 01:40:19 perev - * Add konstant min hit number - * - * Revision 1.3 2012/04/10 22:41:54 perev - * Cleanup - * - * Revision 1.2 2010/09/29 23:39:12 perev - * Intereface fillPulls(...) chamnged - * - * Revision 1.1 2010/07/06 20:27:53 perev - * Alpha version of Stv (Star Tracker Virtual) - * - * Revision 1.2 2010/07/03 16:27:15 perev - * Last time name Stv - * - * Revision 1.1 2010/06/22 19:34:28 perev - * EventFiller added - * - * Revision 2.24 2006/12/18 01:30:52 perev - * fillPulls reorganized - * - * - **************************************************************************/ -#ifndef StvStEventFiller_HH -#define StvStEventFiller_HH -#include "StDetectorId.h" - -enum ECuts { kMinFitPoints=11 }; - - -class StEvent; -class StTrackNode; -class StTrackDetectorInfo; -class StvNode; -class StvHit; -class StTrack; -class StvPullEvent; -#include "StvEventFiller.h" -#include "StThreeVectorD.hh" -//class StHelix; -//class StHelixModel; -#include "StPhysicalHelixD.hh" - -/*! \class StvStEventFiller - StvStEventFiller is a utilitity class meant to properly convert StvTrack - objects into StTrack (Global/Primary) objects and hang these on the StEvent - Track-node. - - \author Manuel Calderon de la Barca Sanchez (Yale Software) - Rewritten for StvVmc - \author Victor Perev (BNL) - - */ -class StvStEventFiller : public StvEventFiller -{ -public: - StvStEventFiller(); - virtual ~StvStEventFiller(); - void fillEvent(); - void fillEventPrimaries(); - void fillDetectorInfo(StTrackDetectorInfo* detInfo, const StvTrack* kTrack,bool refCountIncr); - void fillGeometry(StTrack* track, const StvTrack* kTrack, bool outer); - //void fillTopologyMap(StTrack* track, const StvTrack* kTrack); - void fillFitTraits(StTrack* track, const StvTrack* kTrack); - void fillTrack(StTrack* track, const StvTrack* kTrack,StTrackDetectorInfo* detInfo ); - void fillDca(StTrack* track, const StvTrack* kTrack); - void fillFlags(StTrack* track); - double impactParameter(StTrack* strack , StThreeVectorD &vertexPosition); - void setPullEvent(StvPullEvent *pe) {mPullEvent=pe;} - void getAllPointCount(const StvTrack *track,int count[1][3]); - const StvHit *GetHit(const StvNode *node) const; -private: - void fillResHack(StHit *hh,const StvHit *stiHit, const StvNode *node); - void fillPulls (double len,StHit *hh,const StvHit *stiHit - ,const StvNode *node - ,const StvTrack *track - ,int dets[1][3],int gloPri); - void fillPulls (const StvTrack *ktrack,const StTrack *stTrack,int gloPri); - bool accept(const StvTrack* kTrack); - void FillStHitErr(StHit *hh,const StvNode *node); - -private: - int mGloPri; //0=filing global,1=filing primary - int mTrackNumber; - int mUsedHits[100]; - int mUsedGits[100]; - - unsigned short mStvEncoded; - - -}; - -#endif diff --git a/StRoot/StvMaker/StvStEventHitSelector.cxx b/StRoot/StvMaker/StvStEventHitSelector.cxx deleted file mode 100644 index 5b01ee18677..00000000000 --- a/StRoot/StvMaker/StvStEventHitSelector.cxx +++ /dev/null @@ -1,56 +0,0 @@ - -// $Id: StvStEventHitSelector.cxx,v 1.1 2013/05/24 16:35:42 perev Exp $ -/*! -\author V Perev 2013 - -Hit selector. Using track info, marks selected hits. Used for hit error fit -to use only hits from "good" tracks -
      -*/ -#include "StEvent/StEvent.h" -#include "StEvent/StHit.h" -#include "StEvent/StTrack.h" -#include "StEvent/StTrackGeometry.h" -#include "StEvent/StTrackNode.h" -#include "StEvent/StTrackDetectorInfo.h" -#include "StarClassLibrary/StThreeVectorF.hh" -#include "StvStEventHitSelector.h" - - -ClassImp(StvStEventHitSelector) - -//_____________________________________________________________________________ -StvStEventHitSelector::StvStEventHitSelector(const char *name) : TNamed(name,"") -{ - mPtMin = 0.5; -} - -//_____________________________________________________________________________ -int StvStEventHitSelector::Edit(const StEvent *event) -{ - - int nSel = 0; - if (!event) return 0; - const StSPtrVecTrackNode& trackNode = event->trackNodes(); - int nTracks = trackNode.size(); - if (!nTracks) return -1; //No track info - for (int itk=0; itk < nTracks; itk++) { - StTrackNode *node = trackNode[itk]; - if (!node) continue; - StTrack *glTrack = node->track(global); - if (!glTrack) continue; - StTrackGeometry *geo = glTrack->geometry(); - if (!geo) continue; - StThreeVectorF mom = geo->momentum(); - if (mom.perp2()< mPtMin*mPtMin) continue; - const StPtrVecHit& hits = glTrack->detectorInfo()->hits(); - int nHits = hits.size(); - if (nHits <15) continue; - for(int ih=0; ihSetBit(kMarked); nSel++; - } - } - return nSel; -} diff --git a/StRoot/StvMaker/StvStEventHitSelector.h b/StRoot/StvMaker/StvStEventHitSelector.h deleted file mode 100644 index 960623ac65e..00000000000 --- a/StRoot/StvMaker/StvStEventHitSelector.h +++ /dev/null @@ -1,24 +0,0 @@ -//StvStEventHitSelector.h - -#ifndef StvStEventHitSelector_HH -#define StvStEventHitSelector_HH - - -#include "TNamed.h" -class StEvent; - -class StvStEventHitSelector : public TNamed -{ - public: - enum {kMarked = 1}; - public: - StvStEventHitSelector(const char* name = "HitSelector"); - int Edit(const StEvent *evt); - void SetPtMin(double pt) { mPtMin = pt;} -private: -double mPtMin; - -ClassDef(StvStEventHitSelector,0) -}; - -#endif diff --git a/StRoot/StvMaker/StvStEventMaker.cxx b/StRoot/StvMaker/StvStEventMaker.cxx deleted file mode 100644 index 1b2011d6ce8..00000000000 --- a/StRoot/StvMaker/StvStEventMaker.cxx +++ /dev/null @@ -1,53 +0,0 @@ - -// $Id: StvStEventMaker.cxx,v 1.2 2013/05/24 16:35:00 perev Exp $ -/*! -\author V Perev 2030 - -A maker StvStEventMaker remove all redundant info from StEvent -if StEvent is used for input. Only TpcHits must survive -
      -*/ -#include "StEvent/StEvent.h" -#include "StvStEventMaker.h" -ClassImp(StvStEventMaker) - -//_____________________________________________________________________________ -StvStEventMaker::StvStEventMaker(const char *name) : StMaker(name) -{ -} - -//_____________________________________________________________________________ -Int_t StvStEventMaker::Make() -{ - - StEvent *event = (StEvent*)GetInputDS("StEvent"); - if (!event) return kStOK; - StSPtrVecObject& V = event->content(); - int n = V.size(); - for (int i=0; iClassName(),"Hit" )) continue; - if (strstr(to->ClassName(),"Track")) continue; - V[i] = 0; delete to; - } - return kStOK; -} -//_____________________________________________________________________________ -StvStEventMaker* StvStEventMaker::Inst() -{ - StMaker *mk = StMaker::GetChain(); - assert(mk); -// Search of StIOMaker::inputStream - mk = mk->GetMaker("inputStream"); - if (!mk) return 0; - assert(strcmp(mk->ClassName(),"StIOMaker")==0); - StvStEventMaker *myMaker = new StvStEventMaker; - TDataSet *par = myMaker->GetParent(); - par->Remove(myMaker); - par = mk->GetParent(); - TList* tl= par->GetList(); - tl->AddAfter(mk,myMaker); - myMaker->SetParent(par); - return myMaker; -} diff --git a/StRoot/StvMaker/StvStEventMaker.h b/StRoot/StvMaker/StvStEventMaker.h deleted file mode 100644 index 4f076de19c0..00000000000 --- a/StRoot/StvMaker/StvStEventMaker.h +++ /dev/null @@ -1,22 +0,0 @@ -//StvStEventMaker.h - -#ifndef StvStEventMaker_HH -#define StvStEventMaker_HH - - -#include "StMaker.h" - - -class StvStEventMaker : public StMaker -{ - public: - - StvStEventMaker(const char* name = "StvStEvent"); - virtual Int_t Make(); - static StvStEventMaker* Inst(); - virtual const char* GetCVS() const - {static const char cvs[]="Tag $Name: $ $Id: StvStEventMaker.h,v 1.3 2018/01/28 00:49:01 perev Exp $ built " __DATE__ " " __TIME__; return cvs;} - ClassDef(StvStEventMaker,0) -}; - -#endif diff --git a/StRoot/StvMaker/StvStarVertexFinder.cxx b/StRoot/StvMaker/StvStarVertexFinder.cxx deleted file mode 100644 index b84eae9b3ca..00000000000 --- a/StRoot/StvMaker/StvStarVertexFinder.cxx +++ /dev/null @@ -1,90 +0,0 @@ -#include "StvMaker/StvStarVertexFinder.h" -#include "Stv/StvHit.h" -#include "StThreeVectorF.hh" -#include "StMatrixF.hh" -#include "StEvent.h" -#include "StPrimaryVertex.h" -#include "StGenericVertexMaker/StGenericVertexMaker.h" -#include "StGenericVertexMaker/StGenericVertexFinder.h" -#include "StMaker.h" -#include "StvUtil/StvNodePars.h" - - -//______________________________________________________________________________ -StvStarVertexFinder::StvStarVertexFinder(const char *name) - : StvVertexFinder(name) -{mGVF=0;} - -//______________________________________________________________________________ -StvStarVertexFinder::~StvStarVertexFinder() -{} -//______________________________________________________________________________ -void StvStarVertexFinder::Clear(const char*) -{ - if (mGVF) mGVF->Clear(); - StvVertexFinder::Clear(); -} - -//______________________________________________________________________________ -/// Return the main vertex held by the given StEvent -/// A null pointer is returned if StEvent holds no valid -/// vertex. -//______________________________________________________________________________ -int StvStarVertexFinder::Fit(StEvent * event) -{ - cout <<"StvStarVertexFinder::fit(StEvent * event) -I- Started"<GetMaker("GenericVertex"); - if ( gvm ){ - mGVF = gvm->GetGenericFinder(); - assert(mGVF); - } else { - LOG_WARN << "Could not find a GenericVertex instance" << endm; - } - } - //AAR - modified - // changed to fill primary vert only if fit returns true (okay) - int nVtx=0; - if ( mGVF ){ - Clear(); // this calls mGVF->Clear() requiring knowing about GenericVertex - nVtx = mGVF->fit(event); - if(nVtx){ - //vertex fit returns okay, so save - mGVF->FillStEvent(event); - } - } - return nVtx; - -} - -//______________________________________________________________________________ -/// Return the main vertex held by the given StEvent -/// A null pointer is returned if StEvent holds no valid -/// vertex. -//______________________________________________________________________________ -int StvStarVertexFinder::GetVertex(int idx,double x[3],double e[6]) -{ - if (!mGVF) return 1; - StPrimaryVertex *spv = mGVF->getVertex(idx); - if (!spv) return 2; - - // Get an instance of StHit from the factory - const StThreeVectorF& vp = spv->position(); - StMatrixF cov = spv->covariantMatrix(); - - cout <<"StvStarVertexFinder::GetVertex("<IsFixed() || StvFitErrs::EmxSign(3,e)>0); - return 0; -} diff --git a/StRoot/StvMaker/StvStarVertexFinder.h b/StRoot/StvMaker/StvStarVertexFinder.h deleted file mode 100644 index 5dc9685253d..00000000000 --- a/StRoot/StvMaker/StvStarVertexFinder.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef StvStarVertexFinder_H -#define StvStarVertexFinder_H 1 -#include "Stv/StvVertexFinder.h" -class StGenericVertexFinder; -class StvStarVertexFinder : public StvVertexFinder -{ -public: - StvStarVertexFinder(const char* name); - virtual ~StvStarVertexFinder(); - int Fit(StEvent*); // fit the vertex - void Clear(const char *opt=0); -private: - int GetVertex(int index,double xyz[3],double err[6]); -private: -StGenericVertexFinder* mGVF; -}; - - -#endif diff --git a/StRoot/StvMaker/StvTpcActive.cxx b/StRoot/StvMaker/StvTpcActive.cxx deleted file mode 100644 index 94c28e74914..00000000000 --- a/StRoot/StvMaker/StvTpcActive.cxx +++ /dev/null @@ -1,221 +0,0 @@ -#include -#include -#include -#include -#include "StvTpcActive.h" -#include "StEvent/StEnumerations.h" -#include "TGeoManager.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "TGeoVolume.h" - -#include "StDetectorDbMaker/St_tpcRDOMasksC.h" -#include "StDetectorDbMaker/St_tpcAnodeHVavgC.h" -#include "StDetectorDbMaker/St_tpcPadGainT0BC.h" - - -// This is from file g2t_volume_is.g -// nbpads = 73 -// tpads = { 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, -// 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, -// 7, 8, 8, 8, 9, 9, 9,10,10,10, -// 11,11,11,12,12,12,13,13,13,14, -// 14,15,16,17,18,19,20,21,22,23, -// 24,25,26,27,28,29,30,31,32,33, -// 34,35,36,37,38,39,40,41,42,43, -// 44,45,45}; -// -// isdets = { 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, -// 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, -// 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, -// 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -// 0, 0, 2 }; -enum {kNGPads=73,kNTPads=45}; -static const double kZPrompt = 205; - -static const int TPADS[kNGPads]={ -1, 1, 1, 2, 2, 2, 3, 3, 3, 4, -4, 4, 5, 5, 5, 6, 6, 6, 7, 7, -7, 8, 8, 8, 9, 9, 9,10,10,10, -11,11,11,12,12,12,13,13,13,14, -14,15,16,17,18,19,20,21,22,23, -24,25,26,27,28,29,30,31,32,33, -34,35,36,37,38,39,40,41,42,43, -44,45,45}; - -static const int RPADS[kNGPads]={ - 0, 1, 0, 0, 2, 0, 0, 3, 0, 0 -, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7 -, 0, 0, 8, 0, 0, 9, 0, 0,10, 0 -, 0,11, 0, 0,12, 0, 0,13, 0, 0 -,14,15,16,17,18,19,20,21,22,23 -,24,25,26,27,28,29,30,31,32,33 -,34,35,36,37,38,39,40,41,42,43 -,44,45, 0}; -static const int GPADS[kNTPads]={ - 2, 5, 8,11,14,17,20,23,26,29 -,32,35,38,41,42,43,44,45,46,47 -,48,49,50,51,52,53,54,55,56,57 -,58,59,60,61,62,63,64,65,66,67 -,68,69,70,71,72}; - -static const int ISDETS[kNGPads]={ -1, 0, 2, 1, 0, 2, 1, 0, 2, 1, -0, 2, 1, 0, 2, 1, 0, 2, 1, 0, -2, 1, 0, 2, 1, 0, 2, 1, 0, 2, -1, 0, 2, 1, 0, 2, 1, 0, 2, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 2}; - -ClassImp(StvTpcActive) - -//______________________________________________________________________________ -StvTpcActive::StvTpcActive(const char *name):StActorFunctor(name) -{ - memset(mBeg,0,mEnd-mBeg+1); -} -//______________________________________________________________________________ -int StvTpcActive::VoluId() -{ - - if (GetDetId() != kTpcId) return 0; - if (strncmp(GetVolu()->GetName(),"TPA",3)) return 0; - int numbv[3]; - GetIPath(3,numbv); - int tpgv = numbv[2]; - int tpss = numbv[1]; - mSector= tpss+12*(tpgv-1); - mGPad = numbv[0]; - -// tpad >nbpads (73) prompt hits - mPrompt = 0; - if (mGPad > kNGPads) { mGPad -= kNGPads; mPrompt = 1; } - mIsDet = ISDETS[mGPad-1]; - mTPad = RPADS [mGPad-1]; - return 100000*mIsDet+100*mSector+mTPad; -} -//______________________________________________________________________________ -int StvTpcActive::operator()( const double *) -{ -static St_tpcRDOMasksC *pRdoMasks = St_tpcRDOMasksC::instance(); -static St_tpcAnodeHVavgC *tpcAnodeHVavgC = St_tpcAnodeHVavgC::instance(); -static St_tpcPadGainT0BC *tpcPadGainT0BC = St_tpcPadGainT0BC::instance(); - - - if (!VoluId()) return 0; - if (!mTPad) return 0; - int iRdo = pRdoMasks->rdoForPadrow(mTPad); - int iact = pRdoMasks->isOn(mSector, iRdo); - if (!iact) return 0; - - iact = tpcAnodeHVavgC->livePadrow(mSector,mTPad) - && tpcPadGainT0BC->livePadrow(mSector,mTPad); - - return iact; -} - -ClassImp(StvTpcSelector) - -//______________________________________________________________________________ -StvTpcSelector::StvTpcSelector(const char *name):StvTpcActive(name) -{ - mInOut=-99; - TString ts(name); - if (ts.Index("Inner" ,0,TString::kIgnoreCase)>-1) mInOut =0; - if (ts.Index("Outer" ,0,TString::kIgnoreCase)>-1) mInOut =1; - if (ts.Index("Prompt",0,TString::kIgnoreCase)>-1) mInOut+=2; - assert(mInOut>=0); -} -//______________________________________________________________________________ -int StvTpcSelector::operator()(const double xyz[3]) -{ - - if (!VoluId()) return 0; - if (!mTPad) return 0; - if ((mTPad>13 ) != (mInOut&1 )) return 0; - if ((mPrompt==0) != ((mInOut&2)==0)) return 0; - return 1; -} - - -ClassImp(StvTpcEdit) - -//______________________________________________________________________________ -StvTpcEdit::StvTpcEdit():StvTpcActive("TpcEdit") -{ -} -//______________________________________________________________________________ -int StvTpcEdit::operator()( const double *) -{ -static StTGeoProxy *tg = StTGeoProxy::Inst(); - if (!VoluId()) return 0; - const TGeoVolume *vol = GetVolu(); - assert(vol); - if (!tg->IsSensitive(vol)) return 0; - StHitPlaneInfo* inf = tg->IsHitPlane(vol); - if (!inf) return 0; - const char *path = GetPath(); - StHitPlane *hp = inf->GetHitPlane(path); - if (!hp) return 0; - if (mTPad) return 0; //Not fake volume - hp=inf->RemHitPlane(path); - delete hp; - return 1; -} -//______________________________________________________________________________ -int StvTpcPrompt::operator()(const double xyz[3]) -{ - - if (!VoluId()) return 0; - if (!mTPad) return 0; - if (!mPrompt) return 0; - return 123; -} -//______________________________________________________________________________ -#include "StEvent/StTpcHit.h" -#include "Stv/StvHit.h" -// Workaround of bug in StTpcHit::padrow() -#include "StDetectorDbMaker/St_tpcPadPlanesC.h" -// End of workaround - -//______________________________________________________________________________ -int StvTpcHitActor::operator()(const double xyz[3]) -{ -static int nCall = 0; nCall++; -static const int kMaxRows = St_tpcPadPlanesC::instance()->numberOfRows(); -static const int iSect[24] = {23,22,21,20,19,18,17,16,15,14,13,24 - ,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1,12}; - assert(mHit); - TString path(GetPath()); - if (mDetId != kTpcId) return 0; - int jTPCE = path.Index("TPCE"); - if (jTPCE<0) return 0; - StvHit *hit = (StvHit *)mHit; - StTpcHit *tpcHit = (StTpcHit*)hit->stHit(); - - int sector = tpcHit->sector(); - if ((sector<=12) != (xyz[2]>0)) { - sector = iSect[sector-1];// pileup tracks with wrong Z - } - int tpadrow = tpcHit->padrow(); - -// Workaround of bug int StTpcHit::padrow() - if (tpadrow>kMaxRows) tpadrow &= 0x3F; -// End of workaround - - int gpadrow = GPADS[tpadrow-1]; - if (fabs(xyz[2]) > kZPrompt) gpadrow+=kNGPads; - int tpgv = 1; if (sector>12) {tpgv = 2; sector-=12;} - path.Remove(jTPCE+6,99); - path+="/TPGV_"; path+=tpgv; - path+="/TPSS_"; path+=sector; - if (tpadrow<=13) { path+="/TPAD_";} else { path+="/TPA1_"; } - path+=gpadrow; - int ok = gGeoManager->cd(path); - assert(ok); - return 1; -} diff --git a/StRoot/StvMaker/StvTpcActive.h b/StRoot/StvMaker/StvTpcActive.h deleted file mode 100644 index 255f8918012..00000000000 --- a/StRoot/StvMaker/StvTpcActive.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef __StvTpcActive_h_ -#define __StvTpcActive_h_ -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StvTpcActive: public StActorFunctor -{ -public: - StvTpcActive(const char *name=""); -virtual ~StvTpcActive(){} -virtual int operator()(const double xyz[3]=0); -int VoluId(); -protected: -char mBeg[1]; -int mSector; -int mIsDet; -int mGPad; //Padrow number including all non physical -int mTPad; //Padrow number including only physical -int mPrompt; //It is a prompt hit , -char mEnd[1]; - -ClassDef(StvTpcActive,0) -}; - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StvTpcSelector: public StvTpcActive -{ -public: - StvTpcSelector(const char *name); -virtual ~StvTpcSelector(){} -virtual int operator()(const double xyz[3]); -protected: -int mInOut; - -ClassDef(StvTpcSelector,0) -}; - - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StvTpcEdit: public StvTpcActive -{ -public: - StvTpcEdit(); - ~StvTpcEdit(){} -int operator()(const double xyz[3]=0); -protected: - -ClassDef(StvTpcEdit,0) -}; -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ - -class StvTpcPrompt: public StvTpcActive -{ -public: - StvTpcPrompt(){;} - ~StvTpcPrompt(){;} -int operator()(const double xyz[3]=0); -protected: - -ClassDef(StvTpcPrompt,0) -}; -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ - -class StvTpcHitActor: public StvTpcActive -{ -public: - StvTpcHitActor(){;} - ~StvTpcHitActor(){;} -int operator()(const double xyz[3]=0); -protected: - -ClassDef(StvTpcHitActor,0) -}; -#endif diff --git a/StRoot/StvSeed/StvCASeedFinder.cxx b/StRoot/StvSeed/StvCASeedFinder.cxx deleted file mode 100644 index bf03007f1fd..00000000000 --- a/StRoot/StvSeed/StvCASeedFinder.cxx +++ /dev/null @@ -1,322 +0,0 @@ -#if 0 //Temporary OFF -#include -#include -#include -#include -#include -#include "TCernLib.h" -#include "StvCASeedFinder.h" -#include "StMultiKeyMap.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" - -#include "StEvent/StEnumerations.h" -#include "StEvent/StTpcHit.h" - -#include "StDbUtilities/StTpcCoordinateTransform.hh" -#include "StDbUtilities/StGlobalCoordinate.hh" -#include "StDbUtilities/StTpcLocalSectorCoordinate.hh" - -#include "Stv/StvHit.h" -#include "THelixTrack.h" -//#define APPROX_DEBUG -#include "StarMagField/StarMagField.h" -#include "StvUtil/StvHitErrCalculator.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvDraw.h" -#include "Stv/StvHit.h" - -#define ENABLE_VECTORIZATION -#include "TPCCATracker/code/AliHLTTPCCAGBHit.h" -#include "TPCCATracker/code/AliHLTTPCCAGBTrack.h" -#include "TPCCATracker/code/AliHLTTPCCAParam.h" -#include "TPCCATracker/code/AliHLTTPCCAGBTracker.h" - -// -// static double innerR[13] = {60.000, 64.800, 69.600, 74.400, 79.200, // 5 -// 84.000, 88.800, 93.600, 98.800, 104.000, // 10 -// 109.200, 114.400, 119.600}; -// static double outerR[32] = {127.195, 129.195, // 15 -// 131.195, 133.195, 135.195, 137.195, 139.195, // 20 -// 141.195, 143.195, 145.195, 147.195, 149.195, // 25 -// 151.195, 153.195, 155.195, 157.195, 159.195, // 30 -// 161.195, 163.195, 165.195, 167.195, 169.195, // 35 -// 171.195, 173.195, 175.195, 177.195, 179.195, // 40 -// 181.195, 183.195, 185.195, 187.195, 189.195};// 45 - -static const int NumberOfPadsAtRow[45] = { - 88, 96,104,112,118,126,134,142,150,158, // Inner - 166,174,182, - 98,100,102,104,106,106,108, // Outer - 110,112,112,114,116,118,120,122,122,124, - 126,128,128,130,132,134,136,138,138,140, - 142,144,144,144,144 -}; -static const int kNSlices = 24; //TODO initialize from StRoot -static const int kNRows = 45; - -static float rRows[kNRows] = - {60.000, 64.800, 69.600, 74.400, 79.200, // 5 //TODO initialize from StRoot - 84.000, 88.800, 93.600, 98.800, 104.000, // 10 - 109.200, 114.400, 119.600, - 127.195, 129.195, // 15 - 131.195, 133.195, 135.195, 137.195, 139.195, // 20 - 141.195, 143.195, 145.195, 147.195, 149.195, // 25 - 151.195, 153.195, 155.195, 157.195, 159.195, // 30 - 161.195, 163.195, 165.195, 167.195, 169.195, // 35 - 171.195, 173.195, 175.195, 177.195, 179.195, // 40 - 181.195, 183.195, 185.195, 187.195, 189.195};// 45 - -typedef std::complex myComplex; -static const double kToRad = M_PI/180; -static const myComplex kIm = myComplex(0,1); - -static const myComplex sectAng[24] = { -exp(-kIm*kToRad* 60.),exp(-kIm*kToRad* 30.),exp(-kIm*kToRad* 0.), -exp( kIm*kToRad* 30.),exp( kIm*kToRad* 60.),exp( kIm*kToRad* 90.), -exp( kIm*kToRad*120.),exp( kIm*kToRad*150.),exp(-kIm*kToRad*180.), -exp(-kIm*kToRad*150.),exp(-kIm*kToRad*120.),exp(-kIm*kToRad* 90.), - -exp(-kIm*kToRad*120.),exp(-kIm*kToRad*150.),exp(-kIm*kToRad*180.), -exp( kIm*kToRad*150.),exp( kIm*kToRad*120.),exp( kIm*kToRad* 90.), -exp( kIm*kToRad* 60.),exp( kIm*kToRad* 30.),exp( kIm*kToRad* 0.), -exp(-kIm*kToRad* 30.),exp(-kIm*kToRad* 60.),exp(-kIm*kToRad* 90.)}; - - - -class AliHLTTPCCAParamVector: public std::vector{}; -class AliHLTTPCCAGBHitVector :public std::vector{}; -class IdTruthVector :public std::vector {}; - - -ClassImp(StvCASeedFinder) -//_____________________________________________________________________________ -StvCASeedFinder::StvCASeedFinder(const char *name):StvSeedFinder(name) -{ - memset(mBeg,0,mEnd-mBeg+1); - fTracker = new AliHLTTPCCAGBTracker; - fCaParam = new AliHLTTPCCAParamVector; - fCaHits = new AliHLTTPCCAGBHitVector; - fIdTruth = new IdTruthVector; - Clear(); -} -//_____________________________________________________________________________ -void StvCASeedFinder::Clear(const char*) -{ - memset(mBeg,0,mMed-mBeg+1); - fTracker->StartEvent(); - fCaParam->clear(); // settings for all sectors to give CATracker - fCaHits->clear(); // hits to give CATracker - fIdTruth->clear(); // id of the Track, which has created CaHit -} -//_____________________________________________________________________________ -void StvCASeedFinder::Reset() -{ - memset(mBeg,0,mMed-mBeg+1); -} -//_____________________________________________________________________________ -void StvCASeedFinder::MakeSettings() -{ - for ( int iSlice = 0; iSlice < kNSlices; iSlice++ ) { - AliHLTTPCCAParam SlicePar; - memset(&SlicePar, 0, sizeof(AliHLTTPCCAParam)); - - int sector = iSlice+1; - // int sector = iSlice; - SlicePar.SetISlice( iSlice ); - SlicePar.SetNRows ( kNRows ); - double beta = 0; - if (sector > 12) beta = (24-sector)*2.*TMath::Pi()/12.; - else beta = sector *2.*TMath::Pi()/12.; - SlicePar.SetAlpha ( beta ); - SlicePar.SetDAlpha ( 30*TMath::DegToRad() ); //TODO initialize from StRoot - SlicePar.SetCosAlpha ( TMath::Cos(SlicePar.Alpha()) ); - SlicePar.SetSinAlpha ( TMath::Sin(SlicePar.Alpha()) ); - SlicePar.SetAngleMin ( SlicePar.Alpha() - 0.5*SlicePar.DAlpha() ); - SlicePar.SetAngleMax ( SlicePar.Alpha() + 0.5*SlicePar.DAlpha() ); - SlicePar.SetRMin ( 51. ); //TODO initialize from StRoot - SlicePar.SetRMax ( 194. ); //TODO initialize from StRoot - SlicePar.SetErrX ( 0. ); //TODO initialize from StRoot - SlicePar.SetErrY ( 0.12 ); // 0.06 for Inner //TODO initialize from StRoot - SlicePar.SetErrZ ( 0.16 ); // 0.12 for Inner NodePar->fitPars() //TODO initialize from StRoot - // SlicePar.SetPadPitch ( 0.675 );// 0.335 -"- - float x[3]={0,0,0},b[3]; - StarMagField::Instance()->BField(x,b); - SlicePar.SetBz ( - b[2] ); // change sign because change z - if (sector <= 12) { - SlicePar.SetZMin ( 0. ); //TODO initialize from StRoot - SlicePar.SetZMax ( 210. ); //TODO initialize from StRoot - } else { - SlicePar.SetZMin (-210. ); //TODO initialize from StRoot - SlicePar.SetZMax ( 0. ); //TODO initialize from StRoot - } - for( int iR = 0; iR < kNRows; iR++){ - SlicePar.SetRowX(iR, rRows[iR]); - } -#if 1 - SlicePar.SetRecoType(1); //Stv hiterr parametrisation - const double *coeffInner = StvHitErrCalculator::Inst("StvTpcInnerHitErrs")->GetPars(); - for(int iCoef=0; iCoef<6; iCoef++) - { - SlicePar.SetParamS0Par(0, 0, iCoef, (float)coeffInner[iCoef] ); - } - SlicePar.SetParamS0Par(0, 0, 6, 0.0f ); - const double *coeffOuter = StvHitErrCalculator::Inst("StvTpcOuterHitErrs")->GetPars(); - for(int iCoef=0; iCoef<6; iCoef++) - { - SlicePar.SetParamS0Par(0, 1, iCoef, (float)coeffOuter[iCoef] ); - } -#endif -#if 0 //Hack - SlicePar.SetRecoType(0); //Stv hiterr parametrisation - float inn[6]= {0.000944592291, 0.00096804701, 0.0307030007 - ,0.005380766 , 0.00276213209, 0.0185125507}; - - float out[6]= {0.00119955395, 0.000499619695, 0.0558479801 - ,0.0100383796 , 0.000534858496, 0.0479304604}; - - for(int iCoef=0; iCoef<6; iCoef++) - { - SlicePar.SetParamS0Par(0, 0, iCoef, inn[iCoef] ); - SlicePar.SetParamS0Par(0, 1, iCoef, out[iCoef] ); - } -#endif - - SlicePar.SetParamS0Par(0, 1, 6, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 0, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 1, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 2, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 3, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 4, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 5, 0.0f ); - SlicePar.SetParamS0Par(0, 2, 6, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 0, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 1, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 2, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 3, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 4, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 5, 0.0f ); - SlicePar.SetParamS0Par(1, 0, 6, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 0, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 1, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 2, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 3, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 4, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 5, 0.0f ); - SlicePar.SetParamS0Par(1, 1, 6, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 0, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 1, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 2, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 3, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 4, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 5, 0.0f ); - SlicePar.SetParamS0Par(1, 2, 6, 0.0f ); - - fCaParam->push_back(SlicePar); - } // for iSlice -} // void StiTPCCATrackerInterface::MakeSettings() - -//_____________________________________________________________________________ -void StvCASeedFinder::MakeHits() -{ -const static double TAN15 = tan(M_PI*20/180); //18 != mistype - - fStvHits = StTGeoProxy::Inst()->GetAllHits(); - if (!fStvHits) return; - int nHits = fStvHits->size(); - if (!nHits) return; - for (int ihit = 0;ihitdetector(); - if (!hp) continue; - if (hp->GetDetId()!=kTpcId) continue; - const StTpcHit *tpcHit = (StTpcHit*)(hit->stHit()); - if ( ! tpcHit) continue; - int sector = tpcHit->sector(); - int padrow = tpcHit->padrow(); - - -// Make CA Hit - AliHLTTPCCAGBHit caHit; - myComplex myXY(hit->x()[0],hit->x()[1]); - myXY*=sectAng[sector-1]; - assert(fabs(myXY.imag()/myXY.real())<=TAN15); - assert(myXY.real()>0); - caHit.SetX( myXY.real()); // take position of the row - caHit.SetY( - myXY.imag()); - caHit.SetZ( - hit->x()[2]); - // caHit.SetErrX( ); - caHit.SetErrY( 0.12 );// TODO: read parameters from somewhere - caHit.SetErrZ( 0.16 ); - caHit.SetISlice( sector - 1 ); - caHit.SetIRow(padrow-1 ); - caHit.SetID(ihit); - fIdTruth->push_back( tpcHit->idTruth()); - fCaHits->push_back(caHit); - } - -} -//________________________________________________________________________________ -void StvCASeedFinder::Run() -{ - -// TStopwatch timer; -// timer.Start(); - - MakeSettings(); - MakeHits(); - - // run tracker - fTracker->SetSettings(*fCaParam); - fTracker->SetHits(*fCaHits); - - - -// timer.Stop(); -// fPreparationTime_real = timer.RealTime(); -// fPreparationTime_cpu = timer.CpuTime(); - - fTracker->FindTracks(); - fNTracks = fTracker->NTracks(); - fITrack = -1; -// copy hits -// timer.Start(); - -// timer.Stop(); -// fPreparationTime_real += timer.RealTime(); -// fPreparationTime_cpu += timer.CpuTime(); - -} -//________________________________________________________________________________ -const THelixTrack* StvCASeedFinder::NextSeed() -{ - if (!fNTracks) Run(); - if (!fNTracks) return 0;; - - while (++fITrackTrack( fITrack ); - const int NHits = tr.NHits(); - if (NHits <3) continue; - for ( int iHit = NHits-1; iHit >= 0; iHit-- ){ - const int index = fTracker->TrackHit( tr.FirstHitRef() + iHit ); - const int hId = fTracker->Hit( index ).ID(); - fSeedHits.push_back((StvHit*)(*fStvHits)[hId]); - } - const THelixTrack *ht = Approx(); - if (ht) return ht; - } - return 0; - -} -//________________________________________________________________________________ -int StvCASeedFinder::padp(int pad, int row) { - int p = 0; - p = (int)(pad - NumberOfPadsAtRow[row]/2); - if(row<13) - p = (int)p/2; - return p; -} -#endif diff --git a/StRoot/StvSeed/StvCASeedFinder.h b/StRoot/StvSeed/StvCASeedFinder.h deleted file mode 100644 index 54239c0899e..00000000000 --- a/StRoot/StvSeed/StvCASeedFinder.h +++ /dev/null @@ -1,55 +0,0 @@ -/// \File StvCASeedFinder.h -/// \author Victorb Perev 01/2010 -#ifndef StvCASeedFinder_HH -#define StvCASeedFinder_HH -#include "Stv/StvSeedFinder.h" -#include -#include -/// \class StvCASeedFinder - -class StvHit; -class AliHLTTPCCAParam; -class AliHLTTPCCAParamVector; -class AliHLTTPCCAGBHit; -class AliHLTTPCCAGBHitVector; -class IdTruthVector; -class AliHLTTPCCAGBTracker; -class StVoidArr; - -class StvCASeedFinder : public StvSeedFinder -{ -public: - StvCASeedFinder(const char *name="TpcCaSeedFinder"); - ~StvCASeedFinder(){;} - const THelixTrack* NextSeed(); - void Clear(const char *opt=""); - void Reset(); - void Print(const char *opt="") const {;} - -protected: - -private: - void Run(); - void MakeSettings(); - void MakeHits(); - -static Int_t padp(Int_t pad, Int_t row); -private: -char mBeg[1]; -int fNTracks; -int fITrack; -StVoidArr *fStvHits; -char mMed[1]; -AliHLTTPCCAGBTracker *fTracker; -AliHLTTPCCAParamVector *fCaParam; // settings for all sectors to give CATracker -AliHLTTPCCAGBHitVector *fCaHits; // hits to give CATracker -IdTruthVector *fIdTruth; // id of the Track, which has created CaHit - - - -char mEnd[1]; -KlassDef(StvCASeedFinder,0);//K instead of C to avoid dictionary creation -}; - - -#endif diff --git a/StRoot/StvSeed/StvConeRejector.cxx b/StRoot/StvSeed/StvConeRejector.cxx deleted file mode 100644 index feba9b20f18..00000000000 --- a/StRoot/StvSeed/StvConeRejector.cxx +++ /dev/null @@ -1,187 +0,0 @@ -#include -#include -#include -#include -#include "TVector3.h" -#include "StvConeRejector.h" -#include "StvSeedConst.h" - - -//VP ??? enum {kFstAng=88,kMinLen=3,kMaxLen=50,kDivLen=5}; -enum {kFstAng=88,kMinLen=3,kMaxLen=50,kDivLen=1}; -static const double kFstCos = cos(kFstAng*M_PI/180); - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -inline static float Dot(const float A[3],const float B[3]) -{ - return A[0]*B[0]+A[1]*B[1]+A[2]*B[2]; -} -//_____________________________________________________________________________ -inline static void Cop(float A[3],const float B[3]) -{ - A[0]=B[0];A[1]=B[1];A[2]=B[2]; -} -//_____________________________________________________________________________ -inline static void Mul(float A[3],float F,const float B[3]) -{ - A[0]=B[0]*F; A[1]=B[1]*F; A[2]=B[2]*F; -} -//_____________________________________________________________________________ -inline static void Sub(float A[3],const float B[3],const float C[3]) -{ - A[0]=B[0]-C[0]; A[1]=B[1]-C[1]; A[2]=B[2]-C[2]; -} -//_____________________________________________________________________________ -inline static void Add(float A[3],const float B[3],const float C[3]) -{ - A[0]=B[0]+C[0]; A[1]=B[1]+C[1]; A[2]=B[2]+C[2]; -} -//_____________________________________________________________________________ -inline static void Cro(float A[3],const float B[3],const float C[3]) -{ -// TVector3(fY*p.fZ-p.fY*fZ, fZ*p.fX-p.fZ*fX, fX*p.fY-p.fX*fY); - A[0] = B[1]*C[2]-C[1]*B[2]; - A[1] = B[2]*C[0]-C[2]*B[0]; - A[2] = B[0]*C[1]-C[0]*B[1]; - -} -//_____________________________________________________________________________ -StvConeRejector::StvConeRejector() -{ - memset(mBeg,0,mEnd-mBeg+1); -} -//_____________________________________________________________________________ -void StvConeRejector::Reset(const float pos[3],const float dir[3] - ,float rad,float theta,float err) -/// Definition of start position, direction and radius of cone sector -/// if direction,radius,angle or error are not defined, then -/// they are calculated automatically. -{ - Cop(mPos,pos); - mRxy2 = mPos[0]*mPos[0]+mPos[1]*mPos[1]; - mR2 = mRxy2 + mPos[2]*mPos[2]; - mRxy = sqrt(mRxy2); - mErr = SEED_ERR(mRxy); - double norL=0,norR=0; - - if (dir) { //Direction defined - Cop(mDir[0],dir); - mThet = (theta) ? theta : kFstAng*M_PI/180; - } else { //Estimate dir as median direction to (0,0,-kZRange) and (0,0,kZRange) - - norL = sqrt(mRxy2+pow(mPos[2]-kZRange,2)); - norR = sqrt(mRxy2+pow(mPos[2]+kZRange,2)); - double norQ = (1./norL+1./norR); - - mDir[0][0]= mPos[0]*norQ; - mDir[0][1]= mPos[1]*norQ; - mDir[0][2]= mPos[2]*norQ +kZRange*(1./norR-1./norL); - norQ = 1./sqrt(Dot(mDir[0],mDir[0])); - Mul(mDir[0],-norQ,mDir[0]); - mThet = (mR2 -(kZRange*kZRange))/(norL*norR); - mThet = 0.5*acos(mThet); - - assert(mThet< M_PI/2); - } - if (rad ) { mOutRad = rad;} //rad is defined, use it - else { //rad is no defined, estimate it - mOutRad = (norL>norR) ? norL:norR; - mOutRad/= kDivLen; - if (mOutRadlim) mLim[0][i] = lim; - lim = qwe + asd + mErr; - if (mLim[1][i] mCos) {mLim[1][i] = mOutRad;} - else if (mDir[0][i]<-mCos) {mLim[0][i] = -mOutRad;} - - // Move to global system - mLim[0][i]+= mPos[i]; - mLim[1][i]+= mPos[i]; - } -static int mytimes = 20; - if (mytimes >0) { - TestIt(); - mytimes--; - double fullVol = M_PI*200*200*400/100; - double vol1=1/fullVol; for (int i=0;i<3;i++) { vol1*=mLim[1][i]-mLim[0][i];} - printf (" vol1 = %g \n",vol1); - } -} -//_____________________________________________________________________________ -int StvConeRejector::Reject(const float x[3]) const -{ - float xx[3]; - Sub(xx,x,mPos); - float r2 = xx[0]*xx[0]+xx[1]*xx[1]+xx[2]*xx[2]; - if (r2>mOutRad2) return 1; - float myX = Dot(xx,mDir[0]); - if (myX <0) return 2; - - float myY2 = (r2-myX*myX); - if (myY2 >myX*myX*mTan2) return 3; - return 0; -} -#include "TRandom.h" -//_____________________________________________________________________________ -int StvConeRejector::TestIt() const -{ - float x[3]; - - for (int i=0;i<20;i++) { - - int ifail = 0; - double r = (mOutRad*1.5)*gRandom->Rndm(); - if (r >mOutRad) ifail+=1; - double sThet = mSin*1.1; if(sThet>=0.99) sThet=0.99; - sThet = sThet*gRandom->Rndm(); - if (sThet>mSin) ifail+=2; - double cThet = sqrt(1.-sThet*sThet); - double alfa = M_PI*2*gRandom->Rndm(); - for (int j = 0;j<3;j++) { - x[j] = r*(mDir[0][j]*cThet + sThet*(mDir[1][j]*cos(alfa)+mDir[2][j]*sin(alfa))); - } - if (Dot(x,x)>mOutRad*mOutRad) ifail+=4; - Add(x,x,mPos); - int irej = Reject(x); - assert((!!irej) == (!!ifail)); - } - return 0; -} diff --git a/StRoot/StvSeed/StvConeRejector.h b/StRoot/StvSeed/StvConeRejector.h deleted file mode 100644 index de11fe27853..00000000000 --- a/StRoot/StvSeed/StvConeRejector.h +++ /dev/null @@ -1,43 +0,0 @@ -/// \File StvConeRejector.h -/// \author Victorb Perev 01/2010 -/// \class StvConeRejector - -#ifndef StvConeRejector_HH -#define StvConeRejector_HH -#include "StvSeed/StvSeedConst.h" - -class StvConeRejector -{ -public: - StvConeRejector (); - ~StvConeRejector (){;} -void Reset(const float pos[3],const float dir[3]=0 - ,float len=0,float theta=0,float err=0); -void Prepare(); -const Mtx33F_t &GetDir() const { return mDir;} - -// 0=accepted -int Reject(const float x[3]) const; -int TestIt() const; -private: - -public: -// Input data -char mBeg[1]; -float mPos[3]; // start position -float mDir[3][3]; // track direction + orthogonal axises -float mOutRad; // cone radius of limitation (similar to height) -float mOutRad2; // mOutRad**2 -float mRxy; // Rxy ofstart position -float mRxy2; // Rxy**2 -float mR2; // R**2 -float mThet; // 1/2 of cone angle -float mCos; // cos(mThet) -float mSin; // sin(mThet) -float mTan2; // tan(mThet)**2 -float mErr; // 3d accuracy to be inside of cone -float mLim[2][3]; // xyz min and xyz max of cube around the cone -char mEnd[1]; -}; - -#endif diff --git a/StRoot/StvSeed/StvDefaultSeedFinder.cxx b/StRoot/StvSeed/StvDefaultSeedFinder.cxx deleted file mode 100644 index 58c2c4c2dc0..00000000000 --- a/StRoot/StvSeed/StvDefaultSeedFinder.cxx +++ /dev/null @@ -1,514 +0,0 @@ -#include -#include -#include -#include "TCernLib.h" -#include "TVector3.h" -#include "StvDefaultSeedFinder.h" -#include "StMultiKeyMap.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "Stv/StvHit.h" -#include "THelixTrack.h" -//#define APPROX_DEBUG -#ifdef APPROX_DEBUG -#include "TCanvas.h" -#include "TH1F.h" -#include "TProfile.h" -#endif //APPROX_DEBUG -#include "StvSeedConst.h" -#include "Stv/StvConst.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvDraw.h" - - -void myBreak(int); -enum {kFstAng=65,kErrFakt=4,kLenFakt=4,kMaxLen=300}; -enum {kPhi=0,kRxy=1,kTanL=2,kZ=3}; -static const double kFstTan = tan(kFstAng*M_PI/180); -static const double kMinTan = 0.01; - -ClassImp(StvDefaultSeedFinder) - -//_____________________________________________________________________________ -StvDefaultSeedFinder::StvDefaultSeedFinder(const char *name):StvSeedFinder(name) -{ - memset(mBeg,0,mEnd-mBeg+1); - fMultiHits = new StMultiKeyMap(kNKeys); - fMultiIter = new StMultiKeyMapIter(0); - f1stHitMap = new Stv1stHitMap; - f1stHitMapIter= new Stv1stHitMapIter; - fSgn = 1; -} -//_____________________________________________________________________________ -void StvDefaultSeedFinder::Clear(const char*) -{ - memset(mBeg,0,mMed-mBeg+1); - f1stHitMap->clear(); - fMultiHits->Clear(); - *f1stHitMapIter = f1stHitMap->end(); - StvSeedFinder::Clear(); -} -//_____________________________________________________________________________ -void StvDefaultSeedFinder::Reset() -{ - memset(mBeg,0,mMed-mBeg+1); - const StVoidArr *hitArr = StTGeoProxy::Inst()->GetSeedHits(); - int nHits = hitArr->size(); - for (int iHit=0;iHittimesUsed()) continue; - const float *x = stiHit->x(); - float r2 = x[0]*x[0] + x[1]*x[1] + x[2]*x[2]; - f1stHitMap->insert(std::pair(-fSgn*r2, stiHit)); - - fMultiHits->Add(stiHit,x); - } - fMultiHits->MakeTree(); - *f1stHitMapIter = f1stHitMap->begin(); -} -//_____________________________________________________________________________ -int StvDefaultSeedFinder::Again(int ) -{ - *f1stHitMapIter = f1stHitMap->begin(); - mNDejavu = 0; - return 1; -} -//_____________________________________________________________________________ -void StvDefaultSeedFinder::ShowIn() -{ - fDraw = StvDraw::Inst(); - if (mSel.mPnt) fDraw->Hits(mSel.mNPnt,mSel.mPnt); - StvSeedFinder::ShowIn(); -} -//_____________________________________________________________________________ -// Start of Local auxiliary routines -inline static void Lagrange3Int (float t,float T1,float T2,float coe[3]) -{ - coe[0]= (t-T1)*(t-T2)/(T1*(T2 )); - coe[1]= -(t )*(t-T2)/(T1*(T2-T1)); - coe[2]= (t )*(t-T1)/(T2*(T2-T1)); -} -//_____________________________________________________________________________ -inline static void ZLine3Int (float t,float T1,float T2,float coe[3]) -{ - float aT = (T1 +T2 )/3; - float aTT = (T1*T1+T2*T2)/3; - float det = aTT-aT*aT; - coe[0] = (1. + ( -aT)*(t-aT)/det)/3; - coe[1] = (1. + (T1-aT)*(t-aT)/det)/3; - coe[2] = (1. + (T2-aT)*(t-aT)/det)/3; -} - -//_____________________________________________________________________________ -inline static void Lagrange3Der (float t,float T1,float T2,float coe[3]) -{ - coe[0]= ((t-T1)+(t-T2))/(T1*(T2 )); - coe[1]= -((t )+(t-T2))/(T1*(T2-T1)); - coe[2]= ((t )+(t-T1))/(T2*(T2-T1)); -} -//_____________________________________________________________________________ -inline static void ZLine3Der (float T1,float T2,float coe[3]) -{ - float aT = (T1 +T2 )/3; - float aTT = (T1*T1+T2*T2)/3; - float det = aTT-aT*aT; - coe[0] = ( -aT)/det/3; - coe[1] = (T1-aT)/det/3; - coe[2] = (T2-aT)/det/3; -} -//_____________________________________________________________________________ -inline static float Dot(const float dir[3],const float pnt[3]) -{ - return dir[0]*pnt[0]+dir[1]*pnt[1]+dir[2]*pnt[2]; -} -//_____________________________________________________________________________ -inline static float Prj(const float dir[3],const float pnt[3],const float beg[3]) -{ - return dir[0]*(pnt[0]-beg[0])+dir[1]*(pnt[1]-beg[1])+dir[2]*(pnt[2]-beg[2]); -} -//_____________________________________________________________________________ -inline static void Mul(const float a[3],float scale,float b[3]) -{ - b[0]=a[0]*scale;b[1]=a[1]*scale;b[2]=a[2]*scale; -} -//_____________________________________________________________________________ -inline static float Dir(const float a[3],const double b[3],float dir[3]) -{ - - dir[0] = a[0];dir[1] = a[1];dir[2] = a[2]; - if (b[2]<1e11) {dir[0]-=b[0];dir[1]-=b[1];dir[2]-=b[2];} - double len = sqrt(dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2]); - dir[0]/=len; dir[1]/=len;dir[2]/=len; - return len; -} -//_____________________________________________________________________________ -inline static float Impact2(const float dir[3],const float pnt[3]) -{ - float imp[3]; - imp[0] = dir[1]*pnt[2]-dir[2]*pnt[1]; - imp[1] = dir[2]*pnt[0]-dir[0]*pnt[2]; - imp[2] = dir[0]*pnt[1]-dir[1]*pnt[0]; - return imp[0]*imp[0]+imp[1]*imp[1]+imp[2]*imp[2]; -} -// End of Local auxiliary routines -//_____________________________________________________________________________ -const THelixTrack* StvDefaultSeedFinder::NextSeed() -{ -static int nCall = 0; nCall++; -std::vector mySeedObjs; - - StvHit *fstHit,*selHit=0; - - int nTally = 0; - while ((*f1stHitMapIter)!=f1stHitMap->end()) {//1st hit loop - fstHit = (*(*f1stHitMapIter)).second; - int fstIdTruth = fstHit->idTru(); - int notMine = 1; - do { - if (fIdTruth && !fstIdTruth) break; - if (fstHit->timesUsed() || mNDejavu>=kNDejavu) break; - } while((notMine=0)); - if (notMine) { //1st hit not useful - ++(*f1stHitMapIter); mNDejavu = 0; continue; - } - fSeedHits.clear(); - mSel.Reset(); - selHit = fstHit; - m1stHit = fstHit->x(); - mSel.SetErr(sqrt(fstHit->err2())*kErrFakt); - - while (1) { //Search next hit -// Add info from selected hit - nTally++; - fSeedHits.push_back(selHit); fNUsed[0]++; - if (fSeedHits.size()>=kMaxHits) break; -// Store second hit to skip it next time - if (fSeedHits.size()==2) mDejavu[mNDejavu++]=selHit; - const StHitPlane *hp = selHit->detector(); - const float *hd = hp->GetDir(selHit->x())[0]; - mSel.AddHit(selHit->x(),hd,hp->GetLayer()); - mSel.Prepare(); - - fMultiIter->Set(fMultiHits->GetTop(),mSel.mLim[0],mSel.mLim[1]); - - selHit=0; -// for (StMultiKeyNode *node=0;(node = *(*fMultiIter)) ;++(*fMultiIter)) - StMultiKeyNode *node=0; - StvHit *nexHit = 0; - while(1) { - node = *(*fMultiIter) ; if (!node) break; - nexHit = (StvHit*)node->GetObj() ;++(*fMultiIter); - - if (nexHit->isUsed()) continue; - if (fIdTruth && fstIdTruth!=nexHit->idTru()) continue; - const StHitPlane *hpNex = nexHit->detector(); - if (hpNex==hp) continue; - int dejavu = 0; - for (int j=0;jx(),hpNex); - if (ans>0) continue; //hit outside the cone - - // Selecting the best - selHit=nexHit; - if (!ans) continue; - // Decrease size of searching box - mSel.Update(); - fMultiIter->Update(mSel.mLim[0],mSel.mLim[1]); - } //endMultiIter loop - - if (!selHit) break; //No more hits - }// end NextHit loop -// If no hits found, go to next 1st hit - - if ((int)fSeedHits.size()<=1) {mNDejavu = 99; continue;} - if ((int)fSeedHits.size() < fMinHits) continue; - - - const THelixTrack *hel = Approx(); - -#if 0 - if (hel) { //print all seed hits - for (int it = 0;it<(int)fSeedHits.size(); ++it) { - auto *hit = fSeedHits[it]; - printf("%d *** StvDefaultSeedFinder::NextSeed %g %g %g %s ***\n",it - ,hit->x()[0],hit->x()[1],hit->x()[2] - ,hit->detector()->GetName()); - } } - - -#endif - - - - - if (hel) { fNSeeds[0]++;;return hel;} //Good boy - // Bad seed - fNUsed[0] -= fSeedHits.size(); - }// end 1st hit loop - fNSeeds[1]+=fNSeeds[0]; fNUsed[1]+= fNUsed[0]; - return 0; -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StvConeSelector::StvConeSelector() -{ - memset(mBeg,0,mEnd-mBeg+1);mSgn=1; - mVtx[2] = 1e6; -} -//_____________________________________________________________________________ -void StvConeSelector::AddHit(const float *x,const float *dir,float layer) -{ - mMinPrj = 1.e11; mMinImp = 1.e11; mHp = 0; - mX[++mJst]=x; - mHit = x; - mLayer = layer; - mHitDir = dir; - assert(mJst<100); -} -//_____________________________________________________________________________ -void StvConeSelector::Prepare() -{ -static int nCall=0; nCall++; -StvDebug::Break(nCall); - - float Rxy = sqrt(mX[0][0]*mX[0][0]+mX[0][1]*mX[0][1]); - SetErr(SEED_ERR(Rxy)*kErrFakt); - float stp=0,myLen; - int kase = mJst; if (kase>2) kase = 2; - - switch(kase) { - - case 0: { - if (mVtx[2]>1e3) { - myLen = sqrt(Dot(mX[0],mX[0])); - Mul(mX[0] ,-mSgn/myLen,mDir); - } else { - float myX[3] = { mX[0][0]-mVtx[0],mX[0][1]-mVtx[1],mX[0][2]-mVtx[2]}; - myLen = sqrt(Dot(myX,myX)); - Mul(myX ,-mSgn/myLen,mDir); - } - float sgn = Dot(mHit,mDir); - assert(mSgn*sgn<0); - mS[0]=0; - mTan = (mVtx[2]>=1e3)? kFstTan: mErr/myLen; - }; break; - - case 1: { - stp=0; - for (int i=0;i<3;i++) {mDir[i]=mHit[i]-mX[mJst-1][i]; stp+=mDir[i]*mDir[i];} - stp = sqrt(stp ); - for (int i=0;i<3;i++) {mDir[i]/=stp;} - mS[1]=stp; - mTan = mErr/stp; - }; break; - - - case 2: { - stp=0; - for (int i=0;i<3;i++) {float qwe=mHit[i]-mX[mJst-1][i]; stp+=qwe*qwe;} - stp = sqrt(stp ); - mS[mJst]=stp; - mTan = mErr/(mS[mJst]+mS[mJst-1])/sqrt(3.); - float T1 = mS[mJst-1],T2 = mS[mJst]+T1; - float coe[3]; - Lagrange3Der (T2,T1,T2,coe); - - mDir[0] = coe[0]*mX[mJst-2][0]+coe[1]*mX[mJst-1][0]+coe[2]*mHit[0]; - mDir[1] = coe[0]*mX[mJst-2][1]+coe[1]*mX[mJst-1][1]+coe[2]*mHit[1]; - mDir[2] = coe[0]*mX[mJst-2][2]+coe[1]*mX[mJst-1][2]+coe[2]*mHit[2]; - stp=0; - for (int i=0;i<3;i++) {stp+=mDir[i]*mDir[i];} - stp = sqrt(stp ); - for (int i=0;i<3;i++) {mDir[i]/=stp;} - }; break; - - default: assert(0 && "Wrong case"); - } - mRxy2 = mHit[0]*mHit[0]+mHit[1]*mHit[1]; - mRxy = sqrt(mRxy2); - mDelta = SEED_ERR(mRxy); - mLen= mLayer*kLenFakt/(fabs(Dot(mHitDir,mDir))+1e-10); - if (mLen>kMaxLen) mLen = kMaxLen; - UpdateLims(); - -} -#ifndef MultiPhiZMap -//_____________________________________________________________________________ -void StvConeSelector::UpdateLims() -{ - mLim[2][0]=1e11; - for (int i=0;i<3;i++) { - float qwe = mLen*mDir[i]; - float asd = mLen*mTan*sqrt(fabs(1-mDir[i]*mDir[i])); - float lim = qwe - asd - mErr; - mLim[0][i] = (lim<0)? lim:-mErr; - lim = qwe + asd + mErr; - mLim[1][i] = (lim>0)? lim: mErr; -// Move to global system - mLim[0][i]+= mHit[i]; - mLim[1][i]+= mHit[i]; - } - -// // Account that all the hits inside of cylinder with Rxy -// for (int i=0;i<2;i++) { -// if (mLim[0][i]<-mRxy) mLim[0][i]=-mRxy; -// if (mLim[1][i]> mRxy) mLim[1][i]= mRxy; -// } - -} -#endif -#ifdef MultiPhiZMap -//_____________________________________________________________________________ -void StvConeSelector::UpdateLims() -{ -static int nCall=0; nCall++; -StvDebug::Break(nCall); -struct myLim_t {double Phi,Rxy,tanL,Z;}; -//static const StvConst *kons = StvConst::Inst(); -static const double kMyMax = 220; - TVector3 vHit(mHit); - TVector3 nT(mDir); - TVector3 nP(nT.Orthogonal()); - TVector3 nL(nT.Cross(nP)); - enum {kPNT = sizeof(mPnt)/sizeof(mPnt[0])}; - - for (int ix=0;ix<3;ix++) { - if (vHit[ix]+nT[ix]*mLen > kMyMax) {mLen = ( kMyMax-1-vHit[ix])/nT[ix];} - if (vHit[ix]+nT[ix]*mLen <-kMyMax) {mLen = (-kMyMax+1-vHit[ix])/nT[ix];} - } - TVector3 vBas(vHit+nT*mLen); - mNPnt=0; - mPnt[mNPnt++]=vHit; - double myRad = mLen*mTan*sqrt(2.)+mErr; - for (int i=-1;i<2;i+=2) { - mPnt[mNPnt++]=vBas+nP*(i*myRad); - mPnt[mNPnt++]=vBas+nL*(i*myRad); - assert(mNPnt<=kPNT); - } - -// account points out of volume. - int nPnt1st = mNPnt; - int ySign = (vHit[1]<0)? -1:1; - for (int ip=1;ip kMyMax) {lim = kMyMax-1;} - else if (P[ix] < -kMyMax) {lim = -kMyMax+1;} - if (!lim) continue; - for (int jHB=0;jHB<2;jHB++) { - alfa = (lim-(*vHB[jHB])[ix])/(P[ix]-(*vHB[jHB])[ix]); - if (alfa<0.01) alfa=0.01; - assert(alfa>=0 && alfa<1); - if (ALFA[jHB]>alfa) ALFA[jHB]=alfa; - } } //End ix loop - if (fabs(P[ix]) < kMyMax) continue; - double lim = (P[ix]<0)? -kMyMax: kMyMax; - double al = (lim-vHit[ix])/(P[ix]-vHit[ix]); - if (al<0.01) al=0.01; - assert(al>=0 && al<1); - if (alfa>al) alfa=al; - } //End ix loop - - if (alfa<1) {P = P*alfa + vHit*(1-alfa);} -// Now upp and down in Y (to avoid problems with Phi = +-Pi) - if (P[1]*ySign >0) continue; - alfa = -vHit.y()/(P.y()-vHit.y()); - mPnt[mNPnt++] = P*alfa*0.99 + vHit*(1-alfa*0.99); - mPnt[mNPnt++] = P*alfa*1.01 + vHit*(1-alfa*1.01); - }// end of point loop - - myLim_t Dow[2]={{ 1e11, 1e11, 1e11, 1e11},{ 1e11, 1e11, 1e11, 1e11}}; - myLim_t Upp[2]={{-1e11,-1e11,-1e11,-1e11},{-1e11,-1e11,-1e11,-1e11}}; - for (int ip=0;ipphi) dow.Phi=phi; - if (upp.Phirxy) dow.Rxy=rxy; - if (upp.Rxyz) dow.Z=z; - if (upp.ZtanL) dow.tanL=tanL; - if (upp.tanL -M_PI/2) kase |=2; - if (Dow[1].Phi < M_PI/2) kase |=4; - if (Upp[1].Phi > M_PI/2) kase |=8; - - mLim[2][0] = 1e11; - if ((kase&(1|8))!=(1|8)) { // Np ambiguity - mLim[0][kPhi ] = MIN(Dow[0].Phi ,Dow[1].Phi ); - mLim[0][kRxy ] = MIN(Dow[0].Rxy ,Dow[1].Rxy ); - mLim[0][kTanL] = MIN(Dow[0].tanL,Dow[1].tanL); - mLim[0][kZ ] = MIN(Dow[0].Z ,Dow[1].Z ); - mLim[1][kPhi ] = MAX(Upp[0].Phi ,Upp[1].Phi ); - mLim[1][kRxy ] = MAX(Upp[0].Rxy ,Upp[1].Rxy ); - mLim[1][kTanL] = MAX(Upp[0].tanL,Upp[1].tanL); - mLim[1][kZ ] = MAX(Upp[0].Z ,Upp[1].Z ); - } else { - for (int li=0,du=0;li<=2;li+=2,du++) { - mLim[li+0][kPhi ] = Dow[du].Phi ; - mLim[li+0][kRxy ] = Dow[du].Rxy-mErr ; - mLim[li+0][kTanL] = Dow[du].tanL; - mLim[li+0][kZ ] = Dow[du].Z -mErr ; - - mLim[li+1][kPhi ] = Upp[du].Phi ; - mLim[li+1][kRxy ] = Upp[du].Rxy +mErr; - mLim[li+1][kTanL] = Upp[du].tanL; - mLim[li+1][kZ ] = Upp[du].Z +mErr; - } - } -} -#endif //MultiPhiZMap -//_____________________________________________________________________________ -int StvConeSelector::Reject(const float x[3],const void* hp) -{ - if (x[0]*x[0]+x[1]*x[1]>mRxy2) return 1; - - float xx[3] = {x[0]-mHit[0],x[1]-mHit[1],x[2]-mHit[2]}; - - float r2xy = xx[0]*xx[0]+xx[1]*xx[1]; - float z2 = xx[2]*xx[2]; - if (r2xy < (kMinTan*kMinTan)*z2) return 3; - mHitLen = (r2xy+z2); - if (mHitLen < 1e-8) return 4; - mHitPrj = Dot(xx,mDir); - if (mHitPrj < 1e-8) return 4; - if (mHitPrj>mLen) return 6; //Outside of cone along - float imp =mHitLen-mHitPrj*mHitPrj; if (imp<=0) imp = 0; - float lim = (mErr) + mHitPrj*mTan; - if (imp > lim*lim) return 7; //Outside of cone aside - int ans = 99; - if (mHp != hp) { //different layers, only prj is important - if (mHitPrj>mMinPrj) return 8; //more far than best,along - ans = -1; - } else { //same layer, only impact is important - if (imp>mMinImp) return 9; //same plane but impact bigger - ans = 0; - } - if (hp) {mMinPrj= mHitPrj; mMinImp=imp; mHp = hp;} - return ans; //impact best but cone the same -} -//_____________________________________________________________________________ -void StvConeSelector::Update() -{ - if (mLen<=mHitPrj) return; - mLen = mHitPrj; - UpdateLims(); -} - - diff --git a/StRoot/StvSeed/StvDefaultSeedFinder.h b/StRoot/StvSeed/StvDefaultSeedFinder.h deleted file mode 100644 index a435756d1e3..00000000000 --- a/StRoot/StvSeed/StvDefaultSeedFinder.h +++ /dev/null @@ -1,109 +0,0 @@ -/// \File StvDefaultSeedFinder.h -/// \author Victor Perev 01/2010 -#ifndef StvDefaultSeedFinder_HH -#define StvDefaultSeedFinder_HH -#include "TVector3.h" -#include "Stv/StvSeedFinder.h" -#include -#include -enum {kNKeys = 3}; - - -class StvHit; -class StMultiKeyMap; -typedef std::multimap Stv1stHitMap; -typedef Stv1stHitMap::iterator Stv1stHitMapIter; -class StMultiKeyMapIter; - -class StvConeSelector -{ -public: - StvConeSelector(); - ~StvConeSelector(){;} - -void Reset() {mJst=-1;} -void Prepare(); -void Update(); -void AddHit(const float *x,const float *dir,float layer); -void SetErr(float err) {mErr=err;} -void SetSgn(int dir=1) { mSgn = dir; } -void SetVtx(const float vtx[3]) { memcpy(mVtx,vtx,sizeof(mVtx));} - -int Reject(const float x[3],const void* hp); // 0 :x accepted - // >0 :x rejected - //-1 =x accepted and lims updated -private: -void UpdateLims(); //Update limits - -public: -// Input data -char mBeg[1]; -int mJst; -const void* mHp; -float mVtx[3]; -float mErr; -float mRxy2; -float mRxy; -float mDelta; -float mZ2; -float mDir[3]; // track direction -float mLayer; -const float *mHitDir; // hit plane direction -float mLen; // cone length (height) -// Calculated data - -float mTan; // (tan(cone angle/2) -float mLim[4][kNKeys]; -// Output data -float mHitLen; -float mHitPrj; -float mMinPrj; -float mMinImp; - -const float *mX[100]; -const float *mHit; -float mS[100]; -int mNPnt; -char mEnd[1]; -int mSgn; -TVector3 mPnt[100]; -}; - -class StvDefaultSeedFinder : public StvSeedFinder -{ -enum { kNDejavu=4 }; -public: - StvDefaultSeedFinder(const char *name="Default"); - ~StvDefaultSeedFinder(){;} - const THelixTrack* NextSeed(); - void Clear(const char *opt=""); - int Again(int repeat); - void Reset(); - void Print(const char *opt="") const {;} - void ShowIn(); - int Reject(const float x[3]) {return mSel.Reject(x,0)>0;} -void SetSgn(int dir=1) { fSgn = dir; mSel.SetSgn(dir);} -void SetVtx(const float vtx[3]) { StvSeedFinder::SetVtx(vtx); mSel.SetVtx(fVtx);} - -protected: - -private: -char mBeg[1]; -int fIPass,fNSeeds[2],fNUsed[2]; -char mMed[1]; -int mNDejavu; -const StvHit *mDejavu[kNDejavu]; - -StMultiKeyMap *fMultiHits; -StMultiKeyMapIter *fMultiIter; -Stv1stHitMap *f1stHitMap; -Stv1stHitMapIter *f1stHitMapIter; -float const *m1stHit; -float m1stDir[3]; // first track direction -char mEnd[1]; -StvConeSelector mSel; -ClassDef(StvDefaultSeedFinder,0); -}; - - -#endif diff --git a/StRoot/StvSeed/StvKNSeedFinder.cxx b/StRoot/StvSeed/StvKNSeedFinder.cxx deleted file mode 100644 index 7e9a7a62a1a..00000000000 --- a/StRoot/StvSeed/StvKNSeedFinder.cxx +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include "TCernLib.h" -#include "TSystem.h" -#include "TVector3.h" -#include "StMultiKeyMap.h" -#include "THelixTrack.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StvSeed/StvSeedConst.h" - -#ifndef __NOSTV__ -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -#include "StvKNSeedFinder.h" -#include "Stv/StvHit.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvDraw.h" -#endif - -#ifdef APPROX_DEBUG -#include "TCanvas.h" -#include "TH1F.h" -#include "TProfile.h" -#endif //APPROX_DEBUG -void myBreak(int); - -#ifndef __NOSTV__ -ClassImp(StvKNSeedFinder) -#endif - -enum {kMinRxy = 1}; - - -//_____________________________________________________________________________ -StvKNSeedFinder::StvKNSeedFinder(const char *name):StvSeedFinder(name) -{ - memset(mBeg,0,mEnd-mBeg+1); - mSel.Set(fMinHits); - fMultiHits = new StMultiKeyMap(3); - fMultiIter = new StMultiKeyMapIter(0); - f1stHitMap = new Stv1stHitMap; - f1stHitMapIter= new Stv1stHitMapIter; -} -//_____________________________________________________________________________ -void StvKNSeedFinder::Clear(const char*) -{ - memset(mBeg,0,mMed-mBeg+1); - f1stHitMap->clear(); - fMultiHits->Clear(); - *f1stHitMapIter = f1stHitMap->end(); - StvSeedFinder::Clear(); -} -//_____________________________________________________________________________ -void StvKNSeedFinder::Reset() -{ - memset(mBeg,0,mMed-mBeg+1); -#ifndef __NOSTV__ -static const float kSqrHlf = sqrt(0.5); - assert(!f1stHitMap->size()); - const StVoidArr *hitArr = StTGeoProxy::Inst()->GetSeedHits(); - int nHits = hitArr->size(); - for (int iHit=0;iHittimesUsed()) continue; - const float *x = hit->x(); - float r2 = x[0]*x[0] + x[1]*x[1] + x[2]*x[2]; - f1stHitMap->insert(std::pair(-r2, hit)); - float xx[5] = {x[0],x[1],x[2],(x[0]+x[1])*kSqrHlf,(-x[0]+x[1])*kSqrHlf}; - fMultiHits->Add(hit,xx); - } - - fMultiHits->MakeTree(); - *f1stHitMapIter = f1stHitMap->begin(); -#endif -} -//_____________________________________________________________________________ -int StvKNSeedFinder::Again(int) -{ - *f1stHitMapIter = f1stHitMap->begin(); - return 1; -} -//_____________________________________________________________________________ -const THelixTrack* StvKNSeedFinder::NextSeed() -{ -static int nCall=0; nCall++; - int nTotHits=0,nAccHits=0; - - if (fstHit) ++(*f1stHitMapIter); //Next seed if success - for (;(*f1stHitMapIter)!=f1stHitMap->end();++(*f1stHitMapIter)) {//1st hit loop - - fstHit = (*(*f1stHitMapIter)).second; - assert(fstHit); - if (fstHit->timesUsed()) continue; - fSeedHits.clear(); - const float *fstPos = fstHit->x(); - const StHitPlane *fstHp = fstHit->detector(); - mRej.Reset(fstPos); - mRej.Prepare(); - fMultiIter->Set(fMultiHits->GetTop(),mRej.mLim[0],mRej.mLim[1]); - mSel.Reset(fstHit->x(),&(mRej.GetDir()),fstHit); - nTotHits=0;nAccHits=0; - -// Add all near hits - for (StMultiKeyNode *node=0;(node = *(*fMultiIter)) ;++(*fMultiIter)) - { -// Search next hit - StvHit *nexHit = (StvHit*)node->GetObj(); - - if (nexHit->isUsed()) continue; - if (nexHit->detector()==fstHp) continue; - nTotHits++; - int ans = mRej.Reject(nexHit->x()); - if (ans) StvDebug::Count("KNNRej",10+ans); - if (ans) continue; - nAccHits++; - - mSel.Add(nexHit->x(),nexHit,nexHit->detector()); - - } //endMultiIter loop - if (nAccHitsGetNode(StvTrack::kFirstPoint); - double P[3]; - node->GetFP().getMom(P); - - double eta = TVector3(P).Eta(); - int nHits = tk->GetNHits(kPxlId); - nHits += tk->GetNHits(kIstId); - nHits += tk->GetNHits(kSstId); - StvDebug::Count("GoodEta",eta); - if (nHits>=2) StvDebug::Count("HftEta",eta); -#endif -} - diff --git a/StRoot/StvSeed/StvKNSeedFinder.h b/StRoot/StvSeed/StvKNSeedFinder.h deleted file mode 100644 index 9d8beef5ad9..00000000000 --- a/StRoot/StvSeed/StvKNSeedFinder.h +++ /dev/null @@ -1,56 +0,0 @@ -/// \File StvKNSeedFinder.h -/// \author Victorb Perev 01/2010 -#ifndef StvKNSeedFinder_HH -#define StvKNSeedFinder_HH -#ifndef __NOSTV__ -#include "Stv/StvSeedFinder.h" -#endif -#include "StvSeedConst.h" -#include "StvConeRejector.h" -#include "StvKNSeedSelector.h" -#include -#include -/// \class StvKNSeedFinder - -class StvHit; -class StvHits; -class StvTrack; -class StMultiKeyMap; -typedef std::multimap Stv1stHitMap; -typedef Stv1stHitMap::iterator Stv1stHitMapIter; -class StMultiKeyMapIter; - - -class StvKNSeedFinder : public StvSeedFinder -{ -public: - StvKNSeedFinder(const char *name="KN"); - ~StvKNSeedFinder(){;} - const THelixTrack* NextSeed(); - void Clear(const char *opt=""); - int Again(int repeat); - void Reset(); - void FeedBack(const StvTrack *tk); - void Print(const char *opt="") const {;} - const StvHits *GetHits() const; - const float *Eigen(){return mSel.Eigen();} - virtual void Show(); -protected: - -protected: -char mBeg[1]; -int fNSeeds[2],fNUsed[2]; -StvHit *fstHit; -char mMed[1]; -StMultiKeyMap *fMultiHits; -StMultiKeyMapIter *fMultiIter; -Stv1stHitMap *f1stHitMap; -Stv1stHitMapIter *f1stHitMapIter; -char mEnd[1]; -StvConeRejector mRej; -StvKNSeedSelector mSel; -ClassDef(StvKNSeedFinder,0); -}; - - -#endif diff --git a/StRoot/StvSeed/StvKNSeedSelector.cxx b/StRoot/StvSeed/StvKNSeedSelector.cxx deleted file mode 100644 index 027a627e220..00000000000 --- a/StRoot/StvSeed/StvKNSeedSelector.cxx +++ /dev/null @@ -1,570 +0,0 @@ -#include -#include -#include -#include -#include "StvUtil/StvDebug.h" -#include "StvKNSeedSelector.h" -#include "Stv/StvHit.h" - -#include "TStopwatch.h" - - -#include "StvSeedConst.h" -//static const float kMaxDis = 9*3.14/180; //???Maximal angle allowed for connected hits -//static const float kMaxDis = 15*3.14/180; //???Maximal angle allowed for connected hits -static const float kMaxDis = 30*3.14/180; //???Maximal angle allowed for connected hits -static const float kMaxLam = (M_PI-kMaxDis)/2; -static const float kSinDis = sin(kMaxDis/2); - -//static const float kMinDis = 1*3.14/180;; //KN angle allowed -//static const float kMinDis = 2*3.14/180;; //KN angle allowed -//static const float kMinDis = 9*3.14/180;; //KN angle allowed -static const float kMinDis = 5*3.14/180;; //KN angle allowed -//static const float kMinDis = 3*3.14/180;; //KN angle allowed -//static const float kMinDis = 12*3.14/180;; //KN angle allowed - -//static const float kDisRatio= 1.0; //ratio for KNN distance -//static const float kDisRatio= 0.7; //ratio for KNN distance -//static const float kDisRatio= 0.6; //ratio for KNN distance -//static const float kDisRatio= 0.8; //ratio for KNN distance -//static const float kDisRatio= 0.9; //ratio for KNN distance -//static const float kDisRatio= 1.5; //ratio for KNN distance -static const float kDisRatio= 3.; //ratio for KNN distance - -static const float kErrFact= 1./3; //bigErr/kErrFact/len is angle error - -//enum { kNumTheDiv = 20 }; //number of divisions in theta -enum { kNumTheDiv = 40 }; //number of divisions in theta -static float kStpTheDiv = M_PI/kNumTheDiv; //step in theta map - -TStopwatch SW; - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -static void Eigen2(const double err[3], float lam[2], float eig[2][2]) -{ - - double spur = err[0]+err[2]; - double det = err[0]*err[2]-err[1]*err[1]; - double dis = spur*spur-4*det; - if (dis<0) dis = 0; - dis = sqrt(dis); - lam[0] = 0.5*(spur+dis); - lam[1] = 0.5*(spur-dis); - if (!eig) return; - eig[0][0] = 1; eig[0][1]=0; - if (dis>1e-6*spur) {// eigenvalues are different - if (fabs(err[0]-lam[0])>fabs(err[2]-lam[0])) { - eig[0][1] = 1; eig[0][0]= -err[1]/(err[0]-lam[0]); - } else { - eig[0][0] = 1; eig[0][1]= -err[1]/(err[2]-lam[0]); - } - double tmp = sqrt(eig[0][0]*eig[0][0]+eig[0][1]*eig[0][1]); - eig[0][0]/=tmp; eig[0][1]/=tmp; - } - eig[1][0]=-eig[0][1]; eig[1][1]= eig[0][0]; -} - - -//_____________________________________________________________________________ -static inline double Ang( const float A[3],const float B[3]) -{ - double cang = ((A[0]-B[0])*A[0]+(A[1]-B[1])*A[1]+(A[2]-B[2])*A[2]); -assert(cang>-0.01); - if (cang<0) cang = 0; - double ang = 2*sqrt(cang/2); - if (ang>1.99) { ang = M_PI;} - else if (ang>1.0 ) { ang = 2.*asin(ang/2); } - return ang; -} -//_____________________________________________________________________________ -static inline void Ave( float A[3],const float B[3]) -{ - float nor = 0; - for (int i=0;i<3;i++) { A[i] += 0.2*B[i]; nor += A[i]*A[i];} - nor = sqrt(nor); - for (int i=0;i<3;i++) { A[i]/=nor;} -} -//_____________________________________________________________________________ -static inline void Add( float A[3],const float B[3],float len) -{ -float wt=len*len; - A[0] += B[0]*wt; A[1] += B[1]*wt; A[2] += B[2]*wt; -} -//_____________________________________________________________________________ -static inline void Sub( float A[3],const float B[3],float C[3]) -{ - A[0] = B[0]-C[0]; A[1] = B[1]-C[1]; A[2] = B[2]-C[2]; -} -//_____________________________________________________________________________ -static inline void Zer( float A[3]) -{ - A[0] =0; A[1] = 0; A[2] =0; -} -//_____________________________________________________________________________ -static inline double Nor(float A[3]) -{ - double sum = A[0]*A[0] + A[1]*A[1] + A[2]*A[2]; - sum = sqrt(sum); - A[0]/=sum;A[1]/=sum;A[2]/=sum; - return sum; -} -//_____________________________________________________________________________ -static inline void Fil(float *A,float F,int nA) -{ - for (int i=0;i0 && mLen <1000 && "mLen is wrong"); - double dot = D0t(mDir,mDir); - assert (fabs(dot-1)<1e-4 && "mDir is wrong"); - for (int i=0;i=0 && mDist[i]< 100 )); - assert( mNbor[i]>=0 || (mDist[i]>=1e10 && mDist[i]<=1e11)); - } - assert(mPhi>= -M_PI*2 && mPhi<=M_PI*2 ); - assert(mThe>= -M_PI/2 && mThe<=M_PI/2); - return 0; -} -//_____________________________________________________________________________ -void StvKNSeedSelector::Insert( int iA,int iB,float dis) -{ - float *a = mAux[iA].mDist; - if (dis >= a[kKNumber-1]) return; - int *n = mAux[iA].mNbor; - auto *detB = mAux[iB].mDet; - for (int jk=0;jka[jk]); - if (n[jk]<0){ - kase|=2; - } else { - auto *detJ = mAux[n[jk]].mDet; - if (detB == detJ) kase|=2; - } - switch (kase) { - case 1: continue; //Bigger only, goto next - case 3: return; //Bigger & same, Get out - case 0: //Insert - for (int j=kKNumber-2;j>=jk;j--) {a[j+1]=a[j]; n[j+1]=n[j];} //Insert - default: a[jk]=dis; n[jk]=iB; //end of list. Replace - } - break; - } - for (int jKNN = kKNumber-1; jKNN>=kKNminber; jKNN--) { - if (mKNNDist[jKNN] < a[jKNN]) continue; - mKNNDist[jKNN] = a[jKNN]; - mMinIdx[jKNN] = iA; - } -} -//_____________________________________________________________________________ -StvKNSeedSelector::StvKNSeedSelector() -{ - mStartHit = 0; - mAux.reserve(100); -} -//_____________________________________________________________________________ -/// Reset first hit position -/// @param float startPos[3] - position of starting hit -/// @param void *startHit - addres of hit. Format of hit is not used there - -void StvKNSeedSelector::Reset(const float startPos[3],const Mtx33F_t *dir, void *startHit) -{ - mState = 0; - mAux.clear(); - mSel.clear(); - mTheDiv.clear(); -#ifdef KNNMAP2 - mTheMap.clear(); -#endif - mDir = dir; - mStartHit = startHit; - memcpy(mStartPos,startPos,sizeof(mStartPos)); - for (int jk = kKNminber; jk(aux.mPhi,last)); - - float myMaxPhi = 2*kSinDis/aux.mCosThe; - if (myMaxPhi>=2*0.99) {myMaxPhi = M_PI;} - else if (myMaxPhi> 2*0.50) {myMaxPhi = 2*asin(myMaxPhi/2);} - - if (aux.mPhi-myMaxPhi<-M_PI) { - last = mAux.size(); mAux.resize(last+1); mAux.back() = aux; - mAux.back().mPhi = aux.mPhi+2*M_PI; - mTheDiv[iThe].insert(std::pair(mAux.back().mPhi,last)); - } - if (aux.mPhi+myMaxPhi> M_PI) { - last = mAux.size(); mAux.resize(last+1); mAux.back() = aux; - mAux.back().mPhi = aux.mPhi-2*M_PI; - mTheDiv[iThe].insert(std::pair(mAux.back().mPhi,last)); - } -#endif -#ifdef KNNMAP2 - mTheMap.insert(std::pair(aux.mThe,last)); -#endif -} -#ifdef KNNMAP0 -//_____________________________________________________________________________ -void StvKNSeedSelector::Relink() -{ - Fil(mMinIdx , -1,kKNumber); - Fil(mKNNDist,kMaxDis,kKNumber); - for (int i1=0;i1<(int)mAux.size();i1++) { -// if ( mAux[i1].mSel) continue; - assert(fabs(mAux[i1].mThe)<= M_PI ); - assert(fabs(mAux[i1].mPhi)<= M_PI*2); - mAux[i1].Reset(); - for (int i2=0;i2KMaxDis) continue; - float dang = fabs(mAux[i1].mPhi-mAux[i2].mPhi); - if (dang > M_PI) dang -= 2*M_PI; - if (fabs(dang)*mAux[i1].mCosThe>KMaxDis) continue; - Update(i1,i2); - } } -} -#endif -#ifdef KNNMAP1 -//_____________________________________________________________________________ -void StvKNSeedSelector::Relink() -{ - Fil(mMinIdx , -1,kKNumber); - Fil(mKNNDist,kMaxDis,kKNumber); - MyTheDiv::iterator it2The = mTheDiv.begin(); - for (MyTheDiv::iterator it1The = mTheDiv.begin(); - it1The != mTheDiv.end();++it1The) //Main loop over theta - { - float the1 = (*it1The).first; - for (;it2The!=mTheDiv.end();++it2The) { - float the2 = (*it2The).first; - if (the2>=the1-kMaxDis) break; - } - if (it2The==mTheDiv.end()) continue; - - - MyPhiDiv &my1PhiDiv = (*it1The).second; //Main phi loop - for (MyPhiDiv::iterator it1Phi=my1PhiDiv.begin(); - it1Phi != my1PhiDiv.end(); - ++it1Phi) {//Main loop over phi - int i1 = (*it1Phi).second; - StvKNAux &aux1 = mAux[i1]; - void* hit1 = aux1.mHit; -// if (aux1.mSel) continue; - // Secondary theta loop - for (MyTheDiv::iterator it3The=it2The;it3The!=mTheDiv.end();++it3The) - { - float the3 = (*it3The).first; - if (the3>aux1.mThe) break; - MyPhiDiv &my3PhiDiv = (*it3The).second; - - float myMaxPhi = 2*kSinDis/aux1.mCosThe; - if (myMaxPhi>=2) {myMaxPhi = M_PI;} - else if (myMaxPhi> 0.5) {myMaxPhi = 2*asin(myMaxPhi/2);} - int n = my3PhiDiv.size(); - MyPhiDiv::iterator it3Phi = (myMaxPhi5)? my3PhiDiv.lower_bound(aux1.mPhi-myMaxPhi) - : my3PhiDiv.begin(); - - for (;it3Phi !=my3PhiDiv.end(); ++it3Phi) { //loop over Phi partner - if ((*it3Phi).first > aux1.mPhi) break; - int i3 = (*it3Phi).second; - if (i3==i1) continue; - StvKNAux & aux3 = mAux[i3]; -// if ( aux3.mSel) continue; - if ( aux3.mHit==hit1) continue; - if (fabs(aux1.mThe-aux3.mThe) > kMaxDis) continue; - float dang = fabs(aux1.mPhi-aux3.mPhi); - if (dang > M_PI) dang -= 2*M_PI; - if (fabs(dang)*aux1.mCosThe>kMaxDis) continue; - Update(i1,i3); - }//end of it3Phi loop - }// end of it3The loop - }//End of main Phi loop - - }//End of main theta loop -} -#endif -#ifdef KNNMAP2 -//_____________________________________________________________________________ -void StvKNSeedSelector::Relink() -{ - Fil(mMinIdx , -1,kKNumber); - Fil(mKNNDist,kMaxDis,kKNumber); - auto it2The = mTheMap.begin(); - for (auto it1The = mTheMap.begin(); - it1The != mTheMap.end();++it1The) //Main loop over theta - { - float the1 = (*it1The).first; - int i1 = (*it1The).second; - auto &aux1 = mAux[i1]; -// if ( aux1.mSel) continue; - for (;it2The!=mTheMap.end();++it2The) { - float the2 = (*it2The).first; - if (the2>=the1-kMaxDis) break; - } - if (it2The==mTheMap.end()) continue; - for (auto it3The=it2The;it3The!=mTheMap.end();++it3The) - { - float the3 = (*it3The).first; - if (the3>the1) break; - int i3 = (*it3The).second; - if (i1 == i3) continue; - if (fabs(the3-the1)>kMaxDis) continue; - auto &aux3 = mAux[i3]; -// if ( aux3.mSel) continue; - float dang = fabs(aux1.mPhi-aux3.mPhi); - if (dang > M_PI) dang -= 2*M_PI; - if (fabs(dang)*aux1.mCosThe>kMaxDis) continue; - Update(i1,i3); - }// end of it3The loop - - }//End of main theta loop -} -#endif - - -//_____________________________________________________________________________ -int StvKNSeedSelector::Select() -{ -static int nCall=0; nCall++; - while (1) { - mSel.clear(); - mMapLen.clear(); - for (int i=0;i<(int)mAux.size();i++) { mAux[i].Test(i); } - - Relink(); - if (!mMinIdx) return 0; - for (int i=0;i<(int)mAux.size();i++) { mAux[i].Test(i); } - - - - for (mIKnn = kKNumber-1;mIKnn>=kKNminber; mIKnn--) - { - if (mMinIdx[mIKnn]<0) continue; -/// define the best direction - mMapLen.clear(); - memcpy(mAveDir,mAux[mMinIdx[mIKnn]].mDir,sizeof(mAveDir)); - assert(fabs(mAveDir[0])+fabs(mAveDir[1])+fabs(mAveDir[2])>0.1); - mNHits=0; - Pass(mMinIdx[mIKnn],mKNNDist[mIKnn]*kDisRatio); - double wid = Width(); - if (wid>90) continue; -if ((mKNNDist[mIKnn]*wid > kMinDis)) { - StvDebug::Count("BadDistWid",sqrt(mKNNDist[mIKnn]*wid)); - StvDebug::Count("BadDist_vs_Wid",sqrt(wid),sqrt(mKNNDist[mIKnn])); -} - if (mKNNDist[mIKnn]*wid > kMinDis) continue; -{ - StvDebug::Count("GooDistWid",sqrt(mKNNDist[mIKnn]*wid)); - StvDebug::Count("GooDist_vs_Wid",sqrt(wid),sqrt(mKNNDist[mIKnn])); -} - - const void *hpPre = 0; - mSel.push_back(mStartHit); - std::map::iterator myIt; - int iPre = 0; - mSel.clear(); - for (myIt = mMapLen.begin(); myIt !=mMapLen.end(); ++myIt) - { - int i = (*myIt).second; - const void *hp = ((StvHit*)(mAux[i].mHit))->detector(); - if (hpPre != hp ) { - mSel.push_back(mAux[i].mHit); - iPre = i;hpPre = hp; - continue; - } - //Hit from the same detector - float ang0 = Ang(mAveDir, mAux[iPre].mDir); - float ang1 = Ang(mAveDir, mAux[i ].mDir); - if (ang0accuAng) break; // the rest even bigger - int idx = aux.mNbor[ifan]; - if (mAux[idx].mSel==mIKnn) continue; - Pass(idx,accuAng); - } -} -//_____________________________________________________________________________ -void StvKNSeedSelector::Update(int ia,int ib) -{ - - if (mAux[ia].mDet == mAux[ib].mDet) return; - float *aDir = mAux[ia].mDir; - float *bDir = mAux[ib].mDir; - - double dis = Ang(aDir,bDir); - if (dis>kMaxDis) return; -// if (dis>mKNNDist) return; - Insert(ia,ib,dis); - Insert(ib,ia,dis); -} -#include "TVector3.h" -//_____________________________________________________________________________ -double StvKNSeedSelector::Width() -{ -static int nCall = 0; nCall++; - if (mMapLen.size()<3) return 1e11; - - TVector3 myX(mAveDir),myZ(myX.Orthogonal()),myY(myZ.Cross(myX)); - double G[3]={0},uv[2]={0}; - std::map::iterator myIt; - - for( myIt=mMapLen.begin(); myIt!=mMapLen.end();++myIt) - { - int i = (*myIt).second; - TVector3 dir(mAux[i].mDir); - double u = myY.Dot(dir); - double v = myZ.Dot(dir); - uv[0]+=u;uv[1]+=v; - G[0]+=u*u;G[1]+=u*v;G[2]+=v*v; - } - double dN = mMapLen.size(); - G[0]/=dN;G[1]/=dN;G[2]/=dN; uv[0]/=dN;uv[1]/=dN; - G[0]-=uv[0]*uv[0];G[1]-=uv[0]*uv[1];G[2]-=uv[1]*uv[1]; - Eigen2(G,mEigen,0); - return sqrt(mEigen[1]/(mEigen[0]+1e-11)); - -} - -#if 1 -#include "TSystem.h" -#include "TCanvas.h" -#include "TGraph.h" -#include "Stv/StvDraw.h" -class StvHit; -//______________________________________________________________________________ -void StvKNSeedSelector::Show() const -{ -static TCanvas *myCanvas = 0; -static TGraph *szGraph = 0; -static TGraph *ptGraph = 0; -static TGraph *slGraph = 0; - int startIdTru = GetIdTru(mStartHit); - std::vector X[3],Y[3]; - double reg[2][2]={{999,-999},{999,-999}}; - - TVector3 mainDir(mStartPos);mainDir*=(-1.); - mainDir = mainDir.Unit(); - TVector3 myX(mainDir),myY(myX.Orthogonal()),myZ(myX.Cross(myY)); - - int nPts = mAux.size(); - for (int ia =0;iau) reg[0][0]=u;if (reg[0][1]v) reg[1][0]=v;if (reg[1][1]Clear(); - delete szGraph; szGraph=0; - delete ptGraph; ptGraph=0; - delete slGraph; slGraph=0; - -// Define the scene - szGraph = new TGraph(2, reg[0], reg[1]); - szGraph->SetMarkerColor(kYellow); - szGraph->SetMarkerSize(5); - szGraph->Draw("AP"); - int color[3]={kGreen,kRed,kMagenta}; - for (int k=0;k<3;k++) { - if (!X[k].size()) continue; - ptGraph = new TGraph(X[k].size(), &X[k][0], &Y[k][0]); - ptGraph->SetMarkerColor(color[k]); - ptGraph->SetMarkerSize(1); - ptGraph->Draw("Same *"); - } - - myCanvas->Modified(); - myCanvas->Update(); - while(!gSystem->ProcessEvents()){gSystem->Sleep(200);}; - -} -#endif //Show -#include "Stv/StvHit.h" -//______________________________________________________________________________ -int StvKNSeedSelector::GetIdTru(const void *hit) const -{ - return ((StvHit*)hit)->idTru(); -} diff --git a/StRoot/StvSeed/StvKNSeedSelector.h b/StRoot/StvSeed/StvKNSeedSelector.h deleted file mode 100644 index 19b81e9111b..00000000000 --- a/StRoot/StvSeed/StvKNSeedSelector.h +++ /dev/null @@ -1,93 +0,0 @@ -/// \File StvKNSeedSelector.h -/// \author Victor Perev 01/2010 -#ifndef StvKNSeedSelector_HH -#define StvKNSeedSelector_HH -#include -#include -#include -#include "StvSeed/StvSeedConst.h" -typedef std::multimap MyPhiDiv; - -typedef std::map MyTheDiv; - - - -#include "TNamed.h" -/// \class StvKNSeedSelector - - -typedef std::vector VoidVec; -enum {kKNumber=5,kKNminber=2}; - -class StvKNAux { -public: - StvKNAux(); - void Reset(); - int Test(int idx) const; -public: - void *mHit; //void pointer to hit - const void *mDet; //void pointer to detector plane - float mLen; //distance from the 1st hit - float mDir[3]; //direction from the 1st hit - float mDist[kKNumber]; //sorted angles to nearest hits - float mPhi; - float mThe; - float mCosThe; - int mNbor[kKNumber]; //indices in Aux array to nearest hits - int mSel; //hit selected -}; - -class StvKNSeedSelector -{ -friend class StvKNSeedFinder; -public: - - StvKNSeedSelector(); - virtual ~StvKNSeedSelector(){;} -virtual int GetIdTru(const void *hit) const; - void Set(int minHits) { mMinHits = minHits;} - void Reset(const float startPos[3],const Mtx33F_t *dir,void *voidHit); - void Add (const float pos[3],void *voidHit, const void *voidDet); - int Select(); -const VoidVec &Get() const { return mSel;} - int GetNHits() const{ return mSel.size();} - void Show() const; -private: - void Relink(); - void Update(int ia,int ib); - void Insert(int ia,int ib,float dis); - void Pass(int iux,double accuAng); - double Width(); -const float *Eigen() const {return mEigen;} -protected: - int mMinHits; - int mState; //Status, &1 =narrow trace - int mIKnn; -const Mtx33F_t *mDir; -void *mStartHit; -float mStartPos[3]; -float mAveDir[3]; -float mStartRad; -float mKNNDist[kKNumber]; //minimal KN distance -int mMinIdx [kKNumber]; //index of aux with minimal KN distance -float mEigen[2];//Eigen numbers of uu,uv,vv matrix in most dense place -float mMaxSel; //Max angle deviation between hits -float mMaxAccu; //Max accumulated angle between hit & bestHit in Pass() -float mMaxNear; //Max angle between hits in Pass() -float mErr; //Estimated space error -int mNHits; //number of selected hits -VoidVec mSel; -std::vector mAux; -std::map mMapLen; -MyTheDiv mTheDiv; -}; -inline StvKNAux::StvKNAux() -{ - memset(this,0,sizeof(*this)); - Reset(); -} -inline void StvKNAux::Reset() -{ - for (int i=0;i -#include -#include -#include -#include -#include -#include "TROOT.h" -#include "TClass.h" -#include "TH1F.h" -#include "TBrowser.h" -#include "TH2F.h" -#include "TProfile.h" -#include "TCanvas.h" -#include "TSystem.h" -#include "TString.h" -#include "StvDebug.h" -#include "StvGrappa.h" - -typedef std::map myTallyMap_t; -typedef myTallyMap_t::const_iterator myTallyIter_t; -static myTallyMap_t mgTally; - -int StvDebug::mgDebug=1; //0=no debug, 1=Normal, 2=count is on -StvGrappa *StvDebug::mgGrappa = 0; -StvGrappa *StvDebug::mgGrappaTmp= 0; - -typedef std::map myDebMap_t; -typedef myDebMap_t::const_iterator myDebIter_t; -static myDebMap_t myDebMap; - -typedef std::map myCanMap_t; -typedef myCanMap_t::const_iterator myCanIter_t; -myCanMap_t myCanMap; - -//______________________________________________________________________________ -int StvDebug::Break(int key) -{ static int kto=-20102017; - if (kto != key) return 0; - printf ("BOT OHO %d\n",key); - return 1; -} -//______________________________________________________________________________ -int StvDebug::Break(double x,double y,double z) -{ static double myX=-9999,myY=-9999,myZ=-9999; - if (fabs(x-myX)>0.2) return 0; - if (fabs(y-myY)>0.2) return 0; - if (fabs(z-myZ)>0.5) return 0; - printf ("BOT OHO %g==%g %g==%g %g==%g\n",x,myX,y,myY,z,myZ); - return 1; -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,double val) -{ - if (mgDebug<2) return; - TH1 *&h = (TH1*&)myDebMap[key]; - if (!h) { h = new TH1F(key,key,100,0.,0.);} - h->Fill(val); -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,const char *val) -{ - if (mgDebug<2) return; - TH1 *&h = (TH1*&)myDebMap[key]; - if (!h) { h = new TH1F(key,key,0,0.,0.);} - h->Fill(val,1.); -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,double val,double left,double rite) -{ - if (mgDebug<2) return; - TH1 *&h = (TH1*&)myDebMap[key]; - if (!h) { h = new TH1F(key,key,100,left,rite);} - h->Fill(val); -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,double valx, double valy - ,double leftx,double ritex - ,double lefty,double ritey) -{ - if (mgDebug<2) return; - TH1 *&h = (TH1*&)myDebMap[key]; - if (!h) { h = new TH2F(key,key,100,leftx,ritex,100,lefty,ritey);} - h->Fill(valx,valy); -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,double valx,double valy) -{ - if (mgDebug<2) return; - TH1 *&h = (TH1*&)myDebMap[key]; - if (!h) { h = new TH2F(key,key,100,0.,0.,100,0,0);} - h->Fill(valx,valy); -} -//______________________________________________________________________________ -void StvDebug::Count(const char *key,const char *valx,double valy) -{ - if (mgDebug<2) return; - TH2 *&h = (TH2*&)myDebMap[key]; - if (!h) { h = new TH2F(key,key,100,0.,0.,100,0,0);} - h->Fill(valx,valy,1.); -} -//______________________________________________________________________________ -//______________________________________________________________________________ -//______________________________________________________________________________ -//______________________________________________________________________________ -#if 0 -//______________________________________________________________________________ -void StvDebug::Sumary(int) -{ - printf("StvDebug::Sumary()\n"); - TH1 *H[4]; - int nH = 0,n=0; - for (myDebIter_t iter = myDebMap.begin();iter != myDebMap.end();++iter) { - TH1 *h = (*iter).second; n++; - if (h->IsA()->InheritsFrom("TH2")) continue; - - int nEnt = h->GetEntries(); - double mean = h->GetMean(); - double rms = h->GetRMS(); - printf("TH1 %2d - %12s:\t %5d %g(+-%g)\n",n,h->GetName(),nEnt,mean,rms); - if (rms<=0) continue; - if (nH==4) {Draw(nH,H);nH=0;} - H[nH++] = h; - } - if (nH) Draw(nH,H); - - for (myDebIter_t iter = myDebMap.begin();iter != myDebMap.end();++iter) { - TH1 *h = (*iter).second; n++; - if (!h->IsA()->InheritsFrom("TH2")) continue; - int nEnt = h->GetEntries(); - double mean = h->GetMean(); - double rms = h->GetRMS(); - printf("TH2 %2d - %12s:\t %5d %g(+-%g)\n",n,h->GetName(),nEnt,mean,rms); - if (rms<=0) continue; - H[0]=h;Draw(1,H); - } - - if (!n) return; - while(!gSystem->ProcessEvents()){}; - -} -#endif -#if 1 -//______________________________________________________________________________ -void StvDebug::Sumary(int nHist) -{ - if (!nHist) nHist=4; - printf("StvDebug::Sumary()\n"); - - int nH = 0,n=0; - for (myTallyIter_t iter = mgTally.begin();iter != mgTally.end();++iter) { - int nn = (*iter).second; n++; - const char *kto = (*iter).first.c_str(); - printf("%3d - Tally.%s = %d\n",n,kto,nn); - } - - - - - TH1 *H[10]; - for (int numCha = 0; numCha<2; numCha++) { - nH = 0;n=0; - for (myDebIter_t iter = myDebMap.begin();iter != myDebMap.end();++iter) { - TH1 *h = (*iter).second; n++; - if (!h->IsA()->InheritsFrom("TH1")) continue; - if ( h->IsA()->InheritsFrom("TH2")) continue; - - int nEnt = h->GetEntries(); - if (!nEnt) continue; - if ((h->GetXaxis()->GetLabels()==0) != (numCha == 0)) continue; - double mean = h->GetMean(); - double rms = h->GetRMS(); - printf("TH1 %2d - %12s:\t %5d %g(+-%g)\n",n,h->GetName(),nEnt,mean,rms); - if (nH==nHist) {Draw(nH,H);nH=0;} - if (numCha) h->LabelsOption(">V","X"); - H[nH++] = h; - } - if (nH) Draw(nH,H); - } - for (myDebIter_t iter = myDebMap.begin();iter != myDebMap.end();++iter) { - TH1 *h = (*iter).second; n++; - if (!h->IsA()->InheritsFrom("TH2")) continue; - int nEnt = h->GetEntries(); - if (!nEnt) continue; - double mean = h->GetMean(); - double rms = h->GetRMS(); - printf("TH2 %2d - %12s:\t %5d %g(+-%g)\n",n,h->GetName(),nEnt,mean,rms); - H[0]=h;//Draw(1,H); - TString ts(h->GetName()); ts+="_pfx"; - H[1] = ((TH2*)h)->ProfileX(ts.Data()); - Draw(2,H); - } - - if (!n) return; - while(!gSystem->ProcessEvents()){}; - -} -#endif -//______________________________________________________________________________ -void StvDebug::Reset() -{ - for (myDebIter_t iter = myDebMap.begin();iter != myDebMap.end();++iter) { - ((*iter).second)->Clear(); - } - for (myCanIter_t iter = myCanMap.begin();iter != myCanMap.end();++iter) { - ((*iter).second)->Clear(); - } -} -//______________________________________________________________________________ -void StvDebug::Draw(int nH,TH1** H) -{ -static int nCall=0; nCall++; - - TString ts("C_"); ts += H[0]->GetName(); - TCanvas *&C = myCanMap[ts.Data()]; - if (!C) C = new TCanvas(ts.Data(),ts.Data(),600,800); - C->Clear();C->Divide(1,nH); - for (int i=0;icd(i+1); H[i]->Draw(); } - - C->Modified();C->Update(); -} -//______________________________________________________________________________ -const char *StvDebug::Env(const char *key) -{ - return gSystem->Getenv(key); -} -//______________________________________________________________________________ -int StvDebug::Inv(const char *key) -{ - return atoi(Env(key)); -} -//______________________________________________________________________________ -int StvDebug::iFlag(const char *flagName,int dflt) -{ - const char *val = gSystem->Getenv(flagName); - if (!val) return dflt; - printf("\nStvDebug::iFlag: %s = %s\n\n",flagName,val); - - return atoi(val); -} - -//______________________________________________________________________________ -double StvDebug::dFlag(const char *flagName, double dflt) -{ - const char *val = gSystem->Getenv(flagName); - if (!val) return dflt; - printf("\nStvDebug::dFlag: %s = %s\n\n",flagName,val); - - return atof(val); -} -//______________________________________________________________________________ -void StvDebug::Browse(const char *name, TObject *obj) -{ - auto *br = new TBrowser(name,obj); - if (br){}; - return; -} -//______________________________________________________________________________ -void StvDebug::AddGra(double x, double y,double z, int iObj) -{ - if (mgDebug<2) return; - if (!mgGrappa)mgGrappa = new StvGrappa("StvDebug"); - mgGrappa->Add(x,y,z,iObj); -} -//______________________________________________________________________________ -void StvDebug::ClearGra() -{ - if (!mgGrappa) return; - mgGrappa->Clear(); -} -//______________________________________________________________________________ -void StvDebug::ShowGra() -{ - if (!mgGrappa) return; - mgGrappa->Show(); -} -//______________________________________________________________________________ -void StvDebug::SetActGra(int akt) -{ - mgGrappa->SetActive(akt); -} -//______________________________________________________________________________ -void StvDebug::Show(const StvTrack* tk) -{ - delete mgGrappaTmp; - mgGrappaTmp = new StvGrappa("BOT OH"); - mgGrappaTmp->Show(tk); -} -//______________________________________________________________________________ -void StvDebug::SaveAll() -{ - TIter nextCanv(gROOT->GetListOfCanvases()); - TCanvas *obj=0; - while((obj=(TCanvas*)nextCanv())) {// loop over Canvas - if (!obj->InheritsFrom("TCanvas")) continue; - TString ts(obj->GetName());ts+=".ps"; - obj->SaveAs(ts); - ts = obj->GetName(); ts+=".png"; - obj->SaveAs(ts); - - } -// while(!gSystem->ProcessEvents()){}; - -} diff --git a/StRoot/StvUtil/StvDebug.h b/StRoot/StvUtil/StvDebug.h deleted file mode 100644 index 54fb9fceacc..00000000000 --- a/StRoot/StvUtil/StvDebug.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __STVDEBUG_h_ -#define __STVDEBUG_h_ -#include "TObject.h" -//------------------------------------------------------------------------------ -class TObject; -class TH1; -class StvGrappa; -class StvTrack; -class StvDebug -{ -public: - StvDebug(){} -static int Break(int kount); -static int Break(double x,double y,double z); -static int Debug() {return mgDebug;}; -static void SetDebug(int idb) {mgDebug=idb;}; -static void Count(const char *key,double val); -static void Count(const char *key,const char *val); -static void Count(const char *key,const char *val,double valy); -static void Count(const char *key,double val,double left,double rite); -static void Count(const char *key,double valx,double valy); -static void Count(const char *key,double valx, double valy - ,double leftx,double ritex - ,double lefty,double ritey); -static void SaveAll(); -static void Sumary(int inPage=4); -static void Reset(); -static const char *Env(const char *key); -static int Inv(const char *key); -static int iFlag(const char *flagName, int dflt=0); -static double dFlag(const char *flagName, double dflt=0); -static void Browse(const char *name, TObject *obj); -// StvGrappa -static void AddGra(double x,double y,double z,int iObj); -static void ClearGra(); -static void ShowGra(); -static void Show(const StvTrack*); -static void SetActGra(int akt = 1); - -private: -static void Draw(int nH,TH1** H); -public: -static int mgDebug; -static StvGrappa *mgGrappa; -static StvGrappa *mgGrappaTmp; - - -#if 0 -ClassDef(StvDebug,0) -#endif -}; -#endif diff --git a/StRoot/StvUtil/StvELossTrak.cxx b/StRoot/StvUtil/StvELossTrak.cxx deleted file mode 100644 index 744e9cd1f06..00000000000 --- a/StRoot/StvUtil/StvELossTrak.cxx +++ /dev/null @@ -1,755 +0,0 @@ -// $Id: StvELossTrak.cxx,v 1.17 2015/06/18 23:31:26 perev Exp $ -// -// -// Class StvELossTrak -// ------------------ -#include -#include -#include -#include -#include "TGeoMaterial.h" -#include "StvUtil/StvDebug.h" -#include "StvELossTrak.h" -static int gNoEloss = 0; - -//SUBROUTINE G3DRELX(A,Z,DENS,T,HMASS,DEDX) - -static double gsigma2(double ZoverA,double DENS,double CHARGE2 - ,double AMASS ,double BET2,double STEP ); -//static double gdrelx (double A ,double Z ,double DENS ,double T,double HMASS); - -static const double kPiMass=0.13956995; -static const double kMinP = 0.01,kMinE = sqrt(kMinP*kMinP+kPiMass*kPiMass); -static const double kMaxP = 1000,kMaxE = sqrt(kMaxP*kMaxP+kPiMass*kPiMass); -static const double kMaxFak=1,kMaxTheta2=1,kMaxPartOfE = 0.1; -static const double kMomTol=1e-2; - -ClassImp(StvELossTrak) - -//_____________________________________________________________________________ -StvELossTrak::StvELossTrak() -{ - gNoEloss = StvDebug::iFlag("NOELOSS"); - memset(fBeg,0,fEnd-fBeg+1); -} -//______________________________________________________________________________ -void StvELossTrak::reset() -{ - fMats.clear(); - memset(fBeg,0,fEnd-fBeg+1); -} -//______________________________________________________________________________ -void StvELossTrak::unset() -{ - fMats.clear(); -} -//_____________________________________________________________________________ -void StvELossTrak::Reset(int dir,double mass, double charge) -{ - memset(fBeg,0,fEnd-fBeg+1); - fMats.clear(); - fDir = dir; fM=mass; fCharge=charge; - -} -//_____________________________________________________________________________ -void StvELossTrak::Clear(const char*) -{ - memset(fMed,0,fEnd-fMed+1); -} -//_____________________________________________________________________________ -void StvELossTrak::Set(double A, double Z, double dens, double x0, double p,const TGeoMaterial *mate) -{ - fdEdX=0; - if (p<=0) p = fP[1]; - if (pkMaxP) p=kMaxP; - if (A<=0) x0 = 1e+11; - if (!Same(A,Z,dens,x0,p)) { - // Normal, non update mode. Save material data - fMats.resize(fMats.size()+1); - Aux &M = fMats.back(); - M.fLen=0; - M.fA=A; - M.fZ=Z; - M.fDens=dens; - M.fX0=x0; - M.fP = p; -assert(mate); - M.fMat = mate; - } - if (fP[0]<=0) fP[0] = p; - fP[1] = p; - fdEdX=0;fdEdXErr2=0; - double p2 = fP[1]*fP[1],m2 = fM*fM; - fE = sqrt(p2+m2); - fFak = (14.1*14.1)*(p2+m2)/(p2*p2*1e6); - if (fFak>kMaxFak) fFak = kMaxFak; - double T = fE-fM; - if (A>0) { - double charge2 = fCharge*fCharge; - if (!mate || !mate->IsMixture()) { //it is not mixture - fdEdX = gdrelx(A,Z,dens,T,fM)*dens*charge2; - - } else { //Mixture case - - fdEdX = 0; - const TGeoMixture *mix = (const TGeoMixture*)mate; - int nMix = mix->GetNelements(); - const double *wt = mix->GetWmixt(); - const double *zz = mix->GetZmixt(); - const double *aa = mix->GetAmixt(); - for (int iMix=0;iMix kAccu*M.fA) return 0; - if (fabs(M.fZ-Z)> kAccu*M.fZ) return 0; - if (fabs(M.fDens-dens)> 1e-5+kAccu*M.fDens) return 0; - if (fabs(M.fP-p)> 1e-3*M.fP) return 0; - return 1; -} -//_____________________________________________________________________________ -void StvELossTrak::Set(const TGeoMaterial *mate,double p) -{ - Set(mate->GetA(),mate->GetZ(),mate->GetDensity(),mate->GetRadLen(),p,mate); -} -//______________________________________________________________________________ -//_____________________________________________________________________________ -void StvELossTrak::Add(double len) -{ -// fMCS[0] = Thet2*L1*( L1*L1/3+L0*(L1+L0) ); -// fMCS[1] = Thet2*L1*( -L1-2*L0); -// fMCS[2] = Thet2*L1; -// return fMCS[0]+L*(fMCS[1]+L*fMCS[2]); -static int nCall=0; nCall++; -StvDebug::Break(nCall); - double myLen = len; - while (1) { - double dP = fP[1]*kMomTol; - double dE = dP*fP[1]/fE; - double dL = dE/(fdEdX+1e-11); - if (fDir && fP[1]-dPmyLen) dL=myLen; - Aux &aux = fMats.back(); - aux.fLen+=dL; - double QQ = fFak/fMats.back().fX0; - double theta2 = QQ*dL; - if (theta2 >kMaxTheta2) theta2 = kMaxTheta2; - if (fMCS[2]+theta2>kMaxTheta2) theta2 = kMaxTheta2-fMCS[2]; - fMCS[2] += theta2; - fMCS[1] += theta2*(-2*fTotLen - dL); - fMCS[0] += theta2*(dL*dL/3+fTotLen*(fTotLen+dL)); -assert(fMCS[2]< kMaxTheta2*1.1); - double ELoss = fdEdX *dL; - if ( ELoss > kMaxPartOfE*fE) ELoss = kMaxPartOfE*fE; - fTotELoss += ELoss; - if (fTotELoss > kMaxPartOfE*fE) fTotELoss = kMaxPartOfE*fE; - - fTotELossErr2 += fdEdXErr2*dL; - dP = ELoss*fE/fP[1]; - if (fDir) { fP[1]-=dP; if (fP[1]0.1) dP = log(1.+dP); - - double dE = (eNow-eBef)/eBef; - if (fabs(dE)>0.1) dE = log(1.+dE); - fdLogEdLogP = dE/dP; - - -} -//_____________________________________________________________________________ -void StvELossTrak::Update() const -{ - double dP = fP[0]*0.01; - StvELossTrak elt = *this; - elt.Update(fDir,fP[0]+dP); - fdLogEdLogP = elt.fdLogEdLogP; -} -//_____________________________________________________________________________ -void StvELossTrak::Print(const char *opt) const -{ - printf("ELossTrak: dir=%d q=%d mass=%g p=%g %g totLen=%g totELoss=%g\n" - ,int(fDir),int(fCharge),fM,fP[0],fP[1],fTotLen,fTotELoss); - double totLen = 0,totE=0; - for (int i=0;i<(int)fMats.size();i++) { - const Aux &M = fMats[i]; - double dE = M.fLen*M.fdEdX; - double T = sqrt(M.fP*M.fP+fM*fM)-fM; - printf("%6.3f totE=%g T=%g dL=%g dens=%g dE=%g dEdX=%g\n" - ,totLen,totE,T,M.fLen,M.fDens,dE,M.fdEdX); - totLen+=M.fLen; totE+=dE; - } -} -//_____________________________________________________________________________ -class AofZ_t { -public: -int mZ; -double mA; -char mName[8]; -char mTitle[20]; -}; -#if 1 -//______________________________________________________________________________ -//* Revision 1.1.1.1 1995/10/24 10:21:24 cernlib -//* Geant -//* -//* -//#include "geant321/pilot.h" -//*CMZ : 3.21/03 06/10/94 18.22.43 by S.Giani -//*-- Author : -//______________________________________________________________________________ -// SUBROUTINE GDRELX(A,Z,DENS,T,HMASS,dedx) -double StvELossTrak::gdrelx(double A1,double Z1,double DENS1,double T1,double HMASS1) -{ -// -// ****************************************************************** -// * * -// * Calculates the mean 1/DENS*dE/dx of a particle with kinetic * -// * energy T in an element of atomic number Z, atomic weight A * -// * and density DENS ( the density is just used for the * -// * calculation of the density effect in the case of high T). * -// * The routine reproduces the experimental and/or tabulated * -// * energy losses rather well down to T -> 0. * -// * Simple parametrization is used for T .le. T2L=2 MeV (see * -// * H.H.Andersen,J.F.Ziegler:Hydrogen stopping powers and * -// * ranges in all element,Pergamon Press,1977.). * -// * For T .gt. T2L=2 MeV the corrected Bethe-Bloch stopping * -// * power / restricted energy loss formula is used. * -// * * -// * * -// * ==>Called by : GDRELA * -// * Author L.Urban ********* * -// * * -// ****************************************************************** -// -//#include "geant321/gconsp.inc" -//#include "geant321/gccuts.inc" -//#include "geant321/gcunit.inc" -#define double float -float A=A1,Z=Z1,DENS=DENS1,T=T1,HMASS=HMASS1; - - - -static const double AMUKEV=931494.32,AMUKEV50=pow(AMUKEV,0.50),AMUKEV45=pow(AMUKEV,0.45); -static const double D=0.000153537,T1L=0.00001,T2L=0.002; -static const double AVO=0.60221367,EMPROT=0.9382723,EMASS=0.0005109990615; -static const double DCUTM=0.001; -//DIMENSION B(6,92),C(6,92),CECOF[6] -//* -static const double B[93][6]={ - {0.}, - {1.262 ,1.44 ,242.6 ,12000. ,0.1159 ,18.8}, - {1.229 ,1.397 ,484.5 ,5873. ,0.05225 ,41.7}, - {1.411 ,1.6 ,725.6 ,3013. ,0.04578 ,47.6}, - {2.248 ,2.59 ,966. ,153.8 ,0.03475 ,62.7}, - {2.474 ,2.815 ,1206. ,1060. ,0.02855 ,76.0}, - {2.631 ,2.989 ,1445. ,957.2 ,0.02819 ,77.3}, - {2.954 ,3.35 ,1683. ,1900. ,0.02513 ,86.7}, - {2.652 ,3. ,1920. ,2000. ,0.0223 ,97.7}, - {2.085 ,2.352 ,2157. ,2634. ,0.01816 ,120.}, - {1.951 ,2.199 ,2393. ,2699. ,0.01568 ,139.}, - {2.542 ,2.869 ,2628. ,1854. ,0.01472 ,148.}, - {3.792 ,4.293 ,2862. ,1009. ,0.01397 ,156.}, - {4.154 ,4.739 ,2766. ,164.5 ,0.02023 ,162.}, - {4.15 ,4.7 ,3329. ,550. ,0.01321 ,165.}, - {3.232 ,3.647 ,3561. ,1560. ,0.01267 ,172.}, - {3.447 ,3.891 ,3792. ,1219. ,0.01211 ,180.}, - {5.047 ,5.714 ,4023. ,878.6 ,0.01178 ,185.}, - {5.731 ,6.5 ,4253. ,530. ,0.01123 ,194.}, - {5.151 ,5.833 ,4482. ,545.7 ,0.01129 ,193.}, - {5.521 ,6.252 ,4710. ,553.3 ,0.01112 ,196.}, - {5.201 ,5.884 ,4938. ,560.9 ,0.009995 ,218.}, - {4.862 ,5.496 ,5165. ,568.5 ,0.009474 ,230.}, - {4.48 ,5.055 ,5391. ,952.3 ,0.009117 ,239.}, - {3.983 ,4.489 ,5616. ,1336. ,0.008413 ,259.}, - {3.469 ,3.907 ,5725. ,1461. ,0.008829 ,270.}, - {3.519 ,3.963 ,6065. ,1243. ,0.007782 ,280.}, - {3.14 ,3.535 ,6288. ,1372. ,0.007361 ,296.}, - {3.553 ,4.004 ,6205. ,555.1 ,0.008763 ,310.}, - {3.696 ,4.175 ,4673. ,387.8 ,0.02188 ,322.}, - {4.21 ,4.75 ,6953. ,295.2 ,0.006809 ,320.}, - {5.041 ,5.697 ,7173. ,202.6 ,0.006725 ,324.}, - {5.554 ,6.3 ,6496. ,110. ,0.009689 ,330.}, - {5.323 ,6.012 ,7611. ,292.5 ,0.006447 ,338.}, - {5.874 ,6.656 ,7395. ,117.5 ,0.007684 ,340.}, - {5.611 ,6.335 ,8046. ,365.2 ,0.006244 ,349.}, - {6.411 ,7.25 ,8262. ,220. ,0.006087 ,358.}, - {5.694 ,6.429 ,8478. ,292.9 ,0.006087 ,358.}, - {6.339 ,7.159 ,8693. ,330.3 ,0.006003 ,363.}, - {6.407 ,7.234 ,8907. ,367.8 ,0.005889 ,370.}, - {6.734 ,7.603 ,9120. ,405.2 ,0.005765 ,378.}, - {6.902 ,7.791 ,9333. ,442.7 ,0.005587 ,390.}, - {6.425 ,7.248 ,9545. ,480.2 ,0.005367 ,406.}, - {6.799 ,7.671 ,9756. ,517.6 ,0.005315 ,410.}, - {6.108 ,6.887 ,9966. ,555.1 ,0.005151 ,423.}, - {5.924 ,6.677 ,10180. ,592.5 ,0.004919 ,443.}, - {5.238 ,5.9 ,10380. ,630. ,0.004758 ,458.}, - {5.623 ,6.354 ,7160. ,337.6 ,0.01394 ,466.}, - {5.814 ,6.554 ,10800. ,355.5 ,0.004626 ,471.}, - {6.23 ,7.024 ,11010. ,370.9 ,0.00454 ,480.}, - {6.41 ,7.227 ,11210. ,386.4 ,0.004474 ,487.}, - {7.5 ,8.48 ,8608. ,348. ,0.009074 ,494.}, - {6.979 ,7.871 ,11620. ,392.4 ,0.004402 ,495.}, - {7.725 ,8.716 ,11830. ,394.8 ,0.004376 ,498.}, - {8.231 ,9.289 ,12030. ,397.3 ,0.004384 ,497.}, - {7.287 ,8.218 ,12230. ,399.7 ,0.004447 ,490.}, - {7.899 ,8.911 ,12430. ,402.1 ,0.004511 ,483.}, - {8.041 ,9.071 ,12630. ,404.5 ,0.00454 ,480.}, - {7.489 ,8.444 ,12830. ,406.9 ,0.00442 ,493.}, - {7.291 ,8.219 ,13030. ,409.3 ,0.004298 ,507.}, - {7.098 ,8. ,13230. ,411.8 ,0.004182 ,521.}, - {6.91 ,7.786 ,13430. ,414.2 ,0.004058 ,537.}, - {6.728 ,7.58 ,13620. ,416.6 ,0.003976 ,548.}, - {6.551 ,7.38 ,13820. ,419. ,0.003877 ,562.}, - {6.739 ,7.592 ,14020. ,421.4 ,0.003863 ,564.}, - {6.212 ,6.996 ,14210. ,423.9 ,0.003725 ,585.}, - {5.517 ,6.21 ,14400. ,426.3 ,0.003632 ,600.}, - {5.219 ,5.874 ,14600. ,428.7 ,0.003498 ,623.}, - {5.071 ,5.706 ,14790. ,433. ,0.003405 ,640.}, - {4.926 ,5.542 ,14980. ,433.5 ,0.003342 ,652.}, - {4.787 ,5.386 ,15170. ,435.9 ,0.003292 ,662.}, - {4.893 ,5.505 ,15360. ,438.4 ,0.003243 ,672.}, - {5.028 ,5.657 ,15550. ,440.8 ,0.003195 ,682.}, - {4.738 ,5.329 ,15740. ,443.2 ,0.003186 ,684.}, - {4.574 ,5.144 ,15930. ,442.4 ,0.003144 ,693.}, - {5.2 ,5.851 ,16120. ,441.6 ,0.003122 ,698.}, - {5.07 ,5.704 ,16300. ,440.9 ,0.003082 ,707.}, - {4.945 ,5.563 ,16490. ,440.1 ,0.002965 ,735.}, - {4.476 ,5.034 ,16670. ,439.3 ,0.002871 ,759.}, - {4.856 ,5.46 ,18320. ,438.5 ,0.002542 ,755.}, - {4.308 ,4.843 ,17040. ,487.8 ,0.002882 ,756.}, - {4.723 ,5.311 ,17220. ,537. ,0.002913 ,748.}, - {5.319 ,5.982 ,17400. ,586.3 ,0.002871 ,759.}, - {5.956 ,6.7 ,17800. ,677. ,0.00266 ,765.}, - {6.158 ,6.928 ,17770. ,586.3 ,0.002812 ,775.}, - {6.204 ,6.979 ,17950. ,586.3 ,0.002776 ,785.}, - {6.181 ,6.954 ,18120. ,586.3 ,0.002748 ,793.}, - {6.949 ,7.82 ,18300. ,586.3 ,0.002737 ,796.}, - {7.506 ,8.448 ,18480. ,586.3 ,0.002727 ,799.}, - {7.649 ,8.609 ,18660. ,586.3 ,0.002697 ,808.}, - {7.71 ,8.679 ,18830. ,586.3 ,0.002641 ,825.}, - {7.407 ,8.336 ,19010. ,586.3 ,0.002603 ,837.}, - {7.29 ,8.204 ,19180. ,586.3 ,0.002573 ,847.}}; - -static const double CECOF[7]={0.,0.42237,0.0304,-0.00038,3.858,-0.1668,0.00158}; -static double C[6]={0}; -enum {kNAW=118}; -AofZ_t AW[kNAW]={ -{1,1.0079, "H", "Hydrogen" }, -{2,4.0026, "He", "Helium" }, -{3,6.941, "Li", "Lithium" }, -{4,9.0122, "Be", "Beryllium" }, -{5,10.811, "B", "Boron" }, -{6,12.0107, "C", "Carbon" }, -{7,14.0067, "N", "Nitrogen" }, -{8,15.9994, "O", "Oxygen" }, -{9,18.9984, "F", "Fluorine" }, -{10,20.1797, "Ne", "Neon" }, -{11,22.9897, "Na", "Sodium" }, -{12,24.305, "Mg", "Magnesium" }, -{13,26.9815, "Al", "Aluminum" }, -{14,28.0855, "Si", "Silicon" }, -{15,30.9738, "P", "Phosphorus" }, -{16,32.065, "S", "Sulfur" }, -{17,35.453, "Cl", "Chlorine" }, -{18,39.948, "Ar", "Argon" }, -{19,39.0983, "K", "Potassium" }, -{20,40.078, "Ca", "Calcium" }, -{21,44.9559, "Sc", "Scandium" }, -{22,47.867, "Ti", "Titanium" }, -{23,50.9415, "V", "Vanadium" }, -{24,51.9961, "Cr", "Chromium" }, -{25,54.938, "Mn", "Manganese" }, -{26,55.845, "Fe", "Iron" }, -{27,58.9332, "Co", "Cobalt" }, -{28,58.6934, "Ni", "Nickel" }, -{29,63.546, "Cu", "Copper" }, -{30,65.39, "Zn", "Zinc" }, -{31,69.723, "Ga", "Gallium" }, -{32,72.64, "Ge", "Germanium" }, -{33,74.9216, "As", "Arsenic" }, -{34,78.96, "Se", "Selenium" }, -{35,79.904, "Br", "Bromine" }, -{36,83.8, "Kr", "Krypton" }, -{37,85.4678, "Rb", "Rubidium" }, -{38,87.62, "Sr", "Strontium" }, -{39,88.9059, "Y", "Yttrium" }, -{40,91.224, "Zr", "Zirconium" }, -{41,92.9064, "Nb", "Niobium" }, -{42,95.94, "Mo", "Molybdenum" }, -{43,98, "Tc", "Technetium" }, -{44,101.07, "Ru", "Ruthenium" }, -{45,102.906, "Rh", "Rhodium" }, -{46,106.42, "Pd", "Palladium" }, -{47,107.868, "Ag", "Silver" }, -{48,112.411, "Cd", "Cadmium" }, -{49,114.818, "In", "Indium" }, -{50,118.71, "Sn", "Tin" }, -{51,121.76, "Sb", "Antimony" }, -{52,127.6, "Te", "Tellurium" }, -{53,126.904, "I", "Iodine" }, -{54,131.293, "Xe", "Xenon" }, -{55,132.905, "Cs", "Cesium" }, -{56,137.327, "Ba", "Barium" }, -{57,138.905, "La", "Lanthanum" }, -{58,140.116, "Ce", "Cerium" }, -{59,140.908, "Pr", "Praseodymium" }, -{60,144.24, "Nd", "Neodymium" }, -{61,145, "Pm", "Promethium" }, -{62,150.36, "Sm", "Samarium" }, -{63,151.964, "Eu", "Europium" }, -{64,157.25, "Gd", "Gadolinium" }, -{65,158.925, "Tb", "Terbium" }, -{66,162.5, "Dy", "Dysprosium" }, -{67,164.93, "Ho", "Holmium" }, -{68,167.259, "Er", "Erbium" }, -{69,168.934, "Tm", "Thulium" }, -{70,173.04, "Yb", "Ytterbium" }, -{71,174.967, "Lu", "Lutetium" }, -{72,178.49, "Hf", "Hafnium" }, -{73,180.948, "Ta", "Tantalum" }, -{74,183.84, "W", "Tungsten" }, -{75,186.207, "Re", "Rhenium" }, -{76,190.23, "Os", "Osmium" }, -{77,192.217, "Ir", "Iridium" }, -{78,195.078, "Pt", "Platinum" }, -{79,196.966, "Au", "Gold" }, -{80,200.59, "Hg", "Mercury" }, -{81,204.383, "Tl", "Thallium" }, -{82,207.2, "Pb", "Lead" }, -{83,208.98, "Bi", "Bismuth" }, -{84,209, "Po", "Polonium" }, -{85,210, "At", "Astatine" }, -{86,222, "Rn", "Radon" }, -{87,223, "Fr", "Francium" }, -{88,226, "Ra", "Radium" }, -{89,227, "Ac", "Actinium" }, -{90,232.038, "Th", "Thorium" }, -{91,231.036, "Pa", "Protactinium" }, -{92,238.029, "U", "Uranium" }, -{93,237, "Np", "Neptunium" }, -{94,244, "Pu", "Plutonium" }, -{95,243, "Am", "Americium" }, -{96,247, "Cm", "Curium" }, -{97,247, "Bk", "Berkelium" }, -{98,251, "Cf", "Californium" }, -{99,252, "Es", "Einsteinium" }, -{100,257, "Fm", "Fermium" }, -{101,258, "Md", "Mendelevium" }, -{102,259, "No", "Nobelium" }, -{103,262, "Lr", "Lawrencium" }, -{104,261, "Rf", "Rutherfordium" }, -{105,262, "Db", "Dubnium" }, -{106,266, "Sg", "Seaborgium" }, -{107,264, "Bh", "Bohrium" }, -{108,277, "Hs", "Hassium" }, -{109,268, "Mt", "Meitnerium" }, -{110,0, "Ds", "Darmstadtium" }, -{111,272, "Rg", "Roentgenium" }, -{112,0, "Uub", "Ununbium" }, -{113,0, "Uut", "Ununtrium" }, -{114,0, "Uuq", "Ununquadium" }, -{115,0, "Uup", "Ununpentium" }, -{116,0, "Uuh", "Ununhexium" }, -{117,0, "Uus", "Ununseptium" }, -{118,0, "Uuo", "Ununoctium" }}; - -double poti,p,e,beta,bet2,tau,sl,sh,eta,eta2,b2g2,tmax,cc,x0,x1,xa,xm,delta; -double f1,f2,f3,f4,f5,tupp,ce,st,sbb,dedx; -//* ------------------------------------------------------------------ -//* in the case of non-integer Z the low energy parameters -//* and the ionization potential are taken at INT(Z) ! -//* - int iz=(int)(Z+1e-8); if (iz == 92) iz = 91; - double wt1=Z-iz,wt0 = 1-wt1; - assert((iz>0)&&(iz<92)); -//* -//* Calculate coefficients C(I,J) if it has not been done already -//* - double fac0=AVO/AW[iz ].mA; - double fac1=AVO/AW[iz+1].mA; - C[0]=AMUKEV50*(B[iz][0]*wt0*fac0+B[iz+1][0]*wt1*fac1); - C[1]=AMUKEV45*(B[iz][1]*wt0*fac0+B[iz+1][1]*wt1*fac1); - C[2]= (B[iz][2]*wt0*fac0+B[iz+1][2]*wt1*fac1)/AMUKEV; - C[3]= (B[iz][3]*wt0 +B[iz+1][3]*wt1 )/AMUKEV; - C[4]=AMUKEV* (B[iz][4]*wt0 +B[iz+1][4]*wt1 ); -//* poti=16.E-9*Z**0.9 - C[5]= (B[iz][5]*wt0+B[iz+1][5]*wt1)*1.E-9; -//* -//* ---------------------------------------------------------------- - double hmass2 = HMASS*HMASS; - double T1LIM=HMASS*T1L/EMPROT; - double T2LIM=HMASS*T2L/EMPROT; -//* -//* Calculate dE/dx -//* ---> for T .le. T1LIM (very low energy) -//* - if (gNoEloss) return 0; - if(T<=T1LIM) { - tau=T/HMASS; - dedx=C[0]*pow(tau,0.5); - } else { -//* -//* ---> for T1LIM .lt. T and T .le. T2LIM (low energy) -//* - if(T<=T2LIM) { - tau=T/HMASS; - sl=C[1]*pow(tau,0.45); - sh=C[2]*log(1.+C[3]/tau+C[4]*tau)/tau; - dedx=sl*sh/(sl+sh); -//* -//* ---> for T .gt. T2LIM ( "high " energy , Bethe-Bloch formula) -//* - } else { - p=sqrt(T*(T+2.*HMASS)); - e=T+HMASS; - beta=p/e; - bet2=beta*beta; - eta=p/HMASS; - eta2=eta*eta; -//*+++ new line follows..... - b2g2=eta*eta; -//*+++ end of correction - tmax=2.*EMASS*T*(T+2.*HMASS); -//*+++ correction of the next line -//* tmax=tmax/(HMASS**2+EMASS**2+EMASS*(T+HMASS)); - tmax=tmax/(hmass2+EMASS*(EMASS+2.*e)); -//*+++ end of correction -//* -//* density correction -//* - poti=C[5]; - cc=1.+2.*log(poti/(28.8E-9*sqrt(DENS*Z/A))); -//* condensed material ? ( dens .gt. 0.05 ? ) - if(DENS>0.05) { - if(poti < 1.E-7) { - if(cc < 3.681) { - x0=0.2; - } else { - x0=0.326*cc-1.; - } - x1=2.; - } else { - if(cc < 5.215) { - x0=0.2; - } else { - x0=0.326*cc-1.5; - } - x1=3.; - } -//* gas ? ( dens . le . 0.05 ? ) - } else { - if(cc<=12.25) { - int ip=(int)((cc-10.)/0.5)+1; - if(ip < 0) ip=0; - if(ip>4) ip=4; - x0=1.6+0.1*ip; - x1=4.; - } else { - if(cc<=13.804) { - x0=2.; - x1=5.; - } else { - x0=0.326*cc-2.5; - x1=5.; - } - } - } -//* - xa=cc/4.606; - xm=3.; - double aa=4.606*(xa-x0)/pow(x1-x0,xm); -//* - double x=log10(eta); - delta=0.; - if(x>x0) { - delta=4.606*x-cc; - if(x < x1) delta=delta+aa*pow(x1-x,xm); - } -//* -//* calculate shell correction -//* - double potsq=poti*poti; - if(eta>0.13) { - f1=1./eta2; - f2=f1*f1; - f3=f1*f2; - f4=(f1*CECOF[1]+f2*CECOF[2]+f3*CECOF[3])*1.E+12; - f5=(f1*CECOF[4]+f2*CECOF[5]+f3*CECOF[6])*1.E+18; - ce=f4*potsq+f5*potsq*poti; - } else { - eta2=0.0169; - f1=1./eta2; - f2=f1*f1; - f3=f1*f2; - f4=(f1*CECOF[1]+f2*CECOF[2]+f3*CECOF[3])*1.E+12; - f5=(f1*CECOF[4]+f2*CECOF[5]+f3*CECOF[6])*1.E+18; - ce=f4*potsq+f5*potsq*poti; - ce=ce*log(T/T2LIM)/log(0.0079/T2LIM); - } -//* - f1=D*Z/(A*bet2); -//* -//* stopping power or restricted dE/dx ? -//* -//*+++ correction of the next few lines -//* if(DCUTM.GE.tmax) { -//* f2=2.*(log(tmax/poti)-bet2) -//* } else { -//* f2=log(tmax*DCUTM/potsq)-bet2*(1.+DCUTM/tmax) -//* } - tupp=DCUTM; - if(tmax < DCUTM) tupp=tmax; - f2=log(2.*EMASS*b2g2/poti)+log(tupp/poti)-bet2*(1.+tupp/tmax); -//*+++ end of correction - dedx=f1*(f2-delta-2.*ce/Z); -//* -//* - tau=T2LIM/HMASS; - sl=C[1]*pow(tau,0.45); - sh=C[2]*log(1.+C[3]/tau+C[4]*tau)/tau; - st=sl*sh/(sl+sh); -//* - tmax=2.*EMASS*T2LIM*(T2LIM+2.*HMASS); -//*+++ correction of the next line -//* tmax=tmax/(HMASS**2+EMASS**2+EMASS*(T2LIM+HMASS)); - tmax=tmax/(HMASS*HMASS+EMASS*EMASS+2.*EMASS*(T2LIM+HMASS)); -//*+++ end of correction - bet2=T2LIM*(T2LIM+2.*HMASS)/pow(T2LIM+HMASS,2); - sbb=2.*(log(tmax/poti)-bet2); - sbb=D*Z*sbb/(A*bet2); - double corbb=(st/sbb-1.)*T2LIM; -//* - dedx=dedx*(1.+corbb/T); -//* - } - } - return dedx; -} -#endif //0 -// -#undef double - -//*CMZ : 3.21/02 29/03/94 15.41.21 by S.Giani -//-- Author : -//______________________________________________________________________________ -double gsigma2(double ZoverA,double DENS,double CHARGE2 - ,double AMASS ,double BET2,double STEP ) -{ -// SUBROUTINE GFLUCT(DEMEAN,DE) - -static const double DGEV=0.153536E-3,EMASS=0.0005109990615; -// - double gamm2 = 1./(1.-BET2); - double gamma = sqrt(gamm2); -// -// *** low energy transfer - double xi = DGEV*CHARGE2*STEP*DENS*ZoverA/(BET2); -// -// Energy straggling using Gaussian -// STEP = current step-length (cm) -// Author : G.N. Patrick -// -// -// Maximum energy transfer to atomic electron (GeV). - double eta2 = BET2*gamm2; - double ratio = EMASS/AMASS; - double emax =(2*EMASS*eta2)/(1+2*ratio*gamma+ratio*ratio); -// -// +-----------------------------------+ -// I Sample from Gaussian distribution I -// +-----------------------------------+ - double sigma2 = xi*(1.-0.5*BET2)*emax; - return sigma2; -} diff --git a/StRoot/StvUtil/StvELossTrak.h b/StRoot/StvUtil/StvELossTrak.h deleted file mode 100644 index ce220bb050a..00000000000 --- a/StRoot/StvUtil/StvELossTrak.h +++ /dev/null @@ -1,78 +0,0 @@ -// $Id: StvELossTrak.h,v 1.11 2015/06/18 02:10:39 perev Exp $ -// -// -// Class StvELossTrak -// ------------------ - - -#ifndef STIELOSSTRAK_H -#define STIELOSSTRAK_H -#include "TObject.h" -#include "vector" -class TGeoMaterial; -static const double PiMASS=0.13956995; - -class StvELossTrak : public TObject -{ -public: -class Aux { -public: -Aux(){memset(this,0,sizeof(*this));} - -const TGeoMaterial* fMat; -float fLen,fP,fdEdX,fA,fZ,fDens,fX0; -}; -typedef std::vector AuxVect; -public: - StvELossTrak(); - ~StvELossTrak(){;} - void Reset(int dir,double mass=PiMASS, double charge=1); - void Clear(const char *opt=""); - int Same(double A, double Z, double dens, double x0, double p) const; - void Set (double A, double Z, double Dens, double x0, double p,const TGeoMaterial *mate); - void Set (const TGeoMaterial *mate, double p); - void Set (double p); - void Add(double len); - void Update(int dir,double Pmom); - void Update() const; - double GetTheta2() const; - double GetOrt2() const; - - double dEdX () const {return fTotELoss/fTotLen;} - double ELoss() const {return fTotELoss;} - double ELossErr2() const {return fTotELossErr2;} - double PLoss(double p) const; - double dPLossdP0(double p) const; - double TotLen() const {return fTotLen;} - double P() const {return fP[0];} - double M() const {return fM;} - int GetNMats() const {return fMats.size();} - const Aux &GetMate(int idx); - void reset(); - void unset(); - void Print(const char *opt) const; -static double gdrelx(double A,double Z,double DENS,double T,double HMASS); - - -private: -char fBeg[1]; -char fDir; -char fCharge; //particle charge -double fM; //mass -double fdEdX,fdEdXErr2; -double fP[2]; //momentum start & end -double fE; //energy -double fFak; -// -char fMed[1]; -double fTotELoss; ///accumulated energy loss -double fTotELossErr2; ///accumulated error of energy loss -double fTotLen; ///accumulated track length -double fMCS[3]; /// -mutable double fdLogEdLogP; /// d(log(dEdx)/dLog(p) -char fEnd[1]; -AuxVect fMats; -ClassDef(StvELossTrak,0) -}; -#endif //STIELOSSTRAK_H - diff --git a/StRoot/StvUtil/StvFtsHitErrCalculator.cxx b/StRoot/StvUtil/StvFtsHitErrCalculator.cxx deleted file mode 100644 index 298c759af5a..00000000000 --- a/StRoot/StvUtil/StvFtsHitErrCalculator.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#include "StvFtsHitErrCalculator.h" -ClassImp(StvFtsHitErrCalculator) - - diff --git a/StRoot/StvUtil/StvFtsHitErrCalculator.cxx.C b/StRoot/StvUtil/StvFtsHitErrCalculator.cxx.C deleted file mode 100644 index 13648b37658..00000000000 --- a/StRoot/StvUtil/StvFtsHitErrCalculator.cxx.C +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include -#include -#include -#include "StEvent/StEnumerations.h" -#include "StvFtsHitErrCalculator.h" -#include "StvUtil/StvDebug.h" -#include "StThreeVectorF.hh" -#include - -ClassImp(StvFtsHitErrCalculator) -double StvFtsHitErrCalculator::mgRPhiErrs[2]={0,0}; //these errors are used only for CalcDetErrs - -//______________________________________________________________________________ -int StvFtsHitErrCalculator::CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRr[3]) -{ -// X = R*cos(Fi), Y=R*sin(Fi), Z = z -// dX/dR = ( cos(Fi) ,sin(Fi),0) -// dX/dFi = (-R*sin(Fi), R*cos(Fi),0) -// U & V coordinate in detector plane -// U = hiDir[1][0]*X+hiDir[1][1]*Y + hiDir[1][2]*Z -// V = hiDir[2][0]*X+hiDir[2][1]*Y + hiDir[2][2]*Z -// -// dU/dR = hiDir[1][0]*cos(Fi)+hiDir[1][1]*sin(Fi) -// dV/dR = hiDir[2][0]*cos(Fi)+hiDir[2][1]*sin(Fi) -// dU/dFi =(-hiDir[1][0]*sin(Fi)+hiDir[1][1]*cos(Fi))*R -// dV/dFi =(-hiDir[2][0]*sin(Fi)+hiDir[2][1]*cos(Fi))*R -// But our case is more simple: -// hiDir {{0, 0, 1}, {0, -1, 0}, {1, 0, 0}} - -// dU/dR = -sin(Fi) -// dV/dR = cos(Fi) -// dU/dFi =-cos(Fi)*R -// dV/dFi =-sin(Fi)*R - -// UU = sin(Fi)**2*dR**2 + cos(Fi)**2*R**2*dFi**2 -// VV = cos(Fi)**2*dR**2 + sin(Fi)**2*R**2*dFi**2 -// UV = -sin(Fi)*cos(Fi)*dR**2 + cos(Fi)*sin(Fi)*(R*dFi)**2 -// UV = sin(Fi)*cos(Fi)*(-dR**2 + (R*dFi)**2) - if (mPar[kZErr]<1e-11) { hRr[0]=1;hRr[1]=0;hRr[2]=1; return 0;} - - double Rxy2 = (hiPos[0]*hiPos[0]+hiPos[1]*hiPos[1]); - mPar[kPhiErr] = mgRPhiErrs[kPhiErr]; - mPar[kRxyErr] = mgRPhiErrs[kRxyErr]; - double myRxyErr2 = mPar[kRxyErr]*mPar[kRxyErr]; - double myPhiErr2 = mPar[kPhiErr]*mPar[kPhiErr]; - double cosFi2 = hiPos[0]*hiPos[0]/Rxy2; - double sinFi2 = hiPos[1]*hiPos[1]/Rxy2; - double sicoFi = hiPos[0]*hiPos[1]/Rxy2; - memset(mDRr,0,sizeof(mDRr)); - mDRr[kYY] = sinFi2*myRxyErr2+cosFi2*myPhiErr2*Rxy2; - mDRr[kZZ] = cosFi2*myRxyErr2+sinFi2*myPhiErr2*Rxy2; - mDRr[kZY] = sicoFi*(-myRxyErr2+myPhiErr2*Rxy2); - if (!hRr) return 0; - hRr[0] = mDRr[kYY]; - hRr[1] = mDRr[kYZ]; - hRr[2] = mDRr[kZZ]; - - assert(hRr[0]*hRr[2]>hRr[1]*hRr[1]); - -// double tst[4] = {-hiPos[1],hiPos[0],tst[1],-tst[0]}; -// double nor = sqrt(hiPos[0]*hiPos[0]+hiPos[1]*hiPos[1]); -// for (int i=0;i<4;i++) {tst[i]/=nor;} -// double dR2 = hRr[0]*tst[0]*tst[0]+2*hRr[1]*tst[0]*tst[1]+hRr[2]*tst[1]*tst[1]; -// double dF2 = hRr[0]*tst[2]*tst[2]+2*hRr[1]*tst[2]*tst[3]+hRr[2]*tst[3]*tst[3]; -// assert(fabs(dR2-pow(mPar[kRxyErr],2))/dR2 <1e-3); -// assert(fabs(dF2-pow(mPar[kPhiErr],2)*Rxy2)/dF2 <1e-3); - - return 0; -} -//______________________________________________________________________________ - - -#include "StHit.h" -#include "Stv/StvHit.h" -#include "StarVMC/GeoTestMaker/StTGeoProxy.h" -//______________________________________________________________________________ -int StvFtsHitErrCalculator::CalcDcaErrs(const StvHit *hit,double hRr[3]) -{ - StHit *stHit = (StHit*)hit->stHit(); - StThreeVectorF dRdPdZ = stHit->positionError(); - float const *fx = hit->x(); - mPar[kRxyErr] = dRdPdZ[0]; - mPar[kPhiErr] = dRdPdZ[1]; - - if (mgRPhiErrs[kRxyErr]detector(); - const Mtx33F_t &hD = hp->GetDir(fx); - int ians = CalcDcaErrs(fx,hD,hRr); - -// double Rxy2 = (fx[0]*fx[0]+fx[1]*fx[1]); -// double tst[4] = {-fx[1],fx[0],tst[1],-tst[0]}; -// double nor = sqrt(fx[0]*fx[0]+fx[1]*fx[1]); -// for (int i=0;i<4;i++) {tst[i]/=nor;} -// double dR2 = mDRr[0]*tst[0]*tst[0]+2*mDRr[1]*tst[0]*tst[1]+mDRr[2]*tst[1]*tst[1]; -// double dF2 = mDRr[0]*tst[2]*tst[2]+2*mDRr[1]*tst[2]*tst[3]+mDRr[2]*tst[3]*tst[3]; -// assert(fabs(dR2-pow(mPar[kRxyErr],2))/dR2 <1e-3); -// assert(fabs(dF2-pow(mPar[kPhiErr],2)*Rxy2)/dF2 <1e-3); -// -// tst[0] = fx[0]*mTG[1][0]+fx[1]*mTG[1][1]; -// tst[1] = fx[0]*mTG[2][0]+fx[1]*mTG[2][1]; -// nor = sqrt(tst[0]*tst[0]+tst[1]*tst[1]); -// tst[0]/=nor; tst[1]/=nor; -// tst[2] = -tst[1]; tst[3] = tst[0]; -// double ddR2 = mTRr[0]*tst[0]*tst[0]+2*mTRr[1]*tst[0]*tst[1]+mTRr[2]*tst[1]*tst[1]; -// double ddF2 = mTRr[0]*tst[2]*tst[2]+2*mTRr[1]*tst[2]*tst[3]+mTRr[2]*tst[3]*tst[3]; -// assert(fabs(ddR2-pow(mPar[kRxyErr],2))/ddR2 <1e-1); -// assert(fabs(ddF2-pow(mPar[kPhiErr],2)*Rxy2)/ddF2 <1e-1); - - return ians; -} - diff --git a/StRoot/StvUtil/StvFtsHitErrCalculator.h b/StRoot/StvUtil/StvFtsHitErrCalculator.h deleted file mode 100644 index fea1f5aaf2c..00000000000 --- a/StRoot/StvUtil/StvFtsHitErrCalculator.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __StvFtsHitErrCalculatorulator_h_ -#define __StvFtsHitErrCalculatorulator_h_ -#include "StEvent/StEnumerations.h" -#include "StvUtil/StvHitErrCalculator.h" - -class StvHit; - -class StvFtsHitErrCalculator : public StvHitRrCalculator { - -public: - StvFtsHitErrCalculator(const char *name="FtsHitErrs"):StvHitRrCalculator(name){}; - -protected: -ClassDef(StvFtsHitErrCalculator,0) -}; - -#endif diff --git a/StRoot/StvUtil/StvFtsHitErrCalculator.h.C b/StRoot/StvUtil/StvFtsHitErrCalculator.h.C deleted file mode 100644 index 735e6d0d0f7..00000000000 --- a/StRoot/StvUtil/StvFtsHitErrCalculator.h.C +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __StvFtsHitErrCalculatorulator_h_ -#define __StvFtsHitErrCalculatorulator_h_ -#include "StEvent/StEnumerations.h" -#include "StvUtil/StvHitErrCalculator.h" - -class StvHit; - -class StvFtsHitErrCalculator : public StvHitErrCalculator { - -public: - StvFtsHitErrCalculator(const char *name="FtsHitErr"):StvHitErrCalculator(name,2){}; -int CalcDcaErrs(const StvHit* hit,double hRR[3]); -int CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); -int CalcDcaErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]) - {return StvHitErrCalculator::CalcDcaErrs(hiPos,hiDir,hRR);} - -protected: -enum { -kRxyErr =0, /* Intrinsic resolution, padrow or rxy direction */ -kPhiErr =1}; /* Intrinsic resolution, Phi direction */ - -static double mgRPhiErrs[2]; //these errors are used only for CalcDetErrs - //when the concrete hit is not defined - - -ClassDef(StvFtsHitErrCalculator,0) -}; - -#endif diff --git a/StRoot/StvUtil/StvGrappa.cxx b/StRoot/StvUtil/StvGrappa.cxx deleted file mode 100644 index f8d780033d0..00000000000 --- a/StRoot/StvUtil/StvGrappa.cxx +++ /dev/null @@ -1,184 +0,0 @@ - -#include "TMath.h" -#include "StvGrappa.h" -#include "TCanvas.h" -#include "TGraph.h" - -#include "Stv/StvHit.h" -#include "Stv/StvNode.h" -#include "Stv/StvTrack.h" - -ClassImp(StvGrappa) -enum StvGrappa2_e {kX,kY,kZ,kR}; - -//______________________________________________________________________________ -StvGrappa::StvGrappa(const char* name) -{ -static int nCall=0; nCall++; - if (name && *name) { SetName(name);} - else { TString ts("Grappa_"); ts+=nCall; SetName(ts.Data());} - memset(mBeg,0,mEnd-mBeg+1); - mActive = 1; -} -//______________________________________________________________________________ -void StvGrappa::Add(double x,double y,double z,int iObj) -{ - if (!mActive) return; - float r = sqrt(x*x+y*y); - mPts[iObj][kX].push_back(x); - mPts[iObj][kY].push_back(y); - mPts[iObj][kZ].push_back(z); - mPts[iObj][kR].push_back(r); -} -//______________________________________________________________________________ -void StvGrappa::Clear(const char *) -{ - if (!mActive) return; - delete mCanvas;mCanvas=0; - for (int i=0;i<(int)mKeep.size();i++) { delete mKeep[i];} - mKeep.clear(); - MyClear(); -} - -//______________________________________________________________________________ -void StvGrappa::MyClear() -{ - for (int i=0;iDivide(1,kNVal); -} -//______________________________________________________________________________ -void StvGrappa::MySize (int iPad, int iX,int iY) -{ - if (iPad==0) { - for (int i=0;ival) mMiMax[iVal][0]=val; - if (mMiMax[iVal][1]cd(iPad+1); - gra->Draw("AP"); - mKeep.push_back(gra); -} -//______________________________________________________________________________ -void StvGrappa::Show() -{ -static const int iXY[kNPad][2] = {{0,1},{2,0},{2,1},{2,3}}; - if (!NObj()) return; - if (!mActive) return; - MySort(); - MakeCanvas(); - - for (int iPad=0;iPadModified(); - mCanvas->Update(); - while(!gSystem->ProcessEvents()){}; - MyClear(); -} - -//______________________________________________________________________________ -void StvGrappa::MyShow(int iPad,int iObj, int iX,int iY) -{ - - int n = mPts[iObj][iX].size(); - if (!n) return; - auto *myGra = new TGraph(n,&mPts[iObj][iX][0],&mPts[iObj][iY][0]); - - myGra->SetMarkerStyle(mMarkerStyle); - myGra->SetMarkerSize (mMarkerSize ); - myGra->SetMarkerColor(mMarkerColor); - mCanvas->cd(iPad+1); - myGra->Draw(mOpt); - mKeep.push_back(myGra); -} -//______________________________________________________________________________ -void StvGrappa::MySort() -{ -std::vector Idx; -std::vector Buf; - for (int iObj=0;iObjbegin();it!=tk->end();++it) { - const StvNode *node = (*it); - const StvHit *hit = node->GetHit(); - const double *Xd = node->GetFP().pos(); - Add(Xd[0],Xd[1],Xd[2],kNode); - if (!hit) continue; - const float *Xf = hit->x(); - Add(Xf[0],Xf[1],Xf[2],kHit); - } - Show(); -} diff --git a/StRoot/StvUtil/StvGrappa.h b/StRoot/StvUtil/StvGrappa.h deleted file mode 100644 index 94913b77a1a..00000000000 --- a/StRoot/StvUtil/StvGrappa.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef STVGRAPPA_H -#define STVGRAPPA_H - -#include -#include "TSystem.h" -#include "TNamed.h" - -class TCanvas; -class TGraph; -class StvTrack; - -class StvGrappa: public TNamed -{ -public: -enum StvGrappa_e {kNode,kHit,kHIT,kHelx,kPont,kNObj,kNPad=4,kNVal=4}; - -StvGrappa(const char* name=""); -~StvGrappa(){ Clear();} -void Add(double x,double y,double z,int iObj); -void Show(); -void Clear(const char* opt=0); - int NObj() const; -void SetActive(int akt=1) {mActive = akt;} -void Show(const StvTrack *tk); -private: -void MakeCanvas(); -void MyShow(int iPad,int iObj,int iX,int iY ); -void MySize(int iPad,int iX,int iY); -void MyClear(); -void MySort(); - - -protected: -char mBeg[1]; -int mMarkerColor; -int mMarkerStyle; -int mMarkerSize; -float mMiMax[kNVal][2]; -const char *mOpt; -TCanvas *mCanvas; -char mEnd[1]; -int mActive; -std::vector mPts[kNObj][kNVal]; //[iObj][x,y,z,rxy] -std::vector mKeep; // -ClassDef(StvGrappa,0) -}; -#endif diff --git a/StRoot/StvUtil/StvHitErrCalculator.cxx b/StRoot/StvUtil/StvHitErrCalculator.cxx deleted file mode 100644 index b31ef99e4e4..00000000000 --- a/StRoot/StvUtil/StvHitErrCalculator.cxx +++ /dev/null @@ -1,680 +0,0 @@ -#include -#include -#include -#include -#include "TCernLib.h" -#include "StvHitErrCalculator.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvHit.h" -#include -#include - -static std::map calcMap; -enum {kMaxLam = 85,kMaxPsi=85}; -static const double kMinCosLam = cos(M_PI/180*kMaxLam),k2MinCosLam=kMinCosLam*kMinCosLam; -static const double kMinCosPsi = cos(M_PI/180*kMaxPsi),k2MinCosPsi=kMinCosPsi*kMinCosPsi; -static const double kMinCpCl = 0.1; - - -// //______________________________________________________________________________ -// double Det33(double T[3][3]) -// { -// // 00 01 02 -// // 10 11 12 -// // 20 21 22 -// T[0][0]*T[1][1]*T[2][2]+T[0][1]*T[1][2]*T[2][0]+T[1][0]*T[2][2]*T[0][2] -// -T[2][0]*T[1][1]*T[0][2] - -ClassImp(StvHitErrCalculator) -ClassImp(StvTpcHitErrCalculator) -//______________________________________________________________________________ -StvHitErrCalculator::StvHitErrCalculator(const char *name,int nPar):TNamed(name,"") -{ - memset(mBeg,0,mEnd-mBeg+1); - mNPar = nPar; - if (!*GetName()) return; - StvHitErrCalculator *&calc = calcMap[GetName()]; - assert(!calc && "Name clash"); - calc = this; -} -//______________________________________________________________________________ -StvHitErrCalculator *StvHitErrCalculator::Inst(const char *name) -{ - StvHitErrCalculator *calc = calcMap[name]; - assert(calc); - return calc; -} -//______________________________________________________________________________ -void StvHitErrCalculator::SetPars(const double *par) -{ - memcpy(mPar,par, GetNPars()*sizeof(*mPar)); -} -//______________________________________________________________________________ -void StvHitErrCalculator::SetTrack(const float tkDir[3]) -{ - double d[3]={tkDir[0],tkDir[1],tkDir[2]}; - SetTrack(d); -} -//______________________________________________________________________________ -void StvHitErrCalculator::SetTrack(const double tkDir[3]) -{ - double nor = (tkDir[0]*tkDir[0]+tkDir[1]*tkDir[1]+tkDir[2]*tkDir[2]); - nor = (fabs(nor-1)< 1e-2)? (nor+1)*0.5 : sqrt(nor); - TCL::vscale(tkDir,1./nor,mTG[0],3); - - nor = (1.-mTG[0][2])*(1+mTG[0][2]); - if (nor <1e-6) { - mTG[1][0]=1; mTG[1][1]=0; mTG[1][2]=0; - mTG[2][0]=0; mTG[2][1]=1; mTG[2][2]=0; - } else { - nor = sqrt(nor); - mTG[1][0] = -mTG[0][1]/nor; mTG[1][1] = mTG[0][0]/nor;mTG[1][2] = 0; - - mTG[2][0] = /*mTG[0][1]*mTG[1][2]*/-mTG[1][1]*mTG[0][2] ; - mTG[2][1] = mTG[0][2]*mTG[1][0]/*-mTG[1][2]*mTG[0][0]*/; - mTG[2][2] = mTG[0][0]*mTG[1][1] -mTG[1][0]*mTG[0][1] ; - } - -} -//______________________________________________________________________________ -int StvHitErrCalculator::CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRr[3]) -{ -/// Calculate hit error matrix in local detector system. In this system -/// detector plane is x = const -// Nt = (cos(Lam)*cos(Phi),cos(Lam)*sin(Phi),sin(Lam)) - memset(mDD[0],0,mNPar*sizeof(mDD[0])); - memset(mDRr,0,sizeof(mDRr)); - mDD[kYErr][kYY] = 1; - mDD[kZErr][kZZ] = 1; - mDRr[kXX] = 0.; - mDRr[kYY] = mDD[kYErr][kYY]*mPar[kYErr]; - mDRr[kZZ] = mDD[kZErr][kZZ]*mPar[kZErr]; - mDRr[kZY] = 0; - if (!hRr) return 0; - hRr[kXX] = mDRr[kYY]; - hRr[kYX] = mDRr[kZY]; - hRr[kYY] = mDRr[kZZ]; - return 0; -} -//______________________________________________________________________________ -int StvHitErrCalculator::CalcLocals(const float hiDir[3][3]) -{ -/// Calculate hit error matrix in DCA system. In this system -/// track is along x axis, Y axis comes thru hit point -static const double s15 = sin(3.14/180*15); -static const double c15 = cos(3.14/180*15); -static const double s45 = sin(3.14/180*45); -static const double c45 = cos(3.14/180*45); - - if (!hiDir) { - mSp = s15 ; mCp = c15 ; mSl = s45 ; mCl = c45 ; - mSp2 = s15*s15; mCp2 = c15*c15; mSl2 = s45*s45; mCl2 = c45*c45; - mCpCl = mCp*mCl; - return 0; - } - for (int j=0;j<3;j++) { - mTL[j] = (hiDir[j][0]*mTG[0][0]+hiDir[j][1]*mTG[0][1]+hiDir[j][2]*mTG[0][2]);} - - -// mTL = (cos(Lam)*cos(Phi),cos(Lam)*sin(Phi),sin(Lam)) - mSl = mTL[2],mCl2 = ((1-mSl)*(1+mSl)); - if (mCl20); - assert(hRr[kYY]>0); - assert(hRr[kYY]*hRr[kXX]>hRr[kYX]*hRr[kYX]); - return 0; -} -//______________________________________________________________________________ -void StvHitErrCalculator::CalcDcaDers(double dRr[kMaxPars][3]) -{ -// Calculate deriavatives of err matrix. -// must be called after CalcDcaErrs(...) - double myDRr[6]; - for (int iPar=0;iParerrMtx(),mDRr,6); - TCL::trasat(mTG[0],mDRr,mTRr,3,3); - hRr[kXX] = mTRr[kYY]; - hRr[kXY] = mTRr[kYZ]; - hRr[kYY] = mTRr[kZZ]; - return 0; -} -//______________________________________________________________________________ -int StvHitRrCalculator::CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRr[3]) -{ - assert(hiPos && hiDir && hRr); - assert(0 && "Not implemented"); - return 0; -} - -//______________________________________________________________________________ -int StvTpcHitErrCalculator::CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRr[3]) -{ -/// Calculate hit error matrix in local detector system. In this system -/// detector plane is x = const -// = DD/12 -// -// = tP* DD/12 -// = tP2*DD/12 +WWy/cP2 -// -// = tL/cP*(DD/12) -// = (tP*tL)/cP*((DD/12 + WWy)) -// = tL2/cP2*(DD/12 + WWy) +WWz - - double Rxy = sqrt(hiPos[0]*hiPos[0]+hiPos[1]*hiPos[1]); - if ( Rxy < 100 ) {assert( strstr(GetName(),"Inner"));} - - int ans = CalcLocals(hiDir); - if (ans) return ans; - - memset(mDD[0],0,mNPar*sizeof(mDD[0])); - memset(mDRr,0,sizeof(mDRr)); - - double myTp = mSp/mCp, myTp2 = myTp*myTp; - double myTl = mSl/mCl, myTl2 = myTl*myTl; - mZSpan = fabs(fabs(hiPos[2])-210)/100; - double WWyy = mPar[kYYDiff]*mZSpan; - double WWzz = mPar[kZZDiff]*mZSpan; - double DD = mPar[kThkDet]/12; - - double qCpCl = sqrt(mCpCl); - double yF = mPar[kYFact ]*qCpCl; - double zF = mPar[kZFact ]*qCpCl; - -// = DD/12 -// -// = tP * DD/12 *sqrt(yFact) -// = tP2*(DD/12) +WWy/cP2 -// -// = tL/cP*(DD/12) -// = (tP*tL)/cP*((DD/12 + WWy)) -// = tL2/cP2*(DD/12 + WWy) +WWz +AB/cP2 - -// mDRr[kXX] = DD; -// -// mDRr[kYX] = myTp*DD*yF; -// mDRr[kZX] = myTl/mCp*DD*zF; -// - mDRr[kYY] =(myTp2*DD + WWyy/mCp2)*yF*yF + mPar[kYErr]; - mDRr[kZY] = myTp*myTl/mCp*(DD + WWyy)*yF*zF; - mDRr[kZZ] = (myTl2/mCp2*(DD +WWyy) + WWzz + mPar[kZAB2]/180/mCp2)*zF*zF + mPar[kZErr]; - -// NOW DERIVATIVEs - -// = DD/12 -// - -// mDRr[kYX] = myTp*DD*yF; -// mDD[kYFact ][kYX] = myTp*DD*qCpCl; - - -// mDRr[kZX] = myTl/mCp*DD*zF; -// mDD[kZFact ][kZX] = myTl/mCp*DD*qCpCl; - -// mDRr[kYY] =(myTp2*DD + WWyy/mCp2)*yF*yF + mPar[kYErr]; - mDD[kYErr ][kYY] = 1;; - mDD[kYFact ][kYY] = (myTp2*DD + WWyy/mCp2)*yF*2*qCpCl; - mDD[kYYDiff][kYY] = mZSpan/mCp2*yF*yF; - -// mDRr[kZY] = myTp*myTl/mCp*(DD + WWyy)*yF*zF; - mDD[kYFact ][kZY] = myTp*myTl/mCp*(DD + WWyy)*zF*qCpCl; - mDD[kZFact ][kZY] = myTp*myTl/mCp*(DD + WWyy)*yF*qCpCl; - mDD[kYYDiff][kZY] = mZSpan*myTp*myTl/mCp*yF*zF; - -// mDRr[kZZ] = (myTl2/mCp2*(DD +WWyy) + WWzz + mPar[kZAB2]/180/mCp2)*zF*zF + mPar[kZErr]; - mDD[kZErr ][kZZ] = 1;; - mDD[kZFact ][kZZ] = (myTl2/mCp2*(DD +WWyy) + WWzz + mPar[kZAB2]/180/mCp2)*zF*2*qCpCl; - mDD[kYYDiff][kZZ] = mZSpan*myTl2/mCp2*zF*zF; - mDD[kZZDiff][kZZ] = mZSpan*zF*zF; - mDD[kZAB2 ][kZZ] = 1./180/mCp2*zF*zF; - - - assert(mDRr[kYY]>0); - assert(mDRr[kZZ]>0); - assert(mDRr[kYY]*mDRr[kZZ]>mDRr[kZY]*mDRr[kZY]); - - if (!hRr) return 0; - hRr[kXX] = mDRr[kYY]; - hRr[kYY] = mDRr[kZZ]; - hRr[kYX] = mDRr[kZY]; - - return 0; - -} -//______________________________________________________________________________ -//______________________________________________________________________________ -//______________________________________________________________________________ -int StvTpcGeoErrCalculator::CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRr[3]) -{ -// = DD/12 -// -// = tP*DD/12 -// = tP2*(DD/12) +WWy/cP2 -// -// = tL/cP*(DD/12) -// = (tP*tL)/cP*((DD/12 + WWy)) -// = tL2/cP2*(DD/12 + WWy) +WWz - -/// Calculate hit error matrix in local detector system. In this system -/// detector plane is x = const - - int ans =CalcLocals(hiDir); - if (ans) return ans; - - memset(mDD[0],0,mNPar*sizeof(mDD[0])); - double myTp = mSp/mCp, myTp2 = myTp*myTp; - double myTl = mSl/mCl, myTl2 = myTl*myTl; - - mZSpan = fabs(fabs(hiPos[2])-210)/100; - mDD[kYThkDet][kXX] = 0.5/12; - mDD[kZThkDet][kXX] = 0.5/12; - - mDD[kYThkDet][kYX] = myTp /12; - - mDD[kYThkDet][kYY] = myTp2/12; - mDD[kYDiff ][kYY] = mZSpan/mCp2; - - mDD[kZThkDet][kZX] = myTl/mCp/12; - - mDD[kYThkDet][kZY] = myTl*myTp/mCp/12 *0.5; - mDD[kZThkDet][kZY] = myTl*myTp/mCp/12 *0.5; - mDD[kYDiff ][kZY] = mZSpan*myTl*myTp/mCp; - - mDD[kZThkDet][kZZ] = myTl2/mCp2/12; - mDD[kYDiff ][kZZ] = mZSpan*myTl2/mCp2; - mDD[kZDiff ][kZZ] = mZSpan; - TCL::vscale(mDD[0],mCpCl,mDD[0],6*mNPar); - - for (int ig=0;ig<6;ig++) { - double s = 0; - for (int ip=0;ip = DD/12 -// - int ans = CalcLocals(hiDir); - if (ans) return ans; - mZSpan = fabs(fabs(hiPos[2])-210)/100; - mCpCl = 1; - double myTp = mSp/mCp, myTp2 = myTp*myTp; - double myTl = mSl/mCl, myTl2 = myTl*myTl; - - double DDy = mPar[kYThkDet]; - double DDz = mPar[kZThkDet]; - double WWy = mPar[kYDiff]*mZSpan; - double WWz = mPar[kZDiff]*mZSpan; - - memset(mDD[0],0,mNPar*sizeof(mDD[0])); -// Sti code -// ecross=Coeff[0]+Coeff[1]*dz/(cosCA*cosCA) +Coeff[2]*tanCA* tanCA; -// edip =Coeff[3]+Coeff[4]*dz*cosDipInv2 +Coeff[5]*tanDip*tanDip; - - - mDRr[kXX] = 1e-6; - mDRr[kYY] = myTp2*DDy +WWy/mCp2+mPar[kYErr]; - mDRr[kZZ] = myTl2*DDz +WWz/mCl2+mPar[kZErr]; - - if (!hRr) return 0; - hRr[kXX] = mDRr[kYY]; - hRr[kYY] = mDRr[kZZ]; - hRr[kYX] = mDRr[kZY]; - - return 0; - -} - - -#include "TRandom.h" -#include "TVector3.h" -//______________________________________________________________________________ -void StvTpcHitErrCalculator::Dest(double phiG,double lamG) -{ - double par[10]={0}; -static const char *titPa[9]={"YErr ","ZErr ","ThkDet","YYDiff","ZZDiff" - ,"YZDiff","YFact","ZFact ","ZAB2 "}; - -static const char *titYZ [3] = {"YY","ZY","ZZ"}; -static const char *titXYZ[6] = {"XX","YX","YY","ZX","ZY","XX"}; - -// kYErr =0, /* Intrinsic resolution, padrow or Y direction */ -// kZErr =1, /* Intrinsic resolution, z direction */ -// kThkDet =2, /* detector thickness**2 , not fitted */ -// kYYDiff =3, /* Diffusion in XY direction *yFactor */ -// kZZDiff =4, /* Diffusion in Z direction *ZFactor */ -// kYFact =5, /* Error factor in Y-direction */ -// kZFact =6, /* Error factor in Z-direction */ -// kZAB2 =7}; /* Constant member in Z direction (a*b)**2 */ - - par[kYErr]=0.03*0.03; - par[kZErr]=0.07*0.07; - par[kThkDet]=1.; - par[kYYDiff]=0.11; - par[kZZDiff]=0.12; - par[kYFact ]=0.9; - par[kZFact ]=0.8; - par[kZAB2 ]=1; - - double Lam = lamG/180*M_PI; - double Phi = phiG/180*M_PI; - double cL = cos(Lam); - double sL = sin(Lam); - double cP = cos(Phi); - double sP = sin(Phi); - double Nt[3]={cL*cP,cL*sP,sL}; - float hiPos[3] = {100,0,55}; - float hiDir[3][3]={{1,0,0},{0,1,0},{0,0,1}}; - -// Randomize orientation - double LamH = (gRandom->Rndm()-0.5); - double PhiH = (gRandom->Rndm()-0.5); -// copy all info from arrays to TVector3 - TVector3 myV[4]; - for (int i=0;i<3;i++) { myV[i] = TVector3(hiDir[i]);} - myV[3] = TVector3(Nt); -// Rotate it - for (int i=0;i<4;i++) { myV[i].RotateZ(PhiH);myV[i].RotateX(LamH);} - -// copy all info back into arrays - for (int i=0;i<3;i++) { Nt[i] = myV[3][i]; - for (int j=0;j<3;j++) { hiDir[i][j] = myV[i][j]; }} - - StvTpcHitErrCalculator calc("TpcInnerHitErrs"); - int nPars = calc.GetNPars(); - calc.SetPars(par); - calc.SetTrack(Nt); - double hRR[6],dRR[10][3],dRRx[10][6]; - - StvTpcHitErrCalculator calk("TpcInnerHitErrs.tmp"); - for (int detDca = 0; detDca<3; detDca++) { -static const char *tit[3] = {"Test CalcDetDers()","Test CalcDcaDers()","Test internals" }; - printf("\n\n\n StvTpcHitErrCalculator::Dest(%s)\n\n",tit[detDca]); - switch(detDca) { - case 0: {calc.CalcDetErrs(hiPos,hiDir,hRR); calc.CalcDetDers(dRR); break;} - case 1: {calc.CalcDcaErrs(hiPos,hiDir,hRR); calc.CalcDcaDers(dRR); break;} - case 2: {calc.CalcDetErrs(hiPos,hiDir,hRR); calc.CalcDetDers(dRR); - memcpy(hRR ,calc.mDRr ,sizeof(hRR )); - memcpy(dRRx[0],calc.mDD[0],sizeof(dRRx)); break;} - }; - for (int j=0;j<3;j++) { - printf("hRR[%d]=%g Der = %g %g %g %g\n",j,hRR[j] - ,dRR[0][j],dRR[1][j],dRR[2][j],dRR[3][j]); - } - - for (int ider=0;iderRndm()-0.5)/2; -// double Phi = 3.14*(gRandom->Rndm()-0.5); - double Lam = lamG/180*M_PI; - double Phi = phiG/180*M_PI; - double W = 0; //Width of the track - double D = 0; //Thickness of detector plane - double cL = cos(Lam); - double sL = sin(Lam); - double tL = tan(Lam); - double cP = cos(Phi); - double sP = sin(Phi); - TVector3 Nt(cL*cP,cL*sP,sL); - TVector3 Np(-sP, cP, 0); - TVector3 Nl(-sL*cP,-sL*sP,cL); - - TVector3 V; - double YZ[3]={0},BG[3]={0}; - int nEl=100000,iEl=0; - while (1) { - double alfa = D/(Nt[0])*(gRandom->Rndm()-0.5)*10; - double beta = gRandom->Gaus()*W; - double gama = gRandom->Gaus()*W; - V = Nt*alfa + Np*beta + Nl*gama; - if (fabs((V[0]))>0.5*D) continue; - V[1]+= gRandom->Gaus()*sqrt(par[kYErr]); - V[2]+= gRandom->Gaus()*sqrt(par[kZErr]); - - if(++iEl>=nEl) break; - -// Project along X to X=0 - alfa = (V[0]); V[0] =0; - beta = (Np*V); - gama = (Nl*V); - BG[0]+=beta*beta; BG[1]+=beta*gama;BG[2]+=gama*gama; - - beta = (V[1]); - gama = (V[2]); - YZ[0] += beta*beta; YZ[1] += beta*gama;YZ[2] += gama*gama; - } - for (int j=0;j<3;j++){YZ[j]/=nEl; BG[j]/=nEl;} - - printf("Phi=%d Lam=%d: \tYY=%g \tYZ=%g \tZZ=%g \tTrace=%g\n" - , int(Phi/3.1415*180),int(Lam/3.1415*180),YZ[0],YZ[1],YZ[2],YZ[0]+YZ[2]); - - StvHitErrCalculator calc("",nPar); - calc.SetPars(par); - double np[3]={ cP, sP, tL}; - double hitErr[3]; - calc.SetTrack(np); - float hiDir[3][3]={{1,0,0} - ,{0,1,0} - ,{0,0,1}}; - calc.CalcDetErrs(0,hiDir,hitErr); - printf("Det Calc: \tYY=%g \tYZ=%g \tZZ=%g \tTrace=%g\n" - ,hitErr[0],hitErr[1],hitErr[2],hitErr[0]+hitErr[2]); - - printf("DCA : \tBB=%g \tBG=%g \tGG=%g \tTrace=%g\n",BG[0],BG[1],BG[2],BG[0]+BG[2]); - calc.CalcDcaErrs(0,hiDir,hitErr); - printf("DCA Calc : \tBB=%g \tBG=%g \tGG=%g \tTrace=%g\n" - ,hitErr[0],hitErr[1],hitErr[2],hitErr[0]+hitErr[2]); - - double LamH = (gRandom->Rndm()-0.5); - double PhiH = (gRandom->Rndm()-0.5); -// copy all info from arrays to TVector3 - TVector3 myV[4]; - for (int i=0;i<3;i++) { myV[i] = TVector3(hiDir[i]);} - myV[3] = TVector3(np); -// Rotate it - for (int i=0;i<4;i++) { myV[i].RotateZ(PhiH);myV[i].RotateX(LamH);} - -// copy all info back into arrays - for (int i=0;i<3;i++) { np[i] = myV[3][i]; - for (int j=0;j<3;j++) { hiDir[i][j] = myV[i][j]; }} -// Now try how life is here - calc.SetTrack(np); - calc.CalcDetErrs(0,hiDir,hitErr); - printf("Det Rot : \tYY=%g \tYZ=%g \tZZ=%g \tTrace=%g\n" - ,hitErr[0],hitErr[1],hitErr[2],hitErr[0]+hitErr[2]); - - double myHitErr[3]; - double myT[2][2]= {{cP,0},{-sL*sP,cL}}; - TCL::trasat(myT[0],hitErr,myHitErr,2,2); - printf("DCAtest : \tBB=%g \tBG=%g \tGG=%g \tTrace=%g\n" - ,myHitErr[0],myHitErr[1],myHitErr[2],myHitErr[0]+myHitErr[2]); - - - calc.CalcDcaErrs(0,hiDir,hitErr); - printf("DCA Rot : \tBB=%g \tBG=%g \tGG=%g \tTrace=%g\n" - ,hitErr[0],hitErr[1],hitErr[2],hitErr[0]+hitErr[2]); - - - -} -//______________________________________________________________________________ -void StvHitErrCalculator::Dest(double phiG,double lamG) -{ - int nPars = 2; - double par[6]={0}; - par[kYErr]=0.1*0.1; - par[kZErr]=0.2*0.2; - - double Lam = lamG/180*M_PI; - double Phi = phiG/180*M_PI; - double cL = cos(Lam); - double sL = sin(Lam); - double cP = cos(Phi); - double sP = sin(Phi); - double Nt[3]={cL*cP,cL*sP,sL}; - float hiPos[3] = {100,0,0}; - float hiDir[3][3]={{1,0,0},{0,1,0},{0,0,1}}; - - double LamH = (gRandom->Rndm()-0.5); - double PhiH = (gRandom->Rndm()-0.5); -// copy all info from arrays to TVector3 - TVector3 myV[4]; - for (int i=0;i<3;i++) { myV[i] = TVector3(hiDir[i]);} - myV[3] = TVector3(Nt); -// Rotate it - for (int i=0;i<4;i++) { myV[i].RotateZ(PhiH);myV[i].RotateX(LamH);} - -// copy all info back into arrays - for (int i=0;i<3;i++) { Nt[i] = myV[3][i]; - for (int j=0;j<3;j++) { hiDir[i][j] = myV[i][j]; }} - - - - StvHitErrCalculator calc("",nPars); - calc.SetPars(par); - calc.SetTrack(Nt); - double hRR[3],dRR[10][3]; - calc.CalcDcaErrs(hiPos,hiDir,hRR); - calc.CalcDcaDers(dRR); - for (int j=0;jdetector(); - const Mtx33F_t &hD = hp->GetDir(hit->x()); - return CalcDcaErrs(hit->x(),hD,hRr); -} - -#endif //0 diff --git a/StRoot/StvUtil/StvHitErrCalculator.h b/StRoot/StvUtil/StvHitErrCalculator.h deleted file mode 100644 index 0aa2e62c950..00000000000 --- a/StRoot/StvUtil/StvHitErrCalculator.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef __StvHitErrCalculatorulator_h_ -#define __StvHitErrCalculatorulator_h_ -#include "assert.h" -#include "TNamed.h" -class StvHit; -typedef float Mtx33F_t[3][3]; - -class StvHitErrCalculator : public TNamed { -public: -enum {kMaxPars=10}; - -StvHitErrCalculator(const char *name,int nPars=2); - void SetPars(const double *par); - void SetTrack(const double tkDir[3]); - void SetTrack(const float tkDir[3]); -virtual int CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); -virtual int CalcDcaErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); -virtual int CalcDcaErrs(const StvHit *hit,double hRR[3]); -virtual void CalcDetDers(double dRR[kMaxPars][3]); -virtual void CalcDcaDers(double dRR[kMaxPars][3]); -virtual double Trace(const float hiPos[3]); -virtual int GetNPars() const {return mNPar;} -const double *GetPars() const {return mPar ;} - double *GetPars() {return mPar ;} -static StvHitErrCalculator *Inst(const char *name); -static void Test(double phiG=33,double lamG=66); -static void Dest(double phiG=33,double lamG=66); -protected: -int CalcLocals(const float hiDir[3][3]); -protected: -enum {kYErr=0,kZErr=1}; -enum {kXX=0,kYX=1,kXY=1,kYY=2,kZX=3,kXZ=3,kZY=4,kYZ=4,kZZ=5}; - -char mBeg[1]; -int mFailed; -int mNPar; //Size of mPar -double mPar[kMaxPars]; // mPar -double mDRr[6]; // Full hitErr Matrix in detecor system -double mTRr[6]; // Full hitErr Matrix in track system -double mTG[3][3]; // track direction in global system -double mTL[3]; // track direction in local hit plane system -double mCp ,mSp ,mCl ,mSl; -double mCp2,mSp2,mCl2,mSl2,mCpCl; -double mTT[3][3]; //matrix converting from detector to track(dca) system -double mDD[kMaxPars][6]; -char mEnd[1]; -ClassDef(StvHitErrCalculator,0) -}; - -class StvHitRrCalculator : public StvHitErrCalculator { - -public: - StvHitRrCalculator(const char *name="HitRr"):StvHitErrCalculator(name,0){}; -virtual int CalcDcaErrs(const StvHit *stvHit,double hRR[3]); -virtual int CalcDcaErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]){assert(0); return 999;}; -virtual int CalcDetErrs(const float*, const float (*)[3], double*); -ClassDef(StvHitRrCalculator,0) -}; - - - -class StvTpcHitErrCalculator : public StvHitErrCalculator { - -public: - StvTpcHitErrCalculator(const char *name="TpcHitErr"):StvHitErrCalculator(name,8){}; -virtual int CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); -static void Dest(double phiG=33,double lamG=33); - -protected: -enum { -kYErr =0, /* Intrinsic resolution, padrow or Y direction */ -kZErr =1, /* Intrinsic resolution, z direction */ -kThkDet =2, /* detector thickness**2 , not fitted */ -kYYDiff =3, /* Diffusion in XY direction *yFactor */ -kZZDiff =4, /* Diffusion in Z direction *ZFactor */ -kYFact =5, /* Error factor in Y-direction */ -kZFact =6, /* Error factor in Z-direction */ -kZAB2 =7}; /* Constant member in Z direction (a*b)**2 */ -double mZSpan; -ClassDef(StvTpcHitErrCalculator,0) -}; - - -class StvTpcGeoErrCalculator : public StvHitErrCalculator { - -public: - StvTpcGeoErrCalculator(const char *name="TpcHitGeo"):StvHitErrCalculator(name,7){}; -virtual int CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); - -protected: -enum {kYDiff =2 //Diffusion in XY direction - ,kYThkDet=4 //Effective detectot thickness for Y err - ,kZDiff =3 //Diffusion in Z direction - ,kZThkDet=5 //Effective detectot thickness for Z err - ,kZAB2 =6 //Constant member in Z direction (a*b)**2 - }; -double mZSpan; -ClassDef(StvTpcGeoErrCalculator,0) -}; - -class StvTpcStiErrCalculator : public StvHitErrCalculator { - -public: - StvTpcStiErrCalculator(const char *name="StiHitErr"):StvHitErrCalculator(name,6){}; -virtual int CalcDetErrs(const float hiPos[3],const float hiDir[3][3],double hRR[3]); - -protected: -enum {kYErr =0 //Diffusion in XY direction - ,kYThkDet=1 //Effective detectot thickness**2/12 for Y err - ,kYDiff =2 //Diffusion in Z direction - ,kZErr =3 //electronics Z err - ,kZDiff =4 //Diffusion in Z direction - ,kZThkDet=5}; //Effective detectot thickness**2/12 for Z err -double mZSpan; -/*ClassDef(StvTpcStiErrCalculator,0)*/ -}; - -#endif diff --git a/StRoot/StvUtil/StvKNNUtil.cxx b/StRoot/StvUtil/StvKNNUtil.cxx deleted file mode 100644 index 1f1560e1c3a..00000000000 --- a/StRoot/StvUtil/StvKNNUtil.cxx +++ /dev/null @@ -1,176 +0,0 @@ -#include -#include -#include -#include -#include -#include "StvKNNUtil.h" -//_____________________________________________________________________________ - StvKNNUtil::StvKNNUtil(int nVr,int nGb): mNVars(nVr),mKNNgb(nGb) -{ -assert(nGb<=kKNNgbMax); -assert(nVr<=kKNNvrMax); - Reset(); -} -//_____________________________________________________________________________ -void StvKNNUtil::Reset() -{ -mIdxBestWost[0]=-1; mIdxBestWost[1]=-1; -mBestWost[0] =3e33; mBestWost[1] =-3e33; -mEnt.clear(); -} -//_____________________________________________________________________________ -int StvKNNUtil::Add(ULong_t id,const float *vars) -{ - int nWas = mEnt.size(); - mEnt.resize(nWas+1); - StvKNNAux &bk = mEnt.back(); - bk.mId = id; - memcpy(bk.mVar,vars,sizeof(bk.mVar[0])*mNVars); - for (int i=0;iq[0].qa) continue; - int before = 1; - for (;before=q[before].qa) break;} - if (before-1>0) {memcpy(q,q+1,(before-1)*sizeof(q[0]));} - q[before-1].qa = qa; q[before-1].ix = kogo; -// Now update min/max - if (mBestWost[0]>q[0].qa) {mBestWost[0]=q[0].qa;mIdxBestWost[0]=kuda;} - }//end neighbour loop - }//end ent loop - return mEnt.size(); - -} -//_____________________________________________________________________________ -double StvKNNUtil::Dist(const float *a,const float *b) const -{ double s=0; - for(int i=0;imaxDis) maxDis=s; - } - return sqrt(maxDis); -} - -//_____________________________________________________________________________ -StvKNNAux::StvKNNAux() -{ - memset(this,0,sizeof(*this)); -} - diff --git a/StRoot/StvUtil/StvKNNUtil.h b/StRoot/StvUtil/StvKNNUtil.h deleted file mode 100644 index 0ac98a43020..00000000000 --- a/StRoot/StvUtil/StvKNNUtil.h +++ /dev/null @@ -1,54 +0,0 @@ - -/// \File StvKNNUtil.h -/// \author Victor Perev 01/2013 -#ifndef StvKNNUtil_HH -#define StvKNNUtil_HH -#include -#include -#include "Rtypes.h" -/// \class StvKNNUtil - -enum { kKNNgbMax = 5, kKNNvrMax=3}; -class StvKNNAux -{ -friend class StvKNNUtil; -public: -class QaIx_t {public: int ix;float qa;}; -StvKNNAux(); -private: -ULong_t mId; -float mVar[kKNNvrMax]; -QaIx_t mQa[kKNNgbMax]; -}; - - -class StvKNNUtil -{ -public: - StvKNNUtil(int nVr,int nGb); - virtual ~StvKNNUtil(){;} - virtual double Dist(const float *a,const float *b) const; - void Reset(); - int Add(ULong_t id,const float *vars); -double GetBest(ULong_t *id=0,ULong_t *ngb=0) const; -double GetWost(ULong_t *id=0,ULong_t *ngb=0) const; -double GetBest(int &idx,int *ngb=0) const; -double GetWost(int &idx,int *ngb=0) const; -double GetByIdx(int idx,int *ngb=0)const; - -double BestPos(float *var =0) const; -double WostDis(const float *var) const; - -private: -const int mNVars; //number of variables -const int mKNNgb; //number of neighbours -mutable int mIdxBestWost[2]; -mutable double mBestWost[2]; //[0]=max density; [1]=min density - - -std::vector mEnt; //KNN entries - - -}; - -#endif diff --git a/StRoot/StvUtil/StvNodePars.cxx b/StRoot/StvUtil/StvNodePars.cxx deleted file mode 100644 index b0c2d105320..00000000000 --- a/StRoot/StvUtil/StvNodePars.cxx +++ /dev/null @@ -1,1854 +0,0 @@ -#include -#include -#include -#include "TCernLib.h" -#include "TMath.h" -#include "TMath.h" -#include "StvUtil/StvNodePars.h" -#include "StvUtil/StvELossTrak.h" -#include "StvUtil/StvDebug.h" -#include "Stv/StvToolkit.h" -#include "TString.h" - -static const double kMaxPti=200,kMaxCurv=(0.000299792458 * 4.98478)*kMaxPti,kMaxEta = 6; -static const double kMaxLamda = 3.14159265358/2-atan(exp(-kMaxEta))*2; -static const double kMaxTanL = tan(kMaxLamda); - -enum {kHf,kZf,kAf,kLf,kPf}; -enum {kHh,kAh,kCh,kZh,kLh}; - static const int idx66[6][6] = - {{ 0, 1, 3, 6,10,15},{ 1, 2, 4, 7,11,16},{ 3, 4, 5, 8,12,17} - ,{ 6, 7, 8, 9,13,18},{10,11,12,13,14,19},{15,16,17,18,19,20}}; -static const double recvCORRMAX = 0.99; -static const double chekCORRMAX = 0.9999; - -// x y z psi pti tan cur -static double MAXNODPARS[] ={555,555,555,6.66,kMaxPti+10, kMaxTanL+10, .1}; -// h z a l ptin -static const double MAXFITPARS[] ={1.0 ,1.0,0.5 ,0.5 ,kMaxPti }; -static const double BIGFITPARS[] ={0.1 ,0.1,0.1 ,0.1 ,0.01},BIGFITPART=0.01; -static const double kERRFACT = 3*3; -static const double kFitErrs[5] ={3,3 - ,10./180*M_PI - ,10./180*M_PI - ,kMaxPti}; -static const double kPiMass=0.13956995; -static const double kMinP = 0.01,kMinE = sqrt(kMinP*kMinP+kPiMass*kPiMass); -static const double kMaxCorr = 0.1; - - -//______________________________________________________________________________ -static void LinearCurv (double Rho,double dRho,double len, double &dT,double &dH) -{ - - - double X[2]={0},D[2]={1}; - double X0End[2]; - TCircle tc(X,D,Rho); - tc.Eval(len,X0End); - double step = 0.1/fabs(Rho)+1e-10; - int nStep = int(fabs(len)/step+0.5); - step = len/nStep; - for (int istep=0;istep0.5) return (sin(x)-x)/x2/x; - double nom = -1./6; - double sum = nom; - for (int it=4;1;it+=2) { - nom = -nom*x2/(it*(it+1)); - sum +=nom; - if (fabs(nom) <= 1e-10*fabs(sum)) break; - } - return sum; -} -//______________________________________________________________________________ -void StvTrackNode::mult6(double Rot[kNPars][kNPars],const double Pro[kNPars][kNPars]) -{ - double T[kNPars][kNPars]; - - if (!Rot[0][0]) {memcpy(Rot[0],Pro[0],sizeof(T)); return;} - - memcpy(T[0],Pro[0],sizeof(T)); - - for (int i=0;i=1e-5 && fabs(tmp)> 1e-3*fabs(_curv)) {ierr=1001; goto FAILED;} - for (int i=0;i<=kNPars;i++){if (fabs(P[i]) > MAXNODPARS[i]) {ierr = i+ 1; goto FAILED;}} - - for (int i=-2;i<0;i++) {if (fabs(P[i]) > 1.0001) {ierr = i+1010; goto FAILED;}} - tmp = fabs(cos(_psi)-_cosCA); - ierr = 1002; if (tmp>1e-4) goto FAILED; - tmp = fabs(sin(_psi)-_sinCA); - ierr = 1003; if (tmp>1e-4) goto FAILED; - return 0; -FAILED: - assert(ierr<1000); - if (!pri ) return ierr; - printf("StvNodePars::check(%s) == FAILED(%d)\n",pri,ierr); print(); - return ierr; -} -//______________________________________________________________________________ -StvNodePars &StvNodePars::merge(double wt,StvNodePars &other) -{ - assert(_hz); - double wt0 = 1.-wt; - for (int i=0;iPos(),3*sizeof(_x)); - assert(fabs(_x)<500); - assert(fabs(_y)<500); - _psi = atan2(th->Dir()[1],th->Dir()[0]); - double sinL = th->Dir()[2]; - double cosL = sqrt((1-sinL)*(1+sinL)); - _tanl = sinL/cosL; - - _cosCA = th->Dir()[0]/cosL; - _sinCA = th->Dir()[1]/cosL; - _curv = th->GetRho(); - _hz = Hz; - assert(_hz); - if (fabs(_curv) > fabs(1e-6*_hz)) {_ptin = _curv/_hz; } - else {_ptin = 1e-6; _curv = _ptin*_hz;} -} - -//______________________________________________________________________________ -void StvNodePars::get(THelixTrack *th) const -{ - assert(_hz); - double dir[3]={_cosCA,_sinCA,_tanl}; - th->Set(&_x,dir,_curv); -} -//______________________________________________________________________________ -void StvNodePars::move(double dLen) -{ - double dcCA,dsCA,dC,dS,dCR,dSR,dX,dY,dZ; - double dLxy = dLen*getCosL(); - double dPhi = _curv*dLxy; -assert(fabs(_cosCA)<1.001); -assert(fabs(_sinCA)<1.001); - - assert(_hz); - if (fabs(dPhi) < 0.1) { - dCR = dLxy*dPhi*(-1./2 + dPhi*dPhi/24); dSR = dLxy*(1-dPhi*dPhi/6); - dC = dCR*_curv; dS = dSR*_curv; - } else { - dC = cos(dPhi)-1; dS = sin(dPhi); - dCR = dC/_curv; dSR = dS/_curv; - } - dX = (_cosCA*dSR + _sinCA*dCR); - dY = (_sinCA*dSR - _cosCA*dCR); - dZ = dLxy*_tanl; - dcCA = _cosCA*dC - _sinCA*dS; - dsCA = _sinCA*dC + _cosCA*dS; - _cosCA+=dcCA; _sinCA+=dsCA; _x+=dX; _y+=dY; _z+=dZ; _psi+=dPhi; -assert(fabs(_cosCA)<1.01); - if (fabs(_cosCA)>1 || fabs(_sinCA)>1 ) ready(); - while(_psi> M_PI) { _psi-=2*M_PI;} - while(_psi<-M_PI) { _psi+=2*M_PI;} - assert(fabs(_psi)<=M_PI); -} -//______________________________________________________________________________ -double StvNodePars::move(const double v[3],double dPP, int dir) -{ -// move to dca point and return dca length -// dPP account energy loss dPP = deltaP/P/Len - -static int nCall=0; nCall++; -static const double kMomAccu = 1e-3; //momentum relative accuracy -static const double kAngAcc[2]={3.14/180, kAngAcc[0]*0.1}; -static const double kAngMax=0.1; -StvDebug::Break(nCall); - - double MOM[3]={_cosCA,_sinCA,_tanl}; - double cos2Li = (1+_tanl*_tanl),cosL = sqrt(1./cos2Li); - - double myLen = 0; - for (int jk=0;jk<2;jk++) {//jk=0=move without energy loss,=1 with - int converge = 0; - StvNodePars save = *this; - for (int it=0;it<5;it++) { - double mom[3]={_cosCA,_sinCA,_tanl}; - double vtx[3]={v[0]-_x,v[1]-_y,v[2]-_z}; - double tau = (vtx[0]*mom[0]+vtx[1]*mom[1]+vtx[2]*mom[2])*cosL; - double dang = tau*_curv*cosL; - if (fabs(dang)>kAngMax) break; - move(tau); myLen+=tau; - if (fabs(dang) < kAngAcc[jk]) {converge = 1; break;} - }// end iters - if (!converge) { //failed, try THelix - *this = save; - double mom[3]={_cosCA,_sinCA,_tanl}; - THelixTrack hlx(&_x,mom,_curv); - myLen = hlx.Path(v); - move(myLen); - } - -assert(fabs(_z)<999); - if (jk) return myLen; - double dRho = dPP*myLen,fak = 1+dRho; //accounts sign dP/P = -dRho/Rho & sign of len - if (fabs(dRho)0) ? mydRho:0; - } - if (_curv*fak > kMaxCurv) { - double mydRho = (kMaxCurv-_curv)/_curv; - dRho = (mydRho*dRho>0) ? mydRho:0; - } - double lxy=myLen*cosL; - - double ang = _curv*lxy,ang2=ang*ang; - double dH,dT,dA; - int jkFlag=1; - if (fabs(ang)<0.1) {//Small angle - dH = 1./3 ; dT = 1./4;} - else if ( fabs(ang)<0.5) {//Reasonable angle - double qqCos = ((cos(ang)-1)/ang2+1./2)/ang2; //~ 1/24 - double qqSin = (sin(ang)/(ang)-1)/ang2; //~-1/6 - dT = ((qqCos+qqSin)*2-qqCos*ang2+1./2); //~1/4 - dH = ((2*qqCos+qqSin)*ang2 -2*qqSin ); //~1/3 - } - else {//Big angle, approximation does NOT work - jkFlag=0; - LinearCurv(_curv,dRho*_curv,lxy,dT,dH ); - } - if (jkFlag) { - dH*= dRho*ang *lxy/2; - dT*=-dRho*ang2*lxy/2; - } - dA = dRho*ang/2; - - - - _x += MOM[0]*dT-MOM[1]*dH; - _y += MOM[1]*dT+MOM[0]*dH; - _psi += dA; - while (_psi<-M_PI) { _psi+=2*M_PI;} - while (_psi> M_PI) { _psi-=2*M_PI;} -assert(fabs(_psi)<=M_PI); - _curv += _curv*dRho; - _ptin =_curv/_hz; - if (fabs(dA)<1e-2) { - double cosCA = _cosCA; - _cosCA -= _sinCA*dA; - _sinCA += cosCA*dA;} - else { - _cosCA = cos(_psi); - _sinCA = sin(_psi); - } - - - }//end jk loop -assert((myLen>0) == (dir==1)); -assert(fabs(_z)<999); - return myLen; - -} -//______________________________________________________________________________ -void StvNodePars::moveToR(double R) -{ - double myR2 = _x*_x + _y*_y; - double myDot = _x*_cosCA + _y*_sinCA; - double dR2 = R*R-myR2; - double dis = myDot*myDot+dR2; - assert(_hz); - if (dis<0) dis = 0; - dis = sqrt(dis); - double dL = (dR2)/(dis+fabs(myDot)); - if (myDot<0) dL = -dL; - move(dL/getCosL()); -// assert(fabs(_x*_x+ _y*_y-R*R)/(2*R)<1e-2); -} - -//______________________________________________________________________________ -StvNodePars &StvNodePars::operator=(const StvNodePars& fr) -{ - if (&fr==this) return *this; - memcpy(this,&fr,sizeof(*this)); -assert(_hz); - return *this; -} -//______________________________________________________________________________ -const StvFitPars &StvNodePars::operator-(const StvNodePars& sub) const -{ -static StvFitPars fp; - - double cos2L = 1./(1+sub._tanl*sub._tanl); - double cosL = sqrt(cos2L); - double sinL = sub._tanl*cosL; - double dx = _x-sub._x; - double dy = _y-sub._y; - double dz = _z-sub._z; - - fp.mH = dx*( -sub._sinCA)+ dy*( sub._cosCA); - fp.mZ = dx*(-sinL*sub._cosCA)+ dy*(-sinL*sub._sinCA) +dz*cosL; - double a = (_psi -sub._psi ); - if (a < -M_PI) {a += M_PI*2;} - else if (a > M_PI) {a -= M_PI*2;} -assert(fabs(_psi) M_PI) _psi -= 2*M_PI; - assert(fabs(_psi)1e-5) ready(); - _ptin += fp.mP; - if (_ptin > kMaxPti) _ptin = kMaxPti; - if (_ptin < -kMaxPti) _ptin =-kMaxPti; - - double l = fp.mL,tL; - if (fabs(l) < 0.1) {tL = l*(1+l*l/3);} - else {tL = tan(l) ;} - _tanl = (_tanl+tL)/(1.-_tanl*tL); - - if (_tanl < -kMaxTanL) _tanl = -kMaxTanL; - if (_tanl > kMaxTanL) _tanl = kMaxTanL; - _curv = _hz *_ptin; - if (fabs( _cosCA)>1 || fabs( _sinCA)>1) ready(); - assert(!check("StvNodePars::operator+=") || 1); -} -//______________________________________________________________________________ -void StvNodePars::print() const -{ -static const char* tit[]={"cosCA","sinCA","X","Y","Z","Eta","Ptin","TanL","Curv",0}; - for (int i=-2;i1e-5) return 0; - if (fabs(_sinCA-sin(_psi))>1e-5) return 0; - if (fabs(_curv -_hz*_ptin)>1e-5) return 0; - return 1; -} -//_____________________________________________________________________________ -StvFitPars StvNodePars::delta() const -{ - double spaceR = 0.1+sqrt(_x*_x+_y*_y)/200; - double spaceZ = 0.1+fabs(_z)/200; - StvFitPars fp; - fp.mH = spaceR; fp.mZ = spaceZ; - fp.mA = fp.mL = 3.14/180*30; //ten degree - fp.mP = fabs(_ptin)*0.2; - if (fp.mP<0.1) fp.mP = 0.1; - return fp; -} -//_____________________________________________________________________________ -StvFitErrs StvNodePars::deltaErrs() const -{ - StvFitPars dlt = delta(); - StvFitErrs fe; - for (int i=0,li=0;i< 5;li+=++i) {fe[li+i] = kERRFACT*dlt[i]*dlt[i];} - fe.mHz = _hz; - return fe; -} -//_____________________________________________________________________________ -void StvFitErrs::Add(const StvELossTrak *el,const StvNodePars &pa, double len) -{ - if (!el) return; - - double fakLen = (len)? fabs(len/el->TotLen()):1.; - double p2 = pa.getP2(); - double e2 = p2+el->M()*el->M(); - double fakNrj = e2/p2*(pa._ptin*pa._ptin)/p2; - mAA+= el->GetTheta2() *fakLen; - mLL+= el->GetTheta2() *fakLen; - mHH+= el->GetOrt2() *fakLen; - mZZ+= el->GetOrt2() *fakLen; - mPP+= el->ELossErr2() *fakNrj *fakLen; - if (mHH<=0 || mHH>1e2 || mZZ<=0 || mZZ>1e2) Recov(); -} -//_____________________________________________________________________________ -double StvNodePars::diff(const StvNodePars &other) const -{ - StvFitPars fp = *this-other; - StvFitPars dlt = delta(); - double myMax=0; - for (int i=0;i<5;i++) { - double d = fabs(fp[i])/dlt[i]; - if (myMax _ptin - der[kHf][kPf]*=_hz; - der[kZf][kPf]*=_hz; - der[kAf][kPf]*=_hz; - - -} -//______________________________________________________________________________ -void StvNodePars::Deriv(double len, double dPdP0, StvFitDers &der) const -{ -// Update existing derivatives using energy loss info: -// len - new length -// dPdP0 - d(Ploss)/dP0 /len/ -// -// dP = dPdP0* dP0 -// d(Pt/cosL) = dPdP0* d(Pt0/cosL) -// dPt/cosL + Pt*sinL/cosL**2*dL = dPdP0* ( dPt0/cosL + Pt0*sinL/cosL**2*dL) - - - - double dPLossdP0 = -dPdP0*len; - double dPtidPti0 = dPLossdP0; - double dPtidLam0 =-dPLossdP0*_tanl*_ptin; - - der[kPf][kPf]+= dPtidPti0; // dPti/dRho ; - der[kPf][kLf]+= dPtidLam0; // dPti/dLam ; -} - -//______________________________________________________________________________ -//______________________________________________________________________________ -void StvHitErrs::rotate(double angle) -{ double t[2][2]; - t[0][0] = cos(angle); t[0][1] = -sin(angle); - t[1][0] = -t[0][1] ; t[1][1] = t[0][0]; - double r[3]; - TCL::trasat(t[0],&hXX,r,2,2); - TCL::ucopy(r,&hXX,3); -} - - -//______________________________________________________________________________ -//______________________________________________________________________________ -StvFitErrs::StvFitErrs(double hh,double hz,double zz) -{ - memset(this,0,sizeof(*this)); - mHH=hh;mHZ=hz;mZZ=zz;mHz = 3e33; - assert(&mPP-&mHH+1==15); -} -//______________________________________________________________________________ -double StvFitErrs::Sign() const {return EmxSign(5,Arr());} -//______________________________________________________________________________ -const StvFitErrs &StvFitErrs::operator*(const StvFitDers &how) const -{ -static StvFitErrs myFitErrs; - TCL::trasat(how[0],Arr(),myFitErrs.Arr(),5,5); - myFitErrs.mHz = mHz; - myFitErrs.Recov(); - assert(mHH>0); - assert(mZZ>0); - - return myFitErrs; -} -//______________________________________________________________________________ -StvFitErrs &StvFitErrs::operator=(const StvFitErrs &fr) -{ - assert(fr.mHH>0); - assert(fr.mZZ>0); - - if (&fr==this) return *this; - memcpy(this,&fr,sizeof(*this)); -assert(mHz); - return *this; -} -// //______________________________________________________________________________ -// void StvFitErrs::Reset(double hz) -// { -// memset(this,0,sizeof(*this)); -// mHH = kFitErrs[0]*kFitErrs[0]; -// mZZ = kFitErrs[1]*kFitErrs[1]; -// mAA = kFitErrs[2]*kFitErrs[2]; -// mLL = kFitErrs[3]*kFitErrs[3]; -// mPP = kFitErrs[4]*kFitErrs[4]; -// mHz = hz; -// } - -//______________________________________________________________________________ -void StvFitErrs::Set(const THelixTrack *he, double hz) -{ -mHz = hz;assert(hz); -const THEmx_t *emx = he->Emx(); -double cosL = he->GetCos(); -double sinL = he->GetSin(); -double rho = he->GetRho(); -//double dAdZ = -sinL*rho; - -mHH = emx->mHH; -mHZ = cosL*emx->mHZ; -mZZ = cosL*emx->mZZ*cosL; -mHA = cosL*emx->mHA + (-sinL*cosL*cosL*rho)*emx->mHZ; -mZA = (cosL*emx->mAZ + (-sinL*cosL*cosL*rho)*emx->mZZ)*cosL; -mAA = (cosL*emx->mAA + (-sinL*cosL*cosL*rho)*emx->mAZ)*cosL + (cosL*emx->mAZ + (-sinL*cosL*cosL*rho)*emx->mZZ)*(-sinL*cosL*cosL*rho); -mHL = emx->mHL; -mZL = emx->mZL*cosL; -mAL = emx->mAL*cosL + emx->mZL*(-sinL*cosL*cosL*rho); -mLL = emx->mLL; -mHP = (1/mHz)*emx->mHC; -mZP = (1/mHz)*emx->mCZ*cosL; -mAP = (1/mHz)*emx->mAC*cosL + (1/mHz)*emx->mCZ*(-sinL*cosL*cosL*rho); -mLP = (1/mHz)*emx->mCL; -mPP = (1/mHz)*emx->mCC*(1/mHz); - assert(mHH>0); - assert(mZZ>0); - - - Recov(); -} -//______________________________________________________________________________ -void StvFitErrs::Get(THelixTrack *he) const -{ - assert(mHz); - he->SetEmx(0); - THEmx_t *emx = he->Emx(); - double cosL = he->GetCos(); - double sinL = he->GetSin(); - double rho = he->GetRho(); - double dAdZeta = sinL*rho; - -emx->mHH = mHH; -emx->mHA = dAdZeta*mHZ + 1/cosL*mHA; -emx->mAA = dAdZeta*mZZ*dAdZeta + 2/cosL*(mZA*dAdZeta) + mAA/cosL/cosL; -emx->mHC = (mHz)*mHP; -emx->mAC = (mHz)*(mZP*dAdZeta + mAP/cosL); -emx->mCC = (mHz)*mPP*(mHz); -emx->mHZ = 1/cosL*mHZ; -emx->mAZ = 1/cosL*(mZZ*dAdZeta + mZA*1/cosL); -emx->mCZ = 1/cosL*mZP*(mHz); -emx->mZZ = 1/cosL*mZZ*1/cosL; -emx->mHL = mHL; -emx->mAL = mZL*dAdZeta + mAL*1/cosL; -emx->mCL = mLP*(mHz); -emx->mZL = mZL*1/cosL; -emx->mLL = mLL; - - -} -//_____________________________________________________________________________ -void StvFitErrs::Backward() -{ - mHA*=-1; mAP*=-1; mHZ*=-1; mZP*=-1; mAL*=-1; mZL*=-1; -} -//_____________________________________________________________________________ -int StvFitErrs::Check(const char *tit) const -{ - if (mHH+mZZ<=0) return 0; - ((StvFitErrs*)((void*)this))->Recov(); - int ierr=0; - double dia[5];const double *e=&mHH; - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=e[li+i]; -// if (dia[i]< 1e-8*kFitErrs[i]*kFitErrs[i]) {ierr = i+1; goto ERR;} - if (dia[i]> 1e+4*kFitErrs[i]*kFitErrs[i]) {ierr = i+6; goto ERR;} - for (int j=0;j=dia[i]*dia[j]){ierr = 100+10*i+j;goto ERR;} - } } - assert(mHz); - return 0; -ERR: if (!tit) return ierr; - printf("StvFitErrs::Check(%s)=%d\n",tit,ierr); - Print(); - return ierr; -} -//_____________________________________________________________________________ -double StvFitErrs::MaxCorr() const -{ - if (mHH+mZZ<=0) return 0; - double dia[5],maxCorr=0;const double *e=&mHH; - - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=e[li+i]; - for (int j=0;j=dia[i]*dia[j]) jerr++; - } } - if (jerr) { //Recovery - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j MAXFITPARS[i]+space) return i+1;}; - for (int i=2;i<4;i++) {if (fabs(Arr()[i]) > MAXFITPARS[i] ) return i+1;}; - - if (fabs(mP) > BIGFITPARS[4]+fabs(np._ptin)*BIGFITPART) return 4+1; - return 0; -} -//_____________________________________________________________________________ -int StvFitPars::Check(const char *tit) const -{ - int ifail = 0; - for (int i=0;i<5;i++) {if (fabs(Arr()[i]) > MAXFITPARS[i]){ifail=i+1;break;}}; - if (!ifail) return 0; - if (!tit || !tit[0]) return ifail; - TString ts(tit);ts +=" *** Check = "; ts+=ifail;ts +=" ***"; - Print(ts.Data()); - return 0; -} -//_____________________________________________________________________________ -void StvFitPars::Print(const char *tit) const -{ -static const char* Nams[]={"mH","mZ","mA","mL","mP",0}; - if (tit && tit[0]) printf("StvFitPars::Print(%s)\n",tit); - for (int i=0;Nams[i]; i++) {printf("%s=%g ",Nams[i],Arr()[i]);} - printf("\n"); -} -//_____________________________________________________________________________ - -//_____________________________________________________________________________ -/** - returns the node information - double x[6], : state, for a definition, in radial implementation - rad - radius at start (cm). See also comments - phi - azimuthal angle (in rad) - z - z-coord. (cm) - tanl - tan(dip) =pz/pt - psi - azimuthal angle of pT vector (in rads) - pti - signed invert Pt.// pti = curv/hz - double cc[15] : error matrix of the state "x" rad is fixed - code definition adopted here, where: - PhiPhi; - ZPhi ,ZZ; - TanlPhi ,TanlZ ,TanlTanl, - PhiPsi ,ZPsi ,TanlPsi , PsiPsi , - PhiPti ,ZPti ,TanlPti, PsiPti, PtiPti - -*/ -//_____________________________________________________________________________ -void StvNodePars::GetRadial(double radPar[6],double radErr[15],const StvFitErrs *fitErr) const -{ -//Remind StvFitPars: -//double mH; // direction perpendicular movement and Z -//double mZ; // Pseudo Z, direction perpendicular movement & H -//double mA; // Angle in XY. cos(A),sin(A),T moving direction -//double mL; // Angle lambda in Rxy/Z -//double mP; // 1/pt with curvature sign - - enum {jRad=0,jPhi,jZ,jTan,jPsi,jPti}; - enum {jRPhiRPhi=0 - ,jRPhiZ ,jZZ - ,jRPhiTan,jZTan,jTanTan - ,jRPhiPsi,jZPsi,jTanPsi,jPsiPsi - ,jRPhiPti,jZPti,jTanPti,jPsiPti,jPtiPti}; - double r2xy = _x*_x+_y*_y, rxy=sqrt(r2xy); - double cos2L = 1./(1+_tanl*_tanl); - double cosL = sqrt(cos2L); - double sinL = _tanl*cosL; - - radPar[jRad] = rxy; - radPar[jPhi] = atan2(_y,_x); - radPar[jZ ] = _z; - radPar[jTan] = _tanl; - radPar[jPsi] = _psi; - radPar[jPti] = _ptin; - if (!radErr) return; - - - double A[6][5]= -/* H Z A L P */ -/*--------------------------------------------------------*/ -/*x*/ {{ -_sinCA, -sinL*_cosCA, 0, 0, 0}, -/*y*/ { _cosCA, -sinL*_sinCA, 0, 0, 0}, -/*z*/ { 0, cosL, 0, 0, 0}, -/*A*/ { 0, 0, 1, 0, 0}, -/*L*/ { 0, 0, 0, 1, 0}, -/*P*/ { 0, 0, 0, 0, 1}}; - - double g[6][1]= - {{ cosL*_cosCA }, - { cosL*_sinCA }, - { sinL }, - { cosL*cosL*_curv}, - { 0 }, - { 0 }}; - - double myX[1][6] = {{_x,_y,0,0,0,0}}; - - TMatrixD MA(6,5,A[0]),Mg(6,1,g[0]),Mx(1,6,myX[0]); - double xg = -1./(Mx*Mg)[0][0]; - TMatrixD T1 = MA+(Mg*(Mx*MA))*xg; - -// -double dRad[5][6] = -/* x, y, z, A, L, P*/ -/*-----------------------------------------------------------*/ -/*jRPhi*/ {{- _y/rxy, _x/rxy, 0, 0, 0, 0} -/*jZ */ ,{ 0, 0, 1, 0, 0, 0} -/*jTan*/ ,{ 0, 0, 0, 0,1/cos2L, 0} -/*jPsi*/ ,{ 0, 0, 0, 1/cosL, 0, 0} -/*jPti*/ ,{ 0, 0, 0, 0, 0, 1}}; -/*-----------------------------------------------------------*/ - - TMatrixD T2=TMatrixD(5,6,dRad[0])*T1; - TCL::trasat(T2.GetMatrixArray(),fitErr->Arr(),radErr,5,5); - -} -//_____________________________________________________________________________ -void StvNodePars::GetPrimial(double radPar[6],double radErr[15],const StvFitErrs *fitErr) const -{ -/// This is GetRadial for primary track. Radial representation of errors -/// is senseless for primary. But our oldfashiond TPT format demanding it. -/// All space errors supposed to be zeros. - -//Remind StvFitPars: -//double mH; // direction perpendicular movement and Z -//double mZ; // Pseudo Z, direction perpendicular movement & H -//double mA; // Angle in XY. cos(A),sin(A),T moving direction -//double mL; // Angle lambda in Rxy/Z -//double mP; // 1/pt with curvature sign - - enum {jRad =0,jPhi ,jZ ,jTan,jPsi,jPti}; - - double r2xy = _x*_x+_y*_y, rxy=sqrt(r2xy); - double cos2L = 1./(1+_tanl*_tanl); - double cosL = sqrt(cos2L); - - radPar[jRad] = rxy; - radPar[jPhi] = atan2(_y,_x); - radPar[jZ ] = _z; - radPar[jTan] = _tanl; - radPar[jPsi] = _psi; - radPar[jPti] = _ptin; - if (!radErr) return; - -double T[5][5] = -/* H, Z, A, L, P*/ -/*----------------------------------------------------*/ -/*jRPhi*/ {{ 0, 0, 0, 0, 0} -/*jZ */ ,{ 0, 0, 0, 0, 0} -/*jTan*/ ,{ 0, 0, 0, 1/cos2L,0} -/*jPsi*/ ,{ 0, 0,1/cosL, 0, 0} -/*jPti*/ ,{ 0, 0, 0, 0, 1}}; -/*----------------------------------------------------*/ - - TCL::trasat(T[0],fitErr->Arr(),radErr,5,5); - -} -//______________________________________________________________________________ -const StvFitPars &StvFitPars::operator*(const StvFitDers &t) const -{ -static StvFitPars myPars; - TCL::vmatl(t[0],Arr(),myPars.Arr(),5,5); - return myPars; -} -//_____________________________________________________________________________ -void StvFitErrs::Get(const StvNodePars *np, StvNodeErrs *ne) const -{ - double cos2L = 1./(np->_tanl*np->_tanl+1); - double dTdL = 1./cos2L; - double cosL = sqrt(cos2L); - -// d/dH d/dZ d/dA d/dLam d/dPti - double T[6][5] = {{ np->_cosCA, 0, 0, 0, 0} //dX - ,{ np->_sinCA, 0, 0, 0, 0} //dY - ,{ 0, 1/cosL, 0, 0, 0} //dZ - ,{ 0, 0, 1, 0, 0} //dEta - ,{ 0, 0, 0, 0, 1} //dPti - ,{ 0, 0, 0, dTdL, 0}}; //dTan - - assert(0); - TCL::trasat(T[0],this->Arr(),*ne,5,6); - -} -//______________________________________________________________________________ -StvImpact::StvImpact() {memset(this,0,sizeof(*this));} - -//______________________________________________________________________________ -void StvImpact::Print(const char *opt) const -{ - if (!opt) opt = ""; - printf("StvImpact::Print(%s) ==\n",opt); - -static const char* tit[]={"Imp","Z ","Psi","Pti","Cur",0}; - const float* P=&mImp; - for (int i=0;i<5;i++) {printf("%s = %g, ",tit[i],P[i]);} - printf("\n"); - if (mImpImp<=0) return; - const float *e = &mImpImp; - for (int i=0,li=0;i< 5;li+=++i) { - printf("%s ",tit[i]); - for (int j=0;j<=i;j++) { - printf("%g\t",e[li+j]);} - printf("\n"); - } - - -} -#if 0 // -//____________________________________________________________ -double EmxSign(int n,const double *a) -{ - double ans=3e33; - double buf[55]; - double *B = (n<=10) ? buf : new double[n]; - double *b = B; - // trchlu.F -- translated by f2c (version 19970219). - // - //see original documentation of CERNLIB package F112 - - /* Local variables */ - int ipiv, kpiv, i__, j; - double r__, dc; - int id, kd; - double sum; - - - /* CERN PROGLIB# F112 TRCHLU .VERSION KERNFOR 4.16 870601 */ - /* ORIG. 18/12/74 W.HART */ - - - /* Parameter adjuTments */ - --b; --a; - - /* Function Body */ - ipiv = 0; - - i__ = 0; - - do { - ++i__; - ipiv += i__; - kpiv = ipiv; - r__ = a[ipiv]; - - for (j = i__; j <= n; ++j) { - sum = 0.; - if (i__ == 1) goto L40; - if (r__ == 0.) goto L42; - id = ipiv - i__ + 1; - kd = kpiv - i__ + 1; - - do { - sum += b[kd] * b[id]; - ++kd; ++id; - } while (id < ipiv); - -L40: - sum = a[kpiv] - sum; -L42: - if (j != i__) b[kpiv] = sum * r__; - else { - if (sum 0.) r__ = (double)1. / dc; - } - kpiv += j; - } - - } while (i__ < n); - -RETN: if (B!=buf) delete B; - return ans; -} /* trchlu_ */ -#endif //0 - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -#include "TRandom.h" -#include "TMatrixDSym.h" -#include "TMatrixD.h" -#include "TVectorD.h" -#include "TVector3.h" -#include "StarRoot/TRandomVector.h" -//_____________________________________________________________________________ -ClassImp(StvNodeParsTest); -void StvNodeParsTest::Test() -{ - double thPars[7+15],Hz=0.000299792458 * 4.98478; - for (int i=0;i<7+15;i++) {thPars[i]=gRandom->Rndm();} - THelixTrack th(thPars,thPars+3,thPars[6]),thh; - memcpy(thPars+3,th.Dir(),3*sizeof(double)); - th.SetEmx(thPars+7); - - StvNodePars pars; - StvFitErrs errs; - pars.set(&th,Hz); - errs.Set(&th,Hz); - pars.reverse(); - errs.Backward(); - pars.get(&thh); - errs.Get(&thh); - thh.Backward(); - - double thhPars[7+15]; - memcpy(thhPars,thh.Pos(),7*sizeof(double)); - memcpy(thhPars+7,thh.Emx()->Arr(),15*sizeof(double)); - int nerr=0; - for (int i=0;i<7+15;i++) { - if (fabs(thhPars[i]-thPars[i]) <1e-6) continue; - nerr++;printf("%d = %g %g \n",i,thPars[i],thhPars[i]);} - printf("nmErrs = %d\n",nerr); -} -//_____________________________________________________________________________ -void StvNodeParsTest::TestGetRadial(int nEv) -{ -StvFitErrs fE; - double f = 0.01; - TVectorD D(5); - D[0] = 1.0*1.0 *f; - D[1] = 2.0*2.0 *f; - D[2] = 0.03*0.03 *f; - D[3] = 0.04*0.04 *f; - D[4] = 0.07*0.07 *f; - TRandomVector RV(D); - - TMatrixD S(RV.GetMtx()); - S.Print(); - - double *e = &fE.mHH; - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - e[li+j]= S[i][j]; - } } - - - StvNodePars node; - node.reset(); - double myRad = 100; - double phi = gRandom->Rndm()*2*M_PI; - node._x = myRad*cos(phi); - node._y = myRad*sin(phi); - node._z = (gRandom->Rndm()-0.5)*200; - node._psi = phi + (gRandom->Rndm()-0.5); - node._tanl = gRandom->Rndm(); - node._ptin = (gRandom->Rndm()-0.5); - node._hz = 0.000299792458 * 4.98478; - node.ready(); - - double radPar[6],radErr[15]; - node.GetRadial(radPar,radErr,&fE); - TMatrixDSym SS(5); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - SS[i][j]=radErr[li+j]; SS[j][i]=radErr[li+j]; - } } - SS.Print(); - - double rE[15]={0}; - for (int ev=0;evqAmax) qAmax=dif; - } } - qA/=15; - printf("Quality %g < %g < 1\n",qA,qAmax); -} - -//_____________________________________________________________________________ -static void Add(THelixTrack &ht,const double add[5]) -{ -// add = H,A,C,Z,L - TVector3 pos(ht.Pos()),dir(ht.Dir()),ort(-dir[1],dir[0],0.); - ort = ort.Unit(); - double rho=ht.GetRho(); - pos+=ort*add[0]; pos[2]+=add[3]; - dir.SetMagThetaPhi(1.,dir.Theta()-add[4],dir.Phi()+add[1]); - double wk[7]={pos[0],pos[1],pos[2],dir[0],dir[1],dir[2],rho+add[2]}; - ht.Set(wk,wk+3,wk[6]); -} - - -//_____________________________________________________________________________ -void StvNodeParsTest::TestErrProp(int nEv) -{ - -StvNodePars iP,iPR,oP,oPR; -THelixTrack iH,iHR,oH,ht; -StvFitErrs iE,oE,oER; - -THEmx_t oHE,oHER; -double dia[5],*e,*er,*vtx; - iP._cosCA = 0.99999209770847208, iP._sinCA = 0.0039754899835676982, iP._x = 153.15599597873157, - iP._y = 61.139971243562862, iP._z = -165.47715347045698, iP._psi = 0.0039755004554277579, iP._ptin = 3.000133812200076, iP._tanl = 9, - iP._curv = 0.0044971007445879334, iP._hz = 0.0014989667215176954; - - iE.mHH = 0.008422599212098222, iE.mHZ = -0.0091916832962463078, iE.mZZ = 0.019038123366318632, iE.mHA = -0.00039625080910056564, - iE.mZA = 0.00027601715939822415, iE.mAA = 3.8654618686681686e-05, iE.mHL = 0.00029431818666556691, iE.mZL = -0.00060667408715620378, - iE.mAL = -1.2045956628097832e-05, iE.mLL = 2.6946791206097881e-05, iE.mHP = 0.013476203596402746, iE.mZP = -0.00058380596704562366, - iE.mAP = -0.0021487322180886877, iE.mLP = 0.00016358043963761329, iE.mPP = 0.17711658543201794, iE.mHz = 0.0014989667215176954; -#if 0 - iP._cosCA = 0.051522195951218416; iP._sinCA = -0.99867184876021664; iP._x = 56.80456301948584; - iP._y = -179.95090442478528; iP._z = 16.833129146428401; iP._psi = -1.5192513089402997; iP._ptin = -4.286089548109465; - iP._tanl = -0.71077992742240803; iP._curv = -0.0063779138641975935;iP._hz=(0.0014880496061989194); - iP.ready(); - - iE.mHH = 0.0025928369042255385; iE.mHZ = -4.9934860023454386e-11; iE.mZZ = 0.014598355970801268; iE.mHA = -0.00059887440419442305; - iE.mZA = 1.0958739205478152e-11; iE.mAA = 0.00026524379894739812; iE.mHL = 3.463001237863329e-12; iE.mZL = -0.0016525557966380938; - iE.mAL = 8.3669926017237923e-13; iE.mLL = 0.00041855110437868546; iE.mHP = 0.0043962440767417576; iE.mZP = -2.904206508909407e-11; - iE.mAP = -0.0041320793241820105; iE.mLP = -2.5031139398137018e-12; iE.mPP = 0.78568815092933286; iE.SetHz(0.0014880496061989194); -#endif - - oER*=0.; - oHER.Clear(); - -// Prepare error matrix for TRandomVector - TMatrixDSym S(5); - e = iE.Arr(); - for (int i=0,li=0;i< 5;li+=++i) {S[i][i] = e[li+i];} - TRandomVector::RandRotate(S); - - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++) { e[li+j] = S[i][j];}} -// - iE.Print("Input StvFitErrs"); - - iP.get(&iH); // nodePar => Helix - iE.Get(&iH); // fitErr => HelixErr - iE.Set(&iH,iP._hz); - iE.Print("Input StvFitErrs => THEmx_t => StvFitErrs"); - - - iH.Emx()->Print("Input Helix Errs"); - oH = iH; - double myDist = 33; - oH.Move(myDist); //Move helix to 100cm - oP.set(&oH,iP._hz); //helix100 => nodePar100 - oE.Set(&oH,iP._hz); //helixErr100 => fitErr100 - oE.Print("Output StvFitErrs"); - oH.Emx()->Print("Output Helix Errs"); - - vtx = oH.Pos(); - TVector3 Vtx(vtx); - TVector3 Dir(oH.Dir()); - TVector3 Nxy(-Dir[1],Dir[0],0.); Nxy = Nxy.Unit(); - -static int iHELIX=0; - -// Prepare error matrix for TRandomVector - e = (iHELIX) ? iH.Emx()->Arr() : iE.Arr(); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - S[i][j]=e[li+j]; S[j][i]=e[li+j]; - } } - TRandomVector RV(S); - -// Event loop - for (int ev=0;ev <= nEv;ev++) { - iPR = iP; - ht = iH; -// Randomize fit parameters - const TVectorD res = RV.Gaus(); - - if (iHELIX) { //Randomize helix directly - Add(ht,res.GetMatrixArray()); - } else { - StvFitPars fp(res.GetMatrixArray()); iPR+=fp; -// Create THelixTrack from StvNodePars - iPR.get(&ht); -// Set no error matrix to helix - ht.SetEmx(0); - } - -// // Change helix direction for fun -// ht.Backward(); -// Move random helix to DCA point of etalon vertex - double my100 = ht.Path(vtx); - assert(fabs(my100-myDist) <20); - ht.Move(my100); - oPR.set(&ht,iP._hz); - StvFitPars fp = (oPR-oP); - double *e = oER.Arr(); - double *d = fp.Arr(); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - e[li+j]+=d[i]*d[j]; - } } - double dS = ht.Path(vtx[0],vtx[1]); - ht.Move(dS); - double D[5]; - TVector3 VPos(ht.Pos()),VDir(ht.Dir()); - D[0] = (VPos-Vtx)*Nxy; - D[1] = VDir.DeltaPhi(Dir); - D[2] = ht.GetRho()-oH.GetRho(); - D[3] = VPos[2]-Vtx[2]; - D[4] = -(VDir.Theta()-Dir.Theta());// "-" due to theta)= Pi-Lambda - - e = oHER.Arr(); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - e[li+j]+=D[i]*D[j]; - } } - - - }//EndEvts - - oER *= (1./nEv); - oHER*= (1./nEv); - - printf("*** Check THelixTrack Error matrix ***\n"); - e = oH.Emx()->Arr(); - er = oHER.Arr(); - double qA=0,qAmax=0; - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=e[li+i]; - for (int j=0;j<=i;j++) { - double dif = (er[li+j]-e[li+j])/sqrt(dia[i]*dia[j]); - printf("(%d %d) \t%g = \t%g \t%g\n",i,j,er[li+j],e[li+j],dif); - dif = fabs(dif); - qA+= (dif); if (dif>qAmax) qAmax=dif; - } } - printf("Quality %g < %g < 1\n",qA,qAmax); - - - printf("*** Check StvFitErr Error matrix ***\n"); - e = oE.Arr(); - er = oER.Arr(); - qA=0;qAmax=0; - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=e[li+i]; - for (int j=0;j<=i;j++) { - double dif = (er[li+j]-e[li+j])/sqrt(dia[i]*dia[j]); - printf("(%d %d) \t%g = \t%g \t%g\n",i,j,er[li+j],e[li+j],dif); - dif = fabs(dif); - qA+= (dif); if (dif>qAmax) qAmax=dif; - } } - qA/=15; - printf("Quality %g < %g < 1\n",qA,qAmax); - -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -void StvNodeParsTest::TestMtx() -{ - double maxEps = 0,maxEpz = 0; - double hz = 0.0014880496061989194; - int nErr=0; - int iR =100 + gRandom->Rndm()*100; - int iAlf = 10 + gRandom->Rndm()*100; - int iLam = 10 + gRandom->Rndm()*100; - - double alf = iAlf/180.*M_PI; - double lam = iLam/180.*M_PI; - StvNodePars basePar,modiPar,baseEndPar,modiEndPar; - double Rho = 1./iR; - basePar._x=0.10; - basePar._y=0.20; - basePar._z=0.30; - basePar._psi=alf; - basePar._ptin=Rho/hz;; - basePar._tanl=tan(lam); - basePar._curv=Rho; - basePar._hz=hz; - basePar.ready(); - - THelixTrack baseHlx,modiHlx,baseEndHlx,modiEndHlx; - StvFitDers mtxStv,mtxZtv,mtxNum; - StvHlxDers mtxHlx; - basePar.get(&baseHlx); - double len = iR*1.5; - baseEndHlx = baseHlx; baseEndHlx.Move(len,mtxHlx); - baseEndPar.set(&baseEndHlx,hz); - baseEndPar.convert(mtxStv , mtxHlx); - baseEndPar.Deriv(len,mtxZtv); - double stpArr[]={0.1, 0.1, 3.14/180, 3.14/180, 0.1*basePar._ptin+1e-2}; - double fak=0.01; - memset(mtxNum[0],0,sizeof(mtxNum)); - for (int ip=0;ip<5; ip++) { //Loop thru input parameters - StvFitPars fp; fp.Arr()[ip]=stpArr[ip]*fak; - modiPar = basePar; - modiPar+= fp; - modiPar.get(&modiHlx); - modiEndHlx = modiHlx; - modiEndHlx.Move(len); - double myLen = modiEndHlx.Path(baseEndHlx.Pos()); - modiEndHlx.Move(myLen); - modiEndPar.set(&modiEndHlx,hz); - fp = modiEndPar-baseEndPar; - - for (int jp=0;jp<5;jp++) { - mtxNum[jp][ip] = fp.Arr()[jp]/(stpArr[ip]*fak); - } } - printf("TestMtx: Angle=%d Lam=%d \tRad=%d\n",iAlf,iLam,iR); - -static const char T[]="HZALP"; - for (int ip=0;ip<5; ip++) { //Loop thru input parameters - for (int jp=0;jp<5;jp++) { - double est = mtxNum[jp][ip]; - double ana = mtxStv[jp][ip]; - double unu = mtxZtv[jp][ip]; - double eps = 2*fabs(est-ana)/(stpArr[jp]/stpArr[ip]); - double epz = 2*fabs(est-unu)/(stpArr[jp]/stpArr[ip]); - if (eps>maxEps) maxEps=eps; - if (epz>maxEpz) maxEpz=epz; - - if (eps < 1e-3 && epz < 1e-3) continue; - nErr++; - printf(" m%c%c \t%g \t%g \t%g\n",T[jp],T[ip],ana,est,eps); - printf(" m%c%c \t%g \t%g \t%g\n",T[jp],T[ip],unu,est,epz); - } } - printf("TestMtx: %d errors maxEps=%g maxEpz=%g\n",nErr,maxEps,maxEpz); - -} - -//_____________________________________________________________________________ -// Some math for: -// -// (cL*cP) -// T = (cL*sP) -// (sL ) -// -// -// (-sP) -// P = ( cP) -// ( 0 ) -// -// -// -// (-sL*cP) -// L = (-sL*sP) -// ( cL ) -// -// -// dX = T*t + P*h + L*l -// -// -// (cP) -// D = (sP) -// (0 ) -// -// X0 = -imp*P -// dD = P*dPsi = P*(a/cL + rho*(cL*t -sL*l)) -// -// -// -// (Tk = T*s/cL + P*(-Imp+h+dFi0*s +rho*s*s/2) + L*l -// -// ACCOUNT ONLY 2D -// Tk = D*(s-sL*l) + P*(-Imp+h+dFi0*s+rho*s*s/2) -// dTk= D + P*(dFi0+rho*s) -// -// (Tk*dTk) = 0 -// -// Now keep only the biggest order of magnitude -// -// Tk = D*(s-sL*l) + P*(-Imp) -// dTk= D + P*(dFi0+rho*s) -// -// (s-sL*l)-Imp*(dFi0+rho*s)= 0 -// (1-Imp*rho)*s -sL*l -Imp*dFi0=0 -// s= (sL*l+Imp*dFi0)/(1-Imp*rho) -// dFi = dFi0 +rho*(sL*l+Imp*dFi0)/(1-Imp*rho) -// dFi = (dFi0*(1+rho*Imp) +rho*sL*l)/(1-rho*Imp) -// -// dFidFi0 = (1.)/(1-rho*Imp); -// dFidl = rho*sL/(1-rho*Imp); -// -// dFidA = (1+rho*Imp)/(1-rho*Imp) /cL -// -// dtdA = Imp/c2L/(1-Imp*rho) -// dtdl = tL/(1-Imp*rho) -// -// dZda = sL*dtdA; -// dZdl = sL*dtdl+cL; -// - -//_____________________________________________________________________________ -void StvNodePars::GetImpact(StvImpact *imp,const StvFitErrs *fe) const -{ - /// signed impact parameter; Signed in such a way that: - /// x = -impact*sin(Psi) - /// y = impact*cos(Psi) - imp->mImp = _x*(-_sinCA) + _y*(_cosCA); - double tst = _x*( _cosCA) + _y*(_sinCA); - assert(fabs(tst)<1e-5 || fabs(imp->mImp) > 1000*fabs(tst)); - imp->mZ = _z; - imp->mPsi = _psi; - imp->mPti = _ptin; - imp->mTan = _tanl; - imp->mCurv= _curv; - if (!fe) return; - - double c2L = 1./(1+_tanl*_tanl); - double cL = sqrt(c2L); - double sL = cL*_tanl; -// StvFitPars -// mH; direction perpendicular movement and Z -// mZ; Pseudo Z, direction perpendicular movement & H -// mA; Angle in XY. cos(A),sin(A),T moving direction -// mL; Angle lambda in Rxy/Z -// mP; 1/pt with curvature sign - -// Impacts -// float mImpImp; -// float mZImp, mZZ; -// float mPsiImp, mPsiZ, mPsiPsi; -// float mPtiImp, mPtiZ, mPtiPsi, mPtiPti; -// float mTanImp, mTanZ, mTanPsi, mTanPti, mTanTan; - -// t = tL*l + imp/cL/cL/(1-imp*rho)*a -// =========================== - - -double mImp = imp->mImp; -double nomMins = (1-mImp*_curv); -// d/dA -double dtda = mImp/nomMins /c2L; -double dpsida = 1/nomMins /cL; -double dZda = sL*dtda; -// d/dl -double dsdl = sL/nomMins; -double dPsidl = _curv*dsdl; -double dtdl = dsdl/cL; -double dZdl = sL*dtdl + cL; - - -double T[5][5]={ -/* h l A Lam Pti */ -/*------------------------------------*/ -/*Imp*/{ 1, 0, 0, 0, 0}, -/*Z */{ 0, dZdl, dZda, 0, 0}, -/*Psi*/{ 0,dPsidl, dpsida, 0, 0}, -/*Pti*/{ 0, 0, 0, 0, 1}, -/*Tan*/{ 0, 0, 0,1/c2L, 0}}; -/*-------------------------------------*/ - double qwe[15]; - TCL::trasat(T[0],fe->Arr(),qwe,5,5); - TCL::ucopy(qwe,&imp->mImpImp,15); -} -//_____________________________________________________________________________ -void StvNodeParsTest::TestImpact(int nEv) -{ - -StvNodePars iP,iPR,oP,oPR; -THelixTrack iH,iHR,oH,ht; - -THEmx_t oHE,oHER; -double dia[5],*e,qA,qAmax; -float *ef,*erf; - - iP._cosCA = 0.051522195951218416; iP._sinCA = -0.99867184876021664; iP._x = 56.80456301948584; - iP._y = -179.95090442478528; iP._z = 16.833129146428401; iP._psi = -1.5192513089402997; iP._ptin = -4.286089548109465; - iP._tanl = -0.71077992742240803; iP._curv = -0.0063779138641975935;iP._hz=(0.0014880496061989194); - iP.ready(); -StvFitErrs iE,oE,oER; - iE.mHH = 0.0025928369042255385; iE.mHZ = -4.9934860023454386e-11; iE.mZZ = 0.014598355970801268; iE.mHA = -0.00059887440419442305; - iE.mZA = 1.0958739205478152e-11; iE.mAA = 0.00026524379894739812; iE.mHL = 3.463001237863329e-12; iE.mZL = -0.0016525557966380938; - iE.mAL = 8.3669926017237923e-13; iE.mLL = 0.00041855110437868546; iE.mHP = 0.0043962440767417576; iE.mZP = -2.904206508909407e-11; - iE.mAP = -0.0041320793241820105; iE.mLP = -2.5031139398137018e-12; iE.mPP = 0.78568815092933286; iE.SetHz(0.0014880496061989194); - - - oER*=0.; - oHER.Clear(); - -// Prepare error matrix for TRandomVector - TMatrixDSym S(5); - e = iE.Arr(); - for (int i=0,li=0;i< 5;li+=++i) {S[i][i] = e[li+i];} - S*=0.01; -// Make huge correlations - TRandomVector::RandRotate(S); -// And put it back - for (int i=0,li=0;i< 5;li+=++i) {for (int j=0;j<=i;j++){e[li+j] = S[i][j];}} -// -// iE.Print("Input StvFitErrs"); - - iP.get(&iH); // nodePar => Helix - iE.Get(&iH); // fitErr => HelixErr - iE.Set(&iH,iP._hz); -// iE.Print("Input StvFitErrs => THEmx_t => StvFitErrs"); - - -// iH.Emx()->Print("Input Helix Errs"); - oH = iH; - double myDist = oH.Path(0.,0.); - oH.Move(myDist); //Move helix to 100cm - oP.set(&oH,iP._hz); //helix100 => nodePar100 - oE.Set(&oH,iP._hz); //helixErr100 => fitErr100 - oE.Print("Output StvFitErrs"); -// oH.Emx()->Print("Output Helix Errs"); - StvImpact oI,oIR; - oP.GetImpact(&oI,&oE); - oI.Print("Output StvImpact"); - - - -// Prepare error matrix for TRandomVector - e = iE.Arr(); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - S[i][j]=e[li+j]; S[j][i]=e[li+j]; - } } - TRandomVector RV(S); - -// Event loop - double oErr[15]={0}; - for (int ev=0;ev <= nEv;ev++) { - iPR = iP; - ht = iH; -// Randomize fit parameters - TVectorD res = RV.Gaus(); - StvFitPars fp(res.GetMatrixArray()); iPR+=fp; -// Create THelixTrack from StvNodePars - iPR.get(&ht); -// Set no error matrix to helix - ht.SetEmx(0); - - double my100 = ht.Path(0.,0.); - assert(fabs(my100-myDist)= M_PI) d[2]-=2*M_PI; -// float *ef = &oIR.mImpImp; - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { -// ef[li+j]+=d[i]*d[j]; - oErr[li+j]+=d[i]*d[j]; - } } - - my100 = ht.Path(oP.P); - ht.Move(my100); - oPR.set(&ht,iP._hz); - fp = oPR-oP; - const double *q = fp.Arr(); - e = oER.Arr(); - for (int i=0,li=0;i< 5;li+=++i) { - for (int j=0;j<=i;j++ ) { - e[li+j]+=q[i]*q[j]; - } } - }//EndEvts - TCL::vscale(oErr,(1./nEv),oErr,15); - TCL::ucopy (oErr,&oIR.mImpImp, 15); - oER*=(1./nEv); - - printf("*** Check StvFitErr matrix ***\n"); - - qA=0;qAmax=0; - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=oE[li+i]; - for (int j=0;j<=i;j++) { - double dif = (oER[li+j]-oE[li+j])/sqrt(dia[i]*dia[j]); - printf("(%d %d) \t%g = \t%g \t%g\n",i,j,oER[li+j],oE[li+j],dif); - dif = fabs(dif); - qA+= (dif); if (dif>qAmax) qAmax=dif; - } } - qA/=15; - printf("Quality %g < %g < 1\n",qA,qAmax); - - - printf("/n*** Check StvImpact Error matrix ***\n"); - ef = &oI.mImpImp; - erf = &oIR.mImpImp; - qA=0;qAmax=0; - for (int i=0,li=0;i< 5;li+=++i) { - dia[i]=ef[li+i]; - for (int j=0;j<=i;j++) { - double dif = (erf[li+j]-ef[li+j])/sqrt(dia[i]*dia[j]); - printf("(%d %d) \t%g = \t%g \t%g\n",i,j,erf[li+j],ef[li+j],dif); - dif = fabs(dif); - qA+= (dif); if (dif>qAmax) qAmax=dif; - } } - qA/=15; - printf("Quality %g < %g < 1\n",qA,qAmax); - -} -//_____________________________________________________________________________ -#include "TMatrixT.h" -#include "TMatrixTSym.h" -#include "TVectorT.h" -//_____________________________________________________________________________ -double StvFitErrs::EmxSign(int n,const float *e) -{ - enum {maxN =10,maxE = (maxN*maxN-maxN)/2+maxN}; - double d[maxE]; - assert(n>0 && n<=maxN); - TCL::ucopy(e,d,(n*(n+1))/2); - return EmxSign(n,d); -} -//_____________________________________________________________________________ -double StvFitErrs::EmxSign(int n,const double *e) -{ - TMatrixDSym S(n); - TVectorD coe(n); - for (int i=0,li=0;i< n;li+=++i) { - double qwe = e[li+i]; - if(qwe<=0) return qwe; - qwe = pow(2.,-int(log(qwe)/(2*log(2)))); - coe[i]=qwe; - for (int j=0;j<=i;j++ ) { - S[i][j]=e[li+j]*coe[i]*coe[j]; S[j][i]=S[i][j]; - } } - TMatrixD EigMtx(n,n); - TVectorD EigVal(n); - EigMtx = S.EigenVectors(EigVal); - - double ans = 3e33; - for (int i=0;i -#include -#include -#include -#include -#include -#include "THelixTrack.h" - -class StvNodePars; -class StvFitPars; -class StvFitErrs; -class StvImpact; -class StvELossTrak; - -//------------------------------------------------------------------------------ -typedef double Mtx55D_t[5][5]; -void Multiply(Mtx55D_t &res, const Mtx55D_t &A,const Mtx55D_t &B); -void Multiply(double res[5], const Mtx55D_t &A,const double B[5]); -inline void Copy(Mtx55D_t &to,const Mtx55D_t &fr){memcpy(to[0],fr[0],5*5*sizeof(to[0][0]));} - -//------------------------------------------------------------------------------ -class StvFitDers //Derivative matrix of StvFitPars -{ -public: -operator const Mtx55D_t &() const {return mMtx;}; -operator Mtx55D_t &() {return mMtx;}; -StvFitDers &operator=( const StvFitDers &fr) - {memcpy(mMtx[0],fr[0],sizeof(mMtx)); return *this;}; - void Reverse(); -protected: -Mtx55D_t mMtx; -}; -//------------------------------------------------------------------------------ -class StvHlxDers //Derivative matrix of THelixTrack -{ -public: -operator const Mtx55D_t &() const {return mMtx;}; -operator Mtx55D_t &() {return mMtx;}; -StvHlxDers &operator=( const StvFitDers &fr) - {memcpy(mMtx[0],fr[0],sizeof(mMtx)); return *this;}; -protected: -Mtx55D_t mMtx; -}; - -void Invert(Mtx55D_t &to,const Mtx55D_t &fr); -void Testik(const Mtx55D_t &tt); -double EmxSign(int n,const double *a); -double EmxSign(int n,const float *a); -//------------------------------------------------------------------------------ -class StvFitPars -{ -public: - StvFitPars():mH(0),mZ(0),mA(0),mL(0),mP(0){} - StvFitPars(double h,double z):mH(h),mZ(z),mA(0),mL(0),mP(0){} - StvFitPars(const double *arr) {memcpy(&mH,arr,5*sizeof(mH));} -const StvFitPars &operator*(const StvFitDers &t) const; - void Print(const char *tit=0) const; - int Check(const char *tit=0) const; - int TooBig(const StvNodePars &np) const; - double *Arr() {return &mH;} -const double *Arr() const {return &mH;} -operator const double *() const {return &mH;} -operator double *() {return &mH;} -StvFitPars &operator*=(double f) - {for(int i=0;i<5;i++){(*this)[i]*=f;} return *this;} - -public: -// Let (Dx,Dy,Dz) vector track direction -// It could be also represented: -// (cos(L)*cos(A),cos(L)*sin(A),sin(L)) - -// mH: movement along (-Dy ,Dx , 0) vector -// mZ: movement along (-Dx*Dz , -Dz*Dy, Dy*Dy+Dx*Dx) -// Or mH: along (-cos(A),sin(A),0) -// mZ: along (-sin(L)*cos(A),-sin(L)*sin(A), cos(L)) - -double mH; // direction perpendicular movement and Z -double mZ; // Pseudo Z, direction perpendicular movement & H -double mA; // Angle in XY. cos(A),sin(A),T moving direction -double mL; // Angle lambda in Rxy/Z -double mP; // 1/pt with curvature sign -}; - - -//------------------------------------------------------------------------------ -class StvNodePars { -public: - enum eNodePars {kNPars=5}; - StvNodePars() {reset();} - void reset(); - void ready(); - int isReady() const; - void set(const THelixTrack *ht, double Hz); -const double *pos() const {return &_x;} - double *pos() {return &_x;} - void get( THelixTrack *ht) const; -double getPt() const { return 1./(fabs(_ptin)+1e-6); } - void getMom(double p[3]) const; - void getDir(double d[3]) const; -double getP2() const; -double getP() const; -double getRxy() const; -double getCos2L() const {return 1./(1.+_tanl*_tanl);} -double getCosL() const; - void reverse(); - void Deriv(double len, StvFitDers &der) const; - void Deriv(double len,double dPdP0,StvFitDers &der) const; - int isValid() const {return (_hz && _cosCA);}; -/// convert THelixTrack derivativ matrix into StvFitPar one - void convert( StvFitDers &fitDer , const StvHlxDers &hlxDer) const; -// move point along helix - void move(double dLen); -double move(const double v[3],double dPP,int dir); -// move point along helix up to given radius in xy - void moveToR(double Rxy); -StvNodePars &merge(double wt,StvNodePars &other); -// typical variations of parametrs -StvFitPars delta() const; -StvFitErrs deltaErrs() const; -double diff(const StvNodePars &other) const; -double diff(const StvNodePars &other, const StvFitErrs &otherr) const; -double diff(const float hit[3]) const; - -operator const double *() const {return P;} -operator double *() {return P;} - int getCharge() const {return (_ptin > 0) ? -1 : 1;} - int check(const char *pri=0) const; -void operator+=(const StvFitPars &add); -StvNodePars &operator=(const StvNodePars &fr); -const StvFitPars &operator-(const StvNodePars& sub) const; -void print() const; - void GetRadial (double radPar[6],double *radErr=0,const StvFitErrs *fE=0) const; - void GetPrimial(double radPar[6],double *radErr=0,const StvFitErrs *fE=0) const; - void GetImpact(StvImpact *imp,const StvFitErrs *fE=0) const; - - enum {kX=0,kY,kZ,kPhi,kCurv,kTanL}; -public: - /// sine and cosine of cross angle - double _cosCA; - double _sinCA; - union{double P[1];double _x;}; - double _y; - double _z; - double _psi; - /// signed invert pt [sign = sign(-qB)] - double _ptin; - /// tangent of the track momentum dip angle - double _tanl; - /// signed curvature [sign = sign(-qB)] - double _curv; - /// Z component magnetic field in units Pt(Gev) = Hz * RCurv(cm) - double _hz; -}; -class StvNodeErrs { -public: -StvNodeErrs(){reset();assert(&_cTT-&_cXX+1==21);} -void reset() {memset(this,0,sizeof(StvNodeErrs));} -operator const double *() const { return &_cXX;} -operator double *() { return &_cXX;} -public: - double _cXX; - double _cYX,_cYY; - double _cZX,_cZY, _cZZ; - double _cEX,_cEY, _cEZ, _cEE; - double _cPX,_cPY, _cPZ, _cPE, _cPP; - double _cTX,_cTY, _cTZ, _cTE, _cTP, _cTT; -}; - -//------------------------------------------------------------------------------ -class StvFitErrs -{ -public: - enum eFitErrs {kNErrs=15}; - StvFitErrs(double hh=0,double hz=0,double zz=0); - StvFitErrs(const StvFitErrs &fr) {*this = fr;} - void Set(const THelixTrack *he,double hz); - void Get( THelixTrack *he) const; - void Get(const StvNodePars *np, StvNodeErrs *ne) const; -double GetHz() const ;//?? { return mHz ;} - void SetHz(double hz);//?? { mHz=hz ;} - const double *Arr() const { return &mHH;} - double *Arr() { return &mHH;} -operator const double *() const { return &mHH;} -operator double *() { return &mHH;} -StvFitErrs &operator=(const StvFitErrs &fr) ; -StvFitErrs &operator*=(double f) {for (int i=0;i mMats; -}; -//------------------------------------------------------------------------------ -class StvNodeParsTest -{ -public: -static void Test(); -static void TestGetRadial(int nEv=10000); -static void TestErrProp (int nEv=10000); -static void TestMtx (); -static void TestImpact (int nEv=10000) ; -ClassDef(StvNodeParsTest,0) -}; - -//------------------------------------------------------------------------------ -// StvNodePars::inlines -inline void StvNodePars::reset(){memset(this,0,sizeof(StvNodePars));} -//------------------------------------------------------------------------------ -inline void StvNodePars::ready(){_cosCA=cos(_psi);_sinCA=sin(_psi);_curv = _hz*_ptin;} -//------------------------------------------------------------------------------ -inline void StvNodePars::getMom(double p[3]) const -{ - double pt = 1./(fabs(_ptin)+1e-6); - p[0]=pt*_cosCA;p[1]=pt*_sinCA;p[2]=pt*_tanl; -} -//------------------------------------------------------------------------------ -inline double StvNodePars::getRxy() const -{ - return sqrt(_x*_x+_y*_y); -} -//------------------------------------------------------------------------------ -inline void StvNodePars::getDir(double d[3]) const -{ - double nor = sqrt(1.+_tanl*_tanl); - d[0]=_cosCA/nor;d[1]=_sinCA/nor;d[2]=_tanl/nor; -} -//------------------------------------------------------------------------------ -inline double StvNodePars::getP() const -{ - double t =_tanl*_tanl; - t = (t<0.01)? (1.+t*(0.5-t*0.125)) : sqrt(1.+t); - return t/(fabs(_ptin)+1e-12); -} - -//------------------------------------------------------------------------------ -inline double StvNodePars::getP2() const -{ return 1./(_ptin*_ptin+1e-12)*(1.+_tanl*_tanl);} - -//------------------------------------------------------------------------------ -inline void StvNodePars::reverse() -{ - _cosCA = -_cosCA; _sinCA=-_sinCA; _psi+= M_PI; - while (_psi> M_PI) {_psi-=2*M_PI;} - while (_psi<-M_PI) {_psi+=2*M_PI;} - _tanl = -_tanl ; _curv = -_curv ; _ptin = -_ptin; -} -//------------------------------------------------------------------------------ -inline double StvNodePars::getCosL() const -{ - double tt = _tanl*_tanl; - return (tt<0.1)? 1./(1. +tt*(0.5 - tt*0.25)) :1./sqrt(1+tt); -} - -#endif diff --git a/StRoot/StvUtil/StvPullEvent.cxx b/StRoot/StvUtil/StvPullEvent.cxx deleted file mode 100644 index fd131543d23..00000000000 --- a/StRoot/StvUtil/StvPullEvent.cxx +++ /dev/null @@ -1,201 +0,0 @@ -#include -#include -#include "StvPullEvent.h" -#include "RVersion.h" -#if ROOT_VERSION_CODE < 331013 -#include "TCL.h" -#else -#include "TCernLib.h" -#endif -#include "StEvent/StEnumerations.h" -#include "StvDebug.h" - -ClassImp(StvPullTrk) -ClassImp(StvPullHit) -ClassImp(StvPullEvent) - -//_____________________________________________________________________________ - StvPullEvent::StvPullEvent() - :mTrksG("StvPullTrk",100) - ,mTrksP("StvPullTrk",100) - ,mHitsG("StvPullHit",100) - ,mHitsP("StvPullHit",100) - ,mHitsR("StvPullHit",100) - { - mHitsG.SetOwner(0); mHitsP.SetOwner(0); mHitsR.SetOwner(0); - Clear(); - }; -//_____________________________________________________________________________ -void StvPullTrk::Clear(const char*) -{ - memset(mBeg,0,mEnd-mBeg+1); -} -//_____________________________________________________________________________ -StvPullTrk::StvPullTrk() -{ - Clear(); -} -//_____________________________________________________________________________ -void StvPullTrk::Print(const char* option) const -{ - if (!option) option=""; - printf("StvPullTrk::Print(%s)\n",option); -} - - -//_____________________________________________________________________________ -void StvPullHit::Clear(const char*) -{ - memset(mBeg,0,mEnd-mBeg+1); -} -//_____________________________________________________________________________ -StvPullHit::StvPullHit() -{ - Clear(); -} -//_____________________________________________________________________________ -void StvPullHit::Print(const char* option) const -{ - if (!option) option=""; - printf("StvPullHit::Print(%s)\n",option); - - printf("lYHit %g(%g)\tlZHit %g(%g) lLen=%g\n" - ,lYHit,lYHitErr - ,lZHit,lZHitErr,lLen); - - - printf("lYPul %g(%g)\tlZPul %g(%g)\n" - ,lYPul,lYPulErr - ,lZPul,lZPulErr); - - - printf("gRHit=%g \tgPHit %g(%g)\tgZHit %g(%g)\n" - ,gRHit - ,gPHit,gPHitErr - ,gZHit,gZHitErr); - - printf("gRFit=%g \tgPFit %g(%g)\tgZFit %g(%g)\n" - ,gRFit - ,gPFit,gPFitErr - ,gZFit,gZFitErr); - - printf("gPPul %g(%g)\tgZPul %g(%g)\n" - ,gPPul,gPPulErr - ,gZPul,gZPulErr); - - -} -//_____________________________________________________________________________ -int StvPullHit::TestIt() -{ - return 0; -} -//_____________________________________________________________________________ -void StvPullEvent::Add(StvPullHit &hit,int gloPrim) -{ - TClonesArray *hits = &mHitsG+gloPrim; - int iHit = hits->GetLast()+1; - StvPullHit *kHit = (StvPullHit*)hits->New(iHit); - *kHit = hit; - if (gloPrim) return; - if (!hit.mDetector) return; - int i = 4; - if (hit.mDetector==kTpcId) i=1; - if (hit.mDetector==kSvtId) i=2; - if (hit.mDetector==kSsdId) i=3; - if (hit.mDetector==kPxlId) i=4; - if (hit.mDetector==kIstId) i=5; - if (!i || i>3)return; - ++mNHits[i-1]; -} -//_____________________________________________________________________________ -void StvPullEvent::Add(StvPullTrk &trk,int gloPrim) -{ - TClonesArray *trks = &mTrksG+gloPrim; - int iTrk = trks->GetLast()+1; - StvPullTrk *kTrk = (StvPullTrk*)trks->New(iTrk); - *kTrk = trk; - assert(trk.mTrackNumber); - mNTrks[gloPrim]++; -} -//_____________________________________________________________________________ - -const int *StvPullEvent::GetNHits() const -{ - return mNHits; -} -//_____________________________________________________________________________ -void StvPullEvent::Clear(const char*) -{ - mHitsG.Clear();mHitsP.Clear();mHitsR.Clear(); - mTrksG.Clear();mTrksP.Clear(); - memset(mVtx,0,sizeof(mVtx)); - memset(mEtx,0,sizeof(mEtx)); - mRun=0; mEvt=0; - memset(mNTrks,0,sizeof(mNTrks)+sizeof(mNHits)); - -} - -//_____________________________________________________________________________ -void StvPullEvent::Finish() -{ -static int nCall=0; nCall++; - int iTkG=0,iTkP=0,iHiG=0,iHiP=0,idP=0,idG=0; - StvPullTrk* trkG=0,*trkP =0; - StvPullHit* hiG=0,*hiP =0; - int nHiG = mHitsG.GetLast()+1; - int nHiP = mHitsP.GetLast()+1; - for (iTkG=0;iTkGmTrackNumber; - idP=-1; trkP=0; - if (iTkPmTrackNumber; - } - int vertex = 0; - if (idG==idP) { //It is a primary - vertex = trkP->mVertex; - int nHits=0; - for(;iHiPmTrackNumber) break; - nHits++; - hiP->mTrackNumber=iTkG+1; - hiP->mVertex=vertex; - } - assert(nHits<=trkP->nAllHits); - trkP->mTrackNumber= iTkG+1; iTkP++; - }//end It is a primary - - int nHits=0; - for(;iHiGmTrackNumber) break; - nHits++; - hiG->mTrackNumber=iTkG+1; hiG->mVertex=vertex; - } - assert(nHits<=trkG->nAllHits); - trkG->mVertex = vertex; - trkG->mTrackNumber= iTkG+1; - } - -// for (iTkG=0;iTkGmVertex != mIVtx) continue; -// if (trkG->nAllHits < 15) continue; -// double ar[7]; -// ar[0] = cos(trkG->mPhi-trkG->mPsi); -// // assert(fabs(ar[0])<1e-3); -// ar[0] = trkG->mRxy*cos(trkG->mPhi); -// ar[1] = trkG->mRxy*sin(trkG->mPhi); -// ar[2] = trkG->mZ; -// ar[3] = cos(trkG->mDip)*cos(trkG->mPsi); -// ar[4] = cos(trkG->mDip)*sin(trkG->mPsi); -// ar[5] = sin(trkG->mDip); -// ar[6] = trkG->mCurv; -// double dca00 = (-ar[0]*ar[4]+ar[1]*ar[3])/cos(trkG->mDip); -// StvDebug::Count("PriDca00",dca00); -// } - - - -} - diff --git a/StRoot/StvUtil/StvPullEvent.h b/StRoot/StvUtil/StvPullEvent.h deleted file mode 100644 index ddb0a166ecf..00000000000 --- a/StRoot/StvUtil/StvPullEvent.h +++ /dev/null @@ -1,224 +0,0 @@ -/*! - * \class StvPullEvent - * \author Victor Perev, Jan 2006 - */ -/*************************************************************************** - * - * $Id: StvPullEvent.h,v 1.9 2016/12/28 16:49:11 perev Exp $ - * - * Author: Victor Perev, Jan 2006 - *************************************************************************** - * - * Description: - * - *************************************************************************** - * - * $Log: StvPullEvent.h,v $ - * Revision 1.9 2016/12/28 16:49:11 perev - * Global X,Y,Z for hit added - * - * Revision 1.8 2013/07/02 04:08:09 perev - * add dca00 to pull tree - * - * Revision 1.7 2013/03/08 03:42:55 perev - * Define empty Finish() - * - * Revision 1.6 2012/10/21 22:59:41 perev - * Add IdTruth into pulls - * - * Revision 1.5 2012/04/10 22:44:15 perev - * Chi2 for primary track + vertex added - * - * Revision 1.4 2011/08/19 16:27:06 perev - * track errors added - * - * Revision 1.3 2011/07/19 20:10:31 perev - * Dca00 added - * - * Revision 1.2 2011/04/03 20:53:54 perev - * Type of end tracking added - * - * Revision 1.1 2010/09/25 17:52:07 perev - * NewDir - * - * Revision 1.3 2010/08/01 00:13:19 perev - * Pull errors added - * - * Revision 1.2 2010/07/30 02:54:30 perev - * Length fr hit added - * - * Revision 1.1 2010/07/06 20:27:43 perev - * Alpha version of Stv (Star Tracker Virtual) - * - * Revision 1.7 2009/10/24 20:35:33 perev - * Remove redundante definition of StvPullEvent::~StvPullEvent() - * - * Revision 1.6 2009/10/18 22:02:12 perev - * Propagate primary info into globals(Finish()) - * - * Revision 1.5 2009/10/15 03:28:58 perev - * Add primary vertex number and charge(GVB) - * - * Revision 1.4 2007/10/16 20:56:00 fisyak - * Add pull entries for Pxl and Ist - * - * Revision 1.3 2006/12/19 19:44:41 perev - * tracks added - * - * Revision 1.2 2006/12/18 01:33:35 perev - * + branch mHitsR(nd) +nHitCand +iHitCand - * - * Revision 1.1 2006/04/07 17:34:41 perev - * StvPullEvent class added - * - * Revision 1.1 2006/02/14 19:02:09 perev - * Svt self alignment maker - * - * - **************************************************************************/ -#ifndef StvPullEvent_hh -#define StvPullEvent_hh -#include "TObject.h" -#include "TClonesArray.h" -#include "TDatime.h" - - -class StvPullTrk : public TObject { -public: - StvPullTrk(); - ~StvPullTrk(){} - void Finish(){;} - void Clear(const char *opt = ""); - void Print(const char* option = "") const; -public: -char mBeg[1]; -short mTrackNumber; //track number -unsigned char mVertex; //vertex number for primary track -unsigned char nAllHits; //number of all hits in track -unsigned char nTpcHits; //number of tpc hits in track -unsigned char nFtpcHits; //number of tpc hits in track -unsigned char nSsdHits; //number of ssd hits in track -unsigned char nRndHits; //number of RND hits in track -unsigned char mL; //Length of track -unsigned char mTypeEnd; //Type of end tracking - -float mChi2; -float mChi2P; -float mCurv; //curvature -float mPt; //pt -float mPsi; //track Psi(around beam) in global Stv frame -float mDip; //track Dip in global Stv frame -float mRxy; //Rxy of track begining -float mPhi; //Phi angle of track begining -float mZ; -float mDca00; -// Errors -float mPtErr; //pt error -float mPsiErr; //track Psi error -float mDipErr; //track Dip error -float mRxyErr; //Rxy error -float mZErr; //z error -short int mIdTruTk; -short int mQaTruTk; -char mEnd[1]; - ClassDef(StvPullTrk,4); -}; - -class StvPullHit : public TObject { -public: - StvPullHit(); - ~StvPullHit(){} - void Clear(const char *opt = ""); - void Print(const char* option = "") const; -int TestIt(); -public: -char mBeg[1]; //! No IO -short mTrackNumber; //track number of hit -unsigned char mVertex; //vertex number for primary track -unsigned char nAllHits; //number of all hits in track -unsigned char nTpcHits; //number of tpc hits in track -unsigned char nFtpcHits; //number of ftpc hits in track -unsigned char nSsdHits; //number of ssd hits in track -unsigned char nRndHits; //number of RND hits in track -unsigned char mDetector; //see StHit.h - // 0=smallest Xi2 - - -float mChi2; -float mCurv; //curvature -float mPt; //pt -float mCharge; //charge (Q) -float mX; //global X -float mY; //global Y -float mZ; //global Z -// locals -// local Stv frame is a StvTrtack frame -float lYHit; // y of Hit in local Stv frame -float lZHit; // z of Hit in local Stv frame -float lYHitErr; // y Hit Err in local Stv frame -float lZHitErr; // z Hit Err in local Stv frame -float lLen; // length of Hit - -float lYPul; // lYHit/lYHitErr -float lZPul; // lZHit/lZHitErr -float lYPulErr; // y pull Err in local Stv frame -float lZPulErr; // z pull Err in local Stv frame - -// Globals -float gPhiHP; // phi of normal vector of hit plane in global Stv frame -float gLamHP; // lambda of normal vector of hit plane in global Stv frame -float gRHit; // Rxy of Hit in global Stv frame -float gPHit; // Phi of Hit in global Stv frame -float gZHit; // Z of Hit in global Stv frame -float gPHitErr; // Phi Hit err in global Stv frame -float gZHitErr; // Z Hit err in global Stv frame - -float gRFit; // Rxy of Fit in global Stv frame -float gPFit; // Phi of Fit in global Stv frame -float gZFit; // Z of Fit in global Stv frame -float gPFitErr; // Phi Fit err in global Stv frame -float gZFitErr; // Z Fit err in global Stv frame - -float gPPul; // dPhi*Rxy of Pul in global Stv frame -float gZPul; // dZ of Pul in global Stv frame -float gPPulErr; // dPhi Pul err in global Stv frame -float gZPulErr; // dZ Pul err in global Stv frame - -float gPsi; // track Psi in global Stv frame -float gDip; // track Dip in global Stv frame -short int mIdTruth; -short int mQaTruth; -char mEnd[1]; //!No IO - ClassDef(StvPullHit,2); -}; - -class StvPullEvent : public TObject { -public: - StvPullEvent(); -void Clear(const char *opt = ""); -void Finish(); -void Add(StvPullHit &ph,int gloPrim); -void Add(StvPullTrk &pt,int gloPrim=0); -const int *GetNHits() const; -public: - int mRun; - int mEvt; - TDatime mDate; //DAQ time (GMT) - - int mIVtx; //Primary vertex id - float mVtx[3]; //Primary vertex position in global frame - float mEtx[6]; //errors xx,yx,yy,zx,zy,zz - float mChi2; //Chi square of vertex fit - int mNTrks[2]; //N glob,N Prim tracks - int mNHits[6]; //nTpc,nSvt,nSsd,nPxl,nIst,nRnd hits - -TClonesArray mTrksG; //global tracks -TClonesArray mTrksP; //primary tracks -TClonesArray mHitsG; //StvPullHits for global tracks -TClonesArray mHitsP; //StvPullHits for primary tracks -TClonesArray mHitsR; //StvPullHits for Rnd detectors - ClassDef(StvPullEvent,5); -}; - - -#endif diff --git a/StarVMC/GeoTestMaker/CompareInvX0.C b/StarVMC/GeoTestMaker/CompareInvX0.C deleted file mode 100644 index 56d3861620e..00000000000 --- a/StarVMC/GeoTestMaker/CompareInvX0.C +++ /dev/null @@ -1,90 +0,0 @@ -int loaded=0; - -void Load(); - -void CompareInvX0(const char *m1, const char *m2) -{ - Load(); - const TProfile2D *P[3]={0}; - const char *M[2]={m1,m2}; - - for (int i=0;i<2;i++) { - int ierr=0; - { gROOT->Macro(M[i],&ierr);} - if (ierr) return; - TString myTs(M[i]); - myTs = gSystem->BaseName(myTs); - assert(myTs(0,2) == "C_"); - myTs.Replace(0,2,""); - int j=0; - for (j=1; jFindObject(myTs); - if (!P[i]) {printf("***ERROR: Histogram %s NOT FOUND***\n",myTs.Data());return;} - - printf("File %s && hist %s OK\n",M[i],myTs.Data()); - } - - int nX = P[0]->GetXaxis()->GetNbins(); - assert(nX==P[1]->GetXaxis()->GetNbins()); - - int nY = P[0]->GetYaxis()->GetNbins(); - assert(nY==P[1]->GetYaxis()->GetNbins()); - - double xLow=P[0]->GetXaxis()->GetXmin(); - double xUpp=P[0]->GetXaxis()->GetXmax(); - double xWid=P[0]->GetXaxis()->GetBinWidth(1); - double yLow=P[0]->GetYaxis()->GetXmin(); - double yUpp=P[0]->GetYaxis()->GetXmax(); - double yWid=P[0]->GetYaxis()->GetBinWidth(1); - - TString myTs("Compare_"); myTs += P[0]->GetName(); - myTs+="_And_"; myTs += P[1]->GetName(); - P[2] = new StTProfile2D(myTs,myTs,nX,xLow,xUpp,nY,yLow,yUpp); - for (int iX=1;iX<=nX;iX++) { - for (int iY=1;iY<=nY;iY++) { - double cont[2]; - cont[0] = P[0]->GetBinContent(iX,iY); - cont[1] = P[1]->GetBinContent(iX,iY); - double sum = cont[0] + cont[1]; - if (sum <1e-4) continue; - double del = cont[1] - cont[0]; - double err = pow(P[0]->GetBinError(iX,iY),2) - + pow(P[1]->GetBinError(iX,iY),2); - -// if (del*del < 9*err) continue; -// if (fabs(del)< 0.005*sum) continue; - if (fabs(del)< 0.001*sum) continue; - P[2]->Fill(xLow+0.5*xWid*(iX-1),yLow+0.5*yWid*(iY-1),del); - } } - - TString ts("C_"); ts +=P[2]->GetName(); - TCanvas *CC = new TCanvas(ts,ts,600,800); - P[2]->Draw("colz"); - CC->Print(".C"); - CC->Print(".png"); -} - -void Load() -{ - -TH1D h1d; h1d.GetPainter(); -gSystem->Load("libVMC.so"); -gSystem->Load("St_base.so"); -gSystem->Load("St_Tables.so"); -gSystem->Load("StUtilities.so"); -gSystem->Load("StChain.so"); -gSystem->Load("StarVMCApplication.so"); -gSystem->Load("libStarMiniCern.so"); -gSystem->Load("libgeant3.so"); -gSystem->Load("GeoTestMaker.so"); -loaded=1; - -} - diff --git a/StarVMC/GeoTestMaker/GCall.cxx b/StarVMC/GeoTestMaker/GCall.cxx deleted file mode 100644 index 1c67def1f35..00000000000 --- a/StarVMC/GeoTestMaker/GCall.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// $Id: GCall.cxx,v 1.4 2010/04/29 03:05:27 perev Exp $ -// -// -// Class GCall -// ------------------ -// Base class for Magnetic field calculation - -#include -#include -#include -#include "TError.h" -#include "GCall.h" - -ClassImp(GCall) -//_____________________________________________________________________________ -GCall::GCall(const char *name,const char *tit) - : TNamed(name,tit),fMC(0),fMCA(0) -{ - fDebug=0;fMC = 0; fMCA=0;fStack = 0; -} -//_____________________________________________________________________________ - void GCall::SetInterfaces(TVirtualMCApplication *mca,TVirtualMC *mc,TVirtualMCStack *stk) -{ - fMC = mc; fMCA=mca;fStack = stk; -} -//_____________________________________________________________________________ -int GCall::FunDD(const Double_t*, Double_t* b) -{ - Error("FunDD","Empty method is called"); - assert(0); return 0; - - } -//_____________________________________________________________________________ -void GCall::Field(const Double_t*, Double_t* b) -{ - Error("Field","Empty method is called"); - assert(0); -} -//_____________________________________________________________________________ -int GCall::Fun() -{ - Error("Fun","Empty method is called"); - assert(0);return 0; -} -//_____________________________________________________________________________ -void GCall::Print(const Option_t*) const -{ - Error("Print","Empty method is called"); -} - - diff --git a/StarVMC/GeoTestMaker/GCall.h b/StarVMC/GeoTestMaker/GCall.h deleted file mode 100644 index c3e0f514058..00000000000 --- a/StarVMC/GeoTestMaker/GCall.h +++ /dev/null @@ -1,49 +0,0 @@ -// $Id: GCall.h,v 1.2 2009/06/07 02:28:36 perev Exp $ -// -// -// Class GCall -// ------------------ - - -#ifndef STMC_USER_H -#define STMC_USER_H - -#include -class TVirtualMC;// ......................... Interface to Monte Carlo -class TVirtualMCApplication;// .............. Interface to MonteCarlo application -class TVirtualMCStack; - -class GCall : public TNamed -{ - public: - GCall(const char *name="Empty",const char *tit=""); - virtual ~GCall(){} - // methods - void SetInterfaces(TVirtualMCApplication *mca - ,TVirtualMC *mc - ,TVirtualMCStack *stk); - virtual void Init() {}; - virtual int Fun (); - virtual int FunDD(const Double_t* d1, Double_t* d2); - virtual void Field(const Double_t* d1, Double_t* d2); - virtual void Print(const Option_t* opt=0) const; - virtual void Finish(const Option_t* opt=0) {if(opt){}}; - - int operator()(){return Fun();} - int operator()(const double* d1, double* d2) {return FunDD(d1,d2);} - void SetDebug(int db=1) {fDebug = db ;} - int GetDebug() const {return fDebug;} - - protected: - // data members - int fDebug; - TVirtualMC *fMC; // .............. Interface to Monte Carlo - TVirtualMCApplication *fMCA;// .............. Interface to MonteCarlo application - TVirtualMCStack *fStack; - - ClassDef(GCall,0) // Extended TParticle -}; - -#endif //STMC_USER_H - - diff --git a/StarVMC/GeoTestMaker/GeoTestChain.C b/StarVMC/GeoTestMaker/GeoTestChain.C deleted file mode 100644 index c0e16e02254..00000000000 --- a/StarVMC/GeoTestMaker/GeoTestChain.C +++ /dev/null @@ -1,39 +0,0 @@ -int loaded=0; - -void Load(); -void GeoTestChain(const char *gy="y2009a(TPCE)",int nEv = 10000) -{ -if (!loaded) Load(); - - -StChain *chain = new StChain; -TString tsy(gy); -gSystem->ExpandPathName(tsy); -StMaker *mk = new GeoTestMaker("GeoTest",tsy.Data(), nEv); -mk->SetAttr("nPrim",100); -// StMaker *mk = new GeoTestMaker("GeoTest",tsy.Data(),1); -// mk->SetAttr("EtaMin",0.50); -// mk->SetAttr("EtaMax",0.51); -// mk->SetAttr("SteppingDebug",1); - - chain->Init(); - chain->EventLoop(1); - chain->Finish(); - -} - -void Load() -{ -TH1D h1d; h1d.GetPainter(); -gSystem->Load("libVMC.so"); -gSystem->Load("St_base.so"); -gSystem->Load("St_Tables.so"); -gSystem->Load("StUtilities.so"); -gSystem->Load("StChain.so"); -gSystem->Load("StarVMCApplication.so"); -gSystem->Load("libStarMiniCern.so"); -gSystem->Load("libgeant3.so"); -gSystem->Load("GeoTestMaker.so"); -loaded=1; - -} diff --git a/StarVMC/GeoTestMaker/GeoTestLoad.C b/StarVMC/GeoTestMaker/GeoTestLoad.C deleted file mode 100644 index 4dfb6763971..00000000000 --- a/StarVMC/GeoTestMaker/GeoTestLoad.C +++ /dev/null @@ -1,16 +0,0 @@ -int loaded=0; -void GeoTestLoad() -{ -TH1D h1d; h1d.GetPainter(); -gSystem->Load("libVMC.so"); -gSystem->Load("St_base.so"); -gSystem->Load("St_Tables.so"); -gSystem->Load("StUtilities.so"); -gSystem->Load("StChain.so"); -gSystem->Load("StarVMCApplication.so"); -gSystem->Load("libStarMiniCern.so"); -gSystem->Load("libgeant3.so"); -gSystem->Load("GeoTestMaker.so"); -loaded=1; - -} diff --git a/StarVMC/GeoTestMaker/GeoTestMaker.cxx b/StarVMC/GeoTestMaker/GeoTestMaker.cxx deleted file mode 100644 index 2e91cada566..00000000000 --- a/StarVMC/GeoTestMaker/GeoTestMaker.cxx +++ /dev/null @@ -1,136 +0,0 @@ -//*-- Author : Victor Perev -// -// $Id: GeoTestMaker.cxx,v 1.5 2013/04/20 21:53:41 perev Exp $ -// $Log: GeoTestMaker.cxx,v $ -// Revision 1.5 2013/04/20 21:53:41 perev -// Rename StTGeoHelper ==> StTGeoProxy -// -// Revision 1.4 2010/01/27 23:02:57 perev -// Development -// -// Revision 1.3 2009/08/29 21:19:04 perev -// 100 * 10000 tracks -// -// Revision 1.2 2009/06/07 02:28:36 perev -// 1st reasonable version with orth2 -// -// Revision 1.1 2009/03/25 23:15:10 perev -// New VMC maker -// -// Revision 1.9 2009/02/03 15:55:44 fisyak -// synchronize with .DEV2 -// -// Revision 1.2 2009/01/24 00:21:43 fisyak -// Fix debug flag -// -// Revision 1.1.1.1 2008/12/10 20:45:49 fisyak -// Merge with macos version -// -// Revision 1.8 2008/03/05 13:15:56 fisyak -// comply Skip signuture with base class -// -// Revision 1.7 2007/04/07 19:33:09 perev -// Check for input file added -// -// Revision 1.6 2007/01/09 04:53:20 potekhin -// New input modes -// -// Revision 1.4 2005/09/13 21:34:29 fisyak -// Move initialization from Init to InitRun, add conversion TGeoVolume to TVolume for StEventDisplayMaker and TofMatchers -// -// Revision 1.3 2005/06/17 18:35:45 fisyak -// Add flow diagram -// -// Revision 1.2 2005/06/09 20:14:40 fisyak -// Set Run number (=1 D) -// -// Revision 1.1 2005/05/24 22:58:08 fisyak -// The first version -// -// -// Rewritten by V.Perev - -/* Flow diagram: - Load(); // shared libraries - GetVMC(); // define gGeoManager ------------------- -GeoTestMaker::Init() ------------------- - -*/ - -#include -#include "TROOT.h" -#include "TSystem.h" -#include "TGeometry.h" -#include "TGeoManager.h" -#include "TObjectSet.h" -#include "GeoTestMaker.h" -#include "Stiostream.h" -#include "StarMagField.h" -#include "StVMCApplication.h" -#include "StMCStack.h" -#include "StMessMgr.h" -#include "TVirtualMC.h" -#include "TGeant3TGeo.h" -#include "StMCInitApp.h" -//#include "StMCSteppingHist.h" -#include "StMCStepping2Hist.h" -#include "StTGeoProxy.h" - -ClassImp(GeoTestMaker); - -//_____________________________________________________________________________ -GeoTestMaker::GeoTestMaker(const char *name,const char *gy, int trig) - :StMaker(name),fNTrig(trig),fGeo(gy) -{ -gSystem->AddIncludePath("${STAR}2/StarDb/VmcGeometry"); -} - -//_____________________________________________________________________________ -int GeoTestMaker::Init() -{ - StVMCApplication *app = new StVMCApplication(fGeo, "StVMC application"); - StMCInitApp *ini = new StMCInitApp(); - - if (*SAttr("NPrim" )) {ini->SetNPrim(IAttr( "NPrim"));} - if (*SAttr("PtMin" )) {ini->SetPt (DAttr( "PtMin"),DAttr( "PtMax"));} - if (*SAttr("EtaMin")) {ini->SetEta(DAttr("EtaMin"),DAttr("EtaMax"));} - if (*SAttr("PhiMin")) {ini->SetEta(DAttr("PhiMin"),DAttr("PhiMax"));} - if (*SAttr("ZMin" )) {ini->SetZ (DAttr( "ZMin"),DAttr( "ZMax"));} - app->SetInit(ini); -//StMCSteppingHist *steps = new StMCSteppingHist(fGeo); - StMCStepping2Hist *steps = new StMCStepping2Hist(fGeo); - app->SetStepping(steps); - if (*SAttr("SteppingDebug")) {steps->SetDebug(IAttr("SteppingDebug"));} - - app->Init(); - - StTGeoProxy::Instance()->Init(1); - - return StMaker::Init(); -} -//_____________________________________________________________________________ -int GeoTestMaker::InitRun (int runumber) -{ - return kStOK; -} -//_____________________________________________________________________________ -int GeoTestMaker::Make() -{ - TVirtualMC::GetMC()->ProcessRun(fNTrig); - return kStOK; -} -//_____________________________________________________________________________ -int GeoTestMaker::Finish() -{ - // StMCSteppingHist::Instance()->Finish(); -//StMCSteppingHist::Instance()->Finish(); - StMCStepping2Hist::Instance()->Finish(); - return StMaker::Finish(); -} - -//________________________________________________________________________________ -void GeoTestMaker::SetDebug(int l) { - StMaker::SetDebug(l); -} diff --git a/StarVMC/GeoTestMaker/GeoTestMaker.h b/StarVMC/GeoTestMaker/GeoTestMaker.h deleted file mode 100644 index 9e85392090d..00000000000 --- a/StarVMC/GeoTestMaker/GeoTestMaker.h +++ /dev/null @@ -1,48 +0,0 @@ -// $Id: GeoTestMaker.h,v 1.2 2015/08/04 21:13:40 jwebb Exp $ - -#ifndef STAR_GeoTestMaker -#define STAR_GeoTestMaker - -/*! - * - * \class GeoTestMaker - * \author fisyak - * \date 2005/04/22 - * \brief virtual base class for Maker - * - * This commented block at the top of the header file is considered as - * the class description to be present on the this class Web page. - * - */ - -#include "StMaker.h" -#include "StVMCApplication.h" -#include "TGeant3TGeo.h" -class GeoTestMaker : public StMaker { - public: - GeoTestMaker(const char *name="GeoTest",const char *gy="y2009",int nTrig=100); - virtual ~GeoTestMaker() {} - int Init(); - int InitRun(int); - int Make(); - int Finish(); - void SetDebug(int l); - - private: - // Private method declaration if any - - protected: - int fNTrig; - TString fGeo; - public: - virtual const char *GetCVS() const { - static const char cvs[]="Tag $Name: $ $Id: GeoTestMaker.h,v 1.2 2015/08/04 21:13:40 jwebb Exp $ built " __DATE__ " " __TIME__ ; - return cvs; - } - - ClassDef(GeoTestMaker,0) // Makers -}; - -#endif - - diff --git a/StarVMC/GeoTestMaker/GeoTouch.C b/StarVMC/GeoTestMaker/GeoTouch.C deleted file mode 100644 index ccfa66dfe12..00000000000 --- a/StarVMC/GeoTestMaker/GeoTouch.C +++ /dev/null @@ -1,38 +0,0 @@ -int loaded=0; - -void Load(); -class StTGeoHelper; -StTGeoHelper *geoHelp=0; - -void GeoTouch(const char *gy="y2009") -{ -if (!loaded) Load(); - TString ts("$STAR/StarDb/VmcGeometry/"); ts +=gy; ts +=".h"; - gROOT->Macro(ts); - geoHelp = StTGeoHelper::Instance(); -} -void Show(double z,double rxy) -{ - geoHelp->ShootZR(z,rxy); -} - - - - - - -void Load() -{ -TH1D h1d; h1d.GetPainter(); -gSystem->Load("libVMC.so"); -gSystem->Load("St_base.so"); -gSystem->Load("St_Tables.so"); -gSystem->Load("StUtilities.so"); -gSystem->Load("StChain.so"); -gSystem->Load("StarVMCApplication.so"); -gSystem->Load("libStarMiniCern.so"); -gSystem->Load("libgeant3.so"); -gSystem->Load("GeoTestMaker.so"); -loaded=1; - -} diff --git a/StarVMC/GeoTestMaker/StMCConstructGeometry.cxx b/StarVMC/GeoTestMaker/StMCConstructGeometry.cxx deleted file mode 100644 index 4517ddc2d72..00000000000 --- a/StarVMC/GeoTestMaker/StMCConstructGeometry.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// $Id: StMCConstructGeometry.cxx,v 1.6 2015/08/04 21:13:40 jwebb Exp $ -// -// -// Class StMCConstructGeometry -// ------------------ -// Base class for Magnetic field calculation - -#include -#include -#include "Stiostream.h" -//#include "StMessMgr.h" -#include "StMCConstructGeometry.h" -#include "TVirtualMC.h" -#include "TVirtualMCApplication.h" -#include "TROOT.h" -#include "TSystem.h" -#include "TGeoManager.h" -#include "TGeoShape.h" -#include "TGeoBBox.h" -#include "TGeoMatrix.h" -#include "TEnv.h" -#include "TRegexp.h" -#include "StMCStack.h" - -#include "StMessMgr.h" - -ClassImp(StMCConstructGeometry) - -//_____________________________________________________________________________ -StMCConstructGeometry::StMCConstructGeometry(const char *gy) - : GCall(gy,"StMCConstructGeometry") -{ -} -//_____________________________________________________________________________ -int StMCConstructGeometry::Fun() -{ - TString ts,tsn(GetName()),star("${STAR}"),top; - if (! gGeoManager) { - top = tsn(TRegexp("(.*)")); - if (top[0]=='(') {tsn.ReplaceAll(top,""); top = top(1, top.Length()-2); } - - if (tsn.Contains("yf")) { - star = "${STAR_PATH}/.DEV2"; - TString aaa(".include ${STAR_PATH}/.DEV2/StarDb/VmcGeometry"); - gSystem->ExpandPathName(aaa); - gROOT->ProcessLine(aaa); - aaa = gEnv->GetValue("Unix.*.Root.MacroPath",0); - aaa+= ":"; aaa+= star; aaa+="$/StarDb/VmcGeometry/"; - gEnv->SetValue("Unix.*.Root.MacroPath",aaa); - tsn.ReplaceAll("yf",""); - } - if (!ts.Contains(".C")) { - ts=star; - ts+="/StarDb/VmcGeometry/Geometry."; - ts+=tsn; ts+=".C"; - } - gSystem->ExpandPathName(ts); - int fail=gROOT->LoadMacro(ts); - //if (fail) Printf("operator()","fail=%d path=%s",fail,ts.Data()); - if (fail) LOG_FATAL << "operator() fail=" << fail << " path=" << ts.Data() << endm; - assert(fail==0); - gROOT->ProcessLine("CreateTable()"); - } - if (top.Length()) SetTop(top); - - gMC->SetRootGeometry(); - - return 0; -} -//_____________________________________________________________________________ -void StMCConstructGeometry::SetTop(const char *topName) -{ - TGeoVolume *vol= gGeoManager->GetVolume(topName); - assert(vol); - if (strcmp(topName,"CAVE")==0) {gGeoManager->SetTopVolume(vol);return;} - - TGeoMedium *meVac = gGeoManager->GetMedium("Vacuum"); - if(!meVac) { - const TGeoMaterial *maVac = gGeoManager->GetMaterial("Vacuum"); - if (!maVac) maVac = new TGeoMaterial("Vacuum", 0,0,0); - meVac = new TGeoMedium("Vacuum",1000000,maVac); - } - TGeoBBox *bb = (TGeoBBox*)vol->GetShape(); - bb->ComputeBBox(); - TString myName("."); myName+=vol->GetName(); - TGeoVolume *top = gGeoManager->MakeBox(myName,meVac - ,bb->GetDX(),bb->GetDY(),bb->GetDZ()); - - top->AddNode(vol,1,new TGeoTranslation(bb->GetOrigin()[0] - ,bb->GetOrigin()[1] - ,bb->GetOrigin()[2])); - gGeoManager->SetTopVolume(top); -} - - - - - - - diff --git a/StarVMC/GeoTestMaker/StMCConstructGeometry.h b/StarVMC/GeoTestMaker/StMCConstructGeometry.h deleted file mode 100644 index 5d54c51ef83..00000000000 --- a/StarVMC/GeoTestMaker/StMCConstructGeometry.h +++ /dev/null @@ -1,31 +0,0 @@ -// $Id: StMCConstructGeometry.h,v 1.2 2010/01/27 23:02:57 perev Exp $ -// -// -// Class StMCConstructGeometry -// ------------------ - - -#ifndef STMC_GENERATEPRIMARIES_H -#define STMC_GENERATEPRIMARIES_H - -#include "GCall.h" -class StMCConstructGeometry : public GCall -{ - public: - StMCConstructGeometry(const char *gy); - virtual ~StMCConstructGeometry(){} - // methods - int Fun(); - private: - void SetTop(const char *topName); - - protected: - // data members - - ClassDef(StMCConstructGeometry,0) // Extended TParticle -}; - -#endif //STMC_GENERATEPRIMARIES_H - - - diff --git a/StarVMC/GeoTestMaker/StMCInitApp.cxx b/StarVMC/GeoTestMaker/StMCInitApp.cxx deleted file mode 100644 index 1b18f87887b..00000000000 --- a/StarVMC/GeoTestMaker/StMCInitApp.cxx +++ /dev/null @@ -1,99 +0,0 @@ -// $Id: StMCInitApp.cxx,v 1.3 2009/10/13 17:19:35 perev Exp $ -// -// -// Class StMCInitApp -// ------------------ -// Base class for Magnetic field calculation - -#include -#include -#include "Stiostream.h" -#include "StMCInitApp.h" -#include "TVirtualMC.h" -#include "TVirtualMCApplication.h" -#include "TROOT.h" -#include "TSystem.h" -#include "TGeoManager.h" -#include "StVMCApplication.h" -#include "TGeant3TGeo.h" -#include "StMCStack.h" -#include "StMCConstructGeometry.h" -#include "StMCSimplePrimaryGenerator.h" -#include "StMCSteppingHist.h" - -ClassImp(StMCInitApp) - -//_____________________________________________________________________________ -StMCInitApp::StMCInitApp() -{ -fNPrim = 10; -fGCode = 48; -fPt [0] = 1; fPt [1] = 1; -fEta[0] = -6; fEta[1] = 6; -fPhi[0] = -180; fPhi[1] = 180; -fZ [0] = 0; fZ [1] = 0; -fOpt = "G"; -printf("*%p = %g %g\n",fPt,fPt [0],fPt [1]); - -} -//_____________________________________________________________________________ -int StMCInitApp::Fun() -{ - StVMCApplication *app = (StVMCApplication*)TVirtualMCApplication::Instance(); - new TGeant3TGeo("C++ Interface to Geant3"); - Info("Init","TGeant3TGeo has been created."); - StMCConstructGeometry *geo = new StMCConstructGeometry(app->GetName()); - app->SetConstructGeometry(geo); - - StMCSimplePrimaryGenerator *gen = new StMCSimplePrimaryGenerator( - fNPrim, fGCode, - fPt [0] ,fPt [1], - fEta[0] ,fEta[1], - fPhi[0] ,fPhi[1], - fZ [0] ,fZ [1], fOpt); - - app->SetPrimaryGenerator(gen); - - - gMC->SetStack(new StMCStack(100)); - gMC->Init(); - gMC->BuildPhysics(); - - Info("Init","switch off physics"); - gMC->SetProcess("DCAY", 0); - gMC->SetProcess("ANNI", 0); - gMC->SetProcess("BREM", 0); - gMC->SetProcess("COMP", 0); - gMC->SetProcess("HADR", 0); - gMC->SetProcess("MUNU", 0); - gMC->SetProcess("PAIR", 0); - gMC->SetProcess("PFIS", 0); - gMC->SetProcess("PHOT", 0); - gMC->SetProcess("RAYL", 0); - gMC->SetProcess("LOSS", 4); // no fluctuations - // gMC->SetProcess("LOSS 1"); // with delta electron above dcute - gMC->SetProcess("DRAY", 0); - gMC->SetProcess("MULS", 0); - gMC->SetProcess("STRA", 0); - gMC->SetCut("CUTGAM", 1e-3 ); - gMC->SetCut("CUTELE", 1e-3 ); - gMC->SetCut("CUTHAD", .001 ); - gMC->SetCut("CUTNEU", .001 ); - gMC->SetCut("CUTMUO", .001 ); - gMC->SetCut("BCUTE", .001 ); - gMC->SetCut("BCUTM", .001 ); - gMC->SetCut("DCUTE", 1e-3 ); - gMC->SetCut("DCUTM", .001 ); - gMC->SetCut("PPCUTM", .001 ); - gMC->SetCut("TOFMAX", 50.e-6); - - return 0; -} - - - - - - - - diff --git a/StarVMC/GeoTestMaker/StMCInitApp.h b/StarVMC/GeoTestMaker/StMCInitApp.h deleted file mode 100644 index 413d141e476..00000000000 --- a/StarVMC/GeoTestMaker/StMCInitApp.h +++ /dev/null @@ -1,46 +0,0 @@ -// $Id: StMCInitApp.h,v 1.2 2009/06/07 02:28:36 perev Exp $ -// -// -// Class StMCInitApp -// ------------------ - - -#ifndef STMC_INITAPP_H -#define STMC_INITAPP_H - -#include "GCall.h" -class StMCInitApp : public GCall -{ - public: - StMCInitApp(); - virtual ~StMCInitApp(){} - // methods - int Fun(); - -// Setters - void SetNPrim(int nTrk) {fNPrim =nTrk;} - void SetGCode(int gCode) {fGCode =gCode; fOpt="G";} - void SetPDG(int pCode) {fGCode =pCode; fOpt="" ;} - void SetPt (double ptMin,double ptMax) {fPt [0]=ptMin; fPt[1] =ptMax;} - void SetEta(double etMin,double etMax) {fEta[0]=etMin; fEta[1]=etMax;} - void SetPhi(double phMin,double phMax) {fPhi[0]=phMin; fPhi[1]=phMax;} - void SetZ (double zzMin,double zzMax) {fZ [0]=zzMin; fZ [1]=zzMax;} - - - protected: - // data members - int fNPrim; - int fGCode; -double fPt[2]; -double fEta[2]; -double fPhi[2]; -double fZ[2]; -TString fOpt; - - ClassDef(StMCInitApp,0) // Extended TParticle -}; - -#endif //STMC_GENERATEPRIMARIES_H - - - diff --git a/StarVMC/GeoTestMaker/StMCPrimaryGenerator.cxx b/StarVMC/GeoTestMaker/StMCPrimaryGenerator.cxx deleted file mode 100644 index c513b958089..00000000000 --- a/StarVMC/GeoTestMaker/StMCPrimaryGenerator.cxx +++ /dev/null @@ -1,56 +0,0 @@ -// $Id: StMCPrimaryGenerator.cxx,v 1.2 2009/10/13 17:19:35 perev Exp $ -// -// -// Class StMCPrimaryGenerator -// ------------------ -// Base class for Magnetic field calculation - -#include -#include -#include -#include "StMCPrimaryGenerator.h" -#include "TVirtualMC.h" -#include "TPDGCode.h" -#include "TRandom.h" - - - -ClassImp(StMCPrimaryGenerator) - -//_____________________________________________________________________________ -StMCPrimaryGenerator::StMCPrimaryGenerator(int ntrk,int pdg) - : GCall("StMCPrimaryGenerator","") -{ - SetNTrk(ntrk); SetPDG(pdg); memset(fVtx,0,sizeof(fVtx)); -} -//_____________________________________________________________________________ -void StMCPrimaryGenerator::SetVtx(const double *vtx) -{ - for (int i=0;i<3;i++){fVtx[i]=vtx[i];} -} -//_____________________________________________________________________________ -void StMCPrimaryGenerator::SetVtx(const float *vtx) -{ - for (int i=0;i<3;i++){fVtx[i]=vtx[i];} -} - -//_____________________________________________________________________________ -void StMCPrimaryGenerator::PushTrack( - int toBeDone, int parent, int pdg - ,double px, double py, double pz,double e - ,double vx, double vy, double vz,double tof - ,double polx,double poly,double polz - ,TMCProcess mech, int& ntr, double weight, int is) -{ - TVirtualMC::GetMC()->GetStack()->PushTrack( - toBeDone,parent,pdg,px, py, pz,e ,vx, vy, vz,tof - ,polx,poly,polz, mech, ntr, weight,is); -} - - - - - - - - diff --git a/StarVMC/GeoTestMaker/StMCPrimaryGenerator.h b/StarVMC/GeoTestMaker/StMCPrimaryGenerator.h deleted file mode 100644 index d9ddc440f92..00000000000 --- a/StarVMC/GeoTestMaker/StMCPrimaryGenerator.h +++ /dev/null @@ -1,39 +0,0 @@ -// $Id: StMCPrimaryGenerator.h,v 1.1 2009/03/25 23:15:10 perev Exp $ -// -// -// Class StMCPrimaryGenerator -// ------------------ - - -#ifndef STAR_StMCPrimaryGenerator_H -#define STAR_StMCPrimaryGenerator_H - -#include "GCall.h" -#include "TVirtualMCStack.h" -class StMCPrimaryGenerator : public GCall -{ - public: - StMCPrimaryGenerator(int ntrk=1,int pdg=0); - virtual ~StMCPrimaryGenerator(){} - // methods - void SetNTrk(int ntrk) {fNTrk=ntrk;} - void SetPDG (int pdg ) {fPDG =pdg ;} - void SetVtx (const double *vtx ); - void SetVtx (const float *vtx ); - void PushTrack(int toBeDone, int parent, int pdg - ,double px, double py, double pz,double e - ,double vx, double vy, double vz,double tof - ,double polx,double poly,double polz - ,TMCProcess mech, int& ntr, double weight, int is); - protected: - // data members - int fNTrk; - int fPDG; - double fVtx[3]; - ClassDef(StMCPrimaryGenerator,0) // Extended TParticle -}; - -#endif //STAR_StMCPrimaryGenerator_H - - - diff --git a/StarVMC/GeoTestMaker/StMCSimplePrimaryGenerator.cxx b/StarVMC/GeoTestMaker/StMCSimplePrimaryGenerator.cxx deleted file mode 100644 index e1bb4969ca5..00000000000 --- a/StarVMC/GeoTestMaker/StMCSimplePrimaryGenerator.cxx +++ /dev/null @@ -1,99 +0,0 @@ -// $Id: StMCSimplePrimaryGenerator.cxx,v 1.4 2012/06/11 16:17:42 fisyak Exp $ -#include -#include -#include "Riostream.h" -#include "StMCSimplePrimaryGenerator.h" -#include "TString.h" -#include "TDatabasePDG.h" -#include "TRandom.h" -#include "TMath.h" -using namespace std; -ClassImp(StMCSimplePrimaryGenerator); -//_____________________________________________________________________________ - StMCSimplePrimaryGenerator::StMCSimplePrimaryGenerator( - int nprim, int Id, - double pT_min, double pT_max, - double Eta_min, double Eta_max, - double Phi_min, double Phi_max, - double Z_min, double Z_max, const char *option) - :StMCPrimaryGenerator() -{ - SetGenerator( nprim ,Id, - pT_min ,pT_max, - Eta_min ,Eta_max, - Phi_min ,Phi_max, - Z_min ,Z_max , option); -} - -//_____________________________________________________________________________ -void StMCSimplePrimaryGenerator::SetGenerator(int nprim, int Id, - double pT_min,double pT_max, - double Eta_min, double Eta_max, - double Phi_min, double Phi_max, - double Z_min, double Z_max, const Char_t *option) { - fNTrk = nprim; fPDG = Id; - fpT_min = pT_min; - fpT_max = pT_max; - fEta_min = Eta_min; - fEta_max = Eta_max; - fPhi_min = Phi_min; - fPhi_max = Phi_max; - fZ_min = Z_min; - fZ_max = Z_max; - TString opt(option); - if (! opt.CompareTo("G",TString::kIgnoreCase)) fPDG = TDatabasePDG::Instance()->ConvertGeant3ToPdg(fPDG); - cout << "Generate " << fNTrk << " primary tracks of type " << fPDG << endl; - cout << fpT_min << " < pT < " << fpT_max << endl; - cout << fEta_min << " < eta < " << fEta_max << endl; - cout << fPhi_min<< " < phi < " << fPhi_max<< endl; - cout << fZ_min << " < zVer< " << fZ_max << endl; -} -//_____________________________________________________________________________ -void StMCSimplePrimaryGenerator::GenerateOnePrimary() { - // Add one primary particle to the user stack (derived from TVirtualMCStack). - // Track ID (filled by stack) - int ntr; - - // Option: to be tracked - int toBeDone = 1; - - // Particle type - int pdg = fPDG; - - // Polarization - double polx = 0.; - double poly = 0.; - double polz = 0.; - - // Position - double tof = 0.; - - // Energy (in GeV) - double pT = fpT_min + (fpT_max - fpT_min )*gRandom->Rndm(); - double eta = fEta_min + (fEta_max - fEta_min)*gRandom->Rndm(); - double phi = fPhi_min + (fPhi_max - fPhi_min)*gRandom->Rndm(); - phi *= M_PI/180; - - // Particle momentum - double px, py, pz; - px = pT*TMath::Cos(phi); - py = pT*TMath::Sin(phi); - pz = pT*TMath::SinH(eta); - // double kinEnergy = 0.050; - double mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass(); - if (mass<=0.) mass = 1e-8; - double e = TMath::Sqrt(mass*mass + pz*pz + pT*pT); - // Add particle to stack - assert(e>1e-6); - PushTrack(toBeDone, -1, pdg, px, py, pz, e - ,fVtx[0], fVtx[1],fVtx[2] - ,tof , polx ,poly, polz, - kPPrimary, ntr, 1., 0); -} -//_____________________________________________________________________________ -int StMCSimplePrimaryGenerator::Fun() { - - fVtx[2]=(fZ_min + (fZ_max-fZ_min)*gRandom->Rndm()); - for (int i=0; i -#include -#include "StMCStack.h" -#include -#include -#include - -class myTParticle : public TParticle { - public: -myTParticle(Int_t pdg, Int_t status, Int_t mother1, Int_t mother2 - ,Int_t daughter1, Int_t daughter2 - ,Double_t px, Double_t py, Double_t pz - ,Double_t etot, Double_t vx, Double_t vy, Double_t vz - ,Double_t time) - :TParticle(pdg,status,mother1,mother2,daughter1, daughter2 - ,px,py,pz,etot,vx,vy,vz,time) - { fId=0;} - -~myTParticle(); - - int GetId() const {return fId;} - void SetId(int id) {fId = id ;} - void SetMother(myTParticle* particle) { fMother=particle;} - void AddDaughter(myTParticle* particle) { fDaughters.push_back(particle);} -//void Print(const Option_t *opt=0) const; - myTParticle* GetMother() const { return fMother;} - Int_t GetNDaughters() const { return fDaughters.size();} - myTParticle* GetDaughter(Int_t i) const; - - private: - // data members - int fId; - myTParticle *fMother; - std::vector fDaughters; -}; - -//_____________________________________________________________________________ -myTParticle* myTParticle::GetDaughter(Int_t i) const -{ - if (i < 0 || i >= (int)fDaughters.size()) - Fatal("GetDaughter", "Index out of range"); - return fDaughters[i]; -} - -//_____________________________________________________________________________ -myTParticle::~myTParticle() -{ - int n = fDaughters.size(); - for (int i=0;iSetPolarisation(polx, poly, polz); - particle->SetWeight(weight); - particle->SetUniqueID(mech); - - myTParticle* mother = 0; - int ID = GetNtrack(); - if (parent>=0 && toBeDone && mech != kPPrimary) { - mother = (myTParticle*)GetParticle(parent); - ID = mother->GetId(); - particle->SetId(ID); particle->SetMother(mother); - mother->AddDaughter(particle); - } - else { - particle->SetId(ID); - fParticles.push_back(particle); - } - if (mech == kPPrimary) fNPrimary++; - if (toBeDone) fStack.push(particle); -} -//_____________________________________________________________________________ -TParticle* StMCStack::PopNextTrack(int& itrack) { -// Gets next particle for tracking from the stack. -// --- - - fCurrentTrack = -1; - fCurrentParticle = 0; - itrack = fCurrentTrack; - if (fStack.empty()) return 0; - - fCurrentParticle = fStack.top(); - fStack.pop(); - - if (!fCurrentParticle) return 0; - - itrack = fCurrentParticle->GetId(); - fCurrentTrack = itrack; - - return fCurrentParticle; -} -//_____________________________________________________________________________ -void StMCStack::Print(const Option_t *opt) const { -// Print(const Option_t *opt=0)s info for all particles. -// --- - - printf("*** StMCStack Info ***\n"); - printf("Total number of particles: %d\n",GetNtrack()); - printf("Number of primary particles: %d\n",GetNprimary()); - for (int i=0; iPrint(); - } -} -//_____________________________________________________________________________ -void StMCStack::Clear(const char *) -{ - // Deletes contained particles, resets particles array and stack. - // --- - - // reset fStack should be empty by this time - assert(fStack.empty()); - fCurrentTrack = -1; - fNPrimary = 0; - for( int i=0; i<(int)fParticles.size();i++) {delete fParticles[i];} - fParticles.clear(); -} -//_____________________________________________________________________________ -TParticle* StMCStack::GetCurrentTrack() const -{ -// Gets the current track particle. -// --- - return GetParticle(fCurrentTrack); -} - -//_____________________________________________________________________________ -int StMCStack::GetCurrentParentTrackNumber() const -{ -// Returns the current track parent ID. -// --- - - myTParticle* current = GetParticle(fCurrentTrack); - - if (!current) return -1; - - myTParticle* mother = current->GetMother(); - - if (!mother) return -1; - - return mother->GetId(); -} - -//_____________________________________________________________________________ -myTParticle* StMCStack::GetParticle(int id) const -{ -// Returns id-th particle in fParticles. - if (id < 0 || id >= (int)fParticles.size()) - Fatal("GetParticle", "Index out of range"); - return fParticles[id]; -} - - diff --git a/StarVMC/GeoTestMaker/StMCStack.h b/StarVMC/GeoTestMaker/StMCStack.h deleted file mode 100644 index 761ee8feab6..00000000000 --- a/StarVMC/GeoTestMaker/StMCStack.h +++ /dev/null @@ -1,68 +0,0 @@ -// $Id: StMCStack.h,v 1.2 2010/04/29 03:05:28 perev Exp $ -// $Log: StMCStack.h,v $ -// Revision 1.2 2010/04/29 03:05:28 perev -// CleanUp -// -// Revision 1.1 2009/03/25 23:15:10 perev -// New VMC maker -// -// Revision 1.3 2005/06/09 20:13:47 fisyak -// It looks like that all hits in place (calorimeters have to be check for volumeid) -// -// Revision 1.2 2005/05/03 15:42:14 fisyak -// Adjust for bfc -// -// Revision 1.1 2005/04/25 20:44:28 fisyak -// StarVMCApplication with example in macros/starVMC.C -// - -#ifndef StMC_STACK_H -#define StMC_STACK_H - -#include "TVirtualMCStack.h" -#include "TObjArray.h" -#include - -class myTParticle; -class TParticle; - -class StMCStack : public TVirtualMCStack { -public: - StMCStack(int size = 0); - virtual ~StMCStack(); - - // methods - virtual void PushTrack(int toBeDone, int parent, int pdg, - double px, double py, double pz, double e, - double vx, double vy, double vz, double tof, - double polx, double poly, double polz, - TMCProcess mech, int& ntr,double weight, - int is) ; - virtual TParticle* PopNextTrack(int& track); - virtual TParticle* PopPrimaryForTracking(int i); - void Print(const char* opt=0) const; - void Clear(const char* opt=0); - private: - - virtual void SetCurrentTrack(int track) {fCurrentTrack = track;} - virtual int GetNtrack() const {return fParticles.size();} - virtual int GetNprimary() const {return fNPrimary;} - virtual TParticle* GetCurrentTrack() const; - virtual int GetCurrentTrackNumber() const {return fCurrentTrack;} - virtual int GetCurrentTrackId() const {return GetCurrentTrackNumber()+1;} - virtual int GetCurrentParentTrackNumber()const; - myTParticle* GetParticle(int id) const; - myTParticle* GetCurrentParticle() {return fCurrentParticle;} - private: - // data members - std::stack fStack; //! - std::vector fParticles; - int fCurrentTrack; - int fNPrimary; - myTParticle* fCurrentParticle; - ClassDef(StMCStack,0) // StMCStack -}; - -#endif - - diff --git a/StarVMC/GeoTestMaker/StMCStepping.cxx b/StarVMC/GeoTestMaker/StMCStepping.cxx deleted file mode 100644 index 1ec9c63c800..00000000000 --- a/StarVMC/GeoTestMaker/StMCStepping.cxx +++ /dev/null @@ -1,336 +0,0 @@ -// $Id: StMCStepping.cxx,v 1.10 2014/08/20 02:31:58 perev Exp $ -// -// -// Class StMCStepping -// ------------------ - -#include -#include -#include -#include "StMCStepping.h" -#include "TPDGCode.h" -#include "TVirtualMC.h" -#include "TGeoManager.h" -#include "TGeoNode.h" -#include "TGeoVolume.h" -#include "TGeoMedium.h" -#include "TGeant3.h" - -static TVirtualMC *myMC=0; - -ClassImp(StMCStepping) -int SteppingCasesI[] = { - StMCStepping::kNewTrack , - StMCStepping::kTrackAlive, - StMCStepping::kTrackDisappeared, - StMCStepping::kTrackEntering, - StMCStepping::kTrackExiting, - StMCStepping::kTrackInside, - StMCStepping::kTrackOut, - StMCStepping::kTrackStop, - 0}; - -const char *SteppingCasesC[] = { - "NewTrack", - "TrackAlive", - "TrackDisappeared", - "TrackEntering", - "TrackExiting", - "TrackInside", - "TrackOut", - "TrackStop", - 0}; - -int SteppingKazesI[] = { - StMCStepping::kNEWtrack, - StMCStepping::kENTERtrack, - StMCStepping::kCONTINUEtrack, - StMCStepping::kEXITtrack, - StMCStepping::kENDEDtrack, - StMCStepping::kOUTtrack, - StMCStepping::kIgnore, - 0}; - -const char *SteppingKazesC[] = { - "NEWtrack", - "ENTERtrack", - "CONTINUEtrack", - "EXITtrack", - "ENDEDtrack", - "OUTtrack", - "Ignore", - 0}; - -class MyAux -{ -public: -float fLen,fP,fEdep; -}; - -static std::vector gAux; - -//_____________________________________________________________________________ -StMCStepping::StMCStepping(const char *name,const char *tit) - : GCall(name,tit) -{ - memset(fBeg,0,fEnd-fBeg+1); - fKazePrev = -1; - myMC = 0; - fDir = 1; -} -//_____________________________________________________________________________ -void StMCStepping::Print(const Option_t*) const -{ - double lenTot = 0,eTot=0; - for (int i=0;i<(int)gAux.size();i++) { - MyAux &M = gAux[i]; - eTot+=M.fEdep; - double T = sqrt(M.fP*M.fP+fMass*fMass)-fMass; - T = (fDir)? T+M.fEdep: T-M.fEdep; - printf("%6.3f eTot=%g T=%g dL=%g dE=%g dEdX=%g\n" - ,lenTot,eTot,T,M.fLen,M.fEdep,M.fEdep/(M.fLen+1e-11)); - lenTot += M.fLen; - } - printf(" totLen=%g totE=%g\n",lenTot,eTot); - - - -} -//_____________________________________________________________________________ -TString StMCStepping::CaseAsString(int kase) -{ - TString ts; - for (int i=0;SteppingCasesI[i];i++) - { - if (!(kase&SteppingCasesI[i])) continue; - if (ts.Length()) ts +="&"; - ts += SteppingCasesC[i]; - } - return ts; -} -//_____________________________________________________________________________ -TString StMCStepping::KazeAsString(int kase) -{ - TString ts; - for (int i=0;SteppingKazesI[i];i++) - { - if (!(kase&SteppingKazesI[i])) continue; - if (ts.Length()) ts +="&"; - ts += SteppingKazesC[i]; - } - return ts; -} - - -//_____________________________________________________________________________ -void StMCStepping::Case() -{ -static int nCall = 0; nCall++; - fSteps++; - fNode = gGeoManager->GetCurrentNode(); - fVolume = fNode->GetVolume(); - fMedium = fVolume->GetMedium(); - fMaterial = fMedium->GetMaterial(); - fX0 = fMaterial->GetRadLen(); - myMC = gMC; - fCase = 0; - if(myMC->IsNewTrack ()) fCase |= kNewTrack; -//if(myMC->TrackLength() == 0 ) fCase |= kNewTrack; -//if(myMC->IsTrackAlive ()) fCase |= kTrackAlive; - if(myMC->IsTrackDisappeared ()) fCase |= kTrackDisappeared; - if(myMC->IsTrackEntering ()) fCase |= kTrackEntering; - if(myMC->IsTrackExiting ()) fCase |= kTrackExiting; - if(myMC->IsTrackInside ()) fCase |= kTrackInside; - if(myMC->IsTrackOut ()) fCase |= kTrackOut; - if(myMC->IsTrackStop ()) fCase |= kTrackStop; - - fKaze=0; - if(!fKaze && fCase&kNewTrack) fKaze = kNEWtrack; - if(!fKaze && fCase&kTrackEntering) fKaze = kENTERtrack; - if(!fKaze && fCase&kTrackInside) fKaze = kCONTINUEtrack; - if( fCase&kTrackExiting) fKaze = kEXITtrack; - if( fCase&kTrackStop) fKaze = kENDEDtrack; - if( fCase&kTrackDisappeared) fKaze = kENDEDtrack; - if( fCase&kTrackOut) fKaze = kOUTtrack; - int kaze = fKaze; -// if(fKazePrev==fKaze && fKaze !=kCONTINUEtrack) fKaze= kIgnore; - fKazePrev=kaze; -//vp fCasName = CaseAsString(fCase); -//vp fKazName = KazeAsString(fKaze); - - myMC->TrackPosition(fCurrentPosition); - myMC->TrackMomentum(fCurrentMomentum); - assert(fCurrentMomentum[3]>1e-6); - fCurrentLength = myMC->TrackLength(); - fCharge = myMC->TrackCharge(); - fMass = myMC->TrackMass(); - fEtot = myMC->Etot(); - - switch (fKaze) { - - case kNEWtrack: - fSteps=0; - fTrackNumber++; - fStartPosition = fCurrentPosition; - fStartMomentum = fCurrentMomentum; - gAux.clear(); - case kENTERtrack:; - { - fEnterPosition = fCurrentPosition; - fEnterMomentum = fCurrentMomentum; - fEnterLength = fCurrentLength; - fEdep = 0; - break;} - - case kCONTINUEtrack:; - case kEXITtrack:; - case kOUTtrack: - fEdep = myMC->Edep(); - fEtot = myMC->Etot(); - RecovEloss(); - myMC->TrackPosition(fCurrentPosition); - myMC->TrackMomentum(fCurrentMomentum); - break; - - case kENDEDtrack: - break; - - case kIgnore:; - assert(0 && "Ignore case??"); - break; - - default: - Error("Case","Unexpected case %d == %s",fKaze,fCasName.Data()); - assert(0); - } - fPrevLength = fCurrentLength; - fPrevPosition = fCurrentPosition; - fPrevMomentum = fCurrentMomentum; -} -//_____________________________________________________________________________ -int StMCStepping::Fun() -{ - Case(); - switch (fCase) { - case kNewTrack|kTrackEntering:; - case kNewTrack:; - fPrevLength =0; - case kTrackEntering:; - printf("\n\nStepping %s\n",fCasName.Data()); - printf("Vol= %s Mat=%s Med=%s\n" - ,fVolume->GetName() - ,fMaterial->GetName() - ,fMedium->GetName()); -// printf("Track %s\t Mass(%d) = %g Pos= %g %g %g Mom=%g %g %g\n" -// ,fParName.Data(),fPDG,fMass -// ,fCurrentPosition[0],fCurrentPosition[1],fCurrentPosition[2] -// ,fCurrentMomentum[0],fCurrentMomentum[1],fCurrentMomentum[2]); - - break; - - case kTrackInside|kTrackDisappeared: - case kTrackInside|kTrackStop: - case kTrackDisappeared: - case kTrackExiting: - case kTrackInside: - case kTrackOut: - case kTrackStop: - case kTrackDisappeared|kTrackOut: - printf("Continue %s\n",fCasName.Data()); - printf("Track dLen= %g Pos= %g %g %g Mom=%g %g %g\n" - ,fCurrentLength-fEnterLength - ,fCurrentPosition[0],fCurrentPosition[1],fCurrentPosition[2] - ,fCurrentMomentum[0],fCurrentMomentum[1],fCurrentMomentum[2]); - break; - - default: - Error("Case","Unexpected case %x == %s",fCase,fCasName.Data()); - assert(0); - } - return 0; -} -//_____________________________________________________________________________ -void StMCStepping::RecovEloss() -{ -// Update directly Geant3 common when we moving bacward the track -// and energy loss is negative - - -static int nCall = 0; nCall++; -static int debu = 0; - enum {kX=0,kY,kZ,kDx,kDy,kDz,kP}; - -static Gctrak_t *gGctrak=((TGeant3*)TVirtualMC::GetMC())->Gctrak(); -static float *vect = gGctrak->vect; -static Float_t &getot = gGctrak->getot; -static Float_t &gekin = gGctrak->gekin; - - - do { -// if (fEdep=0); - if (dLgekin); - ((TGeant3*)gMC)->Gekbin(); - vect[kP] = sqrt(gekin*(getot+fMass)); - - } while(0); - myMC->TrackPosition(fCurrentPosition); - myMC->TrackMomentum(fCurrentMomentum); - gAux.back().fP=fCurrentMomentum.P(); - -///??????????????????????????????????? - if (fEdep -#include -#include -#include -#include "TROOT.h" -#include "TColor.h" -#include "TVirtualMC.h" -#include "StMCStepping2Hist.h" -#include "StTGeoProxy.h" -#include "TObjArray.h" -#include "TNamed.h" -#include "TH1F.h" -#include "THStack.h" - -#include "TGeoManager.h" -#include "TGeoVolume.h" -#include "TGeoShape.h" -#include "TGeoBBox.h" -#include "TGeoTube.h" -#include "TProfile.h" -#include "TProfile2D.h" -#include "TLegend.h" -#include "TStyle.h" -#include "TCanvas.h" -#include "TSystem.h" -#include "StTProfile2D.h" -#include "StiELossTrk.h" - -void Break(int ii) { -static int myII=-1946; -if (ii != myII) return; -printf ("Break %d\n",ii); -} - -StMCStepping2Hist *StMCStepping2Hist::fThis=0; - -static TH1D *Convert(const TProfile *tp,const char *suff="th1d") -{ - int nx = tp->GetXaxis()->GetNbins(); - double xl = tp->GetXaxis()->GetXmin(); - double xu = tp->GetXaxis()->GetXmax(); - - TString ts(tp->GetName());ts += "_"; ts+=suff; - TH1D *hh = new TH1D(ts,tp->GetTitle(),nx,xl,xu); - double ents=0; - for (int i=1;i<=nx;i++) { - double cont = tp->GetBinContent(i); - hh->SetBinContent(i, cont); - ents += cont; - } - hh->SetEntries(ents); - hh->SetFillColor(tp->GetFillColor()); - return hh; -} - -//_____________________________________________________________________________ -class My2Hist -{ -enum {kMAXNODE=1000,kMAXMODU=20}; -public: -class Node_t { -public: -TString name; -double radL; -double ort2; -double rxy; -double z; -double len; -double mcs[3]; - int ihit; - -}; - -private: -class From_t { -public: - From_t(){ ort2=0;radL=0;nTims=0;} - -public: -TString name; -double radL; -double ort2; -int nTims; -}; - -class Modu_t { -public: -Modu_t() {memset(mybeg,0,myend-mybeg+1);} -From_t *GetFrom(const char *name); -void Add2From(const char *name,double radl,double ort2); -public: -TString name; -char mybeg[1]; -double radL; -double ort2; -double rMax; -double zMax; -int ihit; -int kolo; -TProfile *prof[4]; -int nfrom; -char myend[1]; -From_t from[kMAXMODU]; -}; - -public: - My2Hist(const char *tit); -const char *GetName() const {return mName.Data();} -void SetEta(double eta){ mEta = eta;} -Node_t &AddNode(); - - -void Fill(double rxy0,double rxy1,double z0,double z1,double radL); -void Update(); -void Paint(); -void Save(); -void PrintFrom(); -Modu_t &GetModu(const TString &name); -void Clear(); -void PadClean(TPad *pad); - -private: -char mFist[1]; -int mNModu; //number of modules used -int mNNode; //number of nodees used -int mNBins; //number of bins in profile -double mLimt[2];//limits of profile -double mEta; - - -THStack *mStk[3][2]; -TCanvas *mC[3][2],*mC2,*mCt; -TLegend *mL[3][2],*mL2; - -StTProfile2D *mP2; -TH1D *mHt; -double mDelta2Z; -double mDelta2R; -char mLast[1]; - -Node_t mNode[kMAXNODE]; -Modu_t mModu[kMAXMODU]; -TString mName; //Name - -}; - -//_____________________________________________________________________________ -My2Hist::From_t *My2Hist::Modu_t::GetFrom(const char *name) -{ - int i; - for (i=0;inTims++; - fr->radL +=radl; - fr->ort2 +=ort2; -} -//_____________________________________________________________________________ -My2Hist::My2Hist(const char *tit) -{ - gStyle->SetPalette(1); - if (!gROOT->GetColor(1000)) new TColor(1000,1,1,1); - - - memset(mFist,0,mLast-mFist); - mNBins = 60; - mLimt[0]= -6; - mLimt[1]= 6; - mName = tit; - TString ts("P2_");ts+=mName; ts+="_ZR"; - double zLow=-2000,zUpp=2000; - double rLow=0 ,rUpp=500; - int nZ=400,nR=250; - mDelta2Z = (zUpp-zLow)/nZ; - mDelta2R = (rUpp-rLow)/nR; - mP2 = new StTProfile2D(ts,"invX0(Z,Rxy)",nZ,zLow,zUpp,nR,rLow,rUpp); - mHt = new TH1D("OldStar","TrackLen(Rxy)",100,1./200,1./60); -} - -//_____________________________________________________________________________ -My2Hist::Node_t &My2Hist::AddNode() -{ - return mNode[mNNode++]; -} -//_____________________________________________________________________________ -void My2Hist::Fill(double r0,double r1,double z0,double z1,double radL) -{ - if (radL <=0.) radL = 3e33; - double dR = r1-r0,dZ = z1 - z0; - double Delta2R = (dR<0) ? -mDelta2R:mDelta2R; - double Delta2Z = (dZ<0) ? -mDelta2Z:mDelta2Z; - double tau,dau; - double dQ = sqrt(dR*dR+dZ*dZ); - double rA=r0,zA=z0; - while(1) { - double rB = int((rA+Delta2R)/mDelta2R)*mDelta2R; - tau = (r1-rA)/dR; - dau = (rB-rA)/dR; - if (tau>dau) tau = dau; - - double zB = int((zA+Delta2Z)/mDelta2Z)*mDelta2Z; - dau = (z1 -zA)/dZ; - if (tau>dau) tau = dau; - dau = (zB -zA)/dZ; - if (tau>dau) tau = dau; - if (tau<1e-6) break; - rB = rA + dR*tau; - zB = zA + dZ*tau; - double dL = dQ*tau; - mP2->Fill(0.5*(zA+zB),0.5*(rA+rB),1./radL,dL); - if (fabs(z0) <200 && fabs(z1) <200 && r1<200) { mHt->Fill(1/(0.5*(rA+rB)),dL);} - rA = rB; zA = zB; - } - -} -//_____________________________________________________________________________ -void My2Hist::Update() -{ - if (!mNNode) return; - int idxLst; - for (idxLst=mNNode-1;idxLst>=0;idxLst--) {if(mNode[idxLst].ihit) break;} - if (idxLst<0) {mNNode=0; Clear(); return;} - - TString ts(mNode[idxLst].name); - for (;idxLst>=0;idxLst--) {if(mNode[idxLst].name!=ts) break;} - if (idxLst<0) {mNNode=0; Clear(); return;} - - - for (int idx=0;idx<=idxLst;idx++) { - Modu_t &modu = GetModu(mNode[idx].name); - modu.radL += mNode[idx].radL; - assert(modu.radL<100); - modu.ihit += mNode[idx].ihit; - if (modu.rMax< mNode[idx].rxy) modu.rMax = mNode[idx].rxy; - if (modu.zMax< mNode[idx].z ) modu.zMax = mNode[idx].z ; - } - - for (int idx=0;idxFill(mEta,mModu[idx].radL); - } - - TString prevName("****"); - for (int ihi=0;ihiFill(mEta,radL[1]); - hitm.prof[2]->Fill(mEta,sqrt(ort2[1])); - } } - - Clear(); - -} - -//_____________________________________________________________________________ -void My2Hist::Paint() -{ - enum {nKols=12}; -// Magenta= red anilin (sirenevyj) -// Cian = light blue (goluboj) -// Spring = light green -// Teal = Blue Green -// Sort by aver rxy - Modu_t swap; - - do { swap.prof[0]=0; - for (int i=1;i= mModu[i-1].rMax) continue; - swap = mModu[i]; mModu[i]=mModu[i-1]; mModu[i-1]=swap; - } - } while(swap.prof[0]); - - for (int i=0,kol=-1;iGetEntries(); - int nEnt1 = (int)mModu[i].prof[1]->GetEntries(); - if (nEnt0+nEnt1<=0) continue; - kol++; - mModu[i].kolo = gStyle->GetColorPalette((kol*23)); - const char *cens = (mModu[i].ihit)? "*":" "; - printf (" Modu=%s%s \tRxy=%g \tradL=%g \tEnt=%d/%d \tColor=%d\n" - ,(const char*)mModu[i].name,cens - ,mModu[i].rMax - ,mModu[i].prof[0]->GetMaximum() - ,nEnt0,nEnt1 - ,mModu[i].kolo - ); - } -static const char *ParaName[3]={"RadL" ,"RadL","Ort"}; -static const char *SmallBig[2]={"Small","Big" }; -static const char *FromInto[3]={"ThisToAll" ,"AllToThis","AllToThis"}; -static const double myMax[3]={ 3 ,3 , 3 }; - for (int jk=0;jk<3; jk++) { - - for (int sb=0;sb<2; sb++) { - TString namS("HS_"); namS+=ParaName[jk];namS+=SmallBig[sb]; namS+=FromInto[jk]; - TString namH(namS); namH.Replace(1,1,"1"); - TString tit(SmallBig[sb]); tit+=" "; tit+=ParaName[jk]; - tit+="(Eta) contribution "; tit+=FromInto[jk]; - THStack *ths = new THStack(namS,tit); - TLegend *tl = new TLegend(0.6,0.6,0.9,0.9); - mL[jk][sb] = tl; - tl->SetFillStyle(4050); - mStk[jk][sb] = ths; - for (int ih = 0;ihGetEntries()) continue; - if ((sb) != (mModu[ih].prof[jk]->GetMaximum()>myMax[jk])) continue; - // assert(kolSetFillColor(mModu[ih].kolo); - ths->Add(Convert(mModu[ih].prof[jk],namH)); - tl->AddEntry(mModu[ih].prof[jk],"","f"); - }// end ih - if (!ths->GetHists()) continue; - TString ts("C_"); ts+=mName; ts+=ParaName[jk]; - ts+=SmallBig[sb] ; ts +=FromInto[jk]; - - mC[jk][sb] = new TCanvas(ts,tit,600,800); - ths->Draw(); tl->Draw(); - mC[jk][sb]->Update(); - - }//end sb - }//end jk - - mP2->SupressZeros(1e-5); - TString ts("C_"); ts+=mName; ts+="_ZR"; - mCt = new TCanvas("OldStar","TrakLen(Rxy)" ,600,800); - mHt->Draw(); - mCt->Modified(); mCt->Update(); - - mC2 = new TCanvas(ts ,"invX0(Z,Rxy)" ,600,800); - mC2->Divide(1,3); - mC2->cd(1); mP2->Draw("colz"); - ts="P_"; ts+=mName; ts+="_Z"; - TProfile *pz = mP2->ProfileX(ts,1,-1); - pz->SetFillStyle(3026); - pz->SetLineColor(2); - pz->SetLineWidth(3); - - ts="P_"; ts+=mName; ts+="_R"; - TProfile *pr = mP2->ProfileY(ts,1,-1); - pr->SetFillStyle(3026); - pr->SetLineColor(2); - pr->SetLineWidth(3); - - mC2->cd(2); pz->Draw(""); - mC2->cd(3); pr->Draw(""); - - mC2->Modified(); mC2->Update(); -} -//_____________________________________________________________________________ -void My2Hist::Save() -{ - for (int i=0;i<7;i++) { - if(!mC[0][i]) continue; - mC[0][i]->Update(); - mC[0][i]->Print(".png"); - PadClean(mC[0][i]); - mC[0][i]->Print(".C"); - if (i>5) continue; - } -} -//_____________________________________________________________________________ -My2Hist::Modu_t &My2Hist::GetModu(const TString &name) -{ -static int idx = -1; - if (idx>=0 && name == mModu[idx].name) return mModu[idx]; - -//search by name - for (idx=0; idx < mNModu ; idx++) {if (name==mModu[idx].name) break;} - - if (idx==mNModu) { - mModu[mNModu].name = name; - TString ts(name); ts+="_"; - mModu[mNModu].prof[0] = new TProfile(name,name,mNBins,mLimt[0],mLimt[1]); - ts+="_"; - mModu[mNModu].prof[1] = new TProfile(ts ,name,mNBins,mLimt[0],mLimt[1]); - ts+="_"; - mModu[mNModu].prof[2] = new TProfile(ts ,name,mNBins,mLimt[0],mLimt[1]); - mNModu++; assert(mNModu<100); - } - return mModu[idx]; -} -//_____________________________________________________________________________ -void My2Hist::Clear() -{ - mNNode = 0; - for (int idx=0;idxGetListOfPrimitives(); - if (!tl) return; - TObject *to; - TObjLink *lnkNex = tl->FirstLink(),*lnk=0; - while (lnkNex) { - lnk = lnkNex; lnkNex = lnk->Next(); - to = lnk->GetObject(); if (!to) continue; - if (to->InheritsFrom(TPad::Class())) { PadClean((TPad*)to); continue;} - if (to->InheritsFrom(TH1F::Class())) { tl->Remove(lnk);/* delete to;*/} - } - -} -//_____________________________________________________________________________ -void My2Hist::PrintFrom() -{ -#define QWE(x) (int(x*1000)/1000.) - TString ts(GetName()); ts+=".tab"; - FILE *ftab = fopen(ts.Data(),"w"); - assert (ftab); - - - fprintf(ftab,"\n\n PrintFrom() %s contributions\n\n",GetName()); - - for (int im=0;imSetPalette(1); - assert(!fThis); - memset(fFist,0,fLast-fFist); - TString tsName(GetName()); - int yf = tsName.Contains(".DEV2"); - tsName = gSystem->BaseName(tsName.Data()); - tsName.ReplaceAll(".C",""); - tsName.ReplaceAll("Geometry.",""); - if (yf) tsName += "yf"; - fThis = this; - fMy2Hist = new My2Hist(tsName); - fELossTrk[0] = new StiELossTrk; - fELossTrk[1] = new StiELossTrk; -} -//_____________________________________________________________________________ -StMCStepping2Hist::~StMCStepping2Hist() -{ - fThis=0; -} -//_____________________________________________________________________________ -void StMCStepping2Hist::Print(const Option_t*) const -{ - StTGeoProxy::Instance()->Print(KazeAsString(fKaze)); - printf("RadLen=%g fCurrentLength=%g Rxy=%g Z=%g\n\n" - , fTotRadL,fCurrentLength,fCurrentPosition.Perp(),fCurrentPosition.Z()); -} -//_____________________________________________________________________________ -int StMCStepping2Hist::Fun() -{ -static int nCall = 0; -nCall++; - -if (!fHitShape) fHitShape = StTGeoProxy::Instance()->GetHitShape(); - - const TGeoVolume *modu = 0; TString ts,modName; - Case(); -// Sensitive volume - - if (fSensMaxZ < fabs(fCurrentPosition.Z())) fSensMaxZ = fabs(fCurrentPosition.Z()); - if (fSensMaxR < fCurrentPosition.Perp() ) fSensMaxR = fCurrentPosition.Perp(); -// - - assert(fCurrentLength< 10000); - assert(fEnterLength < 10000); - -// StTGeoProxy::Instance()->Print(KazeAsString(fKaze)); -// printf("fEnterLength=%g fCurrentLength=%g Rxy=%g Z=%g\n\n" -// , fEnterLength, fCurrentLength,fCurrentPosition.Perp(),fCurrentPosition.Z()); -SWITCH: int myKaze = fKaze; -if (GetDebug()) {printf("%d - ",nCall); Print();} -if (strcmp(fVolume->GetName(),"TPAD")==0) Break(1); - - - switch (fKaze) { - case kNEWtrack:; - fELossTrk[0]->Reset(); - fMy2Hist->Update(); - fTotRadL=0; - fModName=""; - - case kENTERtrack:; - if (strcmp(fVolume->GetName(),"HALL")==0) fKaze=kENDEDtrack; - if (fHitShape->Outside(fCurrentPosition.Z(),fCurrentPosition.Perp())) - fKaze=kENDEDtrack; - break; - - case kCONTINUEtrack: - case kIgnore: - break; - - case kOUTtrack: - case kENDEDtrack: - fMy2Hist->Update(); - TVirtualMC::GetMC()->StopTrack(); - break; - - case kEXITtrack: - { - fVolHits = (StTGeoProxy::Instance()->IsSensitive(fVolume))? 1:0; - if (fX0<=0) break; - double dL = fCurrentLength-fEnterLength; - fVolRadL = fabs(dL)/fX0; - fTotRadL += fVolRadL; -//?? assert(fTotRadL<100); - modu = StTGeoProxy::Instance()->GetModu(); - fModName = (modu)? modu->GetName(): "CAVE"; - fModName = Alias(fModName); - fELossTrk[0]->Add(dL,fX0); - fELossTrk[1]->Reset();; - fELossTrk[1]->Add(dL,fX0); - fTotOrt2 = fELossTrk[0]->GetOrt2(); - FillHist(1); - - } - break; - - default: - Error("Case","Unexpected case %x == %s",fCase,fCasName.Data()); - assert(0); - } - if (fKaze!=myKaze) goto SWITCH; - - return 0; -} - -//_____________________________________________________________________________ -void StMCStepping2Hist::Finish(const char *) -{ - printf("\nMaxSensVolu: Rxy=%g aZ=%g\n\n",fSensMaxR,fSensMaxZ); - - - fMy2Hist->Paint(); - fMy2Hist->Save(); - fMy2Hist->PrintFrom(); -} - -//_____________________________________________________________________________ -void StMCStepping2Hist::FillHist(int flag) -{ - - switch(flag) { - - case 0: break; - - case 1: - { - double r1 = fEnterPosition.Perp(); - double r2 = fCurrentPosition.Perp(); - double eta = fCurrentMomentum.Eta(); - double phi = fCurrentMomentum.Phi()/M_PI*180; if(phi){} - double z1 = fEnterPosition[2]; - double z2 = fCurrentPosition[2]; - - fMy2Hist->SetEta(eta); - My2Hist::Node_t &node = fMy2Hist->AddNode(); - node.name = fModName; - node.len = fEnterLength; - node.radL =fVolRadL; - node.z =z2; - node.ort2 =fTotOrt2; - node.rxy =r2; - node.ihit =fVolHits; - fELossTrk[1]->GetCoef(node.mcs); - fMy2Hist->Fill(r1,r2,z1,z2,fX0); - break; - } - } - -} -//_____________________________________________________________________________ -const char *StMCStepping2Hist::Alias(const char *modu) -{ - const char *inp[] = {"IBSH","IBSG","IBSF","IBSE","IBSD" - ,"IBSC","IBCC","IBAC","IBSB","IBSA" - ,"IBEM" - ,"FTMO" - ,"FBOX","FBO1","FBO2",0}; - - const char *out[] = {"VPDD","VPDD","VPDD","VPDD","VPDD" - ,"VPDD","VPDD","VPDD","VPDD","VPDD" - ,"VPDD" - ,"FTPC" - ,"FPDM","FPDM","FPDM",0}; - - for (int i=0;inp[i];i++) { - if (strcmp(modu,inp[i])==0) return out[i]; - } - return modu; -} diff --git a/StarVMC/GeoTestMaker/StMCStepping2Hist.h b/StarVMC/GeoTestMaker/StMCStepping2Hist.h deleted file mode 100644 index aad0037a1c2..00000000000 --- a/StarVMC/GeoTestMaker/StMCStepping2Hist.h +++ /dev/null @@ -1,57 +0,0 @@ -// $Id: StMCStepping2Hist.h,v 1.3 2013/04/20 21:54:07 perev Exp $ -// -// -// Class StMCStepping2Hist -// ------------------ - - -#ifndef STMC_STEPPING2HIST_H -#define STMC_STEPPING2HIST_H - -#include "TString.h" -#include "TArrayF.h" -#include "TLorentzVector.h" -#include "StMCStepping.h" - -class StTGeoProxy; -class StTGeoHitShape; -class My2Hist; -class StiELossTrk; - -class StMCStepping2Hist : public StMCStepping -{ -public: - StMCStepping2Hist(const char *name="",const char *tit=""); -virtual ~StMCStepping2Hist(); - // methods -virtual int Fun(); -virtual void Print (const Option_t* opt=0) const; -virtual void Finish(const Option_t* opt=0); -static StMCStepping2Hist *Instance() {return fThis;} -private: -static const char *Alias(const char *modu); -void FillHist(int flag); -protected: -char fFist[1]; -double fSensMaxR; -double fSensMaxZ; -double fTotRadL; -double fTotOrt2; -double fVolRadL; - int fVolHits; - - StiELossTrk *fELossTrk[2]; - My2Hist *fMy2Hist; -const StTGeoHitShape *fHitShape ; -char fLast[1]; -TString fModName; - -private: -void FillHist(); - -static StMCStepping2Hist *fThis; - -ClassDef(StMCStepping2Hist,0) // -}; -#endif //STMC_STEPPING2HIST_H - diff --git a/StarVMC/GeoTestMaker/StMCSteppingHist.cxx b/StarVMC/GeoTestMaker/StMCSteppingHist.cxx deleted file mode 100644 index c9699ebe31f..00000000000 --- a/StarVMC/GeoTestMaker/StMCSteppingHist.cxx +++ /dev/null @@ -1,413 +0,0 @@ -// $Id: StMCSteppingHist.cxx,v 1.3 2009/10/13 17:19:35 perev Exp $ -// -// -// Class StMCSteppingHist -// ------------------ -// Base class for Magnetic field calculation - -#include -#include -#include -#include -#include "StMCSteppingHist.h" -#include "TObjArray.h" -#include "TNamed.h" -#include "TH1F.h" - -#include "TGeoManager.h" -#include "TGeoVolume.h" -#include "TGeoShape.h" -#include "TGeoBBox.h" -#include "TGeoTube.h" -#include "TProfile.h" -#include "TProfile2D.h" -#include "StTProfile2D.h" -#include "TStyle.h" -#include "TCanvas.h" -#include "TSystem.h" - -#include "StarRoot/TH1Helper.h" - -StMCSteppingHist *StMCSteppingHist::fThis=0; -int Kount[10]={0,0,0,0,0,0,0,0,0,0}; -double hMin[4] = {99,99,99,99}; -double hMax[4] = {0}; -class MyHolder : public TNamed -{ -public: - MyHolder(const char *name,const char *tit):TNamed(name,tit) - {memset(&fEps,0,(char*)&fLast-(char*)&fEps);} - - double fEps; - double fEpz; - int fEnt; - int fTot; - double fS[2]; - double fSA[2]; - double fSR[2]; - - TH1F *fH[2]; - int fLast; -}; - - - -ClassImp(StMCSteppingHist) - -//_____________________________________________________________________________ -StMCSteppingHist::StMCSteppingHist(const char *name,const char *tit) - : StMCStepping(name,tit) -{ - gStyle->SetPalette(1); - assert(!fThis); - memset(&fFist,0,&fLast-&fFist); - TString tsName(GetName()); - int yf = tsName.Contains(".DEV2"); - tsName = gSystem->BaseName(tsName.Data()); - tsName.ReplaceAll(".C",""); - tsName.ReplaceAll("Geometry.",""); - if (yf) tsName += "yf"; - fThis = this; - fVols = new TObjArray(); - fMats = new TObjArray(); - const char *hNam[]= {"Star_dRadL_1","Star_dRadL_2","Star_dRadL_3" - ,"Tpce_dRadL_1","Tpce_dRadL_2","Tpce_dRadL_3" - ,"Star__RadL_1","Star__RadL_2","Star__RadL_3" - ,"Tpce__RadL_1","Tpce__RadL_2","Tpce__RadL_3",0}; - - const char *hTit[]= {"STAR dRadL(eta,rxy)" - ,"STAR dRadL(phi,rxy)" - ,"STAR dRadL(phi,eta)" - ,"TPC dRadL(eta,rxy)" - ,"TPC dRadL(phi,rxy)" - ,"TPC dRadL(phi,eta)" - ,"STAR RadL(eta,rxy)" - ,"STAR RadL(phi,rxy)" - ,"STAR RadL(phi,eta)" - ,"TPC RadL(eta,rxy)" - ,"TPC RadL(phi,rxy)" - ,"TPC RadL(phi,eta)",0}; - -const double hPar[][6]= {{60, 0, 3, 110,0,220} - ,{30,-15,15, 110,0,220} - ,{30,-15,15, 60,0, 3} - ,{60, 0, 3, 110,0,220} - ,{30,-15,15, 110,0,220} - ,{30,-15,15, 60,0, 3} - ,{60, 0, 3, 110,0,220} - ,{30,-15,15, 110,0,220} - ,{30,-15,15, 60,0, 3} - ,{60, 0, 3, 110,0,220} - ,{30,-15,15, 110,0,220} - ,{30,-15,15, 60,0, 3}}; - - rStep = int(hPar[0][5]/hPar[0][3]+0.0001); - - for (int i=0;hNam[i];i++) { - TString tsn(tsName); tsn+="_"; tsn+=hNam[i]; - TString tst(tsName); tst+=":"; tst+=hTit[i]; - - mH[i] = new StTProfile2D(tsn.Data(),tst.Data() - ,(int)hPar[i][0],hPar[i][1],hPar[i][2] - ,(int)hPar[i][3],hPar[i][4],hPar[i][5]); - mC[i] = new TCanvas(tsn.Data(),tst.Data(),600,800); - mC[i]->Divide(1,3); - mC[i]->cd(1); gPad->SetLogz();mH[i]->Draw("colZ"); - } - - - -} -//_____________________________________________________________________________ -StMCSteppingHist::~StMCSteppingHist() -{ - fVols ->Delete(); delete fVols; fVols =0; - fMats ->Delete(); delete fMats; fMats =0; - fThis=0; -} -//_____________________________________________________________________________ -void StMCSteppingHist::Print(const Option_t*) const -{ - fVols->ls(); - fMats->ls(); -} -//_____________________________________________________________________________ -int StMCSteppingHist::Fun() -{ - Case(); - assert(fCurrentLength< 10000); - assert(fEnterLength < 10000); - switch (fKaze) { - case kNEWtrack:; - FillVolMat(); - mRadL=0; - case kENTERtrack:; - TestTGeo(); - break; - - case kCONTINUEtrack: - case kOUTtrack: - case kIgnore: - break; - - case kEXITtrack: - case kENDEDtrack: - { - SummArr(); - FillHist(); - } - break; - - default: - Error("Case","Unexpected case %x == %s",fCase,fCasName.Data()); - assert(0); - } - return 0; -} -//_____________________________________________________________________________ -void StMCSteppingHist::Fill(TObjArray *arr) -{ - - MyHolder *mh = 0; - int n = arr->GetSize(); - for (int idx=1;idxAt(idx); - if (!mh) continue; - if (!mh->fS[0]) continue; - mh->fEnt++; - for (int j=0;j<2;j++) { - double val = mh->fS[j]; - mh->fS[j]=0; - mh->fSA[j]+=val; - mh->fSR[j]+=(val*val); - } - } -} -//_____________________________________________________________________________ -void StMCSteppingHist::Sort(TObjArray *arr) -{ - arr->Compress(); - arr->Sort(); - int n = arr->GetSize(); - for (int i=0;iAt(i+0); - if (!t0) break; - TNamed *t1=(TNamed*)arr->At(i+1); - if (!t1) break; - const char *n0 = t0->GetName(); - const char *n1 = t1->GetName(); - if (*n0 != *n1) continue; - int l0 = strcspn(n0,"#"); - int l1 = strcspn(n1,"#"); - if (l0!=l1) continue; - if (strncmp(n0,n1,l0)) continue; - TString ts(n0);ts.Insert(l0,"_"); - t0->SetName(ts.Data()); - } - arr->Sort(); -} - -//_____________________________________________________________________________ -void StMCSteppingHist::SummArr() -{ - for (int iarr=0;iarr<2;iarr++) { - TObjArray *arr = (&fVols)[iarr]; - - int n = arr->GetSize(); - int id = ((iarr==0)? fVolume->GetNumber():fMaterial->GetIndex()); - MyHolder *mh=0; - if (id < n) mh = (MyHolder*)arr->At(id); - if (!mh) { - TString ts = (!iarr)? fVolume->GetName():fMedium->GetName(); - ts+="#"; ts+=id; - mh = new MyHolder(ts.Data(),fMedium->GetName()); - for (int i=0;i<2;i++) { - TH1F *h = new TH1F(ts.Data(), "", 100, 0., 1.); - TH1Helper::SetCanRebin(h); - h->SetDirectory(0); - mh->fH[i] = h; - } - arr->AddAtAndExpand(mh,id); - } - mh->fTot++; - double eps = fPrevEps+fMedium->GetParam(kEpsil); - mh->fEps+=eps; - double cl=fCurrentLength; - double el=fEnterLength; - double s = cl-el; - double sz = s*(cl*cl+cl*el+el*el); - mh->fEpz += 3.*(cl*cl*fMedium->GetParam(kEpsil)+el*el*fPrevEps); - mh->fS[0] += s; - mh->fS[1] += sz; - }//end of for - fPrevEps = fMedium->GetParam(kEpsil); -} - -//_____________________________________________________________________________ -void StMCSteppingHist::FillVolMat() -{ - Fill(fVols); - Fill(fMats); - fPrevEps=0; -} - -//_____________________________________________________________________________ -void StMCSteppingHist::Finish(const char *opt) -{ -// *** MinMax[0] = 1.01188e-08 82.2315 -// *** MinMax[1] = 1.01188e-08 1.38347 -// *** MinMax[2] = 6.65619e-06 269.674 -// *** MinMax[3] = 0.00645718 10.036 -// Print(opt); - - for (int i=0;i<4;i++) { - printf (" *** MinMax[%d] = %g %g\n",i,hMin[i],hMax[i]); - } - - double myMin[4]={1e-6,1e-6,5e-6,5e-3}; - double myMax[4]={1e+2,5e+0,1e+2,1e+1}; - TString ts; - int idx; - for (int i=0;mH[i];i++) { - mH[i]->SetMinimum(myMin[i/3]); - mH[i]->SetMaximum(myMax[i/3]); - TProfile *hx = mH[i]->ProfileX(); - ts = hx->GetTitle(); - idx = ts.Index(","); - ts.Replace(idx,4,""); - hx->SetTitle(ts); - TProfile *hy = mH[i]->ProfileY(); - ts = hy->GetTitle(); - idx = ts.Index(","); - ts.Replace(idx-3,4,""); - hy->SetTitle(ts); - mC[i]->cd(2);hx->Draw("logy"); - mC[i]->cd(3);hy->Draw("logy"); - mC[i]->Modified(); mC[i]->Update(); - } - -#if 0 - static const char* ext[]={".volu",".mate",0}; - FillVolMat(); - Sort(fVols); - Sort(fMats); - for (int iar=0;iar<2; iar++) { - TObjArray *arr = (&fVols)[iar]; - TString file(GetName()); file +="MCStep"; file += ext[iar]; - - FILE *f = fopen(file.Data(),"w"); - - int n = arr->GetSize(); - for (int i=0; iAt(i); - if(!mh) continue; - int nent = mh->fEnt; - if (nent<10) continue; - double aver = mh->fSA[0]/nent; - double rms = (mh->fSR[0]/nent-aver*aver); - rms = sqrt(rms/(nent-1)); - double eps = mh->fEps/nent; - rms = rms + eps; - double fak = (nent/fTrackNumber)*(4./3)*3.141592; - eps = mh->fEpz/nent; - double sz = mh->fSA[1]/nent; - double sze = mh->fSR[1]/nent-sz*sz; - sz = (sz*fak); - sze = (sqrt(sze/(nent-1))+eps)*fak; - sz /= 1000.; sze /=1000.; - fprintf(f,"%20s.%s \tnent=%d \taver=%g +- %g \tsize= %g +- %g\n" - ,mh->GetName(),GetName(),nent,aver,rms,sz,sze); - } - } -#endif //0 -// printf("Kount[0-2] = %d %d %d\n",Kount[0],Kount[1],Kount[2]); - - while(!gSystem->ProcessEvents()){}; - for (int i=0;mC[i];i++) {mC[i]->Print(".C");} - for (int i=0;mC[i];i++) {mC[i]->Print(".png");} - -} - -//_____________________________________________________________________________ -void StMCSteppingHist::TestTGeo() -{ -#if 0 - double par[9]; - if (!gGeoManager) return; - TGeoVolume *gv = gGeoManager->GetCurrentVolume(); - assert(gv); - assert(fVolName == gv->GetName()); - if (fMatName != "TPCE_SENSITIVE_GAS") return; - - TGeoShape *sh = gv->GetShape(); - if (strcmp("TGeoTube",sh->GetName())== 0) { - TGeoTube *tube = (TGeoTube *)sh; - par[0] = tube->GetRmin(); - par[1] = tube->GetRmax(); - par[2] = tube->GetDz();} - - else if (strcmp("TGeoBBox",sh->GetName())== 0) { - TGeoBBox *bbox = (TGeoBBox *)sh; - par[0] = bbox->GetDX(); - par[1] = bbox->GetDY(); - par[2] = bbox->GetDZ(); - } else { return;} - - printf("TestTGeo: %s::%s %g %g %g\n",gv->GetName(),sh->GetName(),par[0],par[1],par[2]); -#endif //0 -} -//_____________________________________________________________________________ -void StMCSteppingHist::FillHist() -{ - int inTPC=0; - for (int i=1;1;i++) { - TGeoNode *n = gGeoManager->GetMother(i); - if(!n) break; - TGeoVolume *v=n->GetVolume(); - if (!v) continue; - if (strcmp(v->GetName(),"TPCE")) continue; - inTPC=1; break; - } - - double r1 = fEnterPosition.Perp(); - double r2 = fCurrentPosition.Perp(); - double eta = fCurrentMomentum.Eta(); - double phi = fCurrentMomentum.Phi()/M_PI*180; -// printf("vol=%s.%s radL=%g\n",fVolume->GetName(),fMaterial->GetName(),fMaterial->GetRadLen()); - double radl = fMaterial->GetRadLen(); if (radl<=0) return; - radl = fabs(fCurrentLength-fEnterLength)/radl; - for (int iDet=0;iDet<=inTPC*3; iDet+=3) { - double jl = r1,jr; - while(1) { - jr=int(jl+rStep); if (jr >r2) jr=r2; - double dr = jr-jl; - double myRadLen = radl*dr/(r2-r1); - assert(myRadLen>=0); - mH[iDet+0]->Fill(eta,jr ,myRadLen); - mH[iDet+1]->Fill(phi,jr ,myRadLen); - mH[iDet+2]->Fill(phi,eta,myRadLen); - - mRadL += 0.5*myRadLen; - mH[iDet+6]->Fill(eta,jr ,mRadL); - mH[iDet+7]->Fill(phi,jr ,mRadL); - mH[iDet+8]->Fill(phi,eta,mRadL); - mRadL += 0.5*myRadLen; - if (myRadLen > 1e-8) { - int jDet = iDet/3; - if (hMin[jDet]>myRadLen) hMin[jDet]=myRadLen; - if (hMax[jDet]mRadL) hMin[jDet]=mRadL; - if (hMax[jDet]=r2) break; - } - } -} - - - - - - diff --git a/StarVMC/GeoTestMaker/StMCSteppingHist.h b/StarVMC/GeoTestMaker/StMCSteppingHist.h deleted file mode 100644 index 08c0577def5..00000000000 --- a/StarVMC/GeoTestMaker/StMCSteppingHist.h +++ /dev/null @@ -1,52 +0,0 @@ -// $Id: StMCSteppingHist.h,v 1.1 2009/03/25 23:15:11 perev Exp $ -// -// -// Class StMCSteppingHist -// ------------------ - - -#ifndef STMC_STEPPINGHIST_H -#define STMC_STEPPINGHIST_H - -#include "TString.h" -#include "TArrayF.h" -#include "TLorentzVector.h" -#include "StMCStepping.h" -class TProfile2D; -class TCanvas; -class TObjArray; -class StMCSteppingHist : public StMCStepping -{ -public: - StMCSteppingHist(const char *name="",const char *tit=""); -virtual ~StMCSteppingHist(); - // methods -virtual int Fun(); -virtual void Print (const Option_t* opt=0) const; -virtual void Finish(const Option_t* opt=0); -static StMCSteppingHist *Instance() {return fThis;} -void TestTGeo(); -protected: -char fFist; -TObjArray *fVols; -TObjArray *fMats; -double fPrevEps; -TProfile2D *mH[20]; -TCanvas *mC[20]; -int rStep; -double mRadL; -char fLast; -private: -void Fill(TObjArray *arr); -void Sort(TObjArray *arr); -void SummArr(); -void FillVolMat(); -void FillHist(); - -static StMCSteppingHist *fThis; - -ClassDef(StMCSteppingHist,0) // -}; - -#endif //STMC_STEPPINGHIST_H - diff --git a/StarVMC/GeoTestMaker/StStepping.cxx.C b/StarVMC/GeoTestMaker/StStepping.cxx.C deleted file mode 100644 index 5f35761e018..00000000000 --- a/StarVMC/GeoTestMaker/StStepping.cxx.C +++ /dev/null @@ -1,408 +0,0 @@ -#include -#include -#include "Stiostream.h" -#include "StarVMCApplication.h" -#include "StarMCHits.h" -#include "TGeoManager.h" -#include "TGeant3TGeo.h" -#if ROOT_VERSION_CODE < 331013 -#include "TCL.h" -#else -#include "TCernLib.h" -#endif -#include "TDataSetIter.h" -#include "TPDGCode.h" -#include "TVirtualMC.h" -#include "TArrayI.h" -#include "TObjArray.h" -#include "TObjString.h" -#include "TClass.h" -#include "TROOT.h" -#include "TRandom.h" -#include "TLorentzVector.h" -#include "TFile.h" -#ifdef __ROOT__ -#include "StMaker.h" -#endif -#include "St_g2t_Chair.h" -#include "tables/St_g2t_event_Table.h" -#include "tables/St_g2t_pythia_Table.h" -#include "tables/St_g2t_track_Table.h" -#include "tables/St_g2t_vertex_Table.h" -#include "tables/St_particle_Table.h" -//#include "tables/St_g2t_run_Table.h" -#include "tables/St_g2t_gepart_Table.h" -#include "StEnumerations.h" -StarMCHits *StarMCHits::fgInstance = 0; -ClassImp(StarMCHits); -struct Detector_G2T_t { - StDetectorId kType; - Char_t *Name; - Char_t *G2T_type; - Char_t *G2T_name; - Char_t *G2T_sys; - Char_t *G2T_geom; -}; -static const Detector_G2T_t g2t[] = { - // type(cd) name sys geom version - { kTofId, "BCSB","g2t_ctf_hit","g2t_tof_hit","BTOF","btof_btog"}, // ++ - { kTofId, "BRSG","g2t_ctf_hit","g2t_tfr_hit","BTOF","btof_btog"}, // ++ - { kCtbId, "BXSA","g2t_ctf_hit","g2t_ctb_hit","BTOF","btof_btog"}, // ++ - { kUnknownId, "BPOL","g2t_ctf_hit","g2t_bbc_hit","BBCM","" }, // ++ - { kBarrelEmcPreShowerId,"CSDA","g2t_emc_hit","g2t_smd_hit","CALB","" }, // + - { kBarrelEmcTowerId, "CSUP","g2t_emc_hit","g2t_emc_hit","CALB","" }, // + - { kEndcapEmcPreShowerId,"EHMS","g2t_emc_hit","g2t_esm_hit","ECAL","ecal_emcg"}, // + - { kUnknownId, "ELGR","g2t_emc_hit","g2t_eem_hit","ECAL","" }, // + - { kUnknownId, "EPCT","g2t_emc_hit","g2t_eem_hit","ECAL","" }, // + - { kEndcapEmcTowerId, "ESCI","g2t_emc_hit","g2t_eem_hit","ECAL","ecal_emcg"}, // + - { kEndcapEmcPreShowerId,"EXSE","g2t_emc_hit","g2t_esm_hit","ECAL","" }, // + - { kFgtId, "FGSC","g2t_fgt_hit","g2t_fgt_hit","FGTD","" }, // + - { kUnknownId, "FHMS","g2t_emc_hit","g2t_fpd_hit","FPDH","" }, - { kUnknownId, "FLGR","g2t_emc_hit","g2t_fpd_hit","FPDH","" }, - { kUnknownId, "FPCT","g2t_emc_hit","g2t_fpd_hit","FPDH","" }, - { kUnknownId, "FSCI","g2t_emc_hit","g2t_fpd_hit","FPDH","" }, - { kUnknownId, "FREO","g2t_rch_hit","g2t_rch_hit","RICH","" }, // + - { kFtpcWestId, "FSEC","g2t_ftp_hit","g2t_ftp_hit","FTPC","ftpc_ftpg"}, // + - { kIstId, "IBSS","g2t_ist_hit","g2t_ist_hit","ISTB","" }, // + - { kUnknownId, "OQUA","g2t_rch_hit","g2t_rch_hit","RICH","" }, - { kPxlId, "PLAC","g2t_pix_hit","g2t_pix_hit","PIXL","" }, // + - { kPhmdId, "PDGS","g2t_pmd_hit","g2t_pmd_hit","PHMD","" }, // + - { kZdcWestId, "QSCI","g2t_emc_hit","g2t_zdc_hit","ZCAL","" }, // + - { kUnknownId, "QUAR","g2t_rch_hit","g2t_rch_hit","RICH","" }, // + - { kUnknownId, "RCSI","g2t_rch_hit","g2t_rch_hit","RICH","" }, // + - { kUnknownId, "RGAP","g2t_rch_hit","g2t_rch_hit","RICH","" }, // + - { kSsdId, "SFSD","g2t_svt_hit","g2t_ssd_hit","SISD","" }, // ++ - { kSvtId, "SVTD","g2t_svt_hit","g2t_svt_hit","SVTT","svtt_svtg"}, // ++ - { kSvtId, "svtd","g2t_svt_hit","g2t_svt_hit","SVTT","svtt_svtg"}, // ++ - { kMwpcWestId, "TMSE","g2t_mwc_hit","g2t_mwc_hit","TPCE","" }, // ++ - { kTpcId, "TPAD","g2t_tpc_hit","g2t_tpc_hit","TPCE","tpce_tpcg"}, // ++ - { kTpcId, "tpad","g2t_tpc_hit","g2t_tpc_hit","TPCE","tpce_tpcg"}, // ++ - { kUnknownId, "VRAD","g2t_vpd_hit","g2t_vpd_hit","VPDD","vpdd_vpdg"} // + -}; -static const Int_t No_g2t = sizeof(g2t)/sizeof(Detector_G2T_t); -//________________________________________________________________________________ -StarMCHits::StarMCHits(const Char_t *name,const Char_t *title) : - TDataSet(name,title), fDetectors(0), fDetList(0), - fVolUserInfo(0), fCurrentDetector(0), fDebug(0), fSeed(0), fEventNumber(0) -{ - fgInstance = this; fHitHolder = this; -} -//________________________________________________________________________________ -Int_t StarMCHits::Init() { - cout << "StarMCHits::Init() -I- Get Detectors" <GetDataBase("VmcGeometry/Index"); - assert(fDetectors); - // Make list of detector elements - TDataSetIter next( fDetectors , 99); - TDataSet *set = 0; - if (fDetList) delete fDetList; - fDetList = new THashList(100,0); - Int_t N = 0; - while ((set = next())) { - StarVMCDetector *det = dynamic_cast(set); - if (! det ) continue; - if (TString(det->GetName()) == "FPCT") continue; // ignore fpd - if (TString(det->GetName()) == "BRSG") continue; // ignore tfr - fDetList->Add(det); - N++; - } - fDetList->Rehash(N); - cout << "StarMCHits::Init() -I- Get Volume Info" << endl; - // TObjArray *UniqueVolumes = gGeoManager->GetListOfUVolumes(); - TObjArray *Volumes = gGeoManager->GetListOfUVolumes(); - Int_t Nids = Volumes->GetEntriesFast(); - if (! fVolUserInfo ) fVolUserInfo = new TObjArray(256); - for (Int_t i = 0; i < Nids; i++) { - TGeoVolume *vol = (TGeoVolume *) Volumes->At(i); - if (! vol) continue; - Int_t uid = vol->GetNumber(); -#if 0 - cout << "Volume:\t" << i << "\t" << vol->GetName() << "\t" << vol->GetTitle() << "\t" << uid; -#endif - TString title(vol->GetName(),4); - TObject *det = fDetList->FindObject(title.Data()); -#if 0 - if (det) cout << "\tDetector: " << det->GetName();// << "\t" << det->GetTitle(); -#endif - fVolUserInfo->AddAtAndExpand(det,uid); -#if 0 - cout << endl; -#endif - } - return 0; -} -//________________________________________________________________________________ -void StarMCHits::Step() { - // static Int_t Idevt0 = -1; - static Double_t Gold = 0; -#if 0 - if (Debug() && gMC->IsA()->InheritsFrom("TGeant3TGeo")) { - TGeant3TGeo *geant3 = (TGeant3TGeo *)gMC; - geant3->Gdebug(); - } -#endif - // cout << "Call StarMCHits::Step" << endl; - TGeoNode *nodeT = gGeoManager->GetCurrentNode(); - assert(nodeT); - TGeoVolume *volT = nodeT->GetVolume(); - assert(volT); - const TGeoMedium *med = volT->GetMedium(); - /* fParams[0] = isvol; - fParams[1] = ifield; - fParams[2] = fieldm; - fParams[3] = tmaxfd; - fParams[4] = stemax; - fParams[5] = deemax; - fParams[6] = epsil; - fParams[7] = stmin; */ - Int_t Isvol = (Int_t) med->GetParam(0); - fCurrentDetector = 0; - if (Isvol <= 0) return; - fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); - if (! fCurrentDetector) { - volT = nodeT->GetMotherVolume(); - fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); - if (! fCurrentDetector) { - TString path(gGeoManager->GetPath()); - TObjArray *obj = path.Tokenize("_/"); - Int_t N = obj->GetEntries(); - for (Int_t i = N-2; i >= 0; i -= 2) { - TObjString *o = (TObjString *) obj->At(i); - const Char_t *name = o->GetName(); - volT = gGeoManager->GetVolume(name); - assert (volT); - fCurrentDetector = (StarVMCDetector *) fVolUserInfo->At(volT->GetNumber()); - if (fCurrentDetector) break; - } - delete obj; - } - } - if (Isvol && ! fCurrentDetector && Debug()) { - cout << "Active medium:" << med->GetName() << "\t for volume " << volT->GetName() - << " has no detector description" << endl; - } - // Int_t Idevt = gMC->CurrentEvent(); - gMC->TrackPosition(fHit.Current.Global.xyzT); - gMC->TrackMomentum(fHit.Current.Global.pxyzE); - TGeoHMatrix *matrixC = gGeoManager->GetCurrentMatrix(); - fHit.Current.Global2Local(matrixC); - if (gMC->IsTrackEntering()) { - fHit.Detector= fCurrentDetector; - fHit.Entry = fHit.Current; - fHit.Sleng = gMC->TrackLength(); - fHit.Charge = (Int_t) gMC->TrackCharge(); - fHit.Mass = gMC->TrackMass(); - fHit.AdEstep = fHit.AStep = 0; - return; - } - Double_t GeKin = fHit.Current.Global.pxyzE.E() - fHit.Mass; - fHit.Sleng = gMC->TrackLength(); - if (fHit.Sleng == 0.) Gold = GeKin; - Double_t dEstep = gMC->Edep(); - Double_t Step = gMC->TrackStep(); - fHit.iPart = gMC->TrackPid(); - fHit.iTrack = StarVMCApplication::Instance()->GetStack()->GetCurrentTrackId(); // GetCurrentTrackNumber() + 1 to be consistent with g2t - // - - - - - - - - - - - - - energy correction - - - - - - - - - - - if (gMC->IsTrackStop() && TMath::Abs(fHit.iPart) == kElectron) { - TArrayI proc; - Int_t Nproc = gMC->StepProcesses(proc); - Int_t Mec = 0; - for (Int_t i = 0; i < Nproc; i++) if (proc[i] == kPAnnihilation || proc[i] == kPStop) Mec = proc[i]; - Int_t Ngkine = gMC->NSecondaries(); - if (fHit.iPart == kElectron && Ngkine == 0 && Mec == kPStop) dEstep = Gold; - else { - if (fHit.iPart == kPositron && Ngkine < 2 && Mec == kPAnnihilation) { - dEstep = Gold + 2*fHit.Mass; - if (Ngkine == 1) { - TLorentzVector x; - TLorentzVector p; - Int_t IpartSec; - gMC->GetSecondary(0,IpartSec,x,p); - dEstep -= p.E(); - } - } - } - } - // - - - - - - - - - - - - - - - - user - - - - - - - - - - - - - - - - // user step - // - - - - - - - - - - - - - - - sensitive - - - - - - - - - - - - - - fHit.AdEstep += dEstep; - fHit.AStep += Step; - if (fHit.AdEstep == 0) return; - if (! gMC->IsTrackExiting() && ! gMC->IsTrackStop()) return; - fHit.Exit = fHit.Current; - fHit.Middle = fHit.Entry; - fHit.Middle += fHit.Exit; - fHit.Middle *= 0.5; - if (! fCurrentDetector) return; - fHit.VolumeId = fCurrentDetector->GetVolumeId(gGeoManager->GetPath()); - FillG2Table(); -} -//________________________________________________________________________________ -void StarMCHits::FillG2Table() { - St_g2t_Chair *chair = fCurrentDetector->GetChair(); - assert(chair); - chair->Fill(fHit); -} -//________________________________________________________________________________ -void StarMCHits::FinishEvent() { - static const Double_t pEMax = 1 - 1.e-10; - TDataSet *m_DataSet = StarMCHits::instance()->GetHitHolder(); - if (! m_DataSet) return; - St_g2t_event *g2t_event = new St_g2t_event("g2t_event",1); - m_DataSet->Add(g2t_event); - g2t_event_st event; - memset (&event, 0, sizeof(g2t_event_st)); - fEventNumber++; - event.n_event = fEventNumber;//IHEAD(2) - event.ge_rndm[0] = fSeed;//IHEAD(3) - event.ge_rndm[1] = 0;//IHEAD(4) - event.n_run = 1; - event.n_track_eg_fs = StarVMCApplication::Instance()->GetStack()->GetNtrack(); - event.n_track_prim = StarVMCApplication::Instance()->GetStack()->GetNprimary(); - event.prim_vertex_p = 1; - event.b_impact = 99; - event.phi_impact = 0.5; - g2t_event->AddAt(&event); - Int_t NoVertex = 1; - St_g2t_vertex *g2t_vertex = new St_g2t_vertex("g2t_vertex",NoVertex); - m_DataSet->Add(g2t_vertex); - g2t_vertex_st vertex; - Int_t NTracks = StarVMCApplication::Instance()->GetStack()->GetNtrack(); - St_g2t_track *g2t_track = new St_g2t_track ("g2t_track",NTracks); - m_DataSet->Add(g2t_track); - g2t_track_st track; - StarMCParticle *particle = 0; - Int_t iv = 0; - TLorentzVector oldV(0,0,0,0); - TLorentzVector newV(0,0,0,0); - TLorentzVector devV(0,0,0,0); - for (Int_t it = 0; it GetStack()->GetParticle(it); - TParticle *part = (TParticle *) particle->GetParticle(); - part->ProductionVertex(newV); - devV = newV - oldV; - if (iv == 0 || devV.Mag() > 1.e-7) { - if (iv > 0) g2t_vertex->AddAt(&vertex); - memset (&vertex, 0, sizeof(g2t_vertex_st)); - iv++; - vertex.id = iv ;// primary key - vertex.event_p = 0 ;// pointer to event - vertex.eg_label = 0 ;// generator label (0 if GEANT) - vertex.eg_tof = 0 ;// vertex production time - vertex.eg_proc = 0 ;// event generator mechanism - memcpy(vertex.ge_volume," ",4); ;// GEANT volume name - vertex.ge_medium = 0 ;// GEANT Medium - vertex.ge_tof = 0 ;// GEANT vertex production time - vertex.ge_proc = 0 ;// GEANT mechanism (0 if eg) - vertex.ge_x[0] = newV.X() ;// GEANT vertex coordinate - vertex.ge_x[1] = newV.Y() ; - vertex.ge_x[2] = newV.Z() ; - vertex.ge_tof = newV.T() ; - vertex.n_parent = 0 ;// number of parent tracks - vertex.parent_p = 0 ;// first parent track - vertex.is_itrmd = 0 ;// flags intermediate vertex - vertex.next_itrmd_p = 0 ;// next intermedate vertex - vertex.next_prim_v_p= 0 ;// next primary vertex - oldV = newV; - } - vertex.n_daughter++; - track.id = it+1; - track.eg_label = particle->GetIdGen(); - track.eg_pid = part->GetPdgCode(); - track.ge_pid = gMC->IdFromPDG(track.eg_pid); - track.start_vertex_p = iv; - track.p[0] = part->Px(); - track.p[1] = part->Py(); - track.p[2] = part->Pz(); - track.ptot = part->P(); - track.e = part->Energy(); - track.charge = part->GetPDG()->Charge()/3; - Double_t ratio = part->Pz()/part->Energy(); - ratio = TMath::Min(1.-1e-10,TMath::Max(-1.+1e-10, ratio)); - track.rapidity = TMath::ATanH(ratio); - track.pt = part->Pt(); - ratio = part->Pz()/part->P(); - ratio = TMath::Min(pEMax,TMath::Max(-pEMax, ratio)); - track.eta = TMath::ATanH(ratio); - g2t_track->AddAt(&track); - } - g2t_vertex->AddAt(&vertex); -} -//________________________________________________________________________________ -void StarMCHits::Clear(const Option_t* opt) { - TObjArrayIter next(fVolUserInfo); - StarVMCDetector *desc = 0; - while ((desc = (StarVMCDetector *) next())) { desc->Clear(); } - if (gRandom) fSeed = gRandom->GetSeed(); -} -//_____________________________________________________________________________ -void StarMCHits::MakeDetectorDescriptors() { - if (! gGeoManager) { - cout << "No gGeoManager" << endl; - return; - } - TDataSet *Detectors = StMaker::GetChain()->GetDataBase("VmcGeometry/Index"); - if (! Detectors) { - cout << "No Detectors found in VmcGeometry/Index" << endl; - } - // Make List of sensitive volumes - TObjArray *vols = gGeoManager->GetListOfVolumes(); - Int_t nvol = vols->GetEntriesFast(); - Int_t nSensVol = 0; - Int_t nsize = 100; - TArrayI Indx(nsize); Int_t *indx = Indx.GetArray(); - for (Int_t i = 0; i < nvol; i++) { - TGeoVolume *vol = (TGeoVolume *) vols->At(i); - if (! vol) continue; - TGeoMedium *med = vol->GetMedium(); - if (! med) continue; - Int_t isvol = (Int_t) med->GetParam(0); - if (! isvol) continue; - indx[nSensVol] = i; - nSensVol++; - if (nSensVol >= nsize) { - nsize *= 2; - Indx.Set(nsize); - indx = Indx.GetArray(); - } - TString Path(MakeDetectorDescriptor(vol->GetName())); - if (Detectors) { - // Check consistency - StarVMCDetector *det = (StarVMCDetector *) Detectors->Find(vol->GetName()); - if (! det) { - cout << "Detector description for " << vol->GetName() << "\t" << vol->GetTitle() << " is missing" << endl; - } else { - TString FMT = det->GetFMT(); - cout << "Found path:\t" << Path.Data() << endl; - cout << "Set path:\t" << FMT.Data(); - if (Path == FMT) cout << " are the same" << endl; - else cout << " are the different" << endl; - } - } - - } -} -//_____________________________________________________________________________ -const Char_t *StarMCHits::MakeDetectorDescriptor(const Char_t *det) { - enum Limits {nlvMAX=15,nskMAX=20,nvMAX=20}; - static TString path; - return path.Data(); -} -//________________________________________________________________________________ -void StarMCHits::SetDebug(Int_t m) { - if (fDebug == m) return; - fDebug = m; - if (gMC && gMC->IsA()->InheritsFrom("TGeant3TGeo")) { - TGeant3TGeo *geant3 = (TGeant3TGeo *)gMC; - Gcflag_t* cflag = geant3->Gcflag(); - cflag->idebug = Debug(); - cflag->idemax = 10000; - cflag->iswit[0] = 2; - cflag->iswit[1] = 2; - } -} diff --git a/StarVMC/GeoTestMaker/StStepping.h.C b/StarVMC/GeoTestMaker/StStepping.h.C deleted file mode 100644 index c4d2d0371b7..00000000000 --- a/StarVMC/GeoTestMaker/StStepping.h.C +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef StarMCHits_h -#define StarMCHits_h -#include "StarVMCDetector.h" -#include "St_g2t_Chair.h" -#include "StarHitVector.h" - -class StarMCHits : public TDataSet { - public: - virtual ~StarMCHits() {SafeDelete(fDetList); SafeDelete(fVolUserInfo);} - static StarMCHits *instance(const Char_t *name="", - const Char_t *title="") { - if (fgInstance) return fgInstance; - return new StarMCHits(name, title); - } - virtual StarMCHits *Instance() const {return fgInstance;} - virtual Int_t Init(); - virtual void Clear(const Option_t* opt = ""); - virtual void Step(); -#if 0 - virtual Float_t GetHitK(Int_t k); -#endif - virtual void SetHitHolder(TDataSet *m) {fHitHolder = m;} - virtual void SetDebug(Int_t m=0); - virtual TDataSet *GetDetectors() {return fDetectors;} - virtual TObjArray *GetVolUserInfo() {return fVolUserInfo;} - virtual TDataSet *GetHitHolder() {return fHitHolder;} - virtual StarVMCDetector *GetCurrentDetector() {return fCurrentDetector;} - virtual void FillG2Table(); - virtual void FinishEvent(); - virtual Int_t Debug() { return fDebug;} - static void MakeDetectorDescriptors(); - static const Char_t *MakeDetectorDescriptor(const Char_t *det); - private: - StarMCHits(const Char_t *name="StarMCHits",const Char_t *title=""); - static StarMCHits *fgInstance; - GHit_t fHit; - TDataSet *fDetectors; - THashList *fDetList; - TObjArray *fVolUserInfo; - TDataSet *fHitHolder; - StarVMCDetector *fCurrentDetector; - Int_t fDebug; - UInt_t fSeed; - Int_t fEventNumber; - ClassDef(StarMCHits,1) -}; -#endif diff --git a/StarVMC/GeoTestMaker/StTGeoProxy.cxx b/StarVMC/GeoTestMaker/StTGeoProxy.cxx deleted file mode 100644 index f4b01dafab5..00000000000 --- a/StarVMC/GeoTestMaker/StTGeoProxy.cxx +++ /dev/null @@ -1,1740 +0,0 @@ -// $Id: StTGeoProxy.cxx,v 1.14 2017/05/02 19:36:28 perev Exp $ -// -// -// Class StTGeoProxy -// ------------------ - - - -#include -#include -#include -#include -#include -#include -#include -#include "TROOT.h" -#include "TString.h" -#include "TMath.h" -#include "TObjArray.h" -#include "TGeoManager.h" -#include "TGeoNavigator.h" -#include "TGeoNode.h" -#include "TGeoVolume.h" -#include "TGeoShape.h" -#include "TGeoBBox.h" -#include "TGeoTube.h" -#include "TGeoMatrix.h" -#include "TCernLib.h" -#include "TVector3.h" - -#include "StTGeoProxy.h" -#include "StMultiKeyMap.h" - -int StTGeoProxy::StTGeoProxy::fgKount[3] = {0}; - - -enum {kMaxVolId = 1000000}; - -//_____________________________________________________________________________ -int GetVoluId(const TGeoVolume *vol) -{ - return vol->GetNumber()+kMaxVolId*vol->GetUniqueID(); -} - -class myTVector3 : public TVector3 { - -public: - - - myTVector3(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0):TVector3(x,y,z){;} - // The constructor. - - myTVector3(const Double_t *d):TVector3(d){;} - myTVector3(const Float_t *f):TVector3(f){;} - // Constructors from an array - - operator TVector3 &() {return *(TVector3*)this;} - operator const TVector3 &() const {return *(TVector3*)this;} - // The copy constructor. - myTVector3(const TVector3 &v):TVector3(v){;} - // Assignment - myTVector3 & operator = (const TVector3 &v){ *((TVector3*)this)=v; return *this;} - myTVector3 & operator = (const myTVector3 &v){ *((TVector3*)this)=v; return *this;} - - myTVector3 & operator = (const double *d){ SetXYZ(d[0],d[1],d[2]); return *this;} - myTVector3 & operator = (const float *f){ SetXYZ(f[0],f[1],f[2]); return *this;} - - void Set(const Double_t *d){SetXYZ(d[0],d[1],d[2]);} - void Set(const Float_t *f){SetXYZ(f[0],f[1],f[2]);} - void Get( Double_t *d){d[0]=X();d[1]=Y();d[2]=Z();} - void Get( Float_t *f){f[0]=X();f[1]=Y();f[2]=Z();} - - - -const double* GetArrD() const { fD[0]=X();fD[0]=Y();fD[0]=Z(); return fD;} -const float* GetArrF() const { fF[0]=X();fF[0]=Y();fF[0]=Z(); return fF;} - -protected: -mutable double fD[3]; -mutable float fF[3]; - -}; - -#define DOT(a,b) (a[0]*b[0]+a[1]*b[1]+a[2]*b[2]) - -static StTGeoProxy *gStTGeoProxy=0; -typedef std::map myVoluMap ; - -ClassImp(StTGeoProxy) -ClassImp(StVoluInfo) -ClassImp(StHitPlaneInfo) -ClassImp(StHitPlane) -ClassImp(StHitTube ) - -enum EMEDIUM {kISVOL =0,kIFIELD=1,kFIELDM=2,kTMAXFD=3 - ,kSTEMAX=4,kDEEMAX=5,kEPSIL =6,kSTMIN =7}; - -struct myMap {int id; const char *name;}; -static myMap gMyMod[] = { -{kUnknownId ,"" }, -{kTpcId ,"TPCE" }, -{kSvtId ,"SVTT" }, -{kRichId ,"RICH" }, -{kFtpcWestId ,"FTPC" }, -{kFtpcEastId ,"FTPC" }, -{kTofId ,"BTOF" }, -{kCtbId ,"Ctb" }, -{kSsdId ,"SFMO" }, -{kBarrelEmcTowerId ,"CALB" }, -{kBarrelEmcPreShowerId ,"CALB" }, -{kBarrelSmdEtaStripId ,"CALB" }, -{kBarrelSmdPhiStripId ,"CALB" }, -{kEndcapEmcTowerId ,"ECAL" }, -{kEndcapEmcPreShowerId ,"ECAL" }, -{kEndcapSmdUStripId ,"ECAL" }, -{kEndcapSmdVStripId ,"ECAL" }, -{kZdcWestId ,"" }, -{kZdcEastId ,"" }, -{kMwpcWestId ,"" }, -{kMwpcEastId ,"" }, -{kPhmdCpvId ,"PHMD" }, -{kPhmdId ,"PHMD" }, -{kPxlId ,"PXMO" }, -{kIstId ,"IBMO" }, -{kFgtId ,"FGTM" }, -{kEtrId ,"ETRV" }, -{kFpdWestId ,"FBOX" }, -{kFpdEastId ,"FBOX" }, -{kFmsId ,"" }, -{kRpsId ,"" }, -{kMtdId ,"MMBL" }, -{kSstId ,"SFMO" }, -#ifdef kFtsIdentifier -{kFtsId ,"FTSM" }, -#endif -{0,0 }}; - -void myBreak(int i) -{ -static int iCatch=-999; - if (iCatch!=i) return; - printf("myBreak:iCatch=%d\n",i); -} -//_____________________________________________________________________________ -StTGeoProxy::StTGeoProxy() -{ - assert(!gStTGeoProxy); - gStTGeoProxy=this; - memset(fBeg,0,fEnd-fBeg); - fVoluInfoArr = new StVoluInfoMap; - fHitPlaneArr = new TObjArray(); - fOpt = 1; - fSeedHits = new StVoidArr(); - fAllHits = new StVoidArr(); -} -//_____________________________________________________________________________ -int StTGeoProxy::Load(const char *geo) -{ - if (gGeoManager) { // Geom already there - Warning("Load","TGeoManager(%s,%s) is already there" - ,gGeoManager->GetName(),gGeoManager->GetTitle()); - return -1; - } - TString ts("$STAR/StarDb/AgiGeometry/"); - ts+=geo; ts+=".h"; - int ierr=0; - Long_t ans = gROOT->Macro(ts, &ierr); if (ans){}; - assert(!ierr); - return ierr; -} -//_____________________________________________________________________________ -void StTGeoProxy::Init(int mode) -{ - fMode = mode; - InitInfo(); - ls("Sc"); - if (fMode&2) InitHitPlane(); -// if (fMode&1) InitHitShape(); -} -//_____________________________________________________________________________ -void StTGeoProxy::InitLayers(StDetectorId did) -{ - StvSetLayer sl; - Edit(did,&sl); -} -//_____________________________________________________________________________ -void StTGeoProxy::Finish() -{ -// Avoid deleting of TGeoManager - gGeoManager = 0; -} -//_____________________________________________________________________________ -void StTGeoProxy::InitInfo() -{ - gGeoManager->CdTop(); - std::map moduMap; - StTGeoIter it; - it.Print("StTGeoProxy_Init"); - const TGeoVolume *vol= *it; - StVoluInfo *myModu=0; - for (;(vol=*it);++it) { - vol->GetShape()->ComputeBBox(); - int volId = ::GetVoluId(vol); -// First visit - if (it.IsFirst()) { //First visit -// Recognize module -// Check for MODULE - do { - myModu = 0; - if (!IsModule(vol) && !it.IsOmule()) break; - StVoluInfo *ext = SetFlag(vol,StVoluInfo::kModule); - if (DetId(vol->GetName())) ext->SetMODULE(); - assert(IsModule(vol)); - myModu = ext; -// printf("Module = %s(%d) ",vol->GetName(),volId); it.Print(0); - } while(0); - - if (myModu) continue; - if (!IsSensitive(vol)) continue; - for (int idx=1;1;idx++) { - const TGeoVolume *myVolu = it.GetVolu(idx); - if (!myVolu) break; - StVoluInfo *inf = IsModule(myVolu); - if (!inf) continue; - inf->AddSens(); break; - } - } - - - if (it.IsLast()) { //Last visit - -// Define for MODULE (capital letters, module with hits) - myModu = IsModule(vol); - if (!myModu) continue; - if (!myModu->GetSens()) {// Module without hits or not active now - if (!(moduMap[volId])) {//first time - printf("Module = %s(%d) ",vol->GetName(),volId); it.Print(0); - moduMap[volId]++; - } - } else {// Module with hits. It is MODULE - SetFlag(vol,StVoluInfo::kHitted); - TString ts = (IsActive(vol))? "*":" "; - printf("MODULE%s= %s(%d) Sens=%d",ts.Data(),vol->GetName(),volId,myModu->GetSens()); - it.Print(0); - } - - } - } - - - - - -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::SetModule (const char *voluName, int akt) -{ - const char *volName = voluName; - StDetectorId did = DetId(volName); - if (did) volName = ModName(did); - TGeoVolume *vol = gGeoManager->FindVolumeFast(volName); - if (!vol) { Warning("SetModule","Volume %s Not Found",voluName);return 0;} - - StVoluInfo *info = SetFlag(vol,StVoluInfo::kModule,akt); - if (did) info->SetMODULE(); - return info; -} -//_____________________________________________________________________________ -int StTGeoProxy::SetActive (const char *voluName, int akt,StActorFunctor *af) -{ - StVoluInfo *inf = SetModule(voluName,1); - if (!inf) return 0; - inf->SetBit(StVoluInfo::kActive,akt); - int n = 1; - if (!akt) {inf->SetActiveFunctor(0); return 1;} - inf->SetActiveFunctor(af); - -// Now care about all parents. They should be active as well - StTGeoIter it; - const TGeoVolume *vol=0; - for (;(vol=*it);++it) { - if (strcmp(voluName,vol->GetName()))continue; - if (!it.IsFirst()) continue; //Not a First visit - const TGeoVolume *myVol ; - for ( int idx=1; (myVol = it.GetVolu(idx));idx++) { - if (IsActive(myVol)) continue; - n+=SetActive(myVol->GetName(),1,0); - } - } - return 1; -} -//_____________________________________________________________________________ -int StTGeoProxy::SetActive (StDetectorId did,int akt,StActorFunctor *af) -{ - const char *modu = ModName(did); - if (!*modu) { Warning("SetActive","DetId %d Unknown",did);return 0;} - if (af) af->SetDetId(did); - int n = SetActive(modu,akt,af); -//??? if (n) return 0; - Long64_t mask = 1; mask = mask<<(int)did; - if (akt) { fActiveModu |= mask; } - else { fActiveModu &= ~mask; } -//??? return n; - return 1; -} -//_____________________________________________________________________________ -int StTGeoProxy::IsActive (StDetectorId did) const -{ - return ((fActiveModu & ((Long64_t)1)<Kind(); - if (flg >= StVoluInfo::kHitPlane) kase += 10; - switch (kase) { - case 0: inf = new StVoluInfo( volId); break; - case 10: ; - case StVoluInfo::kVoluInfo+10: inf = new StHitPlaneInfo(volId); break; - } - SetInfo(inf); inf->SetBit(flg,act); - return inf; -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::IsFlag(const TGeoVolume *volu,StVoluInfo::E_VoluInfo flg) const -{ - int volId = ::GetVoluId(volu); - StVoluInfo *inf = GetInfo(volId); - if (!inf ) return 0; - - if(inf->TestBit(flg)==0) return 0; - return inf; -} -//_____________________________________________________________________________ -int StTGeoProxy::Edit(StDetectorId did,StActorFunctor *af) -{ - - StTGeoIter it; - StDetectorId detId=kUnknownId; - int nEdit=0; - const TGeoVolume *vol=0,*myModu=0; - for (;(vol=*it);++it) { - - if ( it.IsLast() && (vol == myModu)) myModu=0; - if (!it.IsFirst()) {continue;} //First visit only - StVoluInfo *inf = IsModule(vol); - if (inf) { - if (!IsActive(vol)) {myModu=0; it.Skip(); continue;} - detId = DetId(vol->GetName()); - if (!detId) { continue;} - if (!did ) {myModu =vol; continue;} - if (did != detId) {myModu=0; it.Skip(); continue;} - myModu =vol; - } - if (!myModu) continue; - const char *path = it.GetPath(); - gGeoManager->cd(path); - af->SetDetId(detId); - int ans = (*af)(); - if (ans>0) nEdit++; - } - return nEdit; -} -//_____________________________________________________________________________ -void StTGeoProxy::InitHitShape() -{ - - fHitShape = new StTGeoHitShape(); - for (int pass=0;pass<2;pass++) { - StTGeoIter it; - for (const TGeoVolume *vol=0;(vol=*it);++it) { - vol->GetShape()->ComputeBBox(); - // First visit - if (!it.IsFirst()) continue; //First visit only - - if(IsModule(vol) && !IsActive(vol)) {it.Skip();continue;} - // Update HitShape - if (!IsSensitive(vol)) continue; - if (!IsHitPlane(vol) ) continue; - - double global[8][3],local[3],D[3]; - TGeoBBox *bb = (TGeoBBox*)vol->GetShape(); - bb->ComputeBBox(); - const double *ori = bb->GetOrigin(); - D[0] = bb->GetDX(); - D[1] = bb->GetDY(); - D[2] = bb->GetDZ(); - for (int jk=0;jk<8;jk++) { - for (int ix=0,im=1; ix<3; ix++,im<<=1) { - local[ix] = ori[ix] + D[ix]* ((!!(jk&im))*2 -1);} - it.LocalToMaster(local,global[jk]); - } - double z1 = 3e33, z2 = -3e33; - double rMax = 0; - for (int jk=0;jk<8;jk++) { - if (z1 > global[jk][2]) z1 = global[jk][2]; - if (z2 < global[jk][2]) z2 = global[jk][2]; - double r2 = pow(global[jk][0],2)+pow(global[jk][1],2); - if (rMaxUpdate(z1,z2,0);} - else { - fHitShape->Update(z1,z2,rMax); - fHitShape->Update(z1,z2,0.1);// It is a HACK (VP) - } - } - } - fHitShape->Smooth(-100,100); - fHitShape->Print(); - -} -//_____________________________________________________________________________ -void StTGeoProxy::InitHitPlane(StActorFunctor *act) -{ - StTGeoIter it; - StDetectorId detId=kUnknownId; - const TGeoVolume *vol=0; - for (;(vol=*it);++it) { //Loop to create StHitPlaneInfo for sensitive & active volumes - if (!it.IsFirst()) {continue;} //First visit only - if (IsModule(vol)) { - if (!IsActive(vol)) {it.Skip();continue;} - detId = DetId(vol->GetName()); - if (!detId) continue;; - } - vol->GetShape()->ComputeBBox(); -// First visit -// try to make HitPlaneInfo - if(!IsSensitive(vol)) continue; - StHitPlaneInfo *hpi = MakeHitPlaneInfo(it); - hpi->SetDetId(detId); - } - - it.Reset(); - detId=kUnknownId; - for (;(vol=*it);++it) { - if (!it.IsFirst()) {continue;} //First visit only - if (IsModule(vol)) { - if (!IsActive(vol)) {it.Skip();continue;} - detId = DetId(vol->GetName()); - if(!detId) continue; - } - if(!IsSensitive(vol)) continue; - StHitPlaneInfo *hpi = IsHitPlane(vol); - if (!hpi) continue; - StHitPlane *hp = hpi->MakeHitPlane(it,act); - if(!hp) continue; - hp->SetDetId(detId); - - } - -} -//_____________________________________________________________________________ -int StTGeoProxy::SetHitErrCalc(StDetectorId modId,TNamed *hitErrCalc - ,StActorFunctor *sel) - -{ - assert(IsActive(modId)); - const char *modu = ModName(modId); - assert(modu); - int kount=0; - TGeoVolume *moduVol = gGeoManager->FindVolumeFast(modu); - if (!moduVol) return 0; - StTGeoIter it; - const TGeoVolume *vol=0; - - for (;(vol=*it);++it) { if (vol==moduVol) break;} - - if (!vol) return 0; - if (!IsMODULE(vol)) return 0; - if (!IsActive(vol)) return 0; - ++it; - - for (;(vol=*it);++it) { - if (vol==moduVol && (it.IsFirst() || it.IsLast())) break; - if (!it.IsFirst()) continue; - if (!IsSensitive(vol)) continue; - StHitPlaneInfo* hpi = IsHitPlane(vol); - if (!hpi) continue; - StHitPlane* hp = hpi->GetHitPlane (it.GetPath()); - if (!hp) continue; - if (hp->GetHitErrCalc()==hitErrCalc) continue; - - if (sel) {//check selector - gGeoManager->cd(it.GetPath()); - sel->SetDetId(modId); - if (!sel->Operator(hp->GetPnt())) continue; - } - hp->SetHitErrCalc(hitErrCalc); - kount++; - } - return kount; -} -//_____________________________________________________________________________ -StTGeoProxy::~StTGeoProxy() -{ - delete fVoluInfoArr; -} -//_____________________________________________________________________________ -StTGeoProxy *StTGeoProxy::Instance() -{ - if (!gStTGeoProxy) gStTGeoProxy = new StTGeoProxy; - return gStTGeoProxy; -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::GetInfo(int idx) const -{ - StVoluInfoMapIter it = fVoluInfoArr->find(idx); - if (it == fVoluInfoArr->end()) return 0; - return (*it).second; -} -//_____________________________________________________________________________ -StVoluInfo *&StTGeoProxy::GetINFO(int idx) -{ - StVoluInfo *&inf = (*fVoluInfoArr)[idx]; - if (inf) return inf; - inf = new StVoluInfo(idx); - return inf; -} -//_____________________________________________________________________________ -void StTGeoProxy::SetInfo(StVoluInfo* ext) -{ - int volId = ext->GetVoluId(); - StVoluInfo *&inf = (*fVoluInfoArr)[volId]; - if (inf==ext) return; - if (inf) delete inf; - inf = ext; -} -//_____________________________________________________________________________ -void StTGeoProxy::AddHitPlane(StHitPlane* pla) -{ - fHitPlaneArr->Add(pla); -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::IsModule(const TGeoVolume *volu) const -{ - int id = ::GetVoluId(volu); - StVoluInfo *ext = GetInfo(id); - if (!ext) return 0; - if (!ext->IsModule()) return 0; - return ext; -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::IsMODULE(const TGeoVolume *volu) const -{ - int id = ::GetVoluId(volu); - StVoluInfo *ext = GetInfo(id); - if (!ext) return 0; - if (!ext->IsMODULE()) return 0; - return ext; -} -//_____________________________________________________________________________ -StVoluInfo *StTGeoProxy::IsModule(const TGeoNode *node) const -{ return IsModule(node->GetVolume()); } -//_____________________________________________________________________________ -StHitPlaneInfo* StTGeoProxy::IsHitPlane(const TGeoVolume *volu) const -{ - int id = ::GetVoluId(volu); - StVoluInfo *ext = GetInfo(id); - if (!ext) return 0; - if (!ext->IsHitPlane()) return 0; - return (StHitPlaneInfo*)ext; -} -//_____________________________________________________________________________ -StHitPlaneInfo* StTGeoProxy::IsHitPlane(const TGeoNode *node) const -{ return IsHitPlane(node->GetVolume()); } - -//_____________________________________________________________________________ -int StTGeoProxy::MayHitPlane(const TGeoVolume *volu) const -{ - enum {kHow=4}; - - const TGeoShape* sh=volu->GetShape() ; - if (!sh) return -1; - if (!sh->IsValidBox()) return -1; - int myKode=0; - int kase = sh->IsCylType() ; - switch (kase) { - case 0://Plane case - { - const TGeoBBox *bb = (const TGeoBBox*)sh; - double dd[3]={bb->GetDX(),bb->GetDY(),bb->GetDZ()}; - int jMin =0,jMax=0,jMed=0; - for (int j=1;j<3;j++) { if (dd[j]dd[jMax]) jMax=j;} - for (int j=1;j<3;j++) { if (j==jMin) continue;if (j==jMax) continue;jMed=j;} - myKode = (jMin+1)+ 10*(jMed+1) + 100*(jMax+1); - if (dd[jMin]*kHow>dd[jMed]) myKode = 0; - break; - } - case 1: //Tube case - { - double par[9]; - sh->GetBoundingCylinder(par); - const TGeoBBox *bb = (const TGeoBBox*)sh; - par[4] = bb->GetDZ(); - par[0] = sqrt(par[0]); - par[1] = sqrt(par[1]); - if ((par[1]-par[0])*kHow < (2*par[4])) myKode = 4; //thin walls - if ((par[1]-par[0]) > kHow*(2*par[4])) myKode = 123; //disk - } - } - return myKode; -} -//_____________________________________________________________________________ -StHitPlaneInfo *StTGeoProxy::MakeHitPlaneInfo(const StTGeoIter &it) -{ -static int nCall=0; nCall++; - - const TGeoVolume *myVolu = *it; - if (!IsSensitive(myVolu)) return 0; - const TGeoVolume *volu=0; - StHitPlaneInfo *bhp=0; - for (int up=0;(volu=it.GetVolu(up));up++) { - - int ax = MayHitPlane(volu); - if (ax<0) continue; - - const TGeoShape *sh = volu->GetShape(); - const TGeoBBox *bb = (const TGeoBBox*)sh; - int iv = ::GetVoluId(volu); - StVoluInfo *ext = GetInfo(iv); - int kase = 0; - if (ext) kase = ext->Kind(); - switch(kase) { - - case 0: //no extention - case 1: {//basic extention - bhp = new StHitPlaneInfo(iv); - if (ext) *bhp = *ext; - bhp->SetHitPlane(); - bhp->SetAxis(ax); - TCL::ucopy(bb->GetOrigin(),bhp->fOrg,3); - MakeDir(ax,bhp->fDir); - SetInfo(bhp); - break;} - - case 2: //HitPlane extention - bhp = (StHitPlaneInfo*)ext; - break; - default: assert(0 && " Wrong kind of StVoluInfo"); - } - break; - } - if (bhp) return bhp; - printf(" ***Warning: HitPlane not found for:"); it.Print(0); - return 0; -} -//_____________________________________________________________________________ -int StTGeoProxy::MakeDir(int kode, float dir[3][3]) -{ - memset(dir[0],0,sizeof(dir[0][0])*3*3); - - int ax1 = (kode%10); - if (ax1>0 && ax1<=3) { - myTVector3 myDir[3]; - myDir[0][((kode )%10)-1]=1; - myDir[2][((kode/100)%10)-1]=1; - myDir[1] = myDir[2].Cross(myDir[0]); - for (int i=0;i<3;i++) {myDir[i].Get(dir[i]);} - }else if(ax1==4) { - for (int jk=0;jk<3;jk++){dir[jk][jk]=1;} - - }else {;} - - return 0; -} -//_____________________________________________________________________________ -void StTGeoProxy::Summary() -{ - int np = StTGeoProxy::fgKount[2]; - int nh = StTGeoProxy::fgKount[1]; - int ni = StTGeoProxy::fgKount[0]-nh; - printf("/nStTGeoProxy::Summary() Info=%d HitPlaneInfo=%d HitPlane=%d created\n\n",ni,nh,np); -} - -//_____________________________________________________________________________ -void StHitPlane::SetLayer() -{ - static StTGeoProxy *tg = StTGeoProxy::Inst(); - const float *pnt = GetPnt(); - double myPnd[3]={pnt[0],pnt[1],pnt[2]}; - const float *dir = GetDir(pnt)[0]; - double myDir[3] = {-dir[0],-dir[1],-dir[2]}; - assert(DOT(myPnd,myDir)<0); - - fNex = tg->Look(100,myPnd,myDir); - assert(fNex>1e-2); -} -//_____________________________________________________________________________ -int StTGeoProxy::IsSensitive(const TGeoVolume *volu) -{ - if (!volu) volu = gGeoManager->GetCurrentVolume(); - const TGeoMedium *tm = volu->GetMedium(); - if (!tm) return 0; - return (tm->GetParam(kISVOL)>0.); -} -//_____________________________________________________________________________ -const TGeoVolume *StTGeoProxy::GetModu() const -{ - for (int i=0;1;i++) { - TGeoNode *n = gGeoManager->GetMother(i); - if(!n) break; - TGeoVolume *v=n->GetVolume(); - if (!v) continue; - if (IsModule(v)) return v; - } - return 0; -} -//_____________________________________________________________________________ -const TGeoVolume *StTGeoProxy::GetVolu() const -{ - return gGeoManager->GetCurrentVolume(); -} -//_____________________________________________________________________________ -void StTGeoProxy::Print(const char *tit) const -{ - TGeoVolume *v=0; - if (tit) printf("StTGeoProxy::Print(%s)\n\n",tit); - for (int i=gGeoManager->GetLevel();i>=0;i--) { - TGeoNode *n = gGeoManager->GetMother(i); - if(!n) break; - v=n->GetVolume(); - if (!v) continue; - printf("/%s#%d",v->GetName(),n->GetNumber()); - } - if (v && v->GetMaterial()) { - printf("(%s)",v->GetMaterial()->GetName()); - if (IsSensitive(v)) printf("*"); - } - printf("\n"); - -} -//_____________________________________________________________________________ -void StTGeoProxy::ls(const char *opt) const -{ -static int nCall=0;nCall++; -static const char *types[]={"Dead","MODU","Modu","HitP","Sens","Actv"}; - int opta = strstr(opt,"a")!=0; //print all - int optm = strstr(opt,"m")!=0; //module - int optM = strstr(opt,"M")!=0; //MODULE - int opts = strstr(opt,"s")!=0; //senitive - int optp = strstr(opt,"p")!=0; //Hit Plane - int optc = strstr(opt,"c")!=0; //Count summary - int optS = strstr(opt,"S")!=0; //Silent, only summary - int optA = strstr(opt,"A")!=0; //only Active in summary - if (optc) opts=1; - std::map myMap; - std::string myName; - - StTGeoIter it; - const TGeoVolume *vol= *it; - int num=0; - for (;(vol=*it);++it) { - if (!it.IsFirst()) continue; -// int volId = ::GetVoluId(vol); - int jk = 0; - StHitPlaneInfo *ghp=0; - do { - if (optM && IsMODULE (vol)) {jk=1;break;} - if (optm && IsModule (vol)) {jk=2;break;} - if (optp && (ghp=IsHitPlane(vol))){jk=3;break;} - if (opts && IsSensitive(vol)) {jk=4; - if (IsActive(vol)) jk=5;break;} - } while (0); - if (!opta && !jk) continue; - num++; - if (optc) {//collect summary - myName = vol->GetName(); - myName+='.'; myName+=types[jk][0]; - myMap[myName]+=1; - } - if (optS) continue; - TString path(it.GetPath()); - const TGeoShape *sh = vol->GetShape(); - const TGeoMedium *me = vol->GetMedium(); - const TGeoMaterial *ma = (me)? me->GetMaterial():0; - const char *maName = (ma)? ma->GetName(): ""; - printf("%3d - %s(%s",num,vol->GetName(),types[jk]); - if (ghp) { - StHitPlane *hp = ghp->GetHitPlane(path); - if (!hp) { - path+=" Not Found"; ghp->Print(path.Data());} - assert(hp); - printf("#%d",hp->GetNHits()); - } - - - printf(",%s,%s)\t %s" - ,sh->ClassName()+4 - ,maName,path.Data()); - - printf("\n"); - } - if (myName.empty()) return; - - int nTot=0,line=0; - printf("lsSummary:\n"); - for (auto it = myMap.begin(); it !=myMap.end(); ++it) { - const char *name = (*it).first.c_str(); - if (optA && !strstr(name,".A")) continue; - int n = (*it).second; nTot+=n; - line++; - printf("%d - %s \t%d\n",line,name,n); - } - printf("%s \t%d\n","InTot",nTot); - -} -//_____________________________________________________________________________ -const char *StTGeoProxy::GetPath() const -{ - return gGeoManager->GetPath(); -} -//_____________________________________________________________________________ -void StTGeoProxy::Test() -{ - gROOT->Macro("$STAR/StarDb/AgiGeometry/y2009.h"); - StTGeoProxy &hlp = *StTGeoProxy::Instance(); - hlp.Init(1+2); -// hlp.ls("p"); - StTGeoIter it; - const TGeoVolume *vol= 0; - int num=0; - hlp.ClearHits(); - for (;(vol=*it);++it) { - if (!it.IsFirst()) continue; - StHitPlaneInfo *hpi = hlp.IsHitPlane(vol); - if (!hpi) continue; - TString path(it.GetPath()); - StHitPlane *hp = hpi->GetHitPlane(path); - assert(hp); - num++; - hlp.AddHit((void*)hp,hp->GetDetId(),hp->GetPnt(),num,1); - } - hlp.InitHits(); - hlp.ls("p"); -} -//_____________________________________________________________________________ -void StTGeoProxy::Break(int kase) -{ -static int myKase = -2009; -if (kase!=myKase) return; -printf("Break(%d)\n",kase); -} -//_____________________________________________________________________________ -const StHitPlane *StTGeoProxy::AddHit(void *hit,StDetectorId detId,const float xyz[3],unsigned int hardw,int seed) -{ -static int nCall = 0; nCall++; -// Test of hardware id assignment quality -enum {kMaxTest=1000,kMaxFail=100}; -// -// Break(nCall); - fDetId = detId; - StHitPlane *hp=0,*hpGeo=0; - fGoodHit = 0; - if (fHitLoadActor) fHitLoadActor->SetHit(hit); - hpGeo = FindHitPlane(xyz,fGoodHit); - if (!hpGeo) { - if (fGoodHit) return 0; //Hit rejected - double pnt[3]={xyz[0],xyz[1],xyz[2]}; - gGeoManager->SetCurrentPoint(pnt); - Warning("AddHit","Hit(%g,%g,%g) in %s Not Found",pnt[0],pnt[1],pnt[2],GetPath()); - return 0; - } - hp = hpGeo; - assert(hp); - assert(hp->GetDetId() == detId); - - fAllHits->push_back(hit); - if (seed) {//add to seed hit collection - fSeedHits->push_back(hit); - } - hp->AddHit(hit,xyz); -//printf("Hit(%g %g %g) added to %s\n",xyz[0],xyz[1],xyz[2],hp->GetName()); - - if (hp->GetNHits()==1) AddHitPlane(hp); - - - return hp; -} -//_____________________________________________________________________________ -StHitPlane *StTGeoProxy::FindHitPlane(const float xyz[3],int &sure) -{ -// cos(a+b) = cos(a)*cos(b) - sin(a)*sin(b) -// sin(a+b) = cos(a)*sin(b) + sin(a)*cos(b) -static const float dirs[][3] = { -{ 0.0000, 0.0000, 1.0000 }, // 1 -{ 0.5000, 0.0000, 0.8660 }, // 2 -{ 0.2500, 0.4330, 0.8660 }, // 3 -{-0.2500, 0.4330, 0.8660 }, // 4 -{-0.5000, 0.0000, 0.8660 }, // 5 -{-0.2500, -0.4330, 0.8660 }, // 6 -{ 0.2500, -0.4330, 0.8660 }, // 7 -{ 0.8660, 0.0000, 0.5000 }, // 8 -{ 0.7344, 0.4589, 0.5000 }, // 9 -{ 0.3796, 0.7784, 0.5000 }, //10 -{-0.0905, 0.8613, 0.5000 }, //11 -{-0.5332, 0.6824, 0.5000 }, //12 -{-0.8138, 0.2962, 0.5000 }, //13 -{-0.8471, -0.1801, 0.5000 }, //14 -{-0.6230, -0.6016, 0.5000 }, //15 -{-0.2095, -0.8403, 0.5000 }, //16 -{ 0.2676, -0.8236, 0.5000 }, //17 -{ 0.6634, -0.5567, 0.5000 }, //18 -{ 0.8576, -0.1205, 0.5000 }, //19 -{ 1.0000, 0.0000, 0.0000 }, //20 -{ 0.8660, 0.5000, 0.0000 }, //21 -{ 0.5000, 0.8660, 0.0000 }, //22 -{ 0.0000, 1.0000, 0.0000 }, //23 -{-0.5000, 0.8660, 0.0000 }, //24 -{-0.8660, 0.5000, 0.0000 }, //25 -{-1.0000, 0.0000, 0.0000 }, //26 -{-0.8660, -0.5000, 0.0000 }, //27 -{-0.5000, -0.8660, 0.0000 }, //28 -{-0.0000, -1.0000, 0.0000 }, //29 -{ 0.5000, -0.8660, 0.0000 }, //30 -{ 0.8660, -0.5000, 0.0000 }, //31 -{ 0.8660, 0.0000, -0.5000 }, //32 -{ 0.7344, 0.4589, -0.5000 }, //33 -{ 0.3796, 0.7784, -0.5000 }, //34 -{-0.0905, 0.8613, -0.5000 }, //35 -{-0.5332, 0.6824, -0.5000 }, //36 -{-0.8138, 0.2962, -0.5000 }, //37 -{-0.8471, -0.1801, -0.5000 }, //38 -{-0.6230, -0.6016, -0.5000 }, //39 -{-0.2095, -0.8403, -0.5000 }, //40 -{ 0.2676, -0.8236, -0.5000 }, //41 -{ 0.6634, -0.5567, -0.5000 }, //42 -{ 0.8576, -0.1205, -0.5000 }, //43 -{ 0.5000, 0.0000, -0.8660 }, //44 -{ 0.2500, 0.4330, -0.8660 }, //45 -{-0.2500, 0.4330, -0.8660 }, //46 -{-0.5000, 0.0000, -0.8660 }, //47 -{-0.2500, -0.4330, -0.8660 }, //48 -{ 0.2500, -0.4330, -0.8660 }, //49 -{ 0.0000, 0.0000, -1.0000 }}; //50 - -enum {kNDIRS = sizeof(dirs)/(3*sizeof(**dirs))}; - -static int nCall=0; nCall++; - double pnt[3]={xyz[0],xyz[1],xyz[2]}; - const TGeoNode *node = gGeoManager->FindNode(pnt[0],pnt[1],pnt[2]); - if (fHitLoadActor) { - int act = (*fHitLoadActor)(pnt); - if (act) node = gGeoManager->GetCurrentNode(); - } - assert(node); - StHitPlane *hp = GetCurrentHitPlane(); - sure = 1; - if (hp && hp->GetHitErrCalc() && IsHitted(pnt)) return hp; - -// volume is sensitive but not active but still sure - if (hp) return 0; - sure = 0; - double Rxy = sqrt(pnt[0]*pnt[0]+pnt[1]*pnt[1]); - double myCos= pnt[0]/Rxy,mySin=pnt[1]/Rxy; - double myDir[3]; - double minDist=(fabs(xyz[0])+fabs(xyz[1]))/10+5; - StHitPlane *minHitPlane=0; - for (int idir=0;idirSetCurrentPoint(pnt); - node = gGeoManager->FindNode(); - myDir[0] = dirs[idir][0]*myCos - dirs[idir][1]*mySin; - myDir[1] = dirs[idir][0]*mySin + dirs[idir][1]*myCos; - myDir[2] = dirs[idir][2]; - double myStep = Look(minDist,pnt,myDir); - if (myStep > minDist) continue; - hp = GetCurrentHitPlane(); - if (!hp ) continue; - if (!hp->GetHitErrCalc()) continue; - if (!IsHitted(gGeoManager->GetLastPoint())) continue; - if (fDetId != hp->GetDetId()) continue; - minDist = myStep; minHitPlane = hp; - } - return minHitPlane; -} - -//_____________________________________________________________________________ -StHitPlane *StTGeoProxy::GetCurrentHitPlane () -{ - const TGeoNode *node = 0; - const StHitPlaneInfo *inf=0; - TString path(gGeoManager->GetPath()); - int inc=0; - for (; inc<=3; inc++) { - node = gGeoManager->GetMother(inc); - if (!node) return 0; - inf = IsHitPlane(node); - if (inf) break; - } - if (!inf) return 0; - for (int jnc = 1; jnc<=inc; jnc++) {gGeoManager->CdUp();} - path=gGeoManager->GetPath(); - StHitPlane *hp= inf->GetHitPlane(path); - return hp; -} -//_____________________________________________________________________________ -void StTGeoProxy::ClearHits() -{ - fAllHits->clear(); - fSeedHits->clear(); - int n = fHitPlaneArr->GetLast()+1; - for (int i=0;iAt(i); - hp->Clear(); - } - fHitPlaneArr->Clear(); -} -//_____________________________________________________________________________ -void StTGeoProxy::Clear(const char *) -{ - ClearHits(); -} -//_____________________________________________________________________________ -int StTGeoProxy::InitHits() -{ - - int n = fHitPlaneArr->GetLast()+1; - int nHits = 0; - for (int i=0;iAt(i); - nHits += hp->InitHits(); - } - return nHits; -} -//_____________________________________________________________________________ -StDetectorId StTGeoProxy::DetId(const char *detName) -{ - StDetectorId id = detectorIdByName(detName); - if (id) return id; - TString tDetName(detName); - for (int i = 0;gMyMod[i].name; i++) { - if (!tDetName.CompareTo(gMyMod[i].name,TString::kIgnoreCase)) - return (StDetectorId)gMyMod[i].id;} - return (StDetectorId)0; -} -//_____________________________________________________________________________ -const char *StTGeoProxy::DetName(StDetectorId detId) -{ - const char *det =detectorNameById(detId); - return det; -} -//_____________________________________________________________________________ -const char *StTGeoProxy::ModName(StDetectorId detId) -{ - for (int i = 0;gMyMod[i].name; i++) - { if (gMyMod[i].id==detId) return gMyMod[i].name;} - return ""; -} - -//_____________________________________________________________________________ -int StTGeoProxy::IsHitted(const double X[3]) const -{ - if (!IsSensitive()) return 0; - const TGeoVolume *mo = GetModu(); - if (!IsActive(mo)) return 0; - StVoluInfo *vi = GetInfo(::GetVoluId(mo)); - StActorFunctor *af = vi->GetActiveFunctor(); - if (!af) return 1; - return (*af)(X); -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -const char *StVoluInfo::GetName() const -{ - int volId = GetUniqueID(); - return (volId) ? gGeoManager->GetVolume(volId)->GetName():"NoName"; -} - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StHitPlaneInfo::StHitPlaneInfo(int volId) : StVoluInfo(volId) -{ - fAxi=0; - memset(fOrg,0,sizeof(fOrg)+sizeof(fDir)); - StTGeoProxy::fgKount[1]++; -} -//_____________________________________________________________________________ -StHitPlaneInfo::~StHitPlaneInfo() -{ - StTGeoProxy::fgKount[1]--; -} -//_____________________________________________________________________________ -StHitPlane *StHitPlaneInfo::MakeHitPlane(const StTGeoIter &it,StActorFunctor *act) -{ -static int nCall=0; nCall++; - const TGeoVolume *volu = *it; - const TGeoShape *sh = volu->GetShape(); - StHitPlane *hp=0; - StHitTube *ht=0; - TString path(it.GetPath()); - hp= (StHitPlane *)GetHitPlane(path); - if (hp) return 0; - - float gPos[3],lDir[3][3]; - it.LocalToMaster(fOrg, gPos); - memcpy(lDir[0],fDir[0],sizeof(fDir)); - int myAxi = fAxi; - if (act) { //Try to use functor - gGeoManager->cd(path); - act->SetDetId(GetDetId()); - int ax = act->Operator(gPos); - if (ax>0) { - myAxi = ax; - StTGeoProxy::MakeDir(ax,lDir); - } } - if (!myAxi) return 0; - - if ((myAxi%10)<=3) { - hp = new StHitPlane(path,::GetVoluId(volu)); - } else if ((myAxi%10)==4) { - StHitTube *ht = new StHitTube(path,::GetVoluId(volu)); hp = ht; - } - - fHitPlanePathMap[path] = hp; - const char *pa = (*(fHitPlanePathMap.find(path))).first; - hp->SetPath(pa); - - memcpy(hp->fOrg,gPos,sizeof(gPos)); - myTVector3 Vd[3],Vo(hp->fOrg); - int upd = 0; - for (int i=0;i<3;i++) { - it.LocalToMasterVect(lDir[i], hp->fDir[i]); Vd[i]=hp->fDir[i];} -// Check signature and try to fix - for(int i=0;i<3;i++){Vd[i]= hp->fDir[i];} - for(int iTry=0;iTry<2;iTry++) { - int iTst=0; - for(int i=0;i<3;i++){ - int j = (i+1)%3,k = (j+1)%3; - myTVector3 res = Vd[i].Cross(Vd[j]); - iTst+= ((Vd[k]-res).Mag()>1e-4); - } - if (!iTst) break; - assert(!iTry); - upd++; Vd[1]*=(-1.); - } - - if (Vd[0].Dot(Vo)<0) {upd++; // Rotate around local Z - for(int i=0;i<2;i++){Vd[i].Rotate(M_PI,Vd[2]);}} - - if (Vd[2][2]<0) {upd++; // Rotate around local X - for(int i=1;i<3;i++) {Vd[i].Rotate(M_PI,Vd[0]);}} - if (upd) { // Update - for(int i=0;i<3;i++){Vd[i].Get(hp->fDir[i]);}} - - if (ht) { - double par[9];float pnt[3]={0}; - sh->GetBoundingCylinder(par); - double rMed = (sqrt(par[0])+sqrt(par[1]))*0.5; - double pMed = 0.5*(par[2]+par[3])*M_PI/180; - pnt[0] = rMed*cos(pMed); - pnt[1] = rMed*sin(pMed); - it.LocalToMaster(pnt, ht->fPnt); - ht->fRmed = rMed; - } - -// Check - for(int i=0;i<3;i++){for(int j=0;j<3;j++) {Vd[i][j]= hp->fDir[i][j];}} - for(int i=0;i<3;i++){ - int j = (i+1)%3,k = (j+1)%3; - myTVector3 res = Vd[i].Cross(Vd[j]); - assert( (Vd[k]-res).Mag()<1e-4); - } - - return hp; -} -//_____________________________________________________________________________ -StHitPlane *StHitPlaneInfo::GetHitPlane (const TString &path) const -{ -static int nCall=0; nCall++; - StHitPlanePathMapIter it = fHitPlanePathMap.find(path); - if (it == fHitPlanePathMap.end()) {return 0;} - return (*it).second; -} -//_____________________________________________________________________________ -StHitPlane *StHitPlaneInfo::RemHitPlane (const TString &path) -{ - StHitPlanePathMap::iterator it = fHitPlanePathMap.find(path); - if (it == fHitPlanePathMap.end()) {return 0;} - StHitPlane *hp = (*it).second; - fHitPlanePathMap.erase(it); - return hp; -} -//_____________________________________________________________________________ -void StHitPlaneInfo::Print(const char* tit ) const -{ - printf("\nStHitPlaneInfo(%s) %s\n",GetName(),tit); - printf("fOrg: %g %g %g\n",fOrg[0],fOrg[1],fOrg[2]); - for (int i=0;i<3;i++) {; - printf("fDir[%d]: %g %g %g\n",i,fDir[i][0],fDir[i][1],fDir[i][2]);} - int njk = fHitPlanePathMap.size(); - printf("HitPlanes %d:\n",njk); - int j=0; - for (StHitPlanePathMapIter it =fHitPlanePathMap.begin(); - it!=fHitPlanePathMap.end();++it) {printf(" %3d - %s\n",j,(*it).first.Data());j++;} - printf("\n"); - -} -//_____________________________________________________________________________ -StHitPlane::StHitPlane(const char *path,int voluId): TNamed(path,"") -{ - memset(fBeg,0,fEnd-fBeg+1); - SetUniqueID(voluId); - fHitMap = new StMultiKeyMap(2); - StTGeoProxy::fgKount[2]++; -} -//_____________________________________________________________________________ -StHitPlane::~StHitPlane() -{ - StTGeoProxy::fgKount[2]--; - delete fHitMap;fHitMap = 0; -} -//_____________________________________________________________________________ -void StHitPlane::AddHit(void *hit,const float xyz[3]) -{ - float uv[3]; - ToLocal(xyz,uv); - fHitMap->Add(hit,uv+1); - -} -//_____________________________________________________________________________ -void StHitPlane::ToLocal(const float xyz[3],float uv[3]) const -{ - float x[3]; - TCL::vsub(xyz, GetOrg(xyz), x,3); - TCL::vmatl(GetDir(xyz)[0], x, uv, 3, 3); -} -//_____________________________________________________________________________ -int StHitPlane::GetNHits() const -{ -return (fHitMap)?fHitMap->Size():0; -} -//_____________________________________________________________________________ -int StHitPlane::InitHits() -{ - return fHitMap->MakeTree(); -} -//_____________________________________________________________________________ -void StHitPlane::Clear(const char*) -{ - fHitMap->Clear(); -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StHitTube::StHitTube(const char *path,int voluId): StHitPlane(path,voluId) -{ - memset(fBeg,0,fEnd-fBeg+1); -} -//_____________________________________________________________________________ -const Mtx33F_t &StHitTube::GetDir(const float *hit) const -{ -static float myDir[3][3]; - TCL::ucopy(fDir[2],myDir[2],3); - TCL::vsub(hit,fOrg,myDir[0],3); - float fak = TCL::vdot(myDir[0],fDir[2],3); - TCL::vlinco(myDir[0],1.,fDir[2],-fak,myDir[0],3); - fak = TCL::vdot(myDir[0],myDir[0],3); - fak = sqrt(fak); - TCL::vscale(myDir[0],1./fak,myDir[0],3); - TMath::Cross(fDir[2],myDir[0],myDir[1]); - return myDir; -} -//_____________________________________________________________________________ -const float *StHitTube::GetOrg(const float *hit) const -{ -static float myOrg[3]; - TCL::vsub(hit,fOrg,myOrg,3); - float fak = TCL::vdot(myOrg,myOrg,3); - TCL::vlinco(myOrg,fRmed/fak,fOrg,1.,myOrg,3); - return myOrg; -} - - -//_____________________________________________________________________________ - enum {kEND,kDOWN,kNEXT,kUPP}; -//_____________________________________________________________________________ -//_____________________________________________________________________________ - StTGeoIter::StTGeoIter() -{ - fNavi = new TGeoNavigator(gGeoManager); - fNavi->BuildCache(); - Reset(); -} -//_____________________________________________________________________________ -void StTGeoIter::Reset() -{ - fLev = 0; - fStk[0]=0; - fNavi->CdTop(); - fVolu = fNavi->GetCurrentVolume(); - fNow = 1; - fKase = kDOWN; - assert(fLev == fNavi->GetLevel()); -} -//_____________________________________________________________________________ - StTGeoIter::~StTGeoIter() -{ delete fNavi; fNavi = 0;} - -//_____________________________________________________________________________ -StTGeoIter &StTGeoIter::Down() -{ - fKase = kDOWN; return ++(*this); -} -//_____________________________________________________________________________ -StTGeoIter &StTGeoIter::Next() -{ - fKase = kNEXT; return ++(*this); -} -//_____________________________________________________________________________ -StTGeoIter &StTGeoIter::Skip() -{ - fKase = kNEXT; return (*this); -} -//_____________________________________________________________________________ -StTGeoIter &StTGeoIter::Upp() -{ - fKase = kUPP; return ++(*this); -} -//_____________________________________________________________________________ -StTGeoIter &StTGeoIter::operator++() -{ - int nKids; -CASE: - - switch (fKase) { - - case kEND: fVolu=0; fKase=kEND ; fNow=0; break; - - case kDOWN: { - nKids = fVolu->GetNdaughters(); - if (!nKids) { fKase=kNEXT; fNow=2; break;} - fNavi->CdDown(0); fLev++; - fStk[fLev]=0; - assert(fLev == fNavi->GetLevel()); - fVolu = fNavi->GetCurrentVolume(); - fKase=kDOWN; fNow=1; break;} - - case kNEXT: { - if (!fLev) { fVolu=0; fKase=kEND ; fNow=0; break;} - fNavi->CdUp(); fLev--; - assert(fLev == fNavi->GetLevel()); - fVolu = fNavi->GetCurrentVolume(); - nKids = fVolu->GetNdaughters(); - fStk[fLev]++; - if (fStk[fLev]>=nKids) { fKase=kNEXT ; fNow=2; break;} - fNavi->CdDown(fStk[fLev]);fLev++; fStk[fLev]=0; - assert(fLev == fNavi->GetLevel()); - fVolu = fNavi->GetCurrentVolume(); fKase=kDOWN ; fNow=1; break;} - - case kUPP: { - if (!fLev) {fVolu=0; fKase=kEND ; fNow=0; break;} -// TGeoNode *node = fNavi->GetCurrentNode(); - fNavi->CdUp(); fLev--; - fVolu = fNavi->GetCurrentVolume(); - assert(fLev == fNavi->GetLevel()); - fKase=kNEXT; goto CASE;} - } - - return *this; -} -//_____________________________________________________________________________ -const TGeoNode *StTGeoIter::GetNode(int idx) const -{ - return fNavi->GetMother(idx); -} -//_____________________________________________________________________________ -const TGeoHMatrix *StTGeoIter::GetMatr(int idx) const -{ - return fNavi->GetMotherMatrix(idx); -} - -//_____________________________________________________________________________ -const TGeoVolume *StTGeoIter::GetVolu(int idx) const -{ - if (!idx) return fVolu; - const TGeoNode *node = GetNode(idx); - if (!node) return 0; - return node->GetVolume(); -} -//_____________________________________________________________________________ -void StTGeoIter::Print(const char *tit) const -{ - const TGeoVolume *v =0; - if (tit) printf("\nStTGeoIter::Print(%s)\n\n",tit); - printf("%d ",fNow); - for (int l=0;l<=fLev;l++) { - v = GetVolu(fLev-l); - int iocc = (l) ? fStk[l-1]:0; - printf("/%s#%d",v->GetName(),iocc); - } - const TGeoMedium *tm = v->GetMedium(); - const TGeoMaterial *mat = (tm)? tm->GetMaterial():0; - const char* maName = (mat)? mat->GetName():""; - printf("(%s)",maName); - if (tm && tm->GetParam(kISVOL)>0.)printf("*"); - - v = GetVolu(0); - const TGeoShape* sh=v->GetShape() ; - if (sh && sh->IsCylType()) { - double dd[10]; - sh->GetBoundingCylinder(dd);dd[4] = ((const TGeoBBox*)sh)->GetDZ(); - printf(" // shape=%s R1=%g R2=%g Phi1=%g,Phi2=%g,dz=%g",sh->ClassName() - ,sqrt(dd[0]),sqrt(dd[1]),dd[2],dd[3],dd[4]); - - } else if (sh && sh->IsValidBox()) { - const TGeoBBox *bb = (const TGeoBBox*)sh; - double dd[3]={bb->GetDX(),bb->GetDY(),bb->GetDZ()}; - printf(" // shape=%s dx=%g dy=%g dz=%g",sh->ClassName(),dd[0],dd[1],dd[2]); - } - printf("\n"); - -} -//_____________________________________________________________________________ -const char *StTGeoIter::GetPath() const -{ - return fNavi->GetPath(); -} -//_____________________________________________________________________________ -void StTGeoIter::LocalToMaster(const double* local, double* master) const -{ fNavi->LocalToMaster(local,master);} -//_____________________________________________________________________________ -void StTGeoIter::LocalToMasterVect(const double* local, double* master) const -{ fNavi->LocalToMasterVect(local,master);} -//_____________________________________________________________________________ -void StTGeoIter::LocalToMaster(const float* local, float* master) const -{ - double d[6]; - TCL::ucopy(local,d,3); - fNavi->LocalToMaster(d,d+3); - TCL::ucopy(d+3,master,3); -} -//_____________________________________________________________________________ -void StTGeoIter::LocalToMasterVect(const float* local, float* master) const -{ - double d[6]; - TCL::ucopy(local,d,3); - fNavi->LocalToMasterVect(d,d+3); - TCL::ucopy(d+3,master,3); -} -//_____________________________________________________________________________ -int StTGeoIter::IsOmule() const //candidate to module -{ - assert(fVolu); - const TGeoVolume *vol=0; - int jk=0; - for (int ipar=1; (vol=GetVolu(ipar));ipar++) { - int nDau = vol->GetNdaughters(); - if (ipar==1) {jk |= (nDau==1)? 1:2;} - else {jk |= (nDau==1)? 4:8;} - } - return (jk==6); -} -//_____________________________________________________________________________ -const TGeoVolume *StTGeoProxy::FindModule(const char *patt) -{ - - const TGeoVolume *vol=0,*bestVolu=0; - int bestQua = -1000000; - for (StTGeoIter it;(vol=*it);++it) { - const char *name = vol->GetName(); - if (patt[0]!=name[0]) continue; - if (patt[1]!=name[1]) continue; - int n = 0; - for (;patt[n];n++) { if (name[n]!=patt[n]) break;} - if (n<3) continue; - if (it.GetLev()>5) continue; - int qua = n*100 - it.GetLev(); - if (qua <= bestQua) continue; - bestQua = qua; bestVolu = vol; - } - return bestVolu; -} -//_____________________________________________________________________________ -double StTGeoProxy::Look(double maxDist,const double pnt[3],const double dir[3]) -{ -// Search nearest sensitive volume in given direction. -// returns distance - double myPnt[3]={ pnt[0], pnt[1], pnt[2]}; - double myDir[3]={ dir[0], dir[1], dir[2]}; - - gGeoManager->SetCurrentPoint(myPnt); - const TGeoNode *node = gGeoManager->FindNode(); - if (!node) return 0; - gGeoManager->SetCurrentDirection(myDir); - TString prevPath(gGeoManager->GetPath()); - double myStep = 0,epsStp = 1e-4+maxDist*1e-3,minStp = epsStp,stp=0; - for (int istep=0;istep<100 ;istep++) { - node = gGeoManager->FindNextBoundaryAndStep(1.001*(maxDist-myStep)); - if (!node) break; - TString currPath(gGeoManager->GetPath()); - stp = gGeoManager->GetStep(); - int same = (currPath == prevPath); - if (stpGetCurrentPoint(); - for (int j=0;j<3;j++) { myPnt[j]=x[j]+myDir[j]*stp;} - gGeoManager->SetCurrentPoint(myPnt); - node = gGeoManager->FindNode(); - if (!node) break; - } - myStep +=stp; if (myStep>=maxDist) break; - if (same) continue; - - prevPath=currPath; minStp = epsStp; - if (!IsSensitive()) continue; - StHitPlaneInfo* inf = IsHitPlane(node) ; - if (!inf) continue; - StHitPlane *hp = inf->GetHitPlane(currPath); - if (hp) break; - } - return myStep; -} -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StVoluInfo::StVoluInfo(int voluNumber) -{ SetUniqueID(voluNumber); - fActiveFunctor=0; - fNSens = 0; - StTGeoProxy::fgKount[0]++; -} -//_____________________________________________________________________________ -StVoluInfo::~StVoluInfo() -{ - StTGeoProxy::fgKount[0]--; -} - -//_____________________________________________________________________________ -//_____________________________________________________________________________ -StTGeoHitShape::StTGeoHitShape() -{ - fZMin = 1e11; fZMax = -1e11; fRMin=1e11; fRMax = 0; - for (int i=0;iz1) fZMin=z1; - if (fZMax=fZMin && z1<=fZMax); - assert(z2>=fZMin && z2<=fZMax); - if (fRMin>rxy) fRMin=rxy; - if (fRMaxrxy) fRxy[jj][0]=rxy; - if(fRxy[jj][1]jVtx) {jl = jVtx+1;jr = jE -1;} - else {jl = jE +1;jr = jVtx-1;} - - if (jl>=jr) {jl = jE+1; jr = jVtx-1;} - assert(jlfRxy[j][1]) fRxy[j][1] = r; - } - rE = fRxy[jE][0]; - if (jE>jVtx) {jl = jE+1;jr = kNZ-1;} - else {jl = 0 ;jr = jE -1;} - for (int j=jl; j<=jr; j++) { - double r = rE/(jE-jVtx)*(j-jVtx); - if (rfRxy[j][1]) fRMinMax=fRxy[j][1]; - } - - -} -//_____________________________________________________________________________ -int StTGeoHitShape::Outside(double z,double rxy) const -{ - if (zfZMax) return 2; - if (rxy>fRMinMax && rxy=kNZ) jj=kNZ-1; - if (rxy > fRxy[jj][1]) return 5; - if (rxy < fRxy[jj][0]) return -6; - return 0; -} -//_____________________________________________________________________________ -void StTGeoHitShape::Get(double &zMin,double &zMax,double &rMax) const -{ - zMin = fZMin; zMax = fZMax; zMax = fRMax; -} -//_____________________________________________________________________________ -void StTGeoHitShape::Print(const char *) const -{ -printf("StTGeoHitShape::Print() Zmin = %g Zmax = %g Rmax = %g\n",fZMin,fZMax,fRMax); - for (int j=0;jGetMother(iLev); - copyNums[iLev] = 0; - if (!node) return 1; - copyNums[iLev] = node->GetNumber(); - if (!voluNams) continue; - voluNams[iLev] = node->GetVolume()->GetName(); - } - return 0; -} -//_____________________________________________________________________________ -const char* StActorFunctor::GetPath() const -{ - return gGeoManager->GetPath(); -} -//_____________________________________________________________________________ -const TGeoVolume *StActorFunctor::GetVolu() const -{ - return gGeoManager->GetCurrentVolume(); -} -//_____________________________________________________________________________ -const TGeoNode *StActorFunctor::GetNode() const -{ - return gGeoManager->GetCurrentNode(); -} -//_____________________________________________________________________________ -StVoluInfo *StActorFunctor::GetInfo() const -{ -static StTGeoProxy *tgp = StTGeoProxy::Inst(); -const TGeoVolume *v = tgp->GetVolu(); - int voluId = ::GetVoluId(v); - return tgp->GetInfo(voluId); -} -//_____________________________________________________________________________ -StHitPlaneInfo *StActorFunctor::GetHitPlaneInfo() const -{ -static StTGeoProxy *tgp = StTGeoProxy::Inst(); - const TGeoVolume *v = tgp->GetVolu(); - return tgp->IsHitPlane(v); -} -//_____________________________________________________________________________ -StHitPlane *StActorFunctor::GetHitPlane() const -{ -static StTGeoProxy *tgp = StTGeoProxy::Inst(); - return tgp->GetCurrentHitPlane(); -} -//______________________________________________________________________________ -StvSetLayer::StvSetLayer():StActorFunctor("SetLayer") -{ -} -//______________________________________________________________________________ -int StvSetLayer::operator()( const double *) -{ -static StTGeoProxy *tg = StTGeoProxy::Inst(); - if (!tg->IsSensitive()) return 0; - StHitPlane *hp =tg->GetCurrentHitPlane(); - if (!hp) return 0; - hp->SetLayer(); - return 1; -} - - - - - - - - - - - - - - - - - - - - - -//_____________________________________________________________________________ -//_____________________________________________________________________________ diff --git a/StarVMC/GeoTestMaker/StTGeoProxy.h b/StarVMC/GeoTestMaker/StTGeoProxy.h deleted file mode 100644 index 766c9bd3447..00000000000 --- a/StarVMC/GeoTestMaker/StTGeoProxy.h +++ /dev/null @@ -1,415 +0,0 @@ -// $Id: StTGeoProxy.h,v 1.9 2017/05/02 19:35:06 perev Exp $ -// -// -// Class StTGeoProxy -// ------------------ -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ - - -#ifndef ST_TGEOHELPER_H -#define ST_TGEOHELPER_H -#include -#include -#include "StEnumerations.h" -#include "TString.h" -#include "TNamed.h" -class TObjArray; -class TGeoNavigator; -class TGeoNode; -class TGeoVolume; -class TGeoMedium; -class TGeoMaterial; -class TGeoHMatrix; -class StVoluInfo; -class StTGeoHitShape; -class StTGeoIter; -class StHitPlaneInfo; -class StMultiKeyMap; -class StActorFunctor; - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -struct InvertLtStr -{ -bool operator()(const TString& s1, const TString& s2) const - { - int n1 = s1.Length(),n2 = s2.Length(); - if (n1 != n2) return n1=0; --j) {if (c1[j]!=c2[j]) return (c1[j] StHitPlaneHardMap; -typedef std::pair StHitPlaneHardPair; -typedef StHitPlaneHardMap::const_iterator StHitPlaneHardMapIter; - -class StVoluInfo; -typedef std::map< unsigned int, StVoluInfo*> StVoluInfoMap; -typedef StVoluInfoMap::const_iterator StVoluInfoMapIter; - - -class StVoidArr:public std::vector{}; - - -typedef std::map< const TString, StHitPlane*, InvertLtStr> StHitPlanePathMap; -typedef std::pair StHitPlanePathPair; -typedef StHitPlanePathMap::const_iterator StHitPlanePathMapIter; -typedef float Mtx33F_t[3][3]; - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StVoluInfo : public TObject -{ -public: -enum E_VoluInfo { - kModule = BIT(15), // The volume is a module - kMODULE = BIT(16), // The volume is a module,with ID like TPCE,SVTT - kActive = BIT(17), // The volume is active - kHitted = BIT(18), // The volume has hits under it - kHitPlane = BIT(19)}; // The volume is a Hit plane -public: -enum E_Kind { kVoluInfo=1,kHitPlaneInfo=2}; - - StVoluInfo(int voluNumber); -virtual ~StVoluInfo(); - int IsModule () const {return TestBit(kModule);} - int IsMODULE() const {return TestBit(kMODULE);} - int IsHitPlane() const {return TestBit(kHitPlane);} - int IsActive() const {return TestBit(kActive);} - void SetModule (int s=1) {SetBit(kModule,s) ;} - void SetMODULE (int s=1) {SetBit(kMODULE,s) ;} - void SetHitPlane(int s=1) {SetBit(kHitPlane,s) ;} - void SetActive (int s=1) {SetBit(kActive,s) ;} - void SetActiveFunctor(StActorFunctor *af) - {fActiveFunctor=af ;} - int GetVoluId() const {return GetUniqueID() ;} -const TGeoVolume* GetVolu() const; -const char *GetName() const; -StActorFunctor *GetActiveFunctor() {return fActiveFunctor ;} -virtual int Kind() const {return kVoluInfo ;} - void AddSens() {fNSens++; ;} - int GetSens() {return fNSens; ;} - -protected: -StActorFunctor *fActiveFunctor; -int fNSens; -ClassDef(StVoluInfo,0) // -}; - - - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StHitPlaneInfo : public StVoluInfo -{ -friend class StTGeoProxy; -public: - StHitPlaneInfo(int volId); -virtual ~StHitPlaneInfo(); -void operator=(const StVoluInfo& ext){*((StVoluInfo*)this)=ext;} - int Kind() const {return kHitPlaneInfo;} - int Axis() const {return fAxi;} -const Mtx33F_t &GetDir() const {return fDir;} -const float *GetOrg() const {return fOrg;} - StHitPlane *MakeHitPlane(const StTGeoIter &it,StActorFunctor *act=0); - StHitPlane *GetHitPlane (const TString &path) const; - StHitPlane *RemHitPlane (const TString &path); - void SetAxis(int axi) {fAxi=axi;} - void SetDetId(StDetectorId id) { fDetId=id;} - StDetectorId GetDetId() const { return fDetId;} -void Print(const char* opt="") const; -protected: -StDetectorId fDetId; -int fAxi; -float fOrg[3]; -float fDir[3][3]; -StHitPlanePathMap fHitPlanePathMap; -ClassDef(StHitPlaneInfo,0) // -}; - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StHitPlane : public TNamed -{ -friend class StTGeoProxy; -friend class StHitPlaneInfo; -public: - StHitPlane(const char *path, int volId); -virtual ~StHitPlane(); -void Clear(const char *opt=""); -int InitHits(); -void SetHitErrCalc(TNamed *hitErrCalc) {fHitErrCalc = hitErrCalc;} -TNamed *GetHitErrCalc() const {return (TNamed*)fHitErrCalc;} - -virtual const Mtx33F_t &GetDir(const float *) const {return fDir;} -virtual const float *GetOrg(const float *) const {return fOrg;} -virtual const float *GetPnt() const {return fOrg;} -virtual void AddHit(void *hit,const float xyz[3]); -virtual int Kind() const {return 0;} - int GetVoluId() {return GetUniqueID(); } - void ToLocal(const float xyz[3],float uv[3]) const; - StDetectorId GetDetId() const { return fDetId;} - void SetDetId(StDetectorId id){ fDetId=id;} -int GetNHits() const; -float GetLayer() const { return fNex;} -void SetLayer(); -const StMultiKeyMap *GetHitMap() const {return fHitMap;} -void SetPath(const char *path) { fPath=path; } -const char *GetPath() const { return fPath;} -protected: -char fBeg[1]; -StDetectorId fDetId; -float fOrg[3]; -float fDir[3][3]; -float fNex; //distance to next layer -TNamed *fHitErrCalc; -StMultiKeyMap *fHitMap; -const char *fPath; -char fEnd[1]; - -ClassDef(StHitPlane,0) // -}; -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StHitTube : public StHitPlane -{ -friend class StTGeoProxy; -friend class StHitPlaneInfo; -public: - StHitTube(const char *path, int volId); -virtual ~StHitTube(){;} - -virtual const Mtx33F_t &GetDir(const float *) const ; -virtual const float *GetOrg(const float *) const ; -virtual const float *GetPnt() const {return fPnt;} -virtual int Kind() const {return 1;} -protected: -char fBeg[1]; -float fPnt[3]; -float fRmed; -char fEnd[1]; - -ClassDef(StHitTube,0) // -}; -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StActorFunctor : public TNamed -{ -public: - StActorFunctor(const char *name=""):TNamed(name,""){} -virtual ~StActorFunctor(){} - -virtual int operator()(const double xyz[3]=0)=0; - int Operator (const float xyz[3]); - - int GetIPath(int nLev,int *copyNums,const char **voluNams=0) const; - int GetDetId() const {return mDetId;} - void SetDetId(int det) {mDetId = det ;} - void SetHit(void *hit) {mHit = hit ;} -const char* GetPath() const; -const TGeoVolume *GetVolu() const; -const TGeoNode *GetNode() const; - StVoluInfo *GetInfo() const; - StHitPlaneInfo *GetHitPlaneInfo() const; - StHitPlane *GetHitPlane() const; - -protected: -int mDetId; -void *mHit; -ClassDef(StActorFunctor,0) -}; -inline int StActorFunctor::Operator(const float xyz[3]) -{ - if (!xyz) return (*this)(); - double d[3]={xyz[0],xyz[1],xyz[2]}; - return (*this)(d); -} -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StvSetLayer: public StActorFunctor -{ -public: - StvSetLayer(); - ~StvSetLayer(){} -int operator()(const double xyz[3]=0); -private: - -ClassDef(StvSetLayer,0) -}; - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StTGeoProxy : public TObject -{ - StTGeoProxy(); -virtual ~StTGeoProxy(); - -public: - int Load(const char *geo); - void SetOpt (int opt) {fOpt = opt;} - void Init(int mode=0); - void InitLayers(StDetectorId did=kUnknownId); - void Finish(); - int Edit(StDetectorId did,StActorFunctor *af); - - StVoluInfo *SetModule (const char *voluName,int akt=1); - void InitInfo(); - void InitModuLev(); - - void InitHitShape(); - - void SetHitPlane(const char *moduName,const char *voluName,int axis=1); - void InitHitPlane(StActorFunctor *act=0); - int InitHits(); - void ClearHits(); - void Clear(const char *opt=""); - double Look(double maxDist,const double pnt[3],const double dir[3]); - - int SetHitErrCalc(StDetectorId modId,TNamed *hitErrCalc,StActorFunctor *sel=0); -static StTGeoProxy *Instance(); -static StTGeoProxy *Inst(){return Instance();}; - -public: - void Print(const char *tit=0) const; - void ls(const char* opt="Mmps") const; - void SetInfo (StVoluInfo *ext); - int SetActive (const char *voluName,int act=1,StActorFunctor *af=0); - int SetActive (StDetectorId did,int act=1,StActorFunctor *af=0); -const TGeoVolume *FindModule(const char *patt); - StVoluInfo *SetFlag (const TGeoVolume *volu,StVoluInfo::E_VoluInfo flg,int act=1); - StVoluInfo *IsFlag (const TGeoVolume *volu,StVoluInfo::E_VoluInfo flg) const; - StVoluInfo *IsModule (const TGeoVolume *volu) const; - StVoluInfo *IsModule (const TGeoNode *node) const; - StVoluInfo *IsMODULE (const TGeoVolume *volu) const; - StVoluInfo *IsActive (const TGeoVolume *volu=0) const; - int IsGoodHit () const {return fGoodHit;} - int IsActive (StDetectorId did) const; - int IsHitted (const double X[3]) const; -static int IsSensitive(const TGeoVolume *volu=0); -static StDetectorId DetId(const char *detName); -static const char *DetName(StDetectorId detId); -static const char *ModName(StDetectorId detId); -static int MakeDir(int kode,float dir[3][3]); -static void Summary(); - - - - StVoluInfo *GetInfo (int idx) const; - StVoluInfo *&GetINFO (int idx); -const char *GetPath() const; -const TGeoVolume *GetModu() const; -const TGeoVolume *GetVolu() const; -StVoidArr *GetSeedHits() const {return fSeedHits ;} -StVoidArr *GetAllHits() const {return fAllHits ;} - -StHitPlaneInfo* IsHitPlane(const TGeoVolume *volu) const; -StHitPlaneInfo* IsHitPlane(const TGeoNode *node) const; -StHitPlane * GetCurrentHitPlane (); - - int MayHitPlane (const TGeoVolume *volu) const; - StHitPlaneInfo *MakeHitPlaneInfo(const StTGeoIter &iter); - void AddHitPlane(StHitPlane *pla); - -const StHitPlane *AddHit(void *hit,StDetectorId detId, const float xyz[3],unsigned int hardw,int seed); - StHitPlane *FindHitPlane(const float xyz[3],int &sure); - - -const StTGeoHitShape* GetHitShape() const {return fHitShape;} - void SetHitLoadActor(StActorFunctor *fun) {fHitLoadActor = fun;} - - -static void Test(); -static void Break(int kase); -private: - - -private: -char fBeg[1]; -int fMode; //0=fill infos + hitShape, 1= hit planes -int fOpt; //0=Optimisation Off, !=0= Optimization ON -int fGoodHit; //1=last loaded hit inside of sensitive volume -StDetectorId fDetId; -Long64_t fActiveModu; -StVoluInfoMap *fVoluInfoArr; // array of all StVoluIinfo -TObjArray *fHitPlaneArr; // array of StHitPlane's -StVoidArr *fSeedHits; // Vector for hits used in seed finder -StVoidArr *fAllHits; // Vector of all hits, mainly for debug -StTGeoHitShape *fHitShape; - -// Actor functorss -StActorFunctor *fHitLoadActor; // functor used in AddHit - -char fEnd[1]; -public: -static int fgKount[3]; - -ClassDef(StTGeoProxy,0) // -}; - - -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StTGeoIter -{ -public: - StTGeoIter(); - ~StTGeoIter(); - void Reset(); -StTGeoIter &operator++(); -const TGeoVolume *operator*() const {return fVolu;} -StTGeoIter &Next(); -StTGeoIter &Down(); -StTGeoIter &Upp(); -StTGeoIter &Skip(); - -const TGeoNode *GetNode(int idx=0) const; -const TGeoVolume *GetVolu(int idx=0) const; -const TGeoHMatrix*GetMatr(int idx=0) const; - int GetLev() const {return fLev;} - int GetIdx() const {return (fLev)? fStk[fLev-1]:0;} -const int *GetStk() const {return fStk;} - int IsFirst()const {return fNow ==1;} - int IsLast ()const {return fNow ==2;} - int IsEnd() const {return fVolu==0;} - int IsOmule()const; //candidate to module - int State() const {return fNow;} - void LocalToMaster (const double* local, double* master) const; - void LocalToMasterVect(const double* local, double* master) const; - void LocalToMaster (const float* local, float* master) const; - void LocalToMasterVect(const float* local, float* master) const; - void Print(const char *tit="") const; -const char *GetPath() const; -private: - -private: - int fNow; // 1=first visit,2=last visit,3=first and last visit - int fKase; - int fLev; - int fStk[100]; -TGeoVolume *fVolu; -TGeoNavigator *fNavi; - -}; -// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ -class StTGeoHitShape -{ -public: - StTGeoHitShape(); -void Update(double z1, double z2, double rxy); -void Smooth(double zl=-100, double zr=100); -int Outside(double z,double rxy) const; -void Get(double &zMin,double &zMax,double &rMax) const; -void Print(const char *opt=0) const; - -private: -enum E_Safe {kSafe=110}; // Used Rmax = Rmax*kSafe/100, etc... -enum {kNZ=20}; // Number of Z bins - -private: -double fZMin; -double fZMax; -double fRMin; -double fRMax; -double fZStp; -double fRMinMax; -double fRMaxMin; - -double fRxy[kNZ][2]; -}; -#endif //ST_TGEOHELPER_H - diff --git a/StarVMC/GeoTestMaker/StTProfile2D.cxx b/StarVMC/GeoTestMaker/StTProfile2D.cxx deleted file mode 100644 index efa8eb9e921..00000000000 --- a/StarVMC/GeoTestMaker/StTProfile2D.cxx +++ /dev/null @@ -1,351 +0,0 @@ -#include -#include -#include "StTProfile2D.h" -#include "TROOT.h" -#include "TVirtualHistPainter.h" - -ClassImp(StTProfile2D) -//______________________________________________________________________________ -StTProfile2D::StTProfile2D():TProfile2D() -{ - fPainter = new StTHistPainter(); - fPainter->SetHistogram(this); -} -//______________________________________________________________________________ -StTProfile2D::StTProfile2D(const char* name, const char* title - ,Int_t nbinsx, Double_t xlow, Double_t xup - ,Int_t nbinsy, Double_t ylow, Double_t yup - ,double,double, Option_t* option): - TProfile2D(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup,option) -{ - fPainter = new StTHistPainter(); - fPainter->SetHistogram(this); -} -//______________________________________________________________________________ -TProfile *StTProfile2D::ProfileX(const char *name, Int_t firstybin, Int_t lastybin, Option_t *option) const -{ - // *-*-*-*-*Project a 2-D histogram into a profile histogram along X*-*-*-*-*-* - // *-* ======================================================== - // - // The projection is made from the channels along the Y axis - // ranging from firstybin to lastybin included. - // By default, bins 1 to ny are included - // When all bins are included, the number of entries in the projection - // is set to the number of entries of the 2-D histogram, otherwise - // the number of entries is incremented by 1 for all non empty cells. - // - // if option "d" is specified, the profile is drawn in the current pad. - // - // Using a TCutG object, it is possible to select a sub-range of a 2-D histogram. - // One must create a graphical cut (mouse or C++) and specify the name - // of the cut between [] in the option. - // For example, with a TCutG named "cutg", one can call: - // myhist->ProfileX(" ",firstybin,lastybin,"[cutg]"); - // To invert the cut, it is enough to put a "-" in front of its name: - // myhist->ProfileX(" ",firstybin,lastybin,"[-cutg]"); - // It is possible to apply several cuts ("," means logical AND): - // myhist->ProfileX(" ",firstybin,lastybin,[cutg1,cutg2]"); - // - // NOTE that if a TProfile named name exists in the current directory or pad, - // the histogram is reset and filled again with the current contents of the TH2. - // The X axis attributes of the TH2 are copied to the X axis of the profile. - // - // NOTE2 that the default under- / overflow behavior differs from what ProjectionX - // does! Profiles take the bin center into account, so here the under- and overflow - // bins are ignored by default. - - return DoProfile(true, name, firstybin, lastybin, option); - -} - -//______________________________________________________________________________ -TProfile *StTProfile2D::ProfileY(const char *name, Int_t firstxbin, Int_t lastxbin, Option_t *option) const -{ - // *-*-*-*-*Project a 2-D histogram into a profile histogram along Y*-*-*-*-*-* - // *-* ======================================================== - // - // The projection is made from the channels along the X axis - // ranging from firstxbin to lastxbin included. - // By default, bins 1 to nx are included - // When all bins are included, the number of entries in the projection - // is set to the number of entries of the 2-D histogram, otherwise - // the number of entries is incremented by 1 for all non empty cells. - // - // if option "d" is specified, the profile is drawn in the current pad. - // - // Using a TCutG object, it is possible to select a sub-range of a 2-D histogram. - // One must create a graphical cut (mouse or C++) and specify the name - // of the cut between [] in the option. - // For example, with a TCutG named "cutg", one can call: - // myhist->ProfileY(" ",firstybin,lastybin,"[cutg]"); - // To invert the cut, it is enough to put a "-" in front of its name: - // myhist->ProfileY(" ",firstybin,lastybin,"[-cutg]"); - // It is possible to apply several cuts: - // myhist->ProfileY(" ",firstybin,lastybin,[cutg1,cutg2]"); - // - // NOTE that if a TProfile named name exists in the current directory or pad, - // the histogram is reset and filled again with the current contents of the TH2. - // The Y axis attributes of the TH2 are copied to the X axis of the profile. - // - // NOTE2 that the default under- / overflow behavior differs from what ProjectionX - // does! Profiles take the bin center into account, so here the under- and overflow - // bins are ignored by default. - - return DoProfile(false, name, firstxbin, lastxbin, option); -} -//______________________________________________________________________________ -TProfile *StTProfile2D::DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const -{ - TString opt = option; - - const TAxis& outAxis = ( onX ? fXaxis : fYaxis ); - const TAxis& inAxis = ( onX ? fYaxis : fXaxis ); - Int_t outN = outAxis.GetNbins(); - Int_t inN = inAxis.GetNbins(); - const char *expectedName = ( onX ? "_pfx" : "_pfy" ); - - if (firstbin < 0) firstbin = 1; - if (lastbin < 0) lastbin = inN; - if (lastbin > inN+1) lastbin = inN; - - // Create the profile histogram - char *pname = (char*)name; - if (name && strcmp(name, expectedName) == 0) { - Int_t nch = strlen(GetName()) + 5; - pname = new char[nch]; - sprintf(pname,"%s%s",GetName(),name); - } - TProfile *h1=0; - //check if a profile with identical name exist - TObject *h1obj = gROOT->FindObject(pname); - if (h1obj && h1obj->InheritsFrom("TProfile")) { - h1 = (TProfile*)h1obj; - // tb.d. check if number of bin is consistent ? - h1->Reset(); - } - - Int_t ncuts = 0; - opt.ToLower(); //must be called after MakeCuts - - if (!h1) { - const TArrayD *bins = outAxis.GetXbins(); - if (bins->fN == 0) { - h1 = new TProfile(pname,GetTitle(),outN,outAxis.GetXmin(),outAxis.GetXmax(),option); - } else { - h1 = new TProfile(pname,GetTitle(),outN,bins->fArray,option); - } - } - if (pname != name) delete [] pname; - - // Copy attributes - h1->GetXaxis()->ImportAttributes( &outAxis); - h1->SetLineColor(this->GetLineColor()); - h1->SetFillColor(this->GetFillColor()); - h1->SetMarkerColor(this->GetMarkerColor()); - h1->SetMarkerStyle(this->GetMarkerStyle()); - - // - // Fill the profile histogram - Double_t cont; - for (Int_t outBin =0;outBin<=outN+1;outBin++) { - for (Int_t inBin=firstbin;inBin<=lastbin;inBin++) { - Int_t& binx = (onX ? outBin : inBin ); - Int_t& biny = (onX ? inBin : outBin ); - if (ncuts) { - if (!fPainter->IsInside(binx,biny)) continue; - } - cont = GetCellContent(binx,biny); - int bin = biny*(fXaxis.GetNbins()+2) + binx; - double ent = fBinEntries.fArray[bin]; - if (ent <=0.) continue; - h1->Fill(outAxis.GetBinCenter(outBin),cont/ent,ent ); - } - } - if ((firstbin <=1 && lastbin >= inN) && !ncuts) h1->SetEntries(fEntries); - - return h1; -} -//______________________________________________________________________________ -void StTProfile2D::SupressZeros(double minZ) -{ - int nBinX = fXaxis.GetNbins(); - int nBinY = fYaxis.GetNbins(); - for (int ix = 1;ix<=nBinX;ix++) { - for (int iy = 1;iy<=nBinY;iy++) { - if (fabs(GetBinContent(ix,iy)) >minZ) continue; - SetBinContent(ix,iy,0.); - SetBinError (ix,iy,0.); - } } -} -//______________________________________________________________________________ -//______________________________________________________________________________ -//______________________________________________________________________________ -#include "Riostream.h" -#include "TROOT.h" -#include "TClass.h" -#include "TSystem.h" -#include "THistPainter.h" -#include "TH3.h" -#include "TH2.h" -#include "TF2.h" -#include "TF3.h" -#include "TCutG.h" -#include "TMatrixDBase.h" -#include "TMatrixFBase.h" -#include "TVectorD.h" -#include "TVectorF.h" -#include "TPad.h" -#include "TPaveStats.h" -#include "TFrame.h" -#include "TLatex.h" -#include "TLine.h" -#include "TPolyLine.h" -#include "TPoints.h" -#include "TStyle.h" -#include "TGraph.h" -#include "TPie.h" -#include "TGaxis.h" -#include "TColor.h" -#include "TPainter3dAlgorithms.h" -#include "TGraph2DPainter.h" -#include "TGraphDelaunay.h" -#include "TView.h" -#include "TMath.h" -#include "TRandom.h" -#include "TObjArray.h" -#include "TVectorD.h" -#include "Hoption.h" -#include "Hparam.h" -#include "TPluginManager.h" -#include "TPaletteAxis.h" -#include "TCrown.h" -#include "TVirtualPadEditor.h" -#include "TEnv.h" -#include "TPoint.h" - -ClassImp(StTHistPainter) - -extern Hoption_t Hoption; -extern Hparam_t Hparam; -//______________________________________________________________________________ -void StTHistPainter::PaintColorLevels(Option_t *) -{ - /* Begin_html - Control function to draw a 2D histogram as a color plot. - End_html */ - - Double_t z, zc, xk, xstep, yk, ystep, xlow, xup, ylow, yup; - - Double_t zmin = fH->GetMinimum(); - Double_t zmax = fH->GetMaximum(); - if (Hoption.Logz) { - if (zmin > 0) { - zmin = TMath::Log10(zmin); - zmax = TMath::Log10(zmax); - } else { - return; - } - } - - Double_t dz = zmax - zmin; - - if (dz <= 0) return; - - Style_t fillsav = fH->GetFillStyle(); - Style_t colsav = fH->GetFillColor(); - fH->SetFillStyle(1001); - fH->TAttFill::Modify(); - - // Initialize the levels on the Z axis - Int_t ncolors = gStyle->GetNumberOfColors(); - Int_t ndiv = fH->GetContour(); - if (ndiv == 0 ) { - ndiv = gStyle->GetNumberContours(); - fH->SetContour(ndiv); - } - Int_t ndivz = TMath::Abs(ndiv); - if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv); - Double_t scale = ndivz/dz; - - Int_t color; - for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) { - yk = fYaxis->GetBinLowEdge(j); - ystep = fYaxis->GetBinWidth(j); - if (Hoption.System == kPOLAR && yk<0) yk= 2*TMath::Pi()+yk; - for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) { - Int_t bin = j*(fXaxis->GetNbins()+2) + i; - xk = fXaxis->GetBinLowEdge(i); - xstep = fXaxis->GetBinWidth(i); - if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue; - z = fH->GetBinContent(bin); -//VP if (z == 0 && (zmin >= 0 || Hoption.Logz)) continue; // don't draw the empty bins for histograms with positive content - if (z == 0 && (fH->GetBinError(bin) <=0 || Hoption.Logz)) continue; // don't draw the empty bins for histograms with positive content - if (Hoption.Logz) { - if (z > 0) z = TMath::Log10(z); - else z = zmin; - } - if (z < zmin) continue; - xup = xk + xstep; - xlow = xk; - if (Hoption.Logx) { - if (xup > 0) xup = TMath::Log10(xup); - else continue; - if (xlow > 0) xlow = TMath::Log10(xlow); - else continue; - } - yup = yk + ystep; - ylow = yk; - if (Hoption.System != kPOLAR) { - if (Hoption.Logy) { - if (yup > 0) yup = TMath::Log10(yup); - else continue; - if (ylow > 0) ylow = TMath::Log10(ylow); - else continue; - } - if (xup < gPad->GetUxmin()) continue; - if (yup < gPad->GetUymin()) continue; - if (xlow > gPad->GetUxmax()) continue; - if (ylow > gPad->GetUymax()) continue; - if (xlow < gPad->GetUxmin()) xlow = gPad->GetUxmin(); - if (ylow < gPad->GetUymin()) ylow = gPad->GetUymin(); - if (xup > gPad->GetUxmax()) xup = gPad->GetUxmax(); - if (yup > gPad->GetUymax()) yup = gPad->GetUymax(); - } - - if (fH->TestBit(TH1::kUserContour)) { - zc = fH->GetContourLevelPad(0); - if (z < zc) continue; - color = -1; - for (Int_t k=0; kGetContourLevelPad(k); - if (z < zc) { - continue; - } else { - color++; - } - } - } else { - color = Int_t(0.01+(z-zmin)*scale); - } - - Int_t theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz)); - if (theColor > ncolors-1) theColor = ncolors-1; - fH->SetFillColor(gStyle->GetColorPalette(theColor)); - fH->TAttFill::Modify(); - if (Hoption.System != kPOLAR) { - gPad->PaintBox(xlow, ylow, xup, yup); - } else { - TCrown crown(0,0,xlow,xup,ylow*TMath::RadToDeg(),yup*TMath::RadToDeg()); - crown.SetFillColor(gStyle->GetColorPalette(theColor)); - crown.Paint(); - } - } - } - - if (Hoption.Zscale) PaintPalette(); - - fH->SetFillStyle(fillsav); - fH->SetFillColor(colsav); - fH->TAttFill::Modify(); - -} diff --git a/StarVMC/GeoTestMaker/StTProfile2D.h b/StarVMC/GeoTestMaker/StTProfile2D.h deleted file mode 100644 index f5521ef6dad..00000000000 --- a/StarVMC/GeoTestMaker/StTProfile2D.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef STTPROFILE2D_H -#define STTPROFILE2D_H -#include "THistPainter.h" - -#include "TProfile2D.h" - -class StTProfile2D: public TProfile2D -{ -public: -StTProfile2D(); -StTProfile2D(const char* name, const char* title - , Int_t nbinsx, Double_t xlow, Double_t xup - , Int_t nbinsy, Double_t ylow, Double_t yup - , double zMin=0, double zMax=0 - ,const char* option = ""); -TProfile* ProfileX(const char* name = "_pfx", Int_t firstybin = 1, Int_t lastybin = -1, Option_t* option = "") const; -TProfile* ProfileY(const char* name = "_pfy", Int_t firstxbin = 1, Int_t lastxbin = -1, Option_t* option = "") const; -void SupressZeros(double minZ=1e-10); -private: -TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const; - -ClassDef(StTProfile2D,0) -}; - -class StTHistPainter: public THistPainter -{ -public: - StTHistPainter():THistPainter() {;} - ~StTHistPainter(){;} - void PaintColorLevels(Option_t *); -protected: -ClassDef(StTHistPainter,0) -}; - -#endif //STTPROFILE2D_H diff --git a/StarVMC/GeoTestMaker/StVMCApplication.cxx b/StarVMC/GeoTestMaker/StVMCApplication.cxx deleted file mode 100644 index 7c69f775e63..00000000000 --- a/StarVMC/GeoTestMaker/StVMCApplication.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// $Id: StVMCApplication.cxx,v 1.4 2011/05/04 17:46:41 perev Exp $ -// Class StVMCApplication -// ----------------------- -// Implementation of the TVirtualMCApplication -#include -#include "StVMCApplication.h" -#include "GCall.h" -#include "TGeoManager.h" -#include "TROOT.h" -#include "TPDGCode.h" -#include "TGeant3TGeo.h" -#include "StMCStack.h" -ClassImp(StVMCApplication); - -//_____________________________________________________________________________ -StVMCApplication::StVMCApplication(const char *name, const char *title) -{ - SetName(name); SetTitle(title); - memset(mBeg,0,mEnd-mBeg+1); - mRmax = 3e33; mZmax=3e33; -} -//_____________________________________________________________________________ -StVMCApplication::~StVMCApplication() -{ // Destructor -} -//_____________________________________________________________________________ -int StVMCApplication::Trig(int nTrig) -{ - return gMC->ProcessRun(nTrig); -} -//_____________________________________________________________________________ -int StVMCApplication::Init() -{ - if (mInit) (*mInit)(); - SetDebug(mDebug); - return 0; -} -//_____________________________________________________________________________ -void StVMCApplication::Stepping() -{ - (*mStepping)(); -} -//_____________________________________________________________________________ -void StVMCApplication::GeneratePrimaries() -{ - (*mPrimaryGenerator)(); -} -//_____________________________________________________________________________ -void StVMCApplication::ConstructGeometry() -{ // Initialize geometry - if (mConstructGeometry) (*mConstructGeometry)(); -} -//_____________________________________________________________________________ -void StVMCApplication::InitGeometry() -{ - if (mInitGeometry) (*mInitGeometry)(); -} -//_____________________________________________________________________________ -void StVMCApplication::BeginEvent() -{ -// User actions at beginning of event - if (mBeginEvent) (*mBeginEvent)(); -} -//_____________________________________________________________________________ -void StVMCApplication::BeginPrimary() -{ -// User actions at beginning of a primary track - if (mBeginPrimary) (*mBeginPrimary)(); -} -//_____________________________________________________________________________ -void StVMCApplication::PreTrack() -{ -// User actions at beginning of each track - if (mPreTrack) (*mPreTrack)(); -} -//_____________________________________________________________________________ -void StVMCApplication::PostTrack() -{ -// User actions after finishing of each track - if (mPostTrack) (*mPostTrack)(); -} -//_____________________________________________________________________________ -void StVMCApplication::FinishPrimary() -{ -// User actions after finishing of a primary track - if (mFinishPrimary) (*mFinishPrimary)(); -} -//_____________________________________________________________________________ -void StVMCApplication::FinishEvent() -{ -// User actions after finishing of an event - if (mFinishEvent) (*mFinishEvent)(); -} -//_____________________________________________________________________________ -void StVMCApplication::Field(const double* x, double* b) const -{ - if (mField) { (*mField)(x,b);} - else {b[0]=0;b[1]=0;b[2]=5;} -} -//________________________________________________________________________________ -void StVMCApplication::SetDebug(int l) -{ - mDebug = l; - TGeant3TGeo *g3g = (TGeant3TGeo*)gMC; - if (!g3g) return; - - g3g->Gcflag()->idebug = mDebug ; - g3g->Gcflag()->itest = mDebug ? 100:0 ; - if (mDebug > 1) { - g3g->SetDEBU(1,1,100); - g3g->SetSWIT(1,2); - g3g->SetSWIT(2,2); - } else { - g3g->SetSWIT(4,0); - } -} diff --git a/StarVMC/GeoTestMaker/StVMCApplication.h b/StarVMC/GeoTestMaker/StVMCApplication.h deleted file mode 100644 index 445389ddf1e..00000000000 --- a/StarVMC/GeoTestMaker/StVMCApplication.h +++ /dev/null @@ -1,92 +0,0 @@ -// $Id: StVMCApplication.h,v 1.4 2017/05/02 19:34:04 perev Exp $ -// Class StVMCApplication -// ----------------------- -// Implementation of the TVirtualMCApplication -// -#include "TVirtualMCApplication.h" -#ifndef StMC_APPLICATION_H -#define StMC_APPLICATION_H - -class GCall; - -class StVMCApplication : public TVirtualMCApplication -{ - public: - StVMCApplication(const char* name=0, const char *title=0); - virtual ~StVMCApplication(); - int Init(); - int Trig(int nTrig=1); - - virtual void GeneratePrimaries(); - virtual void Stepping(); - virtual void ConstructGeometry(); - virtual void InitGeometry(); - virtual void BeginEvent(); - virtual void BeginPrimary(); - virtual void PreTrack(); - virtual void PostTrack(); - virtual void FinishPrimary(); - virtual void FinishEvent(); - virtual void Field(const double* x, double* b) const; - virtual void AddParticles() {} -//functions setters - void SetInit (GCall* gc) { mInit =gc;} - void SetStepping (GCall *gc) { mStepping =gc;} - void SetPrimaryGenerator (GCall* gc) { mPrimaryGenerator =gc;} - void SetConstructGeometry(GCall* gc) { mConstructGeometry=gc;} - void SetInitGeometry (GCall* gc) { mInitGeometry =gc;} - void SetBeginEvent (GCall* gc) { mBeginEvent =gc;} - void SetBeginPrimary (GCall* gc) { mBeginPrimary =gc;} - void SetPreTrack (GCall* gc) { mPreTrack =gc;} - void SetPostTrack (GCall* gc) { mPostTrack =gc;} - void SetFinishPrimary (GCall* gc) { mFinishPrimary =gc;} - void SetFinishEvent (GCall* gc) { mFinishEvent =gc;} - void SetField (GCall* gc) { mField =gc;} - void SetDebug (int db=1); - -//functions getters - GCall *GetInit () { return mInit ;} - GCall *GetStepping () { return mStepping ;} - GCall *GetPrimaryGenerator () { return mPrimaryGenerator ;} - GCall *GetConstructGeometry() { return mConstructGeometry;} - GCall *GetInitGeometry () { return mInitGeometry ;} - GCall *GetBeginEvent () { return mBeginEvent ;} - GCall *GetBeginPrimary () { return mBeginPrimary ;} - GCall *GetPreTrack () { return mPreTrack ;} - GCall *GetPostTrack () { return mPostTrack ;} - GCall *GetFinishPrimary () { return mFinishPrimary ;} - GCall *GetFinishEvent () { return mFinishEvent ;} - GCall *GetField () { return mField ;} - void SetRZmax(double rMax,double zMax) { mRmax=rMax;mZmax=zMax; } - - virtual double TrackingRmax() const { return mRmax; } - virtual double TrackingZmax() const { return mZmax; } - virtual int Debug() const { return mDebug;} - - private: -// methods -// data members - - char mBeg[1]; - int mDebug; - int mNStepping; - double mRmax; - double mZmax; - GCall* mInit; - GCall* mStepping; - GCall* mPrimaryGenerator; - GCall* mConstructGeometry; - GCall* mInitGeometry; - GCall* mBeginEvent; - GCall* mBeginPrimary; - GCall* mPreTrack; - GCall* mPostTrack; - GCall* mFinishPrimary; - GCall* mFinishEvent; - GCall* mField; - char mEnd[1]; - -ClassDef(StVMCApplication,0) //Interface to MonteCarlo application -}; - -#endif //StMC_APPLICATION_H diff --git a/StarVMC/GeoTestMaker/StiELossTrk.cxx b/StarVMC/GeoTestMaker/StiELossTrk.cxx deleted file mode 100644 index 62306a2d0e1..00000000000 --- a/StarVMC/GeoTestMaker/StiELossTrk.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// $Id: StiELossTrk.cxx,v 1.2 2009/10/13 17:19:35 perev Exp $ -// -// -// Class StiELossTrk -// ------------------ -#include -#include -#include -#include "StiELossTrk.h" -ClassImp(StiELossTrk) - -//_____________________________________________________________________________ -void StiELossTrk::Reset() -{ - memset(fBeg,0,fEnd-fBeg+1); - Set(1.,PiMASS); -} -//_____________________________________________________________________________ -void StiELossTrk::Set(double p2,double mass) -{ - fP2=p2; fMas2 = mass*mass; - fFak = (14.1*14.1*(fP2+fMas2))/(fP2*fP2*1e6); -} -//_____________________________________________________________________________ -void StiELossTrk::Add(double len,double x0) -{ - fMCS[0] += len/x0; - fMCS[1] -= len*len/x0; - fMCS[2] += len*len*len/(3*x0); - fTotLen += len; -} -//_____________________________________________________________________________ -double StiELossTrk::GetTheta2() const -{ - assert(fFak>0); - return fFak*fMCS[0]; -} -//_____________________________________________________________________________ -double StiELossTrk::GetOrt2() const -{ - assert(fFak>0); - return fFak*(fMCS[2]+fTotLen*(fMCS[1]+fTotLen*fMCS[0])); -} -//_____________________________________________________________________________ -void StiELossTrk::GetCoef(double coe[3]) const -{ - for (int i=0;i<3;i++) {coe[i]=fFak*fMCS[i];} -} -//_____________________________________________________________________________ -double StiELossTrk::GetOrt2(double coe[3],double len) -{ - return (coe[2]+len*(coe[1]+len*coe[0])); -} diff --git a/StarVMC/GeoTestMaker/StiELossTrk.h b/StarVMC/GeoTestMaker/StiELossTrk.h deleted file mode 100644 index c74d4225451..00000000000 --- a/StarVMC/GeoTestMaker/StiELossTrk.h +++ /dev/null @@ -1,36 +0,0 @@ -// $Id: StiELossTrk.h,v 1.2 2009/10/13 17:19:35 perev Exp $ -// -// -// Class StiELossTrk -// ------------------ - - -#ifndef STIELOSSTRK_H -#define STIELOSSTRK_H -#include "TObject.h" - -static const double PiMASS=0.13956995; - class StiELossTrk : public TObject -{ -public: - StiELossTrk(){Reset();} - ~StiELossTrk(){;} - void Reset(); - void Set(double p2,double mass = PiMASS); - void Add(double len,double x0); - double GetTheta2() const; - double GetOrt2() const; - void GetCoef(double coe[3]) const; -static double GetOrt2(double coe[3],double len) ; -private: -char fBeg[1]; -double fP2; -double fMas2; -double fFak; -double fTotLen; -double fMCS[3]; -char fEnd[1]; -ClassDef(StiELossTrk,0) -}; -#endif //STIELOSSTRK_H -