//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Class to align tpc with respect to external tracks // // // Environment: // Software NOT developed for the PANDA Detector at FAIR. // // Author List: // Alexander Schmah TUM (original author) // Maxence Vandenbroucke TUM (author) // Francesco Cusanno TUM (author) // Sverre Doerheim TUM (author, rewrite from macro to compiled object) // // //----------------------------------------------------------- #ifndef TpcAlignmentSimple_H #define TpcAlignmentSimple_H #include #include #include #include #include #include #include #include #include #include "TpcResidual.h" #include "TpcSimpleResidual.h" #include "TpcAlignmentManager.h" #include "TpcRefGFTrkResCalc.h" #include "AbsChi2.h" class TpcAlignmentSimple : public TObject, public AbsChi2 { public: TpcAlignmentSimple(); //Sets the ranges of relevant histograms void setMaxRes(double res){maxRes=res;} void setMaxResXY(double res){maxResXY=res;} void setMaxResZ(double res){maxResZ=res;} void setRangeXY(double range){rangeXY=range;} void setAlignmentFile(TString alfile){alignmentFile=alfile;} static void setDetectorName(std::string name){detectorName=name;} void setInputChain(TChain* chain){inputChain=chain;} void setMaxEvents(int nEv){maxEvents=nEv;} void setTpcTrackBranchName(std::string name){tpcTrackBranchName=name;} void setCdcTrackBranchName(std::string name){cdcTrackBranchName=name;} void setCdcGFTrackBranchName(std::string name){cdcGFTrackBranchName=name;} void setCdcGFHitBranchName(std::string name){cdcGFHitBranchName=name;} void setTpcClusterBranchName(std::string name){tpcClusterBranchName=name;} void setShieldPointBranchName(std::string name){tpcShieldPointBranchName=name;} void setCdcHitBranchName(std::string name){cdcHitBranchName=name;} //Settings and options //Set the residual calculator, needs to be called before init! void setResCalculatior(AbsRefTrackResCalc* rc,std::string name){residualCalculator=rc;resCalcName=name;} //for testing, no alignment, only residual calculations void setTestRun(bool opt){testRun=opt;} //only valid for test run, stores residuals void setStore(bool opt){storeResiduals=opt;} //turn on/of charge filtering // chargefilter<0 : only negative tracks // chargefilter>0 : only positive tracks // chargefilter==0 : all tracks void setChargeFiltering(int chargeFilter){chargeFiltering=chargeFilter;} //turn on BAT, replaces minuit with bat, default ist using MCMC void setUseBAT(bool opt=true){fUseBat=opt;} void setBatPars(double batItMin, double batItMax,double batItUpdate, int batNChains){ fBatItMin=batItMin; fBatItMax=batItMax; fBatItUpdate=batItUpdate; fBatNChains=batNChains; } //If BAT is used, enable Simulated anhealing instead of MCMC void setBatSimAn(bool bla =true){fBatSimAn=bla;} //Uses direction of track at the POCA to recalculate Residual void trackUseLinearization(bool opt=true){fUseTrackLinearization=opt;} //Turns on shifting of the center of rotation during the minimization static void setUseShiftRotation(bool bla=true){fuseShiftedRotation=bla;} //Changes the shift witch is used if the previous option is set, default 50 cm static void setRotationShift(double z){fshift=z;} void setAutoRotationShift(bool opt=true){fAutoRotationShift=opt;} // static void setUse3DResiduals(bool opt=true){fUse3DResidual=opt;} //Main methods //Initializes everything, TCA, branches, histograms+++ bool init(); void initHistos(); void fillHistos(const TpcResidual* theRes, const TVector3 pos20, const TVector3 mom20); bool execute(); void writeHistos(); void setHistOutFileName(std::string outfile){fHistoFileName=outfile;} //Static methods, chisquare function static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); //to be minimized virtual double chisquare(int npar,double * pars); virtual void getRealParameters(const std::vector pars,double* realpars); static void setVerbose(int verbose = 1){fVerbose=verbose;} private: static TpcAlignmentSimple* lol; static TStopwatch clock; static int nCallsFcn; static int fVerbose; static bool fuseShiftedRotation; static double fshift; static bool fUseTrackLinearization; static bool fUse3DResidual; static bool fUse2DResidual; static std::string detectorName; static std::string alignmentFile; static std::vector fResiduals; static std::vector fSimpleResiduals; //Used when storing resiudals to file static TClonesArray fTCResiduals; static double meanZ; TString oldtpcxyz; TVector3 inititalTpcPos; double initialPhi; double initialTheta; double initialPsi; //variables needed caching in the chi2 method, not used static double phi_,theta_,psi_; static double dphi_,dtheta_,dpsi_; double xyzPhi, xyzTheta, xyzPsi; static double firstChiSq; static TVector3 tpcpos_; static TVector3 dtpcpos_; static TGeoCombiTrans* lastTransP1P2; static bool printChi2; bool fBatSimAn; bool fUseBat; double fBatItMax; double fBatItMin; double fBatItUpdate; int fBatNChains; bool fAutoRotationShift; //histoRanges double maxRes; double maxResXY; double maxResZ; double rangeXY; double rangeZ; //double meanZ; int zSlices; double zStart; double zEnd; std::string cdcTrackBranchName; std::string cdcGFTrackBranchName; std::string cdcGFHitBranchName; std::string cdcHitBranchName; std::string tpcTrackBranchName; std::string tpcClusterBranchName; std::string tpcShieldPointBranchName; std::string fopiTupleBranchName; std::string fopiTrackBranchName; std::string tpcEventHeaderBranchName; TClonesArray* cdcTracks; TClonesArray* cdcGFTracks; TClonesArray* cdcGFHits; TClonesArray* cdcHits; TClonesArray* tpcClusters; TClonesArray* tpcSPHits; TClonesArray* tpcTracks; TClonesArray* shieldPoints; TClonesArray* mcTracks; TClonesArray* trackTuples; TClonesArray* fopiTracks; TClonesArray* tpcEventHeaders; std::map fBranches; TpcAlignmentManager* alMan; TChain* inputChain; AbsRefTrackResCalc* residualCalculator; std::string resCalcName; int maxEvents; bool storeResiduals; std::string residualFile; int chargeFiltering;// positive value= positive tracks, negative = negative, 0 all std::map hists; std::map histDirName; std::map chi2Hists; TFile* fHistoFile; TString fHistoFileName; bool testRun; TFile* fchi2HistFile; void writeChiSqHists(TString filename="test_1234.root"); public: ClassDef(TpcAlignmentSimple,1) }; #endif // TpcAlignmentSimple_H