CDAnalysis Class Reference

#include <CDAnalysis.h>

List of all members.

Public Member Functions

 CDAnalysis ()
 ~CDAnalysis ()
void CleanMuons ()
void Bb () const
void BbVsGminos ()
void BbEnVsRange () const
void BbThkFeVsRange () const
void ElectronResponse ()
void MuonCalorimetry ()
void MuonNearFar ()
void MuonResponse ()
void MuonSampleCuts ()
void MuonScatter ()
void MuonStVsPl ()
void PrintEvent (Int_t event)
void PrintPIDStats ()
void StoppingMuonCalibration ()
void Template ()
void Template2 ()
void TruthAnalysis ()
void TruthEnDep ()
void TruthEnDepFe ()
void TruthEventLength ()
void ValidateMC ()
void ValidateReco ()
void ValidatePIDInfo ()
void ValidateTrkHits ()
void ValidateTruth ()
void ValidateUnTrkHits ()
void ValidateXTalkHits ()
TGraph * TGraphMap (const std::map< Int_t, Float_t > &m) const
TGraph * TGraphVect (const std::vector< Double_t > &vX, const std::vector< Double_t > &vY) const
void TGraphMinMax (std::vector< TGraph * > &v) const
Int_t Rnd (Double_t x) const
void WriteOutHistos () const
Int_t RunNumber2RunPeriod (Int_t run) const
Int_t SumMapValues (const std::map< Int_t, Int_t > &mapIn) const

Static Public Member Functions

static void InputFileName (std::string f)

Private Member Functions

void CalcAvStripForPSMuonCut (Int_t plane, Int_t strip, Int_t end)
void CalcFirstLastPlane (Int_t plane)
void CalcLastPlaneOnTrk ()
void CalcLowUpScint_TofDiff (Double_t time)
void CalcNumPlanesHit (Int_t plane, Float_t pe)
void CalcNumPlanesHitTrk (Int_t plane)
void InitialiseLoopVariables ()
void InitialisePidVariables ()
void InitialiseHitInfoVariables ()
void MakeChain ()
void ReadInHitInfo (CDTrackedHitInfo *hitInfo)
void ReadInHitInfo (CDXTalkHitInfo *hitInfo)
void SetLoopVariables (Int_t entry)
void SetRatioScEnToBeamEn ()
void SetRootFileObjects ()
void SetScEnDepPerMEU ()
void SetSigCorPerMEU ()
Float_t CalcDistToPlaneCentre (Int_t strip, Float_t transPos) const
Int_t CalcLastPlaneOnTrkNoXTalk () const
Int_t CalcLastPlaneTruth () const
Double_t CalcMeuPLCorrected (std::map< Int_t, Float_t > plEnDep, std::map< Int_t, Float_t > plPLCor, Int_t event, Float_t *GeVPerMeu) const
Float_t CalcPathLengthCorection (const TVector3 &end1, const TVector3 &end2) const
Bool_t CalcPLCor (const std::map< Int_t, TVector3 > &mPlPos, std::map< Int_t, Float_t > &mPLCor) const
void CalcXorYandZ (Int_t strip, Int_t plane, Float_t &x, Float_t &y, Float_t &z) const
Bool_t CalcXYZ (std::map< Int_t, TVector3 > &mPlPos) const
Bool_t CutByHandOnEventLength () const
Bool_t CutOnPSMuons () const
Bool_t CutByHandOnPid () const
Bool_t CutByHandOnPidForElec () const
Bool_t CutOnBadCalorimetry (Int_t plane, Int_t strip, Int_t end) const
Bool_t CutOnBadPedestals (Int_t plane, Int_t strip, Int_t end) const
Bool_t CutOnDeadChips () const
Bool_t CutOnEventLength () const
Bool_t CutOnEventLengthForElec () const
Bool_t CutOnFiducialVolume () const
Bool_t CutOnNumHitsPerPlane () const
Bool_t CutOnNumHitsPerPlane10 () const
Bool_t CutOnNumPlanesHit (Int_t planesHit) const
Bool_t CutOnOverlap () const
Bool_t CutOnOverlapForElec () const
Bool_t CutOnPid () const
Bool_t CutOnPidForElec () const
Bool_t CutOnScint_TofDiff () const
Bool_t CutOnTrackQuality (Bool_t requireGoodTrack=true) const
Double_t dE_dxIterative (MuEnergyLoss &mat, Double_t energyRemaining, Double_t totalThk, Double_t rho, Double_t energyCutOff, Int_t slices) const
void DrawResponsePlot (std::string &title, TProfile *prof, TProfile *profX, TProfile *profT, const std::map< Int_t, Float_t > &num, const std::map< Int_t, Float_t > &numX, const std::map< Int_t, Float_t > &numT, std::string sXTitle="") const
void FillProfHisto (TProfile *prof, std::map< Int_t, Float_t > &counter, const std::map< Int_t, Float_t > &addMe, Int_t offset=0) const
void FillEnVsDist (std::map< Int_t, Float_t > plEnDep, std::map< Int_t, Float_t > plPLCor, Int_t event) const
void FlipVector (std::vector< Double_t > &v) const
void GetEvLenMinMax (Int_t &minPlane, Int_t &maxPlane) const
Int_t GetEventLength () const
void GetLowUpTimeCuts (Float_t &lowTime, Float_t &upTime) const
Double_t GetMainParticleEnergy () const
Double_t GetGreatestMainParticleEnergy (Int_t nEvents=200) const
Bool_t IsDoubleEnded (Int_t inplane) const
Bool_t IsGenuineOrXTalk (Int_t inplane) const
Bool_t IsPlaneGenuine (Int_t inplane) const
Bool_t IsPlaneSideHit (Int_t inplane, Int_t stripend) const
Bool_t IsPlaneXTalkOnly (Int_t inplane) const
Bool_t IsSharedPmtHit (Int_t inplane) const
Bool_t IsStraightTrack (Double_t mainX1Cut) const
Bool_t IsStraightTrack_Radius (Double_t radiusCut) const
std::vector< std::string > MakeFileList ()
void NormaliseVector (std::vector< Double_t > &v, Int_t mode=1) const
TFile * OpenFile (Int_t runNumber, std::string prefix="")
ofstream * OpenTxtFile (Int_t runNumber, std::string prefix)
std::string Pct (Double_t top, Double_t bottom) const
void PrintBasicInfo (std::string="") const
Float_t ReCalibrate (Float_t chargeAdc, Int_t plane, Int_t strip, Int_t stripend) const
void ScaleMap (std::map< Int_t, Float_t > &m, const std::map< Int_t, Float_t > &scaleFactor) const
void ScaleVector (std::vector< Double_t > &v, Double_t scaleFactor) const
void StandardSanityChecks () const
Bool_t StraightTrack_Radius (Double_t radiusCut) const
Float_t TrueDistToPlaneCentre (Int_t strip, Float_t xInStrFrame) const
Double_t TrueEnDep (Int_t inplane, Int_t event) const
Double_t TrueEnDepNotSc (Int_t inplane, Int_t event) const
void TrueHighLowEn (Float_t &highEn, Float_t &lowEn) const
Int_t TrueNumDigiScintHits (Int_t inplane, Int_t event) const
Int_t TrueMuonHunter (Int_t event)
Double_t TrueMainPL (Int_t inplane, Int_t event) const
void TruePLCor (std::map< Int_t, Float_t > &mPLCor, Int_t event) const
Float_t TrueXInStripFrame (Int_t plane, Int_t strip, Int_t event) const

Private Attributes

TFile * fOutFile
TChain * fTrackerTree
TChain * fOptTree
CDTrackerOptionsfTrkOpt
CDPIDInfofPIDInfo
CDTrackInfofTrackInfo
TClonesArray * fTrkHitInfo
TClonesArray * fUnTrkHitInfo
TClonesArray * fXTalkHits
TClonesArray * fTruthHitInfo
Int_t fSnarl
Int_t fSec
Int_t fNumDeadChips
Float_t fTemperature
Float_t fBeamMomentum
SimFlag::SimFlag_t fSimFlag
Int_t fRunNumber
Int_t fSubRun
Int_t fStartSnarl
Int_t fEndSnarl
Int_t fStartTime
Int_t fEndTime
Double_t fMainParticleEnergy
Int_t fEvents
Int_t fFirstPlane
Int_t fLastPlane
Int_t fLastPlaneOdd
Int_t fLastPlaneEven
std::map< Int_t, Int_t > fNumPlanesHitTrk
std::map< Int_t, Int_t > fNumPlanesHitAll
std::map< Int_t, Int_t > fNumPlanesHit25
std::map< Int_t, Int_t > fNumPlanesHitPeCut
std::map< Int_t, Int_t > fNumPlanesHitPeCut10
Float_t fNumHitsPerPlane
Float_t fNumHitsPerPlane25
Float_t fNumHitsPerPlanePeCut10
Int_t fStripsFromCentrePeCut
Float_t fAvStrip
Float_t fStCount
Float_t fAvStrip1
Float_t fStCount1
Float_t fAvStrip2
Float_t fStCount2
Float_t fLowScint_Tof
Float_t fUpScint_Tof
Bool_t fTriggerPMT
Bool_t fFafErr
Bool_t fSparseErr
Int_t fTrigSource
Int_t fKovADC1
Int_t fKovTimeStamp1
Int_t fKovADC2
Int_t fKovTimeStamp2
Int_t fKovADC3
Int_t fKovTimeStamp3
Int_t fSnarlTimeFrame
ULong_t fSnarlMinTimeStamp
ULong_t fSnarlMaxTimeStamp
Int_t fTofTDC0
Int_t fTofTDC1
Int_t fTofTDC2
Int_t fTofADC0
Int_t fTofADC1
Int_t fTofADC2
Int_t fTofADCTimeStamp0
Int_t fTofADCTimeStamp1
Int_t fTofADCTimeStamp2
Int_t fTofTimeStamp
Int_t fTickSinceLast
Bool_t fNoOverlap
Bool_t fInCERTime
UInt_t fPIDType
UInt_t fNoOverlapBits
UInt_t fInCERTimeBits
Float_t fOLChi2
Double_t fTime
Int_t fPlane
Int_t fResultOdd
Int_t fResultEven
Int_t fStrip
Int_t fStripend
Float_t fTransPos
Bool_t fO1
Bool_t fO2
Bool_t fE1
Bool_t fE2
Float_t fChargeAdc
Float_t fChargeMip
Float_t fChargeSigCor
Float_t fChargeSigLin
Float_t fChargePe
Float_t fGain
Float_t fSigCorsPerMip
Float_t fSigCorPerMEU
Float_t fScEnDepPerMEU
Float_t fRatioScEnToBeamEn
Float_t fMeuVsEvLenCutM
Float_t fSigCorVsDistM
Float_t fPeakLastPlane
Float_t fPeakPlaneSigCors
Int_t fMyPiMuCounter
Int_t fPidPiMuCounter
Int_t fMyElecCounter
Int_t fPidElecCounter
Int_t fBothPiMuCounter
Int_t fBothElecCounter
Float_t fAvTemperature
std::string fS
Bool_t fDoReCalibration

Static Private Attributes

static std::string fInputFileName = ""

Detailed Description

Definition at line 39 of file CDAnalysis.h.


Constructor & Destructor Documentation

CDAnalysis::CDAnalysis (  ) 

Definition at line 64 of file CDAnalysis.cxx.

References Msg::kInfo, SimFlag::kUnknown, and MSG.

00065 {
00066   MSG("CDAnalysis",Msg::kInfo)
00067       <<"Running CDAnalysis Constructor..."<<endl;
00068 
00069   //initialise variables
00070   fOutFile=0;//initialise output file pointer
00071   fTrackerTree=0;
00072   fOptTree=0;
00073   fTrkOpt=0;//tracking options
00074   fPIDInfo=0;
00075   fTrackInfo=0;
00076   fTrkHitInfo=0;
00077   fUnTrkHitInfo=0;
00078   fXTalkHits=0;
00079   fTruthHitInfo=0;
00080   
00081   fSnarl=-1;
00082   fSec=-1;
00083   fNumDeadChips=-1;
00084   fTemperature=-1;
00085   fBeamMomentum=0;
00086   fSimFlag=SimFlag::kUnknown;
00087   fRunNumber=0;
00088   fSubRun=0;
00089   fStartSnarl=0;
00090   fEndSnarl=0;
00091   fStartTime=0;
00092   fEndTime=0;
00093   fMainParticleEnergy=0;
00094   fEvents=-1;
00095 
00096   this->InitialiseLoopVariables();
00097   this->InitialiseHitInfoVariables();
00098   this->InitialisePidVariables();
00099 
00100   //set a default value of 1 so it stays as sigcor
00101   fSigCorsPerMip=1;
00102   fSigCorPerMEU=1;
00103   fScEnDepPerMEU=1;
00104   fRatioScEnToBeamEn=1;
00105   
00106   fMeuVsEvLenCutM=0;
00107   fSigCorVsDistM=0;
00108   fPeakLastPlane=0;
00109   fPeakPlaneSigCors=0;
00110   fMyPiMuCounter=0;
00111   fPidPiMuCounter=0;
00112   fMyElecCounter=0;
00113   fPidElecCounter=0;
00114   fBothPiMuCounter=0;
00115   fBothElecCounter=0;
00116   fAvTemperature=0;
00117 
00118   fS="";//general purpose string
00119   fDoReCalibration=false;//don't do recalibration by default
00120 
00122   //all data members are initialised by this point...
00124 
00125   this->MakeChain();
00126   this->SetRootFileObjects();
00127 
00128   //get the main particle energy
00129   fMainParticleEnergy=this->GetGreatestMainParticleEnergy();
00130   if (fMainParticleEnergy>0){
00131     MSG("CDAnalysis",Msg::kInfo)
00132       <<"Found main energy="<<fMainParticleEnergy<<endl;
00133     MSG("CDAnalysis",Msg::kInfo)
00134       <<"Beam Momentum from file="<<fBeamMomentum<<endl;
00135   }
00136 
00137   //setup some root stuff
00138   //include the under and overflow counts
00139   gStyle->SetOptStat(1111111);
00140   gStyle->SetOptFit(1111);
00141   gStyle->SetPalette(1,(Int_t*)0);
00142 
00143   //do these last in the constructor
00144   //set the values appropriately if possible
00145   this->SetSigCorPerMEU();
00146   this->SetScEnDepPerMEU();
00147   this->SetRatioScEnToBeamEn();
00148 
00149   MSG("CDAnalysis",Msg::kInfo)
00150       <<"Finished CDAnalysis Constructor"<<endl;
00151 }

CDAnalysis::~CDAnalysis (  ) 

Definition at line 155 of file CDAnalysis.cxx.

References fOutFile, Msg::kDebug, and MSG.

00156 {
00157   MSG("CDAnalysis",Msg::kDebug)
00158       <<"Running CDAnalysis Destructor..."<<endl;
00159   
00160   if (fOutFile){
00161     fOutFile->Close();
00162   }
00163 
00164   MSG("CDAnalysis",Msg::kDebug)
00165       <<"Finished CDAnalysis Destructor"<<endl;
00166 }


Member Function Documentation

void CDAnalysis::Bb (  )  const

Definition at line 12247 of file CDAnalysis.cxx.

References CDSimpleMC::CalcRatioScToFe(), count, CDSimpleMC::fdE_dxFe, CDSimpleMC::fdE_dxSc, CDSimpleMC::fEn, CDSimpleMC::fEnAlx2Deposited, CDSimpleMC::fEnDeposited, CDSimpleMC::fEnDepositedPl, CDSimpleMC::fEnFeDeposited, CDSimpleMC::fEnRatio, CDSimpleMC::fEnScDeposited, CDSimpleMC::fEnTiO2x2Deposited, FlipVector(), CDSimpleMC::fMomGeV, CDSimpleMC::fMomSc, CDSimpleMC::fMomScGeV, Form(), CDSimpleMC::fX, CDSimpleMC::fXAlx2, CDSimpleMC::fXFe, CDSimpleMC::fXPlanes, CDSimpleMC::fXPlanesRatio, CDSimpleMC::fXSc, CDSimpleMC::fXScPlanes, CDSimpleMC::fXTiO2x2, CDSimpleMC::GetTotalNumScPlanesHit(), Msg::kDebug, Msg::kInfo, legend(), MSG, CDSimpleMC::RunMC(), CDSimpleMC::SetParticleMomentum(), CDSimpleMC::SetThkFe(), and TGraphVect().

12248 {
12249   Float_t sum15_18=0;
12250   Float_t sum15_18Sc=0;
12251   Float_t av15PlanesSc=0;
12252   Float_t avPlanes0to14Sc=0;
12253   Float_t sum15_18Counter=0;
12254   vector<Double_t> eDepositedPl;
12255  
12256   //create simpleMC object
12257   CDSimpleMC mc;
12258   mc.SetThkFe(2.54);
12259   mc.SetParticleMomentum(5000);
12260   //run mc
12261   mc.RunMC();
12262   //get ratios too
12263   mc.CalcRatioScToFe();
12264   /*
12265 //2.5
12266 Using pl=0 in my extra special window, endep=2.00385
12267 Using pl=1 in my extra special window, endep=1.99883
12268 Using pl=2 in my extra special window, endep=1.99371
12269 Using pl=3 in my extra special window, endep=1.98848
12270 Using pl=4 in my extra special window, endep=1.98315
12271 Using pl=5 in my extra special window, endep=1.97771
12272 Using pl=6 in my extra special window, endep=1.97217
12273 Using pl=7 in my extra special window, endep=1.96654
12274 Using pl=8 in my extra special window, endep=1.96082
12275 Using pl=9 in my extra special window, endep=1.95502
12276 Using pl=10 in my extra special window, endep=1.94916
12277 Using pl=11 in my extra special window, endep=1.94325
12278 Using pl=12 in my extra special window, endep=1.93733
12279 Using pl=13 in my extra special window, endep=1.93142
12280 Using pl=14 in my extra special window, endep=1.92558
12281 
12282   //2.54
12283  Using pl=0 in my extra special window, endep=2.00385
12284 Using pl=1 in my extra special window, endep=1.99876
12285 Using pl=2 in my extra special window, endep=1.99355
12286 Using pl=3 in my extra special window, endep=1.98824
12287 Using pl=4 in my extra special window, endep=1.98283
12288 Using pl=5 in my extra special window, endep=1.9773
12289 Using pl=6 in my extra special window, endep=1.97168
12290 Using pl=7 in my extra special window, endep=1.96595
12291 Using pl=8 in my extra special window, endep=1.96014
12292 Using pl=9 in my extra special window, endep=1.95425
12293 Using pl=10 in my extra special window, endep=1.94829
12294 Using pl=11 in my extra special window, endep=1.94229
12295 Using pl=12 in my extra special window, endep=1.93628
12296 Using pl=13 in my extra special window, endep=1.93029
12297 Using pl=14 in my extra special window, endep=1.92439
12298 
12299 //2.5
12300 Using pl=17 in my special window, endep=2.0194
12301 Using pl=18 in my special window, endep=2.01471
12302 Using pl=19 in my special window, endep=2.00992
12303 Using pl=20 in my special window, endep=2.00503
12304 Using pl=21 in my special window, endep=2.00004
12305 Using pl=22 in my special window, endep=1.99494
12306 Using pl=23 in my special window, endep=1.98973
12307 Using pl=24 in my special window, endep=1.98442
12308 Using pl=25 in my special window, endep=1.97901
12309 Using pl=26 in my special window, endep=1.9735
12310 Using pl=27 in my special window, endep=1.96789
12311 Using pl=28 in my special window, endep=1.96219
12312 Using pl=29 in my special window, endep=1.95641
12313 Using pl=30 in my special window, endep=1.95056
12314 Using pl=31 in my special window, endep=1.94466
12315 
12316 //2.54
12317 Using pl=17 in my special window, endep=2.01823
12318 Using pl=18 in my special window, endep=2.01345
12319 Using pl=19 in my special window, endep=2.00856
12320 Using pl=20 in my special window, endep=2.00357
12321 Using pl=21 in my special window, endep=1.99847
12322 Using pl=22 in my special window, endep=1.99326
12323 Using pl=23 in my special window, endep=1.98794
12324 Using pl=24 in my special window, endep=1.98252
12325 Using pl=25 in my special window, endep=1.97699
12326 Using pl=26 in my special window, endep=1.97136
12327 Using pl=27 in my special window, endep=1.96563
12328 Using pl=28 in my special window, endep=1.95981
12329 Using pl=29 in my special window, endep=1.95391
12330 Using pl=30 in my special window, endep=1.94795
12331 Using pl=31 in my special window, endep=1.94195
12332   */
12333 
12334 
12335 
12336   for (UInt_t i=0;i<mc.fEnScDeposited.size();i++){
12337     if (i<=14){
12338       MSG("CDAnalysis",Msg::kInfo)
12339         <<"Using pl="<<i<<" in my extra special window, endep="
12340         <<mc.fEnScDeposited[i]<<endl; 
12341       avPlanes0to14Sc+=mc.fEnScDeposited[i];
12342     }
12343 
12344     if (i>=17 && i<=31){
12345       MSG("CDAnalysis",Msg::kInfo)
12346         <<"Using pl="<<i<<" in my special window, endep="
12347         <<mc.fEnScDeposited[i]<<endl; 
12348       av15PlanesSc+=mc.fEnScDeposited[i];
12349     }
12350   }
12351   //calc the average
12352   av15PlanesSc/=15;
12353   avPlanes0to14Sc/=15;
12354   MSG("CDAnalysis",Msg::kInfo)
12355     <<"Average scint en. dep. for planes 17-31 inclusive="
12356     <<av15PlanesSc<<endl
12357     <<"Average scint en. dep. for planes 0-14 inclusive="
12358     <<avPlanes0to14Sc<<endl;
12359   
12361   //section for sliding window
12363   
12364   vector<TProfile*> pSigCorVsDist;
12365   vector<Int_t> vWindowSize;
12366   vector<Float_t> bigAv;
12367   vector<Int_t> bigAvCounter;
12368   Int_t minEventLength=40;
12369 
12370   //need a new vector for this!!!!
12373   MSG("CDAnalysis",Msg::kInfo) 
12374     <<"size="<<mc.fEnScDeposited.size()<<endl;
12375 
12376   //initialise the profile histos
12377   for (Int_t p=20;p>1;p--){
12378     vWindowSize.push_back(p);
12379     bigAv.push_back(0);
12380     bigAvCounter.push_back(0);
12381   }
12382   
12383   for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
12384        windowSize!=vWindowSize.end();++windowSize){
12385     
12386     string sName=Form("%d",*windowSize);
12387     pSigCorVsDist.push_back
12388       (new TProfile(("pSigCorVsDist"+sName).c_str(),
12389                     ("pSigCorVsDist"+sName).c_str(),100,-2,40));
12390   }
12391 
12392   vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12393   vector<Float_t>::iterator av=bigAv.begin();
12394   vector<Int_t>::iterator count=bigAvCounter.begin();
12395   
12396   //loop over the different window sizes
12397   for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
12398        windowSize!=vWindowSize.end();++windowSize){
12399     MSG("CDAnalysis",Msg::kDebug)
12400       <<"Window size="<<*windowSize<<endl;
12401  
12402     //slide the window along from the end to 40-windowSize
12403     for (Int_t p=0;p<minEventLength-*windowSize;p++){
12404       Int_t lastPlane=mc.fEnScDeposited.size()-1;
12405       Int_t windowStart=lastPlane-p;
12406 
12407       //loop through the hits in the window      
12408       for (Int_t i=0;i<*windowSize;i++){
12409         Int_t plane=windowStart-i;
12410         
12411         (*prof)->Fill(p,mc.fEnScDeposited[plane]);
12412         (*av)+=mc.fEnScDeposited[plane];
12413         (*count)++;
12414 
12415         //calculate the best window value
12416         if (*windowSize==15 && windowStart==lastPlane-18){
12417           MSG("CDAnalysis",Msg::kInfo)
12418             <<"Using pl="<<plane<<" in window"<<endl;
12419           sum15_18+=mc.fEnDepositedPl[plane];
12420           sum15_18Sc+=mc.fEnScDeposited[plane];
12421           sum15_18Counter++;
12422         }
12423       }
12424 
12425       
12426 
12427     }
12428     av++;
12429     count++;
12430     prof++;
12431   }
12432 
12433   //turn on the stats box printing
12434   gStyle->SetOptStat(11);
12435 
12436   TCanvas *cProf=new TCanvas("cProf","Prof",0,0,1200,800);
12437   cProf->SetFillColor(0);
12438   string sName="SlidingWindowBB.ps";
12439   cProf->Print((sName+"[").c_str());
12440   gErrorIgnoreLevel=1;
12441   //plot the unnormalised prof first
12442   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12443        prof!=pSigCorVsDist.end();++prof){      
12444     cProf->Clear();
12445     (*prof)->Draw();
12446     (*prof)->SetTitle("Energy Deposited in Sliding Window");
12447     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
12448     (*prof)->GetYaxis()->SetTitle("Energy Deposited (MeV)");
12449     (*prof)->GetXaxis()->CenterTitle();
12450     (*prof)->GetYaxis()->CenterTitle();
12451     cProf->Print(sName.c_str());
12452   }
12453 
12454   //now normalise the prof
12455   av=bigAv.begin();
12456   count=bigAvCounter.begin();
12457   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12458        prof!=pSigCorVsDist.end();++prof){
12459       
12460     //normalise the prof and scale the axes
12461     MSG("CDAnalysis",Msg::kInfo)
12462       <<"bigCounter="<<*count<<", bigAv="<<*av<<endl;
12463     if (*av>0) (*prof)->Scale((*count)/(*av));
12464     (*prof)->SetMaximum(1.2);
12465     (*prof)->SetMinimum(0.8);
12466       
12467     cProf->Clear();
12468     (*prof)->Draw();
12469     (*prof)->SetTitle("Normalised Energy Deposited in Sliding Window");
12470     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
12471     (*prof)->GetYaxis()->SetTitle("Normalised Energy Deposited");
12472     (*prof)->GetXaxis()->CenterTitle();
12473     (*prof)->GetYaxis()->CenterTitle();
12474     cProf->Print(sName.c_str());
12475     av++;
12476     count++;
12477   }
12478   //close the file
12479   gErrorIgnoreLevel=0;
12480   cProf->Print((sName+"]").c_str());
12481 
12482   TLegend *legend = new TLegend(0.85, 0.7, 0.9, 0.9);
12483   legend->SetBorderSize(0);
12484   legend->SetFillColor(0);
12485   legend->SetTextSize(0.035);
12486 
12487   //now do a few profs on the same plot
12488   TCanvas *cProf2=new TCanvas("cProf2","Prof",0,0,1200,800);
12489   cProf2->SetFillColor(0);
12490   sName="SlidingWindowAll.ps";
12491   //cProf2->Print((sName+"[").c_str());
12492   Int_t counter=0;
12493   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12494        prof!=pSigCorVsDist.end();++prof){
12495 
12496     (*prof)->SetMaximum(1.09);
12497     (*prof)->SetMinimum(0.96);
12498 
12499     //count which prof got to
12500     counter++;
12501 
12502     //decide which profs to draw
12503     static Bool_t firstTime=true;
12504     if (counter==1 || counter==6 || counter==11){ 
12505       if (firstTime) {
12506         (*prof)->Draw();
12507         firstTime=false;
12508       }
12509       else  (*prof)->Draw("sames");
12510 
12511       (*prof)->SetTitle("Normalised Energy Deposited in Sliding Window");
12512       (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
12513       (*prof)->GetYaxis()->SetTitle("Normalised Energy Deposition");
12514       (*prof)->GetXaxis()->CenterTitle();
12515       (*prof)->GetYaxis()->CenterTitle();
12516       static Int_t color=2;
12517       (*prof)->SetLineColor(color);
12518       color+=2;
12519       string sWindowSize=Form("%d",21-counter);
12520       string sGraph=" Window size = ";
12521       sGraph+=sWindowSize;
12522       sGraph+=" planes";
12523       legend->AddEntry((*prof),sGraph.c_str(),"l");
12524     }
12525   }
12526   legend->Draw();
12527 
12528   this->FlipVector(mc.fXScPlanes);
12529   TGraph* eLossSc=TGraphVect(mc.fXScPlanes,mc.fEnScDeposited);
12530   TCanvas *cELossSc=new TCanvas("cELossSc","ELossSc",
12531                                    0,0,1200,800);
12532   cELossSc->SetFillColor(0);
12533   eLossSc->Draw("AP");
12534   eLossSc->SetTitle("Energy Loss in Scintillator");
12535   eLossSc->GetXaxis()->SetTitle("Distance from end of track (planes)");
12536   eLossSc->GetYaxis()->SetTitle("Energy Loss (MeV)");
12537   eLossSc->GetXaxis()->CenterTitle();
12538   eLossSc->GetYaxis()->CenterTitle();
12539   eLossSc->SetMarkerStyle(3);
12540   eLossSc->SetMarkerColor(2);
12541   eLossSc->SetMarkerSize(0.8);
12542 
12543   this->FlipVector(mc.fX);
12544   TGraph* energyLoss=TGraphVect(mc.fX,mc.fEnDeposited);
12545   TCanvas *cEnergyLoss=new TCanvas("cEnergyLoss","EnergyLoss",
12546                                    0,0,1200,800);
12547   cEnergyLoss->SetFillColor(0);
12548   energyLoss->Draw("AP");
12549   energyLoss->SetTitle("Energy Loss in Scintillator and Iron");
12550   energyLoss->GetXaxis()->SetTitle("Distance from end of track (cm)");
12551   energyLoss->GetYaxis()->SetTitle("Energy Loss (MeV)");
12552   energyLoss->GetXaxis()->CenterTitle();
12553   energyLoss->GetYaxis()->CenterTitle();
12554   energyLoss->SetMarkerStyle(3);
12555   energyLoss->SetMarkerColor(2);
12556   energyLoss->SetMarkerSize(0.8);
12557 
12558   this->FlipVector(mc.fXPlanes);
12559   TGraph* energyloss2=TGraphVect(mc.fXPlanes,mc.fEnDeposited);
12560   TCanvas *cEnergyloss2=new TCanvas("cEnergyloss2","Energyloss2",
12561                                    0,0,1200,800);
12562   cEnergyloss2->SetFillColor(0);
12563   energyloss2->Draw("AP");
12564   energyloss2->SetTitle("Energy Loss in Scintillator and Iron");
12565   energyloss2->GetXaxis()->SetTitle("Distance from end of track (planes)");
12566   energyloss2->GetYaxis()->SetTitle("Energy Loss (MeV)");
12567   energyloss2->GetXaxis()->CenterTitle();
12568   energyloss2->GetYaxis()->CenterTitle();
12569   energyloss2->SetMarkerStyle(3);
12570   energyloss2->SetMarkerColor(2);
12571   energyloss2->SetMarkerSize(0.8);
12572 
12573   this->FlipVector(mc.fXFe);
12574   TGraph* gXFevsEn=TGraphVect(mc.fXFe,mc.fEnFeDeposited);
12575   this->FlipVector(mc.fXSc);
12576   TGraph* gXScvsEn=TGraphVect(mc.fXSc,mc.fEnScDeposited);
12577   this->FlipVector(mc.fXAlx2);
12578   TGraph* gXAlx2vsEn=TGraphVect(mc.fXAlx2,mc.fEnAlx2Deposited);
12579   this->FlipVector(mc.fXTiO2x2);
12580   TGraph* gXTiO2x2vsEn=TGraphVect(mc.fXTiO2x2,mc.fEnTiO2x2Deposited);
12581   TCanvas *cEnergyloss3=new TCanvas("cEnergyloss3","Energyloss3",
12582                                     0,0,1200,800);
12583   cEnergyloss3->SetFillColor(0);
12584   cEnergyloss3->Divide(2,1);
12585   cEnergyloss3->cd(1);
12586   gXFevsEn->Draw("AP");
12587   gXFevsEn->SetTitle("Energy Loss in Iron");
12588   gXFevsEn->GetXaxis()->SetTitle("Distance from end of track (cm)");
12589   gXFevsEn->GetYaxis()->SetTitle("Energy Loss (MeV)");
12590   gXFevsEn->GetXaxis()->CenterTitle();
12591   gXFevsEn->GetYaxis()->CenterTitle();
12592   gXFevsEn->SetMarkerStyle(3);
12593   gXFevsEn->SetMarkerColor(2);
12594   gXFevsEn->SetMarkerSize(0.8);
12595   gXFevsEn->SetMinimum(0.00001);
12596   gXFevsEn->SetMaximum(50);
12597 
12598   gXScvsEn->Draw("P");
12599   gXScvsEn->SetTitle("Energy Loss in Scintillator");
12600   gXScvsEn->GetXaxis()->SetTitle("Distance from end of track (cm)");
12601   gXScvsEn->GetYaxis()->SetTitle("Energy Loss (MeV)");
12602   gXScvsEn->GetXaxis()->CenterTitle();
12603   gXScvsEn->GetYaxis()->CenterTitle();
12604   gXScvsEn->SetMarkerStyle(3);
12605   gXScvsEn->SetMarkerColor(3);
12606   gXScvsEn->SetMarkerSize(0.8);
12607 
12608   gXAlx2vsEn->Draw("P");
12609   gXAlx2vsEn->SetTitle("Energy Loss in Aluminium");
12610   gXAlx2vsEn->GetXaxis()->SetTitle("Distance from end of track (cm)");
12611   gXAlx2vsEn->GetYaxis()->SetTitle("Energy Loss (MeV)");
12612   gXAlx2vsEn->GetXaxis()->CenterTitle();
12613   gXAlx2vsEn->GetYaxis()->CenterTitle();
12614   gXAlx2vsEn->SetMarkerStyle(3);
12615   gXAlx2vsEn->SetMarkerColor(4);
12616   gXAlx2vsEn->SetMarkerSize(0.8);
12617 
12618   gXTiO2x2vsEn->Draw("P");
12619   gXTiO2x2vsEn->SetTitle("Energy Loss in TiO2");
12620   gXTiO2x2vsEn->GetXaxis()->SetTitle("Distance from end of track (cm)");
12621   gXTiO2x2vsEn->GetYaxis()->SetTitle("Energy Loss (MeV)");
12622   gXTiO2x2vsEn->GetXaxis()->CenterTitle();
12623   gXTiO2x2vsEn->GetYaxis()->CenterTitle();
12624   gXTiO2x2vsEn->SetMarkerStyle(3);
12625   gXTiO2x2vsEn->SetMarkerColor(6);
12626   gXTiO2x2vsEn->SetMarkerSize(0.8);
12627   cEnergyloss3->SetLogy();
12628   
12629   cEnergyloss3->cd(2);
12630   TGraph* gXScvsEn2=TGraphVect(mc.fXSc,mc.fEnScDeposited);
12631   gXScvsEn2->Draw("AP");
12632   gXScvsEn2->SetTitle("Energy Loss in Scintillator");
12633   gXScvsEn2->GetXaxis()->SetTitle("Distance from end of track (cm)");
12634   gXScvsEn2->GetYaxis()->SetTitle("Energy Loss (MeV)");
12635   gXScvsEn2->GetXaxis()->CenterTitle();
12636   gXScvsEn2->GetYaxis()->CenterTitle();
12637   gXScvsEn2->SetMarkerStyle(3);
12638   gXScvsEn2->SetMarkerColor(3);
12639   gXScvsEn2->SetMarkerSize(0.8);
12640 
12641   TGraph* bbFe=TGraphVect(mc.fEn,mc.fdE_dxFe);
12642   //TGraph* bbAl=TGraphVect(mc.fEn,mc.fdE_dxAl);
12643   TGraph* bbSc=TGraphVect(mc.fEn,mc.fdE_dxSc);
12644   TGraph* bbSc2=TGraphVect(mc.fMomGeV,mc.fdE_dxSc);
12645   TGraph* bbSc3=TGraphVect(mc.fMomScGeV,mc.fEnScDeposited);
12646   TGraph* bbMomVsRange=TGraphVect(mc.fXSc,mc.fMomSc);
12647   TCanvas *cBb=new TCanvas("cBb","Bb",0,0,1200,800);
12648   cBb->SetFillColor(0);
12649   cBb->Divide(2,2);
12650   cBb->cd(1);
12651   bbFe->Draw("AP");
12652   bbFe->SetTitle("dE/dx in Iron");
12653   bbFe->GetXaxis()->SetTitle("Particle Energy");
12654   bbFe->GetYaxis()->SetTitle("dE/dx MeV/(g/cm2)");
12655   bbFe->GetXaxis()->CenterTitle();
12656   bbFe->GetYaxis()->CenterTitle();
12657   bbFe->SetMarkerStyle(3);
12658   bbFe->SetMarkerColor(2);
12659   bbFe->SetMarkerSize(0.8);
12660   cBb->cd(2);
12661   bbMomVsRange->Draw("AP");
12662   bbMomVsRange->SetTitle("Muom Momentum vs Range");
12663   bbMomVsRange->GetXaxis()->SetTitle("Range (cm)");
12664   bbMomVsRange->GetYaxis()->SetTitle("Muon Momentum (MeV/c)");
12665   bbMomVsRange->GetXaxis()->CenterTitle();
12666   bbMomVsRange->GetYaxis()->CenterTitle();
12667   bbMomVsRange->SetMarkerStyle(3);
12668   bbMomVsRange->SetMarkerColor(2);
12669   bbMomVsRange->SetMarkerSize(0.8);
12670       /*
12671   bbAl->Draw("AP");
12672   bbAl->SetTitle("dE/dx in Aluminium");
12673   bbAl->GetXaxis()->SetTitle("Particle Energy");
12674   bbAl->GetYaxis()->SetTitle("dE/dx MeV/(g/cm2)");
12675   bbAl->GetXaxis()->CenterTitle();
12676   bbAl->GetYaxis()->CenterTitle();
12677   bbAl->SetMarkerStyle(3);
12678   bbAl->SetMarkerColor(2);
12679   bbAl->SetMarkerSize(0.8);
12680       */
12681   cBb->cd(3);
12682   bbSc->Draw("AP");
12683   bbSc->SetTitle("dE/dx in Scintillator");
12684   bbSc->GetXaxis()->SetTitle("Particle Energy");
12685   bbSc->GetYaxis()->SetTitle("dE/dx MeV/(g/cm2)");
12686   bbSc->GetXaxis()->CenterTitle();
12687   bbSc->GetYaxis()->CenterTitle();
12688   bbSc->SetMarkerStyle(3);
12689   bbSc->SetMarkerColor(2);
12690   bbSc->SetMarkerSize(0.8);
12691   cBb->cd(4);
12692   bbSc2->Draw("AP");
12693   bbSc2->SetTitle("Bethe-Bloch Curve in Scintillator");
12694   bbSc2->GetXaxis()->SetTitle("Muon Momentum");
12695   bbSc2->GetYaxis()->SetTitle("dE/dx MeV/(g/cm2)");
12696   bbSc2->GetXaxis()->CenterTitle();
12697   bbSc2->GetYaxis()->CenterTitle();
12698   bbSc2->SetMarkerStyle(3);
12699   bbSc2->SetMarkerColor(2);
12700   bbSc2->SetMarkerSize(0.8);
12701   bbSc3->Draw("P");
12702   bbSc3->SetMarkerStyle(8);
12703   bbSc3->SetMarkerColor(3);
12704 
12705   this->FlipVector(mc.fXPlanesRatio);
12706   TGraph* eLossRatio=TGraphVect(mc.fXPlanesRatio,mc.fEnRatio);
12707   TCanvas *cELossRatio=new TCanvas("cELossRatio","ELossRatio",
12708                                    0,0,1200,800);
12709   cELossRatio->SetFillColor(0);
12710   eLossRatio->Draw("AP");
12711   eLossRatio->SetTitle("Energy Loss Ratio Fe/Scint");
12712   eLossRatio->GetXaxis()->SetTitle("Distance from end of track (planes)");
12713   eLossRatio->GetYaxis()->SetTitle("Energy Loss Ratio Fe/Scint");
12714   eLossRatio->GetXaxis()->CenterTitle();
12715   eLossRatio->GetYaxis()->CenterTitle();
12716   eLossRatio->SetMarkerStyle(3);
12717   eLossRatio->SetMarkerColor(2);
12718   eLossRatio->SetMarkerSize(0.8);
12719 
12720   if (sum15_18Counter!=0){
12721     MSG("CDAnalysis",Msg::kInfo) 
12722       <<endl
12723       <<" ** Calibration Summary **"<<endl
12724       <<"Sliding Window 15_18:"<<endl
12725       <<"    Total energy dep in scint and Fe="<<sum15_18<<endl
12726       <<"    Av total energy dep in scint and Fe="
12727       <<sum15_18/sum15_18Counter<<" MeV"
12728       <<endl
12729       <<"    Total energy dep in just scint="<<sum15_18Sc<<endl
12730       <<"    Av total energy dep in just scint="
12731       <<sum15_18Sc/sum15_18Counter<<" MeV"
12732       <<endl;
12733   }
12734 
12735   Double_t totPlanesHit=mc.GetTotalNumScPlanesHit();
12736   MSG("CDAnalysis",Msg::kInfo) 
12737     <<"Total number planes hit="<<totPlanesHit<<endl;
12738 }

void CDAnalysis::BbEnVsRange (  )  const

Definition at line 13253 of file CDAnalysis.cxx.

References FitFunc(), CDSimpleMC::GetParticleEnergy(), CDSimpleMC::GetTotalNumScPlanesHit(), CDSimpleMC::GetTotalScEnLoss(), Msg::kDebug, Msg::kInfo, MSG, NormaliseVector(), CDSimpleMC::RunMC(), CDSimpleMC::SetParticleMomentum(), and TGraphVect().

13254 {
13255   //create simpleMC object
13256   CDSimpleMC mc;
13257 
13258   vector<Double_t> lastPlane;
13259   vector<Double_t> energyBeam;
13260   vector<Double_t> sumEnDepSc;
13261   vector<Double_t> ratioScToBeam;
13262 
13263   //loop over the different energies
13264   for (Int_t beamP=1400;beamP<2010;beamP+=10){
13265     MSG("CDAnalysis",Msg::kInfo) 
13266       <<"Beam P="<<beamP<<endl;
13267     
13268     //set up and run the MC
13269     mc.SetParticleMomentum(beamP);
13270     mc.RunMC();
13271     
13272     //fill the vectors
13273     energyBeam.push_back(mc.GetParticleEnergy());
13274     lastPlane.push_back(mc.GetTotalNumScPlanesHit());
13275     sumEnDepSc.push_back(mc.GetTotalScEnLoss());
13276     ratioScToBeam.push_back(mc.GetTotalScEnLoss()/
13277                             mc.GetParticleEnergy());
13278   }
13279 
13280   MSG("CDAnalysis",Msg::kDebug)
13281     <<"Vpl size="<<lastPlane.size()
13282     <<", Ven size="<<energyBeam.size()<<endl;
13283   TGraph* gEnBeamVsRange=TGraphVect(lastPlane,energyBeam);
13284   TCanvas *cEnBeamVsRange=new TCanvas("cEnBeamVsRange","EnBeamVsRange",
13285                                    0,0,1200,800);
13286   cEnBeamVsRange->SetFillColor(0);
13287   gEnBeamVsRange->Draw("AP");
13288   gEnBeamVsRange->SetTitle("Energy Vs Range");
13289   gEnBeamVsRange->GetXaxis()->SetTitle("Range (planes)");
13290   gEnBeamVsRange->GetYaxis()->SetTitle("Beam Energy");
13291   gEnBeamVsRange->GetXaxis()->CenterTitle();
13292   gEnBeamVsRange->GetYaxis()->CenterTitle();
13293   gEnBeamVsRange->SetMarkerStyle(3);
13294   gEnBeamVsRange->SetMarkerColor(2);
13295   gEnBeamVsRange->SetMarkerSize(0.8);
13296 
13297   TGraph* gScToBeamVsBeam=TGraphVect(energyBeam,ratioScToBeam);
13298   TCanvas *cScToBeamVsBeam=new TCanvas("cScToBeamVsBeam",
13299                                        "cScToBeamVsBeam",
13300                                        0,0,1200,800);
13301   cScToBeamVsBeam->SetFillColor(0);
13302   gScToBeamVsBeam->Draw("AP");
13303   gScToBeamVsBeam->SetTitle("Ratio Sc to Beam Energy vs Beam Energy");
13304   gScToBeamVsBeam->GetXaxis()->SetTitle("Beam Energy");
13305   gScToBeamVsBeam->GetYaxis()->SetTitle("Ratio Sc to Beam Energy");
13306   gScToBeamVsBeam->GetXaxis()->CenterTitle();
13307   gScToBeamVsBeam->GetYaxis()->CenterTitle();
13308   gScToBeamVsBeam->SetMarkerStyle(3);
13309   gScToBeamVsBeam->SetMarkerColor(2);
13310   gScToBeamVsBeam->SetMarkerSize(0.8);
13311 
13312   vector<Double_t> enRange;
13313   vector<Double_t> gradient;
13314 
13315   MSG("CDAnalysis",Msg::kInfo)
13316     <<"First fit..."<<endl;
13317   for (vector<Double_t>::iterator r=lastPlane.begin();
13318        r!=lastPlane.end()-3;++r){
13319     //for (Float_t fitRangeMin=lastPlane[0];
13320     // fitRangeMin<lastPlane[lastPlane.size()-3]-1;fitRangeMin++){
13321     static Int_t counter=0;
13322     
13323     gEnBeamVsRange->Fit("pol1","q","",*r,1000);
13324     TF1* func=gEnBeamVsRange->GetFunction("pol1");
13325     Double_t funcM=func->GetParameter(1);
13326     MSG("CDAnalysis",Msg::kInfo)
13327       <<"fitMin="<<*r<<", en="<<energyBeam[counter]
13328       <<", m="<<funcM<<endl;
13329 
13330     enRange.push_back(energyBeam[counter]);
13331     gradient.push_back(funcM);
13332 
13333     counter++;
13334   }
13335 
13336   //now fit to a non-straight line
13337   TF1 *form = new TF1("form",FitFunc,0,70,3);
13338   //par[0]*TMath::Power(x[0],par[1]) + par[2];
13339   form->SetParameters(1,1,0);
13340   gEnBeamVsRange->Fit("form","q");
13341 
13342   TGraph* gFitGradVsRange=TGraphVect(enRange,gradient);
13343   TCanvas *cFitGradVsRange=new TCanvas("cFitGradVsRange",
13344                                        "FitGradVsRange",
13345                                        0,0,1200,800);
13346   cFitGradVsRange->SetFillColor(0);
13347   gFitGradVsRange->Draw("AP");
13348   gFitGradVsRange->SetTitle("Fit Gradient Vs Min Beam Energy in Fit");
13349   gFitGradVsRange->GetXaxis()->SetTitle("Min Beam Energy in Fit");
13350   gFitGradVsRange->GetYaxis()->SetTitle("Gradient of EnVsRange");
13351   gFitGradVsRange->GetXaxis()->CenterTitle();
13352   gFitGradVsRange->GetYaxis()->CenterTitle();
13353   gFitGradVsRange->SetMarkerStyle(3);
13354   gFitGradVsRange->SetMarkerColor(2);
13355   gFitGradVsRange->SetMarkerSize(0.8);
13356 
13357   //now plot the normalised one
13358   this->NormaliseVector(gradient);
13359   TGraph* gNormFitGradVsRange=TGraphVect(enRange,gradient);
13360   TCanvas *cNormFitGradVsRange=new TCanvas("cNormFitGradVsRange",
13361                                        "NormFitGradVsRange",
13362                                        0,0,1200,800);
13363   cNormFitGradVsRange->SetFillColor(0);
13364   gNormFitGradVsRange->Draw("AP");
13365   gNormFitGradVsRange->SetTitle("Fit Gradient Vs Min Beam Energy in Fit");
13366   gNormFitGradVsRange->GetXaxis()->SetTitle("Min Beam Energy in Fit");
13367   gNormFitGradVsRange->GetYaxis()->SetTitle("Gradient of EnVsRange");
13368   gNormFitGradVsRange->GetXaxis()->CenterTitle();
13369   gNormFitGradVsRange->GetYaxis()->CenterTitle();
13370   gNormFitGradVsRange->SetMarkerStyle(3);
13371   gNormFitGradVsRange->SetMarkerColor(2);
13372   gNormFitGradVsRange->SetMarkerSize(0.8);
13373 
13374   MSG("CDAnalysis",Msg::kDebug)
13375     <<"Vpl size="<<lastPlane.size()
13376     <<", Ven size="<<sumEnDepSc.size()<<endl;
13377   TGraph* gEnDepScVsRange=TGraphVect(lastPlane,sumEnDepSc);
13378   TCanvas *cEnDepScVsRange=new TCanvas("cEnDepScVsRange",
13379                                        "EnDepScVsRange",0,0,1200,800);
13380   cEnDepScVsRange->SetFillColor(0);
13381   gEnDepScVsRange->Draw("AP");
13382   gEnDepScVsRange->SetTitle("Energy Vs Range");
13383   gEnDepScVsRange->GetXaxis()->SetTitle("Range (planes)");
13384   gEnDepScVsRange->GetYaxis()->SetTitle("Energy Deposited in Sc (MeV)");
13385   gEnDepScVsRange->GetXaxis()->CenterTitle();
13386   gEnDepScVsRange->GetYaxis()->CenterTitle();
13387   gEnDepScVsRange->SetMarkerStyle(3);
13388   gEnDepScVsRange->SetMarkerColor(2);
13389   gEnDepScVsRange->SetMarkerSize(0.8);
13390 
13391   vector<Double_t> enRange2;
13392   vector<Double_t> gradient2;
13393 
13394   MSG("CDAnalysis",Msg::kInfo)
13395     <<"Second fit..."<<endl;
13396   for (vector<Double_t>::iterator r=lastPlane.begin();
13397        r!=lastPlane.end()-3;++r){
13398     //for (Float_t fitRangeMin=lastPlane[0];
13399     // fitRangeMin<lastPlane[lastPlane.size()-3]-1;fitRangeMin++){
13400     static Int_t counter=0;
13401     
13402     gEnDepScVsRange->Fit("pol1","q","",*r,1000);
13403     TF1* func=gEnDepScVsRange->GetFunction("pol1");
13404     Double_t funcM=func->GetParameter(1);
13405     MSG("CDAnalysis",Msg::kInfo)
13406       <<"fitMin="<<*r
13407       <<", m="<<funcM<<endl;
13408 
13409     enRange2.push_back(sumEnDepSc[counter]);
13410     gradient2.push_back(funcM);
13411 
13412     counter++;
13413   }
13414   MSG("CDAnalysis",Msg::kInfo)
13415     <<"Finished second fit..."<<endl;
13416 
13417   TGraph* gFitGradVsRange2=TGraphVect(enRange2,gradient2);
13418   TCanvas *cFitGradVsRange2=new TCanvas("cFitGradVsRange2",
13419                                        "FitGradVsRange2",
13420                                        0,0,1200,800);
13421   cFitGradVsRange2->SetFillColor(0);
13422   gFitGradVsRange2->Draw("AP");
13423   gFitGradVsRange2->SetTitle("Norm Fit Gradient Vs Min Energy Dep Sc in Fit");
13424   gFitGradVsRange2->GetXaxis()->SetTitle("Min Energy Dep Sc in Fit");
13425   gFitGradVsRange2->GetYaxis()->SetTitle("Gradient of EnDepScVsRange");
13426   gFitGradVsRange2->GetXaxis()->CenterTitle();
13427   gFitGradVsRange2->GetYaxis()->CenterTitle();
13428   gFitGradVsRange2->SetMarkerStyle(3);
13429   gFitGradVsRange2->SetMarkerColor(2);
13430   gFitGradVsRange2->SetMarkerSize(0.8);
13431 
13432   MSG("CDAnalysis",Msg::kInfo)
13433     <<"Plotting normalised one..."<<endl;
13434 
13435   //now plot the normalised one
13436   this->NormaliseVector(gradient2);
13437   TGraph* gNormFitGradVsRange2=TGraphVect(enRange2,gradient2);
13438   TCanvas *cNormFitGradVsRange2=new TCanvas("cNormFitGradVsRange2",
13439                                        "NormFitGradVsRange2",
13440                                        0,0,1200,800);
13441   cNormFitGradVsRange2->SetFillColor(0);
13442   gNormFitGradVsRange2->Draw("AP");
13443   gNormFitGradVsRange2->SetTitle("Norm Fit Gradient Vs Min Energy Dep Sc in Fit");
13444   gNormFitGradVsRange2->GetXaxis()->SetTitle("Min Energy Dep Sc in Fit");
13445   gNormFitGradVsRange2->GetYaxis()->SetTitle("Gradient of EnDepScVsRange");
13446   gNormFitGradVsRange2->GetXaxis()->CenterTitle();
13447   gNormFitGradVsRange2->GetYaxis()->CenterTitle();
13448   gNormFitGradVsRange2->SetMarkerStyle(3);
13449   gNormFitGradVsRange2->SetMarkerColor(2);
13450   gNormFitGradVsRange2->SetMarkerSize(0.8);
13451 
13452   TF1 *form2 = new TF1("form2",FitFunc,0,70,3);
13453   form2->SetParameters(1,1,0);
13454   form2->FixParameter(2,0);
13455   //gEnDepScVsRange->Fit("form2","q");
13456 }

void CDAnalysis::BbThkFeVsRange (  )  const

Definition at line 13214 of file CDAnalysis.cxx.

References CDSimpleMC::GetThkFe(), CDSimpleMC::GetTotalNumScPlanesHit(), Msg::kInfo, MSG, CDSimpleMC::RunMC(), CDSimpleMC::SetThkFe(), and TGraphVect().

13215 {
13216   //create simpleMC object
13217   CDSimpleMC mc;
13218 
13219   vector<Double_t> vPlanesHit;
13220   vector<Double_t> vThkFe;
13221 
13222   //loop over the different energies
13223   for (Double_t thkFe=2.4;thkFe<2.6;thkFe+=0.01){
13224     MSG("CDAnalysis",Msg::kInfo) 
13225       <<"thkFe="<<thkFe<<endl;
13226     
13227     //set up and run the MC
13228     mc.SetThkFe(thkFe);
13229     mc.RunMC();
13230     
13231     //fill the vectors
13232     vThkFe.push_back(mc.GetThkFe());
13233     vPlanesHit.push_back(mc.GetTotalNumScPlanesHit());
13234   }
13235 
13236   TGraph* gThkFeVsRange=TGraphVect(vPlanesHit,vThkFe);
13237   TCanvas *cThkFeVsRange=new TCanvas("cThkFeVsRange","ThkFeVsRange",
13238                                      0,0,1200,800);
13239   cThkFeVsRange->SetFillColor(0);
13240   gThkFeVsRange->Draw("AP");
13241   gThkFeVsRange->SetTitle("Iron Thickness Vs Range");
13242   gThkFeVsRange->GetXaxis()->SetTitle("Range (planes)");
13243   gThkFeVsRange->GetYaxis()->SetTitle("Fe Thk (cm)");
13244   gThkFeVsRange->GetXaxis()->CenterTitle();
13245   gThkFeVsRange->GetYaxis()->CenterTitle();
13246   gThkFeVsRange->SetMarkerStyle(3);
13247   gThkFeVsRange->SetMarkerColor(2);
13248   gThkFeVsRange->SetMarkerSize(0.8);
13249 }

void CDAnalysis::BbVsGminos (  ) 

Definition at line 12742 of file CDAnalysis.cxx.

References count, CDSimpleMC::fdE_dxFe, CDSimpleMC::fEn, CDSimpleMC::fEnDeposited, CDSimpleMC::fEnDepositedPl, CDSimpleMC::fEnFeDeposited, CDSimpleMC::fEnNotScDeposited, CDSimpleMC::fEnScDeposited, fEvents, FlipVector(), Form(), fS, CDSimpleMC::fX, CDSimpleMC::fXFePlanes, CDSimpleMC::fXNotScPlanes, CDSimpleMC::fXPlanes, CDSimpleMC::fXScPlanes, CDSimpleMC::GetTotalNumScPlanesHit(), InitialiseLoopVariables(), IsStraightTrack(), Msg::kDebug, Msg::kInfo, Msg::kVerbose, legend(), MSG, CDSimpleMC::RunMC(), SetLoopVariables(), TGraphVect(), TrueEnDep(), TrueEnDepNotSc(), and TrueNumDigiScintHits().

12743 {
12744   //create simpleMC object
12745   CDSimpleMC mc;
12746   //run mc
12747   mc.RunMC();
12748 
12749   Float_t sum15_18=0;
12750   Float_t sum15_18Sc=0;
12751   Float_t sum15_18NotSc=0;
12752   Float_t sum15_18All=0;
12753   Float_t sum15_18ScGminos=0;
12754   Float_t sum15_18NotScGminos=0;
12755   Float_t sum15_18AllGminos=0;
12756   Float_t sum15_18Counter=0;
12757   vector<Double_t> eDepositedPl;
12758 
12759   vector<Double_t> tempEnDep(60,0);
12760   vector<Double_t> tempEnDepNotSc(60,0);
12761   vector<Double_t> tempNumDsh(60,0);
12762   vector<Double_t> tempNum(60,0);
12763   vector<TH1F*> hEnDepNotSc;
12764 
12765   for (Int_t pl=0;pl<60;pl++){
12766     fS="Energy Deposition in Iron, plane=";
12767     string sPl=Form("%d",pl);
12768     fS+=sPl;
12769     hEnDepNotSc.push_back(new TH1F(fS.c_str(),fS.c_str(),600,-2,200));
12770     hEnDepNotSc[pl]->SetBit(TH1::kCanRebin);
12771   }
12772 
12776 
12777   this->InitialiseLoopVariables();  
12778   
12779   for(Int_t event=0;event<fEvents;event++){
12780     
12781     this->SetLoopVariables(event);
12782 
12783     //cut on not straight tracks
12784     Double_t mainX1Cut=0.5;
12785     if (!this->IsStraightTrack(mainX1Cut)){
12786       continue;
12787     }
12788 
12789     for (Int_t p=0;p<60;p++){
12790       Double_t enDep=this->TrueEnDep(p,event);
12791       Double_t enDepNotSc=this->TrueEnDepNotSc(p,event);
12792       Int_t numDsh=this->TrueNumDigiScintHits(p,event);
12793       //const Double_t latestT2=hitInfo->GetLatestT2();
12794       //fill the histo
12795       hEnDepNotSc[p]->Fill(1000*enDepNotSc);
12796       
12797       MSG("CDAnalysis",Msg::kVerbose) 
12798         <<", eDepNotSc="<<1000*enDepNotSc<<endl;
12799       
12800       //I'm not averaging zeros here - this is wrong!
12801       if (enDep>0 && enDepNotSc>0){
12802         tempEnDep[p]+=enDep;
12803         tempEnDepNotSc[p]+=enDepNotSc;
12804         tempNumDsh[p]+=numDsh;
12805         tempNum[p]++;
12806       }
12807     }
12808   }//end of for                                       
12809   
12813 
12814   TCanvas *cEnDep=new TCanvas("cEnDep","EnDep",0,0,1200,800);
12815   cEnDep->SetFillColor(0);
12816   cEnDep->Divide(2,3);
12817   cEnDep->cd(1);
12818   hEnDepNotSc[0]->Draw();
12819   cEnDep->cd(2);
12820   hEnDepNotSc[1]->Draw();
12821   cEnDep->cd(3);
12822   hEnDepNotSc[2]->Draw();
12823   cEnDep->cd(4);
12824   hEnDepNotSc[3]->Draw();
12825   cEnDep->cd(5);
12826   hEnDepNotSc[4]->Draw();
12827   cEnDep->cd(6);
12828   hEnDepNotSc[5]->Draw();
12829 
12830   vector<Double_t> eScGminos(60,0);
12831   vector<Double_t> eNotScGminos(60,0);
12832   vector<Double_t> numDshScGminos(60,0);
12833   vector<Double_t> xScGminos(60,0);
12834   Double_t totalEnDep=0;
12835 
12836   for (Int_t p=0;p<60;p++){
12837     if (tempNum[p]>0){
12838       eScGminos[p]=1000.*tempEnDep[p]/tempNum[p];
12839       eNotScGminos[p]=1000.*tempEnDepNotSc[p]/tempNum[p];
12840       numDshScGminos[p]=tempNumDsh[p]/tempNum[p];
12841     }
12842     xScGminos[p]=p;
12843 
12844     //keep a running total
12845     totalEnDep+=eScGminos[p]+eNotScGminos[p];
12846 
12847     MSG("CDAnalysis",Msg::kInfo) 
12848       <<"plane="<<xScGminos[p]
12849       <<", enDep="<<eScGminos[p]
12850       <<", enDepNotSc="<<eNotScGminos[p]
12851       <<", totalEnDep="<<totalEnDep<<endl;
12852   }
12853 
12855   //section for sliding window
12857   
12858   vector<TProfile*> pSigCorVsDist;
12859   vector<Int_t> vWindowSize;
12860   vector<Float_t> bigAv;
12861   vector<Int_t> bigAvCounter;
12862   Int_t minEventLength=40;
12863 
12864   //need a new vector for this!!!!
12867   MSG("CDAnalysis",Msg::kInfo) 
12868     <<"size="<<mc.fEnScDeposited.size()<<endl;
12869 
12870   //initialise the profile histos
12871   for (Int_t p=20;p>1;p--){
12872     vWindowSize.push_back(p);
12873     bigAv.push_back(0);
12874     bigAvCounter.push_back(0);
12875   }
12876   
12877   for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
12878        windowSize!=vWindowSize.end();++windowSize){
12879     
12880     string sName=Form("%d",*windowSize);
12881     pSigCorVsDist.push_back
12882       (new TProfile(("pSigCorVsDist"+sName).c_str(),
12883                     ("pSigCorVsDist"+sName).c_str(),100,-2,40));
12884   }
12885 
12886   vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12887   vector<Float_t>::iterator av=bigAv.begin();
12888   vector<Int_t>::iterator count=bigAvCounter.begin();
12889   
12890   //loop over the different window sizes
12891   for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
12892        windowSize!=vWindowSize.end();++windowSize){
12893     MSG("CDAnalysis",Msg::kDebug)
12894       <<"Window size="<<*windowSize<<endl;
12895  
12896     //slide the window along from the end to 40-windowSize
12897     for (Int_t p=0;p<minEventLength-*windowSize;p++){
12898       Int_t lastPlane=mc.fEnScDeposited.size()-1;
12899       Int_t windowStart=lastPlane-p;
12900 
12901       //loop through the hits in the window      
12902       for (Int_t i=0;i<*windowSize;i++){
12903         Int_t plane=windowStart-i;
12904         
12905         (*prof)->Fill(p,mc.fEnScDeposited[plane]);
12906         (*av)+=mc.fEnScDeposited[plane];
12907         (*count)++;
12908 
12909         //calculate the best window value
12910         if (*windowSize==15 && windowStart==lastPlane-18){
12911           //BB
12912           sum15_18+=mc.fEnDepositedPl[plane];
12913           sum15_18Sc+=mc.fEnScDeposited[plane];
12914           sum15_18NotSc+=mc.fEnNotScDeposited[plane];
12915           sum15_18All+=mc.fEnScDeposited[plane]+
12916             mc.fEnNotScDeposited[plane];
12917 
12918           //gminos
12919           sum15_18ScGminos+=eScGminos[plane];
12920           sum15_18NotScGminos+=eNotScGminos[plane];
12921           sum15_18AllGminos+=eScGminos[plane]+eNotScGminos[plane];
12922 
12923           //general counter
12924           sum15_18Counter++;
12925         }
12926       }
12927     }
12928     av++;
12929     count++;
12930     prof++;
12931   }
12932 
12933   //turn on the stats box printing
12934   gStyle->SetOptStat(11);
12935 
12936   TCanvas *cProf=new TCanvas("cProf","Prof",0,0,1200,800);
12937   cProf->SetFillColor(0);
12938   string sName="SlidingWindowBB.ps";
12939   cProf->Print((sName+"[").c_str());
12940   gErrorIgnoreLevel=1;
12941   //plot the unnormalised prof first
12942   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12943        prof!=pSigCorVsDist.end();++prof){      
12944     cProf->Clear();
12945     (*prof)->Draw();
12946     (*prof)->SetTitle("Energy Deposited in Sliding Window");
12947     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
12948     (*prof)->GetYaxis()->SetTitle("Energy Deposited (MeV)");
12949     (*prof)->GetXaxis()->CenterTitle();
12950     (*prof)->GetYaxis()->CenterTitle();
12951     cProf->Print(sName.c_str());
12952   }
12953 
12954   //now normalise the prof
12955   av=bigAv.begin();
12956   count=bigAvCounter.begin();
12957   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12958        prof!=pSigCorVsDist.end();++prof){
12959       
12960     //normalise the prof and scale the axes
12961     MSG("CDAnalysis",Msg::kInfo)
12962       <<"bigCounter="<<*count<<", bigAv="<<*av<<endl;
12963     if (*av>0) (*prof)->Scale((*count)/(*av));
12964     (*prof)->SetMaximum(1.2);
12965     (*prof)->SetMinimum(0.8);
12966       
12967     cProf->Clear();
12968     (*prof)->Draw();
12969     (*prof)->SetTitle("Normalised Energy Deposited in Sliding Window");
12970     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
12971     (*prof)->GetYaxis()->SetTitle("Normalised Energy Deposited");
12972     (*prof)->GetXaxis()->CenterTitle();
12973     (*prof)->GetYaxis()->CenterTitle();
12974     cProf->Print(sName.c_str());
12975     av++;
12976     count++;
12977   }
12978   //close the file
12979   gErrorIgnoreLevel=0;
12980   cProf->Print((sName+"]").c_str());
12981 
12982   TLegend *legend = new TLegend(0.85, 0.7, 0.9, 0.9);
12983   legend->SetBorderSize(0);
12984   legend->SetFillColor(0);
12985   legend->SetTextSize(0.035);
12986 
12987   //now do a few profs on the same plot
12988   TCanvas *cProf2=new TCanvas("cProf2","Prof",0,0,1200,800);
12989   cProf2->SetFillColor(0);
12990   sName="SlidingWindowAll.ps";
12991   //cProf2->Print((sName+"[").c_str());
12992   Int_t counter=0;
12993   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
12994        prof!=pSigCorVsDist.end();++prof){
12995 
12996     (*prof)->SetMaximum(1.09);
12997     (*prof)->SetMinimum(0.96);
12998 
12999     //count which prof got to
13000     counter++;
13001 
13002     //decide which profs to draw
13003     static Bool_t firstTime=true;
13004     if (counter==1 || counter==6 || counter==11){ 
13005       if (firstTime) {
13006         (*prof)->Draw();
13007         firstTime=false;
13008       }
13009       else  (*prof)->Draw("sames");
13010 
13011       (*prof)->SetTitle("Normalised Energy Deposited in Sliding Window");
13012       (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
13013       (*prof)->GetYaxis()->SetTitle("Normalised Energy Deposition");
13014       (*prof)->GetXaxis()->CenterTitle();
13015       (*prof)->GetYaxis()->CenterTitle();
13016       static Int_t color=2;
13017       (*prof)->SetLineColor(color);
13018       color+=2;
13019       string sWindowSize=Form("%d",21-counter);
13020       string sGraph=" Window size = ";
13021       sGraph+=sWindowSize;
13022       sGraph+=" planes";
13023       legend->AddEntry((*prof),sGraph.c_str(),"l");
13024     }
13025   }
13026   legend->Draw();
13027 
13028   //get the graphs
13029   TGraph* gScBb=TGraphVect(mc.fXScPlanes,mc.fEnScDeposited);
13030   TGraph* gScGminos=TGraphVect(xScGminos,eScGminos);
13031   TGraph* gNumDshScGminos=TGraphVect(xScGminos,numDshScGminos);
13032   
13033   //get canvas
13034   TCanvas *cBbVsGminos=new TCanvas("cBbVsGminos","BbVsGminos",
13035                                    0,0,1200,800);
13036   cBbVsGminos->SetFillColor(0);
13037   cBbVsGminos->Divide(1,3);
13038   cBbVsGminos->cd(1);
13039   gScBb->Draw("AP");
13040   gScBb->SetTitle("Energy Loss in Simple BB MC");
13041   gScBb->GetXaxis()->SetTitle("Plane");
13042   gScBb->GetYaxis()->SetTitle("Energy Loss (MeV)");
13043   gScBb->GetXaxis()->CenterTitle();
13044   gScBb->GetYaxis()->CenterTitle();
13045   gScBb->SetMarkerStyle(3);
13046   gScBb->SetMarkerColor(2);
13047   gScBb->SetMarkerSize(0.8);
13048   cBbVsGminos->cd(2);
13049   gScGminos->Draw("AP");
13050   gScGminos->SetTitle("Energy Loss in GMINOS");
13051   gScGminos->GetXaxis()->SetTitle("Plane");
13052   gScGminos->GetYaxis()->SetTitle("Energy Loss (MeV)");
13053   gScGminos->GetXaxis()->CenterTitle();
13054   gScGminos->GetYaxis()->CenterTitle();
13055   gScGminos->SetMarkerStyle(3);
13056   gScGminos->SetMarkerColor(2);
13057   gScGminos->SetMarkerSize(0.8);
13058   cBbVsGminos->cd(3);
13059   gNumDshScGminos->Draw("AP");
13060   gNumDshScGminos->SetTitle("Num DigiScintHits in GMINOS");
13061   gNumDshScGminos->GetXaxis()->SetTitle("Plane");
13062   gNumDshScGminos->GetYaxis()->SetTitle("Num DigiScintHits");
13063   gNumDshScGminos->GetXaxis()->CenterTitle();
13064   gNumDshScGminos->GetYaxis()->CenterTitle();
13065   gNumDshScGminos->SetMarkerStyle(3);
13066   gNumDshScGminos->SetMarkerColor(2);
13067   gNumDshScGminos->SetMarkerSize(0.8);
13068 
13069   //new graph
13070   TGraph* gNotScBb=TGraphVect(mc.fXNotScPlanes,mc.fEnNotScDeposited);
13071   TGraph* gFeBb=TGraphVect(mc.fXFePlanes,mc.fEnFeDeposited);
13072   TGraph* gNotScGminos=TGraphVect(xScGminos,eNotScGminos);
13073   TCanvas *cBbVsGminos2=new TCanvas("cBbVsGminos2","BbVsGminos2",
13074                                     0,0,1200,800);
13075   cBbVsGminos2->SetFillColor(0);
13076   cBbVsGminos2->Divide(1,2);
13077   cBbVsGminos2->cd(1);
13078   gNotScBb->Draw("AP");
13079   gNotScBb->SetTitle("Energy Loss in Non-Acive Material in BB");
13080   gNotScBb->GetXaxis()->SetTitle("Plane");
13081   gNotScBb->GetYaxis()->SetTitle("Energy Loss (MeV)");
13082   gNotScBb->GetXaxis()->CenterTitle();
13083   gNotScBb->GetYaxis()->CenterTitle();
13084   gNotScBb->SetMarkerStyle(3);
13085   gNotScBb->SetMarkerColor(2);
13086   gNotScBb->SetMarkerSize(0.8);
13087   gFeBb->Draw("P");
13088   gFeBb->SetMarkerStyle(3);
13089   gFeBb->SetMarkerColor(3);
13090   gFeBb->SetMarkerSize(0.8);
13091   cBbVsGminos2->cd(2);
13092   gNotScGminos->Draw("AP");
13093   gNotScGminos->SetTitle("Energy Loss in Non-Acive Material in GMINOS");
13094   gNotScGminos->GetXaxis()->SetTitle("Plane");
13095   gNotScGminos->GetYaxis()->SetTitle("Energy Loss (MeV)");
13096   gNotScGminos->GetXaxis()->CenterTitle();
13097   gNotScGminos->GetYaxis()->CenterTitle();
13098   gNotScGminos->SetMarkerStyle(3);
13099   gNotScGminos->SetMarkerColor(2);
13100   gNotScGminos->SetMarkerSize(0.8);
13101 
13102   //new graph
13103   this->FlipVector(mc.fXScPlanes);
13104   TGraph* eLossSc=TGraphVect(mc.fXScPlanes,mc.fEnScDeposited);
13105   TCanvas *cELossSc=new TCanvas("cELossSc","ELossSc",
13106                                    0,0,1200,800);
13107   cELossSc->SetFillColor(0);
13108   eLossSc->Draw("AP");
13109   eLossSc->SetTitle("Energy Loss in Scintillator");
13110   eLossSc->GetXaxis()->SetTitle("Distance from end of track (planes)");
13111   eLossSc->GetYaxis()->SetTitle("Energy Loss (MeV)");
13112   eLossSc->GetXaxis()->CenterTitle();
13113   eLossSc->GetYaxis()->CenterTitle();
13114   eLossSc->SetMarkerStyle(3);
13115   eLossSc->SetMarkerColor(2);
13116   eLossSc->SetMarkerSize(0.8);
13117 
13118   this->FlipVector(mc.fX);
13119   TGraph* energyLoss=TGraphVect(mc.fX,mc.fEnDeposited);
13120   TCanvas *cEnergyLoss=new TCanvas("cEnergyLoss","EnergyLoss",
13121                                    0,0,1200,800);
13122   cEnergyLoss->SetFillColor(0);
13123   energyLoss->Draw("AP");
13124   energyLoss->SetTitle("Energy Loss in Scintillator and Iron");
13125   energyLoss->GetXaxis()->SetTitle("Distance from end of track (cm)");
13126   energyLoss->GetYaxis()->SetTitle("Energy Loss (MeV)");
13127   energyLoss->GetXaxis()->CenterTitle();
13128   energyLoss->GetYaxis()->CenterTitle();
13129   energyLoss->SetMarkerStyle(3);
13130   energyLoss->SetMarkerColor(2);
13131   energyLoss->SetMarkerSize(0.8);
13132 
13133   this->FlipVector(mc.fXPlanes);
13134   TGraph* energyloss2=TGraphVect(mc.fXPlanes,mc.fEnDeposited);
13135   TCanvas *cEnergyloss2=new TCanvas("cEnergyloss2","Energyloss2",
13136                                    0,0,1200,800);
13137   cEnergyloss2->SetFillColor(0);
13138   energyloss2->Draw("AP");
13139   energyloss2->SetTitle("Energy Loss in Scintillator and Iron");
13140   energyloss2->GetXaxis()->SetTitle("Distance from end of track (planes)");
13141   energyloss2->GetYaxis()->SetTitle("Energy Loss (MeV)");
13142   energyloss2->GetXaxis()->CenterTitle();
13143   energyloss2->GetYaxis()->CenterTitle();
13144   energyloss2->SetMarkerStyle(3);
13145   energyloss2->SetMarkerColor(2);
13146   energyloss2->SetMarkerSize(0.8);
13147   
13148   TGraph* bb=TGraphVect(mc.fEn,mc.fdE_dxFe);
13149   TCanvas *cBb=new TCanvas("cBb","Bb",0,0,1200,800);
13150   cBb->SetFillColor(0);
13151   bb->Draw("AP");
13152   bb->SetMarkerStyle(3);
13153   bb->SetMarkerColor(2);
13154   bb->SetMarkerSize(0.8);
13155 
13156   if (sum15_18Counter!=0){
13157     MSG("CDAnalysis",Msg::kInfo) 
13158       <<endl
13159       <<" ** Calibration Summary **"<<endl
13160       <<"Total number of planes hit in BB="<<mc.GetTotalNumScPlanesHit()
13161       <<endl
13162       <<"Sliding Window 15_18:"<<endl
13163       <<"BB Steel and Scintillator:"<<endl
13164       <<"    Total energy dep="<<sum15_18<<" MeV"<<endl
13165       <<"    Av energy dep="<<sum15_18/sum15_18Counter
13166       <<" MeV"<<endl
13167       <<"GMINOS:"<<endl
13168       <<"    Total energy dep="<<"?"<<" MeV"<<endl
13169       <<"    Av energy dep="<<"?"
13170       <<" MeV"<<endl
13171       <<endl<<endl
13172       <<"BB Non-Active Material:"<<endl
13173       <<"    Total energy dep="<<sum15_18NotSc<<" MeV"<<endl
13174       <<"    Av energy dep="<<sum15_18NotSc/sum15_18Counter
13175       <<" MeV"<<endl
13176       <<"GMINOS:"<<endl
13177       <<"    Total energy dep="<<sum15_18NotScGminos<<" MeV"<<endl
13178       <<"    Av energy dep="<<sum15_18NotScGminos/sum15_18Counter
13179       <<" MeV ("<<100*(sum15_18NotScGminos-sum15_18NotSc)/sum15_18NotSc
13180       <<"%)"<<endl
13181       <<endl<<endl
13182       <<"BB Just Scintillator:"<<endl
13183       <<"    Total energy dep="<<sum15_18Sc<<" MeV"<<endl
13184       <<"    Av energy dep="<<sum15_18Sc/sum15_18Counter
13185       <<" MeV"<<endl
13186       <<"GMINOS:"<<endl
13187       <<"    Total energy dep="<<sum15_18ScGminos<<" MeV"<<endl
13188       <<"    Av energy dep="<<sum15_18ScGminos/sum15_18Counter
13189       <<" MeV ("<<100*(sum15_18ScGminos-sum15_18Sc)/sum15_18Sc<<"%)"
13190       <<endl
13191       <<endl<<endl
13192       <<"BB Total (Active+Passive):"<<endl
13193       <<"    Total energy dep="<<sum15_18All<<" MeV"<<endl
13194       <<"    Av energy dep="<<sum15_18All/sum15_18Counter
13195       <<" MeV"<<endl
13196       <<"GMINOS:"<<endl
13197       <<"    Total energy dep="<<sum15_18AllGminos<<" MeV"<<endl
13198       <<"    Av energy dep="<<sum15_18AllGminos/sum15_18Counter
13199       <<" MeV ("<<100*(sum15_18AllGminos-sum15_18All)/sum15_18All<<"%)"
13200       <<endl<<endl; 
13201   }
13202 }

void CDAnalysis::CalcAvStripForPSMuonCut ( Int_t  plane,
Int_t  strip,
Int_t  end 
) [private]

Definition at line 1152 of file CDAnalysis.cxx.

References fAvStrip, fAvStrip1, fAvStrip2, fStCount, fStCount1, fStCount2, fStripend, Msg::kVerbose, and MAXMSG.

Referenced by StoppingMuonCalibration().

01154 {
01155   if (plane<4){
01156     //calc weighted average strip
01157     fAvStrip=fAvStrip*(fStCount/(fStCount+1))+strip*(1/(fStCount+1));
01158     fStCount++;
01159     MAXMSG("CDAnalysis",Msg::kVerbose,1000)
01160       <<"  strip="<<strip<<", plane="<<plane
01161       <<", fEnd="<<fStripend<<", fAvStrip="<<fAvStrip
01162       <<", fStCount="<<fStCount<<endl;
01163 
01164     //now do each end separately
01165     if (end==1 && plane>0) {
01166       fAvStrip1=fAvStrip1*(fStCount1/(fStCount1+1))+
01167         strip*(1/(fStCount1+1));
01168       fStCount1++;
01169     }
01170     else if (end==2 && plane>0) {
01171       fAvStrip2=fAvStrip2*(fStCount2/(fStCount2+1))+
01172         strip*(1/(fStCount2+1));
01173       fStCount2++;
01174     }
01175   }
01176 }

Float_t CDAnalysis::CalcDistToPlaneCentre ( Int_t  strip,
Float_t  transPos 
) const [private]

Definition at line 2051 of file CDAnalysis.cxx.

References Munits::m.

Referenced by StraightTrack_Radius(), ValidateReco(), and ValidateTrkHits().

02053 {
02054   Float_t stripSize=0.041*Munits::m;
02055   Float_t distToPlaneCentre=-1;
02056   //note that strips are numbered from 0  
02057 
02058   //cutting on transPos==0 is ugly since it's an allowed value
02059   //but this is what it is initialised to and it 
02060   //should only cut real values rarely
02061   if (strip<0 || strip>23 || transPos<0 || transPos==0 || 
02062       transPos>23) return distToPlaneCentre;
02063 
02064   Float_t dist1=-1;
02065   Float_t dist2=-1;
02066   Float_t stripsFromCentre1=-1;
02067   Float_t transPosFromCentre1=-1;
02068 
02069   //get distances measured from plane centre in each view
02070   if (strip<=11) stripsFromCentre1=11-strip;
02071   else if (strip>11) stripsFromCentre1=strip-12;
02072   if (transPos<=11) transPosFromCentre1=11-transPos;
02073   else if (transPos>11) transPosFromCentre1=transPos-11;
02074 
02075   //calc real distances
02076   dist1=stripsFromCentre1*stripSize;
02077   dist2=transPosFromCentre1*stripSize;
02078   
02079   //move it to the middle of a strip so 
02080   //you know which strip it's actually in
02081   dist1+=stripSize*0.5;
02082   //transPos is not quantised so don't worry about it here
02083 
02084   //simple bit of trig
02085   if (dist1>0 && dist2>0){
02086     distToPlaneCentre=sqrt(pow(dist1,2)+pow(dist2,2));
02087   }
02088   
02089   return distToPlaneCentre;
02090 }

void CDAnalysis::CalcFirstLastPlane ( Int_t  plane  )  [private]

Definition at line 1205 of file CDAnalysis.cxx.

References fFirstPlane, fLastPlane, fLastPlaneEven, and fLastPlaneOdd.

Referenced by CalcLastPlaneOnTrk(), ElectronResponse(), MuonCalorimetry(), MuonNearFar(), MuonResponse(), MuonSampleCuts(), MuonScatter(), MuonStVsPl(), StoppingMuonCalibration(), and ValidateReco().

01206 {
01207   if (plane<fFirstPlane) fFirstPlane=plane;
01208   if (plane>fLastPlane) fLastPlane=plane;
01209   if (plane>fLastPlaneOdd && plane%2!=0) fLastPlaneOdd=plane;
01210   if (plane>fLastPlaneEven && plane%2==0) fLastPlaneEven=plane;
01211 }

void CDAnalysis::CalcLastPlaneOnTrk (  )  [private]

Definition at line 1255 of file CDAnalysis.cxx.

References CalcFirstLastPlane(), CutOnBadPedestals(), fLastPlane, fPlane, fStrip, fStripend, fTrkHitInfo, Msg::kVerbose, MSG, ReadInHitInfo(), and StandardSanityChecks().

Referenced by TruthEnDep().

01256 {
01257 
01258   TClonesArray &cTrk=*fTrkHitInfo;
01259   Int_t numTrkHits=fTrkHitInfo->GetEntries();
01260 
01262   //loop over the tracked hits
01264   for (Int_t hit=0;hit<numTrkHits;hit++){
01265     CDTrackedHitInfo *trackedHitInfo=
01266       dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01267     
01268     this->ReadInHitInfo(trackedHitInfo);
01269     
01270     //cut out the bad channels
01271     if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
01272     
01273     //check the channel's sanity
01274     this->StandardSanityChecks();
01275     
01276     //calculate the first and last planes
01277     this->CalcFirstLastPlane(fPlane);
01278     
01279   }
01281   //end of loop over the tracked hits
01283   
01284   MSG("CDAnalysis",Msg::kVerbose)
01285     <<"CalcLastPlaneOnTrk: fLastPlane="<<fLastPlane<<endl; 
01286 }

Int_t CDAnalysis::CalcLastPlaneOnTrkNoXTalk (  )  const [private]

Definition at line 1290 of file CDAnalysis.cxx.

References CutOnBadPedestals(), fLastPlane, fPlane, fTrkHitInfo, fUnTrkHitInfo, fXTalkHits, CDTrackedHitInfo::GetCharge(), CDXTalkHitInfo::GetCharge(), CDXTalkHitInfo::GetEnd(), CDTrackedHitInfo::GetEnd(), CDTrackedHitInfo::GetPlane(), CDXTalkHitInfo::GetPlane(), CDTrackedHitInfo::GetStrip(), CDXTalkHitInfo::GetStrip(), Msg::kDebug, CDTrackedHitInfo::kPe, Msg::kVerbose, and MSG.

Referenced by FillEnVsDist(), MuonCalorimetry(), MuonResponse(), MuonScatter(), and StoppingMuonCalibration().

01291 {
01292   //get tclones arrays for this snarl
01293   TClonesArray &cTrk=*fTrkHitInfo;
01294   Int_t numTrkHits=fTrkHitInfo->GetEntries();
01295   TClonesArray &cUnTrk = *fUnTrkHitInfo;
01296   Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
01297   TClonesArray &cXTalk = *fXTalkHits;
01298   Int_t numXTalkHits=fXTalkHits->GetEntries();
01299   
01300   map<Int_t,Float_t> planeGreatestPe;
01301   Int_t lastPlane=0;  
01302 
01303   //the untracked and xtalk hits are just used to find the greatest
01304   //pe in each plane; they are not included in the last plane 
01305   //directly
01306 
01308   //loop over the untracked hits in the snarl
01310   for (Int_t hit=0;hit<numUnTrkHits;hit++){
01311     //cast the tclonesarray up to a trackedhitinfo object
01312     CDTrackedHitInfo *hitInfo=
01313       dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
01314     
01315     //get the variables
01316     Int_t plane=hitInfo->GetPlane();
01317     Int_t strip=hitInfo->GetStrip();
01318     Int_t stripend=hitInfo->GetEnd();
01319     Float_t chargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01320 
01321     //cut out the bad channels
01322     if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01323     
01324     if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01325                                             chargePe;
01326   }
01327   
01329   //loop over xtalk hits in the snarl
01331   for (Int_t hit=0;hit<numXTalkHits;hit++){
01332     CDXTalkHitInfo *hitInfo=
01333       dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
01334     
01335     //get the variables
01336     Int_t plane=hitInfo->GetPlane();
01337     Int_t strip=hitInfo->GetStrip();
01338     Int_t stripend=hitInfo->GetEnd();
01339     Float_t chargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01340 
01341     //cut out the bad channels
01342     if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01343     
01344     if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01345                                             chargePe;
01346   }
01347 
01349   //loop over the tracked hits
01351   for (Int_t hit=0;hit<numTrkHits;hit++){
01352     CDTrackedHitInfo* hitInfo=
01353       dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01354     
01355     //get the variables
01356     Int_t plane=hitInfo->GetPlane();
01357     Int_t strip=hitInfo->GetStrip();
01358     Int_t stripend=hitInfo->GetEnd();
01359     Float_t chargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01360 
01361     if (plane>lastPlane) lastPlane=plane;
01362 
01363     //cut out the bad channels
01364     if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01365     
01366     if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01367                                             chargePe;
01368   }
01370   //end of loop over the tracked hits
01372 
01373   Int_t newLastPlane=lastPlane;
01374   Double_t xtalkLevel=1.7;
01375 
01376   if (fLastPlane>=3){//make sure track is at least 4 planes
01377     if (planeGreatestPe[lastPlane]>xtalkLevel){
01378       //do nothing
01379     }
01380     else if (planeGreatestPe[lastPlane-1]>xtalkLevel){
01381       newLastPlane=lastPlane-1;
01382     }
01383     else if (planeGreatestPe[lastPlane-2]>xtalkLevel){
01384       newLastPlane=lastPlane-2;
01385     }
01386     else{
01387       if (planeGreatestPe[lastPlane-3]<xtalkLevel){
01388         MSG("CDAnalysis",Msg::kDebug)
01389           <<"4th plane with low pe hit"
01390           <<", pe0="<<planeGreatestPe[lastPlane-0]
01391           <<", pe1="<<planeGreatestPe[lastPlane-1]
01392           <<", pe2="<<planeGreatestPe[lastPlane-2]
01393           <<", pe3="<<planeGreatestPe[lastPlane-3]
01394           <<endl;
01395       }
01396       newLastPlane=lastPlane-3;
01397     }
01398   }
01399   
01400   MSG("CDAnalysis",Msg::kVerbose)
01401     <<"CalcLastPlaneOnTrkNoXTalk: lastPlane="<<lastPlane
01402     <<", newLastPlane="<<newLastPlane<<endl; 
01403   
01404   return newLastPlane;
01405 }

Int_t CDAnalysis::CalcLastPlaneTruth (  )  const [private]

Definition at line 1215 of file CDAnalysis.cxx.

References fLastPlane, fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), DigiSignal::kGenuine, Msg::kVerbose, and MSG.

Referenced by TruthEnDep().

01216 {  
01217   if (!fTruthHitInfo) return 0;
01218 
01219   TClonesArray &cTruth = *fTruthHitInfo;
01220   Int_t numTruthHits=fTruthHitInfo->GetEntries();
01221 
01222   Int_t lastPlane=0;
01223 
01224   //loop over the truth hits
01225   for (Int_t hit=0;hit<numTruthHits;hit++){
01226     //cast the tclonesarray up to a truthhitinfo object
01227     CDTruthHitInfo *hitInfo=
01228       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
01229     
01230     Int_t plane=hitInfo->GetPlane();
01231     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
01232     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
01233 
01234     //check either side
01235     Int_t sumTruth=pmtTruth1|pmtTruth2;
01236 
01237     //check if genuine
01238     if ((sumTruth & DigiSignal::kGenuine)==DigiSignal::kGenuine){
01239       //see if bigger
01240       if (plane>lastPlane) lastPlane=plane;
01241     }
01242     MSG("CDAnalysis",Msg::kVerbose)
01243       <<"sumTruth="<<sumTruth<<endl;
01244   }
01245 
01246   MSG("CDAnalysis",Msg::kVerbose)
01247     <<"CalcLastPlaneTruth: LastPlane="<<lastPlane
01248     <<", fLastPlane="<<fLastPlane<<endl; 
01249 
01250   return lastPlane;
01251 }

void CDAnalysis::CalcLowUpScint_TofDiff ( Double_t  time  )  [private]

Definition at line 1180 of file CDAnalysis.cxx.

References fLowScint_Tof, fTofADCTimeStamp1, fUpScint_Tof, Msg::kWarning, and MAXMSG.

Referenced by ElectronResponse(), and StoppingMuonCalibration().

01181 {
01182   Double_t tickInNs=25./16;//ns, va clock tick
01183   Float_t timeDiff=(time*1e9)-(fTofADCTimeStamp1*tickInNs);//ns
01184 
01185   if (fTofADCTimeStamp1<1 || fTofADCTimeStamp1>1e9/tickInNs){
01186     MAXMSG("CDAnalysis",Msg::kWarning,10)
01187       <<"Bad Tof (TTAG) time="<<fTofADCTimeStamp1
01188       <<" ticks, ("<<fTofADCTimeStamp1*tickInNs<<" ns)"<<endl;
01189   }
01190 
01191   if (timeDiff>1000 || timeDiff<-1000){
01192     MAXMSG("CDAnalysis",Msg::kWarning,10)
01193       <<"Bad Scint-Tof (TTAG) time difference="<<timeDiff<<" ns"
01194       <<", time="<<time<<", tof time="<<fTofADCTimeStamp1
01195       <<" ticks, ("<<fTofADCTimeStamp1*tickInNs<<" ns)"<<endl;
01196   }
01197 
01198   //calc highest and lowest scint tof time diff.
01199   if (timeDiff>fUpScint_Tof) fUpScint_Tof=timeDiff;
01200   if (timeDiff<fLowScint_Tof) fLowScint_Tof=timeDiff;
01201 }

Double_t CDAnalysis::CalcMeuPLCorrected ( std::map< Int_t, Float_t >  plEnDep,
std::map< Int_t, Float_t >  plPLCor,
Int_t  event,
Float_t *  GeVPerMeu 
) const [private]

Definition at line 3777 of file CDAnalysis.cxx.

References Munits::cm, GetEventLength(), Msg::kDebug, Msg::kInfo, Msg::kWarning, MAXMSG, and TrueEnDep().

Referenced by StoppingMuonCalibration().

03782 {
03783   if (plEnDep.size()==0 || plPLCor.size()==0){
03784     MAXMSG("CDAnalysis",Msg::kWarning,10000)
03785       <<"Can't CalcMeuPLCorrected, map has size zero"<<endl;
03786     return -1;
03787   }
03788 
03789   Float_t local14_16=0;
03790   Float_t localSigCor=0;//for calc meu without fractions of planes
03791   Float_t localEnDep=0;//for calc meu without fractions of planes
03792   Int_t plCounter=0;
03793   Float_t initValue=-999;
03794   Float_t materialFromTrkEnd=0;
03795   Float_t materialInWindow=0;
03796   const Float_t material01Pl=(2.5+1)*Munits::cm;
03797   const Float_t material16Pl=16*material01Pl;
03798   const Float_t material14Pl=14*material01Pl;
03799   MAXMSG("CDAnalysis",Msg::kInfo,1)
03800     <<"Using 14 pls material="<<material14Pl
03801     <<", 16 plns="<<material16Pl
03802     <<", 1 plns="<<material01Pl<<endl;
03803 
03804   Int_t endPlane=this->GetEventLength();
03805 
03806   //calculate energy deposition in the window
03807   if (endPlane>=0){
03808     MAXMSG("CDAnalysis",Msg::kDebug,100)
03809       <<"Analysing track window, vtxPl=0"
03810       <<", endPl="<<endPlane<<endl;
03811     
03813     //loop over the track
03815     Int_t pl=endPlane;
03816     while (pl!=0){
03817       
03818       Float_t pathLengthCor=initValue;
03819       pathLengthCor=plPLCor[pl];
03820       if (pathLengthCor<1){
03821         MAXMSG("CDAnalysis",Msg::kWarning,1000)
03822           <<"pl="<<pl<<", endPlane="<<endPlane
03823           <<", path len cor wrong="<<pathLengthCor<<endl;
03824         //set default to 1
03825         pathLengthCor=1;
03826       }
03827 
03829       //sum up energy in window
03831       if ((materialFromTrkEnd+
03832            pathLengthCor*material01Pl)>material16Pl && 
03833           //check if window starts within or before this plane
03834           //&& that don't already have whole window of material
03835           materialInWindow<material14Pl){
03836 
03837         //alternatively start window after the plane in which 
03838         //the window should officially start part way through
03839         //if (materialFromTrkEnd>material16Pl && 
03840         //materialInWindow<material14Pl){
03841         
03842         //work out meu without using a fraction of a plane
03843         Float_t plCorEnDep=0;
03844         if (pathLengthCor) plCorEnDep=plEnDep[pl]/pathLengthCor;
03845         localSigCor+=plCorEnDep;
03846         plCounter++;
03847         //do it for the true en dep as well
03848         Float_t trueEnDep=this->TrueEnDep(pl,event);
03849         MAXMSG("CDAnalysis",Msg::kInfo,100)
03850           <<"trueEnDep="<<trueEnDep
03851           <<", PLCor="<<pathLengthCor
03852           <<", sum="<<localEnDep<<endl;
03853         if (pathLengthCor) trueEnDep/=pathLengthCor;
03854         localEnDep+=trueEnDep;
03855 
03856         //check if adding this much energy takes you over
03857         //the required amount of material
03858         if (materialInWindow+pathLengthCor*material01Pl>material14Pl){
03859 
03860           Float_t materialNeeded=material14Pl-materialInWindow;
03861           //calc the fraction of material/energy needed from this plane
03862           Float_t fractNeeded=materialNeeded/
03863             (pathLengthCor*material01Pl);
03864           
03865           MAXMSG("CDAnalysis",Msg::kDebug,100)
03866             <<"Last Chunk: matNeed="<<materialNeeded
03867             <<", matPl="<<pathLengthCor*material01Pl
03868             <<", 14Pl="<<material14Pl
03869             <<", matWin="<<materialInWindow
03870             <<", matTrk="<<materialFromTrkEnd<<endl
03871             <<"fractNeeded="<<fractNeeded<<", en in plane="<<plEnDep[pl]
03872             <<", en used="<<fractNeeded*plEnDep[pl]<<endl;
03873 
03874           //increment the material in window
03875           materialInWindow+=fractNeeded*(pathLengthCor*material01Pl);
03876 
03877           //add the required fraction of energy in this plane to
03878           //the total
03879           local14_16+=fractNeeded*plEnDep[pl];
03880         }
03881         else{
03882           //add the energy in this plane to the total
03883           materialInWindow+=pathLengthCor*material01Pl;
03884 
03885           MAXMSG("CDAnalysis",Msg::kDebug,500)
03886             <<"Window:p="<<pl
03887             <<", matPl="<<pathLengthCor*material01Pl
03888             <<", matWin="<<materialInWindow
03889             <<", matTrk="<<materialFromTrkEnd
03890             <<", plEn="<<plEnDep[pl]
03891             <<endl;
03892 
03893           //increment the energy deposited
03894           local14_16+=plEnDep[pl];
03895         }
03896       }
03897 
03898       MAXMSG("CDAnalysis",Msg::kDebug,1000)
03899         <<"local: matPl="<<pathLengthCor*material01Pl
03900         <<", matTrk="<<materialFromTrkEnd
03901         <<", matWin="<<materialInWindow<<", sumEnDep="<<local14_16
03902         <<"PLCor="<<pathLengthCor
03903         <<endl;
03904 
03905       //sum up material traversed
03906       if (pathLengthCor>0) materialFromTrkEnd+=pathLengthCor*
03907                              material01Pl;
03908       else {
03909         MAXMSG("CDAnalysis",Msg::kInfo,1000)
03910           <<"Ahhh path len cor wrong="<<pathLengthCor<<endl;
03911       }
03912 
03913       //increment the plane
03914       pl--;
03915     }
03916   }
03917 
03918   Float_t winSigCor=0;
03919   if (plCounter){
03920     winSigCor=localSigCor/plCounter;
03921     localEnDep/=plCounter;
03922     //set the output variable
03923     if (GeVPerMeu) *GeVPerMeu=localEnDep;
03924   }
03925 
03926   //meu from fraction of last plane in window
03927   local14_16/=14;
03928 
03929   //decide which to use
03930   Float_t meu=local14_16;
03931   Bool_t useNoFraction=true;
03932   if (useNoFraction) meu=winSigCor;
03933 
03934   //calc fraction of material in window actually obtained
03935   Float_t fractWin=materialInWindow/material14Pl;
03936   
03937   MAXMSG("CDAnalysis",Msg::kInfo,500)
03938     <<"14_16="<<local14_16<<", winSigCor="<<winSigCor
03939     <<", plCounter="<<plCounter<<", fractWin="<<fractWin<<endl;
03940 
03941   //don't return meu when only a fraction of window was obtained
03942   if (fractWin<1) meu=-1;
03943 
03944   return meu;
03945 }

void CDAnalysis::CalcNumPlanesHit ( Int_t  plane,
Float_t  pe 
) [private]

Definition at line 1125 of file CDAnalysis.cxx.

References fNumPlanesHit25, fNumPlanesHitAll, fNumPlanesHitPeCut, and fNumPlanesHitPeCut10.

Referenced by ElectronResponse(), and StoppingMuonCalibration().

01126 {
01127   //calc the num planes hit
01128   fNumPlanesHitAll[plane]++;
01129 
01130   //calc number of planes hit in first 25
01131   if (plane<25) fNumPlanesHit25[plane]++;
01132 
01133   //calc if pe cut satisfied
01134   if (pe>1.5) {
01135     fNumPlanesHitPeCut[plane]++;
01136 
01137     //only calc planes hit in first 10 planes
01138     if (plane<10) fNumPlanesHitPeCut10[plane]++;
01139   }
01140 }

void CDAnalysis::CalcNumPlanesHitTrk ( Int_t  plane  )  [private]

Definition at line 1144 of file CDAnalysis.cxx.

References fNumPlanesHitTrk.

Referenced by MuonStVsPl().

01145 {
01146   //calc the num planes hit
01147   fNumPlanesHitTrk[plane]++;
01148 }

Float_t CDAnalysis::CalcPathLengthCorection ( const TVector3 &  end1,
const TVector3 &  end2 
) const [private]

Definition at line 1484 of file CDAnalysis.cxx.

01486 {
01487   //calc pathlength between two points
01488   Float_t x=end1.X()-end2.X();
01489   Float_t y=end1.Y()-end2.Y();
01490   Float_t z=end1.Z()-end2.Z();
01491   Float_t pathLength=sqrt(pow(x,2)+pow(y,2)+pow(z,2));
01492   //calc path length correction
01493   Float_t pathLengthCor=-1;
01494   if (z!=0) pathLengthCor=pathLength/fabs(z);
01495   else cout<<"pathlength cor problem: z="<<z
01496            <<", x="<<x<<", y="<<y<<endl;
01497   return pathLengthCor;
01498 }

Bool_t CDAnalysis::CalcPLCor ( const std::map< Int_t, TVector3 > &  mPlPos,
std::map< Int_t, Float_t > &  mPLCor 
) const [private]

Definition at line 1600 of file CDAnalysis.cxx.

References GetEventLength(), Msg::kDebug, Nav::kInfo, Msg::kVerbose, Nav::kWarning, MAXMSG, and MSG.

Referenced by StoppingMuonCalibration().

01602 {
01603   map<Int_t,TVector3>::const_iterator plPosEndIt=mPlPos.end();
01604 
01605   //Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
01606   Int_t lastPlane=this->GetEventLength();
01607   Float_t initValue=-999;
01608  
01609   for (Int_t pl=0;pl<=lastPlane;pl++){
01610     Int_t plVtxSide=pl-2;
01611     Int_t plStopSide=pl+2;
01612     
01613     //protect against going outside allowed ranges
01614     if (plVtxSide<0) plVtxSide=0;
01615     if (plStopSide>lastPlane) plStopSide=lastPlane;
01616 
01617     MAXMSG("CDAnalysis",Msg::kDebug,500)
01618       <<"pl="<<pl<<", plStopSide="<<plStopSide
01619       <<", plVtxSide="<<plVtxSide<<endl;
01620 
01621     //fit track position
01622     TGraph gx_z(3);//min of 3 points
01623     TGraph gy_z(3);
01624     Int_t tmpPl=plStopSide;
01625     Int_t tmpPlVtxSide=plVtxSide+1;
01626     Bool_t posDir=true;//always forward going in caldet
01627     if (posDir) tmpPlVtxSide=plVtxSide-1;
01628     Int_t i=0;
01629     //loop over planes to fit
01630     while (tmpPl!=tmpPlVtxSide){
01631       map<Int_t,TVector3>::const_iterator plPosIt=mPlPos.find(tmpPl);
01632       if (plPosIt!=plPosEndIt){
01633         Float_t x=(plPosIt->second).x();
01634         Float_t y=(plPosIt->second).y();
01635         Float_t z=(plPosIt->second).z();
01636         gx_z.SetPoint(i,z,x);
01637         gy_z.SetPoint(i,z,y);
01638         MAXMSG("CDAnalysis",Msg::kVerbose,500)
01639           <<"Adding point: x="<<x<<", y="<<y<<", z="<<z<<endl;
01640         //count the number of points added
01641         i++;
01642       }
01643       //increment the plane
01644       if (posDir) tmpPl--;
01645       else tmpPl++;
01646     }
01647   
01648     Float_t newPLCor=initValue;
01649     if (i>=3){
01650       gx_z.Fit("pol1","q");
01651       gy_z.Fit("pol1","q");
01652       Float_t mx_z=gx_z.GetFunction("pol1")->GetParameter(1);
01653       Float_t my_z=gy_z.GetFunction("pol1")->GetParameter(1);
01654       //Float_t mx_zErr=gx_z.GetFunction("pol1")->GetParError(1);
01655       //Float_t my_zErr=gy_z.GetFunction("pol1")->GetParError(1);
01656       newPLCor=sqrt(pow(mx_z,2)+pow(my_z,2)+1);
01657       MAXMSG("CDAnalysis",Msg::kDebug,500)
01658         <<"pl="<<pl<<", found plcor="<<newPLCor<<endl;
01659     }
01660     else {
01661       MSG("CDAnalysis",kWarning)
01662         <<"Less than 3 points, can't do local grad. fit"<<endl;
01663       return false;
01664     }
01665 
01666     if (newPLCor!=initValue) mPLCor[pl]=newPLCor;
01667     else MSG("CDAnalysis",kInfo)<<"Bad PLCor"<<endl;
01668 
01669   } 
01670 
01671   return true;
01672 }

void CDAnalysis::CalcXorYandZ ( Int_t  strip,
Int_t  plane,
Float_t &  x,
Float_t &  y,
Float_t &  z 
) const [private]

Definition at line 1502 of file CDAnalysis.cxx.

References Munits::cm.

Referenced by CalcXYZ().

01504 {
01505   Float_t planePitch=5.94*Munits::cm;
01506   Float_t stripWidth=4.1*Munits::cm;
01507   Float_t stripsFromCentre=strip-11.5;//middle 2 strips 11&12 are 0.5 st
01508   Float_t distFromCentre=stripsFromCentre*stripWidth;
01509   
01510   //calc z
01511   z=plane*planePitch;
01512 
01513   if (plane%2==0){//even, v-view (measure v and y), horizontal strips
01514     x=-1;
01515     y=distFromCentre;
01516   }
01517   else if (plane%2==1){//odd, u-view (measure u and x), vertical strips
01518     x=distFromCentre;;
01519     y=-1;
01520   }
01521 }

Bool_t CDAnalysis::CalcXYZ ( std::map< Int_t, TVector3 > &  mPlPos  )  const [private]

Definition at line 1676 of file CDAnalysis.cxx.

References CalcXorYandZ(), CutOnBadPedestals(), fLastPlane, fTrkHitInfo, CDTrackedHitInfo::GetEnd(), GetEventLength(), CDTrackedHitInfo::GetPlane(), CDTrackedHitInfo::GetStrip(), Msg::kDebug, Msg::kVerbose, Msg::kWarning, and MAXMSG.

Referenced by StoppingMuonCalibration().

01677 {
01678   //get tclones arrays for this snarl
01679   TClonesArray &cTrk=*fTrkHitInfo;
01680   Int_t numTrkHits=fTrkHitInfo->GetEntries();
01681   
01682   if (numTrkHits<2){
01683     MAXMSG("CDAnalysis",Msg::kWarning,100)
01684       <<"CalcXYZ::numTrkHits is bad="<<numTrkHits<<endl;
01685     return false;
01686   }
01687 
01688   //Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
01689   Int_t lastPlane=this->GetEventLength();
01690   if (lastPlane<2 || lastPlane>59){
01691     MAXMSG("CDAnalysis",Msg::kWarning,100)
01692       <<"CalcXYZ::last plane is bad="<<lastPlane<<endl;
01693     return false;
01694   }
01695 
01696   Bool_t foundFirstFew=false;
01697   Bool_t unFilledGap=false;
01698   Float_t initValue=-999;
01699   vector<TVector3> plPosition(60);
01700   for (Int_t pl=0;pl<60;pl++){
01701     plPosition[pl]=TVector3(initValue,initValue,initValue);
01702   }
01703 
01705   //loop over the tracked hits
01707   for (Int_t hit=0;hit<numTrkHits;hit++){
01708     CDTrackedHitInfo* hitInfo=
01709       dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01710     
01711     //get the variables
01712     Int_t plane=hitInfo->GetPlane();
01713     Int_t strip=hitInfo->GetStrip();
01714     Int_t stripend=hitInfo->GetEnd();
01715     //Float_t chargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01716 
01717     //cut out the bad channels
01718     if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01719 
01720     Float_t x=initValue;
01721     Float_t y=initValue;
01722     Float_t z=initValue;
01723     this->CalcXorYandZ(strip,plane,x,y,z);
01724 
01725     plPosition[plane]=TVector3(x,y,z);
01726 
01727   }
01729   //end of loop over the tracked hits
01731 
01732   //calc the x and y of the first two planes
01733   //loop and look at more planes if can't find any hits in first few
01734   for (Int_t np=2;np<=5;np++){
01735     //look at first few even planes
01736     Float_t yAvFirstFew=0;
01737     Float_t yAvFirstFewCounter=0;
01738     for (Int_t pl=0;pl<np*2;pl+=2){//even measures v or y
01739       if (plPosition[pl].y()!=initValue){
01740         yAvFirstFew+=plPosition[pl].y();
01741         yAvFirstFewCounter++;
01742       }
01743     }
01744     if (yAvFirstFewCounter>0) yAvFirstFew/=yAvFirstFewCounter;
01745     else yAvFirstFew=initValue;
01746     
01747     //look at first few odd planes
01748     Float_t xAvFirstFew=0;
01749     Float_t xAvFirstFewCounter=0;
01750     for (Int_t pl=1;pl<np*2;pl+=2){//odd measures u or x
01751       if (plPosition[pl].x()!=initValue){
01752         xAvFirstFew+=plPosition[pl].x();
01753         xAvFirstFewCounter++;
01754       }
01755     }
01756     if (xAvFirstFewCounter>0) xAvFirstFew/=xAvFirstFewCounter;
01757     else xAvFirstFew=initValue;
01758     
01759     MAXMSG("CDAnalysis",Msg::kDebug,1000)
01760       <<"num planes="<<np
01761       <<", avX="<<xAvFirstFew<<" ("<<xAvFirstFewCounter<<")"
01762       <<", avY="<<yAvFirstFew<<" ("<<yAvFirstFewCounter<<")"<<endl;
01763 
01764     //now set the TVectors if an average was obtained
01765     if (xAvFirstFew==initValue || yAvFirstFew==initValue){
01766       MAXMSG("CDAnalysis",Msg::kVerbose,100)
01767         <<endl<<"Not found tracked hits with num planes="<<np
01768         <<", looping again..."<<endl<<endl;
01769     }
01770     else{
01771       //set the first 2 planes (what is not measured by that plane)
01772       plPosition[0].SetX(xAvFirstFew);
01773       plPosition[1].SetY(yAvFirstFew);
01774       
01775       //sometimes have to set what should have been measured if 
01776       //it is missing
01777       if (plPosition[0].Y()==initValue || plPosition[1].X()==initValue){
01778         MAXMSG("CDAnalysis",Msg::kDebug,100)
01779           <<endl<<"Having to manually set x or y in first few planes"
01780           <<endl<<endl;
01781         //plPosition[0].Print();
01782         //plPosition[1].Print();
01783       }
01784       if (plPosition[0].Y()==initValue) plPosition[0].SetY(yAvFirstFew);
01785       if (plPosition[1].X()==initValue) plPosition[1].SetX(xAvFirstFew);
01786       foundFirstFew=true;
01787       break;
01788     }
01789   }
01790 
01791   if (!foundFirstFew){
01792     MAXMSG("CDAnalysis",Msg::kDebug,100)
01793       <<endl<<"Not found hits in first few planes ignoring this event"
01794       <<endl<<endl;
01795     return false;
01796   }
01797 
01798   //probably best to do the +/- 2 planes first to fill the gaps
01799   //then do the interpolation into the planes that don't measure
01800   //what is needed.
01801 
01803   //loop and fill the gaps
01805   for (Int_t pl=2;pl<=lastPlane;pl++){
01806 
01807     Bool_t foundGap=false;
01808     
01809     //check for gaps
01810     if (pl%2==0){//even planes, measures v and y
01811       if (plPosition[pl].Y()==initValue) foundGap=true;
01812     }
01813     else if (pl%2==1){//odd planes, measures u and x
01814       if (plPosition[pl].X()==initValue) foundGap=true;
01815     }
01816 
01817     if (foundGap) {
01818       Int_t plPrev=pl-2;
01819       Int_t plNext=pl+2;
01820       Int_t plPrev4=pl-4;
01821       Int_t plNext4=pl+4;
01822       Float_t posPrev=initValue;
01823       Float_t posNext=initValue;
01824       Float_t pos=initValue;
01825       Float_t posPrev4=initValue;
01826       Float_t posNext4=initValue;
01827       Float_t pos4=initValue;
01828 
01829       //protect against going outside allowed ranges
01830       if (plPrev<0) {
01831         if (abs(plPrev%2)==0) plPrev=0;//even
01832         else if (abs(plPrev%2)==1) plPrev=1;//odd
01833       }
01834       if (plNext>59){
01835         if (plNext%2==0) plNext=58;//even
01836         else if (plNext%2==1) plNext=59;//odd
01837       }
01838       if (plPrev4<0) {
01839         if (abs(plPrev4%2)==0) plPrev4=0;//even
01840         else if (abs(plPrev4%2)==1) plPrev4=1;//odd
01841       }
01842       if (plNext4>59){
01843         if (plNext4%2==0) plNext4=58;//even
01844         else if (plNext4%2==1) plNext4=59;//odd
01845       }
01846       
01847       if (pl%2==0){//even planes, measures v and y
01848         //get position
01849         posPrev=plPosition[plPrev].Y();
01850         posNext=plPosition[plNext].Y();
01851         posPrev4=plPosition[plPrev4].Y();
01852         posNext4=plPosition[plNext4].Y();
01853       }
01854       else if (pl%2==1){//odd planes, measures u and x
01855         //get position
01856         posPrev=plPosition[plPrev].X();
01857         posNext=plPosition[plNext].X();
01858         posPrev4=plPosition[plPrev4].X();
01859         posNext4=plPosition[plNext4].X();
01860       }
01861       
01862       if (posPrev==initValue || posNext==initValue){
01863         MAXMSG("CDAnalysis",Msg::kDebug,500)
01864           <<"pl="<<pl<<", not found position"
01865           <<", prev="<<posPrev<<", next="<<posNext
01866           <<endl;
01867       }
01868       else{
01869         //calc the new position
01870         pos=(posPrev+posNext)*0.5;
01871         //MAXMSG("CDAnalysis",Msg::kDebug,1000)
01872         //<<"pl="<<pl
01873         //<<", found positions, prev="<<posPrev<<", next="<<posNext
01874         //<<", pos="<<pos<<endl;
01875       }
01876 
01877       if (posPrev4==initValue || posNext4==initValue){
01878         MAXMSG("CDAnalysis",Msg::kDebug,500)
01879           <<"pl="<<pl<<", not found position"
01880           <<", prev4="<<posPrev4<<", next4="<<posNext
01881           <<endl;
01882       }
01883       else{
01884         //calc the new position
01885         pos4=(posPrev4+posNext4)*0.5;
01886         //MAXMSG("CDAnalysis",Msg::kDebug,1000)
01887         //<<"pl="<<pl
01888         //<<", found positions, prev4="<<posPrev4<<", next4="<<posNext4
01889         //<<", pos4="<<pos4<<endl;
01890       }
01891     
01892       Float_t posToUse=pos;
01893       if (posToUse==initValue) posToUse=pos4;
01894 
01895       if (posToUse!=initValue){
01896         if (pl%2==0){//even planes, measures v and y
01897           //set position
01898           //MAXMSG("CDAnalysis",Msg::kDebug,1000)
01899           //<<"pl="<<pl<<", setting pos="<<posToUse
01900           //<<", y was="<<plPosition[pl].Y()<<endl;
01901           plPosition[pl].SetY(posToUse);
01902         }
01903         else if (pl%2==1){//odd planes, measures u and x
01904           //set position
01905           //MAXMSG("CDAnalysis",Msg::kDebug,1000)
01906           //<<"pl="<<pl<<", setting pos="<<posToUse
01907           //<<", x was="<<plPosition[pl].X()<<endl;
01908           plPosition[pl].SetX(posToUse);
01909         }
01910       }
01911       else{
01912         MAXMSG("CDAnalysis",Msg::kDebug,3000)
01913           <<"pl="<<pl<<", fLastPlane="<<fLastPlane
01914           <<", lastPl="<<lastPlane
01915           <<", not managed to fill gap with first method"<<endl;
01916         unFilledGap=true;
01917       }
01918     }
01919     else{
01920       MAXMSG("CDAnalysis",Msg::kDebug,3000)
01921         <<"pl="<<pl<<", no gap"<<endl;
01922     }
01923   }
01924 
01925   //fill any gaps that failed to get filled above
01926   //simple algorithm to just use the previous x/y value in the track
01927   Float_t lastX=initValue;
01928   Float_t lastY=initValue;
01929   if (unFilledGap){
01930     for (Int_t pl=0;pl<=lastPlane;pl++){
01931       if (pl%2==0){//even planes, measures v and y
01932         if (plPosition[pl].Y()==initValue){
01933           plPosition[pl].SetY(lastY);
01934           //MAXMSG("CDAnalysis",Msg::kVerbose,1000)
01935           //<<"pl="<<pl<<", fLastPlane="<<fLastPlane
01936           //<<", lastPl="<<lastPlane
01937           //<<", filled gap (y="<<lastY<<")"<<endl;
01938         }
01939         //get last position in track
01940         lastY=plPosition[pl].Y();
01941       }
01942       else if (pl%2==1){//odd planes, measures u and x
01943         if (plPosition[pl].X()==initValue){
01944           plPosition[pl].SetX(lastX);
01945           //MAXMSG("CDAnalysis",Msg::kVerbose,1000)
01946           //<<"pl="<<pl<<", fLastPlane="<<fLastPlane
01947           //<<", lastPl="<<lastPlane
01948           //<<", filled gap (x="<<lastX<<")"<<endl;
01949         }
01950         //get last position in track
01951         lastX=plPosition[pl].X();
01952       }
01953     }
01954   }
01955   
01957   //loop and just do the simple calculations 
01958   //+/- 1 plane to calc what is not measured
01960   for (Int_t pl=2;pl<=lastPlane;pl++){
01961     Int_t plPrev=pl-1;
01962     Int_t plNext=pl+1;
01963     Float_t posPrev=initValue;
01964     Float_t posNext=initValue;
01965     Float_t pos=initValue;
01966     
01967     //protect against going outside allowed ranges
01968     if (plPrev<0) {
01969       if (abs(plPrev%2)==0) plPrev=0;//even
01970       else if (abs(plPrev%2)==1) plPrev=1;//odd
01971     }
01972     if (plNext>59){
01973       if (plNext%2==0) plNext=58;//even
01974       else if (plNext%2==1) plNext=59;//odd
01975     }
01976     
01977     if (pl%2==0){//even planes, measures v and y
01978       //get position
01979       posPrev=plPosition[plPrev].X();
01980       posNext=plPosition[plNext].X();
01981     }
01982     else if (pl%2==1){//odd planes, measures u and x
01983       //get position
01984       posPrev=plPosition[plPrev].Y();
01985       posNext=plPosition[plNext].Y();
01986     }
01987     
01988     if (posPrev==initValue || posNext==initValue){
01989       MAXMSG("CDAnalysis",Msg::kDebug,500)
01990         <<"pl="<<pl<<", fLastPlane="<<fLastPlane
01991         <<", lastPl="<<lastPlane
01992         <<", not found position"
01993         <<", prev="<<posPrev<<", next="<<posNext
01994         <<endl;
01995     }
01996     else{
01997       //calc the new position
01998       pos=(posPrev+posNext)*0.5;
01999       MAXMSG("CDAnalysis",Msg::kDebug,1000)
02000         <<"pl="<<pl
02001         <<", found positions, prev="<<posPrev<<", next="<<posNext
02002         <<", pos="<<pos<<endl;
02003     }
02004     
02005     if (pl%2==0){//even planes, measures v and y
02006       //set position
02007       plPosition[pl].SetX(pos);
02008     }
02009     else if (pl%2==1){//odd planes, measures u and x
02010       //set position
02011       plPosition[pl].SetY(pos);
02012     }
02013   }
02014   
02015   //need to do a 3D vector type correction to work out the last plane
02016   //but hack for now - use same x/y as previous plane
02017   Int_t pl=lastPlane;
02018   if (pl%2==0){//even planes, measures v and y
02019     //set position
02020     Float_t lastPlX=plPosition[pl-1].X();
02021     plPosition[pl].SetX(lastPlX);
02022   }
02023   else if (pl%2==1){//odd planes, measures u and x
02024     //set position
02025     Float_t lastPlY=plPosition[pl-1].Y();
02026     plPosition[pl].SetY(lastPlY);
02027   }
02028   
02029   //MAXMSG("CDAnalysis",Msg::kInfo,200)
02030   //<<"fLastPlane="<<fLastPlane
02031   //<<", lastPl="<<lastPlane
02032   //<<endl;
02033   //loop and print positions
02034   //for (Int_t pl=0;pl<60;pl++){
02035   //MAXMSG("CDAnalysis",Msg::kInfo,5000)
02036   //  <<"pl="<<pl<<" (x,y,z)=("<<plPosition[pl].X()
02037   //  <<","<<plPosition[pl].Y()
02038   //  <<","<<plPosition[pl].Z()<<")"<<endl;
02039   //}
02040   
02041   //make map to return (not nice)
02042   for (Int_t pl=0;pl<60;pl++){
02043     mPlPos[pl]=plPosition[pl];
02044   }
02045   
02046   return true;
02047 }

void CDAnalysis::CleanMuons (  ) 

Definition at line 13551 of file CDAnalysis.cxx.

References MuELoss::e, fEvents, Form(), fOutFile, fPIDInfo, fRunNumber, fTime, fTrackInfo, fTrkHitInfo, fUnTrkHitInfo, fXTalkHits, CDTrackedHitInfo::GetCharge(), CDXTalkHitInfo::GetCharge(), CDTrackedHitInfo::GetDxDz(), CDTrackedHitInfo::GetDyDz(), CDTrackedHitInfo::GetDzDs(), CDTrackedHitInfo::GetEnd(), CDPIDInfo::GetFafErr(), CDPIDInfo::GetKovADC1(), CDPIDInfo::GetKovADC2(), CDPIDInfo::GetKovADC3(), CDPIDInfo::GetKovTimeStamp1(), CDPIDInfo::GetKovTimeStamp2(), CDPIDInfo::GetKovTimeStamp3(), CDTrackedHitInfo::GetPlane(), CDXTalkHitInfo::GetPlane(), CDTrackInfo::GetResult(), CDPIDInfo::GetSnarlMaxTimeStamp(), CDPIDInfo::GetSnarlMinTimeStamp(), CDPIDInfo::GetSnarlTimeFrame(), CDPIDInfo::GetSparseErr(), CDTrackedHitInfo::GetStrip(), CDXTalkHitInfo::GetStrip(), CDPIDInfo::GetTickSinceLast(), CDPIDInfo::GetTofADC0(), CDPIDInfo::GetTofADC1(), CDPIDInfo::GetTofADC2(), CDPIDInfo::GetTofADCTimeStamp0(), CDPIDInfo::GetTofADCTimeStamp1(), CDPIDInfo::GetTofADCTimeStamp2(), CDPIDInfo::GetTofTDC0(), CDPIDInfo::GetTofTDC1(), CDPIDInfo::GetTofTDC2(), CDPIDInfo::GetTofTimeStamp(), CDTrackedHitInfo::GetTransPos(), CDPIDInfo::GetTriggerPMT(), CDPIDInfo::GetTrigSource(), CDTrackedHitInfo::GetYPos(), InitialiseLoopVariables(), CDTrackedHitInfo::kAdc, Msg::kDebug, Msg::kInfo, CDTrackedHitInfo::kPe, CDTrackedHitInfo::kSigCorr, CDTrackedHitInfo::kSigLin, Msg::kVerbose, Msg::kWarning, MAXMSG, MSG, OpenFile(), ReadInHitInfo(), ScaleMap(), SetLoopVariables(), and TGraphMap().

13552 {
13553   MSG("CDAnalysis",Msg::kInfo) 
13554     <<" ** Running CleanMuons method... **"<<endl;
13555 
13556   //open the output file for the histograms
13557   fOutFile=this->OpenFile(fRunNumber,"CleanMuons");
13558 
13559   TH1F *hTime=new TH1F("hTime","hTime",100000,-500-9,500e-9);
13560   hTime->GetXaxis()->SetTitle("Time");
13561   hTime->GetXaxis()->CenterTitle();
13562   hTime->GetYaxis()->SetTitle("");
13563   hTime->GetYaxis()->CenterTitle();
13564   hTime->SetFillColor(0);
13565   //hTime->SetBit(TH1::kCanRebin);
13566 
13567   TH1F *hTime2=new TH1F("hTime2","hTime2",1000000,-1,1);
13568   hTime2->GetXaxis()->SetTitle("Time2");
13569   hTime2->GetXaxis()->CenterTitle();
13570   hTime2->GetYaxis()->SetTitle("");
13571   hTime2->GetYaxis()->CenterTitle();
13572   hTime2->SetFillColor(0);
13573   //hTime2->SetBit(TH1::kCanRebin);
13574 
13575   TProfile2D *hStVsPl1=new TProfile2D("hStVsPl1","StVsPl1",
13576                          67,-2,65,27,-2,25);
13577   hStVsPl1->GetXaxis()->SetTitle("Plane");
13578   hStVsPl1->GetXaxis()->CenterTitle();
13579   hStVsPl1->GetYaxis()->SetTitle("Strip");
13580   hStVsPl1->GetYaxis()->CenterTitle();
13581   hStVsPl1->SetFillColor(0);
13582   hStVsPl1->SetBit(TH1::kCanRebin);
13583 
13584   TProfile2D *hStVsPl2=new TProfile2D("hStVsPl2","StVsPl2",
13585                          67,-2,65,27,-2,25);
13586   hStVsPl2->GetXaxis()->SetTitle("Plane");
13587   hStVsPl2->GetXaxis()->CenterTitle();
13588   hStVsPl2->GetYaxis()->SetTitle("Strip");
13589   hStVsPl2->GetYaxis()->CenterTitle();
13590   hStVsPl2->SetFillColor(0);
13591   hStVsPl2->SetBit(TH1::kCanRebin);
13592 
13593   TH1F *hTofKov1Diff=new TH1F("hTofKov1Diff",
13594                                "hTofKov1Diff",4000,-2,3);
13595   hTofKov1Diff->GetXaxis()->SetTitle("TofTimeStamp");
13596   hTofKov1Diff->GetXaxis()->CenterTitle();
13597   hTofKov1Diff->GetYaxis()->SetTitle("");
13598   hTofKov1Diff->GetYaxis()->CenterTitle();
13599   hTofKov1Diff->SetFillColor(0);
13600   hTofKov1Diff->SetBit(TH1::kCanRebin);
13601 
13602   TH1F *hTofKov3Diff=new TH1F("hTofKov3Diff",
13603                                "hTofKov3Diff",4000,-2,3);
13604   hTofKov3Diff->GetXaxis()->SetTitle("TofTimeStamp");
13605   hTofKov3Diff->GetXaxis()->CenterTitle();
13606   hTofKov3Diff->GetYaxis()->SetTitle("");
13607   hTofKov3Diff->GetYaxis()->CenterTitle();
13608   hTofKov3Diff->SetFillColor(0);
13609   hTofKov3Diff->SetBit(TH1::kCanRebin);
13610 
13611   TH1F *hTofKov1DiffWhole=new TH1F("hTofKov1DiffWhole",
13612                                "hTofKov1DiffWhole",4000,-2,3);
13613   hTofKov1DiffWhole->GetXaxis()->SetTitle("TofTimeStamp");
13614   hTofKov1DiffWhole->GetXaxis()->CenterTitle();
13615   hTofKov1DiffWhole->GetYaxis()->SetTitle("");
13616   hTofKov1DiffWhole->GetYaxis()->CenterTitle();
13617   hTofKov1DiffWhole->SetFillColor(0);
13618   hTofKov1DiffWhole->SetBit(TH1::kCanRebin);
13619 
13620   TH1F *hTofKov3DiffWhole=new TH1F("hTofKov3DiffWhole",
13621                                "hTofKov3DiffWhole",4000,-2,3);
13622   hTofKov3DiffWhole->GetXaxis()->SetTitle("TofTimeStamp");
13623   hTofKov3DiffWhole->GetXaxis()->CenterTitle();
13624   hTofKov3DiffWhole->GetYaxis()->SetTitle("");
13625   hTofKov3DiffWhole->GetYaxis()->CenterTitle();
13626   hTofKov3DiffWhole->SetFillColor(0);
13627   hTofKov3DiffWhole->SetBit(TH1::kCanRebin);
13628 
13629   TH1F *hTofTDC0=new TH1F("hTofTDC0","TofTDC0",400,-2,4000);
13630   hTofTDC0->GetXaxis()->SetTitle("TofTDC0");
13631   hTofTDC0->GetXaxis()->CenterTitle();
13632   hTofTDC0->GetYaxis()->SetTitle("");
13633   hTofTDC0->GetYaxis()->CenterTitle();
13634   hTofTDC0->SetFillColor(0);
13635   hTofTDC0->SetBit(TH1::kCanRebin);
13636 
13637   TH1F *hTofTDC2=new TH1F("hTofTDC2","TofTDC2",400,-2,4000);
13638   hTofTDC2->GetXaxis()->SetTitle("TofTDC2");
13639   hTofTDC2->GetXaxis()->CenterTitle();
13640   hTofTDC2->GetYaxis()->SetTitle("");
13641   hTofTDC2->GetYaxis()->CenterTitle();
13642   hTofTDC2->SetFillColor(0);
13643   hTofTDC2->SetBit(TH1::kCanRebin);
13644 
13645   TH1F *hTofDiff=new TH1F("hTofDiff","TofDiff",1000,0,1000);
13646   hTofDiff->GetXaxis()->SetTitle("TofDiff");
13647   hTofDiff->GetXaxis()->CenterTitle();
13648   hTofDiff->GetYaxis()->SetTitle("");
13649   hTofDiff->GetYaxis()->CenterTitle();
13650   hTofDiff->SetFillColor(0);
13651   //hTofDiff->SetBit(TH1::kCanRebin);
13652 
13653   TH1F *hTofDiffElec=new TH1F("hTofDiffElec","TofDiffElec",1000,0,1000);
13654   hTofDiffElec->GetXaxis()->SetTitle("TofDiff");
13655   hTofDiffElec->GetXaxis()->CenterTitle();
13656   hTofDiffElec->GetYaxis()->SetTitle("");
13657   hTofDiffElec->GetYaxis()->CenterTitle();
13658   hTofDiffElec->SetFillColor(0);
13659   //hTofDiffElec->SetBit(TH1::kCanRebin);
13660 
13661   TH1F *hTofDiffNotElec=new TH1F("hTofDiffNotElec","TofDiffNotElec",
13662                                  1000,0,1000);
13663   hTofDiffNotElec->GetXaxis()->SetTitle("TofDiff");
13664   hTofDiffNotElec->GetXaxis()->CenterTitle();
13665   hTofDiffNotElec->GetYaxis()->SetTitle("");
13666   hTofDiffNotElec->GetYaxis()->CenterTitle();
13667   hTofDiffNotElec->SetFillColor(0);
13668   //hTofDiffNotElec->SetBit(TH1::kCanRebin);
13669 
13670   TH1F *hTofTDC0Whole=new TH1F("hTofTDC0Whole","TofTDC0Whole",
13671                                400,-2,4000);
13672   hTofTDC0Whole->GetXaxis()->SetTitle("TofTDC0");
13673   hTofTDC0Whole->GetXaxis()->CenterTitle();
13674   hTofTDC0Whole->GetYaxis()->SetTitle("");
13675   hTofTDC0Whole->GetYaxis()->CenterTitle();
13676   hTofTDC0Whole->SetFillColor(0);
13677   hTofTDC0Whole->SetBit(TH1::kCanRebin);
13678 
13679   TH1F *hTofTDC2Whole=new TH1F("hTofTDC2Whole","TofTDC2Whole",
13680                                400,-2,4000);
13681   hTofTDC2Whole->GetXaxis()->SetTitle("TofTDC2");
13682   hTofTDC2Whole->GetXaxis()->CenterTitle();
13683   hTofTDC2Whole->GetYaxis()->SetTitle("");
13684   hTofTDC2Whole->GetYaxis()->CenterTitle();
13685   hTofTDC2Whole->SetFillColor(0);
13686   hTofTDC2Whole->SetBit(TH1::kCanRebin);
13687 
13688   TH1F *hTofDiffWhole=new TH1F("hTofDiffWhole","TofDiffWhole",
13689                                1000,-2000,4000);
13690   hTofDiffWhole->GetXaxis()->SetTitle("TofDiff");
13691   hTofDiffWhole->GetXaxis()->CenterTitle();
13692   hTofDiffWhole->GetYaxis()->SetTitle("");
13693   hTofDiffWhole->GetYaxis()->CenterTitle();
13694   hTofDiffWhole->SetFillColor(0);
13695   hTofDiffWhole->SetBit(TH1::kCanRebin);
13696 
13697   TH1F *hKovADC1Whole=new TH1F("hKovADC1Whole","KovADC1Whole",
13698                                400,-5,15000);
13699   hKovADC1Whole->GetXaxis()->SetTitle("KovADC1Whole");
13700   hKovADC1Whole->GetXaxis()->CenterTitle();
13701   hKovADC1Whole->GetYaxis()->SetTitle("");
13702   hKovADC1Whole->GetYaxis()->CenterTitle();
13703   hKovADC1Whole->SetFillColor(0);
13704   hKovADC1Whole->SetBit(TH1::kCanRebin);
13705 
13706   TH1F *hKovADC1=new TH1F("hKovADC1","KovADC1",400,-5,15000);
13707   hKovADC1->GetXaxis()->SetTitle("KovADC1");
13708   hKovADC1->GetXaxis()->CenterTitle();
13709   hKovADC1->GetYaxis()->SetTitle("");
13710   hKovADC1->GetYaxis()->CenterTitle();
13711   hKovADC1->SetFillColor(0);
13712   hKovADC1->SetBit(TH1::kCanRebin);
13713 
13714   TH1F *hKovADC1Cut=new TH1F("hKovADC1Cut","KovADC1Cut",400,-5,15000);
13715   hKovADC1Cut->GetXaxis()->SetTitle("KovADC1Cut");
13716   hKovADC1Cut->GetXaxis()->CenterTitle();
13717   hKovADC1Cut->GetYaxis()->SetTitle("");
13718   hKovADC1Cut->GetYaxis()->CenterTitle();
13719   hKovADC1Cut->SetFillColor(0);
13720   hKovADC1Cut->SetBit(TH1::kCanRebin);
13721 
13722   TH1F *hKovADC3Whole=new TH1F("hKovADC3Whole","KovADC3Whole",
13723                                400,-5,15000);
13724   hKovADC3Whole->GetXaxis()->SetTitle("KovADC3Whole");
13725   hKovADC3Whole->GetXaxis()->CenterTitle();
13726   hKovADC3Whole->GetYaxis()->SetTitle("");
13727   hKovADC3Whole->GetYaxis()->CenterTitle();
13728   hKovADC3Whole->SetFillColor(0);
13729   hKovADC3Whole->SetBit(TH1::kCanRebin);
13730 
13731   TH1F *hKovADC3=new TH1F("hKovADC3","KovADC3",400,-5,15000);
13732   hKovADC3->GetXaxis()->SetTitle("KovADC3");
13733   hKovADC3->GetXaxis()->CenterTitle();
13734   hKovADC3->GetYaxis()->SetTitle("");
13735   hKovADC3->GetYaxis()->CenterTitle();
13736   hKovADC3->SetFillColor(0);
13737   hKovADC3->SetBit(TH1::kCanRebin);
13738 
13739   TH1F *hKovADC3Cut=new TH1F("hKovADC3Cut","KovADC3Cut",400,-5,15000);
13740   hKovADC3Cut->GetXaxis()->SetTitle("KovADC3Cut");
13741   hKovADC3Cut->GetXaxis()->CenterTitle();
13742   hKovADC3Cut->GetYaxis()->SetTitle("");
13743   hKovADC3Cut->GetYaxis()->CenterTitle();
13744   hKovADC3Cut->SetFillColor(0);
13745   hKovADC3Cut->SetBit(TH1::kCanRebin);
13746 
13747   TH1F *hStrip=new TH1F("hStrip","Strips hit",100,-2,30);
13748   hStrip->GetXaxis()->SetTitle("Strip");
13749   hStrip->GetXaxis()->CenterTitle();
13750   hStrip->GetYaxis()->SetTitle("");
13751   hStrip->GetYaxis()->CenterTitle();
13752   hStrip->SetFillColor(0);
13753   hStrip->SetBit(TH1::kCanRebin);
13754 
13755   TH1F *hStripend=new TH1F("hStripend","Stripend hit",120,-2,10);
13756   hStripend->GetXaxis()->SetTitle("Stripend");
13757   hStripend->GetXaxis()->CenterTitle();
13758   hStripend->GetYaxis()->SetTitle("");
13759   hStripend->GetYaxis()->CenterTitle();
13760   hStripend->SetFillColor(0);
13761   hStripend->SetBit(TH1::kCanRebin);
13762 
13763   TH1F *hPlane=new TH1F("hPlane","Planes hit",200,-2,75);
13764   hPlane->GetXaxis()->SetTitle("Plane");
13765   hPlane->GetXaxis()->CenterTitle();
13766   hPlane->GetYaxis()->SetTitle("");
13767   hPlane->GetYaxis()->CenterTitle();
13768   hPlane->SetFillColor(0);
13769   hPlane->SetBit(TH1::kCanRebin);
13770 
13771   TH1F *hNumPlanes=new TH1F("hNumPlanes","NumPlanes hit",200,-2,75);
13772   hNumPlanes->GetXaxis()->SetTitle("NumPlanes");
13773   hNumPlanes->GetXaxis()->CenterTitle();
13774   hNumPlanes->GetYaxis()->SetTitle("");
13775   hNumPlanes->GetYaxis()->CenterTitle();
13776   hNumPlanes->SetFillColor(0);
13777   hNumPlanes->SetBit(TH1::kCanRebin);
13778 
13779   TH1F *hEventLength=new TH1F("hEventLength","EventLength hit",200,-2,75);
13780   hEventLength->GetXaxis()->SetTitle("EventLength");
13781   hEventLength->GetXaxis()->CenterTitle();
13782   hEventLength->GetYaxis()->SetTitle("");
13783   hEventLength->GetYaxis()->CenterTitle();
13784   hEventLength->SetFillColor(0);
13785   hEventLength->SetBit(TH1::kCanRebin);
13786 
13787   TH1F *hChargeSigCor=new TH1F("hChargeSigCor","ChargeSigCor",
13788                                1000,-2,15000);
13789   hChargeSigCor->GetXaxis()->SetTitle("ChargeSigCor");
13790   hChargeSigCor->GetXaxis()->CenterTitle();
13791   hChargeSigCor->GetYaxis()->SetTitle("");
13792   hChargeSigCor->GetYaxis()->CenterTitle();
13793   hChargeSigCor->SetFillColor(0);
13794   hChargeSigCor->SetBit(TH1::kCanRebin);
13795 
13796   TH1F *hChargeSigLin=new TH1F("hChargeSigLin","ChargeSigLin",
13797                                1000,-2,15000);
13798   hChargeSigLin->GetXaxis()->SetTitle("ChargeSigLin");
13799   hChargeSigLin->GetXaxis()->CenterTitle();
13800   hChargeSigLin->GetYaxis()->SetTitle("");
13801   hChargeSigLin->GetYaxis()->CenterTitle();
13802   hChargeSigLin->SetFillColor(0);
13803   hChargeSigLin->SetBit(TH1::kCanRebin);
13804 
13805   TH1F *hChargePe=new TH1F("hChargePe","ChargePe",412,-12,400);
13806   hChargePe->GetXaxis()->SetTitle("ChargePe");
13807   hChargePe->GetXaxis()->CenterTitle();
13808   hChargePe->GetYaxis()->SetTitle("");
13809   hChargePe->GetYaxis()->CenterTitle();
13810   hChargePe->SetFillColor(0);
13811   hChargePe->SetBit(TH1::kCanRebin);
13812 
13813   TH1F *hGain=new TH1F("hGain","Gain",1000,-2,150);
13814   hGain->GetXaxis()->SetTitle("Gain");
13815   hGain->GetXaxis()->CenterTitle();
13816   hGain->GetYaxis()->SetTitle("");
13817   hGain->GetYaxis()->CenterTitle();
13818   hGain->SetFillColor(0);
13819   hGain->SetBit(TH1::kCanRebin);
13820 
13821   TH1F *hAdc=new TH1F("hAdc","Adc",1000,-2,150);
13822   hAdc->GetXaxis()->SetTitle("Adc");
13823   hAdc->GetXaxis()->CenterTitle();
13824   hAdc->GetYaxis()->SetTitle("");
13825   hAdc->GetYaxis()->CenterTitle();
13826   hAdc->SetFillColor(0);
13827   hAdc->SetBit(TH1::kCanRebin);
13828 
13829   TH1F *hdzds=new TH1F("hdzds","dzds",400,-2,2);
13830   hdzds->GetXaxis()->SetTitle("dzds");
13831   hdzds->GetXaxis()->CenterTitle();
13832   hdzds->GetYaxis()->SetTitle("");
13833   hdzds->GetYaxis()->CenterTitle();
13834   hdzds->SetFillColor(0);
13835   hdzds->SetBit(TH1::kCanRebin);
13836 
13837   TH1F *hdsdz=new TH1F("hdsdz","dsdz",400,-2,10);
13838   hdsdz->GetXaxis()->SetTitle("dsdz");
13839   hdsdz->GetXaxis()->CenterTitle();
13840   hdsdz->GetYaxis()->SetTitle("");
13841   hdsdz->GetYaxis()->CenterTitle();
13842   hdsdz->SetFillColor(0);
13843   hdsdz->SetBit(TH1::kCanRebin);
13844 
13845   TH1F *hdydz=new TH1F("hdydz","dydz",400,-5,5);
13846   hdydz->GetXaxis()->SetTitle("dydz");
13847   hdydz->GetXaxis()->CenterTitle();
13848   hdydz->GetYaxis()->SetTitle("");
13849   hdydz->GetYaxis()->CenterTitle();
13850   hdydz->SetFillColor(0);
13851   hdydz->SetBit(TH1::kCanRebin);
13852 
13853   TH1F *hdxdz=new TH1F("hdxdz","dxdz",400,-10,10);
13854   hdxdz->GetXaxis()->SetTitle("dxdz");
13855   hdxdz->GetXaxis()->CenterTitle();
13856   hdxdz->GetYaxis()->SetTitle("");
13857   hdxdz->GetYaxis()->CenterTitle();
13858   hdxdz->SetFillColor(0);
13859   hdxdz->SetBit(TH1::kCanRebin);
13860 
13861   TH1F *hdyds=new TH1F("hdyds","dyds",400,-3,3);
13862   hdyds->GetXaxis()->SetTitle("dyds");
13863   hdyds->GetXaxis()->CenterTitle();
13864   hdyds->GetYaxis()->SetTitle("");
13865   hdyds->GetYaxis()->CenterTitle();
13866   hdyds->SetFillColor(0);
13867   hdyds->SetBit(TH1::kCanRebin);
13868 
13869   TH1F *hdxds=new TH1F("hdxds","dxds",400,-3,3);
13870   hdxds->GetXaxis()->SetTitle("dxds");
13871   hdxds->GetXaxis()->CenterTitle();
13872   hdxds->GetYaxis()->SetTitle("");
13873   hdxds->GetYaxis()->CenterTitle();
13874   hdxds->SetFillColor(0);
13875   hdxds->SetBit(TH1::kCanRebin);
13876 
13877   TH1F *hTransPos=new TH1F("hTransPos","TransPos",1000,-2,35);
13878   hTransPos->GetXaxis()->SetTitle("TransPos");
13879   hTransPos->GetXaxis()->CenterTitle();
13880   hTransPos->GetYaxis()->SetTitle("");
13881   hTransPos->GetYaxis()->CenterTitle();
13882   hTransPos->SetFillColor(0);
13883   hTransPos->SetBit(TH1::kCanRebin);
13884 
13885   TH1F *hYPos=new TH1F("hYPos","YPos",1000,-8,8);
13886   hYPos->GetXaxis()->SetTitle("YPos");
13887   hYPos->GetXaxis()->CenterTitle();
13888   hYPos->GetYaxis()->SetTitle("");
13889   hYPos->GetYaxis()->CenterTitle();
13890   hYPos->SetFillColor(0);
13891   hYPos->SetBit(TH1::kCanRebin);
13892 
13893   TH1F *hEvenResult=new TH1F("hEvenResult","EvenResult",100,-5,5);
13894   hEvenResult->GetXaxis()->SetTitle("EvenResult");
13895   hEvenResult->GetXaxis()->CenterTitle();
13896   hEvenResult->GetYaxis()->SetTitle("");
13897   hEvenResult->GetYaxis()->CenterTitle();
13898   hEvenResult->SetFillColor(0);
13899   hEvenResult->SetBit(TH1::kCanRebin);
13900 
13901   TH1F *hOddResult=new TH1F("hOddResult","OddResult",100,-5,5);
13902   hOddResult->GetXaxis()->SetTitle("OddResult");
13903   hOddResult->GetXaxis()->CenterTitle();
13904   hOddResult->GetYaxis()->SetTitle("");
13905   hOddResult->GetYaxis()->CenterTitle();
13906   hOddResult->SetFillColor(0);
13907   hOddResult->SetBit(TH1::kCanRebin);
13908 
13909   TProfile* pSigCorVsPlane=new TProfile("pSigCorVsPlane",
13910                                         "pSigCorVsPlane",
13911                                         65,-1,64);
13912   TProfile* pSigCorVsOsPlane=new TProfile("pSigCorVsOsPlane",
13913                                          "pSigCorVsOsPlane",
13914                                          70,5,75);
13915 
13916   Bool_t triggerPMT;            //Did the triggerPMT fire?
13917   Bool_t fafErr;                //Faf errors?
13918   Bool_t sparseErr;             //sparse errors?
13919   Int_t trigSource;             //trigger source
13920   Int_t kovADC1;                //Cerenkov ADC value
13921   Int_t kovTimeStamp1;          //Cerenkov TimeStamp
13922   Int_t kovADC2;
13923   Int_t kovTimeStamp2;
13924   Int_t kovADC3;
13925   Int_t kovTimeStamp3;
13926   Int_t snarlTimeFrame;         //Event TimeFrame
13927   ULong_t snarlMinTimeStamp;  //event minimum timetimestamp
13928   ULong_t snarlMaxTimeStamp;  //event maximum timestamp
13929   Int_t tofTDC0;                //TOF tdc0 value
13930   Int_t tofTDC1;                //TOF tdc1 value
13931   Int_t tofTDC2;                //TOF tdc2 value
13932   Int_t tofADC0;                //TOF ADC0 value (not always present) 
13933                                //______Context depends on the run
13934   Int_t tofADC1;                //TOF ADC1 value (not always present) 
13935                                //Used for tof system testing
13936   Int_t tofADC2;                //TOF ADC1 value (not always present) 
13937                                //Used for tof system testing
13938   Int_t tofADCTimeStamp0;       //tof adc timestamps
13939   Int_t tofADCTimeStamp1;
13940   Int_t tofADCTimeStamp2;  
13941   Int_t tofTimeStamp;           //time stamp of TOF readout
13942   Int_t tickSinceLast;          //Ticks since last snarl
13943 
13944   map<Int_t,Float_t> totalSigCor;
13945   map<Int_t,Float_t> totalNum;
13946   map<Int_t,Float_t> totalSigCorOffSet;
13947   map<Int_t,Float_t> totalNumOffSet;
13948   map<Int_t,Float_t> totalSigCor2;
13949   map<Int_t,Float_t> totalNum2;
13950   map<Int_t,Float_t> totalSigCorOffSet2;
13951   map<Int_t,Float_t> totalNumOffSet2;
13952   map<Int_t,Float_t> totalSigCor3;
13953   map<Int_t,Float_t> totalNum3;
13954   map<Int_t,Float_t> totalSigCorOffSet3;
13955   map<Int_t,Float_t> totalNumOffSet3;
13956   vector<TProfile*> pSigCorVsDist;
13957   vector<Int_t> vWindowSize;
13958 
13962   
13963   this->InitialiseLoopVariables();  
13964   
13965   for(Int_t event=0;event<fEvents;event++){
13966     
13967     this->SetLoopVariables(event);
13968 
13969     if (!fPIDInfo){
13970       MAXMSG("CDAnalysis",Msg::kWarning,100)
13971         <<"No PID info: fPIDInfo="<<fPIDInfo<<endl;
13972       continue;
13973     }
13974 
13975     triggerPMT=fPIDInfo->GetTriggerPMT();
13976     fafErr=fPIDInfo->GetFafErr() ;
13977     sparseErr=fPIDInfo->GetSparseErr();
13978     trigSource=fPIDInfo->GetTrigSource();
13979     kovADC1=fPIDInfo->GetKovADC1() ;
13980     kovTimeStamp1=fPIDInfo->GetKovTimeStamp1();
13981     kovADC2=fPIDInfo->GetKovADC2();
13982     kovTimeStamp2=fPIDInfo->GetKovTimeStamp2();
13983     kovADC3=fPIDInfo->GetKovADC3();
13984     kovTimeStamp3=fPIDInfo->GetKovTimeStamp3(); 
13985     snarlTimeFrame=fPIDInfo->GetSnarlTimeFrame();
13986     snarlMinTimeStamp=fPIDInfo->GetSnarlMinTimeStamp();
13987     snarlMaxTimeStamp=fPIDInfo->GetSnarlMaxTimeStamp();
13988     tofTDC0=fPIDInfo->GetTofTDC0();
13989     tofTDC1=fPIDInfo->GetTofTDC1();
13990     tofTDC2=fPIDInfo->GetTofTDC2();
13991     tofADC0=fPIDInfo->GetTofADC0();
13992     tofADC1=fPIDInfo->GetTofADC1();
13993     tofADC2=fPIDInfo->GetTofADC2();
13994     tofADCTimeStamp0=fPIDInfo->GetTofADCTimeStamp0();
13995     tofADCTimeStamp1=fPIDInfo->GetTofADCTimeStamp1();
13996     tofADCTimeStamp2=fPIDInfo->GetTofADCTimeStamp2();
13997     tofTimeStamp=fPIDInfo->GetTofTimeStamp();//don't use
13998     tickSinceLast=fPIDInfo->GetTickSinceLast();
13999     
14000     hKovADC3Whole->Fill(kovADC3);
14001     hKovADC1Whole->Fill(kovADC1);
14002     hTofTDC0Whole->Fill(tofTDC0);
14003     hTofTDC2Whole->Fill(tofTDC2);
14004     hTofDiffWhole->Fill(tofTDC2-tofTDC0);
14005     hTofKov1DiffWhole->Fill(tofADCTimeStamp1-kovTimeStamp1);
14006     hTofKov3DiffWhole->Fill(tofADCTimeStamp1-kovTimeStamp3);
14007 
14008     //if (this->CutOnPidForElec()) continue;
14009 
14010     hEvenResult->Fill(fTrackInfo->GetResult(0));
14011     hOddResult->Fill(fTrackInfo->GetResult(1));
14012 
14013     hTofTDC0->Fill(tofTDC0);
14014     hTofTDC2->Fill(tofTDC2);
14015     hTofDiff->Fill(tofTDC2-tofTDC0);
14016     if (kovADC1>500 && kovADC3>500) hTofDiffElec->Fill(tofTDC2-tofTDC0);
14017     else hTofDiffNotElec->Fill(tofTDC2-tofTDC0);
14018     hTofKov1Diff->Fill(tofADCTimeStamp1-kovTimeStamp1);
14019     hTofKov3Diff->Fill(tofADCTimeStamp1-kovTimeStamp3);
14020 
14021     MSG("CDAnalysis",Msg::kVerbose)//diff is the lemo
14022       <<"ttof="<<tofTimeStamp
14023       <<", tofADCTimeStamp1="<<tofADCTimeStamp1<<endl;
14024 
14025     map<Int_t,Int_t> numPlanesHit;
14026     map<Int_t,Int_t> numPlanesHit1;
14027     map<Int_t,Int_t> numPlanesHit2;
14028     Int_t firstPlane=999999;
14029     Int_t lastPlane=-1;
14030     Int_t lastPlaneOdd=-1;
14031     Int_t lastPlaneEven=-1;
14032     map<Int_t,Float_t> planeSigCor;
14033     map<Int_t,Float_t> planeSigCorX;
14034     map<Int_t,Float_t> planeSigCorT;
14035 
14036     //get tclones arrays for this snarl
14037     TClonesArray &cTrk=*fTrkHitInfo;
14038     Int_t numTrkHits=fTrkHitInfo->GetEntries();
14039     TClonesArray &cUnTrk = *fUnTrkHitInfo;
14040     Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
14041     //CDTrackedHitInfo *trackedHitInfo=(CDTrackedHitInfo*) c[hit];
14042     TClonesArray &cXTalk = *fXTalkHits;
14043     Int_t numXTalkHits=fXTalkHits->GetEntries();
14044           
14045     //look for untracked big events
14046     if (numTrkHits<2 && numXTalkHits+numUnTrkHits>100){
14047       MSG("CDAnalysis",Msg::kDebug)
14048         <<"Event="<<event
14049         <<", Num hits: trk="<<numTrkHits<<", unTrk="<<numUnTrkHits
14050         <<", xtalk="<<numXTalkHits<<endl;
14051     }
14052 
14054     //loop over the untracked hits in the snarl
14056     for (Int_t hit=0;hit<numUnTrkHits;hit++){
14057       CDTrackedHitInfo *hitInfo=(CDTrackedHitInfo*) cUnTrk[hit];
14058 
14059       this->ReadInHitInfo(hitInfo);
14060 
14061       Float_t chargeSigCor=hitInfo->GetCharge
14062         (CDTrackedHitInfo::kSigCorr);
14063       Int_t plane=hitInfo->GetPlane();
14064       Int_t strip=hitInfo->GetStrip();
14065 
14066       //cut out the strips with bad pedestals
14067       if ((plane==21 || plane==41) && strip==19) continue;
14068       //cut out the negative adcs
14069       if (strip==13 && plane==40) continue;
14070 
14071       hTime->Fill(fTime-tofTimeStamp);
14072       hTime2->Fill(fTime-tofTimeStamp);
14073 
14074       //add up the charge of the hits in each plane
14075       planeSigCorX[plane]+=chargeSigCor;
14076       planeSigCorT[plane]+=chargeSigCor;
14077     }
14078 
14080     //loop over xtalk hits in the snarl
14082     for (Int_t hit=0;hit<numXTalkHits;hit++){
14083       CDXTalkHitInfo *hitInfo=(CDXTalkHitInfo*) cXTalk[hit];
14084 
14085       this->ReadInHitInfo(hitInfo);      
14086 
14087       Float_t chargeSigCor=hitInfo->GetCharge
14088         (CDTrackedHitInfo::kSigCorr);
14089       Int_t plane=hitInfo->GetPlane();
14090       Int_t strip=hitInfo->GetStrip();
14091       
14092       //cut out the strips with bad pedestals
14093       if ((plane==21 || plane==41) && strip==19) continue;
14094       //cut out the negative adcs
14095       if (strip==13 && plane==40) continue;
14096 
14097       hTime->Fill(fTime-tofTimeStamp);
14098       hTime2->Fill(fTime-tofTimeStamp);
14099 
14100       //add up the charge of the hits in each plane
14101       planeSigCorX[plane]+=chargeSigCor;
14102       planeSigCorT[plane]+=chargeSigCor;
14103     }
14104 
14106     //loop over the tracked hits
14108     for (Int_t hit=0;hit<numTrkHits;hit++){
14109       CDTrackedHitInfo *trackedHitInfo=(CDTrackedHitInfo*) cTrk[hit];
14110           
14111       this->ReadInHitInfo(trackedHitInfo);
14112 
14113       Int_t plane=trackedHitInfo->GetPlane();
14114       Int_t strip=trackedHitInfo->GetStrip();
14115       Int_t stripend=trackedHitInfo->GetEnd();
14116 
14117       Float_t chargeSigCor=trackedHitInfo->GetCharge
14118         (CDTrackedHitInfo::kSigCorr);
14119       Float_t chargeSigLin=trackedHitInfo->GetCharge
14120         (CDTrackedHitInfo::kSigLin);
14121       Float_t chargePe=trackedHitInfo->GetCharge
14122         (CDTrackedHitInfo::kPe);
14123       Float_t gain = chargeSigLin/chargePe;
14124       Float_t adc=trackedHitInfo->GetCharge
14125         (CDTrackedHitInfo::kAdc);
14126 
14127       hTime->Fill(fTime-tofTimeStamp);
14128       hTime2->Fill(fTime-tofTimeStamp);
14129 
14130       if (stripend==1) hStVsPl1->Fill(plane,strip,adc);
14131       if (stripend==2) hStVsPl2->Fill(plane,strip,adc);
14132 
14133       //cut out the strips with bad pedestals
14134       if ((plane==21 || plane==41) && strip==19) continue;
14135       //cut out the negative adcs
14136       if (strip==13 && plane==40) continue;
14137 
14138       if (adc<0 && !(strip==13 && plane==40)){
14139         MSG("CDAnalysis",Msg::kInfo)
14140           <<"Event="<<event<<", adc="<<adc<<" ("<<plane<<":"<<strip
14141           <<")"<<endl;
14142       }
14143       else if (adc<0){
14144         MSG("CDAnalysis",Msg::kInfo)
14145           <<"Event="<<event<<", adc="<<adc<<" ("<<plane<<":"<<strip
14146           <<")"<<endl;
14147       }
14148 
14149       hPlane->Fill(plane);
14150       hStrip->Fill(strip);
14151       hStripend->Fill(stripend);
14152 
14153       //count the number of planes hit
14154       numPlanesHit[plane]++;
14155       if (stripend==1) numPlanesHit1[plane]++;
14156       if (stripend==2) numPlanesHit2[plane]++;
14157       if (plane<firstPlane) firstPlane=plane;
14158       if (plane>lastPlane) lastPlane=plane;
14159       if (plane>lastPlaneOdd && plane%2!=0) lastPlaneOdd=plane;
14160       if (plane>lastPlaneEven && plane%2==0) lastPlaneEven=plane;
14161 
14162       //add up the charge of the tracked hits in each plane
14163       planeSigCor[plane]+=chargeSigCor;
14164       planeSigCorT[plane]+=chargeSigCor;
14165 
14166       hChargeSigCor->Fill(chargeSigCor);
14167       hChargeSigLin->Fill(chargeSigLin);
14168       hChargePe->Fill(chargePe);
14169       hGain->Fill(gain);
14170       hAdc->Fill(adc);
14171 
14172       Float_t dzds = trackedHitInfo->GetDzDs();
14173       Float_t dsdz = 1./dzds;
14174       Float_t dydz = trackedHitInfo->GetDyDz();
14175       Float_t dxdz = trackedHitInfo->GetDxDz();
14176       Float_t dyds = trackedHitInfo->GetDyDz()*
14177         trackedHitInfo->GetDzDs();
14178       Float_t dxds = trackedHitInfo->GetDxDz()*
14179         trackedHitInfo->GetDzDs();
14180       Float_t TransPos = trackedHitInfo->GetTransPos();
14181       Float_t YPos = trackedHitInfo->GetYPos();
14182 
14183       hdzds->Fill(dzds);
14184       hdsdz->Fill(dsdz);
14185       hdydz->Fill(dydz);
14186       hdxdz->Fill(dxdz);
14187       hdyds->Fill(dyds);
14188       hdxds->Fill(dxds);
14189       hTransPos->Fill(TransPos);
14190       hYPos->Fill(YPos);
14191     }
14192         
14193     if (firstPlane<0 || firstPlane>59) continue;
14194 
14195     hNumPlanes->Fill(numPlanesHit.size());
14196 
14197     if (firstPlane>=0 && firstPlane<60){
14198       hEventLength->Fill(lastPlane-firstPlane+1);
14199     }
14200 
14201     Float_t pl1Pl2=0;
14202     if (numPlanesHit2.size()>0) pl1Pl2=1.*numPlanesHit1.size()/
14203                                   numPlanesHit2.size();
14204 
14205     if (firstPlane<60 && numPlanesHit.size()>40 && planeSigCor[1]>800 && planeSigCor[2]>800){
14206 
14207       MSG("CDAnalysis",Msg::kVerbose)
14208         <<"Special: ev="<<event
14209         <<", firstPl="<<firstPlane
14210         <<", lastPl="<<lastPlane
14211         <<", nPl="<<numPlanesHit.size()
14212         <<", nPl1="<<numPlanesHit1.size()
14213         <<", nPl2="<<numPlanesHit2.size()
14214         <<", Pl1/Pl2="<<pl1Pl2<<endl;
14215     }
14216 
14217     if (pl1Pl2>2 || pl1Pl2<1./2){
14218       MSG("CDAnalysis",Msg::kVerbose)
14219         <<"1 sided: ev="<<event
14220         <<", firstPl="<<firstPlane
14221         <<", lastPl="<<lastPlane
14222         <<", nPl="<<numPlanesHit.size()
14223         <<", nPl1="<<numPlanesHit1.size()
14224         <<", nPl2="<<numPlanesHit2.size()
14225         <<", Pl1/Pl2="<<pl1Pl2<<endl;
14226     }
14227 
14228     static Int_t counter=0;
14229     counter++;
14230 
14231     if (counter<80){
14232       MSG("CDAnalysis",Msg::kDebug)
14233         <<"Event="<<event
14234         <<", numPlanes="<<numPlanesHit.size()
14235         <<", kov1="<<kovADC1
14236         <<", kov3="<<kovADC3
14237         <<endl;
14238     }
14239 
14240     if (kovADC1>100){
14241       MSG("CDAnalysis",Msg::kDebug)
14242         <<"High Kov Event="<<event
14243         <<", numPlanes="<<numPlanesHit.size()
14244         <<", kov1="<<kovADC1
14245         <<", kov3="<<kovADC3
14246         <<endl;
14247     }
14248 
14249     if (numPlanesHit.size()>40){
14250       hKovADC3->Fill(kovADC3);
14251       hKovADC1->Fill(kovADC1);
14252     }
14253     else{
14254       hKovADC3Cut->Fill(kovADC3);
14255       hKovADC1Cut->Fill(kovADC1);
14256     }
14257 
14258     //make cuts
14259     if (numPlanesHit.size()<40) continue;
14260     if (firstPlane<0 || firstPlane>59) continue;
14261     if (lastPlane>57) continue;//cut out through going muons, no 58,59
14262 
14263     if (numPlanesHit[lastPlane-1]==0){
14264       MSG("CDAnalysis",Msg::kDebug)
14265         <<"Missing lastPlane-1, event="<<event
14266         <<", numPlanes="<<numPlanesHit.size()
14267         <<", kov1="<<kovADC1
14268         <<", kov3="<<kovADC3
14269         <<endl;
14270     }
14271 
14273     //section for response
14275 
14276     const Int_t reNormPlane=70;
14277     Int_t planeOffset=reNormPlane-lastPlane;
14278 
14279     for (map<Int_t,Float_t>::iterator sig=planeSigCor.begin();
14280          sig!=planeSigCor.end();++sig){
14281       totalSigCor[sig->first]+=sig->second;
14282       totalNum[sig->first]++;
14283       pSigCorVsPlane->Fill(sig->first,sig->second);
14284 
14285       totalSigCorOffSet[sig->first+planeOffset]+=sig->second;
14286       totalNumOffSet[sig->first+planeOffset]++;
14287       pSigCorVsOsPlane->Fill(sig->first+planeOffset,sig->second);
14288     }
14289 
14290     for (map<Int_t,Float_t>::iterator sig=planeSigCorX.begin();
14291          sig!=planeSigCorX.end();++sig){
14292       totalSigCor2[sig->first]+=sig->second;
14293       totalNum2[sig->first]++;
14294 
14295       totalSigCorOffSet2[sig->first+planeOffset]+=sig->second;
14296       totalNumOffSet2[sig->first+planeOffset]++;
14297     }
14298 
14299     for (map<Int_t,Float_t>::iterator sig=planeSigCorT.begin();
14300          sig!=planeSigCorT.end();++sig){
14301       totalSigCor3[sig->first]+=sig->second;
14302       totalNum3[sig->first]++;
14303 
14304       totalSigCorOffSet3[sig->first+planeOffset]+=sig->second;
14305       totalNumOffSet3[sig->first+planeOffset]++;
14306     }
14307 
14309     //section for sliding window
14311     Int_t minEventLength=40;
14312     if (lastPlane<minEventLength) continue;
14313 
14314     MSG("CDAnalysis",Msg::kDebug)
14315       <<"Event="<<event
14316       <<", firstPl="<<firstPlane
14317       <<", lastPl="<<lastPlane
14318       <<", lastPlOdd="<<lastPlaneOdd
14319       <<", lastPlEven="<<lastPlaneEven
14320       <<", numPlanes="<<numPlanesHit.size()<<endl;
14321 
14322     //initialise the profile histos
14323     static Bool_t firstTime=true;
14324     if (firstTime){
14325       for (Int_t p=20;p>1;p--){
14326         vWindowSize.push_back(p);
14327       }
14328 
14329       for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
14330            windowSize!=vWindowSize.end();++windowSize){
14331         
14332         string sName=Form("%d",*windowSize);
14333         pSigCorVsDist.push_back
14334           (new TProfile(("pSigCorVsDist"+sName).c_str(),
14335                         ("pSigCorVsDist"+sName).c_str(),100,-2,40));
14336       }
14337     }
14338     firstTime=false;
14339 
14340     vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
14341 
14342     for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
14343          windowSize!=vWindowSize.end();++windowSize){
14344       
14345       for (Int_t p=0;p<minEventLength-*windowSize;p++){
14346         Int_t windowStart=lastPlane-p;
14347 
14348         Float_t avSigCor=0;
14349         Int_t numUsed=0;
14350         
14351         for (Int_t i=0;i<*windowSize;i++){
14352           Int_t plane=windowStart-i;
14353           
14354           MSG("CDAnalysis",Msg::kVerbose)
14355             <<"Event="<<event
14356             <<", winStart="<<windowStart
14357             <<", plane="<<plane<<endl;
14358           
14359           //cut out planes that are greater than the last plane
14360           //in the view - ie the zeros at the end
14361           Bool_t doZeroCorrection=false;
14362           if (doZeroCorrection && 
14363               ((plane%2==0 && plane>lastPlaneEven) || 
14364                (plane%2!=0 && plane>lastPlaneOdd))){
14365             MSG("CDAnalysis",Msg::kVerbose)
14366               <<"Not using: Event="<<event
14367               <<", pl="<<plane
14368               <<", sigCor="<<planeSigCor[plane]
14369               <<", lastPlane="<<lastPlane
14370               <<", lastPlSig="<<planeSigCor[lastPlane]
14371               <<", lastPlOdd="<<lastPlaneOdd
14372               <<", lastPlEven="<<lastPlaneEven
14373               <<endl;
14374           }
14375           else{
14376             avSigCor+=planeSigCor[plane];
14377             numUsed++;
14378             }
14379         }
14380         
14381         //find average
14382         if (numUsed>0) avSigCor/=numUsed;
14383         (*prof)->Fill(p,avSigCor);
14384         
14385         MSG("CDAnalysis",Msg::kDebug)
14386           <<"Event="<<event
14387           <<", winStart="<<windowStart
14388           <<", avSigCor="<<avSigCor<<endl;
14389       }
14390       prof++;
14391     }
14392   }//end of for                                       
14393   
14397 
14398   MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
14399   
14400   TCanvas *cProf=new TCanvas("cProf","Prof",0,0,1200,800);
14401   cProf->SetFillColor(0);
14402   string sName="SlidingWindow.ps";
14403   cProf->Print((sName+"[").c_str());
14404   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
14405        prof!=pSigCorVsDist.end();++prof){
14406     cProf->Clear();
14407     (*prof)->Draw();
14408     (*prof)->SetTitle("Average SigCor in Sliding Window");
14409     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
14410     (*prof)->GetYaxis()->SetTitle("Average SigCor");
14411     (*prof)->GetXaxis()->CenterTitle();
14412     (*prof)->GetYaxis()->CenterTitle();
14413     cProf->Print(sName.c_str());
14414   }
14415   cProf->Print((sName+"]").c_str());
14416 
14417   this->ScaleMap(totalSigCorOffSet,totalNumOffSet);
14418   TGraph* gPlaneVsAvSigCorOS=this->TGraphMap(totalSigCorOffSet);
14419   TGraph* gPlaneVsNumOS=this->TGraphMap(totalNumOffSet);
14420   this->ScaleMap(totalSigCor,totalNum);
14421   TGraph* gPlaneVsAvSigCor=this->TGraphMap(totalSigCor);
14422   TGraph* gPlaneVsNum=this->TGraphMap(totalNum);
14423 
14424   this->ScaleMap(totalSigCorOffSet2,totalNumOffSet2);
14425   TGraph* gPlaneVsAvSigCorOS2=this->TGraphMap(totalSigCorOffSet2);
14426   TGraph* gPlaneVsNumOS2=this->TGraphMap(totalNumOffSet2);
14427   this->ScaleMap(totalSigCor2,totalNum2);
14428   TGraph* gPlaneVsAvSigCor2=this->TGraphMap(totalSigCor2);
14429   TGraph* gPlaneVsNum2=this->TGraphMap(totalNum2);
14430 
14431   this->ScaleMap(totalSigCorOffSet3,totalNumOffSet3);
14432   TGraph* gPlaneVsAvSigCorOS3=this->TGraphMap(totalSigCorOffSet3);
14433   TGraph* gPlaneVsNumOS3=this->TGraphMap(totalNumOffSet3);
14434   this->ScaleMap(totalSigCor3,totalNum3);
14435   TGraph* gPlaneVsAvSigCor3=this->TGraphMap(totalSigCor3);
14436   TGraph* gPlaneVsNum3=this->TGraphMap(totalNum3);
14437 
14438   TCanvas *cSigCorVsPlane=new TCanvas("cSigCorVsPlane","SigCorVsPlane",
14439                                       0,0,1200,800);
14440   cSigCorVsPlane->SetFillColor(0);
14441   cSigCorVsPlane->Divide(1,2);
14442   cSigCorVsPlane->cd(1);
14443   pSigCorVsPlane->Draw();
14444   pSigCorVsPlane->SetTitle("Energy Deposition (SigCor)");
14445   pSigCorVsPlane->GetXaxis()->SetTitle("Plane");
14446   pSigCorVsPlane->GetYaxis()->SetTitle("Average SigCor");
14447   pSigCorVsPlane->GetXaxis()->CenterTitle();
14448   pSigCorVsPlane->GetYaxis()->CenterTitle();
14449   pSigCorVsPlane->SetMarkerStyle(3);
14450   pSigCorVsPlane->SetMarkerColor(2);
14451   pSigCorVsPlane->SetMarkerSize(0.2);
14452   pSigCorVsPlane->SetLineColor(2);
14453   cSigCorVsPlane->cd(2);
14454   gPlaneVsNum->Draw("AP");
14455   gPlaneVsNum->SetTitle("Number hits");
14456   gPlaneVsNum->GetXaxis()->SetTitle("Normalised plane");
14457   gPlaneVsNum->GetYaxis()->SetTitle("Num hits");
14458   gPlaneVsNum->GetXaxis()->CenterTitle();
14459   gPlaneVsNum->GetYaxis()->CenterTitle();
14460   gPlaneVsNum->SetMarkerStyle(3);
14461   gPlaneVsNum->SetMarkerColor(2);
14462   gPlaneVsNum->SetMarkerSize(0.8);
14463 
14464   TCanvas *cSigCorVsPlane2=new TCanvas("cSigCorVsPlane2",
14465                                        "SigCorVsPlane2",
14466                                        0,0,1200,800);
14467   cSigCorVsPlane2->SetFillColor(0);
14468   cSigCorVsPlane2->Divide(1,2);
14469   cSigCorVsPlane2->cd(1);
14470   pSigCorVsOsPlane->Draw();
14471   pSigCorVsOsPlane->SetTitle("Energy Deposition (SigCor)");
14472   pSigCorVsOsPlane->GetXaxis()->SetTitle("Plane");
14473   pSigCorVsOsPlane->GetYaxis()->SetTitle("Average SigCor");
14474   pSigCorVsOsPlane->GetXaxis()->CenterTitle();
14475   pSigCorVsOsPlane->GetYaxis()->CenterTitle();
14476   pSigCorVsOsPlane->SetMarkerStyle(3);
14477   pSigCorVsOsPlane->SetMarkerColor(3);
14478   pSigCorVsOsPlane->SetMarkerSize(0.4);
14479   pSigCorVsOsPlane->SetLineColor(3);
14480   cSigCorVsPlane2->cd(2);
14481   gPlaneVsNumOS->Draw("AP");
14482   gPlaneVsNumOS->SetTitle("Number hits");
14483   gPlaneVsNumOS->GetXaxis()->SetTitle("Normalised plane");
14484   gPlaneVsNumOS->GetYaxis()->SetTitle("Num hits");
14485   gPlaneVsNumOS->GetXaxis()->CenterTitle();
14486   gPlaneVsNumOS->GetYaxis()->CenterTitle();
14487   gPlaneVsNumOS->SetMarkerStyle(3);
14488   gPlaneVsNumOS->SetMarkerColor(2);
14489   gPlaneVsNumOS->SetMarkerSize(0.8);
14490 
14491   TCanvas *cResponseOS=new TCanvas("cResponseOS","ResponseOS",
14492                                    0,0,1200,800);
14493   cResponseOS->SetFillColor(0);
14494   cResponseOS->Divide(1,2);
14495   cResponseOS->cd(1);
14496   gPlaneVsAvSigCorOS->Draw("AP");
14497   gPlaneVsAvSigCorOS->SetTitle("Muon Energy Deposition");
14498   gPlaneVsAvSigCorOS->GetXaxis()->SetTitle("Normalised plane");
14499   gPlaneVsAvSigCorOS->GetYaxis()->SetTitle("Average SigCor");
14500   gPlaneVsAvSigCorOS->GetXaxis()->CenterTitle();
14501   gPlaneVsAvSigCorOS->GetYaxis()->CenterTitle();
14502   gPlaneVsAvSigCorOS->SetMarkerStyle(3);
14503   gPlaneVsAvSigCorOS->SetMarkerColor(2);
14504   gPlaneVsAvSigCorOS->SetMarkerSize(0.8);
14505   gPlaneVsAvSigCorOS2->Draw("P");
14506   gPlaneVsAvSigCorOS2->SetMarkerStyle(3);
14507   gPlaneVsAvSigCorOS2->SetMarkerColor(3);
14508   gPlaneVsAvSigCorOS2->SetMarkerSize(0.8);
14509   gPlaneVsAvSigCorOS3->Draw("P");
14510   gPlaneVsAvSigCorOS3->SetMarkerStyle(3);
14511   gPlaneVsAvSigCorOS3->SetMarkerColor(4);
14512   gPlaneVsAvSigCorOS3->SetMarkerSize(0.8);
14513   cResponseOS->cd(2);
14514   gPlaneVsNumOS->Draw("AP");
14515   gPlaneVsNumOS->SetTitle("Number hits");
14516   gPlaneVsNumOS->GetXaxis()->SetTitle("Normalised plane");
14517   gPlaneVsNumOS->GetYaxis()->SetTitle("Num hits");
14518   gPlaneVsNumOS->GetXaxis()->CenterTitle();
14519   gPlaneVsNumOS->GetYaxis()->CenterTitle();
14520   gPlaneVsNumOS->SetMarkerStyle(3);
14521   gPlaneVsNumOS->SetMarkerColor(2);
14522   gPlaneVsNumOS->SetMarkerSize(0.8);
14523   gPlaneVsNumOS2->Draw("P");
14524   gPlaneVsNumOS2->SetMarkerStyle(3);
14525   gPlaneVsNumOS2->SetMarkerColor(3);
14526   gPlaneVsNumOS2->SetMarkerSize(0.8);
14527   gPlaneVsNumOS3->Draw("P");
14528   gPlaneVsNumOS3->SetMarkerStyle(3);
14529   gPlaneVsNumOS3->SetMarkerColor(4);
14530   gPlaneVsNumOS3->SetMarkerSize(0.8);
14531 
14532   TCanvas *cResponse=new TCanvas("cResponse","Response",
14533                                    0,0,1200,800);
14534   cResponse->SetFillColor(0);
14535   cResponse->Divide(1,2);
14536   cResponse->cd(1);
14537   gPlaneVsAvSigCor->Draw("AP");
14538   gPlaneVsAvSigCor->SetTitle("Muon Energy Deposition");
14539   gPlaneVsAvSigCor->GetXaxis()->SetTitle("Plane");
14540   gPlaneVsAvSigCor->GetYaxis()->SetTitle("Average SigCor");
14541   gPlaneVsAvSigCor->GetXaxis()->CenterTitle();
14542   gPlaneVsAvSigCor->GetYaxis()->CenterTitle();
14543   gPlaneVsAvSigCor->SetMarkerStyle(3);
14544   gPlaneVsAvSigCor->SetMarkerColor(2);
14545   gPlaneVsAvSigCor->SetMarkerSize(0.8);
14546   gPlaneVsAvSigCor2->Draw("P");
14547   gPlaneVsAvSigCor2->SetMarkerStyle(3);
14548   gPlaneVsAvSigCor2->SetMarkerColor(3);
14549   gPlaneVsAvSigCor2->SetMarkerSize(0.8);
14550   gPlaneVsAvSigCor3->Draw("P");
14551   gPlaneVsAvSigCor3->SetMarkerStyle(3);
14552   gPlaneVsAvSigCor3->SetMarkerColor(4);
14553   gPlaneVsAvSigCor3->SetMarkerSize(0.8);
14554   cResponse->cd(2);
14555   gPlaneVsNum->Draw("AP");
14556   gPlaneVsNum->SetTitle("Number hits");
14557   gPlaneVsNum->GetXaxis()->SetTitle("Plane");
14558   gPlaneVsNum->GetYaxis()->SetTitle("Num hits");
14559   gPlaneVsNum->GetXaxis()->CenterTitle();
14560   gPlaneVsNum->GetYaxis()->CenterTitle();
14561   gPlaneVsNum->SetMarkerStyle(3);
14562   gPlaneVsNum->SetMarkerColor(2);
14563   gPlaneVsNum->SetMarkerSize(0.8);
14564   gPlaneVsNum2->Draw("P");
14565   gPlaneVsNum2->SetMarkerStyle(3);
14566   gPlaneVsNum2->SetMarkerColor(3);
14567   gPlaneVsNum2->SetMarkerSize(0.8);
14568   gPlaneVsNum3->Draw("P");
14569   gPlaneVsNum3->SetMarkerStyle(3);
14570   gPlaneVsNum3->SetMarkerColor(4);
14571   gPlaneVsNum3->SetMarkerSize(0.8);
14572 
14573   /*
14574   TCanvas *cResults=new TCanvas("cResults","Results",0,0,1200,800);
14575   cResults->SetFillColor(0);
14576   cResults->Divide(2,2);
14577   cResults->cd(1);
14578   hEvenResult->Draw();
14579   cResults->cd(2);
14580   hOddResult->Draw();
14581   */
14582 
14583   TCanvas *cKov=new TCanvas("cKov","Kov",0,0,1200,800);
14584   cKov->SetFillColor(0);
14585   cKov->Divide(3,2);
14586   cKov->cd(1);
14587   hKovADC3->Draw();
14588   cKov->cd(2);
14589   hKovADC3Cut->Draw();
14590   cKov->cd(5);
14591   hKovADC1->Draw();
14592   cKov->cd(4);
14593   hKovADC1Cut->Draw();
14594   cKov->cd(3);
14595   hKovADC3Whole->Draw();
14596   cKov->cd(6);
14597   hKovADC1Whole->Draw();
14598 
14599   TCanvas *cTof=new TCanvas("cTof","Tof",0,0,1200,800);
14600   cTof->SetFillColor(0);
14601   hTofDiffNotElec->Draw();
14602   hTofDiffNotElec->SetLineColor(2);
14603   hTofDiffNotElec->SetLineWidth(3);
14604   hTofDiffElec->Draw("sames");
14605   hTofDiffElec->SetLineWidth(3);
14606 
14607   TCanvas *cTofAll=new TCanvas("cTofAll","cTofAll",0,0,1200,800);
14608   cTofAll->SetFillColor(0);
14609   cTofAll->Divide(3,2);
14610   cTofAll->cd(1);
14611   hTofTDC0->Draw();
14612   cTofAll->cd(2);
14613   hTofTDC2->Draw();
14614   cTofAll->cd(3);
14615   hTofDiff->Draw();
14616   cTofAll->cd(4);
14617   hTofTDC0Whole->Draw();
14618   cTofAll->cd(5);
14619   hTofTDC2Whole->Draw();
14620   cTofAll->cd(6);
14621   hTofDiffWhole->Draw();
14622 
14623   TCanvas *cTofKovDiff=new TCanvas("cTofKovDiff","TofKovDiff",
14624                                    0,0,1200,800);
14625   cTofKovDiff->SetFillColor(0);
14626   cTofKovDiff->Divide(2,2);
14627   cTofKovDiff->cd(1);
14628   hTofKov1Diff->Draw();
14629   cTofKovDiff->cd(2);
14630   hTofKov3Diff->Draw();
14631   cTofKovDiff->cd(3);
14632   hTofKov1DiffWhole->Draw();
14633   cTofKovDiff->cd(4);
14634   hTofKov3DiffWhole->Draw();
14635 
14636   TCanvas *cGeom=new TCanvas("cGeom","Geom",0,0,1200,800);
14637   cGeom->SetFillColor(0);
14638   cGeom->Divide(2,3);
14639   cGeom->cd(1);
14640   hPlane->Draw();
14641   cGeom->cd(2);
14642   hStrip->Draw();
14643   cGeom->cd(3);
14644   hStripend->Draw();
14645   cGeom->cd(4);
14646   hNumPlanes->Draw();
14647   cGeom->cd(5);
14648   hEventLength->Draw();
14649 
14650   /*
14651   TCanvas *cHits=new TCanvas("cHits","Hits",0,0,1200,800);
14652   cHits->SetFillColor(0);
14653   cHits->Divide(2,3);
14654   cHits->cd(1);
14655   hChargeSigCor->Draw();
14656   cHits->cd(2);
14657   hChargeSigLin->Draw();
14658   cHits->cd(3);
14659   hChargePe->Draw();
14660   cHits->cd(4);
14661   hGain->Draw();
14662   cHits->cd(5);
14663   hAdc->Draw();
14664   */
14665 
14666   TCanvas *cStVsPl=new TCanvas("cStVsPl","StVsPl",0,0,1200,800);
14667   cStVsPl->SetFillColor(0);
14668   cStVsPl->Divide(1,2);
14669   cStVsPl->cd(1);
14670   hStVsPl1->Draw("colz");
14671   cStVsPl->cd(2);
14672   hStVsPl2->Draw("colz");
14673 
14674   TCanvas *cTime=new TCanvas("cTime","Time",0,0,1200,800);
14675   cTime->SetFillColor(0);
14676   cTime->Divide(2,3);
14677   cTime->cd(1);
14678   hTime->Draw();
14679   cTime->cd(2);
14680   hTime2->Draw();
14681   cTime->cd(3);
14682 
14683   cTime->cd(4);
14684 
14685   cTime->cd(5);
14686 
14687 
14688   /*
14689  TCanvas *cAngles=new TCanvas("cAngles","Angles",0,0,1200,800);
14690   cAngles->SetFillColor(0);
14691   cAngles->Divide(3,2);
14692   cAngles->cd(1);
14693   hdzds->Draw();
14694   cAngles->cd(2);
14695   hdsdz->Draw();
14696   cAngles->cd(3);
14697   hdydz->Draw();
14698   cAngles->cd(4);
14699   hdxdz->Draw();
14700   cAngles->cd(5);
14701   hdyds->Draw();
14702   cAngles->cd(6);
14703   hdxds->Draw();
14704 
14705   TCanvas *cPos=new TCanvas("cPos","Pos",0,0,1200,800);
14706   cPos->SetFillColor(0);
14707   cPos->Divide(2,1);
14708   cPos->cd(1);
14709   hTransPos->Draw();
14710   cPos->cd(2);
14711   hYPos->Draw();
14712   */
14713 
14714   MSG("CDAnalysis",Msg::kInfo) 
14715     <<" ** Finished CleanMuons method **"<<endl;
14716 }

Bool_t CDAnalysis::CutByHandOnEventLength (  )  const [private]

Definition at line 3026 of file CDAnalysis.cxx.

References fBeamMomentum, fLastPlane, fMainParticleEnergy, fRunNumber, fSimFlag, SimFlag::kData, Msg::kDebug, Msg::kInfo, SimFlag::kMC, MAXMSG, and MSG.

03027 {
03028   //set default to not cut
03029   Bool_t cutThisOne=false;
03030 
03031   Int_t minPlane=0;
03032   Int_t maxPlane=60;
03033 
03034   if (fSimFlag==SimFlag::kData){
03035     
03036     //might want to tighten these up to boost the signal to noise ratio
03037     
03038     if (fRunNumber==70709 ||
03039         fRunNumber==71266 ||
03040         fRunNumber==100161 ||
03041         fRunNumber==100270){//1.8
03042       //cut out through going muons, no 58,59
03043       minPlane=42;
03044       maxPlane=57;
03045       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03046     }
03047     else if (fRunNumber==100243){//1.6
03048       minPlane=40;
03049       maxPlane=49;
03050       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03051     }
03052     else if (fRunNumber==100131){//1.4
03053       minPlane=35;
03054       maxPlane=44;
03055       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03056     }
03057     else if (fRunNumber==70579){//1.0 GeV run
03058       //hack - these are 1.8 cuts
03059       if (fLastPlane<42 || fLastPlane>57) cutThisOne=true;
03060     }
03061   }
03062   else if (fSimFlag==SimFlag::kMC){
03063     
03064     if (fMainParticleEnergy>1.3 && fMainParticleEnergy<1.5){
03065       minPlane=35;
03066       maxPlane=44;
03067       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03068     }
03069     else if (fMainParticleEnergy>1.5 && fMainParticleEnergy<1.7){
03070       minPlane=40;
03071       maxPlane=49;
03072       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03073     }
03074     else if (fMainParticleEnergy>1.7 && fMainParticleEnergy<1.9){
03075       minPlane=42;
03076       maxPlane=57;
03077       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03078     }
03079     else if (fMainParticleEnergy>1.9){
03080       minPlane=44;
03081       maxPlane=58;//last but one, so didn't exit
03082       if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03083     }
03084     else{
03085       MAXMSG("CDAnalysis",Msg::kInfo,10)
03086         <<"No event length cut for this particle energy="
03087         <<fMainParticleEnergy<<endl;
03088     }
03089   }
03090 
03091   if (cutThisOne){
03092     MAXMSG("CDAnalysis",Msg::kInfo,1)
03093       <<"Using 'by hand' event length cuts to pass muons: "
03094       <<minPlane<<"<Plane<"<<maxPlane
03095       <<", fBeamMomentum="<<fBeamMomentum<<endl;
03096   }
03097 
03098   MSG("CDAnalysis",Msg::kDebug)
03099     <<"fLastPlane="<<fLastPlane<<", cut this one="<<cutThisOne<<endl;
03100 
03101   return cutThisOne;
03102 }

Bool_t CDAnalysis::CutByHandOnPid (  )  const [private]

Definition at line 2602 of file CDAnalysis.cxx.

References fKovADC1, fKovADC3, fKovTimeStamp3, fRunNumber, fSimFlag, fTofADCTimeStamp1, fTofTDC0, fTofTDC2, SimFlag::kData, Msg::kInfo, Msg::kWarning, and MAXMSG.

Referenced by PrintPIDStats(), and ValidatePIDInfo().

02603 {
02604   //set default to not cut
02605   Bool_t cutThisOne=false;
02606 
02607   //only have pid for real data so return if not data
02608   if (fSimFlag!=SimFlag::kData) return false;
02609 
02610   Bool_t muonKovADC1=false;
02611   Bool_t muonKovADC3=false;
02612   Bool_t goodTof=false;
02613   Bool_t muonInTime=false;
02614 
02615   if (fRunNumber==70579){//a 1 GeV run
02616     if (fKovADC3<500) muonKovADC3=true;
02617     if (fKovADC1<300) muonKovADC1=true;//not an electron ADC
02618     if (fTofTDC2-fTofTDC0>340 && fTofTDC2-fTofTDC0<500) goodTof=true;
02619 
02620     //don't analyse if not a muon
02621     if (!muonKovADC1) cutThisOne=true;
02622     if (!muonKovADC3) cutThisOne=true;
02623     
02624     //don't analyse if bad tof
02625     if (!goodTof) cutThisOne=true;
02626   }
02627   else if (fRunNumber==70709){
02628     //string particleSelection="muons";
02629     string particleSelection="notElectrons";
02630     //string particleSelection="notElectronsNoCkv";
02631 
02632     if (particleSelection=="muons"){
02633       MAXMSG("CDAnalysis",Msg::kWarning,1)
02634         <<"Applying cut: "<<particleSelection<<endl;
02635       
02636       if (fKovADC3<1400 && fKovADC3>0) muonKovADC3=true;//muon ADC
02637       if (fKovADC1<500) muonKovADC1=true;//not an electron ADC
02638       if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02639       //Tof in time with muon triggering kov
02640       if ((fTofADCTimeStamp1-fKovTimeStamp3)<-78 &&
02641           (fTofADCTimeStamp1-fKovTimeStamp3)>-96) muonInTime=true;
02642       
02643       //don't analyse if not a muon
02644       if (!muonKovADC1) cutThisOne=true;
02645       if (!muonKovADC3) cutThisOne=true;
02646       
02647       //don't analyse if bad tof
02648       if (!goodTof) cutThisOne=true;
02649       
02650       //don't analyse if tof not in time with kov set to muons
02651       if (!muonInTime) cutThisOne=true;
02652     }
02653     else if (particleSelection=="notElectrons"){
02654       MAXMSG("CDAnalysis",Msg::kWarning,1)
02655         <<"Applying cut: "<<particleSelection<<endl;
02656       
02657       if (fKovADC3<1400) muonKovADC3=true;//not an electron ADC
02658       if (fKovADC1<500) muonKovADC1=true;//not an electron ADC
02659       if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02660       
02661       //don't analyse if not a muon
02662       if (!muonKovADC1) cutThisOne=true;
02663       if (!muonKovADC3) cutThisOne=true;
02664       
02665       //don't analyse if bad tof
02666       if (!goodTof) cutThisOne=true;
02667 
02668       //don't want the muon in time cut
02669     }
02670   }
02671   else if (fRunNumber==71266){
02672     if (fKovADC3<1400) muonKovADC3=true;//not an electron ADC
02673     if (fKovADC1<1000) muonKovADC1=true;//not an electron ADC
02674     if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02675 
02676     //don't analyse if not a muon
02677     if (!muonKovADC1) cutThisOne=true;
02678     if (!muonKovADC3) cutThisOne=true;
02679     
02680     //don't analyse if bad tof
02681     if (!goodTof) cutThisOne=true;
02682   }
02683   else if (fRunNumber==100131){
02684     if (fKovADC3<1000) muonKovADC3=true;
02685     if (fKovADC1<500) muonKovADC1=true;//not an electron ADC
02686     if (fTofTDC2-fTofTDC0>370 && fTofTDC2-fTofTDC0<525) goodTof=true;
02687 
02688     //don't analyse if not a muon
02689     if (!muonKovADC1) cutThisOne=true;
02690     if (!muonKovADC3) cutThisOne=true;
02691     
02692     //don't analyse if bad tof
02693     if (!goodTof) cutThisOne=true;
02694   }
02695   else if (fRunNumber==100161){
02696 
02697     //string particleSelection="muons";
02698     string particleSelection="notElectrons";
02699     //string particleSelection="notElectronsNoCkv";
02700 
02701     if (particleSelection=="muons"){
02702       MAXMSG("CDAnalysis",Msg::kWarning,1)
02703         <<"Applying cut: "<<particleSelection<<endl;
02704 
02705       if (fKovADC3<850 && fKovADC3>0) muonKovADC3=true;
02706       if (fKovADC1<400) muonKovADC1=true;//not an electron ADC
02707       if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02708       //Tof in time with muon triggering kov
02709       if ((fTofADCTimeStamp1-fKovTimeStamp3)<-24 &&
02710           (fTofADCTimeStamp1-fKovTimeStamp3)>-45) muonInTime=true;
02711       
02712       //don't analyse if not a muon
02713       if (!muonKovADC1) cutThisOne=true;
02714       if (!muonKovADC3) cutThisOne=true;
02715       
02716       //don't analyse if bad tof
02717       if (!goodTof) cutThisOne=true;
02718       
02719       //don't analyse if tof not in time with kov set to muons
02720       if (!muonInTime) cutThisOne=true;
02721     }
02722     else if (particleSelection=="notElectrons"){
02723       MAXMSG("CDAnalysis",Msg::kWarning,1)
02724         <<"Applying cut: "<<particleSelection<<endl;
02725 
02726       if (fKovADC3<850) muonKovADC3=true;
02727       if (fKovADC1<400) muonKovADC1=true;//not an electron ADC
02728       if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02729 
02730       //don't analyse if not a muon
02731       if (!muonKovADC1) cutThisOne=true;
02732       if (!muonKovADC3) cutThisOne=true;
02733       
02734       //don't analyse if bad tof
02735       if (!goodTof) cutThisOne=true;
02736 
02737       //don't want the muon in time cut
02738     }
02739     else if (particleSelection=="notElectronsNoCkv"){
02740       MAXMSG("CDAnalysis",Msg::kWarning,1)
02741         <<"Applying cut: "<<particleSelection<<endl;
02742 
02743       if (fKovADC3<100) muonKovADC3=true;
02744       if (fKovADC1<100) muonKovADC1=true;//not an electron ADC
02745       if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02746 
02747       //don't analyse if not a muon
02748       if (!muonKovADC1) cutThisOne=true;
02749       if (!muonKovADC3) cutThisOne=true;
02750       
02751       //don't analyse if bad tof
02752       if (!goodTof) cutThisOne=true;
02753 
02754       //don't want the muon in time cut
02755     }
02756   }
02757   else if (fRunNumber==100243){
02758     if (fKovADC3<900) muonKovADC3=true;
02759     if (fKovADC1<1000) muonKovADC1=true;//not an electron ADC
02760     if (fTofTDC2-fTofTDC0>350 && fTofTDC2-fTofTDC0<490) goodTof=true;
02761 
02762     //don't analyse if not a muon
02763     if (!muonKovADC1) cutThisOne=true;
02764     if (!muonKovADC3) cutThisOne=true;
02765     
02766     //don't analyse if bad tof
02767     if (!goodTof) cutThisOne=true;
02768     
02769   }
02770   else if (fRunNumber==100270){
02771     if (fKovADC3<1100) muonKovADC3=true;
02772     if (fKovADC1<500) muonKovADC1=true;//not an electron ADC
02773     if (fTofTDC2-fTofTDC0>360 && fTofTDC2-fTofTDC0<525) goodTof=true;
02774 
02775     //don't analyse if not a muon
02776     if (!muonKovADC1) cutThisOne=true;
02777     if (!muonKovADC3) cutThisOne=true;
02778     
02779     //don't analyse if bad tof
02780     if (!goodTof) cutThisOne=true;    
02781   }
02782 
02783   if (cutThisOne){
02784     MAXMSG("CDAnalysis",Msg::kInfo,1)
02785       <<"Applying 'by hand' cut on pid"<<endl;
02786   }
02787 
02788   return cutThisOne;
02789 }

Bool_t CDAnalysis::CutByHandOnPidForElec (  )  const [private]

Definition at line 2472 of file CDAnalysis.cxx.

References fKovADC1, fKovADC3, fKovTimeStamp1, fKovTimeStamp3, fRunNumber, fSimFlag, fTofADCTimeStamp1, fTofTDC0, fTofTDC2, SimFlag::kData, Msg::kInfo, and MAXMSG.

Referenced by PrintPIDStats(), and ValidatePIDInfo().

02473 {
02474   //set default to not cut
02475   Bool_t cutThisOne=false;
02476 
02477   //only have pid for real data so return if not data
02478   if (fSimFlag!=SimFlag::kData) return false;
02479 
02480   string particleSelection="for electrons";
02481   MAXMSG("CDAnalysis",Msg::kInfo,1)
02482     <<"Applying cut: "<<particleSelection<<endl;
02483 
02484   Bool_t elecKovADC1=false;
02485   Bool_t elecKovADC3=false;
02486   Bool_t goodTof=false;
02487   Bool_t elecInTime=false;
02488 
02489   if (fRunNumber==70579){//a 1 GeV run
02490 
02491     if (fTofTDC2-fTofTDC0>340 && fTofTDC2-fTofTDC0<500) goodTof=true;
02492 
02493     //don't analyse if not a elec
02494     if (!elecKovADC1) cutThisOne=true;
02495     if (!elecKovADC3) cutThisOne=true;
02496     
02497     //don't analyse if bad tof
02498     if (!goodTof) cutThisOne=true;
02499   }
02500   else if (fRunNumber==70709){
02501     MAXMSG("CDAnalysis",Msg::kInfo,1)
02502       <<"Applying cut: "<<particleSelection<<endl;
02503 
02504     if (fKovADC3>2000 && fKovADC3<3500) elecKovADC3=true;//elec ADC
02505     if (fKovADC1>1000 && fKovADC1<2500) elecKovADC1=true;
02506     if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02507     //Tof in time with elec triggering kov
02508     if ((fTofADCTimeStamp1-fKovTimeStamp3)<-80 &&
02509         (fTofADCTimeStamp1-fKovTimeStamp3)>-85 &&
02510         (fTofADCTimeStamp1-fKovTimeStamp1)<-30 &&
02511         (fTofADCTimeStamp1-fKovTimeStamp1)>-40) elecInTime=true;
02512     
02513     //don't analyse if not a elec
02514     if (!elecKovADC1) cutThisOne=true;
02515     if (!elecKovADC3) cutThisOne=true;
02516     
02517     //don't analyse if bad tof
02518     if (!goodTof) cutThisOne=true;
02519     
02520     //don't analyse if tof not in time with kov set to elecs
02521     if (!elecInTime) cutThisOne=true;
02522 
02523   }
02524   else if (fRunNumber==71266){
02525 
02526   }
02527   else if (fRunNumber==100131){
02528 
02529   }
02530   else if (fRunNumber==100161){
02531 
02532     MAXMSG("CDAnalysis",Msg::kInfo,1)
02533       <<"Applying cut: "<<particleSelection<<endl;
02534 
02535     if (fKovADC3>1600 && fKovADC3<2100) elecKovADC3=true;//elec ADC
02536     if (fKovADC1>1100 && fKovADC1<3100) elecKovADC1=true;
02537     if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<470) goodTof=true;
02538     //Tof in time with elec triggering kov
02539     if ((fTofADCTimeStamp1-fKovTimeStamp3)<-20 &&
02540         (fTofADCTimeStamp1-fKovTimeStamp3)>-30 &&
02541         (fTofADCTimeStamp1-fKovTimeStamp1)<-50 &&
02542         (fTofADCTimeStamp1-fKovTimeStamp1)>-62) elecInTime=true;
02543     
02544     //don't analyse if not a elec
02545     if (!elecKovADC1) cutThisOne=true;
02546     if (!elecKovADC3) cutThisOne=true;
02547     
02548     //don't analyse if bad tof
02549     if (!goodTof) cutThisOne=true;
02550     
02551     //don't analyse if tof not in time with kov set to elecs
02552     if (!elecInTime) cutThisOne=true;
02553 
02554 
02555   }
02556   else if (fRunNumber==100243){
02557 
02558     
02559   }
02560   else if (fRunNumber==100270){
02561 
02562   }
02563   
02564   if (cutThisOne){
02565     MAXMSG("CDAnalysis",Msg::kInfo,1)
02566       <<"Applying 'by hand' cut on pid to pass only electrons"<<endl;
02567   }
02568 
02569   return cutThisOne;
02570 }

Bool_t CDAnalysis::CutOnBadCalorimetry ( Int_t  plane,
Int_t  strip,
Int_t  end 
) const [private]

Definition at line 2348 of file CDAnalysis.cxx.

References fPlane, fSimFlag, SimFlag::kData, Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse(), and StoppingMuonCalibration().

02350 {
02351   //only have bad channels in real data so return if not data
02352   if (fSimFlag!=SimFlag::kData) return false;
02353 
02354   Bool_t cutThisOne=false;
02355 
02356   //cut out the strips with bad calorimetry
02357   //do this for all run periods to be consistent
02358   if (fPlane==0 || fPlane==35) cutThisOne=true;
02359   
02360   if (cutThisOne){
02361     MAXMSG("CDAnalysis",Msg::kInfo,6)
02362       <<"Applying cut to bad calorimetry:"
02363       <<" (pl="<<plane<<", str="<<strip<<", end="<<end<<")"<<endl;
02364   }
02365   
02366   return cutThisOne;
02367 }

Bool_t CDAnalysis::CutOnBadPedestals ( Int_t  plane,
Int_t  strip,
Int_t  end 
) const [private]

Definition at line 2310 of file CDAnalysis.cxx.

References fRunNumber, fSimFlag, SimFlag::kData, Msg::kInfo, and MAXMSG.

Referenced by CalcLastPlaneOnTrk(), CalcLastPlaneOnTrkNoXTalk(), CalcXYZ(), ElectronResponse(), MuonCalorimetry(), MuonNearFar(), MuonResponse(), MuonSampleCuts(), MuonScatter(), MuonStVsPl(), StoppingMuonCalibration(), and Template2().

02312 {
02313   //only have bad channels in real data so return if not data
02314   if (fSimFlag!=SimFlag::kData) return false;
02315 
02316   Bool_t cutThisOne=false;
02317 
02318   //cut out the strips with bad pedestals
02319   //not sure exactly for which run number the problem was fixed
02320   //had gone away by 71266
02321   if (fRunNumber>=70000 && fRunNumber<=70888){
02322     if ((plane==21 || plane==41) && strip==19) cutThisOne=true;
02323   }
02324   else if (fRunNumber>40000 && fRunNumber<60000){
02325     //cut out the strips with bad pedestals
02326     if ((plane==21 || plane==41) && strip==19 && end==1){
02327       cutThisOne=true;
02328     }
02329     if ((plane==20 || plane==40) && strip==4 && end==2){
02330       cutThisOne=true;
02331     }
02332   }    
02333   
02334   //not sure about this, MK reported it bad
02335   //in the 30000s and 40000s (i.e. T11) 38,10,2 was bad
02336   
02337   if (cutThisOne){
02338     MAXMSG("CDAnalysis",Msg::kInfo,6)
02339       <<"Applying cut to bad pedestal channel:"
02340       <<" (pl="<<plane<<", str="<<strip<<", end="<<end<<")"<<endl;
02341   }
02342   
02343   return cutThisOne;
02344 }

Bool_t CDAnalysis::CutOnDeadChips (  )  const [private]

Definition at line 2292 of file CDAnalysis.cxx.

References fNumDeadChips, Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse(), MuonCalorimetry(), MuonNearFar(), MuonResponse(), MuonSampleCuts(), MuonScatter(), PrintPIDStats(), StoppingMuonCalibration(), and Template2().

02293 {
02294   Bool_t cutThisOne=false;
02295 
02296   //check if dead chips
02297   if (fNumDeadChips>0) cutThisOne=true;
02298 
02299   if (cutThisOne){
02300     MAXMSG("CDAnalysis",Msg::kInfo,1)
02301       <<"Applying cut on dead chips:"
02302       <<" numDeadChips="<<fNumDeadChips<<endl;
02303   }
02304   
02305   return cutThisOne;
02306 }

Bool_t CDAnalysis::CutOnEventLength (  )  const [private]

Definition at line 2996 of file CDAnalysis.cxx.

References fBeamMomentum, fLastPlane, GetEventLength(), GetEvLenMinMax(), Msg::kDebug, Msg::kInfo, MAXMSG, and MSG.

Referenced by MuonCalorimetry(), MuonNearFar(), MuonResponse(), StoppingMuonCalibration(), and TruthEnDep().

02997 {
02998   //set default to not cut
02999   Bool_t cutThisOne=false;
03000 
03001   Int_t lastPlane=this->GetEventLength();
03002   
03003   Int_t minPlane=0;
03004   Int_t maxPlane=60;
03005   this->GetEvLenMinMax(minPlane,maxPlane);
03006 
03007   //new cuts are now inclusive so it's 31<=Pl<=45
03008   if (lastPlane<minPlane || lastPlane>maxPlane) cutThisOne=true;
03009 
03010   if (cutThisOne){
03011     MAXMSG("CDAnalysis",Msg::kInfo,1)
03012       <<"Using event length cuts to pass muons: "
03013       <<minPlane<<"<=Plane<="<<maxPlane
03014       <<" (lastPlane="<<lastPlane<<")"
03015       <<", fBeamMomentum="<<fBeamMomentum<<endl;
03016   }
03017 
03018   MSG("CDAnalysis",Msg::kDebug)
03019     <<"fLastPlane="<<fLastPlane<<", cut this one="<<cutThisOne<<endl;
03020 
03021   return cutThisOne;
03022 }

Bool_t CDAnalysis::CutOnEventLengthForElec (  )  const [private]

Definition at line 2870 of file CDAnalysis.cxx.

References fNumPlanesHitAll, Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse().

02871 {
02872   //set default to not cut
02873   Bool_t cutThisOne=false;
02874 
02875   //Int_t minPlane=0;
02876   Int_t maxPlane=20;
02877 
02878   //old cut
02879   //if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
02880 
02881   //new cut - number of planes hit allows for a noise hit in the
02882   //back of the detector but will cut out muons sucessfully
02883   Int_t numPlanes=fNumPlanesHitAll.size();
02884   if (numPlanes>maxPlane) cutThisOne=true;
02885 
02886   if (cutThisOne){
02887     MAXMSG("CDAnalysis",Msg::kInfo,1)
02888       <<"Using event length cuts for electrons: "
02889       <<"Num hit planes<="<<maxPlane<<endl;
02890   }
02891 
02892   return cutThisOne;
02893 }

Bool_t CDAnalysis::CutOnFiducialVolume (  )  const [private]

Definition at line 2224 of file CDAnalysis.cxx.

References fStripsFromCentrePeCut, Msg::kInfo, and MAXMSG.

Referenced by StoppingMuonCalibration().

02225 {
02226   Bool_t cutThisOne=false;
02227 
02228   Int_t stripsFromCentreCut=10;
02229 
02230   if (fStripsFromCentrePeCut>=stripsFromCentreCut) cutThisOne=true;
02231 
02232   if (cutThisOne){
02233     MAXMSG("CDAnalysis",Msg::kInfo,1)
02234       <<"Applying cut on fiducial volume:"<<endl
02235       <<" stripsFromCentre<"<<stripsFromCentreCut
02236       <<" (fStripsFromCentrePeCut="<<fStripsFromCentrePeCut<<")"
02237       <<endl;
02238   }
02239   
02240   return cutThisOne;
02241 }

Bool_t CDAnalysis::CutOnNumHitsPerPlane (  )  const [private]

Definition at line 2245 of file CDAnalysis.cxx.

References fNumHitsPerPlane, Msg::kInfo, and MAXMSG.

Referenced by StoppingMuonCalibration().

02246 {
02247   Bool_t cutThisOne=false;
02248 
02249   Float_t hitsPerPlLowCut=1.7;
02250   Float_t hitsPerPlCut=2.9;
02251 
02252   if (fNumHitsPerPlane<hitsPerPlLowCut ||
02253       fNumHitsPerPlane>hitsPerPlCut) cutThisOne=true;
02254 
02255   if (cutThisOne){
02256     MAXMSG("CDAnalysis",Msg::kInfo,1)
02257       <<"Applying cut on hits per plane:"
02258       <<" numHitsPerPlane<"<<hitsPerPlCut<<" and >"<<hitsPerPlLowCut
02259       <<" (fNumHitsPerPlane="<<fNumHitsPerPlane<<")"<<endl
02260       <<endl;
02261   }
02262   
02263   return cutThisOne;
02264 }

Bool_t CDAnalysis::CutOnNumHitsPerPlane10 (  )  const [private]

Definition at line 2268 of file CDAnalysis.cxx.

References fNumHitsPerPlanePeCut10, Msg::kInfo, and MAXMSG.

Referenced by StoppingMuonCalibration().

02269 {
02270   Bool_t cutThisOne=false;
02271 
02272   Float_t hitsPerPlPeCut10LowCut=1.1;
02273   Float_t hitsPerPlPeCut10Cut=2.7;
02274 
02275   if (fNumHitsPerPlanePeCut10<hitsPerPlPeCut10LowCut ||
02276       fNumHitsPerPlanePeCut10>hitsPerPlPeCut10Cut) cutThisOne=true;
02277 
02278   if (cutThisOne){
02279     MAXMSG("CDAnalysis",Msg::kInfo,1)
02280       <<"Applying cut on hits per plane:"
02281       <<" numHitsPerPlanePeCut10<"<<hitsPerPlPeCut10Cut
02282       <<" and >"<<hitsPerPlPeCut10LowCut
02283       <<" (fNumHitsPerPlanePeCut10="<<fNumHitsPerPlanePeCut10<<")"
02284       <<endl;
02285   }
02286   
02287   return cutThisOne;
02288 }

Bool_t CDAnalysis::CutOnNumPlanesHit ( Int_t  planesHit  )  const [private]

Definition at line 2934 of file CDAnalysis.cxx.

References fBeamMomentum, fLastPlane, GetEvLenMinMax(), Msg::kDebug, Msg::kInfo, MAXMSG, and MSG.

Referenced by StoppingMuonCalibration().

02935 {
02936   //set default to not cut
02937   Bool_t cutThisOne=false;
02938 
02939   Int_t minPlane=0;
02940   Int_t maxPlane=60;
02941 
02942   this->GetEvLenMinMax(minPlane,maxPlane);
02943 
02944   //new cuts are now inclusive so it's 31<=Pl<=45
02945   if (planesHit<minPlane || planesHit>maxPlane) cutThisOne=true;
02946 
02947   if (cutThisOne){
02948     MAXMSG("CDAnalysis",Msg::kInfo,1)
02949       <<"Using num planes hit cut to pass muons: "
02950       <<minPlane<<"<=Plane<="<<maxPlane
02951       <<", fBeamMomentum="<<fBeamMomentum<<endl;
02952   }
02953 
02954   MSG("CDAnalysis",Msg::kDebug)
02955     <<"fLastPlane="<<fLastPlane<<", cut this one="<<cutThisOne<<endl;
02956 
02957   return cutThisOne;
02958 }

Bool_t CDAnalysis::CutOnOverlap (  )  const [private]

Definition at line 2400 of file CDAnalysis.cxx.

References fOLChi2, fSimFlag, SimFlag::kData, Msg::kInfo, and MAXMSG.

Referenced by StoppingMuonCalibration().

02401 {
02402   //set default to not cut
02403   Bool_t cutThisOne=false;
02404 
02405   //only have pid for real data so return if not data
02406   if (fSimFlag!=SimFlag::kData) return false;
02407 
02408   //if (!fNoOverlap){ //not no overlap=overlap
02409   //cutThisOne=true;
02410   //}
02411   Float_t olChi2Threshold=1.1;
02412   if (fOLChi2>olChi2Threshold) cutThisOne=true;
02413 
02414   if (cutThisOne){
02415     MAXMSG("CDAnalysis",Msg::kInfo,1)
02416       <<"Applying cut on overlap, OLChi2<"<<olChi2Threshold
02417       <<endl;
02418   }
02419 
02420   return cutThisOne;
02421 }

Bool_t CDAnalysis::CutOnOverlapForElec (  )  const [private]

Definition at line 2425 of file CDAnalysis.cxx.

References fOLChi2, fSimFlag, SimFlag::kData, Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse().

02426 {
02427   //set default to not cut
02428   Bool_t cutThisOne=false;
02429 
02430   //only have pid for real data so return if not data
02431   if (fSimFlag!=SimFlag::kData) return false;
02432 
02433   Float_t olChi2Threshold=1.1;
02434   if (fOLChi2>olChi2Threshold) cutThisOne=true;
02435 
02436   if (cutThisOne){
02437     MAXMSG("CDAnalysis",Msg::kInfo,1)
02438       <<"Applying cut on overlap for elec, OLChi2<"<<olChi2Threshold
02439       <<endl;
02440   }
02441 
02442   return cutThisOne;
02443 }

Bool_t CDAnalysis::CutOnPid (  )  const [private]

Definition at line 2574 of file CDAnalysis.cxx.

References fInCERTime, fPIDType, fSimFlag, SimFlag::kData, Msg::kInfo, CalDetParticleType::kMuon, CalDetParticleType::kPion, and MAXMSG.

Referenced by MuonCalorimetry(), MuonNearFar(), MuonResponse(), MuonSampleCuts(), MuonScatter(), PrintPIDStats(), StoppingMuonCalibration(), Template2(), and ValidatePIDInfo().

02575 {
02576   //set default to not cut
02577   Bool_t cutThisOne=false;
02578 
02579   //only have pid for real data so return if not data
02580   if (fSimFlag!=SimFlag::kData) return false;
02581 
02582   Bool_t muonOrPion=fPIDType & (CalDetParticleType::kMuon |
02583                                 CalDetParticleType::kPion);
02584 
02585   if (!muonOrPion){ 
02586     cutThisOne=true;
02587   }
02588   if (!fInCERTime){ 
02589     cutThisOne=true;
02590   }
02591 
02592   if (cutThisOne){
02593     MAXMSG("CDAnalysis",Msg::kInfo,1)
02594       <<"Applying cut on pid to pass only pions and muons"<<endl;
02595   }
02596 
02597   return cutThisOne;
02598 }

Bool_t CDAnalysis::CutOnPidForElec (  )  const [private]

Definition at line 2447 of file CDAnalysis.cxx.

References fInCERTime, fPIDType, fSimFlag, SimFlag::kData, CalDetParticleType::kElectron, Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse(), PrintPIDStats(), and ValidatePIDInfo().

02448 {
02449   //set default to not cut
02450   Bool_t cutThisOne=false;
02451 
02452   //only have pid for real data so return if not data
02453   if (fSimFlag!=SimFlag::kData) return false;
02454 
02455   if (fPIDType!=CalDetParticleType::kElectron){ 
02456     cutThisOne=true;
02457   }
02458   if (!fInCERTime){ 
02459     cutThisOne=true;
02460   }
02461 
02462   if (cutThisOne){
02463     MAXMSG("CDAnalysis",Msg::kInfo,1)
02464       <<"Applying cut on pid to pass only electrons"<<endl;
02465   }
02466 
02467   return cutThisOne;
02468 }

Bool_t CDAnalysis::CutOnPSMuons (  )  const [private]

Definition at line 2962 of file CDAnalysis.cxx.

Referenced by StoppingMuonCalibration().

02963 {
02964   //set default to not cut
02965   Bool_t cutThisOne=false;
02966 
02967   if (fAvStrip<9|| fAvStrip>13){
02968     cutThisOne=true;
02969   }
02970 
02971   return cutThisOne;
02972 }

Bool_t CDAnalysis::CutOnScint_TofDiff (  )  const [private]

Definition at line 2793 of file CDAnalysis.cxx.

References fLowScint_Tof, fUpScint_Tof, GetLowUpTimeCuts(), Msg::kInfo, and MAXMSG.

Referenced by ElectronResponse(), and StoppingMuonCalibration().

02794 {
02795   //set default to not cut
02796   Bool_t cutThisOne=false;
02797 
02798   Float_t lowTime=-1000000;
02799   Float_t upTime=1000000;
02800   
02801   this->GetLowUpTimeCuts(lowTime,upTime);
02802   
02803   if (fLowScint_Tof<lowTime || fUpScint_Tof>upTime) cutThisOne=true;
02804 
02805   if (cutThisOne){
02806     MAXMSG("CDAnalysis",Msg::kInfo,10)
02807       <<"Using TOF-scint diff. cut: "
02808       <<lowTime<<" -> "<<upTime<<" ns"
02809       <<" (t="<<fLowScint_Tof<<" -> "<<fUpScint_Tof<<" ns)"
02810       <<endl;
02811   }
02812 
02813   return cutThisOne;
02814 }

Bool_t CDAnalysis::CutOnTrackQuality ( Bool_t  requireGoodTrack = true  )  const [private]

Definition at line 2371 of file CDAnalysis.cxx.

References fFirstPlane, Msg::kInfo, and MAXMSG.

Referenced by MuonCalorimetry(), MuonNearFar(), MuonResponse(), and StoppingMuonCalibration().

02372 {
02373   //set default to not cut
02374   Bool_t cutThisOne=false;
02375 
02376   //look if a good first plane was found
02377   //this is a good indication of tracking success
02378   Bool_t goodFirstPlane=(fFirstPlane>=0 && fFirstPlane<59);
02379   if (requireGoodTrack){
02380     if (!goodFirstPlane) cutThisOne=true;
02381   }
02382 
02383   //don't do this as not necessary for MEU calibration
02384   //cut on the trackers opinion of what's a good track
02385   //Bool_t goodInBothViews=(fResultEven==1 && fResultOdd==1);
02386   //if (requireGoodTrack){
02387   //  if (!goodInBothViews) cutThisOne=true;
02388   //}
02389 
02390   if (cutThisOne){
02391     MAXMSG("CDAnalysis",Msg::kInfo,1)
02392       <<"Applying cut to track quality"<<endl;
02393   }
02394 
02395   return cutThisOne;
02396 }

Double_t CDAnalysis::dE_dxIterative ( MuEnergyLoss mat,
Double_t  energyRemaining,
Double_t  totalThk,
Double_t  rho,
Double_t  energyCutOff,
Int_t  slices 
) const [private]

calculate energy deposited in material by iterating over small slices and calculating energy remaining at each stage

Definition at line 12210 of file CDAnalysis.cxx.

References MuEnergyLoss::dE_dx(), MuELoss::e, Process::eIonization, Msg::kInfo, and MSG.

12215 {
12218 
12219   Double_t totalEnergyDeposited=0;
12220   Double_t sliceThk=totalThk/slices;
12221 
12222   for (Int_t s=0;s<slices;s++){
12223 
12224     if (energyRemaining<energyCutOff){
12225       MSG("CDAnalysis",Msg::kInfo) 
12226         <<"All energy lost at slice "<<s+1<<"/"<<slices
12227         <<" ("<<100.*s*sliceThk/totalThk<<"% through material)"<<endl;
12228       return -1;
12229     }
12230 
12231     //calculate energy deposited in the slice
12232     //Double_t energyDeposited=mat.dE_dx(energyRemaining)*rho*sliceThk;
12233     double e=energyRemaining;
12234     Double_t energyDeposited=mat.dE_dx
12235       (e,Process::eIonization)*rho*sliceThk;
12236     totalEnergyDeposited+=energyDeposited;
12237 
12238     //increment the energy remaining
12239     energyRemaining-=energyDeposited;
12240   }
12241 
12242   return totalEnergyDeposited;
12243 }

void CDAnalysis::DrawResponsePlot ( std::string &  title,
TProfile *  prof,
TProfile *  profX,
TProfile *  profT,
const std::map< Int_t, Float_t > &  num,
const std::map< Int_t, Float_t > &  numX,
const std::map< Int_t, Float_t > &  numT,
std::string  sXTitle = "" 
) const [private]
void CDAnalysis::ElectronResponse (  ) 

Definition at line 11096 of file CDAnalysis.cxx.

References CalcFirstLastPlane(), CalcLowUpScint_TofDiff(), CalcNumPlanesHit(), CutOnBadCalorimetry(), CutOnBadPedestals(), CutOnDeadChips(), CutOnEventLengthForElec(), CutOnOverlapForElec(), CutOnPidForElec(), CutOnScint_TofDiff(), fChargeAdc, fChargeMip, fChargePe, fChargeSigCor, fEvents, fKovADC1, fKovADC2, fKovADC3, fKovTimeStamp1, fKovTimeStamp3, fNumPlanesHitAll, fOLChi2, fOutFile, fPlane, fRunNumber, fSigCorPerMEU, fStrip, fStripend, fTime, fTofADCTimeStamp1, fTofTDC0, fTofTDC2, fTrkHitInfo, fUnTrkHitInfo, fXTalkHits, InitialiseLoopVariables(), Msg::kDebug, Msg::kInfo, MAXMSG, MSG, OpenFile(), ReadInHitInfo(), ReCalibrate(), SetLoopVariables(), and StandardSanityChecks().

Referenced by StoppingMuonCalibration().

11097 {
11098   MSG("CDAnalysis",Msg::kInfo) 
11099     <<" ** Running ElectronResponse method... **"<<endl;
11100 
11101   //open the output file for the histograms if not already done
11102   if (!fOutFile) fOutFile=this->OpenFile(fRunNumber,"ElecRes");
11103 
11104   TH1F *hNumPlanesAll_Elec=new TH1F("hNumPlanesAll_Elec",
11105                                     "NumPlanesAll_Elec hit",77,-2,75);
11106   hNumPlanesAll_Elec->GetXaxis()->SetTitle("Number of Planes Hit");
11107   hNumPlanesAll_Elec->GetXaxis()->CenterTitle();
11108   hNumPlanesAll_Elec->GetYaxis()->SetTitle("");
11109   hNumPlanesAll_Elec->GetYaxis()->CenterTitle();
11110   hNumPlanesAll_Elec->SetFillColor(0);
11111   hNumPlanesAll_Elec->SetBit(TH1::kCanRebin);
11112 
11113   TH1F *hNumPlanesAllN_Elec=new TH1F("hNumPlanesAllN_Elec",
11114                                     "NumPlanesAllN_Elec hit",77,-2,75);
11115   hNumPlanesAllN_Elec->GetXaxis()->SetTitle("Number of Planes Hit");
11116   hNumPlanesAllN_Elec->GetXaxis()->CenterTitle();
11117   hNumPlanesAllN_Elec->GetYaxis()->SetTitle("");
11118   hNumPlanesAllN_Elec->GetYaxis()->CenterTitle();
11119   hNumPlanesAllN_Elec->SetFillColor(0);
11120   hNumPlanesAllN_Elec->SetBit(TH1::kCanRebin);
11121   
11122   TH1F *hSumSigCor_Elec=new TH1F("hSumSigCor_Elec","hSumSigCor_Elec",
11123                                  500,-2,100000);
11124   hSumSigCor_Elec->SetTitle("Sum of Corrected ADCs in Event");
11125   hSumSigCor_Elec->GetXaxis()->
11126     SetTitle("Sum of Corrected ADCs in Event");
11127   hSumSigCor_Elec->GetXaxis()->CenterTitle();
11128   hSumSigCor_Elec->GetYaxis()->SetTitle("");
11129   hSumSigCor_Elec->GetYaxis()->CenterTitle();
11130   hSumSigCor_Elec->SetFillColor(0);
11131   //hSumSigCor_Elec->SetBit(TH1::kCanRebin);
11132 
11133   TH1F *hSumMeu_Elec=new TH1F("hSumMeu_Elec","hSumMeu_Elec",500,-2,400);
11134   hSumMeu_Elec->SetTitle("Sum of MEUs in Event");
11135   hSumMeu_Elec->GetXaxis()->SetTitle("Sum of MEUs in Event");
11136   hSumMeu_Elec->GetXaxis()->CenterTitle();
11137   hSumMeu_Elec->GetYaxis()->SetTitle("");
11138   hSumMeu_Elec->GetYaxis()->CenterTitle();
11139   hSumMeu_Elec->SetFillColor(0);
11140   //hSumMeu_Elec->SetBit(TH1::kCanRebin);
11141 
11142   TH1F *hSumMip_Elec=new TH1F("hSumMip_Elec","hSumMip_Elec",500,-2,400);
11143   hSumMip_Elec->SetTitle("Sum of Cosmic-MIPs in Event");
11144   hSumMip_Elec->GetXaxis()->SetTitle("Sum of Cosmic-MIPs in Event");
11145   hSumMip_Elec->GetXaxis()->CenterTitle();
11146   hSumMip_Elec->GetYaxis()->SetTitle("");
11147   hSumMip_Elec->GetYaxis()->CenterTitle();
11148   hSumMip_Elec->SetFillColor(0);
11149   //hSumMip_Elec->SetBit(TH1::kCanRebin);
11150 
11151   TH1F *hSigCor_Elec=new TH1F("hSigCor_Elec","hSigCor_Elec",
11152                               5000,-2,10000);
11153   hSigCor_Elec->SetTitle("Corrected ADCs");
11154   hSigCor_Elec->GetXaxis()->SetTitle("Corrected ADCs");
11155   hSigCor_Elec->GetXaxis()->CenterTitle();
11156   hSigCor_Elec->GetYaxis()->SetTitle("");
11157   hSigCor_Elec->GetYaxis()->CenterTitle();
11158   hSigCor_Elec->SetFillColor(0);
11159   hSigCor_Elec->SetBit(TH1::kCanRebin);
11160 
11161   TH1F *hOLChi2_Elec=new TH1F("hOLChi2_Elec","hOLChi2_Elec",
11162                                200,0,10);
11163   hOLChi2_Elec->GetXaxis()->SetTitle("OLChi2");
11164   hOLChi2_Elec->GetXaxis()->CenterTitle();
11165   hOLChi2_Elec->GetYaxis()->SetTitle("");
11166   hOLChi2_Elec->GetYaxis()->CenterTitle();
11167   hOLChi2_Elec->SetFillColor(0);
11168   hOLChi2_Elec->SetLineWidth(3);
11169   //hOLChi2_Elec->SetBit(TH1::kCanRebin);
11170   
11171   TH1F *hOLChi2_ElecN_1=new TH1F("hOLChi2_ElecN_1","hOLChi2_ElecN_1",
11172                                200,0,10);
11173   hOLChi2_ElecN_1->GetXaxis()->SetTitle("OLChi2");
11174   hOLChi2_ElecN_1->GetXaxis()->CenterTitle();
11175   hOLChi2_ElecN_1->GetYaxis()->SetTitle("");
11176   hOLChi2_ElecN_1->GetYaxis()->CenterTitle();
11177   hOLChi2_ElecN_1->SetFillColor(0);
11178   hOLChi2_ElecN_1->SetLineWidth(3);
11179   hOLChi2_ElecN_1->SetLineColor(2);
11180   //hOLChi2_ElecN_1->SetBit(TH1::kCanRebin);
11181 
11182   TH1F *hOLChi2_ElecN=new TH1F("hOLChi2_ElecN","hOLChi2_ElecN",
11183                                200,0,10);
11184   hOLChi2_ElecN->GetXaxis()->SetTitle("OLChi2");
11185   hOLChi2_ElecN->GetXaxis()->CenterTitle();
11186   hOLChi2_ElecN->GetYaxis()->SetTitle("");
11187   hOLChi2_ElecN->GetYaxis()->CenterTitle();
11188   hOLChi2_ElecN->SetFillColor(0);
11189   hOLChi2_ElecN->SetLineWidth(3);
11190   hOLChi2_ElecN->SetLineColor(4);
11191   //hOLChi2_ElecN->SetBit(TH1::kCanRebin);
11192 
11193   TH1F *hKovADC1_Elec=new TH1F("hKovADC1_Elec","KovADC1_Elec",
11194                                400,-5,10000);
11195   hKovADC1_Elec->GetXaxis()->SetTitle("KovADC1");
11196   hKovADC1_Elec->GetXaxis()->CenterTitle();
11197   hKovADC1_Elec->GetYaxis()->SetTitle("");
11198   hKovADC1_Elec->GetYaxis()->CenterTitle();
11199   hKovADC1_Elec->SetFillColor(0);
11200   hKovADC1_Elec->SetBit(TH1::kCanRebin);
11201 
11202   TH1F *hKovADC1_ElecN_1=new TH1F("hKovADC1_ElecN_1","KovADC1_ElecN_1",
11203                                 400,-5,10000);
11204   hKovADC1_ElecN_1->GetXaxis()->SetTitle("KovADC1");
11205   hKovADC1_ElecN_1->GetXaxis()->CenterTitle();
11206   hKovADC1_ElecN_1->GetYaxis()->SetTitle("");
11207   hKovADC1_ElecN_1->GetYaxis()->CenterTitle();
11208   hKovADC1_ElecN_1->SetFillColor(0);
11209   hKovADC1_ElecN_1->SetLineColor(2);
11210   hKovADC1_ElecN_1->SetBit(TH1::kCanRebin);
11211 
11212   TH1F *hKovADC1_ElecN=new TH1F("hKovADC1_ElecN","KovADC1_ElecN",
11213                                 400,-5,10000);
11214   hKovADC1_ElecN->GetXaxis()->SetTitle("KovADC1");
11215   hKovADC1_ElecN->GetXaxis()->CenterTitle();
11216   hKovADC1_ElecN->GetYaxis()->SetTitle("");
11217   hKovADC1_ElecN->GetYaxis()->CenterTitle();
11218   hKovADC1_ElecN->SetFillColor(0);
11219   hKovADC1_ElecN->SetLineColor(4);
11220   hKovADC1_ElecN->SetBit(TH1::kCanRebin);
11221 
11222   TH1F *hKovADC2_Elec=new TH1F("hKovADC2_Elec","KovADC2_Elec",
11223                                400,-5,10000);
11224   hKovADC2_Elec->GetXaxis()->SetTitle("KovADC2");
11225   hKovADC2_Elec->GetXaxis()->CenterTitle();
11226   hKovADC2_Elec->GetYaxis()->SetTitle("");
11227   hKovADC2_Elec->GetYaxis()->CenterTitle();
11228   hKovADC2_Elec->SetFillColor(0);
11229   hKovADC2_Elec->SetBit(TH1::kCanRebin);
11230 
11231   TH1F *hKovADC2_ElecN_1=new TH1F("hKovADC2_ElecN_1","KovADC2_ElecN_1",
11232                                 400,-5,10000);
11233   hKovADC2_ElecN_1->GetXaxis()->SetTitle("KovADC2");
11234   hKovADC2_ElecN_1->GetXaxis()->CenterTitle();
11235   hKovADC2_ElecN_1->GetYaxis()->SetTitle("");
11236   hKovADC2_ElecN_1->GetYaxis()->CenterTitle();
11237   hKovADC2_ElecN_1->SetFillColor(0);
11238   hKovADC2_ElecN_1->SetLineColor(2);
11239   hKovADC2_ElecN_1->SetBit(TH1::kCanRebin);
11240 
11241   TH1F *hKovADC2_ElecN=new TH1F("hKovADC2_ElecN","KovADC2_ElecN",
11242                                 400,-5,10000);
11243   hKovADC2_ElecN->GetXaxis()->SetTitle("KovADC2");
11244   hKovADC2_ElecN->GetXaxis()->CenterTitle();
11245   hKovADC2_ElecN->GetYaxis()->SetTitle("");
11246   hKovADC2_ElecN->GetYaxis()->CenterTitle();
11247   hKovADC2_ElecN->SetFillColor(0);
11248   hKovADC2_ElecN->SetLineColor(4);
11249   hKovADC2_ElecN->SetBit(TH1::kCanRebin);
11250 
11251   TH1F *hKovADC3_Elec=new TH1F("hKovADC3_Elec","KovADC3_Elec",
11252                                400,-5,10000);
11253   hKovADC3_Elec->GetXaxis()->SetTitle("KovADC3");
11254   hKovADC3_Elec->GetXaxis()->CenterTitle();
11255   hKovADC3_Elec->GetYaxis()->SetTitle("");
11256   hKovADC3_Elec->GetYaxis()->CenterTitle();
11257   hKovADC3_Elec->SetFillColor(0);
11258   hKovADC3_Elec->SetBit(TH1::kCanRebin);
11259 
11260   TH1F *hKovADC3_ElecN_1=new TH1F("hKovADC3_ElecN_1","KovADC3_ElecN_1",
11261                                 400,-5,10000);
11262   hKovADC3_ElecN_1->GetXaxis()->SetTitle("KovADC3");
11263   hKovADC3_ElecN_1->GetXaxis()->CenterTitle();
11264   hKovADC3_ElecN_1->GetYaxis()->SetTitle("");
11265   hKovADC3_ElecN_1->GetYaxis()->CenterTitle();
11266   hKovADC3_ElecN_1->SetFillColor(0);
11267   hKovADC3_ElecN_1->SetLineColor(2);
11268   hKovADC3_ElecN_1->SetBit(TH1::kCanRebin);
11269 
11270   TH1F *hKovADC3_ElecN=new TH1F("hKovADC3_ElecN","KovADC3_ElecN",
11271                                 400,-5,10000);
11272   hKovADC3_ElecN->GetXaxis()->SetTitle("KovADC3");
11273   hKovADC3_ElecN->GetXaxis()->CenterTitle();
11274   hKovADC3_ElecN->GetYaxis()->SetTitle("");
11275   hKovADC3_ElecN->GetYaxis()->CenterTitle();
11276   hKovADC3_ElecN->SetFillColor(0);
11277   hKovADC3_ElecN->SetLineColor(4);
11278   hKovADC3_ElecN->SetBit(TH1::kCanRebin);
11279 
11280   TH1F *hTofDiff_Elec=new TH1F("hTofDiff_Elec","hTofDiff_Elec",
11281                                400,-4000,4000);
11282   hTofDiff_Elec->GetXaxis()->SetTitle("TOF");
11283   hTofDiff_Elec->GetXaxis()->CenterTitle();
11284   hTofDiff_Elec->GetYaxis()->SetTitle("");
11285   hTofDiff_Elec->GetYaxis()->CenterTitle();
11286   hTofDiff_Elec->SetFillColor(0);
11287   hTofDiff_Elec->SetBit(TH1::kCanRebin);
11288 
11289   TH1F *hTofDiff_ElecN_1=new TH1F("hTofDiff_ElecN_1","hTofDiff_ElecN_1",
11290                                 400,-4000,4000);
11291   hTofDiff_ElecN_1->GetXaxis()->SetTitle("TOF");
11292   hTofDiff_ElecN_1->GetXaxis()->CenterTitle();
11293   hTofDiff_ElecN_1->GetYaxis()->SetTitle("");
11294   hTofDiff_ElecN_1->GetYaxis()->CenterTitle();
11295   hTofDiff_ElecN_1->SetFillColor(0);
11296   hTofDiff_ElecN_1->SetLineColor(2);
11297   hTofDiff_ElecN_1->SetBit(TH1::kCanRebin);
11298 
11299   TH1F *hTofDiff_ElecN=new TH1F("hTofDiff_ElecN","hTofDiff_ElecN",
11300                                 400,-4000,4000);
11301   hTofDiff_ElecN->GetXaxis()->SetTitle("TOF");
11302   hTofDiff_ElecN->GetXaxis()->CenterTitle();
11303   hTofDiff_ElecN->GetYaxis()->SetTitle("");
11304   hTofDiff_ElecN->GetYaxis()->CenterTitle();
11305   hTofDiff_ElecN->SetFillColor(0);
11306   hTofDiff_ElecN->SetLineColor(4);
11307   hTofDiff_ElecN->SetBit(TH1::kCanRebin);
11308 
11309   TH1F *hTofKov1Diff_Elec=new TH1F("hTofKov1Diff_Elec",
11310                                    "hTofKov1Diff_Elec",4000,-2,3);
11311   hTofKov1Diff_Elec->GetXaxis()->SetTitle("Tof-Ckv time");
11312   hTofKov1Diff_Elec->GetXaxis()->CenterTitle();
11313   hTofKov1Diff_Elec->GetYaxis()->SetTitle("");
11314   hTofKov1Diff_Elec->GetYaxis()->CenterTitle();
11315   hTofKov1Diff_Elec->SetFillColor(0);
11316   hTofKov1Diff_Elec->SetBit(TH1::kCanRebin);
11317 
11318   TH1F *hTofKov1DiffN_1_Elec=new TH1F("hTofKov1DiffN_1_Elec",
11319                                    "hTofKov1DiffN_1_Elec",4000,-2,3);
11320   hTofKov1DiffN_1_Elec->GetXaxis()->SetTitle("Tof-Ckv time");
11321   hTofKov1DiffN_1_Elec->GetXaxis()->CenterTitle();
11322   hTofKov1DiffN_1_Elec->GetYaxis()->SetTitle("");
11323   hTofKov1DiffN_1_Elec->GetYaxis()->CenterTitle();
11324   hTofKov1DiffN_1_Elec->SetFillColor(0);
11325   hTofKov1DiffN_1_Elec->SetBit(TH1::kCanRebin);
11326 
11327   TH1F *hTofKov1DiffN_Elec=new TH1F("hTofKov1DiffN_Elec",
11328                                    "hTofKov1DiffN_Elec",4000,-2,3);
11329   hTofKov1DiffN_Elec->GetXaxis()->SetTitle("Tof-Ckv time");
11330   hTofKov1DiffN_Elec->GetXaxis()->CenterTitle();
11331   hTofKov1DiffN_Elec->GetYaxis()->SetTitle("");
11332   hTofKov1DiffN_Elec->GetYaxis()->CenterTitle();
11333   hTofKov1DiffN_Elec->SetFillColor(0);
11334   hTofKov1DiffN_Elec->SetBit(TH1::kCanRebin);
11335 
11336   TH1F *hTofKov3Diff_Elec=new TH1F("hTofKov3Diff_Elec",
11337                                    "hTofKov3Diff_Elec",4000,-2,3);
11338   hTofKov3Diff_Elec->GetXaxis()->SetTitle("Tof - Ckv time");
11339   hTofKov3Diff_Elec->GetXaxis()->CenterTitle();
11340   hTofKov3Diff_Elec->GetYaxis()->SetTitle("");
11341   hTofKov3Diff_Elec->GetYaxis()->CenterTitle();
11342   hTofKov3Diff_Elec->SetFillColor(0);
11343   hTofKov3Diff_Elec->SetBit(TH1::kCanRebin);
11344 
11345   TH1F *hTofKov3DiffN_1_Elec=new TH1F("hTofKov3DiffN_1_Elec",
11346                                    "hTofKov3DiffN_1_Elec",4000,-2,3);
11347   hTofKov3DiffN_1_Elec->GetXaxis()->SetTitle("Tof - Ckv time");
11348   hTofKov3DiffN_1_Elec->GetXaxis()->CenterTitle();
11349   hTofKov3DiffN_1_Elec->GetYaxis()->SetTitle("");
11350   hTofKov3DiffN_1_Elec->GetYaxis()->CenterTitle();
11351   hTofKov3DiffN_1_Elec->SetFillColor(0);
11352   hTofKov3DiffN_1_Elec->SetBit(TH1::kCanRebin);
11353 
11354   TH1F *hTofKov3DiffN_Elec=new TH1F("hTofKov3DiffN_Elec",
11355                                    "hTofKov3DiffN_Elec",4000,-2,3);
11356   hTofKov3DiffN_Elec->GetXaxis()->SetTitle("Tof - Ckv time");
11357   hTofKov3DiffN_Elec->GetXaxis()->CenterTitle();
11358   hTofKov3DiffN_Elec->GetYaxis()->SetTitle("");
11359   hTofKov3DiffN_Elec->GetYaxis()->CenterTitle();
11360   hTofKov3DiffN_Elec->SetFillColor(0);
11361   hTofKov3DiffN_Elec->SetBit(TH1::kCanRebin);
11362 
11366   
11367   this->InitialiseLoopVariables();  
11368   
11369   for(Int_t event=0;event<fEvents;event++){
11370     
11371     this->SetLoopVariables(event);
11372 
11373     //do this cut before everything
11374     if (this->CutOnDeadChips()) continue;
11375     //don't cut on pid here anymore
11376 
11377     //fill histos before any cuts
11378     hOLChi2_Elec->Fill(fOLChi2);
11379     hKovADC1_Elec->Fill(fKovADC1);
11380     hKovADC2_Elec->Fill(fKovADC2);
11381     hKovADC3_Elec->Fill(fKovADC3);
11382     hTofDiff_Elec->Fill(fTofTDC2-fTofTDC0); 
11383     hTofKov1Diff_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp1);
11384     hTofKov3Diff_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp3);
11385  
11386     Double_t sumSigCor=0;
11387     Double_t sumMip=0;
11388 
11389     //get tclones arrays for this snarl
11390     TClonesArray &cTrk=*fTrkHitInfo;
11391     Int_t numTrkHits=fTrkHitInfo->GetEntries();
11392     TClonesArray &cUnTrk = *fUnTrkHitInfo;
11393     Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
11394     TClonesArray &cXTalk = *fXTalkHits;
11395     Int_t numXTalkHits=fXTalkHits->GetEntries();
11396 
11398     //loop over the untracked hits in the snarl
11400     for (Int_t hit=0;hit<numUnTrkHits;hit++){
11401       //cast the tclonesarray up to a trackedhitinfo object
11402       CDTrackedHitInfo *hitInfo=
11403         dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
11404 
11405       this->ReadInHitInfo(hitInfo);
11406 
11407       //cut out the bad channels
11408       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
11409 
11410       //check the channel's sanity
11411       this->StandardSanityChecks();
11412       
11413       //calc the scint hits time difference compared to tof
11414       this->CalcLowUpScint_TofDiff(fTime);
11415 
11416       //calculate the first and last planes
11417       this->CalcFirstLastPlane(fPlane);
11418       this->CalcNumPlanesHit(fPlane,fChargePe);
11419 
11420       //cut out the channels not to be used in calorimetry
11421       if (this->CutOnBadCalorimetry(fPlane,fStrip,fStripend)) continue;
11422 
11423       //do the calibration again with latest tables, temperatures,etc
11424       fChargeSigCor=this->ReCalibrate(fChargeAdc,
11425                                       fPlane,fStrip,fStripend);
11426 
11427       sumSigCor+=fChargeSigCor;
11428       sumMip+=fChargeMip;
11429       hSigCor_Elec->Fill(fChargeSigCor);
11430     }
11431 
11433     //loop over xtalk hits in the snarl
11435     for (Int_t hit=0;hit<numXTalkHits;hit++){
11436       CDXTalkHitInfo *hitInfo=
11437         dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
11438 
11439       this->ReadInHitInfo(hitInfo);
11440       
11441       //cut out the bad channels
11442       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
11443 
11444       //check the channel's sanity
11445       this->StandardSanityChecks();
11446 
11447       //calc the scint hits time difference compared to tof
11448       this->CalcLowUpScint_TofDiff(fTime);
11449 
11450       //calculate the first and last planes
11451       this->CalcFirstLastPlane(fPlane);
11452       this->CalcNumPlanesHit(fPlane,fChargePe);
11453 
11454       //cut out the channels not to be used in calorimetry
11455       if (this->CutOnBadCalorimetry(fPlane,fStrip,fStripend)) continue;
11456 
11457       //do the calibration again with latest tables, temperatures,etc
11458       fChargeSigCor=this->ReCalibrate(fChargeAdc,
11459                                       fPlane,fStrip,fStripend);
11460 
11461       sumSigCor+=fChargeSigCor;
11462       sumMip+=fChargeMip;
11463       hSigCor_Elec->Fill(fChargeSigCor);
11464     }
11465 
11467     //loop over the tracked hits
11469     for (Int_t hit=0;hit<numTrkHits;hit++){
11470       CDTrackedHitInfo *trackedHitInfo=
11471         dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
11472           
11473       this->ReadInHitInfo(trackedHitInfo);
11474 
11475       //cut out the bad channels
11476       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
11477 
11478       //check the channel's sanity
11479       this->StandardSanityChecks();
11480 
11481       //calc the scint hits time difference compared to tof
11482       this->CalcLowUpScint_TofDiff(fTime);
11483 
11484       //calculate the first and last planes
11485       this->CalcFirstLastPlane(fPlane);
11486       this->CalcNumPlanesHit(fPlane,fChargePe);
11487 
11488       //cut out the channels not to be used in calorimetry
11489       if (this->CutOnBadCalorimetry(fPlane,fStrip,fStripend)) continue;
11490 
11491       //do the calibration again with latest tables, temperatures,etc
11492       fChargeSigCor=this->ReCalibrate(fChargeAdc,
11493                                       fPlane,fStrip,fStripend);
11494 
11495       sumSigCor+=fChargeSigCor;
11496       sumMip+=fChargeMip;
11497       hSigCor_Elec->Fill(fChargeSigCor);
11498     }
11500     //end of loop over the tracked hits
11502 
11503     //fill histos for all data
11504     hNumPlanesAll_Elec->Fill(fNumPlanesHitAll.size());
11505 
11506     if (!this->CutOnPidForElec() &&
11507         !this->CutOnEventLengthForElec() && 
11508         !this->CutOnScint_TofDiff()){
11509       hOLChi2_ElecN_1->Fill(fOLChi2);
11510     }
11511 
11512     if (!this->CutOnEventLengthForElec() && 
11513         !this->CutOnOverlapForElec() &&
11514         !this->CutOnScint_TofDiff()){
11515       hKovADC1_ElecN_1->Fill(fKovADC1);
11516       hKovADC2_ElecN_1->Fill(fKovADC2);
11517       hKovADC3_ElecN_1->Fill(fKovADC3);
11518       hTofDiff_ElecN_1->Fill(fTofTDC2-fTofTDC0); 
11519       hTofKov1DiffN_1_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp1);
11520       hTofKov3DiffN_1_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp3);
11521     }
11522 
11523     //::elec cuts 
11524     //cut on pid for electrons
11525     if (this->CutOnPidForElec()) continue;
11526     //make event length cuts
11527     if (this->CutOnEventLengthForElec()) continue;
11528     //make overlap cut
11529     if (this->CutOnOverlapForElec()) continue;
11530     //cut on the time difference between scint hits and tof hit
11531     if (this->CutOnScint_TofDiff()) continue;
11532     
11533     //fill pid histos
11534     hOLChi2_ElecN->Fill(fOLChi2);
11535     hKovADC1_ElecN->Fill(fKovADC1);
11536     hKovADC2_ElecN->Fill(fKovADC2);
11537     hKovADC3_ElecN->Fill(fKovADC3);
11538     hTofDiff_ElecN->Fill(fTofTDC2-fTofTDC0); 
11539     hTofKov1DiffN_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp1);
11540     hTofKov3DiffN_Elec->Fill(fTofADCTimeStamp1-fKovTimeStamp3);
11541 
11542     //fill histo after cuts
11543     hNumPlanesAllN_Elec->Fill(fNumPlanesHitAll.size());
11544     
11545     MAXMSG("CDAnalysis",Msg::kDebug,10)
11546       <<"Event passing plane cuts="<<event<<endl;
11547 
11548     //fill when one-sided (near-only) readout in a sensible way
11549     if (fRunNumber>=100000) hSumMip_Elec->Fill(sumMip);
11550     if (fRunNumber<100000) hSumMip_Elec->Fill(sumMip/2);
11551 
11552     hSumSigCor_Elec->Fill(sumSigCor);
11553     hSumMeu_Elec->Fill(sumSigCor/fSigCorPerMEU);
11554 
11555   }//end of for                                       
11556   
11560 
11561   MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
11562 
11563   //turn off the stats box printing
11564   //gStyle->SetOptStat(0);
11565   gStyle->SetOptStat(1111111);
11566 
11567   TCanvas *cGeom_Elec=new TCanvas("cGeom_Elec","cGeom_Elec",
11568                                   0,0,1200,800);
11569   cGeom_Elec->SetFillColor(0);
11570   //cGeom_Elec->Divide(2,3);
11571   cGeom_Elec->cd(1);
11572   hNumPlanesAll_Elec->Draw();
11573   hNumPlanesAllN_Elec->SetLineColor(2);
11574   hNumPlanesAllN_Elec->Draw("sames");
11575 
11576   TCanvas *cEnDep_Elec=new TCanvas("cEnDep_Elec","cEnDep_Elec",
11577                                    0,0,1200,800);
11578   cEnDep_Elec->SetFillColor(0);
11579   cEnDep_Elec->Divide(2,3);
11580   cEnDep_Elec->cd(1);
11581   hSigCor_Elec->Draw();
11582   cEnDep_Elec->cd(2);
11583   hSumSigCor_Elec->Draw();
11584   cEnDep_Elec->cd(3);
11585   hSumMeu_Elec->Draw();
11586   cEnDep_Elec->cd(4);
11587   hSumMip_Elec->Draw();
11588 
11589   MSG("CDAnalysis",Msg::kInfo) 
11590     <<" ** Finished ElectronResponse method **"<<endl;
11591 }

void CDAnalysis::FillEnVsDist ( std::map< Int_t, Float_t >  plEnDep,
std::map< Int_t, Float_t >  plPLCor,
Int_t  event 
) const [private]

Definition at line 3949 of file CDAnalysis.cxx.

References CalcLastPlaneOnTrkNoXTalk(), Munits::cm, Form(), Msg::kInfo, Msg::kWarning, MAXMSG, MSG, TrueEnDep(), and TruePLCor().

Referenced by StoppingMuonCalibration().

03952 {
03953   if (plEnDep.size()==0 || plPLCor.size()==0){
03954     MAXMSG("CDAnalysis",Msg::kWarning,10000)
03955       <<"Can't FillEnVsDist, map has size zero"<<endl;
03956     return;
03957   }
03958 
03959   Float_t materialFromTrkEnd=0;
03960   Float_t trueMaterialFromTrkEnd=0;
03961   Int_t planesFromTrkEnd=0;
03962   const Float_t material01Pl=(5.94)*Munits::cm;//including air gap
03963   Float_t initValue=-999;
03964   
03965   
03966   //static Int_t event=-999;
03967   map<Int_t,Float_t> truePLCor;
03968   this->TruePLCor(truePLCor,event);
03969   //event++;
03970 
03971   static TProfile* pEnVsDist=0;
03972   static TProfile* pEnVsDistAll=0;
03973   static TProfile* pEnVsDistAll2=0;
03974   static TProfile* pEnVsDist0=0;
03975   static TProfile* pTrueEnVsDist0=0;
03976   static TProfile* pTrueEnPLCVsDist0=0;
03977   static TProfile* pTrueEnPLCVsDist0270=0;
03978   static TProfile* pTrueEnPLCVsDist0290=0;
03979   static TProfile* pTrueEnPLCVsDist0310=0;
03980   static TProfile* pEnVsPlane0=0;
03981   static TProfile* pTrueEnVsPlane0=0;
03982   static TProfile* pEnVsDistNoEnd=0;
03983   static TProfile* pEnVsDistNoEnd4951=0;
03984   static TProfile* pEnVsDistNoEnd40=0;
03985   static TProfile* pEnVsDistNoEnd250=0;
03986   static TProfile* pEnVsDistNoEnd270=0;
03987   static TProfile* pEnVsDistNoEnd290=0;
03988   static TProfile* pEnVsDistNoEnd290a=0;
03989   static TProfile* pEnVsDistNoEnd290b=0;
03990   static TProfile* pEnVsDistNoEnd310=0;
03991   static TProfile* pEnVsDistNoEndTrue=0;
03992   static TProfile* pEnVsDistNoEndTrue2=0;
03993   static TProfile* pPLCorVsPlane290=0;
03994   static TProfile* pPLCorVsPlaneTrue=0;
03995   static TH1F* hMatFromTrkEnd=0;
03996   static TH1F* hMatFromTrkEndTrue=0;
03997   static TH1F* hSigCorPLC=0;
03998 
03999   static vector<TH1F*> meuSigCorNoPLCorHistos(60);
04000   static vector<TH1F*> meuSigCorPLCorHistos(60);
04001   static vector<TH1F*> meuSigCorNoPLCorPerpHistos(60);
04002   static vector<TH1F*> meuSigCorPLCorPerpHistos(60);
04003   static vector<TH1F*> meuSigCorNoPLCorZerosHistos(60);
04004   static vector<TH1F*> meuSigCorPLCorZerosHistos(60);
04005 
04006   if (pEnVsDist==0) {
04007     pEnVsDist=new TProfile("pEnVsDist","pEnVsDist",60,0,
04008                            (60*material01Pl)/Munits::cm);
04009     pEnVsDistAll=new TProfile("pEnVsDistAll","pEnVsDistAll",60,0,
04010                               (60*material01Pl)/Munits::cm);
04011     pEnVsDistAll2=new TProfile("pEnVsDistAll2","pEnVsDistAll2",60,0,
04012                                (60*material01Pl)/Munits::cm);
04013     pEnVsDistNoEnd=new TProfile("pEnVsDistNoEnd","pEnVsDistNoEnd",60,0,
04014                                 (60*material01Pl)/Munits::cm);
04015     pEnVsDist0=new TProfile("pEnVsDist0","pEnVsDist0",60,0,
04016                             (60*material01Pl)/Munits::cm);
04017     pEnVsPlane0=new TProfile("pEnVsPlane0","pEnVsPlane0",60,0,60);
04018     pTrueEnVsDist0=new TProfile("pTrueEnVsDist0","pTrueEnVsDist0",60,0,
04019                                 (60*material01Pl)/Munits::cm);
04020     pTrueEnPLCVsDist0=new TProfile("pTrueEnPLCVsDist0",
04021                                    "pTrueEnPLCVsDist0",
04022                                    60,0,(60*material01Pl)/Munits::cm);
04023     pTrueEnPLCVsDist0270=new TProfile("pTrueEnPLCVsDist0270",
04024                                    "pTrueEnPLCVsDist0270",
04025                                    60,0,(60*material01Pl)/Munits::cm);
04026     pTrueEnPLCVsDist0290=new TProfile("pTrueEnPLCVsDist0290",
04027                                    "pTrueEnPLCVsDist0290",
04028                                    60,0,(60*material01Pl)/Munits::cm);
04029     pTrueEnPLCVsDist0310=new TProfile("pTrueEnPLCVsDist0310",
04030                                    "pTrueEnPLCVsDist0310",
04031                                    60,0,(60*material01Pl)/Munits::cm);
04032     pTrueEnVsPlane0=new TProfile("pTrueEnVsPlane0","pTrueEnVsPlane0",
04033                                  60,0,60);
04034     pEnVsDistNoEnd4951=new TProfile("pEnVsDistNoEnd4951",
04035                                     "pEnVsDistNoEnd4951",60,0,
04036                                     (60*material01Pl)/Munits::cm);
04037     pEnVsDistNoEnd40=new TProfile("pEnVsDistNoEnd40",
04038                                   "pEnVsDistNoEnd40",60,0,
04039                                   (60*material01Pl)/Munits::cm);
04040     pEnVsDistNoEnd250=new TProfile("pEnVsDistNoEnd250",
04041                                    "pEnVsDistNoEnd250",60,0,
04042                                    (60*material01Pl)/Munits::cm);
04043     pEnVsDistNoEnd270=new TProfile("pEnVsDistNoEnd270",
04044                                    "pEnVsDistNoEnd270",60,0,
04045                                    (60*material01Pl)/Munits::cm);
04046     pEnVsDistNoEnd290=new TProfile("pEnVsDistNoEnd290",
04047                                    "pEnVsDistNoEnd290",60,0,
04048                                    (60*material01Pl)/Munits::cm);
04049     pEnVsDistNoEnd290a=new TProfile("pEnVsDistNoEnd290a",
04050                                    "pEnVsDistNoEnd290a",60,0,
04051                                   (60*material01Pl)/Munits::cm);
04052     pEnVsDistNoEnd290b=new TProfile("pEnVsDistNoEnd290b",
04053                                    "pEnVsDistNoEnd290b",60,0,
04054                                   (60*material01Pl)/Munits::cm);
04055     pEnVsDistNoEnd310=new TProfile("pEnVsDistNoEnd310",
04056                                    "pEnVsDistNoEnd310",60,0,
04057                                    (60*material01Pl)/Munits::cm);
04058     pEnVsDistNoEndTrue=new TProfile("pEnVsDistNoEndTrue",
04059                                     "pEnVsDistNoEndTrue",60,0,
04060                                     (60*material01Pl)/Munits::cm);
04061     pEnVsDistNoEndTrue2=new TProfile("pEnVsDistNoEndTrue2",
04062                                      "pEnVsDistNoEndTrue2",60,0,
04063                                      (60*material01Pl)/Munits::cm);
04064     hMatFromTrkEnd=new TH1F("hMatFromTrkEnd","hMatFromTrkEnd",200,0,4);
04065     hMatFromTrkEndTrue=new TH1F("hMatFromTrkEndTrue",
04066                                 "hMatFromTrkEndTrue",200,0,4);
04067     hSigCorPLC=new TH1F("hSigCorPLC","hSigCorPLC",5000,-100,20000);
04068     pPLCorVsPlane290=new TProfile("pPLCorVsPlane290",
04069                                   "pPLCorVsPlane290",60,0,60);
04070     pPLCorVsPlaneTrue=new TProfile("pPLCorVsPlaneTrue",
04071                                    "pPLCorVsPlaneTrue",60,0,60);
04072 
04073     for (Int_t i=0;i<60;i++){
04074       string sNameSigCorNoPLCor="hMeuSigCorNoPLCorPlane";
04075       string sNameSigCorPLCor="hMeuSigCorPLCorPlane";
04076       string sNameSigCorNoPLCorPerp="hMeuSigCorNoPLCorPerpPlane";
04077       string sNameSigCorPLCorPerp="hMeuSigCorPLCorPerpPlane";
04078       string sNameSigCorNoPLCorZeros="hMeuSigCorNoPLCorZerosPlane";
04079       string sNameSigCorPLCorZeros="hMeuSigCorPLCorZerosPlane";
04080       //string sNameAdc="hAdcNoPLCorPlane";
04081       string sNum=Form("%d",i);
04082       sNameSigCorNoPLCor+=sNum;
04083       sNameSigCorPLCor+=sNum;
04084       sNameSigCorNoPLCorPerp+=sNum;
04085       sNameSigCorPLCorPerp+=sNum;
04086       sNameSigCorNoPLCorZeros+=sNum;
04087       sNameSigCorPLCorZeros+=sNum;
04088       
04089       meuSigCorNoPLCorHistos[i]=new TH1F
04090         (sNameSigCorNoPLCor.c_str(),sNameSigCorNoPLCor.c_str(),
04091          300,-2,3000);
04092       meuSigCorPLCorHistos[i]=new TH1F
04093         (sNameSigCorPLCor.c_str(),sNameSigCorPLCor.c_str(),
04094          300,-2,3000);
04095 
04096       meuSigCorNoPLCorPerpHistos[i]=new TH1F
04097         (sNameSigCorNoPLCorPerp.c_str(),sNameSigCorNoPLCorPerp.c_str(),
04098          300,-2,3000);
04099       meuSigCorPLCorPerpHistos[i]=new TH1F
04100         (sNameSigCorPLCorPerp.c_str(),sNameSigCorPLCorPerp.c_str(),
04101          300,-2,3000);
04102       
04103       meuSigCorNoPLCorZerosHistos[i]=new TH1F
04104         (sNameSigCorNoPLCorZeros.c_str(),
04105          sNameSigCorNoPLCorZeros.c_str(),
04106          300,-2,3000);
04107       meuSigCorPLCorZerosHistos[i]=new TH1F
04108         (sNameSigCorPLCorZeros.c_str(),
04109          sNameSigCorPLCorZeros.c_str(),
04110          300,-2,3000);
04111     }
04112 
04113     MSG("CDAnalysis",Msg::kInfo)
04114       <<"Creating TProfile, pEnVsDist, max bin="
04115       <<(60*material01Pl)/Munits::cm<<endl;
04116   }
04117 
04118   //Int_t endPlane=this->GetEventLength();
04119   Int_t endPlane=this->CalcLastPlaneOnTrkNoXTalk();
04120   Int_t planeToStopBefore=0;//have to change length cuts too!!!
04121 
04122   //calculate energy deposition in the window
04123   if (endPlane>=0){
04124     MAXMSG("CDAnalysis",Msg::kInfo,100)
04125       <<"Filling histo, vtxPl=0"
04126       <<", endPl="<<endPlane<<endl;
04127     
04129     //loop over the track
04131     Int_t pl=endPlane;
04132     while (pl!=planeToStopBefore){//cut out the first x planes (en dep is low, !d-ray)
04133       
04134       Float_t pathLengthCor=initValue;
04135       pathLengthCor=plPLCor[pl];
04136       Float_t truePathLengthCor=truePLCor[pl];
04137       //might be beyond plane end so use reco PLCor
04138       if (truePathLengthCor<1) truePathLengthCor=pathLengthCor;
04139       if (pl==endPlane){
04140         //cap the very last plane
04141         if (truePathLengthCor>3) {
04142           MAXMSG("CDAnalysis",Msg::kWarning,1000)
04143             <<"Capping the last plane PLCor"<<endl;
04144           truePathLengthCor=3;
04145         }
04146       }
04147 
04148       if (pathLengthCor<1){
04149         MAXMSG("CDAnalysis",Msg::kWarning,1000)
04150           <<"pl="<<pl<<", endPlane="<<endPlane
04151           <<", path len cor wrong="<<pathLengthCor<<endl;
04152         //set default to 1
04153         pathLengthCor=1;
04154       }
04155 
04156       Float_t meuSigCor=0;
04157       if (pathLengthCor) meuSigCor=plEnDep[pl]/pathLengthCor;
04158       Float_t meuSigCorTrue=0;
04159       if (truePathLengthCor) meuSigCorTrue=plEnDep[pl]/
04160                                truePathLengthCor;
04161       Float_t plMaterial=pathLengthCor*material01Pl;
04162       Float_t truePlMaterial=truePathLengthCor*material01Pl;
04163 
04164       //plot the value half way through the range of dE/dx it 
04165       //effectively integrates over
04166       Float_t toPlotMaterial=plMaterial*0.5+materialFromTrkEnd;
04167       Float_t trueToPlotMaterial=truePlMaterial*0.5+
04168         trueMaterialFromTrkEnd;
04169 
04170       Float_t trueEnDep=this->TrueEnDep(pl,event);
04171       Float_t trueEnDepPLC=-1;
04172       if (truePathLengthCor) {
04173         trueEnDepPLC=trueEnDep/truePathLengthCor;
04174       }
04175       
04176       //fill the histograms for each individual plane
04177       if (pl<60 && pl>=0) {
04178         //fill both with and without the pathlength correction
04179         //fill as a function of planes from track end point
04180         meuSigCorNoPLCorHistos[planesFromTrkEnd]->Fill(plEnDep[pl]);
04181         meuSigCorPLCorHistos[planesFromTrkEnd]->Fill(meuSigCor);
04182 
04183         //fill as a function of distance from track end point
04184         //distance in units of "perpendicular planes"
04185         Int_t planesFromTrkEndPerp=
04186           static_cast<Int_t>(materialFromTrkEnd/material01Pl);
04187         MAXMSG("CDAnalysis",Msg::kInfo,1000)
04188           <<"pl="<<pl<<", endPlane="<<endPlane
04189           <<", plFrTrkEnd="<<planesFromTrkEnd
04190           <<", plFrTrkEndPerp="<<planesFromTrkEndPerp
04191           <<", matFrTrkEnd="<<materialFromTrkEnd
04192           <<", material01Pl="<<material01Pl<<endl;
04193         if (planesFromTrkEndPerp<60 && planesFromTrkEndPerp>=0) {
04194           meuSigCorNoPLCorPerpHistos[planesFromTrkEndPerp]->
04195             Fill(plEnDep[pl]);
04196           meuSigCorPLCorPerpHistos[planesFromTrkEndPerp]->
04197             Fill(meuSigCor);
04198         }
04199         else cout<<"ahhh, planesFromTrkEndPerp="
04200                  <<planesFromTrkEndPerp<<endl;
04201 
04202         //fill as a function of plane number
04203         meuSigCorNoPLCorZerosHistos[pl]->Fill(plEnDep[pl]);
04204         meuSigCorPLCorZerosHistos[pl]->Fill(meuSigCor);
04205       }
04206       else cout<<"ahhh, pl="<<pl<<endl;
04207 
04208       //fill plot of PLC energy deposition
04209       hSigCorPLC->Fill(meuSigCor);
04210       pEnVsDistAll->Fill((materialFromTrkEnd/Munits::cm),meuSigCor);
04211       if (meuSigCor<7000) pEnVsDistAll2->Fill
04212                             ((materialFromTrkEnd/Munits::cm),meuSigCor);
04213 
04214       //put a check on the crazy brems
04215       //can get high landau-tail events in individual planes
04216       if (meuSigCor<5000){
04217         pEnVsDist->Fill((toPlotMaterial/Munits::cm),meuSigCor);
04218         
04219         //fill using 0 for the first pl, 
04220         //don't try and get an average position
04221         pEnVsDist0->Fill((materialFromTrkEnd/Munits::cm),meuSigCor);
04222         pEnVsPlane0->Fill(pl,meuSigCor);
04223         pTrueEnVsDist0->Fill((materialFromTrkEnd/Munits::cm),trueEnDep);
04224         pTrueEnPLCVsDist0->Fill((materialFromTrkEnd/Munits::cm),
04225                                 trueEnDepPLC);
04226         pTrueEnVsPlane0->Fill(pl,trueEnDep);
04227         
04228         if (pl!=endPlane) {
04229           pEnVsDistNoEnd->Fill((toPlotMaterial/Munits::cm),meuSigCor);
04230           if (truePLCor.size()>0){
04231             pEnVsDistNoEndTrue->Fill((trueToPlotMaterial/Munits::cm),
04232                                      meuSigCorTrue);
04233             //make one with same positions as reco but true enDep
04234             pEnVsDistNoEndTrue2->Fill((toPlotMaterial/Munits::cm),
04235                                       meuSigCorTrue);
04236           }
04237         }
04238       }
04239 
04240       if (meuSigCor<5000 && endPlane>=49 && endPlane<=51){
04241         if (pl!=endPlane) {
04242           pEnVsDistNoEnd4951->Fill((toPlotMaterial/Munits::cm),
04243                                    meuSigCor);
04244         }
04245       }
04246 
04247       if (meuSigCor<5000 && endPlane>40){
04248         if (pl!=endPlane) {
04249           pEnVsDistNoEnd40->Fill((toPlotMaterial/Munits::cm),
04250                                  meuSigCor);
04251         }
04252       }
04253 
04254       //sum up material traversed
04255       materialFromTrkEnd+=plMaterial;
04256       trueMaterialFromTrkEnd+=truePlMaterial;
04257       planesFromTrkEnd++;
04258 
04259       MAXMSG("CDAnalysis",Msg::kInfo,500)
04260         <<"Window:p="<<pl
04261         <<", matPl="<<pathLengthCor*material01Pl
04262         <<", matTrk="<<materialFromTrkEnd
04263         <<", plEn="<<plEnDep[pl]
04264         <<endl;
04265 
04266       //increment the plane
04267       pl--;
04268     }
04269     hMatFromTrkEnd->Fill(materialFromTrkEnd);
04270     hMatFromTrkEndTrue->Fill(trueMaterialFromTrkEnd);
04271     Float_t totalMaterial=materialFromTrkEnd;
04272     materialFromTrkEnd=0;
04273     trueMaterialFromTrkEnd=0;
04274     
04276     //2nd loop over the track
04278     pl=endPlane;
04279     while (pl!=planeToStopBefore){//cut out the first x planes (en dep is low, !d-ray)
04280       
04281       Float_t pathLengthCor=initValue;
04282       pathLengthCor=plPLCor[pl];
04283       Float_t truePathLengthCor=truePLCor[pl];
04284       //might be beyond plane end so use reco PLCor
04285       if (truePathLengthCor<1) truePathLengthCor=pathLengthCor;
04286       if (pl==endPlane){
04287         //cap the very last plane
04288         if (truePathLengthCor>3) {
04289           MAXMSG("CDAnalysis",Msg::kWarning,1000)
04290             <<"Capping the last plane PLCor"<<endl;
04291           truePathLengthCor=3;
04292         }
04293       }
04294 
04295       if (pathLengthCor<1){
04296         MAXMSG("CDAnalysis",Msg::kWarning,1000)
04297           <<"pl="<<pl<<", endPlane="<<endPlane
04298           <<", path len cor wrong="<<pathLengthCor<<endl;
04299         //set default to 1
04300         pathLengthCor=1;
04301       }
04302 
04303       Float_t meuSigCor=0;
04304       if (pathLengthCor) meuSigCor=plEnDep[pl]/pathLengthCor;
04305       Float_t meuSigCorTrue=0;
04306       if (truePathLengthCor) meuSigCorTrue=plEnDep[pl]/
04307                                truePathLengthCor;
04308       Float_t plMaterial=pathLengthCor*material01Pl;
04309       Float_t truePlMaterial=truePathLengthCor*material01Pl;
04310 
04311       //plot the value half way through the range of dE/dx it 
04312       //effectively integrates over
04313       Float_t toPlotMaterial=plMaterial*0.5+materialFromTrkEnd;
04314       //Float_t trueToPlotMaterial=truePlMaterial*0.5+
04315       //trueMaterialFromTrkEnd;
04316 
04317       Float_t trueEnDep=this->TrueEnDep(pl,event);
04318       Float_t trueEnDepPLC=-1;
04319       if (truePathLengthCor) {
04320         trueEnDepPLC=trueEnDep/truePathLengthCor;
04321       }
04322 
04323       //put a check on the crazy brems and cut out the really steep ones
04324       //can also get high landau-tail events in individual planes
04325       if (meuSigCor<5000 && totalMaterial>2.49 && totalMaterial<2.61){
04326         if (pl!=endPlane) {
04327           pEnVsDistNoEnd250->Fill((toPlotMaterial/Munits::cm),
04328                                   meuSigCor);
04329         }
04330       }
04331       if (meuSigCor<5000 && totalMaterial>2.7 && totalMaterial<2.9){
04332         if (pl!=endPlane) {
04333           pEnVsDistNoEnd270->Fill((toPlotMaterial/Munits::cm),
04334                                   meuSigCor);
04335           pTrueEnPLCVsDist0270->Fill((materialFromTrkEnd/Munits::cm),
04336                                      trueEnDepPLC);
04337         }
04338       }
04339       //was 2.8->3.0 when pl!=1
04340       if (meuSigCor<5000 && totalMaterial>2.9 && totalMaterial<3.1){
04341         if (pl!=endPlane) {
04342           pPLCorVsPlane290->Fill(pl,pathLengthCor);
04343           pTrueEnPLCVsDist0290->Fill((materialFromTrkEnd/Munits::cm),
04344                                      trueEnDepPLC);
04345           pPLCorVsPlaneTrue->Fill(pl,truePathLengthCor);
04346           pEnVsDistNoEnd290->Fill((toPlotMaterial/Munits::cm),
04347                                   meuSigCor);
04348         }
04349       }
04350       if (meuSigCor<5000 && totalMaterial>3.1 && totalMaterial<3.3){
04351         if (pl!=endPlane) {
04352           pEnVsDistNoEnd310->Fill((toPlotMaterial/Munits::cm),
04353                                   meuSigCor);
04354           pTrueEnPLCVsDist0310->Fill((materialFromTrkEnd/Munits::cm),
04355                                      trueEnDepPLC);
04356         }
04357       }
04358 
04359       if (meuSigCor<5000 && totalMaterial>2.95 && totalMaterial<3.05){
04360         if (pl!=endPlane) {
04361           pEnVsDistNoEnd290a->Fill((toPlotMaterial/Munits::cm),
04362                                    meuSigCor);
04363         }
04364       }
04365 
04366 
04367       if (meuSigCor<5000 && totalMaterial>2.96 && totalMaterial<3.03){
04368         if (pl!=endPlane) {
04369           pEnVsDistNoEnd290b->Fill((toPlotMaterial/Munits::cm),
04370                                   meuSigCor);
04371         }
04372       }
04373 
04374       //sum up material traversed
04375       materialFromTrkEnd+=plMaterial;
04376       trueMaterialFromTrkEnd+=truePlMaterial;
04377 
04378       //increment the plane
04379       pl--;
04380     }
04381   }
04382 }

void CDAnalysis::FillProfHisto ( TProfile *  prof,
std::map< Int_t, Float_t > &  counter,
const std::map< Int_t, Float_t > &  addMe,
Int_t  offset = 0 
) const [private]

Definition at line 3106 of file CDAnalysis.cxx.

References it, Msg::kWarning, and MSG.

Referenced by MuonNearFar(), MuonResponse(), and StoppingMuonCalibration().

03110 {
03111   if (prof){
03112     for (map<Int_t,Float_t>::const_iterator it=addMe.begin();
03113          it!=addMe.end();++it){
03114       Int_t key=it->first;
03115       if (offset!=0) key=offset-(it->first);
03116 
03117       prof->Fill(key,it->second);
03118       counter[key]++;
03119     }
03120   }
03121   else{
03122     MSG("CDAnalysis",Msg::kWarning)
03123       <<"TProfile not initialised"<<endl;
03124   }
03125 }

void CDAnalysis::FlipVector ( std::vector< Double_t > &  v  )  const [private]

Definition at line 2158 of file CDAnalysis.cxx.

References Msg::kDebug, and MSG.

Referenced by Bb(), and BbVsGminos().

02159 {
02160   MSG("CDAnalysis",Msg::kDebug) 
02161     <<" ** Running FlipVector method... **"<<endl;
02162 
02163   vector<Double_t> tempV=v;
02164 
02165   for (UInt_t i=0;i<v.size();i++) v[i]=tempV[v.size()-1-i];
02166 
02167   MSG("CDAnalysis",Msg::kDebug) 
02168     <<" ** Finished FlipVector method **"<<endl;
02169 }

Int_t CDAnalysis::GetEventLength (  )  const [private]

Definition at line 2976 of file CDAnalysis.cxx.

References fLastPlane, fNumPlanesHitAll, Msg::kInfo, and MAXMSG.

Referenced by CalcMeuPLCorrected(), CalcPLCor(), CalcXYZ(), CutOnEventLength(), StoppingMuonCalibration(), and TruePLCor().

02977 {
02978   Int_t lastPlane=fLastPlane;
02979   
02980   //if there was no track then a last plane is not found
02981   //in this case use the number of planes hit
02982   //this will be fairly rare for muons
02983   if (lastPlane==-1) {
02984     MAXMSG("CDAnalysis",Msg::kInfo,1)
02985       <<"GetEventLength::Using num planes hit in event length:"
02986       <<" fLastPlane="<<fLastPlane
02987       <<", numPlanesHit="<<fNumPlanesHitAll.size()<<endl;
02988     lastPlane=fNumPlanesHitAll.size();
02989   }
02990   
02991   return lastPlane;
02992 }

void CDAnalysis::GetEvLenMinMax ( Int_t &  minPlane,
Int_t &  maxPlane 
) const [private]

Definition at line 2897 of file CDAnalysis.cxx.

References fBeamMomentum, Msg::kInfo, and MAXMSG.

Referenced by CutOnEventLength(), CutOnNumPlanesHit(), StoppingMuonCalibration(), and WriteOutHistos().

02898 {
02899   //I don't understand abs. Sometimes it just returns an int!!
02900   //e.g. in a root macro
02901   Float_t aBeamP=fabs(fBeamMomentum);
02902   
02903   //new cuts are now inclusive so it's 31<=Pl<=45
02904 
02905   if (fabs(fBeamMomentum)>1.3 && fabs(fBeamMomentum)<1.5){
02906     minPlane=31;//minPlane=35;
02907     maxPlane=45;//maxPlane=44;
02908   }
02909   else if (fabs(fBeamMomentum)>1.5 && fabs(fBeamMomentum)<1.7){
02910     minPlane=35;//minPlane=40;
02911     maxPlane=51;//maxPlane=49;
02912   }
02913   else if (fabs(fBeamMomentum)>1.7 && fabs(fBeamMomentum)<1.9){
02914     minPlane=39;//minPlane=42;
02915     maxPlane=56;//maxPlane=57;
02916   }
02917   else if (fabs(fBeamMomentum)>1.9){
02918     minPlane=44;//minPlane=44;
02919     maxPlane=57;//maxPlane=58;
02920   }
02921   else{
02922     MAXMSG("CDAnalysis",Msg::kInfo,10)
02923       <<"No event length cut for this particle energy="
02924       <<fBeamMomentum<<endl;
02925     assert(false);
02926   }
02927   MAXMSG("CDAnalysis",Msg::kInfo,1)
02928     <<"Set Ev. Len min="<<minPlane<<", max="<<maxPlane
02929     <<", aBeamP="<<aBeamP<<endl;
02930 }

Double_t CDAnalysis::GetGreatestMainParticleEnergy ( Int_t  nEvents = 200  )  const [private]

Definition at line 3755 of file CDAnalysis.cxx.

References fEvents, fTrackerTree, and GetMainParticleEnergy().

03756 {
03757   Double_t mainEnergy=0;
03758 
03759   if (nEvents>fEvents) nEvents=fEvents;
03760 
03761   for(Int_t event=0;event<nEvents;event++){
03762     
03763     //get the snarl/event
03764     fTrackerTree->GetEvent(event); 
03765     
03766     Double_t mEn=this->GetMainParticleEnergy();
03767     
03768     //select the greatest one
03769     if (mEn>mainEnergy) mainEnergy=mEn;
03770   }
03771 
03772   return mainEnergy;
03773 }

void CDAnalysis::GetLowUpTimeCuts ( Float_t &  lowTime,
Float_t &  upTime 
) const [private]

Definition at line 2818 of file CDAnalysis.cxx.

References fRunNumber, fSimFlag, SimFlag::kData, Msg::kInfo, MAXMSG, and run().

Referenced by CutOnScint_TofDiff(), and StoppingMuonCalibration().

02820 {
02821   //this works in ns rather naughtily!
02822   lowTime=-1000000;
02823   upTime=1000000;
02824 
02825   Int_t run=fRunNumber;
02826 
02827   //set the time gate here so that you get the same for each run 
02828   //period
02829   Int_t lowTimeLimit=35;
02830   Int_t upTimeLimit=295;
02831   Int_t peak=-1;
02832   
02833   //only have timing issues for real data
02834   if (fSimFlag==SimFlag::kData) {
02835     if (run>=40000 && run<50000){
02836       //just for interest: the peak is 180 ns into the 600 ns varc gate
02837       peak=-125;//ns
02838       lowTime=peak-lowTimeLimit;//was -175;
02839       upTime=peak+upTimeLimit;//was 135;
02840     }
02841     else if (run>=50000 && run<60000){
02842       //just for interest: the peak is 280 ns into the 600 ns varc gate
02843       peak=30;//ns
02844       lowTime=peak-lowTimeLimit;
02845       upTime=peak+upTimeLimit;
02846     }
02847     else if (run>=70000 && run<80000){
02848       //just for interest: the peak is 220 ns into the 600 ns varc gate
02849       peak=5;//ns
02850       lowTime=peak-lowTimeLimit;//-30;//-50;
02851       upTime=peak+upTimeLimit;//300;//260;
02852     }
02853     else{
02854       MAXMSG("CDAnalysis",Msg::kInfo,10)
02855         <<"No time cuts cut for this run="<<fRunNumber<<endl;
02856     }
02857   }
02858   else{
02859     MAXMSG("CDAnalysis",Msg::kInfo,1)
02860       <<"MC data so no sensible timing cuts to set"<<endl;
02861   }
02862 
02863   MAXMSG("CDAnalysis",Msg::kInfo,1)
02864     <<"Set time cuts:  low="<<lowTime<<" ns, upper="<<upTime<<" ns"
02865     <<endl;
02866 }

Double_t CDAnalysis::GetMainParticleEnergy (  )  const [private]

Definition at line 3722 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetMainPartEn(), Msg::kDebug, and MSG.

Referenced by GetGreatestMainParticleEnergy(), and MuonCalorimetry().

03723 {
03724   if (!fTruthHitInfo) return 0;
03725 
03726   Double_t mainEnergy=0;
03727 
03728   TClonesArray &cTruth = *fTruthHitInfo;
03729   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03730   
03731   //loop over the truth hits
03732   for (Int_t hit=0;hit<numTruthHits;hit++){
03733     //cast the tclonesarray up to a truthhitinfo object
03734     CDTruthHitInfo *hitInfo=
03735       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03736     
03737     Double_t en=hitInfo->GetMainPartEn();
03738 
03739     MSG("CDAnalysis",Msg::kDebug)
03740       <<"en="<<en<<endl;
03741 
03742     //find the greatest energy
03743     if (en>mainEnergy) {
03744       mainEnergy=en;
03745       MSG("CDAnalysis",Msg::kDebug)
03746         <<"mainEnergy="<<mainEnergy<<endl;
03747     }
03748   }
03749  
03750   return mainEnergy;
03751 }

void CDAnalysis::InitialiseHitInfoVariables (  )  [private]

Definition at line 249 of file CDAnalysis.cxx.

References fChargeAdc, fChargeMip, fChargePe, fChargeSigCor, fChargeSigLin, fE1, fE2, fGain, fO1, fO2, fPlane, fResultEven, fResultOdd, fStrip, fStripend, fTime, and fTransPos.

Referenced by ReadInHitInfo().

00250 {
00251   fTime=0;
00252 
00253   fPlane=-1;
00254   fResultOdd=-1;
00255   fResultEven=-1;
00256   fStrip=-1;
00257   fStripend=-1;
00258   fTransPos=-1;
00259 
00260   fO1=false;
00261   fO2=false;
00262   fE1=false;
00263   fE2=false;
00264 
00265   fChargeAdc=-1;
00266   fChargeMip=-1;
00267   fChargeSigCor=-1;
00268   fChargeSigLin=-1;
00269   fChargePe=-1;
00270   fGain=-1;
00271 }

void CDAnalysis::InitialiseLoopVariables (  )  [private]

Definition at line 170 of file CDAnalysis.cxx.

References fAvStrip, fAvStrip1, fAvStrip2, fFirstPlane, fLastPlane, fLastPlaneEven, fLastPlaneOdd, fLowScint_Tof, fNumHitsPerPlane, fNumHitsPerPlane25, fNumHitsPerPlanePeCut10, fNumPlanesHit25, fNumPlanesHitAll, fNumPlanesHitPeCut, fNumPlanesHitPeCut10, fNumPlanesHitTrk, fStCount, fStCount1, fStCount2, fStripsFromCentrePeCut, fUpScint_Tof, Msg::kDebug, and MSG.

Referenced by BbVsGminos(), CleanMuons(), ElectronResponse(), MuonCalorimetry(), MuonNearFar(), MuonResponse(), MuonSampleCuts(), MuonScatter(), MuonStVsPl(), PrintPIDStats(), SetLoopVariables(), StoppingMuonCalibration(), Template(), Template2(), TruthAnalysis(), TruthEnDep(), TruthEnDepFe(), TruthEventLength(), ValidateMC(), ValidatePIDInfo(), ValidateReco(), ValidateTrkHits(), ValidateTruth(), ValidateUnTrkHits(), and ValidateXTalkHits().

00171 {
00172   MSG("CDAnalysis",Msg::kDebug)<<"Initialising loop variables..."<<endl;
00173 
00174   fFirstPlane=69;
00175   fLastPlane=-1;
00176   fLastPlaneOdd=-1;
00177   fLastPlaneEven=-1;
00178 
00179   fNumPlanesHitAll.clear();
00180   fNumPlanesHit25.clear();
00181   fNumPlanesHitTrk.clear();
00182   fNumPlanesHitPeCut.clear();
00183   fNumPlanesHitPeCut10.clear();
00184 
00185   fNumHitsPerPlane=-1;
00186   fNumHitsPerPlane25=-1;
00187   fNumHitsPerPlanePeCut10=-1;
00188   fStripsFromCentrePeCut=-1;
00189 
00190   //variables to calc av strip for ps muon cut
00191   fAvStrip=-1;
00192   fStCount=0;
00193   fAvStrip1=-1;
00194   fStCount1=0;
00195   fAvStrip2=-1;
00196   fStCount2=0;
00197 
00198   fLowScint_Tof=1e9;
00199   fUpScint_Tof=-1e9;
00200 
00201   MSG("CDAnalysis",Msg::kDebug)<<"Initialisation complete"<<endl;
00202 }

void CDAnalysis::InitialisePidVariables (  )  [private]

Definition at line 206 of file CDAnalysis.cxx.

References fFafErr, fInCERTime, fInCERTimeBits, fKovADC1, fKovADC2, fKovADC3, fKovTimeStamp1, fKovTimeStamp2, fKovTimeStamp3, fNoOverlap, fNoOverlapBits, fOLChi2, fPIDType, fSnarlMaxTimeStamp, fSnarlMinTimeStamp, fSnarlTimeFrame, fSparseErr, fTickSinceLast, fTofADC0, fTofADC1, fTofADC2, fTofADCTimeStamp0, fTofADCTimeStamp1, fTofADCTimeStamp2, fTofTDC0, fTofTDC1, fTofTDC2, fTofTimeStamp, fTriggerPMT, and fTrigSource.

Referenced by SetLoopVariables().

00207 {
00208   //these are the SI variables
00209   fTriggerPMT=-1;
00210   fFafErr=-1;
00211   fSparseErr=-1;
00212   fTrigSource=-1;
00213 
00214   fKovADC1=-1;
00215   fKovTimeStamp1=-1;
00216   fKovADC2=-1;
00217   fKovTimeStamp2=-1;
00218   fKovADC3=-1;
00219   fKovTimeStamp3=-1;
00220 
00221   fSnarlTimeFrame=-1;
00222   fSnarlMinTimeStamp=0;
00223   fSnarlMaxTimeStamp=0;
00224 
00225   fTofTDC0=-1;
00226   fTofTDC1=-1;
00227   fTofTDC2=-1;
00228   fTofADC0=-1;
00229   fTofADC1=-1;
00230   fTofADC2=-1;
00231   fTofADCTimeStamp0=-1;
00232   fTofADCTimeStamp1=-1;
00233   fTofADCTimeStamp2=-1;
00234   fTofTimeStamp=-1;//don't use this, use fTofADCTimeStamp1==TTAG
00235 
00236   fTickSinceLast=-1;
00237 
00238   //these are the PID variables
00239   fNoOverlap=kFALSE;
00240   fInCERTime=kFALSE;
00241   fPIDType=0;
00242   fNoOverlapBits=0; 
00243   fInCERTimeBits=0; 
00244   fOLChi2=0;
00245 }

static void CDAnalysis::InputFileName ( std::string  f  )  [static]
Bool_t CDAnalysis::IsDoubleEnded ( Int_t  inplane  )  const [private]

Definition at line 3292 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), Msg::kVerbose, and MSG.

Referenced by MuonResponse().

03293 {
03294   if (!fTruthHitInfo) return true;
03295 
03296   TClonesArray &cTruth = *fTruthHitInfo;
03297   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03298   
03299   Bool_t doubleEnded=false;
03300 
03301   //loop over the truth hits
03302   for (Int_t hit=0;hit<numTruthHits;hit++){
03303     //cast the tclonesarray up to a truthhitinfo object
03304     CDTruthHitInfo *hitInfo=
03305       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03306     
03307     Int_t plane=hitInfo->GetPlane();
03308     
03309     if (plane!=inplane) continue;
03310     
03311     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03312     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03313 
03314     if (pmtTruth1 && pmtTruth2) doubleEnded=true;
03315 
03316     MSG("CDAnalysis",Msg::kVerbose)
03317       <<"doubleEnded="<<doubleEnded<<endl;
03318   }
03319 
03320   return doubleEnded;
03321 }

Bool_t CDAnalysis::IsGenuineOrXTalk ( Int_t  inplane  )  const [private]

Definition at line 3325 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), DigiSignal::kCrosstalk, DigiSignal::kCrosstalkOptical, Msg::kDebug, DigiSignal::kGenuine, DigiSignal::kUnknown, Msg::kVerbose, and MSG.

Referenced by MuonResponse().

03326 {
03327   if (!fTruthHitInfo) return true;
03328 
03329   TClonesArray &cTruth = *fTruthHitInfo;
03330   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03331   
03332   Int_t sumTruth=DigiSignal::kUnknown;
03333 
03334   //loop over the truth hits
03335   for (Int_t hit=0;hit<numTruthHits;hit++){
03336     //cast the tclonesarray up to a truthhitinfo object
03337     CDTruthHitInfo *hitInfo=
03338       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03339     
03340     Int_t plane=hitInfo->GetPlane();
03341     
03342     if (plane!=inplane) continue;
03343     
03344     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03345     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03346 
03347     //add up the bits
03348     sumTruth|=pmtTruth1;
03349     sumTruth|=pmtTruth2;
03350   }
03351   
03352   MSG("CDAnalysis",Msg::kVerbose)
03353     <<"sumTruth(GenOrXTalk)="<<sumTruth<<endl;
03354 
03355   Bool_t genuineBit=((sumTruth & DigiSignal::kGenuine)==
03356                      DigiSignal::kGenuine);
03357   Bool_t optXTalkBit=((sumTruth & DigiSignal::kCrosstalkOptical)==
03358                       DigiSignal::kCrosstalkOptical);
03359   Bool_t xTalkBit=((sumTruth & DigiSignal::kCrosstalk)==
03360                    DigiSignal::kCrosstalk);
03361 
03362   if (genuineBit || optXTalkBit) return true;
03363   else if (xTalkBit){
03364     MSG("CDAnalysis",Msg::kDebug)
03365       <<" **** Only non-optXTalk, sumTruth="<<sumTruth<<endl;
03366     return false;
03367   }
03368   else{
03369     MSG("CDAnalysis",Msg::kDebug)
03370       <<"Not genuine or xtalk, sumTruth="<<sumTruth<<endl;
03371     return false;
03372   }
03373 }

Bool_t CDAnalysis::IsPlaneGenuine ( Int_t  inplane  )  const [private]

Definition at line 3175 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), DigiSignal::kGenuine, Msg::kInfo, DigiSignal::kUnknown, Msg::kVerbose, MAXMSG, and MSG.

Referenced by MuonResponse().

03176 {
03177   if (!fTruthHitInfo) return true;
03178 
03179   MAXMSG("CDAnalysis",Msg::kInfo,1)
03180     <<"Running IsPlaneGenuine(), fTruthHitInfo="<<fTruthHitInfo<<endl;
03181 
03182   TClonesArray &cTruth = *fTruthHitInfo;
03183   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03184   
03185   Int_t sumTruth=DigiSignal::kUnknown;
03186 
03187   //loop over the truth hits
03188   for (Int_t hit=0;hit<numTruthHits;hit++){
03189     //cast the tclonesarray up to a truthhitinfo object
03190     CDTruthHitInfo *hitInfo=
03191       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03192     
03193     Int_t plane=hitInfo->GetPlane();
03194 
03195     if (plane!=inplane) continue;
03196 
03197     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03198     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03199 
03200     //add up the bits
03201     sumTruth|=pmtTruth1;
03202     sumTruth|=pmtTruth2;
03203 
03204     MSG("CDAnalysis",Msg::kVerbose)
03205       <<"sumTruth="<<sumTruth<<endl;
03206   }
03207 
03208   //check if genuine or not
03209   Bool_t genuineBit=((sumTruth & DigiSignal::kGenuine)==
03210                      DigiSignal::kGenuine);
03211   
03212   if (genuineBit) return true;
03213   else return false;
03214 }

Bool_t CDAnalysis::IsPlaneSideHit ( Int_t  inplane,
Int_t  stripend 
) const [private]

Definition at line 3251 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), StripEnd::kEast, Msg::kVerbose, StripEnd::kWest, and MSG.

Referenced by MuonResponse().

03252 {
03253   if (!fTruthHitInfo) return true;
03254 
03255   TClonesArray &cTruth = *fTruthHitInfo;
03256   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03257   
03258   Bool_t planeSideHit=false;
03259 
03260   //loop over the truth hits
03261   for (Int_t hit=0;hit<numTruthHits;hit++){
03262     //cast the tclonesarray up to a truthhitinfo object
03263     CDTruthHitInfo *hitInfo=
03264       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03265     
03266     Int_t plane=hitInfo->GetPlane();
03267     
03268     if (plane!=inplane) continue;
03269 
03270     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03271     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03272     
03273 
03274     if (pmtTruth1 && stripEnd==StripEnd::kEast){
03275       planeSideHit=true;
03276       break;//only need the one hit
03277     }
03278     if (pmtTruth2 && stripEnd==StripEnd::kWest){
03279       planeSideHit=true;
03280       break;//only need the one hit
03281     }
03282   }
03283 
03284   MSG("CDAnalysis",Msg::kVerbose)
03285     <<"planeSideHit="<<planeSideHit<<endl;
03286 
03287   return planeSideHit;
03288 }

Bool_t CDAnalysis::IsPlaneXTalkOnly ( Int_t  inplane  )  const [private]

Definition at line 3129 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetPmtTruth1(), CDTruthHitInfo::GetPmtTruth2(), DigiSignal::kCrosstalk, DigiSignal::kCrosstalkOptical, DigiSignal::kGenuine, DigiSignal::kUnknown, Msg::kVerbose, and MSG.

Referenced by MuonResponse().

03130 {
03131   if (!fTruthHitInfo) return false;
03132 
03133   TClonesArray &cTruth = *fTruthHitInfo;
03134   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03135   
03136   Int_t sumTruth=DigiSignal::kUnknown;
03137 
03138   //loop over the truth hits
03139   for (Int_t hit=0;hit<numTruthHits;hit++){
03140     //cast the tclonesarray up to a truthhitinfo object
03141     CDTruthHitInfo *hitInfo=
03142       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03143     
03144     Int_t plane=hitInfo->GetPlane();
03145 
03146     if (plane!=inplane) continue;
03147 
03148     Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03149     Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03150 
03151     //add up the bits
03152     sumTruth|=pmtTruth1;
03153     sumTruth|=pmtTruth2;
03154 
03155     MSG("CDAnalysis",Msg::kVerbose)
03156       <<"sumTruth="<<sumTruth<<endl;
03157   }
03158 
03159   //check if genuine or not
03160   Bool_t genuineBit=((sumTruth & DigiSignal::kGenuine)==
03161                      DigiSignal::kGenuine);
03162   Bool_t optXTalkBit=((sumTruth & DigiSignal::kCrosstalkOptical)==
03163                       DigiSignal::kCrosstalkOptical);
03164   Bool_t xTalkBit=((sumTruth & DigiSignal::kCrosstalk)==
03165                    DigiSignal::kCrosstalk);
03166   
03167   if (genuineBit || sumTruth==0) return false;
03168   else if (optXTalkBit) return true;
03169   else if (xTalkBit) return true;
03170   else return false;
03171 }

Bool_t CDAnalysis::IsSharedPmtHit ( Int_t  inplane  )  const [private]

Definition at line 3218 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetVaChip1(), CDTruthHitInfo::GetVaChip2(), Msg::kVerbose, and MSG.

Referenced by MuonResponse().

03219 {
03220   if (!fTruthHitInfo) return true;
03221 
03222   TClonesArray &cTruth = *fTruthHitInfo;
03223   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03224   
03225   Bool_t sharedPmtHit=false;
03226 
03227   //loop over the truth hits
03228   for (Int_t hit=0;hit<numTruthHits;hit++){
03229     //cast the tclonesarray up to a truthhitinfo object
03230     CDTruthHitInfo *hitInfo=
03231       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03232     
03233     Int_t plane=hitInfo->GetPlane();
03234     
03235     if (plane!=inplane) continue;
03236     
03237     Int_t vaChip1=hitInfo->GetVaChip1();
03238     Int_t vaChip2=hitInfo->GetVaChip2();
03239 
03240     if (vaChip1==1 || vaChip2==1) sharedPmtHit=true;
03241 
03242     MSG("CDAnalysis",Msg::kVerbose)
03243       <<"sharedPmtHit="<<sharedPmtHit<<endl;
03244   }
03245 
03246   return sharedPmtHit;
03247 }

Bool_t CDAnalysis::IsStraightTrack ( Double_t  mainX1Cut  )  const [private]

Definition at line 3466 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetMainParticle(), and CDTruthHitInfo::GetMainX1().

Referenced by BbVsGminos(), and TruthEnDep().

03467 {
03468   if (!fTruthHitInfo) return true;
03469 
03470   TClonesArray &cTruth = *fTruthHitInfo;
03471   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03472   
03473   //set default return value to true
03474   Bool_t straight=true;
03475 
03476   //loop over the truth hits
03477   for (Int_t hit=0;hit<numTruthHits;hit++){
03478     //cast the tclonesarray up to a truthhitinfo object
03479     CDTruthHitInfo *hitInfo=
03480       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03481     
03482     Int_t mainParticle=hitInfo->GetMainParticle();
03483     Double_t mainX1=hitInfo->GetMainX1();
03484     Int_t muon=13;
03485 
03486     //test for straight tracks
03487     if (abs(mainParticle)==muon && 
03488         (mainX1>mainX1Cut || mainX1<-1*mainX1Cut)){
03489       straight=false;
03490       break;
03491     }
03492   }
03493 
03494   //return result
03495   return straight;
03496 }

Bool_t CDAnalysis::IsStraightTrack_Radius ( Double_t  radiusCut  )  const [private]

Definition at line 3412 of file CDAnalysis.cxx.

References fTruthHitInfo, CDTruthHitInfo::GetMainParticle(), CDTruthHitInfo::GetPlane(), CDTruthHitInfo::GetStrip(), Msg::kVerbose, MAXMSG, TrueDistToPlaneCentre(), and TrueXInStripFrame().

Referenced by ValidateReco().

03413 {
03414   if (!fTruthHitInfo) return true;
03415 
03416   //this method will get called once per event so use event to satisfy
03417   //the TrueXInStripFrame method used below
03418   //bit of a hack but it should work fine
03419   static Int_t event=0;
03420   event++;
03421 
03422   //check if positive
03423   if (radiusCut<0) radiusCut=radiusCut-2*radiusCut;
03424 
03425   TClonesArray &cTruth = *fTruthHitInfo;
03426   Int_t numTruthHits=fTruthHitInfo->GetEntries();
03427   
03428   //set default return value to true
03429   Bool_t straight=true;
03430 
03431   //loop over the truth hits
03432   for (Int_t hit=0;hit<numTruthHits;hit++){
03433     //cast the tclonesarray up to a truthhitinfo object
03434     CDTruthHitInfo *hitInfo=
03435       dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03436     
03437     Int_t mainParticle=hitInfo->GetMainParticle();
03438     Int_t plane=hitInfo->GetPlane();
03439     Int_t strip=hitInfo->GetStrip();
03440     Int_t muon=13;
03441 
03442     if (abs(mainParticle)!=muon) continue;
03443 
03444     Float_t trueX=this->TrueXInStripFrame(plane,strip,event);   
03445     Float_t radiusTrue=this->TrueDistToPlaneCentre(strip,trueX);
03446     MAXMSG("CDAnalysis",Msg::kVerbose,300)
03447       <<"trueX="<<trueX<<", trueRadius="<<radiusTrue
03448       <<", striaght="<<straight<<", radiusCut="<<radiusCut<<endl;
03449 
03450     //test for straight tracks
03451     if (radiusTrue>radiusCut){
03452       straight=false;
03453       break;
03454     }
03455   }
03456 
03457   MAXMSG("CDAnalysis",Msg::kVerbose,100)
03458     <<"Returning straight="<<straight<<endl;
03459 
03460   //return result
03461   return straight;
03462 }

void CDAnalysis::MakeChain (  )  [private]

Definition at line 445 of file CDAnalysis.cxx.

References exit(), fOptTree, fTrackerTree, Msg::kFatal, Msg::kInfo, MakeFileList(), and MSG.

00446 {
00447   //get the files to open
00448   vector<string> fileList=this->MakeFileList();
00449 
00450   //create a chain with TrackerTree
00451   fTrackerTree=new TChain("TrackerTree");
00452   fOptTree=new TChain("TrackerOptions");
00453 
00454   Int_t nf=0;
00455   //add the files to the chain
00456   for (vector<string>::iterator file=fileList.begin();
00457        file!=fileList.end();++file){
00458     
00459     //test if file already exists
00460     ifstream openOk((*file).c_str()); 
00461 
00462     //check if a wildcard was used because ifstream can't open wildcards
00463     Int_t stars=(*file).find("*");
00464     Int_t quest=(*file).find("?");
00465 
00466     //check if file existed
00467     if (!openOk && !(quest>=0 || stars>=0)){
00468       MSG("CDAnalysis",Msg::kInfo)
00469         <<endl<<endl
00470         <<"***********************************************************"
00471         <<endl<<"Can't find file="<<*file<<endl
00472         <<"Note: you can't use '~/'. It has to be the full path"<<endl
00473         <<"***********************************************************"
00474         <<endl<<endl
00475         <<"Exiting here!"<<endl;
00476       exit(0);
00477     }
00478     
00479     MSG("CDAnalysis",Msg::kInfo)<<"Adding file="<<*file<<endl;
00480     nf+=fTrackerTree->Add((*file).c_str());
00481     fOptTree->Add((*file).c_str());
00482   }
00483 
00484   if(nf==0){
00485     MSG("CDAnalysis",Msg::kFatal)
00486       <<endl<<endl
00487       <<"*************************************************************"
00488       <<endl<<"No Tracker*.root files found"<<endl
00489       <<"Please set CDDATA to the directory containing the"
00490       <<" Tracker*.root files"<<endl
00491       <<"Or give the txt file containing the files to be input"<<endl
00492       <<"Note: If more than one file is found they will be"
00493       <<" concatenated in a TChain and treated as one"<<endl
00494       <<"*************************************************************"
00495       <<endl<<endl<<"Program will exit here"<<endl;
00496     exit(0);
00497   }
00498     
00499   MSG("CDAnalysis",Msg::kInfo) 
00500     <<"Tracker Tree information:"<<endl;
00501   fTrackerTree->Show(0);
00502   MSG("CDAnalysis",Msg::kInfo) 
00503     <<"Options Tree information:"<<endl;
00504   fOptTree->Show(0);
00505   //fTrackerTree->Print()
00506   
00507   MSG("CDAnalysis",Msg::kInfo)
00508     <<endl<<"Analysing "<<nf<<" file(s). Reading from disk..."<<endl;
00509 }

vector< string > CDAnalysis::MakeFileList (  )  [private]

Check the fInputFileName first then check the env variable

Definition at line 381 of file CDAnalysis.cxx.

References exit(), fInputFileName, Msg::kDebug, Msg::kFatal, Msg::kInfo, and MSG.

Referenced by MakeChain().

00382 {
00384 
00385   vector<string> fileList;
00386   
00387   if (fInputFileName!=""){
00388     ifstream inputFile(fInputFileName.c_str());
00389 
00390     //check if file exists
00391     if (inputFile){
00392       //variables to hold input from file
00393       string file="";
00394    
00395       //read in from the text file and fill objects
00396       while(inputFile>>file) {
00397         MSG("CDAnalysis",Msg::kDebug)
00398           <<"Found input file name="<<file<<endl;
00399         fileList.push_back(file);
00400       }
00401       MSG("CDAnalysis",Msg::kDebug)
00402         <<"Files names found in txt file="<<fileList.size()<<endl;
00403     }
00404     else{
00405       MSG("CDAnalysis",Msg::kFatal)
00406         <<endl<<endl
00407         <<"***********************************************************"
00408         <<endl<<"Input txt file of file names does not exist!"<<endl
00409         <<"InputFileName="<<fInputFileName<<endl
00410         <<"***********************************************************"
00411         <<endl<<endl<<"Program will exit here"<<endl;
00412       exit(0);
00413     }
00414   }
00415   //return the fileList if files were found
00416   if (fileList.size()>0) return fileList;
00417   
00418   //Check the env variable to find files
00419   char* envVariable=getenv("CDDATA");
00420   if (envVariable==NULL){
00421     MSG("CDAnalysis",Msg::kFatal)
00422       <<endl<<endl
00423       <<"*************************************************************"
00424       <<endl<<"Environmental variable CDDATA not set!"<<endl
00425       <<"Please set CDDATA to the directory containing the"
00426       <<" Tracker*.root files"<<endl
00427       <<"Note: If more than one file is found they will be"
00428       <<" concatenated and treated as one"<<endl
00429       <<"*************************************************************"
00430       <<endl<<endl<<"Program will exit here"<<endl;
00431     exit(0);
00432   }
00433   string sEnv=envVariable;
00434   MSG("CDAnalysis",Msg::kInfo)
00435     <<"Looking for Tracker*.root files using the env variable"<<endl
00436     <<"CDDATA="<<sEnv<<endl;
00437   sEnv+="/Tracker*.root";
00438   fileList.push_back(sEnv);
00439 
00440   return fileList;
00441 }

void CDAnalysis::MuonCalorimetry (  ) 

Definition at line 10514 of file CDAnalysis.cxx.

References Munits::base_energy_name, CalcFirstLastPlane(), CalcLastPlaneOnTrkNoXTalk(), CutOnBadPedestals(), CutOnDeadChips(), CutOnEventLength(), CutOnPid(), CutOnTrackQuality(), fChargeSigCor, fEvents, fLastPlane, fOutFile, fPlane, fRatioScEnToBeamEn, fRunNumber, fScEnDepPerMEU, fSigCorPerMEU, fStrip, fStripend, fTrkHitInfo, fTruthHitInfo, fUnTrkHitInfo, fXTalkHits, GetMainParticleEnergy(), Munits::gigaelectronvolt, InitialiseLoopVariables(), Msg::kInfo, MSG, OpenFile(), ReadInHitInfo(), SetLoopVariables(), and StandardSanityChecks().

10515 {
10516   MSG("CDAnalysis",Msg::kInfo) 
10517     <<" ** Running MuonCalorimetry method... **"<<endl;
10518 
10519   //open the output file for the histograms
10520   fOutFile=this->OpenFile(fRunNumber,"MuonCal");
10521 
10522   TH1F *hSigCorTotal=new TH1F("hSigCorTotal","hSigCorTotal",1000,-2,75);
10523   hSigCorTotal->GetXaxis()->SetTitle("SigCors");
10524   hSigCorTotal->GetXaxis()->CenterTitle();
10525   hSigCorTotal->GetYaxis()->SetTitle("");
10526   hSigCorTotal->GetYaxis()->CenterTitle();
10527   hSigCorTotal->SetFillColor(0);
10528   hSigCorTotal->SetBit(TH1::kCanRebin);
10529 
10530   TH1F *hSigCorTotalTight=new TH1F("hSigCorTotalTight",
10531                                    "hSigCorTotalTight",1000,-2,75);
10532   hSigCorTotalTight->GetXaxis()->SetTitle("SigCors");
10533   hSigCorTotalTight->GetXaxis()->CenterTitle();
10534   hSigCorTotalTight->GetYaxis()->SetTitle("");
10535   hSigCorTotalTight->GetYaxis()->CenterTitle();
10536   hSigCorTotalTight->SetFillColor(0);
10537   hSigCorTotalTight->SetBit(TH1::kCanRebin);
10538 
10539   TH1F *hSigCorTotalPeak=new TH1F("hSigCorTotalPeak",
10540                                   "hSigCorTotalPeak",1000,-2,75);
10541   hSigCorTotalPeak->GetXaxis()->SetTitle("SigCors");
10542   hSigCorTotalPeak->GetXaxis()->CenterTitle();
10543   hSigCorTotalPeak->GetYaxis()->SetTitle("");
10544   hSigCorTotalPeak->GetYaxis()->CenterTitle();
10545   hSigCorTotalPeak->SetFillColor(0);
10546   hSigCorTotalPeak->SetBit(TH1::kCanRebin);
10547 
10548   TH1F *hEventLength=new TH1F("hEventLength","hEventLength hit",
10549                               77,-2,75);
10550   hEventLength->GetXaxis()->SetTitle("Event Length (planes)");
10551   hEventLength->GetXaxis()->CenterTitle();
10552   hEventLength->GetYaxis()->SetTitle("");
10553   hEventLength->GetYaxis()->CenterTitle();
10554   hEventLength->SetFillColor(0);
10555   hEventLength->SetBit(TH1::kCanRebin);
10556 
10557   TH1F *hEventLength2=new TH1F("hEventLength2","hEventLength",77,-2,75);
10558   hEventLength2->GetXaxis()->SetTitle("Event Length (planes)");
10559   hEventLength2->GetXaxis()->CenterTitle();
10560   hEventLength2->GetYaxis()->SetTitle("");
10561   hEventLength2->GetYaxis()->CenterTitle();
10562   hEventLength2->SetFillColor(0);
10563   hEventLength2->SetBit(TH1::kCanRebin);
10564 
10565   TH1F *hEventLength3=new TH1F("hEventLength3","hEventLength",77,-2,75);
10566   hEventLength3->SetTitle("Event Track Length");
10567   hEventLength3->GetXaxis()->SetTitle("Event Length (planes)");
10568   hEventLength3->GetXaxis()->CenterTitle();
10569   hEventLength3->GetYaxis()->SetTitle("");
10570   hEventLength3->GetYaxis()->CenterTitle();
10571   hEventLength3->SetFillColor(0);
10572   hEventLength3->SetBit(TH1::kCanRebin);
10573 
10574   TH1F *hMainEn=new TH1F("hMainEn","hMainEn",2000,-1,2);
10575   hMainEn->GetXaxis()->SetTitle("Beam Energy");
10576   hMainEn->GetXaxis()->CenterTitle();
10577   hMainEn->GetYaxis()->SetTitle("");
10578   hMainEn->GetYaxis()->CenterTitle();
10579   hMainEn->SetFillColor(0);
10580   hMainEn->SetBit(TH1::kCanRebin);
10581 
10582   TProfile* pEnVsRange=new TProfile("pEnVsRange","pEnVsRange",
10583                                     62,0,62);
10584   pEnVsRange->SetTitle
10585     ("Beam Energy from Calorimetry vs Range");
10586   pEnVsRange->GetXaxis()->SetTitle("Range (planes)");
10587   pEnVsRange->GetXaxis()->CenterTitle();
10588   pEnVsRange->GetYaxis()->SetTitle("Beam Energy");
10589   pEnVsRange->GetYaxis()->CenterTitle();
10590   pEnVsRange->SetFillColor(0);
10591 
10595   
10596   this->InitialiseLoopVariables();  
10597   
10598   for(Int_t event=0;event<fEvents;event++){
10599     
10600     this->SetLoopVariables(event);
10601 
10602     if (this->CutOnDeadChips()) continue;
10603     if (this->CutOnPid()) continue;
10604 
10605     Double_t sigCorTotal=0;
10606 
10607     //get the main particle energy
10608     hMainEn->Fill(this->GetMainParticleEnergy());
10609 
10610     //get tclones arrays for this snarl
10611     TClonesArray &cTrk=*fTrkHitInfo;
10612     Int_t numTrkHits=fTrkHitInfo->GetEntries();
10613     TClonesArray &cUnTrk = *fUnTrkHitInfo;
10614     Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
10615     //CDTrackedHitInfo *trackedHitInfo=(CDTrackedHitInfo*) c[hit];
10616     TClonesArray &cXTalk = *fXTalkHits;
10617     Int_t numXTalkHits=fXTalkHits->GetEntries();
10618     //TClonesArray &cTruth = *fTruthHitInfo;
10619     Int_t numTruthHits=0;
10620     if (fTruthHitInfo) numTruthHits=fTruthHitInfo->GetEntries();
10621 
10623     //loop over the untracked hits in the snarl
10625     for (Int_t hit=0;hit<numUnTrkHits;hit++){
10626       //cast the tclonesarray up to a trackedhitinfo object
10627       CDTrackedHitInfo *hitInfo=
10628         dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
10629 
10630       this->ReadInHitInfo(hitInfo);
10631 
10632       //cut out the bad channels
10633       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
10634 
10635       //check the channel's sanity
10636       this->StandardSanityChecks();
10637 
10638       if (fPlane==0) continue;
10639       //sum the sigcor in the event
10640       //make up for no plane 0 with 2 times plane 1
10641       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
10642       else sigCorTotal+=fChargeSigCor;
10643     }
10644 
10646     //loop over xtalk hits in the snarl
10648     for (Int_t hit=0;hit<numXTalkHits;hit++){
10649       CDXTalkHitInfo *hitInfo=
10650         dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
10651 
10652       this->ReadInHitInfo(hitInfo);
10653       
10654       //cut out the bad channels
10655       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
10656 
10657       //check the channel's sanity
10658       this->StandardSanityChecks();
10659 
10660       if (fPlane==0) continue;
10661       //sum the sigcor in the event
10662       //make up for no plane 0 with 2 times plane 1
10663       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
10664       else sigCorTotal+=fChargeSigCor;
10665     }
10666 
10668     //loop over the tracked hits
10670     for (Int_t hit=0;hit<numTrkHits;hit++){
10671       CDTrackedHitInfo *trackedHitInfo=
10672         dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
10673           
10674       this->ReadInHitInfo(trackedHitInfo);
10675 
10676       //cut out the bad channels
10677       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
10678 
10679       //check the channel's sanity
10680       this->StandardSanityChecks();
10681 
10682       //calculate the first and last planes
10683       this->CalcFirstLastPlane(fPlane);
10684 
10685       if (fPlane==0) continue;
10686       //sum the sigcor in the event
10687       //make up for no plane 0 with 2 times plane 1
10688       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
10689       else sigCorTotal+=fChargeSigCor;
10690     }
10692     //end of loop over the tracked hits
10694 
10695     hEventLength->Fill(fLastPlane+1);
10696 
10697     //make sure that the first plane makes sense and was actually set
10698     if (fFirstPlane<0 || fFirstPlane>59) continue;
10699 
10700     //calculate the event energy
10701     Double_t eventEn=(fScEnDepPerMEU/fSigCorPerMEU)*sigCorTotal*
10702       (1/fRatioScEnToBeamEn);
10703     //calc the last plane on the track with no xtalk
10704     Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
10705     hEventLength3->Fill(lastPlaneNoXTalk+1);
10706 
10707     //fill the prof
10708     pEnVsRange->Fill(lastPlaneNoXTalk+1,eventEn);
10709 
10710     //make event length cuts
10711     if (this->CutOnEventLength()) continue;
10712     //make track quality cuts
10713     if (this->CutOnTrackQuality()) continue;
10714 
10715     //fill the total sigcor histo
10716     hSigCorTotal->Fill(sigCorTotal);
10717 
10718     //fill event length plots for those passing cuts
10719     hEventLength2->Fill(fLastPlane+1);
10720 
10721     //look at a certain part of the spectrum
10722     if (lastPlaneNoXTalk+1>=50 && lastPlaneNoXTalk+1<53){//50,51,52
10723       //fill the total sigcor histo
10724       hSigCorTotalTight->Fill(sigCorTotal);
10725     }
10726     
10727     if (lastPlaneNoXTalk+1==51){
10728       //fill the total sigcor histo
10729       hSigCorTotalPeak->Fill(sigCorTotal);
10730     }
10731   }//end of for                                       
10732   
10736 
10737   MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
10738 
10739   //turn off the stats box printing
10740   gStyle->SetOptStat(0);
10741 
10742 
10743   //turn off the stats box printing
10744   //gStyle->SetOptStat(0);
10745   gStyle->SetOptStat(1111111);
10746 
10747   TCanvas *cGeom=new TCanvas("cGeom","Geom",0,0,1200,800);
10748   cGeom->SetFillColor(0);
10749   cGeom->Divide(2,2);
10750   cGeom->cd(1);
10751   hEventLength->Draw();
10752   cGeom->cd(2);
10753   hEventLength2->Draw();
10754   cGeom->cd(3);
10755   hEventLength3->Draw();
10756   cGeom->cd(3);
10757 
10758   TCanvas *cEnVsRange=new TCanvas("cEnVsRange","EnVsRange",
10759                                   0,0,1200,800);
10760   cEnVsRange->SetFillColor(0);
10761   cEnVsRange->Divide(1,2);
10762   cEnVsRange->cd(1);
10763   pEnVsRange->Draw();
10764   cEnVsRange->cd(2);
10765   hEventLength3->Draw();
10766 
10767   TCanvas *cSigCor=new TCanvas("cSigCor","SigCor",0,0,1200,800);
10768   cSigCor->SetFillColor(0);
10769   cSigCor->Divide(2,2);
10770   cSigCor->cd(1);
10771   hSigCorTotal->Draw();
10772   cSigCor->cd(2);
10773   hSigCorTotalTight->Draw();
10774   cSigCor->cd(3);
10775   hSigCorTotalPeak->Draw();
10776   cSigCor->cd(4);
10777   hMainEn->Draw();
10778 
10779   MSG("CDAnalysis",Msg::kInfo) 
10780     <<endl
10781     <<"Mean sigCorTotal="<<hSigCorTotal->GetMean()<<endl
10782     <<"Ratio ScEn to BeamEn="<<fRatioScEnToBeamEn
10783     <<" ("<<1/fRatioScEnToBeamEn<<")"<<endl
10784     <<"GeV per SigCor="<<fScEnDepPerMEU/fSigCorPerMEU<<endl
10785     <<"Beam energy from Calorimetry (lose)="
10786     <<((fScEnDepPerMEU/fSigCorPerMEU)*
10787     hSigCorTotal->GetMean()*(1/fRatioScEnToBeamEn))/
10788     Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl
10789     <<"Beam energy from Calorimetry (tight)="
10790     <<((fScEnDepPerMEU/fSigCorPerMEU)*
10791     hSigCorTotalTight->GetMean()*(1/fRatioScEnToBeamEn))/
10792     Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl
10793     <<"Beam energy from Calorimetry (peak)="
10794     <<((fScEnDepPerMEU/fSigCorPerMEU)*
10795     hSigCorTotalPeak->GetMean()*(1/fRatioScEnToBeamEn))/
10796     Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl<<endl;
10797 
10798   MSG("CDAnalysis",Msg::kInfo) 
10799     <<" ** Finished MuonCalorimetry method **"<<endl;
10800 }

void CDAnalysis::MuonNearFar (  ) 

Definition at line 6152 of file CDAnalysis.cxx.

References CalcFirstLastPlane(), count, CutOnBadPedestals(), CutOnDeadChips(), CutOnEventLength(), CutOnPid(), CutOnTrackQuality(), DrawResponsePlot(), fChargeAdc, fChargeMip, fChargePe, fChargeSigCor, fE1, fE2, fEvents, FillProfHisto(), fLastPlane, fLastPlaneEven, fLastPlaneOdd, fO1, fO2, Form(), fOutFile, fPlane, fRunNumber, fStrip, fStripend, fTrkHitInfo, fTruthHitInfo, fUnTrkHitInfo, fXTalkHits, InitialiseLoopVariables(), Msg::kDebug, Msg::kInfo, Msg::kVerbose, MAXMSG, MSG, OpenFile(), ReadInHitInfo(), SetLoopVariables(), and StandardSanityChecks().

06153 {
06154   MSG("CDAnalysis",Msg::kInfo) 
06155     <<" ** Running MuonNearFar method... **"<<endl;
06156 
06157   //open the output file for the histograms
06158   fOutFile=this->OpenFile(fRunNumber,"MuonNF");
06159 
06160   TH1F *h15_18All=new TH1F("h15_18All","h15_18All",1000,-2,75);
06161   h15_18All->GetXaxis()->SetTitle("SigCors");
06162   h15_18All->GetXaxis()->CenterTitle();
06163   h15_18All->GetYaxis()->SetTitle("");
06164   h15_18All->GetYaxis()->CenterTitle();
06165   h15_18All->SetFillColor(0);
06166   h15_18All->SetBit(TH1::kCanRebin);
06167 
06168   TH1F *h15_18=new TH1F("h15_18","h15_18",1000,-2,75);
06169   h15_18->GetXaxis()->SetTitle("SigCors");
06170   h15_18->GetXaxis()->CenterTitle();
06171   h15_18->GetYaxis()->SetTitle("");
06172   h15_18->GetYaxis()->CenterTitle();
06173   h15_18->SetFillColor(0);
06174   h15_18->SetBit(TH1::kCanRebin);
06175 
06176   TH1F *h15_18_O1=new TH1F("h15_18_O1","h15_18_O1",1000,-2,75);
06177   h15_18_O1->GetXaxis()->SetTitle("SigCors");
06178   h15_18_O1->GetXaxis()->CenterTitle();
06179   h15_18_O1->GetYaxis()->SetTitle("");
06180   h15_18_O1->GetYaxis()->CenterTitle();
06181   h15_18_O1->SetFillColor(0);
06182   h15_18_O1->SetBit(TH1::kCanRebin);
06183 
06184   TH1F *h15_18_E1=new TH1F("h15_18_E1","h15_18_E1",1000,-2,75);
06185   h15_18_E1->GetXaxis()->SetTitle("SigCors");
06186   h15_18_E1->GetXaxis()->CenterTitle();
06187   h15_18_E1->GetYaxis()->SetTitle("");
06188   h15_18_E1->GetYaxis()->CenterTitle();
06189   h15_18_E1->SetFillColor(0);
06190   h15_18_E1->SetBit(TH1::kCanRebin);
06191 
06192   TH1F *h15_18_O2=new TH1F("h15_18_O2","h15_18_O2",1000,-2,75);
06193   h15_18_O2->GetXaxis()->SetTitle("SigCors");
06194   h15_18_O2->GetXaxis()->CenterTitle();
06195   h15_18_O2->GetYaxis()->SetTitle("");
06196   h15_18_O2->GetYaxis()->CenterTitle();
06197   h15_18_O2->SetFillColor(0);
06198   h15_18_O2->SetBit(TH1::kCanRebin);
06199 
06200   TH1F *h15_18_E2=new TH1F("h15_18_E2","h15_18_E2",1000,-2,75);
06201   h15_18_E2->GetXaxis()->SetTitle("SigCors");
06202   h15_18_E2->GetXaxis()->CenterTitle();
06203   h15_18_E2->GetYaxis()->SetTitle("");
06204   h15_18_E2->GetYaxis()->CenterTitle();
06205   h15_18_E2->SetFillColor(0);
06206   h15_18_E2->SetBit(TH1::kCanRebin);
06207 
06208   //sum of all strip ends, normal and offset planes
06209   //tracked
06210   TProfile* pSigCorVsPlane=new TProfile("pSigCorVsPlane",
06211                                         "pSigCorVsPlane",
06212                                         62,0,62);
06213   TProfile* pSigCorVsOsPlane=new TProfile("pSigCorVsOsPlane",
06214                                           "pSigCorVsOsPlane",
06215                                           62,0,62);
06216 
06217   //xtalk + untracked hits
06218   TProfile* pSigCorVsPlaneX=new TProfile("pSigCorVsPlaneX",
06219                                          "pSigCorVsPlaneX",
06220                                          62,0,62);
06221   TProfile* pSigCorVsOsPlaneX=new TProfile("pSigCorVsOsPlaneX",
06222                                            "pSigCorVsOsPlaneX",
06223                                            62,0,62);
06224 
06225   //total
06226   TProfile* pSigCorVsPlaneT=new TProfile("pSigCorVsPlaneT",
06227                                          "pSigCorVsPlaneT",
06228                                          62,0,62);
06229   TProfile* pSigCorVsOsPlaneT=new TProfile("pSigCorVsOsPlaneT",
06230                                            "pSigCorVsOsPlaneT",
06231                                            62,0,62);
06232 
06233   //individual strip ends
06234   //tracked
06235   TProfile* pSigCorVsPlaneO1=new TProfile("pSigCorVsPlaneO1",
06236                                           "pSigCorVsPlaneO1",
06237                                           62,0,62);
06238   TProfile* pSigCorVsPlaneO2=new TProfile("pSigCorVsPlaneO2",
06239                                           "pSigCorVsPlaneO2",
06240                                           62,0,62);
06241   TProfile* pSigCorVsPlaneE1=new TProfile("pSigCorVsPlaneE1",
06242                                           "pSigCorVsPlaneE1",
06243                                           62,0,62);
06244   TProfile* pSigCorVsPlaneE2=new TProfile("pSigCorVsPlaneE2",
06245                                           "pSigCorVsPlaneE2",
06246                                           62,0,62);
06247   //xtalk + untracked hits
06248   TProfile* pSigCorVsPlaneO1X=new TProfile("pSigCorVsPlaneO1X",
06249                                           "pSigCorVsPlaneO1X",
06250                                           62,0,62);
06251   TProfile* pSigCorVsPlaneO2X=new TProfile("pSigCorVsPlaneO2X",
06252                                           "pSigCorVsPlaneO2X",
06253                                           62,0,62);
06254   TProfile* pSigCorVsPlaneE1X=new TProfile("pSigCorVsPlaneE1X",
06255                                           "pSigCorVsPlaneE1X",
06256                                           62,0,62);
06257   TProfile* pSigCorVsPlaneE2X=new TProfile("pSigCorVsPlaneE2X",
06258                                           "pSigCorVsPlaneE2X",
06259                                           62,0,62);
06260   //total
06261   TProfile* pSigCorVsPlaneO1T=new TProfile("pSigCorVsPlaneO1T",
06262                                           "pSigCorVsPlaneO1T",
06263                                           62,0,62);
06264   TProfile* pSigCorVsPlaneO2T=new TProfile("pSigCorVsPlaneO2T",
06265                                           "pSigCorVsPlaneO2T",
06266                                           62,0,62);
06267   TProfile* pSigCorVsPlaneE1T=new TProfile("pSigCorVsPlaneE1T",
06268                                           "pSigCorVsPlaneE1T",
06269                                           62,0,62);
06270   TProfile* pSigCorVsPlaneE2T=new TProfile("pSigCorVsPlaneE2T",
06271                                           "pSigCorVsPlaneE2T",
06272                                           62,0,62);
06273 
06274   //individual strip ends - offset planes
06275   //tracked
06276   TProfile* pSigCorVsOsPlaneO1=new TProfile("pSigCorVsOsPlaneO1",
06277                                             "pSigCorVsOsPlaneO1",
06278                                             62,0,62);
06279   TProfile* pSigCorVsOsPlaneO2=new TProfile("pSigCorVsOsPlaneO2",
06280                                             "pSigCorVsOsPlaneO2",
06281                                             62,0,62);
06282   TProfile* pSigCorVsOsPlaneE1=new TProfile("pSigCorVsOsPlaneE1",
06283                                             "pSigCorVsOsPlaneE1",
06284                                             62,0,62);
06285   TProfile* pSigCorVsOsPlaneE2=new TProfile("pSigCorVsOsPlaneE2",
06286                                             "pSigCorVsOsPlaneE2",
06287                                             62,0,62);
06288 
06289   //xtalk + untracked hits
06290   TProfile* pSigCorVsOsPlaneO1X=new TProfile("pSigCorVsOsPlaneO1X",
06291                                              "pSigCorVsOsPlaneO1X",
06292                                              62,0,62);
06293   TProfile* pSigCorVsOsPlaneO2X=new TProfile("pSigCorVsOsPlaneO2X",
06294                                             "pSigCorVsOsPlaneO2X",
06295                                             62,0,62);
06296   TProfile* pSigCorVsOsPlaneE1X=new TProfile("pSigCorVsOsPlaneE1X",
06297                                             "pSigCorVsOsPlaneE1X",
06298                                             62,0,62);
06299   TProfile* pSigCorVsOsPlaneE2X=new TProfile("pSigCorVsOsPlaneE2X",
06300                                             "pSigCorVsOsPlaneE2X",
06301                                             62,0,62);
06302   //total
06303   TProfile* pSigCorVsOsPlaneO1T=new TProfile("pSigCorVsOsPlaneO1T",
06304                                             "pSigCorVsOsPlaneO1T",
06305                                             62,0,62);
06306   TProfile* pSigCorVsOsPlaneO2T=new TProfile("pSigCorVsOsPlaneO2T",
06307                                             "pSigCorVsOsPlaneO2T",
06308                                             62,0,62);
06309   TProfile* pSigCorVsOsPlaneE1T=new TProfile("pSigCorVsOsPlaneE1T",
06310                                             "pSigCorVsOsPlaneE1T",
06311                                             62,0,62);
06312   TProfile* pSigCorVsOsPlaneE2T=new TProfile("pSigCorVsOsPlaneE2T",
06313                                             "pSigCorVsOsPlaneE2T",
06314                                             62,0,62);
06315 
06316 
06317   //near/far differences
06318   TProfile* pNearFarOdd=new TProfile("pNearFarOdd",
06319                                      "pNearFarOdd",62,0,62);
06320   TProfile* pNearFarEven=new TProfile("pNearFarEven",
06321                                       "pNearFarEven",62,0,62);
06322 
06323 
06324   vector<TProfile*> pSigCorVsDist;
06325   vector<Int_t> vWindowSize;
06326   vector<Float_t> bigAv;
06327   vector<Int_t> bigAvCounter;
06328   Float_t sum15_18=0;
06329   Float_t sum15_18Counter=0;
06330   Float_t sum15_18Mip=0;
06331   Float_t sum15_18MipCounter=0;
06332   Float_t sumSigCorTotal=0;
06333   Float_t sumSigCorTotalCounter=0;
06334   Float_t sumMipTotal=0;
06335   Float_t sumMipTotalCounter=0;
06336 
06337   //variables to calculate the energy dep for different stripends
06338   Float_t sum15_18_O1=0;
06339   Float_t sum15_18CounterO1=0;
06340   Float_t sum15_18_O2=0;
06341   Float_t sum15_18CounterO2=0;
06342   Float_t sum15_18_E1=0;
06343   Float_t sum15_18CounterE1=0;
06344   Float_t sum15_18_E2=0;
06345   Float_t sum15_18CounterE2=0;
06346 
06347   //num maps for all stripends
06348   map<Int_t,Float_t> num;
06349   map<Int_t,Float_t> numX;
06350   map<Int_t,Float_t> numT;
06351   map<Int_t,Float_t> numOs;
06352   map<Int_t,Float_t> numOsX;
06353   map<Int_t,Float_t> numOsT;
06354 
06355   //non-offset num maps for individual stripends
06356   map<Int_t,Float_t> numO1;
06357   map<Int_t,Float_t> numO1X;
06358   map<Int_t,Float_t> numO1T;
06359   map<Int_t,Float_t> numO2;
06360   map<Int_t,Float_t> numO2X;
06361   map<Int_t,Float_t> numO2T;
06362   map<Int_t,Float_t> numE1;
06363   map<Int_t,Float_t> numE1X;
06364   map<Int_t,Float_t> numE1T;
06365   map<Int_t,Float_t> numE2;
06366   map<Int_t,Float_t> numE2X;
06367   map<Int_t,Float_t> numE2T;
06368 
06369   //offset num maps for individual stripends
06370   map<Int_t,Float_t> numOsO1;
06371   map<Int_t,Float_t> numOsO1X;
06372   map<Int_t,Float_t> numOsO1T;
06373   map<Int_t,Float_t> numOsO2;
06374   map<Int_t,Float_t> numOsO2X;
06375   map<Int_t,Float_t> numOsO2T;
06376   map<Int_t,Float_t> numOsE1;
06377   map<Int_t,Float_t> numOsE1X;
06378   map<Int_t,Float_t> numOsE1T;
06379   map<Int_t,Float_t> numOsE2;
06380   map<Int_t,Float_t> numOsE2X;
06381   map<Int_t,Float_t> numOsE2T;
06382 
06383   Int_t noTrackCounter=0;
06384   Int_t passPidCounter=0;
06385  
06389   
06390   this->InitialiseLoopVariables();  
06391   
06392   for(Int_t event=0;event<fEvents;event++){
06393     
06394     this->SetLoopVariables(event);
06395 
06396     if (this->CutOnDeadChips()) continue;
06397     if (this->CutOnPid()) continue;
06398 
06399     //cut on not straight tracks
06400     //Double_t mainX1Cut=0.5;
06401     //if (!this->IsStraightTrack(mainX1Cut)){
06402     //continue;
06403     //}
06404 
06405     //count the number of events passing the pid
06406     passPidCounter++;
06407 
06408     map<Int_t,Int_t> numPlanesHit;
06409     map<Int_t,Int_t> numPlanesHit1;
06410     map<Int_t,Int_t> numPlanesHit2;
06411     map<Int_t,Int_t> numPlanesHitAll;
06412     map<Int_t,Float_t> planeSigCor;
06413     map<Int_t,Float_t> planeSigCorX;
06414     map<Int_t,Float_t> planeSigCorT;
06415     map<Int_t,Float_t> planeSigCorO1;    
06416     map<Int_t,Float_t> planeSigCorO1X;
06417     map<Int_t,Float_t> planeSigCorO1T;
06418     map<Int_t,Float_t> planeSigCorO2;
06419     map<Int_t,Float_t> planeSigCorO2X;
06420     map<Int_t,Float_t> planeSigCorO2T;
06421     map<Int_t,Float_t> planeSigCorE1;
06422     map<Int_t,Float_t> planeSigCorE1X;
06423     map<Int_t,Float_t> planeSigCorE1T;
06424     map<Int_t,Float_t> planeSigCorE2;
06425     map<Int_t,Float_t> planeSigCorE2X;
06426     map<Int_t,Float_t> planeSigCorE2T;
06427 
06428     map<Int_t,Float_t> planeMip;
06429     map<Int_t,Float_t> planeMipX;
06430     map<Int_t,Float_t> planeMipT;
06431 
06432     map<Int_t,Float_t> planePe;
06433     map<Int_t,Float_t> planeGreatestPe;
06434 
06435     //get tclones arrays for this snarl
06436     TClonesArray &cTrk=*fTrkHitInfo;
06437     Int_t numTrkHits=fTrkHitInfo->GetEntries();
06438     TClonesArray &cUnTrk = *fUnTrkHitInfo;
06439     Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
06440     //CDTrackedHitInfo *trackedHitInfo=(CDTrackedHitInfo*) c[hit];
06441     TClonesArray &cXTalk = *fXTalkHits;
06442     Int_t numXTalkHits=fXTalkHits->GetEntries();
06443     //TClonesArray &cTruth = *fTruthHitInfo;
06444     Int_t numTruthHits=0;
06445     if (fTruthHitInfo) numTruthHits=fTruthHitInfo->GetEntries();
06446 
06447     //look for untracked big events
06448     if (numTrkHits<2 && numXTalkHits+numUnTrkHits>1){
06449       MSG("CDAnalysis",Msg::kDebug)
06450         <<"Event="<<event
06451         <<", Num hits: trk="<<numTrkHits<<", unTrk="<<numUnTrkHits
06452         <<", xtalk="<<numXTalkHits<<", truth="<<numTruthHits
06453         <<endl;
06454       noTrackCounter++;
06455       //continue;
06456     }
06457 
06459     //loop over the untracked hits in the snarl
06461     for (Int_t hit=0;hit<numUnTrkHits;hit++){
06462       //cast the tclonesarray up to a trackedhitinfo object
06463       CDTrackedHitInfo *hitInfo=
06464         dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
06465 
06466       this->ReadInHitInfo(hitInfo);
06467 
06468       if (fPlane==0 && fChargeSigCor>1000){
06469         MSG("CDAnalysis",Msg::kDebug)
06470           <<"XTalk Event="<<event
06471           <<", fPlane="<<fPlane
06472           <<", fStrip="<<fStrip
06473           <<", fStripend="<<fStripend
06474           <<", fChargeAdc="<<fChargeAdc
06475           <<", fSigCor="<<fChargeSigCor<<endl;
06476       }
06477 
06478       //cut out the bad channels
06479       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06480 
06481       //count the number of planes hit
06482       numPlanesHitAll[fPlane]++;
06483 
06484       //check the channel's sanity
06485       this->StandardSanityChecks();
06486 
06487       //add up the charge of the hits in each plane
06488       planeSigCorX[fPlane]+=fChargeSigCor;
06489       planeSigCorT[fPlane]+=fChargeSigCor;
06490       planeMipX[fPlane]+=fChargeMip;
06491       planeMipT[fPlane]+=fChargeMip;
06492       if (fO1) planeSigCorO1X[fPlane]+=fChargeSigCor;
06493       if (fO2) planeSigCorO2X[fPlane]+=fChargeSigCor;
06494       if (fE1) planeSigCorE1X[fPlane]+=fChargeSigCor;
06495       if (fE2) planeSigCorE2X[fPlane]+=fChargeSigCor;
06496       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
06497       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
06498       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
06499       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
06500 
06501       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
06502                                                fChargePe;
06503     }
06504 
06506     //loop over xtalk hits in the snarl
06508     for (Int_t hit=0;hit<numXTalkHits;hit++){
06509       CDXTalkHitInfo *hitInfo=
06510         dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
06511 
06512       this->ReadInHitInfo(hitInfo);
06513       
06514       //cut out the bad channels
06515       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06516 
06517       //count the number of planes hit
06518       numPlanesHitAll[fPlane]++;
06519 
06520       //check the channel's sanity
06521       this->StandardSanityChecks();
06522 
06523       //add up the charge of the hits in each plane
06524       planeSigCorX[fPlane]+=fChargeSigCor;
06525       planeSigCorT[fPlane]+=fChargeSigCor;
06526       planeMipX[fPlane]+=fChargeMip;
06527       planeMipT[fPlane]+=fChargeMip;
06528       if (fO1) planeSigCorO1X[fPlane]+=fChargeSigCor;
06529       if (fO2) planeSigCorO2X[fPlane]+=fChargeSigCor;
06530       if (fE1) planeSigCorE1X[fPlane]+=fChargeSigCor;
06531       if (fE2) planeSigCorE2X[fPlane]+=fChargeSigCor;
06532       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
06533       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
06534       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
06535       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
06536 
06537       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
06538                                                fChargePe;
06539     }
06540 
06541     Bool_t lastPlaneO1Hit=false;
06542     Bool_t lastPlaneO2Hit=false;
06543     Bool_t lastPlaneE1Hit=false;
06544     Bool_t lastPlaneE2Hit=false;
06545     Int_t previousfLastPlane=-1;
06546 
06548     //loop over the tracked hits
06550     for (Int_t hit=0;hit<numTrkHits;hit++){
06551       CDTrackedHitInfo *trackedHitInfo=
06552         dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
06553           
06554       this->ReadInHitInfo(trackedHitInfo);
06555 
06556       //cut out the bad channels
06557       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06558 
06559       //check the channel's sanity
06560       this->StandardSanityChecks();
06561 
06562       //calculate the first and last planes
06563       this->CalcFirstLastPlane(fPlane);
06564 
06565       //count the number of planes hit
06566       numPlanesHit[fPlane]++;
06567       numPlanesHitAll[fPlane]++;
06568 
06569      if (fLastPlane==fPlane && fPlane%2==0){
06570 
06571         //check if a new last plane has been found
06572         if (fLastPlane!=previousfLastPlane){
06573           lastPlaneE1Hit=false;
06574           lastPlaneE2Hit=false;
06575         }
06576         previousfLastPlane=fLastPlane;
06577 
06578         //check which stripend to set to true
06579         if (fStripend==1) lastPlaneE1Hit=true;
06580         if (fStripend==2) lastPlaneE2Hit=true;
06581 
06582         //set the hits in the other plane to be false
06583         lastPlaneO1Hit=false;
06584         lastPlaneO2Hit=false;
06585         MSG("CDAnalysis",Msg::kVerbose)
06586           <<"ev="<<event
06587           <<", last="<<fLastPlane
06588           <<", pl="<<fPlane
06589           <<", se="<<fStripend
06590           <<", E1="<<lastPlaneE1Hit
06591           <<", E2="<<lastPlaneE2Hit
06592           <<", O1="<<lastPlaneO1Hit
06593           <<", O2="<<lastPlaneO2Hit<<endl;
06594       }
06595       else if (fLastPlane==fPlane && fPlane%2==1){
06596 
06597         //check if a new last plane has been found
06598         if (fLastPlane!=previousfLastPlane){
06599           lastPlaneO1Hit=false;
06600           lastPlaneO2Hit=false;
06601         }
06602         previousfLastPlane=fLastPlane;
06603 
06604         //check which stripend to set to true
06605         if (fStripend==1) lastPlaneO1Hit=true;
06606         if (fStripend==2) lastPlaneO2Hit=true;
06607 
06608         //set the hits in the other plane to be false
06609         lastPlaneE1Hit=false;
06610         lastPlaneE2Hit=false;
06611 
06612         MSG("CDAnalysis",Msg::kVerbose)
06613           <<"ev="<<event
06614           <<", last="<<fLastPlane
06615           <<", pl="<<fPlane
06616           <<", se="<<fStripend
06617           <<", E1="<<lastPlaneE1Hit
06618           <<", E2="<<lastPlaneE2Hit
06619           <<", O1="<<lastPlaneO1Hit
06620           <<", O2="<<lastPlaneO2Hit<<endl;
06621       }
06622 
06623       //add up the charge of the hits in each plane
06624       planeSigCor[fPlane]+=fChargeSigCor;
06625       planeSigCorT[fPlane]+=fChargeSigCor;
06626       planeMip[fPlane]+=fChargeMip;
06627       planeMipT[fPlane]+=fChargeMip;
06628       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
06629                                                fChargePe;
06630       planePe[fPlane]+=fChargePe;
06631       if (fO1) planeSigCorO1[fPlane]+=fChargeSigCor;
06632       if (fO2) planeSigCorO2[fPlane]+=fChargeSigCor;
06633       if (fE1) planeSigCorE1[fPlane]+=fChargeSigCor;
06634       if (fE2) planeSigCorE2[fPlane]+=fChargeSigCor;
06635       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
06636       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
06637       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
06638       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
06639     }
06641     //end of loop over the tracked hits
06643 
06644     //make sure that the first plane makes sense and was actually set
06645     if (fFirstPlane<0 || fFirstPlane>59) continue;
06646 
06647     //calc the last plane on the track with no xtalk
06648     //Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
06649 
06650     //make event length cuts
06651     if (this->CutOnEventLength()) continue;
06652     //make track quality cuts
06653     if (this->CutOnTrackQuality()) continue;
06654 
06656     //section for response
06658     const Int_t os=fLastPlane;
06659 
06660     //must fill the profs before looping over the maps because
06661     //zeros will get added to the maps at the window stage!
06662     //fill profs for all stripends
06663     this->FillProfHisto(pSigCorVsPlane,num,planeSigCor);
06664     this->FillProfHisto(pSigCorVsPlaneX,numX,planeSigCorX);
06665     this->FillProfHisto(pSigCorVsPlaneT,numT,planeSigCorT);
06666     //offset
06667     this->FillProfHisto(pSigCorVsOsPlane,numOs,planeSigCor,os);
06668     this->FillProfHisto(pSigCorVsOsPlaneX,numOsX,planeSigCorX,os);
06669     this->FillProfHisto(pSigCorVsOsPlaneT,numOsT,planeSigCorT,os);
06670 
06671     //fill non-offset profs for individual stripends
06672     this->FillProfHisto(pSigCorVsPlaneO1,numO1,planeSigCorO1);
06673     this->FillProfHisto(pSigCorVsPlaneO1X,numO1X,planeSigCorO1X);
06674     this->FillProfHisto(pSigCorVsPlaneO1T,numO1T,planeSigCorO1T);
06675     this->FillProfHisto(pSigCorVsPlaneO2,numO2,planeSigCorO2);
06676     this->FillProfHisto(pSigCorVsPlaneO2X,numO2X,planeSigCorO2X);
06677     this->FillProfHisto(pSigCorVsPlaneO2T,numO2T,planeSigCorO2T);
06678     this->FillProfHisto(pSigCorVsPlaneE1,numE1,planeSigCorE1);
06679     this->FillProfHisto(pSigCorVsPlaneE1X,numE1X,planeSigCorE1X);
06680     this->FillProfHisto(pSigCorVsPlaneE1T,numE1T,planeSigCorE1T);
06681     this->FillProfHisto(pSigCorVsPlaneE2,numE2,planeSigCorE2);
06682     this->FillProfHisto(pSigCorVsPlaneE2X,numE2X,planeSigCorE2X);
06683     this->FillProfHisto(pSigCorVsPlaneE2T,numE2T,planeSigCorE2T);
06684 
06685     //fill offset profs for individual stripends
06686     this->FillProfHisto(pSigCorVsOsPlaneO1,numOsO1,planeSigCorO1,os);
06687     this->FillProfHisto(pSigCorVsOsPlaneO1X,numOsO1X,planeSigCorO1X,os);
06688     this->FillProfHisto(pSigCorVsOsPlaneO1T,numOsO1T,planeSigCorO1T,os);
06689     this->FillProfHisto(pSigCorVsOsPlaneO2,numOsO2,planeSigCorO2,os);
06690     this->FillProfHisto(pSigCorVsOsPlaneO2X,numOsO2X,planeSigCorO2X,os);
06691     this->FillProfHisto(pSigCorVsOsPlaneO2T,numOsO2T,planeSigCorO2T,os);
06692     this->FillProfHisto(pSigCorVsOsPlaneE1,numOsE1,planeSigCorE1,os);
06693     this->FillProfHisto(pSigCorVsOsPlaneE1X,numOsE1X,planeSigCorE1X,os);
06694     this->FillProfHisto(pSigCorVsOsPlaneE1T,numOsE1T,planeSigCorE1T,os);
06695     this->FillProfHisto(pSigCorVsOsPlaneE2,numOsE2,planeSigCorE2,os);
06696     this->FillProfHisto(pSigCorVsOsPlaneE2X,numOsE2X,planeSigCorE2X,os);
06697     this->FillProfHisto(pSigCorVsOsPlaneE2T,numOsE2T,planeSigCorE2T,os);
06698 
06700     //section for total event sigcor and mips
06702     Float_t localSumSigCorTotal=0;
06703     Float_t localSumSigCorTotalCounter=0;
06704     for (map<Int_t,Float_t>::iterator sig=planeSigCorT.begin();
06705          sig!=planeSigCorT.end();++sig){
06706       localSumSigCorTotal+=sig->second;
06707       localSumSigCorTotalCounter++;
06708     }
06709 
06710     //add total of this event to the sum of all events 
06711     if (localSumSigCorTotalCounter!=0){
06712       sumSigCorTotal+=localSumSigCorTotal;
06713       sumSigCorTotalCounter++;
06714     }
06715 
06716     Float_t localSumMipTotal=0;
06717     Float_t localSumMipTotalCounter=0;
06718     for (map<Int_t,Float_t>::iterator sig=planeMipT.begin();
06719          sig!=planeMipT.end();++sig){
06720       localSumMipTotal+=sig->second;
06721       localSumMipTotalCounter++;
06722     }
06723 
06724     //add total of this event to the sum of all events 
06725     if (localSumMipTotalCounter!=0){
06726       sumMipTotal+=localSumMipTotal;
06727       sumMipTotalCounter++;
06728     }
06729 
06731     //section for sliding window
06733     Int_t minEventLength=35;
06734     if (fLastPlane<minEventLength) continue;
06735 
06736     //initialise the profile histos
06737     static Bool_t firstTime=true;
06738     if (firstTime){
06739       for (Int_t p=15;p>1;p--){
06740         vWindowSize.push_back(p);
06741         bigAv.push_back(0);
06742         bigAvCounter.push_back(0);
06743       }
06744 
06745       for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
06746            windowSize!=vWindowSize.end();++windowSize){
06747         
06748         string sName=Form("%d",*windowSize);
06749         pSigCorVsDist.push_back
06750           (new TProfile(("pSigCorVsDist"+sName).c_str(),
06751                         ("pSigCorVsDist"+sName).c_str(),100,-2,40));
06752       }
06753     }
06754     firstTime=false;
06755 
06756     vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
06757     vector<Float_t>::iterator av=bigAv.begin();
06758     vector<Int_t>::iterator count=bigAvCounter.begin();
06759     Float_t localSum15_18=0;
06760     Float_t localSum15_18Counter=0;
06761     Float_t localSum15_18Mip=0;
06762     Float_t localSum15_18MipCounter=0;
06763 
06764     Float_t localSum15_18_O1=0;
06765     Float_t localSum15_18CounterO1=0;
06766     Float_t localSum15_18_O2=0;
06767     Float_t localSum15_18CounterO2=0;
06768     Float_t localSum15_18_E1=0;
06769     Float_t localSum15_18CounterE1=0;
06770     Float_t localSum15_18_E2=0;
06771     Float_t localSum15_18CounterE2=0;
06772     Bool_t oneMoreEvenPlane=false;
06773 
06774     //loop over the different window sizes
06775     for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
06776          windowSize!=vWindowSize.end();++windowSize){
06777       
06778       Float_t localSumO1=0;
06779       Float_t localSumCounterO1=0;
06780       Float_t localSumO2=0;
06781       Float_t localSumCounterO2=0;
06782       Float_t localSumE1=0;
06783       Float_t localSumCounterE1=0;
06784       Float_t localSumE2=0;
06785       Float_t localSumCounterE2=0;
06786 
06787       //slide the window along from the end to 40-windowSize
06788       for (Int_t p=0;p<minEventLength-*windowSize;p++){
06789         Int_t windowStart=fLastPlane-p;
06790 
06791         MSG("CDAnalysis",Msg::kVerbose)
06792           <<"Window size="<<*windowSize
06793           <<", window start="<<windowStart
06794           <<endl;
06795 
06796         //loop through the hits in the window
06797         for (Int_t i=0;i<*windowSize;i++){
06798           Int_t plane=windowStart-i;
06799           
06800           //cut out planes that are greater than the last plane
06801           //in the view - ie the zeros at the end
06802           Bool_t doZeroCorrection=false;
06803           if (doZeroCorrection && 
06804               ((plane%2==0 && plane>fLastPlaneEven) || 
06805                (plane%2!=0 && plane>fLastPlaneOdd))){
06806             MSG("CDAnalysis",Msg::kVerbose)
06807               <<"Not using: Event="<<event
06808               <<", pl="<<plane
06809               <<", sigCor="<<planeSigCorT[plane]
06810               <<", fLastPlane="<<fLastPlane
06811               <<", fLastPlSig="<<planeSigCorT[fLastPlane]
06812               <<", fLastPlOdd="<<fLastPlaneOdd
06813               <<", fLastPlEven="<<fLastPlaneEven
06814               <<endl;
06815           }
06816           else{
06817 
06818             //calculate the best window value
06819             //if fLP=48 then the first plane included is 30
06820             //this is actually the 19th from the end of the track
06821             if (*windowSize==15 && windowStart==fLastPlane-18){
06822               localSum15_18+=planeSigCorT[plane];//total including xtalk
06823               localSum15_18Counter++;
06824               localSum15_18Mip+=planeMipT[plane];//total including xtalk
06825               localSum15_18MipCounter++;
06826 
06827               //a 15 plane window means 7 even and 8 odd or vice versa!
06828               if (windowStart%2==0) oneMoreEvenPlane=true;
06829 
06830               //look at the individual stripends
06831               if (plane%2==0){//even
06832                 localSum15_18_E1+=planeSigCorE1T[plane];
06833                 localSum15_18CounterE1++;
06834                 localSum15_18_E2+=planeSigCorE2T[plane];
06835                 localSum15_18CounterE2++;
06836               }
06837               else if (plane%2==1){//odd
06838                 localSum15_18_O1+=planeSigCorO1T[plane];
06839                 localSum15_18CounterO1++;
06840                 localSum15_18_O2+=planeSigCorO2T[plane];
06841                 localSum15_18CounterO2++;
06842               }
06843             }
06844 
06845 
06846             if (*windowSize==15){
06847               //look at the individual stripends
06848               if (plane%2==0){//even
06849                 localSumE1+=planeSigCorE1T[plane];
06850                 localSumCounterE1++;
06851                 localSumE2+=planeSigCorE2T[plane];
06852                 localSumCounterE2++;
06853               }
06854               else if (plane%2==1){//odd
06855                 localSumO1+=planeSigCorO1T[plane];
06856                 localSumCounterO1++;
06857                 localSumO2+=planeSigCorO2T[plane];
06858                 localSumCounterO2++;
06859               }
06860             }
06861 
06862             (*prof)->Fill(p,planeSigCorT[plane]);
06863             (*av)+=planeSigCorT[plane];
06864             (*count)++;
06865           }
06866         }
06867 
06868         //calculate the near/far differences
06869         if (*windowSize==15){
06870 
06871           //a 15 plane window means 7 even and 8 odd or vice versa!
06872           Bool_t moreEven=false;
06873           if (windowStart%2==0) moreEven=true;
06874           Float_t divEven=1;
06875           Float_t divOdd=1;
06876 
06877           if (moreEven) {divEven=8; divOdd=7;}
06878           else {divEven=7; divOdd=8;}
06879 
06880           MAXMSG("CDAnalysis",Msg::kVerbose,70)
06881             <<"WindowStart="<<windowStart<<", moreEven="<<moreEven
06882             <<", divEven="<<divEven<<", divOdd="<<divOdd
06883             <<endl;
06884     
06885           Float_t largestOdd=localSumO1/divOdd;
06886           Float_t largestEven=localSumE1/divEven;
06887           
06888           if (localSumO2/divOdd>localSumO1/divOdd){
06889             largestOdd=localSumO2/divOdd;
06890           }
06891           if (localSumE2/divEven>localSumE1/divEven){
06892             largestEven=localSumE2/divEven;
06893           }
06894 
06895           //protect fpe
06896           if (largestOdd>0){
06897             Float_t diffNearFarOdd=100*(localSumO1/divOdd-
06898                                         localSumO2/divOdd)/largestOdd;
06899             pNearFarOdd->Fill(p,diffNearFarOdd);
06900           }
06901           if (largestEven>0){
06902             Float_t diffNearFarEven=100*(localSumE1/divEven-
06903                                          localSumE2/divEven
06904                                          )/largestEven;
06905             pNearFarEven->Fill(p,diffNearFarEven);
06906           }      
06907         }
06908       }
06909       av++;
06910       count++;
06911       prof++;
06912     }
06913 
06914     if (localSum15_18Counter!=0){
06915       h15_18All->Fill(localSum15_18);
06916       h15_18->Fill(localSum15_18/15);
06917       sum15_18+=localSum15_18;//add this event's energy on to total
06918       sum15_18Counter++;
06919       sum15_18Mip+=localSum15_18Mip;
06920       sum15_18MipCounter++;
06921     }
06922     else{
06923       MAXMSG("CDAnalysis",Msg::kInfo,40)
06924         <<"Event="<<event<<", strange 15_18="<<localSum15_18
06925         <<", counter="<<localSum15_18Counter<<endl;
06926     }
06927 
06928     Float_t divEven=1;
06929     Float_t divOdd=1;
06930     
06931     if (oneMoreEvenPlane) {divEven=8; divOdd=7;}
06932     else {divEven=7; divOdd=8;}
06933     
06934     h15_18_O1->Fill(localSum15_18_O1/divOdd);
06935     sum15_18_O1+=localSum15_18_O1/divOdd;
06936     sum15_18CounterO1++;
06937     h15_18_O2->Fill(localSum15_18_O2/divOdd);
06938     sum15_18_O2+=localSum15_18_O2/divOdd;
06939     sum15_18CounterO2++;
06940     
06941     h15_18_E1->Fill(localSum15_18_E1/divEven);
06942     sum15_18_E1+=localSum15_18_E1/divEven;
06943     sum15_18CounterE1++;
06944     h15_18_E2->Fill(localSum15_18_E2/divEven);
06945     sum15_18_E2+=localSum15_18_E2/divEven;
06946     sum15_18CounterE2++;
06947 
06948   }//end of for                                       
06949   
06953 
06954   MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06955 
06956   //turn off the stats box printing
06957   gStyle->SetOptStat(0);
06958 
06959   //all stripends
06960   string sTitle="Energy Deposition (SigCor, all Stripends)";
06961   string sXTitle="Distance from end of track (planes)";
06962   this->DrawResponsePlot(sTitle,pSigCorVsPlane,pSigCorVsPlaneX,
06963                          pSigCorVsPlaneT,num,numX,numT);
06964   sTitle="Energy Deposition Vs Distance (SigCor, all Stripends)";
06965   this->DrawResponsePlot(sTitle,pSigCorVsOsPlane,pSigCorVsOsPlaneX,
06966                          pSigCorVsOsPlaneT,numOs,numOsX,numOsT,sXTitle);
06967 
06968   //non-offset planes
06969   sTitle="Energy Deposition (SigCor in Odd Planes FD stripend)";
06970   this->DrawResponsePlot(sTitle,pSigCorVsPlaneO1,pSigCorVsPlaneO1X,
06971                          pSigCorVsPlaneO1T,numO1,numO1X,numO1T);
06972 
06973   sTitle="Energy Deposition (SigCor in Odd Planes ND stripend)";
06974   this->DrawResponsePlot(sTitle,pSigCorVsPlaneO2,pSigCorVsPlaneO2X,
06975                          pSigCorVsPlaneO2T,numO2,numO2X,numO2T);
06976 
06977   sTitle="Energy Deposition (SigCor in Even Planes FD stripend)";
06978   this->DrawResponsePlot(sTitle,pSigCorVsPlaneE1,pSigCorVsPlaneE1X,
06979                          pSigCorVsPlaneE1T,numE1,numE1X,numE1T);
06980 
06981   sTitle="Energy Deposition (SigCor in Even Planes ND stripend)";
06982   this->DrawResponsePlot(sTitle,pSigCorVsPlaneE2,pSigCorVsPlaneE2X,
06983                          pSigCorVsPlaneE2T,numE2,numE2X,numE2T);
06984 
06985   //offset planes
06986   sTitle="Energy Deposition Vs Distance (SigCor in Odd Planes FD stripend)";
06987   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneO1,pSigCorVsOsPlaneO1X,
06988                          pSigCorVsOsPlaneO1T,numOsO1,numOsO1X,numOsO1T,
06989                          sXTitle);
06990 
06991   sTitle="Energy Deposition Vs Distance (SigCor in Odd Planes ND stripend)";
06992   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneO2,pSigCorVsOsPlaneO2X,
06993                          pSigCorVsOsPlaneO2T,numOsO2,numOsO2X,numOsO2T,
06994                          sXTitle);
06995 
06996   sTitle="Energy Deposition Vs Distance (SigCor in Even Planes FD stripend)";
06997   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneE1,pSigCorVsOsPlaneE1X,
06998                          pSigCorVsOsPlaneE1T,numOsE1,numOsE1X,numOsE1T,
06999                          sXTitle);
07000 
07001   sTitle="Energy Deposition Vs Distance (SigCor in Even Planes ND stripend)";
07002   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneE2,pSigCorVsOsPlaneE2X,
07003                          pSigCorVsOsPlaneE2T,numOsE2,numOsE2X,numOsE2T,
07004                          sXTitle);
07005 
07006   //turn on the stats box printing
07007   gStyle->SetOptStat(111111);
07008 
07009   TCanvas *c15_18=new TCanvas("c15_18","15_18",0,0,1200,800);
07010   c15_18->SetFillColor(0);
07011   c15_18->Divide(2,3);
07012   c15_18->cd(1);
07013   h15_18->Draw();
07014   c15_18->cd(2);
07015   h15_18All->Draw();
07016   c15_18->cd(3);
07017   h15_18_O1->Draw();
07018   c15_18->cd(4);
07019   h15_18_O2->Draw();
07020   c15_18->cd(5);
07021   h15_18_E1->Draw();
07022   c15_18->cd(6);
07023   h15_18_E2->Draw();
07024 
07025   TCanvas *cNearFar=new TCanvas("cNearFar","NearFar",0,0,1200,800);
07026   cNearFar->SetFillColor(0);
07027   cNearFar->Divide(2,3);
07028   cNearFar->cd(1);
07029   pNearFarOdd->Draw();
07030   cNearFar->cd(2);
07031   pNearFarEven->Draw();
07032 
07033   if (sum15_18Counter!=0){
07034     MSG("CDAnalysis",Msg::kInfo) 
07035       <<endl
07036       <<" ** Calibration Summary **"<<endl
07037       <<"SigCor in sliding window 15_18:"<<endl
07038       <<"    SigCor dep="<<sum15_18<<" (N="<<sum15_18Counter<<")"<<endl
07039       <<"    Av SigCor dep="<<sum15_18/sum15_18Counter
07040       <<" +/- "<<100*(h15_18->GetRMS()/sqrt(h15_18->GetEntries()))/
07041       h15_18->GetMean()<<"%"<<endl
07042       <<"    Av SigCor dep per plane="<<(sum15_18/sum15_18Counter)/15
07043       <<" +/- "<<100*(h15_18->GetRMS()/sqrt(h15_18->GetEntries()))/
07044       h15_18->GetMean()<<"%"<<endl
07045       <<"MIPs in sliding window 15_18:"<<endl
07046       <<"    MIPs dep="<<sum15_18Mip
07047       <<" (N="<<sum15_18MipCounter<<")"<<endl
07048       <<"    Av MIPs dep="<<sum15_18Mip/sum15_18MipCounter
07049       <<endl;
07050     if (sumSigCorTotalCounter!=0){
07051       MSG("CDAnalysis",Msg::kInfo) 
07052         <<"SigCor of whole event:"<<endl
07053         <<"    Sum of SigCor dep="<<sumSigCorTotal
07054         <<" (N="<<sumSigCorTotalCounter<<")"<<endl
07055         <<"    Av sigCor dep="
07056         <<sumSigCorTotal/sumSigCorTotalCounter<<endl
07057         <<"    1 sigCor="
07058         <<1800/(sumSigCorTotal/sumSigCorTotalCounter)<<" MeV"
07059         <<endl;
07060     }
07061     if (sumMipTotalCounter!=0){
07062       MSG("CDAnalysis",Msg::kInfo) 
07063         <<"MIPs of whole event:"<<endl
07064         <<"    Sum of MIPs dep="<<sumMipTotal
07065         <<" (N="<<sumMipTotalCounter<<")"<<endl
07066         <<"    Av MIPs dep="
07067         <<sumMipTotal/sumMipTotalCounter<<endl
07068         <<"    1 MIP="
07069         <<1800/(sumMipTotal/sumMipTotalCounter)<<" MeV"<<endl
07070         <<"    1 GeV="
07071         <<(sumMipTotal/sumMipTotalCounter)/1.8<<" MIPs"
07072         <<endl<<endl;
07073     }
07074   }
07075 
07076   if (sum15_18CounterO1!=0 && sum15_18CounterE1!=0){
07077     MSG("CDAnalysis",Msg::kInfo) 
07078       <<endl
07079       <<"SigCor in sliding window 15_18 in stripend 1:"<<endl
07080       <<" Odd planes:"<<endl
07081       <<"    SigCor dep="<<sum15_18_O1
07082       <<" (N="<<sum15_18CounterO1<<")"<<endl
07083       <<"    Av SigCor dep="<<sum15_18_O1/sum15_18CounterO1
07084       <<" +/- "<<h15_18_O1->GetRMS()/sqrt(h15_18_O1->GetEntries())
07085       <<" ("<<100*((h15_18_O1->GetRMS()/
07086                    sqrt(h15_18_O1->GetEntries()))/
07087                    h15_18_O1->GetMean())<<"%)"
07088       <<endl
07089       <<" Even planes:"<<endl
07090       <<"    SigCor dep="<<sum15_18_E1
07091       <<" (N="<<sum15_18CounterE1<<")"<<endl
07092       <<"    Av SigCor dep="<<sum15_18_E1/sum15_18CounterE1
07093       <<" +/- "<<h15_18_E1->GetRMS()/sqrt(h15_18_E1->GetEntries())
07094       <<" ("<<100*((h15_18_E1->GetRMS()/
07095                    sqrt(h15_18_E1->GetEntries()))/
07096                    h15_18_E1->GetMean())<<"%)"<<endl
07097       <<endl;
07098   }
07099   if (sum15_18CounterO2!=0 && sum15_18CounterE2!=0){
07100     MSG("CDAnalysis",Msg::kInfo) 
07101       <<endl
07102       <<"SigCor in sliding window 15_18 in stripend 2:"<<endl
07103       <<" Odd planes:"<<endl
07104       <<"    SigCor dep="<<sum15_18_O2
07105       <<" (N="<<sum15_18CounterO2<<")"<<endl
07106       <<"    Av SigCor dep="<<sum15_18_O2/sum15_18CounterO2
07107       <<" +/- "<<h15_18_O2->GetRMS()/sqrt(h15_18_O2->GetEntries())
07108       <<" ("<<100*((h15_18_O2->GetRMS()/
07109                    sqrt(h15_18_O2->GetEntries()))/
07110                    h15_18_O2->GetMean())<<"%)"
07111       <<endl
07112       <<" Even planes:"<<endl
07113       <<"    SigCor dep="<<sum15_18_E2
07114       <<" (N="<<sum15_18CounterE2<<")"<<endl
07115       <<"    Av SigCor dep="<<sum15_18_E2/sum15_18CounterE2
07116       <<" +/- "<<h15_18_E2->GetRMS()/sqrt(h15_18_E2->GetEntries())
07117       <<" ("<<100*((h15_18_E2->GetRMS()/
07118                    sqrt(h15_18_E2->GetEntries()))/
07119                    h15_18_E2->GetMean())<<"%)"<<endl
07120       <<endl;
07121   }
07122 
07123   //calculate the differences between near/far
07124   if (sum15_18CounterO2!=0 && sum15_18CounterE2!=0 &&
07125       sum15_18CounterO1!=0 && sum15_18CounterE1!=0){
07126 
07127     Float_t largestOdd=sum15_18_O1/sum15_18CounterO1;
07128     Float_t largestEven=sum15_18_E1/sum15_18CounterE1;
07129     Float_t diffOdd=sum15_18_O1/sum15_18CounterO1-
07130       sum15_18_O2/sum15_18CounterO2;
07131     Float_t diffEven=sum15_18_E1/sum15_18CounterE1-
07132       sum15_18_E2/sum15_18CounterE2;
07133 
07134     if (sum15_18_O2/sum15_18CounterO2>sum15_18_O1/sum15_18CounterO1) {
07135       largestOdd=sum15_18_O2/sum15_18CounterO2;
07136     }
07137     if (sum15_18_E2/sum15_18CounterE2>sum15_18_E1/sum15_18CounterE1) {
07138       largestEven=sum15_18_E2/sum15_18CounterE2;
07139     }
07140     
07141     MSG("CDAnalysis",Msg::kInfo) 
07142       <<endl
07143       <<"Difference between stripend 1 and 2 (1-2/largest):"<<endl
07144       <<" Odd planes:"<<endl
07145       <<"    Difference="<<diffOdd<<" ("<<100*diffOdd/largestOdd<<"%)"
07146       <<endl
07147       <<" Even planes:"<<endl
07148       <<"    Difference="<<diffEven<<" ("
07149       <<100*diffEven/largestEven<<"%)"
07150       <<endl;
07151   }
07152 
07153   MSG("CDAnalysis",Msg::kInfo) 
07154     <<" ** Finished MuonNearFar method **"<<endl;
07155 
07156 }

void CDAnalysis::MuonResponse (  ) 

Definition at line 4746 of file CDAnalysis.cxx.

References Munits::base_energy_name, CalcFirstLastPlane(), CalcLastPlaneOnTrkNoXTalk(), count, CutOnBadPedestals(), CutOnDeadChips(), CutOnEventLength(), CutOnPid(), CutOnTrackQuality(), DrawResponsePlot(), fChargeAdc, fChargeMip, fChargePe, fChargeSigCor, fE1, fE2, fEvents, fFirstPlane, FillProfHisto(), fKovADC3, fLastPlane, fLastPlaneEven, fLastPlaneOdd, fO1, fO2, Form(), fOutFile, fPlane, fRatioScEnToBeamEn, fRunNumber, fScEnDepPerMEU, fSigCorPerMEU, fStrip, fStripend, fTrkHitInfo, fTruthHitInfo, fUnTrkHitInfo, fXTalkHits, Munits::gigaelectronvolt, InitialiseLoopVariables(), IsDoubleEnded(), IsGenuineOrXTalk(), IsPlaneGenuine(), IsPlaneSideHit(), IsPlaneXTalkOnly(), IsSharedPmtHit(), Msg::kDebug, StripEnd::kEast, Msg::kInfo, Msg::kVerbose, Msg::kWarning, StripEnd::kWest, MAXMSG, MSG, OpenFile(), Pct(), ReadInHitInfo(), SetLoopVariables(), and StandardSanityChecks().

04747 {
04748   MSG("CDAnalysis",Msg::kInfo) 
04749     <<" ** Running MuonResponse method... **"<<endl;
04750 
04751   //open the output file for the histograms
04752   fOutFile=this->OpenFile(fRunNumber,"MuonRes");
04753 
04754   TH2F *hPeVsRange=new TH2F("hPeVsRange","PeVsRange",
04755                             20,40,60,50,0,10);
04756   hPeVsRange->GetXaxis()->SetTitle("Last Plane");
04757   hPeVsRange->GetXaxis()->CenterTitle();
04758   hPeVsRange->GetYaxis()->SetTitle("Greatest PE Value");
04759   hPeVsRange->GetYaxis()->CenterTitle();
04760   hPeVsRange->SetFillColor(0);
04761   //hPeVsRange->SetBit(TH1::kCanRebin);
04762 
04763   TH2F *hPeVsRangeGen=new TH2F("hPeVsRangeGen","PeVsRangeGen",
04764                             20,40,60,50,0,10);
04765   hPeVsRangeGen->GetXaxis()->SetTitle("Last Plane");
04766   hPeVsRangeGen->GetXaxis()->CenterTitle();
04767   hPeVsRangeGen->GetYaxis()->SetTitle("Greatest PE Value");
04768   hPeVsRangeGen->GetYaxis()->CenterTitle();
04769   hPeVsRangeGen->SetFillColor(0);
04770   //hPeVsRangeGen->SetBit(TH1::kCanRebin);
04771 
04772   TH2F *hPeVsRangeGen2=new TH2F("hPeVsRangeGen2","PeVsRangeGen2",
04773                             20,40,60,50,0,10);
04774   hPeVsRangeGen2->GetXaxis()->SetTitle("Last Plane");
04775   hPeVsRangeGen2->GetXaxis()->CenterTitle();
04776   hPeVsRangeGen2->GetYaxis()->SetTitle("Greatest PE Value");
04777   hPeVsRangeGen2->GetYaxis()->CenterTitle();
04778   hPeVsRangeGen2->SetFillColor(0);
04779   //hPeVsRangeGen2->SetBit(TH1::kCanRebin);
04780 
04781   TH2F *hPeVsRangeGen3=new TH2F("hPeVsRangeGen3","PeVsRangeGen3",
04782                             20,40,60,50,0,10);
04783   hPeVsRangeGen3->GetXaxis()->SetTitle("Last Plane");
04784   hPeVsRangeGen3->GetXaxis()->CenterTitle();
04785   hPeVsRangeGen3->GetYaxis()->SetTitle("Greatest PE Value");
04786   hPeVsRangeGen3->GetYaxis()->CenterTitle();
04787   hPeVsRangeGen3->SetFillColor(0);
04788   //hPeVsRangeGen3->SetBit(TH1::kCanRebin);
04789 
04790   TH2F *hPeVsRangeXTalk=new TH2F("hPeVsRangeXTalk","PeVsRangeXTalk",
04791                             20,40,60,50,0,10);
04792   hPeVsRangeXTalk->GetXaxis()->SetTitle("Last Plane");
04793   hPeVsRangeXTalk->GetXaxis()->CenterTitle();
04794   hPeVsRangeXTalk->GetYaxis()->SetTitle("Greatest PE Value");
04795   hPeVsRangeXTalk->GetYaxis()->CenterTitle();
04796   hPeVsRangeXTalk->SetFillColor(0);
04797   //hPeVsRangeXTalk->SetBit(TH1::kCanRebin);
04798 
04799   TH2F *hPeVsRangeXTalk2=new TH2F("hPeVsRangeXTalk2","PeVsRangeXTalk2",
04800                             20,40,60,50,0,10);
04801   hPeVsRangeXTalk2->GetXaxis()->SetTitle("Last Plane");
04802   hPeVsRangeXTalk2->GetXaxis()->CenterTitle();
04803   hPeVsRangeXTalk2->GetYaxis()->SetTitle("Greatest PE Value");
04804   hPeVsRangeXTalk2->GetYaxis()->CenterTitle();
04805   hPeVsRangeXTalk2->SetFillColor(0);
04806   //hPeVsRangeXTalk2->SetBit(TH1::kCanRebin);
04807 
04808   TH2F *hPeVsRangeXTalk3=new TH2F("hPeVsRangeXTalk3","PeVsRangeXTalk3",
04809                             20,40,60,50,0,10);
04810   hPeVsRangeXTalk3->GetXaxis()->SetTitle("Last Plane");
04811   hPeVsRangeXTalk3->GetXaxis()->CenterTitle();
04812   hPeVsRangeXTalk3->GetYaxis()->SetTitle("Greatest PE Value");
04813   hPeVsRangeXTalk3->GetYaxis()->CenterTitle();
04814   hPeVsRangeXTalk3->SetFillColor(0);
04815   //hPeVsRangeXTalk3->SetBit(TH1::kCanRebin);
04816 
04817   TH1F *hNumPlanes=new TH1F("hNumPlanes","NumPlanes hit",77,-2,75);
04818   hNumPlanes->GetXaxis()->SetTitle("Number of Planes Hit");
04819   hNumPlanes->GetXaxis()->CenterTitle();
04820   hNumPlanes->GetYaxis()->SetTitle("");
04821   hNumPlanes->GetYaxis()->CenterTitle();
04822   hNumPlanes->SetFillColor(0);
04823   hNumPlanes->SetBit(TH1::kCanRebin);
04824 
04825   TH1F *h15_18All=new TH1F("h15_18All","h15_18All",1000,-2,75);
04826   h15_18All->GetXaxis()->SetTitle("SigCors");
04827   h15_18All->GetXaxis()->CenterTitle();
04828   h15_18All->GetYaxis()->SetTitle("");
04829   h15_18All->GetYaxis()->CenterTitle();
04830   h15_18All->SetFillColor(0);
04831   h15_18All->SetBit(TH1::kCanRebin);
04832 
04833   TH1F *h15_18=new TH1F("h15_18","h15_18",1000,-2,75);
04834   h15_18->GetXaxis()->SetTitle("SigCors");
04835   h15_18->GetXaxis()->CenterTitle();
04836   h15_18->GetYaxis()->SetTitle("");
04837   h15_18->GetYaxis()->CenterTitle();
04838   h15_18->SetFillColor(0);
04839   h15_18->SetBit(TH1::kCanRebin);
04840 
04841   TH1F *hSigCorTotal=new TH1F("hSigCorTotal","hSigCorTotal",1000,-2,75);
04842   hSigCorTotal->GetXaxis()->SetTitle("SigCors");
04843   hSigCorTotal->GetXaxis()->CenterTitle();
04844   hSigCorTotal->GetYaxis()->SetTitle("");
04845   hSigCorTotal->GetYaxis()->CenterTitle();
04846   hSigCorTotal->SetFillColor(0);
04847   hSigCorTotal->SetBit(TH1::kCanRebin);
04848 
04849   TH1F *hSigCorTotalTight=new TH1F("hSigCorTotalTight",
04850                                    "hSigCorTotalTight",1000,-2,75);
04851   hSigCorTotalTight->GetXaxis()->SetTitle("SigCors");
04852   hSigCorTotalTight->GetXaxis()->CenterTitle();
04853   hSigCorTotalTight->GetYaxis()->SetTitle("");
04854   hSigCorTotalTight->GetYaxis()->CenterTitle();
04855   hSigCorTotalTight->SetFillColor(0);
04856   hSigCorTotalTight->SetBit(TH1::kCanRebin);
04857 
04858   TH1F *hSigCorTotalPeak=new TH1F("hSigCorTotalPeak",
04859                                   "hSigCorTotalPeak",1000,-2,75);
04860   hSigCorTotalPeak->GetXaxis()->SetTitle("SigCors");
04861   hSigCorTotalPeak->GetXaxis()->CenterTitle();
04862   hSigCorTotalPeak->GetYaxis()->SetTitle("");
04863   hSigCorTotalPeak->GetYaxis()->CenterTitle();
04864   hSigCorTotalPeak->SetFillColor(0);
04865   hSigCorTotalPeak->SetBit(TH1::kCanRebin);
04866 
04867   TH1F *hNumPlanesAll=new TH1F("hNumPlanesAll","NumPlanesAll hit",
04868                                77,-2,75);
04869   hNumPlanesAll->GetXaxis()->SetTitle("Number of Planes Hit");
04870   hNumPlanesAll->GetXaxis()->CenterTitle();
04871   hNumPlanesAll->GetYaxis()->SetTitle("");
04872   hNumPlanesAll->GetYaxis()->CenterTitle();
04873   hNumPlanesAll->SetFillColor(0);
04874   hNumPlanesAll->SetBit(TH1::kCanRebin);
04875 
04876   TH1F *hNumPlanesMu=new TH1F("hNumPlanesMu","hNumPlanesMu hit",
04877                               77,-2,75);
04878   hNumPlanesMu->GetXaxis()->SetTitle("Number of Planes Hit");
04879   hNumPlanesMu->GetXaxis()->CenterTitle();
04880   hNumPlanesMu->GetYaxis()->SetTitle("");
04881   hNumPlanesMu->GetYaxis()->CenterTitle();
04882   hNumPlanesMu->SetFillColor(0);
04883   hNumPlanesMu->SetLineColor(2);
04884   hNumPlanesMu->SetBit(TH1::kCanRebin);
04885   
04886   TH1F *hFirstPlane=new TH1F("hFirstPlane","FirstPlane hit",77,-2,75);
04887   hFirstPlane->GetXaxis()->SetTitle("First Plane Hit");
04888   hFirstPlane->GetXaxis()->CenterTitle();
04889   hFirstPlane->GetYaxis()->SetTitle("");
04890   hFirstPlane->GetYaxis()->CenterTitle();
04891   hFirstPlane->SetFillColor(0);
04892   hFirstPlane->SetBit(TH1::kCanRebin);
04893 
04894   TH1F *hEventLength=new TH1F("hEventLength","EventLength hit",
04895                               77,-2,75);
04896   hEventLength->GetXaxis()->SetTitle("Event Length (planes)");
04897   hEventLength->GetXaxis()->CenterTitle();
04898   hEventLength->GetYaxis()->SetTitle("");
04899   hEventLength->GetYaxis()->CenterTitle();
04900   hEventLength->SetFillColor(0);
04901   hEventLength->SetBit(TH1::kCanRebin);
04902 
04903   TH1F *hEventLength2=new TH1F("hEventLength2","EventLength",77,-2,75);
04904   hEventLength2->GetXaxis()->SetTitle("Event Length (planes)");
04905   hEventLength2->GetXaxis()->CenterTitle();
04906   hEventLength2->GetYaxis()->SetTitle("");
04907   hEventLength2->GetYaxis()->CenterTitle();
04908   hEventLength2->SetFillColor(0);
04909   hEventLength2->SetBit(TH1::kCanRebin);
04910 
04911   TH1F *hEventLength3=new TH1F("hEventLength3","EventLength",77,-2,75);
04912   hEventLength3->GetXaxis()->SetTitle("Event Length (planes)");
04913   hEventLength3->GetXaxis()->CenterTitle();
04914   hEventLength3->GetYaxis()->SetTitle("");
04915   hEventLength3->GetYaxis()->CenterTitle();
04916   hEventLength3->SetFillColor(0);
04917   hEventLength3->SetBit(TH1::kCanRebin);
04918 
04919   TH2F *hCkvAdcVsRange=new TH2F("hCkvAdcVsRange","CkvAdcVsRange",
04920                                 20,40,60,100,-1,1500);
04921   hCkvAdcVsRange->GetXaxis()->SetTitle("Last Plane");
04922   hCkvAdcVsRange->GetXaxis()->CenterTitle();
04923   hCkvAdcVsRange->GetYaxis()->SetTitle("Ckv ADC");
04924   hCkvAdcVsRange->GetYaxis()->CenterTitle();
04925   hCkvAdcVsRange->SetFillColor(0);
04926   hCkvAdcVsRange->SetBit(TH1::kCanRebin);
04927 
04928   //sum of all strip ends, normal and offset planes
04929   //tracked
04930   TProfile* pSigCorVsPlane=new TProfile("pSigCorVsPlane",
04931                                         "pSigCorVsPlane",
04932                                         62,0,62);
04933   TProfile* pSigCorVsOsPlane=new TProfile("pSigCorVsOsPlane",
04934                                           "pSigCorVsOsPlane",
04935                                           62,0,62);
04936 
04937   //xtalk + untracked hits
04938   TProfile* pSigCorVsPlaneX=new TProfile("pSigCorVsPlaneX",
04939                                          "pSigCorVsPlaneX",
04940                                          62,0,62);
04941   TProfile* pSigCorVsOsPlaneX=new TProfile("pSigCorVsOsPlaneX",
04942                                            "pSigCorVsOsPlaneX",
04943                                            62,0,62);
04944 
04945   //total
04946   TProfile* pSigCorVsPlaneT=new TProfile("pSigCorVsPlaneT",
04947                                          "pSigCorVsPlaneT",
04948                                          62,0,62);
04949   TProfile* pSigCorVsOsPlaneT=new TProfile("pSigCorVsOsPlaneT",
04950                                            "pSigCorVsOsPlaneT",
04951                                            62,0,62);
04952 
04953   //individual strip ends
04954   //tracked
04955   TProfile* pSigCorVsPlaneO1=new TProfile("pSigCorVsPlaneO1",
04956                                           "pSigCorVsPlaneO1",
04957                                           62,0,62);
04958   TProfile* pSigCorVsPlaneO2=new TProfile("pSigCorVsPlaneO2",
04959                                           "pSigCorVsPlaneO2",
04960                                           62,0,62);
04961   TProfile* pSigCorVsPlaneE1=new TProfile("pSigCorVsPlaneE1",
04962                                           "pSigCorVsPlaneE1",
04963                                           62,0,62);
04964   TProfile* pSigCorVsPlaneE2=new TProfile("pSigCorVsPlaneE2",
04965                                           "pSigCorVsPlaneE2",
04966                                           62,0,62);
04967   //xtalk + untracked hits
04968   TProfile* pSigCorVsPlaneO1X=new TProfile("pSigCorVsPlaneO1X",
04969                                           "pSigCorVsPlaneO1X",
04970                                           62,0,62);
04971   TProfile* pSigCorVsPlaneO2X=new TProfile("pSigCorVsPlaneO2X",
04972                                           "pSigCorVsPlaneO2X",
04973                                           62,0,62);
04974   TProfile* pSigCorVsPlaneE1X=new TProfile("pSigCorVsPlaneE1X",
04975                                           "pSigCorVsPlaneE1X",
04976                                           62,0,62);
04977   TProfile* pSigCorVsPlaneE2X=new TProfile("pSigCorVsPlaneE2X",
04978                                           "pSigCorVsPlaneE2X",
04979                                           62,0,62);
04980   //total
04981   TProfile* pSigCorVsPlaneO1T=new TProfile("pSigCorVsPlaneO1T",
04982                                           "pSigCorVsPlaneO1T",
04983                                           62,0,62);
04984   TProfile* pSigCorVsPlaneO2T=new TProfile("pSigCorVsPlaneO2T",
04985                                           "pSigCorVsPlaneO2T",
04986                                           62,0,62);
04987   TProfile* pSigCorVsPlaneE1T=new TProfile("pSigCorVsPlaneE1T",
04988                                           "pSigCorVsPlaneE1T",
04989                                           62,0,62);
04990   TProfile* pSigCorVsPlaneE2T=new TProfile("pSigCorVsPlaneE2T",
04991                                           "pSigCorVsPlaneE2T",
04992                                           62,0,62);
04993 
04994   //individual strip ends - offset planes
04995   //tracked
04996   TProfile* pSigCorVsOsPlaneO1=new TProfile("pSigCorVsOsPlaneO1",
04997                                             "pSigCorVsOsPlaneO1",
04998                                             62,0,62);
04999   TProfile* pSigCorVsOsPlaneO2=new TProfile("pSigCorVsOsPlaneO2",
05000                                             "pSigCorVsOsPlaneO2",
05001                                             62,0,62);
05002   TProfile* pSigCorVsOsPlaneE1=new TProfile("pSigCorVsOsPlaneE1",
05003                                             "pSigCorVsOsPlaneE1",
05004                                             62,0,62);
05005   TProfile* pSigCorVsOsPlaneE2=new TProfile("pSigCorVsOsPlaneE2",
05006                                             "pSigCorVsOsPlaneE2",
05007                                             62,0,62);
05008 
05009   //xtalk + untracked hits
05010   TProfile* pSigCorVsOsPlaneO1X=new TProfile("pSigCorVsOsPlaneO1X",
05011                                              "pSigCorVsOsPlaneO1X",
05012                                              62,0,62);
05013   TProfile* pSigCorVsOsPlaneO2X=new TProfile("pSigCorVsOsPlaneO2X",
05014                                             "pSigCorVsOsPlaneO2X",
05015                                             62,0,62);
05016   TProfile* pSigCorVsOsPlaneE1X=new TProfile("pSigCorVsOsPlaneE1X",
05017                                             "pSigCorVsOsPlaneE1X",
05018                                             62,0,62);
05019   TProfile* pSigCorVsOsPlaneE2X=new TProfile("pSigCorVsOsPlaneE2X",
05020                                             "pSigCorVsOsPlaneE2X",
05021                                             62,0,62);
05022   //total
05023   TProfile* pSigCorVsOsPlaneO1T=new TProfile("pSigCorVsOsPlaneO1T",
05024                                             "pSigCorVsOsPlaneO1T",
05025                                             62,0,62);
05026   TProfile* pSigCorVsOsPlaneO2T=new TProfile("pSigCorVsOsPlaneO2T",
05027                                             "pSigCorVsOsPlaneO2T",
05028                                             62,0,62);
05029   TProfile* pSigCorVsOsPlaneE1T=new TProfile("pSigCorVsOsPlaneE1T",
05030                                             "pSigCorVsOsPlaneE1T",
05031                                             62,0,62);
05032   TProfile* pSigCorVsOsPlaneE2T=new TProfile("pSigCorVsOsPlaneE2T",
05033                                             "pSigCorVsOsPlaneE2T",
05034                                             62,0,62);
05035 
05036   TProfile* pEnVsRange=new TProfile("pEnVsRange","pEnVsRange",
05037                                     62,0,62);
05038 
05039   vector<TProfile*> pSigCorVsDist;
05040   vector<TProfile*> pSigCorVsDistN;
05041   vector<Int_t> vWindowSize;
05042   vector<Float_t> bigAv;
05043   vector<Int_t> bigAvCounter;
05044   Float_t sum15_18=0;
05045   Float_t sum15_18Counter=0;
05046   Float_t sum15_18Mip=0;
05047   Float_t sum15_18MipCounter=0;
05048   Float_t sumSigCorTotal=0;
05049   Float_t sumSigCorTotalCounter=0;
05050   Float_t sumMipTotal=0;
05051   Float_t sumMipTotalCounter=0;
05052 
05053   Int_t lastPlaneOddCounter=0;
05054   Int_t lastPlaneEvenCounter=0;
05055   Int_t lastPlaneO1Counter=0;
05056   Int_t lastPlaneO2Counter=0;
05057   Int_t lastPlaneE1Counter=0;
05058   Int_t lastPlaneE2Counter=0;
05059   Int_t lastPlaneOBothCounter=0;
05060   Int_t lastPlaneEBothCounter=0;
05061 
05062   Int_t totalCounter=0;
05063   Int_t firstPlaneInPairCounter=0;
05064   Int_t sharedPmtCounter=0;
05065   Int_t sharedPmtXTalkCounter=0;
05066   Int_t side1Counter=0;
05067   Int_t side1XTalkCounter=0;
05068   Int_t side2Counter=0;
05069   Int_t side2XTalkCounter=0;
05070   Int_t doubleCounter=0;
05071   Int_t doubleXTalkCounter=0;
05072   Int_t notGenuineOrXTalkCounter=0;
05073 
05074   //num maps for all stripends
05075   map<Int_t,Float_t> num;
05076   map<Int_t,Float_t> numX;
05077   map<Int_t,Float_t> numT;
05078   map<Int_t,Float_t> numOs;
05079   map<Int_t,Float_t> numOsX;
05080   map<Int_t,Float_t> numOsT;
05081 
05082   //non-offset num maps for individual stripends
05083   map<Int_t,Float_t> numO1;
05084   map<Int_t,Float_t> numO1X;
05085   map<Int_t,Float_t> numO1T;
05086   map<Int_t,Float_t> numO2;
05087   map<Int_t,Float_t> numO2X;
05088   map<Int_t,Float_t> numO2T;
05089   map<Int_t,Float_t> numE1;
05090   map<Int_t,Float_t> numE1X;
05091   map<Int_t,Float_t> numE1T;
05092   map<Int_t,Float_t> numE2;
05093   map<Int_t,Float_t> numE2X;
05094   map<Int_t,Float_t> numE2T;
05095 
05096   //offset num maps for individual stripends
05097   map<Int_t,Float_t> numOsO1;
05098   map<Int_t,Float_t> numOsO1X;
05099   map<Int_t,Float_t> numOsO1T;
05100   map<Int_t,Float_t> numOsO2;
05101   map<Int_t,Float_t> numOsO2X;
05102   map<Int_t,Float_t> numOsO2T;
05103   map<Int_t,Float_t> numOsE1;
05104   map<Int_t,Float_t> numOsE1X;
05105   map<Int_t,Float_t> numOsE1T;
05106   map<Int_t,Float_t> numOsE2;
05107   map<Int_t,Float_t> numOsE2X;
05108   map<Int_t,Float_t> numOsE2T;
05109 
05110   Int_t noTrackCounter=0;
05111   Int_t passPidCounter=0;
05112  
05116   
05117   this->InitialiseLoopVariables();  
05118   
05119   for(Int_t event=0;event<fEvents;event++){
05120     
05121     this->SetLoopVariables(event);
05122 
05123     if (this->CutOnDeadChips()) continue;
05124     if (this->CutOnPid()) continue;
05125     //cut on not straight tracks
05126     //Double_t mainX1Cut=0.5;
05127     //if (!this->IsStraightTrack(mainX1Cut)){
05128     //continue;
05129     //}
05130 
05131     //count the number of events passing the pid
05132     passPidCounter++;
05133 
05134     map<Int_t,Int_t> numPlanesHit;
05135     map<Int_t,Int_t> numPlanesHit1;
05136     map<Int_t,Int_t> numPlanesHit2;
05137     map<Int_t,Int_t> numPlanesHitAll;
05138     map<Int_t,Float_t> planeSigCor;
05139     map<Int_t,Float_t> planeSigCorX;
05140     map<Int_t,Float_t> planeSigCorT;
05141     map<Int_t,Float_t> planeSigCorO1;    
05142     map<Int_t,Float_t> planeSigCorO1X;
05143     map<Int_t,Float_t> planeSigCorO1T;
05144     map<Int_t,Float_t> planeSigCorO2;
05145     map<Int_t,Float_t> planeSigCorO2X;
05146     map<Int_t,Float_t> planeSigCorO2T;
05147     map<Int_t,Float_t> planeSigCorE1;
05148     map<Int_t,Float_t> planeSigCorE1X;
05149     map<Int_t,Float_t> planeSigCorE1T;
05150     map<Int_t,Float_t> planeSigCorE2;
05151     map<Int_t,Float_t> planeSigCorE2X;
05152     map<Int_t,Float_t> planeSigCorE2T;
05153 
05154     map<Int_t,Float_t> planeMip;
05155     map<Int_t,Float_t> planeMipX;
05156     map<Int_t,Float_t> planeMipT;
05157 
05158     map<Int_t,Float_t> planePe;
05159     map<Int_t,Float_t> planeGreatestPe;
05160 
05161     Double_t sigCorTotal=0;
05162 
05163     //get tclones arrays for this snarl
05164     TClonesArray &cTrk=*fTrkHitInfo;
05165     Int_t numTrkHits=fTrkHitInfo->GetEntries();
05166     TClonesArray &cUnTrk = *fUnTrkHitInfo;
05167     Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
05168     //CDTrackedHitInfo *trackedHitInfo=(CDTrackedHitInfo*) c[hit];
05169     TClonesArray &cXTalk = *fXTalkHits;
05170     Int_t numXTalkHits=fXTalkHits->GetEntries();
05171     //TClonesArray &cTruth = *fTruthHitInfo;
05172     Int_t numTruthHits=0;
05173     if (fTruthHitInfo) numTruthHits=fTruthHitInfo->GetEntries();
05174 
05175     //look for untracked big events
05176     if (numTrkHits<2 && numXTalkHits+numUnTrkHits>1){
05177       MSG("CDAnalysis",Msg::kDebug)
05178         <<"Event="<<event
05179         <<", Num hits: trk="<<numTrkHits<<", unTrk="<<numUnTrkHits
05180         <<", xtalk="<<numXTalkHits<<", truth="<<numTruthHits
05181         <<endl;
05182       noTrackCounter++;
05183       //continue;
05184     }
05185 
05187     //loop over the untracked hits in the snarl
05189     for (Int_t hit=0;hit<numUnTrkHits;hit++){
05190       //cast the tclonesarray up to a trackedhitinfo object
05191       CDTrackedHitInfo *hitInfo=
05192         dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
05193 
05194       this->ReadInHitInfo(hitInfo);
05195 
05196       if (fPlane==0 && fChargeSigCor>1000){
05197         MSG("CDAnalysis",Msg::kDebug)
05198           <<"XTalk Event="<<event
05199           <<", fPlane="<<fPlane
05200           <<", fStrip="<<fStrip
05201           <<", fStripend="<<fStripend
05202           <<", fChargeAdc="<<fChargeAdc
05203           <<", fSigCor="<<fChargeSigCor<<endl;
05204       }
05205 
05206       //cut out the bad channels
05207       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05208 
05209       //count the number of planes hit
05210       numPlanesHitAll[fPlane]++;
05211 
05212       //check the channel's sanity
05213       this->StandardSanityChecks();
05214 
05215       //add up the charge of the hits in each plane
05216       planeSigCorX[fPlane]+=fChargeSigCor;
05217       planeSigCorT[fPlane]+=fChargeSigCor;
05218       planeMipX[fPlane]+=fChargeMip;
05219       planeMipT[fPlane]+=fChargeMip;
05220       if (fO1) planeSigCorO1X[fPlane]+=fChargeSigCor;
05221       if (fO2) planeSigCorO2X[fPlane]+=fChargeSigCor;
05222       if (fE1) planeSigCorE1X[fPlane]+=fChargeSigCor;
05223       if (fE2) planeSigCorE2X[fPlane]+=fChargeSigCor;
05224       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
05225       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
05226       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
05227       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
05228 
05229       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
05230                                                fChargePe;
05231 
05232       if (fPlane==0) continue;
05233       //sum the sigcor in the event
05234       //make up for no plane 0 with 2 times plane 1
05235       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
05236       else sigCorTotal+=fChargeSigCor;
05237     }
05238 
05240     //loop over xtalk hits in the snarl
05242     for (Int_t hit=0;hit<numXTalkHits;hit++){
05243       CDXTalkHitInfo *hitInfo=
05244         dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
05245 
05246       this->ReadInHitInfo(hitInfo);
05247       
05248       //cut out the bad channels
05249       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05250 
05251       //count the number of planes hit
05252       numPlanesHitAll[fPlane]++;
05253 
05254       //check the channel's sanity
05255       this->StandardSanityChecks();
05256 
05257       //add up the charge of the hits in each plane
05258       planeSigCorX[fPlane]+=fChargeSigCor;
05259       planeSigCorT[fPlane]+=fChargeSigCor;
05260       planeMipX[fPlane]+=fChargeMip;
05261       planeMipT[fPlane]+=fChargeMip;
05262       if (fO1) planeSigCorO1X[fPlane]+=fChargeSigCor;
05263       if (fO2) planeSigCorO2X[fPlane]+=fChargeSigCor;
05264       if (fE1) planeSigCorE1X[fPlane]+=fChargeSigCor;
05265       if (fE2) planeSigCorE2X[fPlane]+=fChargeSigCor;
05266       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
05267       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
05268       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
05269       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
05270 
05271       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
05272                                                fChargePe;
05273 
05274       if (fPlane==0) continue;
05275       //sum the sigcor in the event
05276       //make up for no plane 0 with 2 times plane 1
05277       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
05278       else sigCorTotal+=fChargeSigCor;
05279     }
05280 
05281     Bool_t lastPlaneO1Hit=false;
05282     Bool_t lastPlaneO2Hit=false;
05283     Bool_t lastPlaneE1Hit=false;
05284     Bool_t lastPlaneE2Hit=false;
05285     Int_t previousfLastPlane=-1;
05286 
05288     //loop over the tracked hits
05290     for (Int_t hit=0;hit<numTrkHits;hit++){
05291       CDTrackedHitInfo *trackedHitInfo=
05292         dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
05293           
05294       this->ReadInHitInfo(trackedHitInfo);
05295 
05296       //cut out the bad channels
05297       if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05298 
05299       //check the channel's sanity
05300       this->StandardSanityChecks();
05301 
05302       //calculate the first and last planes
05303       this->CalcFirstLastPlane(fPlane);
05304 
05305       //count the number of planes hit
05306       numPlanesHit[fPlane]++;
05307       numPlanesHitAll[fPlane]++;
05308 
05309       if (fLastPlane==fPlane && fPlane%2==0){
05310 
05311         //check if a new last plane has been found
05312         if (fLastPlane!=previousfLastPlane){
05313           lastPlaneE1Hit=false;
05314           lastPlaneE2Hit=false;
05315         }
05316         previousfLastPlane=fLastPlane;
05317 
05318         //check which stripend to set to true
05319         if (fStripend==1) lastPlaneE1Hit=true;
05320         if (fStripend==2) lastPlaneE2Hit=true;
05321 
05322         //set the hits in the other plane to be false
05323         lastPlaneO1Hit=false;
05324         lastPlaneO2Hit=false;
05325         MSG("CDAnalysis",Msg::kVerbose)
05326           <<"ev="<<event
05327           <<", last="<<fLastPlane
05328           <<", pl="<<fPlane
05329           <<", se="<<fStripend
05330           <<", E1="<<lastPlaneE1Hit
05331           <<", E2="<<lastPlaneE2Hit
05332           <<", O1="<<lastPlaneO1Hit
05333           <<", O2="<<lastPlaneO2Hit<<endl;
05334       }
05335       else if (fLastPlane==fPlane && fPlane%2==1){
05336 
05337         //check if a new last plane has been found
05338         if (fLastPlane!=previousfLastPlane){
05339           lastPlaneO1Hit=false;
05340           lastPlaneO2Hit=false;
05341         }
05342         previousfLastPlane=fLastPlane;
05343 
05344         //check which stripend to set to true
05345         if (fStripend==1) lastPlaneO1Hit=true;
05346         if (fStripend==2) lastPlaneO2Hit=true;
05347 
05348         //set the hits in the other plane to be false
05349         lastPlaneE1Hit=false;
05350         lastPlaneE2Hit=false;
05351 
05352         MSG("CDAnalysis",Msg::kVerbose)
05353           <<"ev="<<event
05354           <<", last="<<fLastPlane
05355           <<", pl="<<fPlane
05356           <<", se="<<fStripend
05357           <<", E1="<<lastPlaneE1Hit
05358           <<", E2="<<lastPlaneE2Hit
05359           <<", O1="<<lastPlaneO1Hit
05360           <<", O2="<<lastPlaneO2Hit<<endl;
05361       }
05362 
05363       //add up the charge of the hits in each plane
05364       planeSigCor[fPlane]+=fChargeSigCor;
05365       planeSigCorT[fPlane]+=fChargeSigCor;
05366       planeMip[fPlane]+=fChargeMip;
05367       planeMipT[fPlane]+=fChargeMip;
05368       if (fChargePe>planeGreatestPe[fPlane]) planeGreatestPe[fPlane]=
05369                                                fChargePe;
05370       planePe[fPlane]+=fChargePe;
05371       if (fO1) planeSigCorO1[fPlane]+=fChargeSigCor;
05372       if (fO2) planeSigCorO2[fPlane]+=fChargeSigCor;
05373       if (fE1) planeSigCorE1[fPlane]+=fChargeSigCor;
05374       if (fE2) planeSigCorE2[fPlane]+=fChargeSigCor;
05375       if (fO1) planeSigCorO1T[fPlane]+=fChargeSigCor;
05376       if (fO2) planeSigCorO2T[fPlane]+=fChargeSigCor;
05377       if (fE1) planeSigCorE1T[fPlane]+=fChargeSigCor;
05378       if (fE2) planeSigCorE2T[fPlane]+=fChargeSigCor;
05379 
05380       if (fPlane==0) continue;
05381       //sum the sigcor in the event
05382       //make up for no plane 0 with 2 times plane 1
05383       else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
05384       else sigCorTotal+=fChargeSigCor;
05385     }
05387     //end of loop over the tracked hits
05389 
05390     //fill histos for all data
05391     hNumPlanes->Fill(numPlanesHit.size());
05392     hNumPlanesAll->Fill(numPlanesHitAll.size());
05393     hEventLength->Fill(fLastPlane+1);
05394 
05395     //make sure that the first plane makes sense and was actually set
05396     if (fFirstPlane<0 || fFirstPlane>59) continue;
05397 
05398     //calculate the event energy
05399     Double_t eventEn=(fScEnDepPerMEU/fSigCorPerMEU)*sigCorTotal*
05400       (1/fRatioScEnToBeamEn);
05401     //calc the last plane on the track with no xtalk
05402     Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
05403 
05404     //fill the prof
05405     pEnVsRange->Fill(lastPlaneNoXTalk+1,eventEn);
05406 
05407     if (fLastPlane%2==1) lastPlaneOddCounter++;
05408     if (fLastPlane%2==0) lastPlaneEvenCounter++;
05409 
05410     //work out which stripends in the last plane were hit
05411     if (lastPlaneE1Hit || lastPlaneE2Hit){
05412       if (lastPlaneE1Hit && !lastPlaneE2Hit) lastPlaneE1Counter++;
05413       else if (!lastPlaneE1Hit && lastPlaneE2Hit) lastPlaneE2Counter++;
05414       else lastPlaneEBothCounter++;
05415     }
05416     else if (lastPlaneO1Hit || lastPlaneO2Hit){
05417       if (lastPlaneO1Hit && !lastPlaneO2Hit) lastPlaneO1Counter++;
05418       else if (!lastPlaneO1Hit && lastPlaneO2Hit) lastPlaneO2Counter++;
05419       else lastPlaneOBothCounter++;
05420     }
05421     else{
05422       MSG("CDAnalysis",Msg::kInfo)
05423         <<"Nothing hit!"<<endl;
05424 
05425       MSG("CDAnalysis",Msg::kInfo)
05426         <<"ev="<<event
05427         <<", Num hits: trk="<<numTrkHits<<", unTrk="<<numUnTrkHits
05428         <<", xtalk="<<numXTalkHits
05429         <<", E1="<<lastPlaneE1Hit
05430         <<", E2="<<lastPlaneE2Hit
05431         <<", O1="<<lastPlaneO1Hit
05432         <<", O2="<<lastPlaneO2Hit<<endl;
05433     }
05434 
05435     MSG("CDAnalysis",Msg::kVerbose)<<"New event="<<event<<endl;
05436 
05437     totalCounter++;
05438     //look for the second of a pair of shared pmts
05439     if ((fLastPlane==26 || fLastPlane==27 ||
05440          fLastPlane==30 || fLastPlane==31 ||
05441          fLastPlane==34 || fLastPlane==35 ||
05442          fLastPlane==38 || fLastPlane==39 ||
05443          fLastPlane==42 || fLastPlane==43 ||
05444          fLastPlane==46 || fLastPlane==47 ||
05445          fLastPlane==50 || fLastPlane==51 ||
05446          fLastPlane==54 || fLastPlane==55 ||
05447          fLastPlane==58 || fLastPlane==59)){
05448       //fLastPlaneOdd
05449       //fLastPlaneEven
05450       
05451       if (this->IsDoubleEnded(fLastPlane)){
05452         doubleCounter++;
05453         if (this->IsPlaneXTalkOnly(fLastPlane)){
05454           doubleXTalkCounter++;
05455         }
05456       }
05457       else if (this->IsPlaneSideHit(fLastPlane,StripEnd::kEast)){
05458         side1Counter++;
05459 
05460         if (this->IsPlaneXTalkOnly(fLastPlane)){
05461           side1XTalkCounter++;
05462         }
05463 
05464         if (this->IsSharedPmtHit(fLastPlane)){
05465           sharedPmtCounter++;
05466           if (this->IsPlaneXTalkOnly(fLastPlane)){
05467             sharedPmtXTalkCounter++;
05468           }
05469         }
05470       }
05471       else if (this->IsPlaneSideHit(fLastPlane,StripEnd::kWest)){
05472         side2Counter++;
05473          
05474         if (this->IsPlaneXTalkOnly(fLastPlane)){
05475           side2XTalkCounter++;
05476         }
05477  
05478         if (this->IsSharedPmtHit(fLastPlane)){
05479           sharedPmtCounter++;
05480           if (this->IsPlaneXTalkOnly(fLastPlane)){
05481             sharedPmtXTalkCounter++;
05482           }
05483           MSG("CDAnalysis",Msg::kWarning)
05484             <<"This should not happen at CalDet!"<<endl;
05485         }
05486       }
05487       
05488       MSG("CDAnalysis",Msg::kVerbose)
05489         <<"Shared="<<sharedPmtCounter
05490         <<" ("<<sharedPmtXTalkCounter<<")"
05491         <<", 2end="<<doubleCounter
05492         <<" ("<<doubleXTalkCounter<<")"
05493         <<", end1="<<side1Counter
05494         <<" ("<<side1XTalkCounter<<")"
05495         <<", end2="<<side2Counter
05496         <<" ("<<side2XTalkCounter<<")"
05497         <<endl;
05498     }
05499     else{
05500       firstPlaneInPairCounter++;
05501     }
05502 
05503     if (!this->IsGenuineOrXTalk(fLastPlane)){
05504       notGenuineOrXTalkCounter++;
05505     }
05506 
05507     //make event length cuts
05508     if (this->CutOnEventLength()) continue;
05509     //make track quality cuts
05510     if (this->CutOnTrackQuality()) continue;
05511 
05512     MAXMSG("CDAnalysis",Msg::kInfo,10)
05513       <<"Event passing plane cuts="<<event<<endl;
05514 
05515     //fill the total sigcor histo
05516     hSigCorTotal->Fill(sigCorTotal);
05517 
05518     //fill event length plots for those passing cuts
05519     hFirstPlane->Fill(fFirstPlane);
05520     hEventLength2->Fill(fLastPlane+1);
05521     hEventLength3->Fill(lastPlaneNoXTalk+1);
05522 
05523     //look at a certain part of the spectrum
05524     if (lastPlaneNoXTalk+1>50 && lastPlaneNoXTalk+1<53){
05525       //fill the total sigcor histo
05526       hSigCorTotalTight->Fill(sigCorTotal);
05527     }
05528     
05529     if (lastPlaneNoXTalk+1==51){
05530       //fill the total sigcor histo
05531       hSigCorTotalPeak->Fill(sigCorTotal);
05532     }
05533 
05534     //look at pe versus range
05535     hPeVsRange->Fill(fLastPlane+1,planeGreatestPe[fLastPlane]);
05536     if (this->IsPlaneGenuine(fLastPlane)){
05537       hPeVsRangeGen->Fill(fLastPlane+1,planeGreatestPe[fLastPlane]);
05538     }
05539     else{
05540       hPeVsRangeXTalk->Fill(fLastPlane+1,planeGreatestPe[fLastPlane]);
05541 
05542       //now look at second from last plane
05543       if (this->IsPlaneGenuine(fLastPlane-1)){
05544         hPeVsRangeGen2->Fill(fLastPlane+1-1,
05545                                planeGreatestPe[fLastPlane-1]);
05546       }
05547       else{
05548         hPeVsRangeXTalk2->Fill(fLastPlane+1-1,
05549                                planeGreatestPe[fLastPlane-1]);
05550 
05551         //now look at third from last plane
05552         if (this->IsPlaneGenuine(fLastPlane-2)){
05553           hPeVsRangeGen3->Fill(fLastPlane+1-2,
05554                                planeGreatestPe[fLastPlane-2]);
05555         }
05556         else{
05557           hPeVsRangeXTalk3->Fill(fLastPlane+1-2,
05558                                  planeGreatestPe[fLastPlane-2]);
05559         }
05560       }
05561     }
05562 
05563     hCkvAdcVsRange->Fill(fLastPlane+1,fKovADC3);
05564 
05566     //section for response
05568 
05569     //const Int_t reNormPlane=70;
05570     //Int_t planeOffset=reNormPlane-fLastPlane;
05571     const Int_t os=fLastPlane;
05572 
05573     //do nasty hack for plane 40 - very nasty!!!!
05574     //if (fRunNumber==70709 || fRunNumber==70705){
05575     //planeSigCor[40]=planeSigCor[38];
05576       //don't do xtalk since if pl 38 has zero xtalk then you will make
05577       //the map bigger and will average a zero!!!!
05578       //planeSigCorX[40]=planeSigCorX[38];
05579       //planeSigCorT[40]=planeSigCorT[38];
05580     //}
05581     //do nasty hack for plane 35 - very nasty!!!!
05582     if (fRunNumber>40000 && fRunNumber<60000){
05583       planeSigCor[35]=planeSigCor[37];
05584       planeSigCorT[35]=planeSigCorT[37];
05585     }
05586     //do nasty hack for plane 35 - very nasty!!!!
05587     else if (fRunNumber>100000 && fRunNumber<110000){
05588       //map<Int_t,Float_t> tmp=planeSigCor;
05589       //map<Int_t,Float_t> tmpT=planeSigCor;
05590       //if (tmp[15]!=0){
05591         //planeSigCor[13]=planeSigCor[15];
05592       //}
05593 
05594       //if (tmpT[15]!=0){
05595         //planeSigCorT[13]=planeSigCorT[15];
05596       //}
05597     }
05598 
05599     //fill profs for all stripends
05600     this->FillProfHisto(pSigCorVsPlane,num,planeSigCor);
05601     this->FillProfHisto(pSigCorVsPlaneX,numX,planeSigCorX);
05602     this->FillProfHisto(pSigCorVsPlaneT,numT,planeSigCorT);
05603     //offset
05604     this->FillProfHisto(pSigCorVsOsPlane,numOs,planeSigCor,os);
05605     this->FillProfHisto(pSigCorVsOsPlaneX,numOsX,planeSigCorX,os);
05606     this->FillProfHisto(pSigCorVsOsPlaneT,numOsT,planeSigCorT,os);
05607 
05608     //fill non-offset profs for individual stripends
05609     this->FillProfHisto(pSigCorVsPlaneO1,numO1,planeSigCorO1);
05610     this->FillProfHisto(pSigCorVsPlaneO1X,numO1X,planeSigCorO1X);
05611     this->FillProfHisto(pSigCorVsPlaneO1T,numO1T,planeSigCorO1T);
05612     this->FillProfHisto(pSigCorVsPlaneO2,numO2,planeSigCorO2);
05613     this->FillProfHisto(pSigCorVsPlaneO2X,numO2X,planeSigCorO2X);
05614     this->FillProfHisto(pSigCorVsPlaneO2T,numO2T,planeSigCorO2T);
05615     this->FillProfHisto(pSigCorVsPlaneE1,numE1,planeSigCorE1);
05616     this->FillProfHisto(pSigCorVsPlaneE1X,numE1X,planeSigCorE1X);
05617     this->FillProfHisto(pSigCorVsPlaneE1T,numE1T,planeSigCorE1T);
05618     this->FillProfHisto(pSigCorVsPlaneE2,numE2,planeSigCorE2);
05619     this->FillProfHisto(pSigCorVsPlaneE2X,numE2X,planeSigCorE2X);
05620     this->FillProfHisto(pSigCorVsPlaneE2T,numE2T,planeSigCorE2T);
05621 
05622     //fill offset profs for individual stripends
05623     this->FillProfHisto(pSigCorVsOsPlaneO1,numOsO1,planeSigCorO1,os);
05624     this->FillProfHisto(pSigCorVsOsPlaneO1X,numOsO1X,planeSigCorO1X,os);
05625     this->FillProfHisto(pSigCorVsOsPlaneO1T,numOsO1T,planeSigCorO1T,os);
05626     this->FillProfHisto(pSigCorVsOsPlaneO2,numOsO2,planeSigCorO2,os);
05627     this->FillProfHisto(pSigCorVsOsPlaneO2X,numOsO2X,planeSigCorO2X,os);
05628     this->FillProfHisto(pSigCorVsOsPlaneO2T,numOsO2T,planeSigCorO2T,os);
05629     this->FillProfHisto(pSigCorVsOsPlaneE1,numOsE1,planeSigCorE1,os);
05630     this->FillProfHisto(pSigCorVsOsPlaneE1X,numOsE1X,planeSigCorE1X,os);
05631     this->FillProfHisto(pSigCorVsOsPlaneE1T,numOsE1T,planeSigCorE1T,os);
05632     this->FillProfHisto(pSigCorVsOsPlaneE2,numOsE2,planeSigCorE2,os);
05633     this->FillProfHisto(pSigCorVsOsPlaneE2X,numOsE2X,planeSigCorE2X,os);
05634     this->FillProfHisto(pSigCorVsOsPlaneE2T,numOsE2T,planeSigCorE2T,os);
05635 
05637     //section for total event sigcor and mips
05639     Float_t localSumSigCorTotal=0;
05640     Float_t localSumSigCorTotalCounter=0;
05641     for (map<Int_t,Float_t>::iterator sig=planeSigCorT.begin();
05642          sig!=planeSigCorT.end();++sig){
05643       localSumSigCorTotal+=sig->second;
05644       localSumSigCorTotalCounter++;
05645     }
05646 
05647     //add total of this event to the sum of all events 
05648     if (localSumSigCorTotalCounter!=0){
05649       sumSigCorTotal+=localSumSigCorTotal;
05650       sumSigCorTotalCounter++;
05651     }
05652 
05653     Float_t localSumMipTotal=0;
05654     Float_t localSumMipTotalCounter=0;
05655     for (map<Int_t,Float_t>::iterator sig=planeMipT.begin();
05656          sig!=planeMipT.end();++sig){
05657       localSumMipTotal+=sig->second;
05658       localSumMipTotalCounter++;
05659     }
05660 
05661     //add total of this event to the sum of all events 
05662     if (localSumMipTotalCounter!=0){
05663       sumMipTotal+=localSumMipTotal;
05664       sumMipTotalCounter++;
05665     }
05666 
05668     //section for sliding window
05670     Int_t minEventLength=35;
05671     if (fLastPlane<minEventLength) continue;
05672 
05673     //initialise the profile histos
05674     static Bool_t firstTime=true;
05675     if (firstTime){
05676       for (Int_t p=15;p>1;p--){
05677         vWindowSize.push_back(p);
05678         bigAv.push_back(0);
05679         bigAvCounter.push_back(0);
05680       }
05681 
05682       for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
05683            windowSize!=vWindowSize.end();++windowSize){
05684         
05685         string sName=Form("%d",*windowSize);
05686         pSigCorVsDist.push_back
05687           (new TProfile(("pSigCorVsDist"+sName).c_str(),
05688                         ("pSigCorVsDist"+sName).c_str(),100,-2,40));
05689       }
05690     }
05691     firstTime=false;
05692 
05693     vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
05694     vector<Float_t>::iterator av=bigAv.begin();
05695     vector<Int_t>::iterator count=bigAvCounter.begin();
05696     Float_t localSum15_18=0;
05697     Float_t localSum15_18Counter=0;
05698     Float_t localSum15_18Mip=0;
05699     Float_t localSum15_18MipCounter=0;
05700 
05701     //loop over the different window sizes
05702     for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
05703          windowSize!=vWindowSize.end();++windowSize){
05704       
05705       //slide the window along from the end to 40-windowSize
05706       for (Int_t p=0;p<minEventLength-*windowSize;p++){
05707         Int_t windowStart=fLastPlane-p;
05708 
05709         MSG("CDAnalysis",Msg::kVerbose)
05710           <<"Window size="<<*windowSize
05711           <<", window start="<<windowStart
05712           <<endl;
05713 
05714         //loop through the hits in the window
05715         for (Int_t i=0;i<*windowSize;i++){
05716           Int_t plane=windowStart-i;
05717           
05718           //cut out planes that are greater than the last plane
05719           //in the view - ie the zeros at the end
05720           Bool_t doZeroCorrection=false;
05721           if (doZeroCorrection && 
05722               ((plane%2==0 && plane>fLastPlaneEven) || 
05723                (plane%2!=0 && plane>fLastPlaneOdd))){
05724             MSG("CDAnalysis",Msg::kVerbose)
05725               <<"Not using: Event="<<event
05726               <<", pl="<<plane
05727               <<", sigCor="<<planeSigCorT[plane]
05728               <<", fLastPlane="<<fLastPlane
05729               <<", fLastPlSig="<<planeSigCorT[fLastPlane]
05730               <<", fLastPlOdd="<<fLastPlaneOdd
05731               <<", fLastPlEven="<<fLastPlaneEven
05732               <<endl;
05733           }
05734           else{
05735 
05736             //calculate the best window value
05737             //if fLP=48 then the first plane included is 30
05738             //this is actually the 19th from the end of the track
05739             if (*windowSize==15 && windowStart==fLastPlane-18){
05740               localSum15_18+=planeSigCorT[plane];//total including xtalk
05741               localSum15_18Counter++;
05742               localSum15_18Mip+=planeMipT[plane];//total including xtalk
05743               localSum15_18MipCounter++;
05744 
05745               if (plane%2==0){//even
05746                 
05747               }
05748               else if (plane%2==1){//odd
05749 
05750               }
05751 
05752             }
05753 
05754             (*prof)->Fill(p,planeSigCorT[plane]);
05755             (*av)+=planeSigCorT[plane];
05756             (*count)++;
05757           }
05758         }
05759       }
05760       av++;
05761       count++;
05762       prof++;
05763     }
05764 
05765     if (localSum15_18Counter!=0){
05766       h15_18All->Fill(localSum15_18);
05767       h15_18->Fill(localSum15_18/15);
05768       sum15_18+=localSum15_18;//add this event's energy on to total
05769       sum15_18Counter++;
05770       sum15_18Mip+=localSum15_18Mip;
05771       sum15_18MipCounter++;
05772     }
05773 
05774     if (localSum15_18Counter==0 || localSum15_18<200){
05775       MAXMSG("CDAnalysis",Msg::kInfo,40)
05776         <<"Event="<<event<<", strange 15_18="<<localSum15_18
05777         <<", counter="<<localSum15_18Counter<<endl;
05778     }
05779 
05780   }//end of for                                       
05781   
05785 
05786   MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05787 
05788   //turn off the stats box printing
05789   gStyle->SetOptStat(0);
05790 
05791   //all stripends
05792   string sTitle="Energy Deposition (SigCor, all Stripends)";
05793   string sXTitle="Distance from end of track (planes)";
05794   this->DrawResponsePlot(sTitle,pSigCorVsPlane,pSigCorVsPlaneX,
05795                          pSigCorVsPlaneT,num,numX,numT);
05796   sTitle="Energy Deposition Vs Distance (SigCor, all Stripends)";
05797   this->DrawResponsePlot(sTitle,pSigCorVsOsPlane,pSigCorVsOsPlaneX,
05798                          pSigCorVsOsPlaneT,numOs,numOsX,numOsT,sXTitle);
05799 
05800   //non-offset planes
05801   sTitle="Energy Deposition (SigCor in Odd Planes FD stripend)";
05802   this->DrawResponsePlot(sTitle,pSigCorVsPlaneO1,pSigCorVsPlaneO1X,
05803                          pSigCorVsPlaneO1T,numO1,numO1X,numO1T);
05804 
05805   sTitle="Energy Deposition (SigCor in Odd Planes ND stripend)";
05806   this->DrawResponsePlot(sTitle,pSigCorVsPlaneO2,pSigCorVsPlaneO2X,
05807                          pSigCorVsPlaneO2T,numO2,numO2X,numO2T);
05808 
05809   sTitle="Energy Deposition (SigCor in Even Planes FD stripend)";
05810   this->DrawResponsePlot(sTitle,pSigCorVsPlaneE1,pSigCorVsPlaneE1X,
05811                          pSigCorVsPlaneE1T,numE1,numE1X,numE1T);
05812 
05813   sTitle="Energy Deposition (SigCor in Even Planes ND stripend)";
05814   this->DrawResponsePlot(sTitle,pSigCorVsPlaneE2,pSigCorVsPlaneE2X,
05815                          pSigCorVsPlaneE2T,numE2,numE2X,numE2T);
05816 
05817   //offset planes
05818   sTitle="Energy Deposition Vs Distance (SigCor in Odd Planes FD stripend)";
05819   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneO1,pSigCorVsOsPlaneO1X,
05820                          pSigCorVsOsPlaneO1T,numOsO1,numOsO1X,numOsO1T,
05821                          sXTitle);
05822 
05823   sTitle="Energy Deposition Vs Distance (SigCor in Odd Planes ND stripend)";
05824   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneO2,pSigCorVsOsPlaneO2X,
05825                          pSigCorVsOsPlaneO2T,numOsO2,numOsO2X,numOsO2T,
05826                          sXTitle);
05827 
05828   sTitle="Energy Deposition Vs Distance (SigCor in Even Planes FD stripend)";
05829   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneE1,pSigCorVsOsPlaneE1X,
05830                          pSigCorVsOsPlaneE1T,numOsE1,numOsE1X,numOsE1T,
05831                          sXTitle);
05832 
05833   sTitle="Energy Deposition Vs Distance (SigCor in Even Planes ND stripend)";
05834   this->DrawResponsePlot(sTitle,pSigCorVsOsPlaneE2,pSigCorVsOsPlaneE2X,
05835                          pSigCorVsOsPlaneE2T,numOsE2,numOsE2X,numOsE2T,
05836                          sXTitle);
05837 
05838 
05839   //turn on the stats box printing
05840   gStyle->SetOptStat(11);
05841 
05842   TCanvas *cProf=new TCanvas("cProf","Prof",0,0,1200,800);
05843   cProf->SetFillColor(0);
05844   string sName="SlidingWindow.ps";
05845   cProf->Print((sName+"[").c_str());
05846   gErrorIgnoreLevel=1;
05847   //plot the unnormalised prof first
05848   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
05849        prof!=pSigCorVsDist.end();++prof){      
05850     cProf->Clear();
05851     (*prof)->Draw();
05852     (*prof)->SetTitle("Average SigCor in Sliding Window");
05853     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
05854     (*prof)->GetYaxis()->SetTitle("Average SigCor");
05855     (*prof)->GetXaxis()->CenterTitle();
05856     (*prof)->GetYaxis()->CenterTitle();
05857     cProf->Print(sName.c_str());
05858   }
05859 
05860   //now normalise the prof
05861   vector<Float_t>::iterator av=bigAv.begin();
05862   vector<Int_t>::iterator count=bigAvCounter.begin();
05863   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
05864        prof!=pSigCorVsDist.end();++prof){
05865       
05866     //normalise the prof and scale the axes
05867     MSG("CDAnalysis",Msg::kDebug)
05868       <<"bigCounter="<<*count<<", bigAv="<<*av<<endl;
05869 
05870     //pSigCorVsDistN.push_back
05871     //(new TProfile(("pSigCorVsDistN"+sName).c_str(),
05872     //      ("pSigCorVsDistN"+sName).c_str(),100,-2,40));
05873     if (*av>0) (*prof)->Scale((*count)/(*av));
05874     (*prof)->SetMaximum(1.2);
05875     (*prof)->SetMinimum(0.8);
05876       
05877     cProf->Clear();
05878     (*prof)->Draw();
05879     (*prof)->SetTitle("Average SigCor in Sliding Window");
05880     (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
05881     (*prof)->GetYaxis()->SetTitle("Average SigCor");
05882     (*prof)->GetXaxis()->CenterTitle();
05883     (*prof)->GetYaxis()->CenterTitle();
05884     cProf->Print(sName.c_str());
05885     av++;
05886     count++;
05887   }
05888   //close the file
05889   gErrorIgnoreLevel=0;
05890   cProf->Print((sName+"]").c_str());
05891 
05892   //now do a few profs on the same plot
05893   TCanvas *cProf2=new TCanvas("cProf2","Prof",0,0,1200,800);
05894   cProf2->SetFillColor(0);
05895   sName="SlidingWindowAll.ps";
05896   //cProf2->Print((sName+"[").c_str());
05897   Int_t counter=0;
05898   for (vector<TProfile*>::iterator prof=pSigCorVsDist.begin();
05899        prof!=pSigCorVsDist.end();++prof){
05900 
05901     (*prof)->SetMaximum(1.09);
05902     (*prof)->SetMinimum(0.96);
05903 
05904     //count which prof got to
05905     counter++;
05906 
05907     //decide which profs to draw
05908     static Bool_t firstTime=true;
05909     if (counter==1 || counter==6 || counter==11){ 
05910       if (firstTime) {
05911         (*prof)->Draw();
05912         firstTime=false;
05913       }
05914       else  (*prof)->Draw("sames");
05915 
05916       (*prof)->SetTitle("Average SigCor in Sliding Window");
05917       (*prof)->GetXaxis()->SetTitle("Start of sliding window (planes from end of track)");
05918       (*prof)->GetYaxis()->SetTitle("Average SigCor");
05919       (*prof)->GetXaxis()->CenterTitle();
05920       (*prof)->GetYaxis()->CenterTitle();
05921       static Int_t color=2;
05922       (*prof)->SetLineColor(color);
05923       color+=2;
05924     }
05925   }
05926 
05927   //turn off the stats box printing
05928   //gStyle->SetOptStat(0);
05929   gStyle->SetOptStat(1111111);
05930 
05931   TCanvas *cGeom=new TCanvas("cGeom","Geom",0,0,1200,800);
05932   cGeom->SetFillColor(0);
05933   cGeom->Divide(2,3);
05934   cGeom->cd(1);
05935   hEventLength2->Draw();
05936   cGeom->cd(2);
05937   hEventLength3->Draw();
05938   cGeom->cd(3);
05939   hFirstPlane->Draw();
05940   cGeom->cd(4);
05941   hEventLength->Draw();
05942   cGeom->cd(5);
05943   hNumPlanes->Draw();
05944   cGeom->cd(6);
05945   hNumPlanesAll->Draw();
05946   hNumPlanesMu->Draw("same");
05947  
05948   /*
05949   TCanvas *cCkv=new TCanvas("cCkv","Ckv",0,0,1200,800);
05950   cCkv->SetFillColor(0);
05951   cCkv->Divide(2,2);
05952   cCkv->cd(1);
05953   hCkvAdcVsRange->Draw("colz");
05954   hCkvAdcVsRange->Draw("profsame");
05955   cCkv->cd(2);
05956   TProfile* p=hCkvAdcVsRange->ProfileX();
05957   p->Draw();
05958   cCkv->cd(3);
05959   hCkvAdcVsRange->Draw("colz");
05960   p->Draw("sames");
05961   */
05962 
05963   TCanvas *c15_18=new TCanvas("c15_18","15_18",0,0,1200,800);
05964   c15_18->SetFillColor(0);
05965   c15_18->Divide(2,3);
05966   c15_18->cd(1);
05967   h15_18->Draw();
05968   c15_18->cd(2);
05969   h15_18All->Draw();
05970   c15_18->cd(3);
05971   hSigCorTotal->Draw();
05972   c15_18->cd(4);
05973   hSigCorTotalTight->Draw();
05974   c15_18->cd(5);
05975   hSigCorTotalPeak->Draw();
05976   c15_18->cd(6);
05977   pEnVsRange->Draw();
05978 
05979   MSG("CDAnalysis",Msg::kInfo) 
05980     <<endl
05981     <<"Mean sigCorTotal="<<hSigCorTotal->GetMean()<<endl
05982     <<"Ratio ScEn to BeamEn="<<fRatioScEnToBeamEn
05983     <<" ("<<1/fRatioScEnToBeamEn<<")"<<endl
05984     <<"GeV per SigCor="<<fScEnDepPerMEU/fSigCorPerMEU<<endl
05985     <<"Beam energy from Calorimetry (lose)="
05986     <<((fScEnDepPerMEU/fSigCorPerMEU)*
05987     hSigCorTotal->GetMean()*(1/fRatioScEnToBeamEn))/
05988     Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl
05989     <<"Beam energy from Calorimetry (tight)="
05990