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

CDAnalysis.h

Go to the documentation of this file.
00001 
00002 
00003 // Program name: CDAnalysis.h 
00004 //                                                                     
00005 // Package: CalDetTracker
00006 //                                                                    
00007 // Coded by Jeff Hartnell Jul/2003-Jul/2004       
00008 //                                                                    
00009 // Purpose: To provide a framework for analysis of CalDet data and
00010 //          some standard analysis plots.
00011 //                                                                    
00012 // Contact: jeffrey.hartnell@physics.ox.ac.uk                         
00014 
00015 #ifndef CDANALYSIS_H
00016 #define CDANALYSIS_H
00017 
00018 #include <map>
00019 #include <string>
00020 #include <vector>
00021 #include <fstream>
00022 
00023 class TChain;
00024 class TClonesArray;
00025 class TFile;
00026 class TGraph;
00027 class TProfile;
00028 class TVector3;
00029 
00030 #include "Conventions/SimFlag.h"
00031 class MuEnergyLoss;
00032 
00033 class CDTrackedHitInfo;
00034 class CDXTalkHitInfo;
00035 class CDTrackerOptions;
00036 class CDTrackInfo;
00037 class CDPIDInfo;
00038 
00039 class CDAnalysis : public TObject
00040 {
00041  public:  
00042   
00043   CDAnalysis();
00044   ~CDAnalysis();
00045 
00046   //the analysis methods
00047   void CleanMuons();
00048   void Bb() const;
00049   void BbVsGminos();
00050   void BbEnVsRange() const;
00051   void BbThkFeVsRange() const;
00052   void ElectronResponse();
00053   void MuonCalorimetry();
00054   void MuonNearFar();
00055   void MuonResponse();
00056   void MuonSampleCuts();
00057   void MuonScatter();
00058   void MuonStVsPl();
00059   void PrintEvent(Int_t event);
00060   void PrintPIDStats();
00061   void StoppingMuonCalibration();//the one to get results from!
00062   void Template();
00063   void Template2();
00064   void TruthAnalysis();
00065   void TruthEnDep();
00066   void TruthEnDepFe();
00067   void TruthEventLength();
00068   void ValidateMC();
00069   void ValidateReco();
00070   void ValidatePIDInfo();
00071   void ValidateTrkHits();
00072   void ValidateTruth();
00073   void ValidateUnTrkHits();
00074   void ValidateXTalkHits();
00075  
00076   //this function allows an input file to be specified before 
00077   //constructing the object
00078   static void InputFileName(std::string f);
00079 
00080   //methods that do not modify the object
00081   TGraph* TGraphMap(const std::map<Int_t,Float_t>& m) const;
00082   TGraph* TGraphVect(const std::vector<Double_t>& vX,
00083                      const std::vector<Double_t>& vY) const;
00084   void TGraphMinMax(std::vector<TGraph*>& v) const;
00085   Int_t Rnd(Double_t x) const;
00086   void WriteOutHistos() const;
00087   Int_t RunNumber2RunPeriod(Int_t run) const;
00088   Int_t SumMapValues(const std::map<Int_t,Int_t>& mapIn) const;
00089 
00090  private:
00091 
00092   static std::string fInputFileName;
00093 
00094   //non-const methods
00095   void CalcAvStripForPSMuonCut(Int_t plane,Int_t strip,Int_t end);
00096   void CalcFirstLastPlane(Int_t plane);
00097   void CalcLastPlaneOnTrk();
00098   void CalcLowUpScint_TofDiff(Double_t time);
00099   void CalcNumPlanesHit(Int_t plane,Float_t pe);
00100   void CalcNumPlanesHitTrk(Int_t plane);
00101   void InitialiseLoopVariables();
00102   void InitialisePidVariables();
00103   void InitialiseHitInfoVariables();
00104   void MakeChain();
00105   void ReadInHitInfo(CDTrackedHitInfo* hitInfo);
00106   void ReadInHitInfo(CDXTalkHitInfo* hitInfo);
00107   void SetLoopVariables(Int_t entry);
00108   void SetRatioScEnToBeamEn();
00109   void SetRootFileObjects();
00110   void SetScEnDepPerMEU();
00111   void SetSigCorPerMEU();
00112 
00113   //const methods 
00114   Float_t CalcDistToPlaneCentre(Int_t strip,Float_t transPos) const;
00115   Int_t CalcLastPlaneOnTrkNoXTalk() const;
00116   Int_t CalcLastPlaneTruth() const;
00117   Double_t CalcMeuPLCorrected(std::map<Int_t,Float_t> plEnDep,
00118                               std::map<Int_t,Float_t> plPLCor,
00119                               Int_t event,
00120                               Float_t* GeVPerMeu) const;
00121   Float_t CalcPathLengthCorection(const TVector3& end1,
00122                                   const TVector3& end2) const;
00123   Bool_t CalcPLCor(const std::map<Int_t,TVector3>& mPlPos,
00124                    std::map<Int_t,Float_t>& mPLCor) const;
00125   void CalcXorYandZ(Int_t strip,Int_t plane,
00126                     Float_t& x,Float_t& y,Float_t& z) const;
00127   Bool_t CalcXYZ(std::map<Int_t,TVector3>& mPlPos) const;
00128   Bool_t CutByHandOnEventLength() const;
00129   Bool_t CutOnPSMuons() const;
00130   Bool_t CutByHandOnPid() const;//uses handmade cuts
00131   Bool_t CutByHandOnPidForElec() const;
00132   Bool_t CutOnBadCalorimetry(Int_t plane,Int_t strip,Int_t end) const;
00133   Bool_t CutOnBadPedestals(Int_t plane,Int_t strip,Int_t end) const;
00134   Bool_t CutOnDeadChips() const;
00135   Bool_t CutOnEventLength() const;
00136   Bool_t CutOnEventLengthForElec() const;
00137   Bool_t CutOnFiducialVolume() const;
00138   Bool_t CutOnNumHitsPerPlane() const;
00139   Bool_t CutOnNumHitsPerPlane10() const;
00140   Bool_t CutOnNumPlanesHit(Int_t planesHit) const;
00141   Bool_t CutOnOverlap() const;
00142   Bool_t CutOnOverlapForElec() const;
00143   Bool_t CutOnPid() const;//uses auto pid cuts
00144   Bool_t CutOnPidForElec() const;
00145   Bool_t CutOnScint_TofDiff() const;
00146   Bool_t CutOnTrackQuality(Bool_t requireGoodTrack=true) const;
00147   Double_t dE_dxIterative(MuEnergyLoss& mat,
00148                           Double_t energyRemaining,
00149                           Double_t totalThk,Double_t rho,
00150                           Double_t energyCutOff,Int_t slices) const;
00151   void DrawResponsePlot(std::string& title,TProfile* prof,
00152                         TProfile* profX,TProfile* profT,
00153                         const std::map<Int_t,Float_t>& num,
00154                         const std::map<Int_t,Float_t>& numX,
00155                         const std::map<Int_t,Float_t>& numT,
00156                         std::string sXTitle="") const;
00157   void FillProfHisto(TProfile* prof,std::map<Int_t,Float_t>& counter,
00158                      const std::map<Int_t,Float_t>& addMe,
00159                      Int_t offset=0) const;
00160   void FillEnVsDist(std::map<Int_t,Float_t> plEnDep,
00161                     std::map<Int_t,Float_t> plPLCor,Int_t event) const;
00162   void FlipVector(std::vector<Double_t>& v) const;
00163   void GetEvLenMinMax(Int_t& minPlane,Int_t& maxPlane) const;
00164   Int_t GetEventLength() const;
00165   void GetLowUpTimeCuts(Float_t& lowTime,Float_t& upTime) const;
00166   Double_t GetMainParticleEnergy() const;
00167   Double_t GetGreatestMainParticleEnergy(Int_t nEvents=200) const;
00168   Bool_t IsDoubleEnded(Int_t inplane) const;
00169   Bool_t IsGenuineOrXTalk(Int_t inplane) const;
00170   Bool_t IsPlaneGenuine(Int_t inplane) const;
00171   Bool_t IsPlaneSideHit(Int_t inplane,Int_t stripend) const;
00172   Bool_t IsPlaneXTalkOnly(Int_t inplane) const;
00173   Bool_t IsSharedPmtHit(Int_t inplane) const;
00174   Bool_t IsStraightTrack(Double_t mainX1Cut) const;
00175   Bool_t IsStraightTrack_Radius(Double_t radiusCut) const;
00176   std::vector<std::string> MakeFileList();
00177   void NormaliseVector(std::vector<Double_t>& v,Int_t mode=1) const;
00178   TFile* OpenFile(Int_t runNumber,std::string prefix="");
00179   ofstream* OpenTxtFile(Int_t runNumber,std::string prefix);
00180   std::string Pct(Double_t top,Double_t bottom) const;
00181   void PrintBasicInfo(std::string="") const;
00182   Float_t ReCalibrate(Float_t chargeAdc,Int_t plane,
00183                       Int_t strip,Int_t stripend) const;
00184   void ScaleMap(std::map<Int_t,Float_t>& m,
00185                 const std::map<Int_t,Float_t>& scaleFactor) const;
00186   void ScaleVector(std::vector<Double_t>& v,Double_t scaleFactor) const;
00187   void StandardSanityChecks() const;
00188   Bool_t StraightTrack_Radius(Double_t radiusCut) const;
00189   Float_t TrueDistToPlaneCentre(Int_t strip,Float_t xInStrFrame) const;
00190   Double_t TrueEnDep(Int_t inplane,Int_t event) const;
00191   Double_t TrueEnDepNotSc(Int_t inplane,Int_t event) const;
00192   void TrueHighLowEn(Float_t& highEn,Float_t& lowEn) const;
00193   Int_t TrueNumDigiScintHits(Int_t inplane,Int_t event) const;
00194   Int_t TrueMuonHunter(Int_t event);
00195   Double_t TrueMainPL(Int_t inplane,Int_t event) const;
00196   void TruePLCor(std::map<Int_t,Float_t>& mPLCor,Int_t event) const;
00197   Float_t TrueXInStripFrame(Int_t plane,Int_t strip,Int_t event) const;
00198 
00199   //data members
00200   TFile* fOutFile;
00201   TChain* fTrackerTree;
00202   TChain* fOptTree;
00203   CDTrackerOptions* fTrkOpt;//tracking options
00204   CDPIDInfo* fPIDInfo;//particle id info
00205   CDTrackInfo* fTrackInfo;
00206   TClonesArray* fTrkHitInfo;
00207   TClonesArray* fUnTrkHitInfo;//unidentified hits
00208   TClonesArray* fXTalkHits;//xtalk hits
00209   TClonesArray* fTruthHitInfo;//the truth of the hits
00210 
00211   Int_t fSnarl;
00212   Int_t fSec;
00213   Int_t fNumDeadChips;
00214   Float_t fTemperature;
00215   Float_t fBeamMomentum;
00216   SimFlag::SimFlag_t fSimFlag;
00217   Int_t fRunNumber;
00218   Int_t fSubRun;
00219   Int_t fStartSnarl;
00220   Int_t fEndSnarl;
00221   Int_t fStartTime;
00222   Int_t fEndTime;
00223   Double_t fMainParticleEnergy;
00224   Int_t fEvents;//number of events in tree
00225 
00226   Int_t fFirstPlane;
00227   Int_t fLastPlane;
00228   Int_t fLastPlaneOdd;
00229   Int_t fLastPlaneEven;
00230   std::map<Int_t,Int_t> fNumPlanesHitTrk;
00231   std::map<Int_t,Int_t> fNumPlanesHitAll;
00232   std::map<Int_t,Int_t> fNumPlanesHit25;
00233   std::map<Int_t,Int_t> fNumPlanesHitPeCut;
00234   std::map<Int_t,Int_t> fNumPlanesHitPeCut10;
00235   Float_t fNumHitsPerPlane;
00236   Float_t fNumHitsPerPlane25;
00237   Float_t fNumHitsPerPlanePeCut10;
00238   Int_t fStripsFromCentrePeCut;
00239 
00240   Float_t fAvStrip;//used to calc av strip in ps muon cut
00241   Float_t fStCount;//number of strips averaged in above
00242   Float_t fAvStrip1;
00243   Float_t fStCount1;
00244   Float_t fAvStrip2;
00245   Float_t fStCount2;
00246 
00247   Float_t fLowScint_Tof;//lowest scintillator-tof time difference in ns
00248   Float_t fUpScint_Tof;//highest scintillator-tof time difference in ns
00249 
00250   //these are the CalDetSI PID system variables
00251   Bool_t fTriggerPMT;            //Did the triggerPMT fire?
00252   Bool_t fFafErr;                //Faf errors?
00253   Bool_t fSparseErr;             //sparse errors?
00254   Int_t fTrigSource;             //trigger source
00255 
00256   Int_t fKovADC1;                //CerenKov ADC value
00257   Int_t fKovTimeStamp1;          //Cerenkov TimeStamp
00258   Int_t fKovADC2;
00259   Int_t fKovTimeStamp2;
00260   Int_t fKovADC3;
00261   Int_t fKovTimeStamp3;
00262 
00263   Int_t fSnarlTimeFrame;         //Event TimeFrame
00264   ULong_t fSnarlMinTimeStamp;  //event minimum timetimestamp
00265   ULong_t fSnarlMaxTimeStamp;  //event maximum timestamp
00266 
00267   Int_t fTofTDC0;                //TOF tdc0 value
00268   Int_t fTofTDC1;                //TOF tdc1 value
00269   Int_t fTofTDC2;                //TOF tdc2 value
00270   Int_t fTofADC0;                //TOF ADC0 value (not always present) 
00271                                //______Context depends on the run
00272   Int_t fTofADC1;                //TOF ADC1 value (not always present) 
00273                                //Used for Tof system testing
00274   Int_t fTofADC2;                //TOF ADC1 value (not always present) 
00275                                //Used for Tof system testing
00276   Int_t fTofADCTimeStamp0;       //Tof adc timestamps
00277   Int_t fTofADCTimeStamp1;
00278   Int_t fTofADCTimeStamp2;  
00279   Int_t fTofTimeStamp;           //time stamp of TOF readout
00280 
00281   Int_t fTickSinceLast;          //Ticks since last snarl
00282 
00283   //these are the CalDetPID variables
00284   Bool_t fNoOverlap;
00285   Bool_t fInCERTime;
00286   UInt_t fPIDType; // a bit field 
00287   UInt_t fNoOverlapBits;
00288   UInt_t fInCERTimeBits;
00289   Float_t fOLChi2; 
00290 
00291   //standard trackinfo
00292   Double_t fTime;
00293   Int_t fPlane;
00294   Int_t fResultOdd;//0=nothing, 1=track, 2=vetoed
00295   Int_t fResultEven;
00296   Int_t fStrip;
00297   Int_t fStripend;
00298   Float_t fTransPos;
00299 
00300   //hits odd/even east/west info
00301   Bool_t fO1;
00302   Bool_t fO2;
00303   Bool_t fE1;
00304   Bool_t fE2;
00305 
00306   //calorimetry info
00307   Float_t fChargeAdc;
00308   Float_t fChargeMip;
00309   Float_t fChargeSigCor;
00310   Float_t fChargeSigLin;
00311   Float_t fChargePe;
00312   Float_t fGain;
00313 
00314   //variables for meu and beam energy stuff
00315   Float_t fSigCorsPerMip;
00316   Float_t fSigCorPerMEU;
00317   Float_t fScEnDepPerMEU;
00318   Float_t fRatioScEnToBeamEn;
00319 
00320   //run characteristics
00321   Float_t fMeuVsEvLenCutM;
00322   Float_t fSigCorVsDistM;
00323   Float_t fPeakLastPlane;
00324   Float_t fPeakPlaneSigCors;
00325 
00326   //counters for the various pids
00327   Int_t fMyPiMuCounter;
00328   Int_t fPidPiMuCounter;
00329   Int_t fMyElecCounter;
00330   Int_t fPidElecCounter;
00331   Int_t fBothPiMuCounter;
00332   Int_t fBothElecCounter;
00333 
00334   Float_t fAvTemperature;//keep track of av temperature
00335 
00336   std::string fS;//general purpose string
00337   Bool_t fDoReCalibration;//flag to control recalibration
00338 
00339   ClassDef(CDAnalysis,0)
00340 };
00341 
00342 #endif // CDANALYSIS_H

Generated on Mon Feb 15 11:06:30 2010 for loon by  doxygen 1.3.9.1