00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include <fstream>
00015 #include <cmath>
00016 #include <cassert>
00017
00018 #include "TCanvas.h"
00019 #include "TChain.h"
00020 #include "TError.h"
00021 #include "TFile.h"
00022 #include "TF1.h"
00023 #include "TGraphErrors.h"
00024 #include "TH2F.h"
00025 #include "TLegend.h"
00026 #include "TProfile.h"
00027 #include "TProfile2D.h"
00028 #include "TStyle.h"
00029 #include "TTree.h"
00030 #include "TVector3.h"
00031 #include "TClonesArray.h"
00032
00033 #include "CalDetPID/CalDetParticleType.h"
00034 #include "Calibrator/Calibrator.h"
00035 #include "Digitization/DigiSignal.h"
00036 #include "MessageService/MsgService.h"
00037 #include "MuELoss/MuEnergyLoss.h"
00038 #include "Conventions/Munits.h"
00039 #include "Conventions/StripEnd.h"
00040 #include "Validity/VldContext.h"
00041
00042 #include "CalDetTracker/CDAnalysis.h"
00043 #include "CalDetTracker/CDSimpleMC.h"
00044 #include "CalDetTracker/CDTruthHitInfo.h"
00045 #include "CalDetTracker/CDPIDInfo.h"
00046 #include "CalDetTracker/CDTrackedHitInfo.h"
00047 #include "CalDetTracker/CDTrackInfo.h"
00048 #include "CalDetTracker/CDTrackerOptions.h"
00049 #include "CalDetTracker/CDXTalkHitInfo.h"
00050
00051 using std::endl;
00052 using std::cout;
00053 using std::map;
00054 using std::vector;
00055
00056 string CDAnalysis::fInputFileName="";
00057
00058 ClassImp(CDAnalysis)
00059
00060 CVSID("$Id: CDAnalysis.cxx,v 1.74 2007/07/03 16:01:27 hartnell Exp $");
00061
00062
00063
00064 CDAnalysis::CDAnalysis()
00065 {
00066 MSG("CDAnalysis",Msg::kInfo)
00067 <<"Running CDAnalysis Constructor..."<<endl;
00068
00069
00070 fOutFile=0;
00071 fTrackerTree=0;
00072 fOptTree=0;
00073 fTrkOpt=0;
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
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="";
00119 fDoReCalibration=false;
00120
00122
00124
00125 this->MakeChain();
00126 this->SetRootFileObjects();
00127
00128
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
00138
00139 gStyle->SetOptStat(1111111);
00140 gStyle->SetOptFit(1111);
00141 gStyle->SetPalette(1,(Int_t*)0);
00142
00143
00144
00145 this->SetSigCorPerMEU();
00146 this->SetScEnDepPerMEU();
00147 this->SetRatioScEnToBeamEn();
00148
00149 MSG("CDAnalysis",Msg::kInfo)
00150 <<"Finished CDAnalysis Constructor"<<endl;
00151 }
00152
00153
00154
00155 CDAnalysis::~CDAnalysis()
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 }
00167
00168
00169
00170 void CDAnalysis::InitialiseLoopVariables()
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
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 }
00203
00204
00205
00206 void CDAnalysis::InitialisePidVariables()
00207 {
00208
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;
00235
00236 fTickSinceLast=-1;
00237
00238
00239 fNoOverlap=kFALSE;
00240 fInCERTime=kFALSE;
00241 fPIDType=0;
00242 fNoOverlapBits=0;
00243 fInCERTimeBits=0;
00244 fOLChi2=0;
00245 }
00246
00247
00248
00249 void CDAnalysis::InitialiseHitInfoVariables()
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 }
00272
00273
00274
00275 void CDAnalysis::WriteOutHistos() const
00276 {
00277
00278 if (fOutFile){
00279 if (fOutFile->IsWritable()){
00280 fOutFile->cd();
00281
00282
00283 TTree runInfo("runInfo","runInfo");
00284
00285
00286
00287
00288
00289 Int_t lSimFlag=fSimFlag;
00290 runInfo.Branch("SimFlag",&lSimFlag,"SimFlag/I");
00291 Float_t lBeamMomentum=fBeamMomentum;
00292 runInfo.Branch("BeamMomentum",&lBeamMomentum,"BeamMomentum/F");
00293 Int_t lRunNumber=fRunNumber;
00294 runInfo.Branch("RunNumber",&lRunNumber,"RunNumber/I");
00295 Int_t lSubRun=fSubRun;
00296 runInfo.Branch("SubRun",&lSubRun,"SubRun/I");
00297 Int_t lRunPeriod=this->RunNumber2RunPeriod(fRunNumber);
00298 runInfo.Branch("RunPeriod",&lRunPeriod,"RunPeriod/I");
00299 Int_t lStartTime=fStartTime;
00300 runInfo.Branch("StartTime",&lStartTime,"StartTime/I");
00301 Int_t lEndTime=fEndTime;
00302 runInfo.Branch("EndTime",&lEndTime,"EndTime/I");
00303 Int_t lStartSnarl=fStartSnarl;
00304 runInfo.Branch("StartSnarl",&lStartSnarl,"StartSnarl/I");
00305 Int_t lEndSnarl=fEndSnarl;
00306 runInfo.Branch("EndSnarl",&lEndSnarl,"EndSnarl/I");
00307 Float_t lAvTemperature=fAvTemperature;
00308 runInfo.Branch("AvTemperature",&lAvTemperature,"AvTemperature/F");
00309
00310 Float_t lSigCorsPerMip=fSigCorsPerMip;
00311 runInfo.Branch("SigCorsPerMip",&lSigCorsPerMip,"SigCorsPerMip/F");
00312 Float_t lScEnDepPerMEU=fScEnDepPerMEU;
00313 runInfo.Branch("ScEnDepPerMEU",&lScEnDepPerMEU,"ScEnDepPerMEU/F");
00314 Float_t lRatioScEnToBeamEn=fRatioScEnToBeamEn;
00315 runInfo.Branch("RatioScEnToBeamEn",&lRatioScEnToBeamEn,
00316 "RatioScEnToBeamEn/F");
00317 Float_t lPeakLastPlane=fPeakLastPlane;
00318 runInfo.Branch("PeakLastPlane",&lPeakLastPlane,
00319 "PeakLastPlane/F");
00320 Float_t lPeakPlaneSigCors=fPeakPlaneSigCors;
00321 runInfo.Branch("PeakPlaneSigCors",&lPeakPlaneSigCors,
00322 "PeakPlaneSigCors/F");
00323 Float_t lSigCorVsDistM=fSigCorVsDistM;
00324 runInfo.Branch("SigCorVsDistM",&lSigCorVsDistM,
00325 "SigCorVsDistM/F");
00326 Float_t lMeuVsEvLenCutM=fMeuVsEvLenCutM;
00327 runInfo.Branch("MeuVsEvLenCutM",&lMeuVsEvLenCutM,
00328 "MeuVsEvLenCutM/F");
00329 Int_t lEvLenCutMin=-1;
00330 Int_t lEvLenCutMax=-1;
00331 this->GetEvLenMinMax(lEvLenCutMin,lEvLenCutMax);
00332 runInfo.Branch("EvLenCutMin",&lEvLenCutMin,"EvLenCutMin/I");
00333 runInfo.Branch("EvLenCutMax",&lEvLenCutMax,"EvLenCutMax/I");
00334
00335
00336 Int_t lMyPiMuCounter=fMyPiMuCounter;
00337 runInfo.Branch("MyPiMuCounter",&lMyPiMuCounter,"MyPiMuCounter/I");
00338 Int_t lPidPiMuCounter=fPidPiMuCounter;
00339 runInfo.Branch("PidPiMuCounter",&lPidPiMuCounter,
00340 "PidPiMuCounter/I");
00341 Int_t lMyElecCounter=fMyElecCounter;
00342 runInfo.Branch("MyElecCounter",&lMyElecCounter,"MyElecCounter/I");
00343 Int_t lPidElecCounter=fPidElecCounter;
00344 runInfo.Branch("PidElecCounter",&lPidElecCounter,
00345 "PidElecCounter/I");
00346 Int_t lBothPiMuCounter=fBothPiMuCounter;
00347 runInfo.Branch("BothPiMuCounter",&lBothPiMuCounter,
00348 "BothPiMuCounter/I");
00349 Int_t lBothElecCounter=fBothElecCounter;
00350 runInfo.Branch("BothElecCounter",&lBothElecCounter,
00351 "BothElecCounter/I");
00352
00353
00354 runInfo.Fill();
00355 runInfo.Write();
00356
00357 MSG("CDAnalysis",Msg::kInfo)
00358 <<"Writing histos to: "<<fOutFile->GetName()<<" ..."<<endl;
00359 fOutFile->Write();
00360
00361
00362 }
00363 else {
00364 MSG("CDAnalysis",Msg::kWarning)
00365 <<"File not writable!"<<endl;
00366 }
00367 }
00368 }
00369
00370
00371
00372 void CDAnalysis::InputFileName(string f)
00373 {
00374 MSG("CDAnalysis",Msg::kInfo)
00375 <<"Running with input file name="<<f<<endl;
00376 fInputFileName=f;
00377 }
00378
00379
00380
00381 vector<string> CDAnalysis::MakeFileList()
00382 {
00384
00385 vector<string> fileList;
00386
00387 if (fInputFileName!=""){
00388 ifstream inputFile(fInputFileName.c_str());
00389
00390
00391 if (inputFile){
00392
00393 string file="";
00394
00395
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
00416 if (fileList.size()>0) return fileList;
00417
00418
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 }
00442
00443
00444
00445 void CDAnalysis::MakeChain()
00446 {
00447
00448 vector<string> fileList=this->MakeFileList();
00449
00450
00451 fTrackerTree=new TChain("TrackerTree");
00452 fOptTree=new TChain("TrackerOptions");
00453
00454 Int_t nf=0;
00455
00456 for (vector<string>::iterator file=fileList.begin();
00457 file!=fileList.end();++file){
00458
00459
00460 ifstream openOk((*file).c_str());
00461
00462
00463 Int_t stars=(*file).find("*");
00464 Int_t quest=(*file).find("?");
00465
00466
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
00506
00507 MSG("CDAnalysis",Msg::kInfo)
00508 <<endl<<"Analysing "<<nf<<" file(s). Reading from disk..."<<endl;
00509 }
00510
00511
00512
00513 void CDAnalysis::SetRootFileObjects()
00514 {
00515 MSG("CDAnalysis",Msg::kDebug)
00516 <<"Running the SetRootFileObjects method..."<<endl;
00517
00518
00519 fOptTree->SetBranchAddress("SimFlag",&fSimFlag);
00520 fOptTree->SetBranchAddress("Run",&fRunNumber);
00521 fOptTree->SetBranchAddress("SubRun",&fSubRun);
00522 fOptTree->SetBranchAddress("TrackerOptions",fTrkOpt);
00523 fOptTree->SetBranchAddress("StartTime",&fStartTime);
00524 fOptTree->SetBranchAddress("EndTime",&fEndTime);
00525 fOptTree->SetBranchAddress("StartSnarl",&fStartSnarl);
00526 fOptTree->SetBranchAddress("EndSnarl",&fEndSnarl);
00527 fOptTree->SetBranchAddress("BeamMomentum",&fBeamMomentum);
00528
00529
00530 Int_t events=static_cast<Int_t>(fOptTree->GetEntries());
00531 MSG("CDAnalysis",Msg::kDebug)
00532 <<"OptTree has "<<events<<" events"<<endl;
00533 if (events>0){
00534
00535 fOptTree->GetEvent(0);
00536 MSG("CDAnalysis",Msg::kInfo)
00537 <<"File has run="<<fRunNumber<<", subrun="<<fSubRun
00538 <<", SimFlag="<<SimFlag::AsString(fSimFlag)
00539 <<", beam momentum="<<fBeamMomentum<<endl
00540 <<"Time="<<fStartTime<<"->"<<fEndTime
00541 <<", snarl="<<fStartSnarl<<"->"<<fEndSnarl<<endl;
00542 }
00543
00544
00545 fTrackerTree->SetBranchAddress("TrackInfo",&fTrackInfo);
00546 fTrackerTree->SetBranchAddress("Snarl",&fSnarl);
00547 fTrackerTree->SetBranchAddress("NumDeadChips",&fNumDeadChips);
00548 fTrackerTree->SetBranchAddress("Sec",&fSec);
00549 fTrackerTree->SetBranchAddress("Temperature",&fTemperature);
00550
00551
00552 if (fTrackerTree->GetBranchStatus("PIDInfo")){
00553 fTrackerTree->SetBranchAddress("PIDInfo",&fPIDInfo);
00554 }
00555 else{
00556 MSG("CDAnalysis",Msg::kInfo)
00557 <<"PIDInfo branch does not exist, not setting tree address"<<endl;
00558 }
00559
00560
00561 fTrkHitInfo=new TClonesArray("CDTrackedHitInfo",1000);
00562 fUnTrkHitInfo=new TClonesArray("CDTrackedHitInfo",1000);
00563 fXTalkHits=new TClonesArray("CDXTalkHitInfo",1000);
00564
00565
00566 fTrackerTree->SetBranchAddress("StraightTrackedHitInfo",
00567 &fTrkHitInfo);
00568 fTrackerTree->SetBranchAddress("UnTrackedHitInfo",
00569 &fUnTrkHitInfo);
00570 fTrackerTree->SetBranchAddress("XTalkHitInfo",&fXTalkHits);
00571
00572
00573 if (fTrackerTree->GetBranchStatus("TruthHitInfo")){
00574 fTruthHitInfo=new TClonesArray("CDTruthHitInfo",1000);
00575 fTrackerTree->SetBranchAddress("TruthHitInfo",&fTruthHitInfo);
00576 }
00577 else{
00578 MSG("CDAnalysis",Msg::kInfo)
00579 <<"TruthHitInfo branch does not exist"
00580 <<", not setting tree address"<<endl;
00581 }
00582
00583
00584 fEvents=static_cast<Int_t>(fTrackerTree->GetEntries());
00585
00586
00587 if (fTrackerTree) fTrackerTree->GetEvent(0);
00588 MSG("CDAnalysis",Msg::kInfo)
00589 <<"First snarl="<<fSnarl<<" (sec="<<fSec<<")"<<endl;
00590
00591
00592 Calibrator& cal=Calibrator::Instance();
00593 if (fRunNumber>=70000 && fRunNumber<80000){
00594 cout<<"Setting DriftCalibrator=PulserDriftCalScheme"<<endl;
00595 cal.Set("DriftCalibrator=PulserDriftCalScheme");
00596 cal.GetDriftCalibrator().Set("VATemperatureCalibration=on");
00597 cal.PrintConfig(cout);
00598 }
00599 else{
00600 cout<<"Setting DriftCalibrator=PulserSigLinCalScheme"<<endl;
00601 cal.Set("DriftCalibrator=PulserSigLinCalScheme");
00602 cal.GetDriftCalibrator().Set("VATemperatureCalibration=on");
00603 cal.PrintConfig(cout);
00604 }
00605
00606 MSG("CDAnalysis",Msg::kDebug)
00607 <<"Finished the SetRootFileObjects method"<<endl;
00608 }
00609
00610
00611 Int_t CDAnalysis::RunNumber2RunPeriod(Int_t run) const
00612 {
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626 Int_t runPeriod=0;
00627 if (run>=30000 && run<40000){
00628 runPeriod=1;
00629 }
00630 if (run>=40000 && run<50000){
00631 runPeriod=2;
00632 }
00633 else if (run>=50000 && run<60000){
00634 runPeriod=4;
00635 }
00636 else if (run>=60000 && run<70000){
00637 runPeriod=-1;
00638 }
00639 else if (run>=70000 && run<80000){
00640 runPeriod=5;
00641 }
00642 else if (run>=80000 && run<90000){
00643 runPeriod=6;
00644 }
00645 else if (run>=90000 && run<100000){
00646 runPeriod=7;
00647 }
00648 else if (run>=100000 && run<101000){
00649 runPeriod=8;
00650 }
00651 else if (run>=101000 && run<102000){
00652 runPeriod=9;
00653 }
00654 else if (run>=102000 && run<120000){
00655 runPeriod=11;
00656 }
00657
00658 return runPeriod;
00659 }
00660
00661
00662
00663 void CDAnalysis::SetSigCorPerMEU()
00664 {
00665 if (fSimFlag==SimFlag::kData){
00666 if (fRunNumber>70000 && fRunNumber<80000){
00667 fSigCorPerMEU=591.6;
00668 }
00669 else if (fRunNumber==100161){
00670 fSigCorPerMEU=377.2;
00671 }
00672 else{
00673 MSG("CDAnalysis",Msg::kWarning)
00674 <<"no run number for sigcor per meu"<<endl;
00675 }
00676 }
00677 else if(fSimFlag==SimFlag::kMC){
00678 fSigCorPerMEU=667.104;
00679 }
00680 else{
00681 MSG("CDAnalysis",Msg::kWarning)
00682 <<"SetSigCorPerMEU: SimFlag not set"<<endl;
00683 }
00684
00685 MSG("CDAnalysis",Msg::kInfo)
00686 <<"Using sigcor per MEU="<<fSigCorPerMEU<<endl;
00687 }
00688
00689
00690
00691 void CDAnalysis::SetScEnDepPerMEU()
00692 {
00693
00694 fScEnDepPerMEU=0.00195253*Munits::gigaelectronvolt;
00695
00696
00697
00698 MSG("CDAnalysis",Msg::kInfo)
00699 <<"Using ScEnDep per MEU="<<fScEnDepPerMEU<<endl;
00700 }
00701
00702
00703
00704 void CDAnalysis::SetRatioScEnToBeamEn()
00705 {
00706
00707 fRatioScEnToBeamEn=0.056064;
00708
00709
00710
00711 MSG("CDAnalysis",Msg::kInfo)
00712 <<"Using Ratio ScEn/BeamEn="<<fRatioScEnToBeamEn<<endl;
00713 }
00714
00715
00716
00717 TFile* CDAnalysis::OpenFile(Int_t runNumber,std::string prefix)
00718 {
00719
00720 TFile* outputFile=0;
00721
00722
00723 char *anaDir=getenv("CDANA_DIR");
00724
00725
00726 string sAnaDir="";
00727
00728 if (anaDir!=NULL) {
00729 sAnaDir=anaDir;
00730 }
00731 else {
00732 MSG("CDAnalysis",Msg::kInfo)
00733 <<"Environmental variable $CDANA_DIR not set."
00734 <<" Writing file(s) to current directory"<<endl;
00735 sAnaDir=".";
00736 }
00737
00738
00739 string sRunNumber=Form("%d",runNumber);
00740 string sDetector="C";
00741 string sPrefix="h";
00742 if (prefix!="") sPrefix+=prefix;
00743
00744 string sBase=sAnaDir+"/"+sPrefix+sDetector+sRunNumber;
00745 string sFileName=sBase+".root";
00746
00747
00748 ifstream Test(sFileName.c_str());
00749
00750
00751 if(!Test){
00752 outputFile=new TFile(sFileName.c_str(),"RECREATE");
00753 }
00754 else {
00755
00756 Int_t fred=1;
00757 while(Test) {
00758 Test.close();
00759 string sAppendage=Form("%d",fred);
00760 sFileName=sBase+"_"+sAppendage+".root";
00761 Test.open(sFileName.c_str());
00762 fred++;
00763 }
00764 outputFile=new TFile(sFileName.c_str(),"NEW");
00765 outputFile->SetCompressionLevel(9);
00766 }
00767
00768 string sTmp="No File!";
00769 if (outputFile) sTmp=outputFile->GetName();
00770
00771 MSG("CDAnalysis",Msg::kInfo)
00772 <<"Output file opened: "<<sTmp<<endl;
00773 return outputFile;
00774 }
00775
00776
00777
00778 ofstream* CDAnalysis::OpenTxtFile(Int_t runNumber,std::string prefix)
00779 {
00780
00781 ofstream* outputFile=0;
00782
00783
00784 string sRunNumber=Form("%d",runNumber);
00785 string sDetector="C";
00786 string sPrefix="";
00787 string sAnaDir=".";
00788 if (prefix!="") sPrefix+=prefix;
00789 string sBase=sAnaDir+"/"+sPrefix+sDetector+sRunNumber;
00790 string sFileName=sBase+".txt";
00791
00792 outputFile=new ofstream(sFileName.c_str());
00793
00794 if (outputFile){
00795 MSG("CDAnalysis",Msg::kInfo)
00796 <<"Output txt file opened: "<<sFileName<<endl;
00797 }
00798 else{
00799 MSG("CDAnalysis",Msg::kInfo)
00800 <<"Txt file NOT opened: "<<sFileName<<endl;
00801 }
00802
00803 return outputFile;
00804 }
00805
00806
00807
00808 TGraph* CDAnalysis::TGraphVect(const std::vector<Double_t>& vX,
00809 const std::vector<Double_t>& vY) const
00810 {
00811 MSG("CDAnalysis",Msg::kDebug)
00812 <<" ** Running TGraphVect method... **"<<endl;
00813
00814 TGraph* g=new TGraph(vX.size());
00815
00816 for (UInt_t i=0;i<vX.size();i++){
00817 g->SetPoint(i,vX[i],vY[i]);
00818 }
00819
00820 MSG("CDAnalysis",Msg::kDebug)
00821 <<" ** Finished TGraphVect method **"<<endl;
00822 return g;
00823 }
00824
00825
00826 void CDAnalysis::TGraphMinMax(vector<TGraph*>& v) const
00827 {
00828 Float_t max=-1e200;
00829 Float_t min=+1e200;
00830
00831 for (vector<TGraph*>::iterator vIt=v.begin();vIt!=v.end();++vIt){
00832 for (Int_t i=0;i<(*vIt)->GetN();i++){
00833 Double_t x=0;
00834 Double_t y=0;
00835 (*vIt)->GetPoint(i,x,y);
00836
00837
00838 if (y>max) max=y;
00839 if (y<min) min=y;
00840 }
00841 }
00842
00843 MSG("CDAnalysis",Msg::kDebug)
00844 <<"Found min="<<min<<", max="<<max<<endl;
00845
00846
00847 for (vector<TGraph*>::iterator vIt=v.begin();vIt!=v.end();++vIt){
00848 (*vIt)->SetMinimum(min-0.1*(max-min));
00849 (*vIt)->SetMaximum(max+0.1*(max-min));
00850 }
00851 }
00852
00853
00854
00855 TGraph* CDAnalysis::TGraphMap(const std::map<Int_t,Float_t>& m) const
00856 {
00857 MSG("CDAnalysis",Msg::kDebug)
00858 <<" ** Running TGraphMap method... **"<<endl;
00859
00860 TGraph* g=new TGraph(m.size());
00861
00862 map<Int_t,Float_t>::const_iterator mIter=m.begin();
00863
00864 Int_t i=0;
00865
00866 while (mIter!=m.end()){
00867 g->SetPoint(i,mIter->first,mIter->second);
00868
00869 i++;
00870 mIter++;
00871 }
00872
00873 MSG("CDAnalysis",Msg::kDebug)
00874 <<" ** Finished TGraphMap method **"<<endl;
00875 return g;
00876 }
00877
00878
00879
00880 Int_t CDAnalysis::SumMapValues(const std::map<Int_t,Int_t>& mapIn) const
00881 {
00882 Int_t sum=0;
00883
00884
00885 for (map<Int_t,Int_t>::const_iterator it=mapIn.begin();
00886 it!=mapIn.end();++it){
00887 sum+=it->second;
00888 }
00889
00890 return sum;
00891 }
00892
00893
00894
00895 void CDAnalysis::NormaliseVector(std::vector<Double_t>& v,
00896 Int_t mode) const
00897 {
00898 MSG("CDAnalysis",Msg::kDebug)
00899 <<" ** Running NormaliseVector method... **"<<endl;
00900
00901 if (v.size()>0){
00902
00903 if (mode==1){
00904
00905 Double_t average=0;
00906 for (UInt_t i=0;i<v.size();i++) average+=v[i];
00907 average/=v.size();
00908
00909 MSG("CDAnalysis",Msg::kVerbose)<<"Average="<<average<<endl;
00910
00911
00912 for (UInt_t i=0;i<v.size();i++) v[i]/=average;
00913 }
00914 else if (mode==2){
00915
00916 Double_t vMax=-9e50;
00917 Double_t vMin=9e50;
00918
00919
00920 for (UInt_t i=0;i<v.size();i++){
00921 if (v[i]>vMax) vMax=v[i];
00922 if (v[i]<vMin) vMin=v[i];
00923 }
00924
00925
00926 Int_t numBins=300;
00927 if (4*v.size()<10000) numBins=4*v.size();
00928
00929 MSG("LIAnalysis",Msg::kInfo)
00930 <<"vMax="<<vMax <<", vMin="<<vMin<<", numBins="<<numBins<<endl;
00931
00932
00933 TH1F* h=new TH1F("h","h",numBins,vMin-abs(0.1*vMin),
00934 vMax+abs(0.1*vMin));
00935 h->SetBit(TH1::kCanRebin);
00936
00937 Double_t average=0;
00938 for (UInt_t i=0;i<v.size();i++){
00939
00940 average+=v[i];
00941
00942
00943 h->Fill(v[i]);
00944 }
00945 average/=v.size();
00946
00947
00948 h->Fit("gaus","q0");
00949 TF1* func=h->GetFunction("gaus");
00950 Double_t p1=func->GetParameter(1);
00951 Double_t p2=func->GetParameter(2);
00952
00953
00954 Double_t avToNormWith=p1;
00955 if (p1<vMin || p1>vMax) avToNormWith=average;
00956
00957 MSG("LIAnalysis",Msg::kInfo)
00958 <<"Fitted mean="<<p1
00959 <<" (average="<<average
00960 <<") fitted rms="<<p2
00961 <<", using avToNormWith="<<avToNormWith<<endl;
00962
00963
00964 for (UInt_t i=0;i<v.size();i++) v[i]/=avToNormWith;
00965
00966 delete h;
00967 }
00968 }
00969
00970 MSG("CDAnalysis",Msg::kDebug)
00971 <<" ** Finished NormaliseVector method **"<<endl;
00972 }
00973
00974
00975
00976 void CDAnalysis::SetLoopVariables(Int_t event)
00977 {
00978 Float_t fract=ceil(fEvents/20.);
00979
00980 if (ceil(((Float_t)event)/fract)==((Float_t)event)/fract){
00981 MSG("CDAnalysis",Msg::kInfo)
00982 <<"Fraction of loop complete: "<<event
00983 <<"/"<<fEvents<<" ("
00984 <<(Int_t)(100.*event/fEvents)<<"%)"<<endl;
00985 }
00986
00987
00988 fTrackerTree->GetEvent(event);
00989
00990
00991 this->InitialiseLoopVariables();
00992
00993 this->InitialisePidVariables();
00994
00995
00996 if (fPIDInfo){
00997 fTriggerPMT=fPIDInfo->GetTriggerPMT();
00998 fFafErr=fPIDInfo->GetFafErr() ;
00999 fSparseErr=fPIDInfo->GetSparseErr();
01000 fTrigSource=fPIDInfo->GetTrigSource();
01001 fKovADC1=fPIDInfo->GetKovADC1() ;
01002 fKovTimeStamp1=fPIDInfo->GetKovTimeStamp1();
01003 fKovADC2=fPIDInfo->GetKovADC2();
01004 fKovTimeStamp2=fPIDInfo->GetKovTimeStamp2();
01005 fKovADC3=fPIDInfo->GetKovADC3();
01006 fKovTimeStamp3=fPIDInfo->GetKovTimeStamp3();
01007 fSnarlTimeFrame=fPIDInfo->GetSnarlTimeFrame();
01008 fSnarlMinTimeStamp=fPIDInfo->GetSnarlMinTimeStamp();
01009 fSnarlMaxTimeStamp=fPIDInfo->GetSnarlMaxTimeStamp();
01010 fTofTDC0=fPIDInfo->GetTofTDC0();
01011 fTofTDC1=fPIDInfo->GetTofTDC1();
01012 fTofTDC2=fPIDInfo->GetTofTDC2();
01013 fTofADC0=fPIDInfo->GetTofADC0();
01014 fTofADC1=fPIDInfo->GetTofADC1();
01015 fTofADC2=fPIDInfo->GetTofADC2();
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 fTofADCTimeStamp0=fPIDInfo->GetTofADCTimeStamp0();
01029 fTofADCTimeStamp1=fPIDInfo->GetTofADCTimeStamp1();
01030 fTofADCTimeStamp2=fPIDInfo->GetTofADCTimeStamp2();
01031
01032 fTickSinceLast=fPIDInfo->GetTickSinceLast();
01033
01034
01035 fNoOverlap=fPIDInfo->GetNoOverlap();
01036 fInCERTime=fPIDInfo->GetInCERTime();
01037 fPIDType=fPIDInfo->GetPIDType();
01038 fNoOverlapBits=fPIDInfo->GetNoOverlapBits();
01039 fInCERTimeBits=fPIDInfo->GetInCERTimeBits();
01040 fOLChi2=fPIDInfo->GetOLChi2();
01041 }
01042 }
01043
01044
01045
01046 void CDAnalysis::PrintBasicInfo(std::string s) const
01047 {
01048 MSG("CDAnalysis",Msg::kInfo)
01049 <<s<<"(Pl,St,End)=("<<fPlane<<","<<fStrip<<","<<fStripend<<")"
01050 <<", adc="<<fChargeAdc
01051 <<", sigL="<<fChargeSigLin
01052 <<", sigC="<<fChargeSigCor
01053 <<", mip="<<fChargeMip
01054 <<", pe="<<fChargePe
01055 <<endl;
01056 }
01057
01058
01059
01060 void CDAnalysis::PrintEvent(Int_t event)
01061 {
01062 if (event>=fEvents) {
01063 MSG("CDAnalysis",Msg::kFatal)
01064 <<"No such event in tree="<<event<<", fEvents="<<fEvents<<endl;
01065 return;
01066 }
01067
01068 MSG("CDAnalysis",Msg::kInfo)
01069 <<"Printing for event="<<event<<", fEvents="<<fEvents<<endl;
01070
01071
01072 fTrackerTree->GetEvent(event);
01073
01074
01075 TClonesArray &cTrk=*fTrkHitInfo;
01076 Int_t numTrkHits=fTrkHitInfo->GetEntries();
01077 TClonesArray &cUnTrk = *fUnTrkHitInfo;
01078 Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
01079 TClonesArray &cXTalk = *fXTalkHits;
01080 Int_t numXTalkHits=fXTalkHits->GetEntries();
01081
01083
01085 MSG("CDAnalysis",Msg::kInfo)<<"Untracked hits..."<<endl;
01086 for (Int_t hit=0;hit<numUnTrkHits;hit++){
01087
01088 CDTrackedHitInfo *hitInfo=
01089 dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
01090
01091 this->ReadInHitInfo(hitInfo);
01092
01093 this->PrintBasicInfo();
01094 }
01095
01097
01099 MSG("CDAnalysis",Msg::kInfo)<<"XTalk hits..."<<endl;
01100 for (Int_t hit=0;hit<numXTalkHits;hit++){
01101 CDXTalkHitInfo *hitInfo=
01102 dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
01103
01104 this->ReadInHitInfo(hitInfo);
01105
01106 this->PrintBasicInfo();
01107 }
01108
01110
01112 MSG("CDAnalysis",Msg::kInfo)<<"Tracked hits..."<<endl;
01113 for (Int_t hit=0;hit<numTrkHits;hit++){
01114 CDTrackedHitInfo* hitInfo=
01115 dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01116
01117 this->ReadInHitInfo(hitInfo);
01118
01119 this->PrintBasicInfo();
01120 }
01121 }
01122
01123
01124
01125 void CDAnalysis::CalcNumPlanesHit(Int_t plane,Float_t pe)
01126 {
01127
01128 fNumPlanesHitAll[plane]++;
01129
01130
01131 if (plane<25) fNumPlanesHit25[plane]++;
01132
01133
01134 if (pe>1.5) {
01135 fNumPlanesHitPeCut[plane]++;
01136
01137
01138 if (plane<10) fNumPlanesHitPeCut10[plane]++;
01139 }
01140 }
01141
01142
01143
01144 void CDAnalysis::CalcNumPlanesHitTrk(Int_t plane)
01145 {
01146
01147 fNumPlanesHitTrk[plane]++;
01148 }
01149
01150
01151
01152 void CDAnalysis::CalcAvStripForPSMuonCut(Int_t plane,Int_t strip,
01153 Int_t end)
01154 {
01155 if (plane<4){
01156
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
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 }
01177
01178
01179
01180 void CDAnalysis::CalcLowUpScint_TofDiff(Double_t time)
01181 {
01182 Double_t tickInNs=25./16;
01183 Float_t timeDiff=(time*1e9)-(fTofADCTimeStamp1*tickInNs);
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
01199 if (timeDiff>fUpScint_Tof) fUpScint_Tof=timeDiff;
01200 if (timeDiff<fLowScint_Tof) fLowScint_Tof=timeDiff;
01201 }
01202
01203
01204
01205 void CDAnalysis::CalcFirstLastPlane(Int_t plane)
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 }
01212
01213
01214
01215 Int_t CDAnalysis::CalcLastPlaneTruth() const
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
01225 for (Int_t hit=0;hit<numTruthHits;hit++){
01226
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
01235 Int_t sumTruth=pmtTruth1|pmtTruth2;
01236
01237
01238 if ((sumTruth & DigiSignal::kGenuine)==DigiSignal::kGenuine){
01239
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 }
01252
01253
01254
01255 void CDAnalysis::CalcLastPlaneOnTrk()
01256 {
01257
01258 TClonesArray &cTrk=*fTrkHitInfo;
01259 Int_t numTrkHits=fTrkHitInfo->GetEntries();
01260
01262
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
01271 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
01272
01273
01274 this->StandardSanityChecks();
01275
01276
01277 this->CalcFirstLastPlane(fPlane);
01278
01279 }
01281
01283
01284 MSG("CDAnalysis",Msg::kVerbose)
01285 <<"CalcLastPlaneOnTrk: fLastPlane="<<fLastPlane<<endl;
01286 }
01287
01288
01289
01290 Int_t CDAnalysis::CalcLastPlaneOnTrkNoXTalk() const
01291 {
01292
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
01304
01305
01306
01308
01310 for (Int_t hit=0;hit<numUnTrkHits;hit++){
01311
01312 CDTrackedHitInfo *hitInfo=
01313 dynamic_cast<CDTrackedHitInfo*>(cUnTrk[hit]);
01314
01315
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
01322 if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01323
01324 if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01325 chargePe;
01326 }
01327
01329
01331 for (Int_t hit=0;hit<numXTalkHits;hit++){
01332 CDXTalkHitInfo *hitInfo=
01333 dynamic_cast<CDXTalkHitInfo*>(cXTalk[hit]);
01334
01335
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
01342 if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01343
01344 if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01345 chargePe;
01346 }
01347
01349
01351 for (Int_t hit=0;hit<numTrkHits;hit++){
01352 CDTrackedHitInfo* hitInfo=
01353 dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01354
01355
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
01364 if (this->CutOnBadPedestals(plane,strip,stripend)) continue;
01365
01366 if (chargePe>planeGreatestPe[fPlane]) planeGreatestPe[plane]=
01367 chargePe;
01368 }
01370
01372
01373 Int_t newLastPlane=lastPlane;
01374 Double_t xtalkLevel=1.7;
01375
01376 if (fLastPlane>=3){
01377 if (planeGreatestPe[lastPlane]>xtalkLevel){
01378
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 }
01406
01407
01408
01409 void CDAnalysis::ReadInHitInfo(CDTrackedHitInfo* hitInfo)
01410 {
01411
01412 this->InitialiseHitInfoVariables();
01413
01414 fTime=hitInfo->GetTime();
01415
01416
01417 fPlane=hitInfo->GetPlane();
01418 fStrip=hitInfo->GetStrip();
01419 fStripend=hitInfo->GetEnd();
01420 fTransPos=hitInfo->GetTransPos();
01421
01422
01423 fO1=(fStripend==1 && fPlane%2==1);
01424 fO2=(fStripend==2 && fPlane%2==1);
01425 fE1=(fStripend==1 && fPlane%2==0);
01426 fE2=(fStripend==2 && fPlane%2==0);
01427
01428
01429 fChargeAdc=hitInfo->GetCharge(CDTrackedHitInfo::kAdc);
01430 fChargeMip=hitInfo->GetCharge(CDTrackedHitInfo::kMip);
01431 fChargeSigCor=hitInfo->GetCharge(CDTrackedHitInfo::kSigCorr);
01432 fChargeSigLin=hitInfo->GetCharge(CDTrackedHitInfo::kSigLin);
01433 fChargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01434 if (fChargePe!=0) fGain=fChargeSigLin/fChargePe;
01435 else fGain=-1;
01436
01437 static Bool_t firstTime=true;
01438 if (fChargeMip>0 && fChargeSigCor>0 && firstTime){
01439 firstTime=false;
01440 fSigCorsPerMip=fChargeSigCor/fChargeMip;
01441 MAXMSG("CDAnalysis",Msg::kVerbose,100)
01442 <<"fSigCorsPerMip="<<fSigCorsPerMip<<endl;
01443 }
01444
01445
01446 fResultEven=fTrackInfo->GetResult(0);
01447 fResultOdd=fTrackInfo->GetResult(1);
01448 }
01449
01450
01451
01452 void CDAnalysis::ReadInHitInfo(CDXTalkHitInfo* hitInfo)
01453 {
01454
01455 this->InitialiseHitInfoVariables();
01456
01457 fTime=hitInfo->GetTime();
01458
01459
01460 fPlane=hitInfo->GetPlane();
01461 fStrip=hitInfo->GetStrip();
01462 fStripend=hitInfo->GetEnd();
01463
01464 fTransPos=-1;
01465
01466
01467 fO1=(fStripend==1 && fPlane%2==1);
01468 fO2=(fStripend==2 && fPlane%2==1);
01469 fE1=(fStripend==1 && fPlane%2==0);
01470 fE2=(fStripend==2 && fPlane%2==0);
01471
01472
01473 fChargeAdc=hitInfo->GetCharge(CDTrackedHitInfo::kAdc);
01474 fChargeMip=hitInfo->GetCharge(CDTrackedHitInfo::kMip);
01475 fChargeSigCor=hitInfo->GetCharge(CDTrackedHitInfo::kSigCorr);
01476 fChargeSigLin=hitInfo->GetCharge(CDTrackedHitInfo::kSigLin);
01477 fChargePe=hitInfo->GetCharge(CDTrackedHitInfo::kPe);
01478 if (fChargePe!=0) fGain=fChargeSigLin/fChargePe;
01479 else fGain=-1;
01480 }
01481
01482
01483
01484 Float_t CDAnalysis::CalcPathLengthCorection(const TVector3& end1,
01485 const TVector3& end2) const
01486 {
01487
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
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 }
01499
01500
01501
01502 void CDAnalysis::CalcXorYandZ(Int_t strip,Int_t plane,
01503 Float_t& x,Float_t& y,Float_t& z) const
01504 {
01505 Float_t planePitch=5.94*Munits::cm;
01506 Float_t stripWidth=4.1*Munits::cm;
01507 Float_t stripsFromCentre=strip-11.5;
01508 Float_t distFromCentre=stripsFromCentre*stripWidth;
01509
01510
01511 z=plane*planePitch;
01512
01513 if (plane%2==0){
01514 x=-1;
01515 y=distFromCentre;
01516 }
01517 else if (plane%2==1){
01518 x=distFromCentre;;
01519 y=-1;
01520 }
01521 }
01522
01523
01524
01525 void CDAnalysis::TrueHighLowEn(Float_t& highEn,Float_t& lowEn) const
01526 {
01527 if (!fTruthHitInfo) return;
01528
01529
01530 lowEn=999999;
01531 highEn=-1;
01532
01533 TClonesArray &cTruth = *fTruthHitInfo;
01534 Int_t numTruthHits=fTruthHitInfo->GetEntries();
01535
01536
01537 for (Int_t hit=0;hit<numTruthHits;hit++){
01538
01539 CDTruthHitInfo *hitInfo=
01540 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
01541
01542 Double_t energy=hitInfo->GetMainPartEn();
01543 Int_t particle=hitInfo->GetMainParticle();
01544 Int_t muon=13;
01545
01546 if (abs(particle)==muon) {
01547 if (energy>highEn) highEn=energy;
01548 if (energy<lowEn) lowEn=energy;
01549 }
01550 }
01551
01552
01553 if (lowEn==999999) lowEn=-1;
01554 }
01555
01556
01557
01558 void CDAnalysis::TruePLCor(std::map<Int_t,Float_t>& mPLCor,
01559 Int_t event) const
01560 {
01561 Int_t lastPlane=this->GetEventLength();
01562 if (lastPlane<0) return;
01563 Float_t lastPLCor=-1;
01564 Float_t lastPL=-1;
01565
01566 for (Int_t pl=0;pl<=lastPlane;pl++){
01567 Float_t pathLen=this->TrueMainPL(pl,event);
01568
01569
01570 if (pathLen<0.95*Munits::cm) {
01571 if (lastPL>=0.95*Munits::cm) pathLen=lastPL;
01572 else pathLen=0.95*Munits::cm;
01573 }
01574
01575 lastPL=pathLen;
01576
01577 Float_t pathLengthCor=pathLen/(0.95*Munits::cm);
01578 if (pathLengthCor<0.999) {
01579 MAXMSG("CDAnalysis",Msg::kWarning,500)
01580 <<"bad PLCor="<<pathLengthCor<<endl;
01581 if (lastPLCor>=1) pathLengthCor=lastPLCor;
01582 else pathLengthCor=1;
01583 }
01584 else if (pathLengthCor>0.999 && pathLengthCor<1){
01585 MAXMSG("CDAnalysis",Msg::kVerbose,500)
01586 <<"fractionally wrong PLCor="<<pathLengthCor<<endl;
01587 pathLengthCor=1;
01588 }
01589
01590
01591 mPLCor[pl]=pathLengthCor;
01592
01593
01594 lastPLCor=pathLengthCor;
01595 }
01596 }
01597
01598
01599
01600 Bool_t CDAnalysis::CalcPLCor(const std::map<Int_t,TVector3>& mPlPos,
01601 std::map<Int_t,Float_t>& mPLCor) const
01602 {
01603 map<Int_t,TVector3>::const_iterator plPosEndIt=mPlPos.end();
01604
01605
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
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
01622 TGraph gx_z(3);
01623 TGraph gy_z(3);
01624 Int_t tmpPl=plStopSide;
01625 Int_t tmpPlVtxSide=plVtxSide+1;
01626 Bool_t posDir=true;
01627 if (posDir) tmpPlVtxSide=plVtxSide-1;
01628 Int_t i=0;
01629
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
01641 i++;
01642 }
01643
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
01655
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 }
01673
01674
01675
01676 Bool_t CDAnalysis::CalcXYZ(std::map<Int_t,TVector3>& mPlPos) const
01677 {
01678
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
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
01707 for (Int_t hit=0;hit<numTrkHits;hit++){
01708 CDTrackedHitInfo* hitInfo=
01709 dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
01710
01711
01712 Int_t plane=hitInfo->GetPlane();
01713 Int_t strip=hitInfo->GetStrip();
01714 Int_t stripend=hitInfo->GetEnd();
01715
01716
01717
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
01731
01732
01733
01734 for (Int_t np=2;np<=5;np++){
01735
01736 Float_t yAvFirstFew=0;
01737 Float_t yAvFirstFewCounter=0;
01738 for (Int_t pl=0;pl<np*2;pl+=2){
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
01748 Float_t xAvFirstFew=0;
01749 Float_t xAvFirstFewCounter=0;
01750 for (Int_t pl=1;pl<np*2;pl+=2){
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
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
01772 plPosition[0].SetX(xAvFirstFew);
01773 plPosition[1].SetY(yAvFirstFew);
01774
01775
01776
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
01782
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
01799
01800
01801
01803
01805 for (Int_t pl=2;pl<=lastPlane;pl++){
01806
01807 Bool_t foundGap=false;
01808
01809
01810 if (pl%2==0){
01811 if (plPosition[pl].Y()==initValue) foundGap=true;
01812 }
01813 else if (pl%2==1){
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
01830 if (plPrev<0) {
01831 if (abs(plPrev%2)==0) plPrev=0;
01832 else if (abs(plPrev%2)==1) plPrev=1;
01833 }
01834 if (plNext>59){
01835 if (plNext%2==0) plNext=58;
01836 else if (plNext%2==1) plNext=59;
01837 }
01838 if (plPrev4<0) {
01839 if (abs(plPrev4%2)==0) plPrev4=0;
01840 else if (abs(plPrev4%2)==1) plPrev4=1;
01841 }
01842 if (plNext4>59){
01843 if (plNext4%2==0) plNext4=58;
01844 else if (plNext4%2==1) plNext4=59;
01845 }
01846
01847 if (pl%2==0){
01848
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){
01855
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
01870 pos=(posPrev+posNext)*0.5;
01871
01872
01873
01874
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
01885 pos4=(posPrev4+posNext4)*0.5;
01886
01887
01888
01889
01890 }
01891
01892 Float_t posToUse=pos;
01893 if (posToUse==initValue) posToUse=pos4;
01894
01895 if (posToUse!=initValue){
01896 if (pl%2==0){
01897
01898
01899
01900
01901 plPosition[pl].SetY(posToUse);
01902 }
01903 else if (pl%2==1){
01904
01905
01906
01907
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
01926
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){
01932 if (plPosition[pl].Y()==initValue){
01933 plPosition[pl].SetY(lastY);
01934
01935
01936
01937
01938 }
01939
01940 lastY=plPosition[pl].Y();
01941 }
01942 else if (pl%2==1){
01943 if (plPosition[pl].X()==initValue){
01944 plPosition[pl].SetX(lastX);
01945
01946
01947
01948
01949 }
01950
01951 lastX=plPosition[pl].X();
01952 }
01953 }
01954 }
01955
01957
01958
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
01968 if (plPrev<0) {
01969 if (abs(plPrev%2)==0) plPrev=0;
01970 else if (abs(plPrev%2)==1) plPrev=1;
01971 }
01972 if (plNext>59){
01973 if (plNext%2==0) plNext=58;
01974 else if (plNext%2==1) plNext=59;
01975 }
01976
01977 if (pl%2==0){
01978
01979 posPrev=plPosition[plPrev].X();
01980 posNext=plPosition[plNext].X();
01981 }
01982 else if (pl%2==1){
01983
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
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){
02006
02007 plPosition[pl].SetX(pos);
02008 }
02009 else if (pl%2==1){
02010
02011 plPosition[pl].SetY(pos);
02012 }
02013 }
02014
02015
02016
02017 Int_t pl=lastPlane;
02018 if (pl%2==0){
02019
02020 Float_t lastPlX=plPosition[pl-1].X();
02021 plPosition[pl].SetX(lastPlX);
02022 }
02023 else if (pl%2==1){
02024
02025 Float_t lastPlY=plPosition[pl-1].Y();
02026 plPosition[pl].SetY(lastPlY);
02027 }
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042 for (Int_t pl=0;pl<60;pl++){
02043 mPlPos[pl]=plPosition[pl];
02044 }
02045
02046 return true;
02047 }
02048
02049
02050
02051 Float_t CDAnalysis::CalcDistToPlaneCentre(Int_t strip,
02052 Float_t transPos) const
02053 {
02054 Float_t stripSize=0.041*Munits::m;
02055 Float_t distToPlaneCentre=-1;
02056
02057
02058
02059
02060
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
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
02076 dist1=stripsFromCentre1*stripSize;
02077 dist2=transPosFromCentre1*stripSize;
02078
02079
02080
02081 dist1+=stripSize*0.5;
02082
02083
02084
02085 if (dist1>0 && dist2>0){
02086 distToPlaneCentre=sqrt(pow(dist1,2)+pow(dist2,2));
02087 }
02088
02089 return distToPlaneCentre;
02090 }
02091
02092
02093
02094 Float_t CDAnalysis::TrueDistToPlaneCentre(Int_t strip,
02095 Float_t x) const
02096 {
02097 Float_t stripSize=0.041*Munits::m;
02098 Float_t distToPlaneCentre=-1;
02099
02100
02101 if (strip<0 || strip>23 || x>0.5 || x<-0.5) return distToPlaneCentre;
02102
02103 Float_t dist1=-1;
02104 Float_t dist2=-1;
02105 Float_t stripsFromCentre1=-1;
02106
02107
02108 if (strip<=11) stripsFromCentre1=11-strip;
02109 else if (strip>11) stripsFromCentre1=strip-12;
02110 if (x<0) x=x-2*x;
02111
02112
02113 dist1=stripsFromCentre1*stripSize;
02114 dist2=x;
02115
02116
02117
02118 dist1+=stripSize*0.5;
02119
02120
02121 if (dist1>0 && dist2>0){
02122 distToPlaneCentre=sqrt(pow(dist1,2)+pow(dist2,2));
02123 }
02124
02125 return distToPlaneCentre;
02126 }
02127
02128
02129
02130 void CDAnalysis::StandardSanityChecks() const
02131 {
02132
02133 if (fChargeAdc<1){
02134 MSG("CDAnalysis",Msg::kFatal)
02135 <<"Run has bad adcs!"<<endl
02136 <<"adc="<<fChargeAdc<<" ("<<fPlane<<":"<<fStrip<<":"<<fStripend
02137 <<")"<<endl;
02138 assert(false);
02139 }
02140 }
02141
02142
02143
02144 void CDAnalysis::ScaleVector(std::vector<Double_t>& v,
02145 Double_t scaleFactor) const
02146 {
02147 MSG("CDAnalysis",Msg::kDebug)
02148 <<" ** Running ScaleVector method... **"<<endl;
02149
02150 for (UInt_t i=0;i<v.size();i++) v[i]*=scaleFactor;
02151
02152 MSG("CDAnalysis",Msg::kDebug)
02153 <<" ** Finished ScaleVector method **"<<endl;
02154 }
02155
02156
02157
02158 void CDAnalysis::FlipVector(std::vector<Double_t>& v) const
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 }
02170
02171
02172
02173 Int_t CDAnalysis::Rnd(Double_t x) const
02174 {
02175 Double_t xi=0;
02176
02177 Double_t floatPart=modf(x,&xi);
02178
02179
02180 if (floatPart>0.5) xi++;
02181
02182 return static_cast<Int_t>(xi);
02183 }
02184
02185
02186
02187 void CDAnalysis::ScaleMap(std::map<Int_t,Float_t>& m,
02188 const std::map<Int_t,Float_t>& scaleFactor) const
02189 {
02190 MSG("CDAnalysis",Msg::kDebug)
02191 <<" ** Running ScaleMap method... **"<<endl;
02192
02193 if (m.size()==scaleFactor.size()){
02194
02195 map<Int_t,Float_t>::iterator mIter=m.begin();
02196 map<Int_t,Float_t>::const_iterator scale=scaleFactor.begin();
02197
02198
02199 while (mIter!=m.end()){
02200
02201
02202 if (scale->second!=0){
02203 MSG("CDAnalysis",Msg::kVerbose)
02204 <<"mIter="<<mIter->second<<", scale="<<scale->second<<endl;
02205 mIter->second/=scale->second;
02206 }
02207 else MSG("CDAnalysis",Msg::kWarning)<<"Scale factor zero!"<<endl;
02208
02209 mIter++;
02210 scale++;
02211 }
02212 }
02213 else{
02214 MSG("CDAnalysis",Msg::kWarning)
02215 <<"Not scaling map, vectors are different sizes!"<<endl;
02216 }
02217
02218 MSG("CDAnalysis",Msg::kDebug)
02219 <<" ** Finished ScaleMap method **"<<endl;
02220 }
02221
02222
02223
02224 Bool_t CDAnalysis::CutOnFiducialVolume() const
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 }
02242
02243
02244
02245 Bool_t CDAnalysis::CutOnNumHitsPerPlane() const
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 }
02265
02266
02267
02268 Bool_t CDAnalysis::CutOnNumHitsPerPlane10() const
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 }
02289
02290
02291
02292 Bool_t CDAnalysis::CutOnDeadChips() const
02293 {
02294 Bool_t cutThisOne=false;
02295
02296
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 }
02307
02308
02309
02310 Bool_t CDAnalysis::CutOnBadPedestals(Int_t plane,Int_t strip,
02311 Int_t end) const
02312 {
02313
02314 if (fSimFlag!=SimFlag::kData) return false;
02315
02316 Bool_t cutThisOne=false;
02317
02318
02319
02320
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
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
02335
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 }
02345
02346
02347
02348 Bool_t CDAnalysis::CutOnBadCalorimetry(Int_t plane,Int_t strip,
02349 Int_t end) const
02350 {
02351
02352 if (fSimFlag!=SimFlag::kData) return false;
02353
02354 Bool_t cutThisOne=false;
02355
02356
02357
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 }
02368
02369
02370
02371 Bool_t CDAnalysis::CutOnTrackQuality(Bool_t requireGoodTrack) const
02372 {
02373
02374 Bool_t cutThisOne=false;
02375
02376
02377
02378 Bool_t goodFirstPlane=(fFirstPlane>=0 && fFirstPlane<59);
02379 if (requireGoodTrack){
02380 if (!goodFirstPlane) cutThisOne=true;
02381 }
02382
02383
02384
02385
02386
02387
02388
02389
02390 if (cutThisOne){
02391 MAXMSG("CDAnalysis",Msg::kInfo,1)
02392 <<"Applying cut to track quality"<<endl;
02393 }
02394
02395 return cutThisOne;
02396 }
02397
02398
02399
02400 Bool_t CDAnalysis::CutOnOverlap() const
02401 {
02402
02403 Bool_t cutThisOne=false;
02404
02405
02406 if (fSimFlag!=SimFlag::kData) return false;
02407
02408
02409
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 }
02422
02423
02424
02425 Bool_t CDAnalysis::CutOnOverlapForElec() const
02426 {
02427
02428 Bool_t cutThisOne=false;
02429
02430
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 }
02444
02445
02446
02447 Bool_t CDAnalysis::CutOnPidForElec() const
02448 {
02449
02450 Bool_t cutThisOne=false;
02451
02452
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 }
02469
02470
02471
02472 Bool_t CDAnalysis::CutByHandOnPidForElec() const
02473 {
02474
02475 Bool_t cutThisOne=false;
02476
02477
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){
02490
02491 if (fTofTDC2-fTofTDC0>340 && fTofTDC2-fTofTDC0<500) goodTof=true;
02492
02493
02494 if (!elecKovADC1) cutThisOne=true;
02495 if (!elecKovADC3) cutThisOne=true;
02496
02497
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;
02505 if (fKovADC1>1000 && fKovADC1<2500) elecKovADC1=true;
02506 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02507
02508 if ((fTofADCTimeStamp1-fKovTimeStamp3)<-80 &&
02509 (fTofADCTimeStamp1-fKovTimeStamp3)>-85 &&
02510 (fTofADCTimeStamp1-fKovTimeStamp1)<-30 &&
02511 (fTofADCTimeStamp1-fKovTimeStamp1)>-40) elecInTime=true;
02512
02513
02514 if (!elecKovADC1) cutThisOne=true;
02515 if (!elecKovADC3) cutThisOne=true;
02516
02517
02518 if (!goodTof) cutThisOne=true;
02519
02520
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;
02536 if (fKovADC1>1100 && fKovADC1<3100) elecKovADC1=true;
02537 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<470) goodTof=true;
02538
02539 if ((fTofADCTimeStamp1-fKovTimeStamp3)<-20 &&
02540 (fTofADCTimeStamp1-fKovTimeStamp3)>-30 &&
02541 (fTofADCTimeStamp1-fKovTimeStamp1)<-50 &&
02542 (fTofADCTimeStamp1-fKovTimeStamp1)>-62) elecInTime=true;
02543
02544
02545 if (!elecKovADC1) cutThisOne=true;
02546 if (!elecKovADC3) cutThisOne=true;
02547
02548
02549 if (!goodTof) cutThisOne=true;
02550
02551
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 }
02571
02572
02573
02574 Bool_t CDAnalysis::CutOnPid() const
02575 {
02576
02577 Bool_t cutThisOne=false;
02578
02579
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 }
02599
02600
02601
02602 Bool_t CDAnalysis::CutByHandOnPid() const
02603 {
02604
02605 Bool_t cutThisOne=false;
02606
02607
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){
02616 if (fKovADC3<500) muonKovADC3=true;
02617 if (fKovADC1<300) muonKovADC1=true;
02618 if (fTofTDC2-fTofTDC0>340 && fTofTDC2-fTofTDC0<500) goodTof=true;
02619
02620
02621 if (!muonKovADC1) cutThisOne=true;
02622 if (!muonKovADC3) cutThisOne=true;
02623
02624
02625 if (!goodTof) cutThisOne=true;
02626 }
02627 else if (fRunNumber==70709){
02628
02629 string particleSelection="notElectrons";
02630
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;
02637 if (fKovADC1<500) muonKovADC1=true;
02638 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02639
02640 if ((fTofADCTimeStamp1-fKovTimeStamp3)<-78 &&
02641 (fTofADCTimeStamp1-fKovTimeStamp3)>-96) muonInTime=true;
02642
02643
02644 if (!muonKovADC1) cutThisOne=true;
02645 if (!muonKovADC3) cutThisOne=true;
02646
02647
02648 if (!goodTof) cutThisOne=true;
02649
02650
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;
02658 if (fKovADC1<500) muonKovADC1=true;
02659 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02660
02661
02662 if (!muonKovADC1) cutThisOne=true;
02663 if (!muonKovADC3) cutThisOne=true;
02664
02665
02666 if (!goodTof) cutThisOne=true;
02667
02668
02669 }
02670 }
02671 else if (fRunNumber==71266){
02672 if (fKovADC3<1400) muonKovADC3=true;
02673 if (fKovADC1<1000) muonKovADC1=true;
02674 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<450) goodTof=true;
02675
02676
02677 if (!muonKovADC1) cutThisOne=true;
02678 if (!muonKovADC3) cutThisOne=true;
02679
02680
02681 if (!goodTof) cutThisOne=true;
02682 }
02683 else if (fRunNumber==100131){
02684 if (fKovADC3<1000) muonKovADC3=true;
02685 if (fKovADC1<500) muonKovADC1=true;
02686 if (fTofTDC2-fTofTDC0>370 && fTofTDC2-fTofTDC0<525) goodTof=true;
02687
02688
02689 if (!muonKovADC1) cutThisOne=true;
02690 if (!muonKovADC3) cutThisOne=true;
02691
02692
02693 if (!goodTof) cutThisOne=true;
02694 }
02695 else if (fRunNumber==100161){
02696
02697
02698 string particleSelection="notElectrons";
02699
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;
02707 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02708
02709 if ((fTofADCTimeStamp1-fKovTimeStamp3)<-24 &&
02710 (fTofADCTimeStamp1-fKovTimeStamp3)>-45) muonInTime=true;
02711
02712
02713 if (!muonKovADC1) cutThisOne=true;
02714 if (!muonKovADC3) cutThisOne=true;
02715
02716
02717 if (!goodTof) cutThisOne=true;
02718
02719
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;
02728 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02729
02730
02731 if (!muonKovADC1) cutThisOne=true;
02732 if (!muonKovADC3) cutThisOne=true;
02733
02734
02735 if (!goodTof) cutThisOne=true;
02736
02737
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;
02745 if (fTofTDC2-fTofTDC0>385 && fTofTDC2-fTofTDC0<490) goodTof=true;
02746
02747
02748 if (!muonKovADC1) cutThisOne=true;
02749 if (!muonKovADC3) cutThisOne=true;
02750
02751
02752 if (!goodTof) cutThisOne=true;
02753
02754
02755 }
02756 }
02757 else if (fRunNumber==100243){
02758 if (fKovADC3<900) muonKovADC3=true;
02759 if (fKovADC1<1000) muonKovADC1=true;
02760 if (fTofTDC2-fTofTDC0>350 && fTofTDC2-fTofTDC0<490) goodTof=true;
02761
02762
02763 if (!muonKovADC1) cutThisOne=true;
02764 if (!muonKovADC3) cutThisOne=true;
02765
02766
02767 if (!goodTof) cutThisOne=true;
02768
02769 }
02770 else if (fRunNumber==100270){
02771 if (fKovADC3<1100) muonKovADC3=true;
02772 if (fKovADC1<500) muonKovADC1=true;
02773 if (fTofTDC2-fTofTDC0>360 && fTofTDC2-fTofTDC0<525) goodTof=true;
02774
02775
02776 if (!muonKovADC1) cutThisOne=true;
02777 if (!muonKovADC3) cutThisOne=true;
02778
02779
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 }
02790
02791
02792
02793 Bool_t CDAnalysis::CutOnScint_TofDiff() const
02794 {
02795
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 }
02815
02816
02817
02818 void CDAnalysis::GetLowUpTimeCuts(Float_t& lowTime,
02819 Float_t& upTime) const
02820 {
02821
02822 lowTime=-1000000;
02823 upTime=1000000;
02824
02825 Int_t run=fRunNumber;
02826
02827
02828
02829 Int_t lowTimeLimit=35;
02830 Int_t upTimeLimit=295;
02831 Int_t peak=-1;
02832
02833
02834 if (fSimFlag==SimFlag::kData) {
02835 if (run>=40000 && run<50000){
02836
02837 peak=-125;
02838 lowTime=peak-lowTimeLimit;
02839 upTime=peak+upTimeLimit;
02840 }
02841 else if (run>=50000 && run<60000){
02842
02843 peak=30;
02844 lowTime=peak-lowTimeLimit;
02845 upTime=peak+upTimeLimit;
02846 }
02847 else if (run>=70000 && run<80000){
02848
02849 peak=5;
02850 lowTime=peak-lowTimeLimit;
02851 upTime=peak+upTimeLimit;
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 }
02867
02868
02869
02870 Bool_t CDAnalysis::CutOnEventLengthForElec() const
02871 {
02872
02873 Bool_t cutThisOne=false;
02874
02875
02876 Int_t maxPlane=20;
02877
02878
02879
02880
02881
02882
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 }
02894
02895
02896
02897 void CDAnalysis::GetEvLenMinMax(Int_t& minPlane,Int_t& maxPlane) const
02898 {
02899
02900
02901 Float_t aBeamP=fabs(fBeamMomentum);
02902
02903
02904
02905 if (fabs(fBeamMomentum)>1.3 && fabs(fBeamMomentum)<1.5){
02906 minPlane=31;
02907 maxPlane=45;
02908 }
02909 else if (fabs(fBeamMomentum)>1.5 && fabs(fBeamMomentum)<1.7){
02910 minPlane=35;
02911 maxPlane=51;
02912 }
02913 else if (fabs(fBeamMomentum)>1.7 && fabs(fBeamMomentum)<1.9){
02914 minPlane=39;
02915 maxPlane=56;
02916 }
02917 else if (fabs(fBeamMomentum)>1.9){
02918 minPlane=44;
02919 maxPlane=57;
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 }
02931
02932
02933
02934 Bool_t CDAnalysis::CutOnNumPlanesHit(Int_t planesHit) const
02935 {
02936
02937 Bool_t cutThisOne=false;
02938
02939 Int_t minPlane=0;
02940 Int_t maxPlane=60;
02941
02942 this->GetEvLenMinMax(minPlane,maxPlane);
02943
02944
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 }
02959
02960
02961
02962 Bool_t CDAnalysis::CutOnPSMuons() const
02963 {
02964
02965 Bool_t cutThisOne=false;
02966
02967 if (fAvStrip<9|| fAvStrip>13){
02968 cutThisOne=true;
02969 }
02970
02971 return cutThisOne;
02972 }
02973
02974
02975
02976 Int_t CDAnalysis::GetEventLength() const
02977 {
02978 Int_t lastPlane=fLastPlane;
02979
02980
02981
02982
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 }
02993
02994
02995
02996 Bool_t CDAnalysis::CutOnEventLength() const
02997 {
02998
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
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 }
03023
03024
03025
03026 Bool_t CDAnalysis::CutByHandOnEventLength() const
03027 {
03028
03029 Bool_t cutThisOne=false;
03030
03031 Int_t minPlane=0;
03032 Int_t maxPlane=60;
03033
03034 if (fSimFlag==SimFlag::kData){
03035
03036
03037
03038 if (fRunNumber==70709 ||
03039 fRunNumber==71266 ||
03040 fRunNumber==100161 ||
03041 fRunNumber==100270){
03042
03043 minPlane=42;
03044 maxPlane=57;
03045 if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03046 }
03047 else if (fRunNumber==100243){
03048 minPlane=40;
03049 maxPlane=49;
03050 if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03051 }
03052 else if (fRunNumber==100131){
03053 minPlane=35;
03054 maxPlane=44;
03055 if (fLastPlane<minPlane || fLastPlane>maxPlane) cutThisOne=true;
03056 }
03057 else if (fRunNumber==70579){
03058
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;
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 }
03103
03104
03105
03106 void CDAnalysis::FillProfHisto(TProfile* prof,
03107 std::map<Int_t,Float_t>& counter,
03108 const std::map<Int_t,Float_t>& addMe,
03109 Int_t offset) const
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 }
03126
03127
03128
03129 Bool_t CDAnalysis::IsPlaneXTalkOnly(Int_t inplane) const
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
03139 for (Int_t hit=0;hit<numTruthHits;hit++){
03140
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
03152 sumTruth|=pmtTruth1;
03153 sumTruth|=pmtTruth2;
03154
03155 MSG("CDAnalysis",Msg::kVerbose)
03156 <<"sumTruth="<<sumTruth<<endl;
03157 }
03158
03159
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 }
03172
03173
03174
03175 Bool_t CDAnalysis::IsPlaneGenuine(Int_t inplane) const
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
03188 for (Int_t hit=0;hit<numTruthHits;hit++){
03189
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
03201 sumTruth|=pmtTruth1;
03202 sumTruth|=pmtTruth2;
03203
03204 MSG("CDAnalysis",Msg::kVerbose)
03205 <<"sumTruth="<<sumTruth<<endl;
03206 }
03207
03208
03209 Bool_t genuineBit=((sumTruth & DigiSignal::kGenuine)==
03210 DigiSignal::kGenuine);
03211
03212 if (genuineBit) return true;
03213 else return false;
03214 }
03215
03216
03217
03218 Bool_t CDAnalysis::IsSharedPmtHit(Int_t inplane) const
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
03228 for (Int_t hit=0;hit<numTruthHits;hit++){
03229
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 }
03248
03249
03250
03251 Bool_t CDAnalysis::IsPlaneSideHit(Int_t inplane,Int_t stripEnd) const
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
03261 for (Int_t hit=0;hit<numTruthHits;hit++){
03262
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;
03277 }
03278 if (pmtTruth2 && stripEnd==StripEnd::kWest){
03279 planeSideHit=true;
03280 break;
03281 }
03282 }
03283
03284 MSG("CDAnalysis",Msg::kVerbose)
03285 <<"planeSideHit="<<planeSideHit<<endl;
03286
03287 return planeSideHit;
03288 }
03289
03290
03291
03292 Bool_t CDAnalysis::IsDoubleEnded(Int_t inplane) const
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
03302 for (Int_t hit=0;hit<numTruthHits;hit++){
03303
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 }
03322
03323
03324
03325 Bool_t CDAnalysis::IsGenuineOrXTalk(Int_t inplane) const
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
03335 for (Int_t hit=0;hit<numTruthHits;hit++){
03336
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
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 }
03374
03375
03376
03377 Bool_t CDAnalysis::StraightTrack_Radius(Double_t radiusCut) const
03378 {
03379
03380 if (radiusCut<0) radiusCut=radiusCut-2*radiusCut;
03381
03382
03383 Bool_t straight=true;
03384
03385
03386 TClonesArray &cTrk=*fTrkHitInfo;
03387 Int_t numTrkHits=fTrkHitInfo->GetEntries();
03388
03389 for (Int_t hit=0;hit<numTrkHits;hit++){
03390 CDTrackedHitInfo *trackedHitInfo=
03391 dynamic_cast<CDTrackedHitInfo*>(cTrk[hit]);
03392
03393 Int_t strip=trackedHitInfo->GetStrip();
03394 Double_t transPos=trackedHitInfo->GetTransPos();
03395
03396
03397 Float_t radius=this->CalcDistToPlaneCentre(strip,transPos);
03398
03399
03400 if (radius>radiusCut){
03401 straight=false;
03402 break;
03403 }
03404 }
03405
03406
03407 return straight;
03408 }
03409
03410
03411
03412 Bool_t CDAnalysis::IsStraightTrack_Radius(Double_t radiusCut) const
03413 {
03414 if (!fTruthHitInfo) return true;
03415
03416
03417
03418
03419 static Int_t event=0;
03420 event++;
03421
03422
03423 if (radiusCut<0) radiusCut=radiusCut-2*radiusCut;
03424
03425 TClonesArray &cTruth = *fTruthHitInfo;
03426 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03427
03428
03429 Bool_t straight=true;
03430
03431
03432 for (Int_t hit=0;hit<numTruthHits;hit++){
03433
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
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
03461 return straight;
03462 }
03463
03464
03465
03466 Bool_t CDAnalysis::IsStraightTrack(Double_t mainX1Cut) const
03467 {
03468 if (!fTruthHitInfo) return true;
03469
03470 TClonesArray &cTruth = *fTruthHitInfo;
03471 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03472
03473
03474 Bool_t straight=true;
03475
03476
03477 for (Int_t hit=0;hit<numTruthHits;hit++){
03478
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
03487 if (abs(mainParticle)==muon &&
03488 (mainX1>mainX1Cut || mainX1<-1*mainX1Cut)){
03489 straight=false;
03490 break;
03491 }
03492 }
03493
03494
03495 return straight;
03496 }
03497
03498
03499
03500 Int_t CDAnalysis::TrueMuonHunter(Int_t event)
03501 {
03503 if (!fTruthHitInfo) return -1;
03504
03505 TClonesArray &cTruth = *fTruthHitInfo;
03506 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03507
03508 Bool_t foundFirstMuon=false;
03509 Int_t firstMuonPlane=-1;
03510
03511
03512 for (Int_t hit=0;hit<numTruthHits;hit++){
03513
03514 CDTruthHitInfo *hitInfo=
03515 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03516
03517 Int_t plane=hitInfo->GetPlane();
03518 Double_t enDep=hitInfo->GetTotalEnDep();
03519
03520 Int_t mainParticle=hitInfo->GetMainParticle();
03521 Double_t mainPartEn=hitInfo->GetMainPartEn();
03522 Int_t muon=13;
03523
03524 if (abs(mainParticle)==muon){
03525
03526 if (!foundFirstMuon){
03527 MSG("CDAnalysis",Msg::kInfo)
03528 <<"Event="<<event<<": First plane with muon="<<plane<<endl;
03529 firstMuonPlane=plane;
03530 foundFirstMuon=true;
03531 }
03532
03533 if (plane>32){
03534 MSG("CDAnalysis",Msg::kInfo)
03535 <<"Plane="<<plane<<", enDep="<<enDep
03536 <<", muon energy="<<mainPartEn<<endl;
03537 }
03538 }
03539
03540 }
03541
03542 return firstMuonPlane;
03543 }
03544
03545
03546
03547 Float_t CDAnalysis::TrueXInStripFrame(Int_t plane,Int_t strip,
03548 Int_t event) const
03549 {
03550 if (!fTruthHitInfo) return -1;
03551
03552 static Int_t lastEvent=-1;
03553 static map<Int_t,Double_t> trueX;
03554 static map<Int_t,Int_t> counter;
03555 Int_t inStripKey=500*plane+strip;
03556
03557
03558
03559 if (event!=lastEvent){
03560
03561 lastEvent=event;
03562
03563
03564 trueX.clear();
03565 counter.clear();
03566
03567
03568
03569 TClonesArray &cTruth = *fTruthHitInfo;
03570 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03571
03572
03573 for (Int_t hit=0;hit<numTruthHits;hit++){
03574
03575 CDTruthHitInfo *hitInfo=
03576 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03577
03578 Int_t pmtTruth1=hitInfo->GetPmtTruth1();
03579 Int_t pmtTruth2=hitInfo->GetPmtTruth2();
03580 Int_t sumTruth=0;
03581
03582
03583 sumTruth|=pmtTruth1;
03584 sumTruth|=pmtTruth2;
03585
03586
03587 Bool_t genuineBit=((sumTruth & DigiSignal::kGenuine)==
03588 DigiSignal::kGenuine);
03589
03590
03591 if (!genuineBit) {
03592 continue;
03593 }
03594
03595 Int_t plane=hitInfo->GetPlane();
03596 Int_t strip=hitInfo->GetStrip();
03597 Int_t stripKey=500*plane+strip;
03598
03599 Double_t mainX1=hitInfo->GetMainX1();
03600 Double_t mainX2=hitInfo->GetMainX2();
03601 Double_t avX=(mainX1+mainX2)*0.5;
03602
03603 if (avX==0){
03604 MSG("CDAnalysis",Msg::kDebug)
03605 <<"CDAnalysis::TrueXInStripFrame::average x="<<avX
03606 <<", enDep="<<hitInfo->GetTotalEnDep()<<endl;
03607 }
03608
03609 trueX[stripKey]=avX;
03610 counter[stripKey]++;
03611 }
03612 }
03613
03614 if (counter[inStripKey]>0) return trueX[inStripKey];
03615 else return -1;
03616 }
03617
03618
03619
03620 Double_t CDAnalysis::TrueEnDep(Int_t inplane,Int_t event) const
03621 {
03622 if (!fTruthHitInfo) return 0;
03623
03624 static Int_t lastEvent=-1;
03625 static map<Int_t,Double_t> plEnDep;
03626
03627
03628
03629 if (event!=lastEvent){
03630
03631 lastEvent=event;
03632
03633
03634 plEnDep.clear();
03635
03636
03637
03638 TClonesArray &cTruth = *fTruthHitInfo;
03639 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03640
03641
03642 for (Int_t hit=0;hit<numTruthHits;hit++){
03643
03644 CDTruthHitInfo *hitInfo=
03645 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03646
03647 Int_t plane=hitInfo->GetPlane();
03648 Double_t enDep=hitInfo->GetTotalEnDep();
03649
03650
03651
03652
03653
03654 plEnDep[plane]+=enDep;
03655 }
03656 }
03657
03658 return plEnDep[inplane];
03659 }
03660
03661
03662
03663 Double_t CDAnalysis::TrueMainPL(Int_t inplane,Int_t event) const
03664 {
03665 if (!fTruthHitInfo) return 0;
03666
03667 static Int_t lastEvent=-1;
03668 static map<Int_t,Double_t> plPL;
03669
03670
03671
03672
03673 if (event!=lastEvent){
03674 MAXMSG("CDAnalysis",Msg::kDebug,50)
03675 <<"Building map..."<<endl;
03676
03677 lastEvent=event;
03678
03679
03680 plPL.clear();
03681
03682
03683
03684
03685 TClonesArray &cTruth = *fTruthHitInfo;
03686 Int_t numTruthHits=fTruthHitInfo->GetEntries();
03687
03688
03689 for (Int_t hit=0;hit<numTruthHits;hit++){
03690
03691 CDTruthHitInfo *hitInfo=
03692 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
03693
03694 Int_t plane=hitInfo->GetPlane();
03695 Int_t strip=hitInfo->GetStrip();
03696 Double_t pathLen=hitInfo->GetMainPathLength();
03697 Int_t particle=hitInfo->GetMainParticle();
03698 Int_t muon=13;
03699
03700 if (abs(particle)!=muon) {
03701 MAXMSG("CDAnalysis",Msg::kDebug,100)
03702 <<"Not a muon so ignoring..."<<endl;
03703 continue;
03704 }
03705
03706 MAXMSG("CDAnalysis",Msg::kDebug,500)
03707 <<"plane="<<plane
03708 <<" (currSt="<<strip<<")"<<", lastPL="<<plPL[plane]*100
03709 <<", currentPL="<<pathLen*100<<endl;
03710 plPL[plane]+=pathLen;
03711
03712 }
03713 MAXMSG("CDAnalysis",Msg::kDebug,50)
03714 <<"Finished building map"<<endl;
03715 }
03716
03717 return plPL[inplane];
03718 }
03719
03720
03721
03722 Double_t CDAnalysis::GetMainParticleEnergy() const
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
03732 for (Int_t hit=0;hit<numTruthHits;hit++){
03733
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
03743 if (en>mainEnergy) {
03744 mainEnergy=en;
03745 MSG("CDAnalysis",Msg::kDebug)
03746 <<"mainEnergy="<<mainEnergy<<endl;
03747 }
03748 }
03749
03750 return mainEnergy;
03751 }
03752
03753
03754
03755 Double_t CDAnalysis::GetGreatestMainParticleEnergy(Int_t nEvents) const
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
03764 fTrackerTree->GetEvent(event);
03765
03766 Double_t mEn=this->GetMainParticleEnergy();
03767
03768
03769 if (mEn>mainEnergy) mainEnergy=mEn;
03770 }
03771
03772 return mainEnergy;
03773 }
03774
03775
03776
03777 Double_t CDAnalysis::CalcMeuPLCorrected(std::map<Int_t,Float_t> plEnDep,
03778 std::map<Int_t,Float_t> plPLCor,
03779 Int_t event,
03780 Float_t* GeVPerMeu
03781 ) const
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;
03791 Float_t localEnDep=0;
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
03807 if (endPlane>=0){
03808 MAXMSG("CDAnalysis",Msg::kDebug,100)
03809 <<"Analysing track window, vtxPl=0"
03810 <<", endPl="<<endPlane<<endl;
03811
03813
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
03825 pathLengthCor=1;
03826 }
03827
03829
03831 if ((materialFromTrkEnd+
03832 pathLengthCor*material01Pl)>material16Pl &&
03833
03834
03835 materialInWindow<material14Pl){
03836
03837
03838
03839
03840
03841
03842
03843 Float_t plCorEnDep=0;
03844 if (pathLengthCor) plCorEnDep=plEnDep[pl]/pathLengthCor;
03845 localSigCor+=plCorEnDep;
03846 plCounter++;
03847
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
03857
03858 if (materialInWindow+pathLengthCor*material01Pl>material14Pl){
03859
03860 Float_t materialNeeded=material14Pl-materialInWindow;
03861
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
03875 materialInWindow+=fractNeeded*(pathLengthCor*material01Pl);
03876
03877
03878
03879 local14_16+=fractNeeded*plEnDep[pl];
03880 }
03881 else{
03882
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
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
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
03914 pl--;
03915 }
03916 }
03917
03918 Float_t winSigCor=0;
03919 if (plCounter){
03920 winSigCor=localSigCor/plCounter;
03921 localEnDep/=plCounter;
03922
03923 if (GeVPerMeu) *GeVPerMeu=localEnDep;
03924 }
03925
03926
03927 local14_16/=14;
03928
03929
03930 Float_t meu=local14_16;
03931 Bool_t useNoFraction=true;
03932 if (useNoFraction) meu=winSigCor;
03933
03934
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
03942 if (fractWin<1) meu=-1;
03943
03944 return meu;
03945 }
03946
03947
03948
03949 void CDAnalysis::FillEnVsDist(std::map<Int_t,Float_t> plEnDep,
03950 std::map<Int_t,Float_t> plPLCor,
03951 Int_t event) const
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;
03963 Float_t initValue=-999;
03964
03965
03966
03967 map<Int_t,Float_t> truePLCor;
03968 this->TruePLCor(truePLCor,event);
03969
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
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
04119 Int_t endPlane=this->CalcLastPlaneOnTrkNoXTalk();
04120 Int_t planeToStopBefore=0;
04121
04122
04123 if (endPlane>=0){
04124 MAXMSG("CDAnalysis",Msg::kInfo,100)
04125 <<"Filling histo, vtxPl=0"
04126 <<", endPl="<<endPlane<<endl;
04127
04129
04131 Int_t pl=endPlane;
04132 while (pl!=planeToStopBefore){
04133
04134 Float_t pathLengthCor=initValue;
04135 pathLengthCor=plPLCor[pl];
04136 Float_t truePathLengthCor=truePLCor[pl];
04137
04138 if (truePathLengthCor<1) truePathLengthCor=pathLengthCor;
04139 if (pl==endPlane){
04140
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
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
04165
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
04177 if (pl<60 && pl>=0) {
04178
04179
04180 meuSigCorNoPLCorHistos[planesFromTrkEnd]->Fill(plEnDep[pl]);
04181 meuSigCorPLCorHistos[planesFromTrkEnd]->Fill(meuSigCor);
04182
04183
04184
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
04203 meuSigCorNoPLCorZerosHistos[pl]->Fill(plEnDep[pl]);
04204 meuSigCorPLCorZerosHistos[pl]->Fill(meuSigCor);
04205 }
04206 else cout<<"ahhh, pl="<<pl<<endl;
04207
04208
04209 hSigCorPLC->Fill(meuSigCor);
04210 pEnVsDistAll->Fill((materialFromTrkEnd/Munits::cm),meuSigCor);
04211 if (meuSigCor<7000) pEnVsDistAll2->Fill
04212 ((materialFromTrkEnd/Munits::cm),meuSigCor);
04213
04214
04215
04216 if (meuSigCor<5000){
04217 pEnVsDist->Fill((toPlotMaterial/Munits::cm),meuSigCor);
04218
04219
04220
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
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
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
04267 pl--;
04268 }
04269 hMatFromTrkEnd->Fill(materialFromTrkEnd);
04270 hMatFromTrkEndTrue->Fill(trueMaterialFromTrkEnd);
04271 Float_t totalMaterial=materialFromTrkEnd;
04272 materialFromTrkEnd=0;
04273 trueMaterialFromTrkEnd=0;
04274
04276
04278 pl=endPlane;
04279 while (pl!=planeToStopBefore){
04280
04281 Float_t pathLengthCor=initValue;
04282 pathLengthCor=plPLCor[pl];
04283 Float_t truePathLengthCor=truePLCor[pl];
04284
04285 if (truePathLengthCor<1) truePathLengthCor=pathLengthCor;
04286 if (pl==endPlane){
04287
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
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
04312
04313 Float_t toPlotMaterial=plMaterial*0.5+materialFromTrkEnd;
04314
04315
04316
04317 Float_t trueEnDep=this->TrueEnDep(pl,event);
04318 Float_t trueEnDepPLC=-1;
04319 if (truePathLengthCor) {
04320 trueEnDepPLC=trueEnDep/truePathLengthCor;
04321 }
04322
04323
04324
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
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
04375 materialFromTrkEnd+=plMaterial;
04376 trueMaterialFromTrkEnd+=truePlMaterial;
04377
04378
04379 pl--;
04380 }
04381 }
04382 }
04383
04384
04385
04386 Double_t CDAnalysis::TrueEnDepNotSc(Int_t inplane,Int_t event) const
04387 {
04388 if (!fTruthHitInfo) return 0;
04389
04390 static Int_t lastEvent=-1;
04391 static map<Int_t,Double_t> plEnDep;
04392 static map<Int_t,Double_t> plMainPartEn;
04393 static Double_t totalEnDep=0;
04394
04395
04396
04397 if (event!=lastEvent){
04398
04399 MSG("CDAnalysis",Msg::kVerbose)
04400 <<"Clearing the maps..."<<endl;
04401
04402
04403 lastEvent=event;
04404
04405
04406 plEnDep.clear();
04407 plMainPartEn.clear();
04408 totalEnDep=0;
04409
04410
04411
04412 TClonesArray &cTruth = *fTruthHitInfo;
04413 Int_t numTruthHits=fTruthHitInfo->GetEntries();
04414
04415
04416 for (Int_t hit=0;hit<numTruthHits;hit++){
04417
04418 CDTruthHitInfo *hitInfo=
04419 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
04420
04421 Int_t plane=hitInfo->GetPlane();
04422 Int_t mainParticle=hitInfo->GetMainParticle();
04423 Double_t enDep=hitInfo->GetTotalEnDep();
04424 Double_t mainPartEn=hitInfo->GetMainPartEn();
04425
04426 Int_t muon=13;
04427
04428
04429
04430
04431 plEnDep[plane]+=enDep;
04432
04433 if (mainPartEn>plMainPartEn[plane] && abs(mainParticle)==muon){
04434 plMainPartEn[plane]=mainPartEn;
04435 }
04436 }
04437 }
04438
04439 Double_t plEnDepNotSc=0;
04440
04441 if (!(plMainPartEn[inplane]==0 || plMainPartEn[inplane+1]==0)) {
04442 plEnDepNotSc=plMainPartEn[inplane]-plEnDep[inplane]-
04443 plMainPartEn[inplane+1];
04444 totalEnDep+=plEnDep[inplane]+plEnDepNotSc;
04445 }
04446
04447 MSG("CDAnalysis",Msg::kVerbose)
04448 <<"pl="<<inplane<<", pEn="<<plMainPartEn[inplane]
04449 <<", pEn+1="<<plMainPartEn[inplane+1]
04450 <<", eDep="<<1000*plEnDep[inplane]
04451 <<", eDepNotSc="<<1000*plEnDepNotSc
04452 <<", tE="<<totalEnDep
04453 <<endl;
04454
04455 return plEnDepNotSc;
04456 }
04457
04458
04459
04460 Int_t CDAnalysis::TrueNumDigiScintHits(Int_t inplane,
04461 Int_t event) const
04462 {
04463 if (!fTruthHitInfo) return 0;
04464
04465 static Int_t lastEvent=-1;
04466 static map<Int_t,Int_t> numHits;
04467
04468
04469
04470 if (event!=lastEvent){
04471
04472 lastEvent=event;
04473
04474
04475 numHits.clear();
04476
04477
04478
04479 TClonesArray &cTruth = *fTruthHitInfo;
04480 Int_t numTruthHits=fTruthHitInfo->GetEntries();
04481
04482
04483 for (Int_t hit=0;hit<numTruthHits;hit++){
04484
04485 CDTruthHitInfo *hitInfo=
04486 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
04487
04488 Int_t plane=hitInfo->GetPlane();
04489 Int_t numDsh=hitInfo->GetNumDigiScintHits();
04490
04491
04492
04493
04494
04495 numHits[plane]+=numDsh;
04496 }
04497 }
04498
04499 return numHits[inplane];
04500 }
04501
04502
04503
04504 void CDAnalysis::TruthEnDepFe()
04505 {
04506 map<Int_t,Double_t> plEnDep;
04507 map<Int_t,Double_t> plMainPartEn;
04508 Double_t totalEnDep=0;
04509 vector<TH1F*> hEnDepFe;
04510
04511 for (Int_t pl=0;pl<60;pl++){
04512 fS="Energy Deposition in Iron, plane=";
04513 string sPl=Form("%d",pl);
04514 fS+=sPl;
04515 hEnDepFe.push_back(new TH1F(fS.c_str(),fS.c_str(),600,-2,200));
04516 }
04517
04521
04522 this->InitialiseLoopVariables();
04523
04524 for(Int_t event=0;event<fEvents;event++){
04525
04526 this->SetLoopVariables(event);
04527
04528
04529 plEnDep.clear();
04530 plMainPartEn.clear();
04531 totalEnDep=0;
04532
04533
04534
04535 if (!fTruthHitInfo) break;
04536
04537 TClonesArray &cTruth = *fTruthHitInfo;
04538 Int_t numTruthHits=fTruthHitInfo->GetEntries();
04539
04540
04541 for (Int_t hit=0;hit<numTruthHits;hit++){
04542
04543 CDTruthHitInfo *hitInfo=
04544 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
04545
04546 Int_t plane=hitInfo->GetPlane();
04547 Int_t mainParticle=hitInfo->GetMainParticle();
04548 Double_t enDep=hitInfo->GetTotalEnDep();
04549 Double_t mainPartEn=hitInfo->GetMainPartEn();
04550 Double_t earliestT1=hitInfo->GetEarliestT1();
04551 Int_t muon=13;
04552
04553
04554 if (earliestT1>15e-9) continue;
04555 cout<<"Cutting out the decay electron"<<endl;
04556
04557 plEnDep[plane]+=enDep;
04558
04559 if (mainPartEn>plMainPartEn[plane] && abs(mainParticle)==muon){
04560 plMainPartEn[plane]=mainPartEn;
04561 }
04562 }
04563
04564
04565
04566
04567
04568 for (Int_t p=0;p<59;p++){
04569
04570 Double_t plEnDepFe=plMainPartEn[p]-plEnDep[p]-
04571 plMainPartEn[p+1];
04572 totalEnDep+=plEnDep[p]+plEnDepFe;
04573
04574
04575 hEnDepFe[p]->Fill(1000*plEnDepFe);
04576
04577 MSG("CDAnalysis",Msg::kVerbose)
04578 <<"pl="<<p<<", pEn="<<plMainPartEn[p]
04579 <<", pEn+1="<<plMainPartEn[p+1]
04580 <<", eDep="<<1000*plEnDep[p]
04581 <<", eDepFe="<<1000*plEnDepFe
04582 <<", tE="<<totalEnDep
04583 <<endl;
04584
04585 }
04586 }
04587
04588 TCanvas *cEnDep=new TCanvas("cEnDep","EnDep",0,0,1200,800);
04589 cEnDep->SetFillColor(0);
04590 cEnDep->Divide(2,3);
04591 cEnDep->cd(1);
04592 hEnDepFe[0]->Draw();
04593 cEnDep->cd(2);
04594 hEnDepFe[1]->Draw();
04595 cEnDep->cd(3);
04596 hEnDepFe[2]->Draw();
04597 cEnDep->cd(4);
04598 hEnDepFe[3]->Draw();
04599 cEnDep->cd(5);
04600 hEnDepFe[4]->Draw();
04601 cEnDep->cd(6);
04602 hEnDepFe[5]->Draw();
04603
04604 }
04605
04606
04607
04608 void CDAnalysis::TruthEventLength()
04609 {
04610
04611
04612
04613
04614 fOutFile=this->OpenFile(fRunNumber,"EvLen");
04615
04616 TH1F *hEventLength=new TH1F("hEventLength","EventLength hit",
04617 77,-2,75);
04618 hEventLength->GetXaxis()->SetTitle("Event Length (planes)");
04619 hEventLength->GetXaxis()->CenterTitle();
04620 hEventLength->GetYaxis()->SetTitle("");
04621 hEventLength->GetYaxis()->CenterTitle();
04622 hEventLength->SetFillColor(0);
04623 hEventLength->SetBit(TH1::kCanRebin);
04624
04625 TH1F *hEventLength2=new TH1F("hEventLength2","EventLength",77,-2,75);
04626 hEventLength2->GetXaxis()->SetTitle("Event Length (planes)");
04627 hEventLength2->GetXaxis()->CenterTitle();
04628 hEventLength2->GetYaxis()->SetTitle("");
04629 hEventLength2->GetYaxis()->CenterTitle();
04630 hEventLength2->SetFillColor(0);
04631 hEventLength2->SetBit(TH1::kCanRebin);
04632
04633 TH1F *hEventLength3=new TH1F("hEventLength3","EventLength",77,-2,75);
04634 hEventLength3->GetXaxis()->SetTitle("Event Length (planes)");
04635 hEventLength3->GetXaxis()->CenterTitle();
04636 hEventLength3->GetYaxis()->SetTitle("");
04637 hEventLength3->GetYaxis()->CenterTitle();
04638 hEventLength3->SetFillColor(0);
04639 hEventLength3->SetBit(TH1::kCanRebin);
04640
04641 TH1F *hEventLength4=new TH1F("hEventLength4","EventLength",77,-2,75);
04642 hEventLength4->GetXaxis()->SetTitle("Event Length (planes)");
04643 hEventLength4->GetXaxis()->CenterTitle();
04644 hEventLength4->GetYaxis()->SetTitle("");
04645 hEventLength4->GetYaxis()->CenterTitle();
04646 hEventLength4->SetFillColor(0);
04647 hEventLength4->SetBit(TH1::kCanRebin);
04648
04652
04653 this->InitialiseLoopVariables();
04654
04655 for(Int_t event=0;event<fEvents;event++){
04656
04657 this->SetLoopVariables(event);
04658
04659 Int_t overallLastPlane=0;
04660 Int_t notNoiseLastPlane=0;
04661 Int_t particleLastPlane=0;
04662
04663 Int_t muonLastPlane=0;
04664
04665 if (!fTruthHitInfo) break;
04666 TClonesArray &cTruth = *fTruthHitInfo;
04667 Int_t numTruthHits=fTruthHitInfo->GetEntries();
04668
04669
04670 for (Int_t hit=0;hit<numTruthHits;hit++){
04671
04672 CDTruthHitInfo *hitInfo=
04673 dynamic_cast<CDTruthHitInfo*>(cTruth[hit]);
04674
04675 Int_t plane=hitInfo->GetPlane();
04676 Int_t mainParticle=hitInfo->GetMainParticle();
04677 Int_t pmtTruth1=hitInfo->GetPmtTruth1();
04678 Int_t pmtTruth2=hitInfo->GetPmtTruth2();
04679 Double_t earliestT1=hitInfo->GetEarliestT1();
04680 Int_t muon=13;
04681
04682 if (plane>overallLastPlane) overallLastPlane=plane;
04683
04684 Int_t sumTruth=pmtTruth1 | pmtTruth2;
04685 Bool_t genuine=(sumTruth & DigiSignal::kGenuine)==
04686 DigiSignal::kGenuine;
04687 Bool_t fibreLight=(sumTruth & DigiSignal::kFibreLight)==
04688 DigiSignal::kFibreLight;
04689 Bool_t darkNoise=(sumTruth & DigiSignal::kDarkNoise)==
04690 DigiSignal::kDarkNoise;
04691
04692 if (!genuine && (fibreLight || darkNoise)) continue;
04693
04694 if (plane>notNoiseLastPlane) notNoiseLastPlane=plane;
04695
04696 if (!genuine) continue;
04697
04698
04699 if (earliestT1>500e-9) continue;
04700
04701 if (plane>particleLastPlane) particleLastPlane=plane;
04702
04703
04704
04705
04706
04707 if (abs(mainParticle)!=muon) continue;
04708
04709 if (plane>muonLastPlane) muonLastPlane=plane;
04710 }
04711
04712 hEventLength->Fill(overallLastPlane+1);
04713 hEventLength2->Fill(notNoiseLastPlane+1);
04714 hEventLength3->Fill(particleLastPlane+1);
04715
04716 hEventLength4->Fill(muonLastPlane+1);
04717
04718 }
04719
04720 TCanvas *cGeom=new TCanvas("cGeom","Geom",0,0,1200,800);
04721 cGeom->SetFillColor(0);
04722 cGeom->Divide(2,3);
04723 cGeom->cd(1);
04724 hEventLength->Draw();
04725 cGeom->cd(2);
04726 hEventLength2->Draw();
04727 hEventLength2->SetLineColor(2);
04728 cGeom->cd(3);
04729 hEventLength3->Draw();
04730 hEventLength3->SetLineColor(3);
04731 cGeom->cd(4);
04732 hEventLength4->Draw();
04733 hEventLength->SetLineColor(4);
04734 cGeom->cd(5);
04735 hEventLength4->Draw();
04736 hEventLength2->Draw("sames");
04737 cGeom->cd(6);
04738 hEventLength4->Draw();
04739 hEventLength3->Draw("sames");
04740 hEventLength2->Draw("sames");
04741 hEventLength->Draw("sames");
04742 }
04743
04744
04745
04746 void CDAnalysis::MuonResponse()
04747 {
04748 MSG("CDAnalysis",Msg::kInfo)
04749 <<" ** Running MuonResponse method... **"<<endl;
04750
04751
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
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
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
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
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
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
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
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
04929
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
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
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
04954
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
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
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
04995
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
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
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
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
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
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
05126
05127
05128
05129
05130
05131
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
05164 TClonesArray &cTrk=*fTrkHitInfo;
05165 Int_t numTrkHits=fTrkHitInfo->GetEntries();
05166 TClonesArray &cUnTrk = *fUnTrkHitInfo;
05167 Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
05168
05169 TClonesArray &cXTalk = *fXTalkHits;
05170 Int_t numXTalkHits=fXTalkHits->GetEntries();
05171
05172 Int_t numTruthHits=0;
05173 if (fTruthHitInfo) numTruthHits=fTruthHitInfo->GetEntries();
05174
05175
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
05184 }
05185
05187
05189 for (Int_t hit=0;hit<numUnTrkHits;hit++){
05190
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
05207 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05208
05209
05210 numPlanesHitAll[fPlane]++;
05211
05212
05213 this->StandardSanityChecks();
05214
05215
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
05234
05235 else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
05236 else sigCorTotal+=fChargeSigCor;
05237 }
05238
05240
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
05249 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05250
05251
05252 numPlanesHitAll[fPlane]++;
05253
05254
05255 this->StandardSanityChecks();
05256
05257
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
05276
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
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
05297 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
05298
05299
05300 this->StandardSanityChecks();
05301
05302
05303 this->CalcFirstLastPlane(fPlane);
05304
05305
05306 numPlanesHit[fPlane]++;
05307 numPlanesHitAll[fPlane]++;
05308
05309 if (fLastPlane==fPlane && fPlane%2==0){
05310
05311
05312 if (fLastPlane!=previousfLastPlane){
05313 lastPlaneE1Hit=false;
05314 lastPlaneE2Hit=false;
05315 }
05316 previousfLastPlane=fLastPlane;
05317
05318
05319 if (fStripend==1) lastPlaneE1Hit=true;
05320 if (fStripend==2) lastPlaneE2Hit=true;
05321
05322
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
05338 if (fLastPlane!=previousfLastPlane){
05339 lastPlaneO1Hit=false;
05340 lastPlaneO2Hit=false;
05341 }
05342 previousfLastPlane=fLastPlane;
05343
05344
05345 if (fStripend==1) lastPlaneO1Hit=true;
05346 if (fStripend==2) lastPlaneO2Hit=true;
05347
05348
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
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
05382
05383 else if (fPlane==1) sigCorTotal+=2*fChargeSigCor;
05384 else sigCorTotal+=fChargeSigCor;
05385 }
05387
05389
05390
05391 hNumPlanes->Fill(numPlanesHit.size());
05392 hNumPlanesAll->Fill(numPlanesHitAll.size());
05393 hEventLength->Fill(fLastPlane+1);
05394
05395
05396 if (fFirstPlane<0 || fFirstPlane>59) continue;
05397
05398
05399 Double_t eventEn=(fScEnDepPerMEU/fSigCorPerMEU)*sigCorTotal*
05400 (1/fRatioScEnToBeamEn);
05401
05402 Int_t lastPlaneNoXTalk=this->CalcLastPlaneOnTrkNoXTalk();
05403
05404
05405 pEnVsRange->Fill(lastPlaneNoXTalk+1,eventEn);
05406
05407 if (fLastPlane%2==1) lastPlaneOddCounter++;
05408 if (fLastPlane%2==0) lastPlaneEvenCounter++;
05409
05410
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
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
05449
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
05508 if (this->CutOnEventLength()) continue;
05509
05510 if (this->CutOnTrackQuality()) continue;
05511
05512 MAXMSG("CDAnalysis",Msg::kInfo,10)
05513 <<"Event passing plane cuts="<<event<<endl;
05514
05515
05516 hSigCorTotal->Fill(sigCorTotal);
05517
05518
05519 hFirstPlane->Fill(fFirstPlane);
05520 hEventLength2->Fill(fLastPlane+1);
05521 hEventLength3->Fill(lastPlaneNoXTalk+1);
05522
05523
05524 if (lastPlaneNoXTalk+1>50 && lastPlaneNoXTalk+1<53){
05525
05526 hSigCorTotalTight->Fill(sigCorTotal);
05527 }
05528
05529 if (lastPlaneNoXTalk+1==51){
05530
05531 hSigCorTotalPeak->Fill(sigCorTotal);
05532 }
05533
05534
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
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
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
05568
05569
05570
05571 const Int_t os=fLastPlane;
05572
05573
05574
05575
05576
05577
05578
05579
05580
05581
05582 if (fRunNumber>40000 && fRunNumber<60000){
05583 planeSigCor[35]=planeSigCor[37];
05584 planeSigCorT[35]=planeSigCorT[37];
05585 }
05586
05587 else if (fRunNumber>100000 && fRunNumber<110000){
05588
05589
05590
05591
05592
05593
05594
05595
05596
05597 }
05598
05599
05600 this->FillProfHisto(pSigCorVsPlane,num,planeSigCor);
05601 this->FillProfHisto(pSigCorVsPlaneX,numX,planeSigCorX);
05602 this->FillProfHisto(pSigCorVsPlaneT,numT,planeSigCorT);
05603
05604 this->FillProfHisto(pSigCorVsOsPlane,numOs,planeSigCor,os);
05605 this->FillProfHisto(pSigCorVsOsPlaneX,numOsX,planeSigCorX,os);
05606 this->FillProfHisto(pSigCorVsOsPlaneT,numOsT,planeSigCorT,os);
05607
05608
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
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
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
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
05662 if (localSumMipTotalCounter!=0){
05663 sumMipTotal+=localSumMipTotal;
05664 sumMipTotalCounter++;
05665 }
05666
05668
05670 Int_t minEventLength=35;
05671 if (fLastPlane<minEventLength) continue;
05672
05673
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
05702 for (vector<Int_t>::iterator windowSize=vWindowSize.begin();
05703 windowSize!=vWindowSize.end();++windowSize){
05704
05705
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
05715 for (Int_t i=0;i<*windowSize;i++){
05716 Int_t plane=windowStart-i;
05717
05718
05719
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
05737
05738
05739 if (*windowSize==15 && windowStart==fLastPlane-18){
05740 localSum15_18+=planeSigCorT[plane];
05741 localSum15_18Counter++;
05742 localSum15_18Mip+=planeMipT[plane];
05743 localSum15_18MipCounter++;
05744
05745 if (plane%2==0){
05746
05747 }
05748 else if (plane%2==1){
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;
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 }
05781
05785
05786 MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05787
05788
05789 gStyle->SetOptStat(0);
05790
05791
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
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
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
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
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
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
05867 MSG("CDAnalysis",Msg::kDebug)
05868 <<"bigCounter="<<*count<<", bigAv="<<*av<<endl;
05869
05870
05871
05872
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
05889 gErrorIgnoreLevel=0;
05890 cProf->Print((sName+"]").c_str());
05891
05892
05893 TCanvas *cProf2=new TCanvas("cProf2","Prof",0,0,1200,800);
05894 cProf2->SetFillColor(0);
05895 sName="SlidingWindowAll.ps";
05896
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
05905 counter++;
05906
05907
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
05928
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
05950
05951
05952
05953
05954
05955
05956
05957
05958
05959
05960
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 <<((fScEnDepPerMEU/fSigCorPerMEU)*
05991 hSigCorTotalTight->GetMean()*(1/fRatioScEnToBeamEn))/
05992 Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl
05993 <<"Beam energy from Calorimetry (peak)="
05994 <<((fScEnDepPerMEU/fSigCorPerMEU)*
05995 hSigCorTotalPeak->GetMean()*(1/fRatioScEnToBeamEn))/
05996 Munits::gigaelectronvolt<<" "<<Munits::base_energy_name<<endl<<endl;
05997
05998
05999
06000
06001
06002
06003
06004
06005
06006
06007
06008
06009
06010
06011
06012
06013
06014
06015
06016
06017
06018
06019 Int_t oddEvenSum=lastPlaneEvenCounter+lastPlaneOddCounter;
06020 Float_t oddPercent=-1;
06021 Float_t evenPercent=-1;
06022 if (oddEvenSum) oddPercent=100.*lastPlaneOddCounter/oddEvenSum;
06023 if (oddEvenSum) evenPercent=100.*lastPlaneEvenCounter/oddEvenSum;
06024
06025 MSG("CDAnalysis",Msg::kInfo)
06026 <<"Last plane, odd="<<lastPlaneOddCounter<<" ("<<oddPercent<<"%)"
06027 <<", even="<<lastPlaneEvenCounter<<" ("<<evenPercent<<"%)"<<endl;
06028
06029 Int_t totalSum=lastPlaneE1Counter+lastPlaneE2Counter+
06030 lastPlaneO1Counter+lastPlaneO2Counter+
06031 lastPlaneEBothCounter+lastPlaneOBothCounter;
06032 Float_t e1Percent=-1;
06033 Float_t e2Percent=-1;
06034 Float_t o1Percent=-1;
06035 Float_t o2Percent=-1;
06036 Float_t eBothPercent=-1;
06037 Float_t oBothPercent=-1;
06038 if (totalSum) o1Percent=100.*lastPlaneO1Counter/totalSum;
06039 if (totalSum) o2Percent=100.*lastPlaneO2Counter/totalSum;
06040 if (totalSum) e1Percent=100.*lastPlaneE1Counter/totalSum;
06041 if (totalSum) e2Percent=100.*lastPlaneE2Counter/totalSum;
06042 if (totalSum) eBothPercent=100.*lastPlaneEBothCounter/totalSum;
06043 if (totalSum) oBothPercent=100.*lastPlaneOBothCounter/totalSum;
06044
06045 Float_t totalPercent=o1Percent+o2Percent+e1Percent+e2Percent+
06046 oBothPercent+eBothPercent;
06047
06048 MSG("CDAnalysis",Msg::kInfo)
06049 <<"Last Plane:"<<endl
06050 <<" Total number hits="<<totalSum<<endl
06051 <<" Hits on both sides of plane:"<<endl
06052 <<" Odd="<<lastPlaneOBothCounter<<" ("<<oBothPercent<<"%)"<<endl
06053 <<" Even="<<lastPlaneEBothCounter<<" ("<<eBothPercent<<"%)"<<endl
06054 <<" Hits on only one side of plane:"<<endl
06055 <<" Odd-ND="<<lastPlaneO2Counter<<" ("<<o2Percent<<"%)"<<endl
06056 <<" Odd-FD="<<lastPlaneO1Counter<<" ("<<o1Percent<<"%)"<<endl
06057 <<" Even-ND="<<lastPlaneE2Counter<<" ("<<e2Percent<<"%)"<<endl
06058 <<" Even-FD="<<lastPlaneE1Counter<<" ("<<e1Percent<<"%)"<<endl
06059 <<" Sum of 6 percentages="<<totalPercent<<endl;
06060
06061 Float_t sharedXTalkPercent=-1;
06062 Float_t side1XTalkPercent=-1;
06063 Float_t side2XTalkPercent=-1;
06064 Float_t doubleXTalkPercent=-1;
06065 Float_t notGenuineOrXTalkPercent=-1;
06066 if (sharedPmtCounter) sharedXTalkPercent=100.*sharedPmtXTalkCounter/
06067 sharedPmtCounter;
06068 if (side1Counter) side1XTalkPercent=100.*side1XTalkCounter/
06069 side1Counter;
06070 if (side2Counter) side2XTalkPercent=100.*side2XTalkCounter/
06071 side2Counter;
06072 if (doubleCounter) doubleXTalkPercent=100.*doubleXTalkCounter/
06073 doubleCounter;
06074 if (totalCounter) notGenuineOrXTalkPercent=100.*
06075 notGenuineOrXTalkCounter/totalCounter;
06076
06077 MSG("CDAnalysis",Msg::kInfo)
06078 <<endl
06079 <<"totalCounter="<<totalCounter<<endl
06080 <<"firstPlaneInPairCounter="<<firstPlaneInPairCounter<<endl
06081 <<"double="<<doubleCounter
06082 <<", xtalk="<<doubleXTalkCounter
06083 <<" ("<<doubleXTalkPercent<<"%)"<<endl
06084 <<"side1="<<side1Counter
06085 <<", xtalk="<<side1XTalkCounter
06086 <<" ("<<side1XTalkPercent<<"%)"<<endl
06087 <<"side2="<<side2Counter
06088 <<", xtalk="<<side2XTalkCounter
06089 <<" ("<<side2XTalkPercent<<"%)"<<endl
06090 <<"Number of times shared pmt on second of"
06091 <<" two planes was last plane="
06092 <<sharedPmtCounter<<endl
06093 <<"Number of times above was XTalk only="<<sharedPmtXTalkCounter
06094 <<" ("<<sharedXTalkPercent<<"%)"<<endl
06095 <<"notGenuineOrXTalkCounter="<<notGenuineOrXTalkCounter
06096 <<" ("<<notGenuineOrXTalkPercent<<"%)"<<endl;
06097
06098 MSG("CDAnalysis",Msg::kInfo)
06099 <<endl<<"passPidCounter="<<passPidCounter<<endl
06100 <<"noTrackCounter="<<noTrackCounter
06101 <<" ("<<Pct(noTrackCounter,passPidCounter)<<"%)"<<endl;
06102
06103 if (sum15_18Counter!=0){
06104 MSG("CDAnalysis",Msg::kInfo)
06105 <<endl
06106 <<" ** Calibration Summary **"<<endl
06107 <<"SigCor in sliding window 15_18:"<<endl
06108 <<" SigCor dep="<<sum15_18<<" (N="<<sum15_18Counter<<")"<<endl
06109 <<" Av SigCor dep="<<sum15_18/sum15_18Counter
06110 <<" +/- "<<100*(h15_18->GetRMS()/sqrt(h15_18->GetEntries()))/
06111 h15_18->GetMean()<<"%"<<endl
06112 <<" Av SigCor dep per plane="<<(sum15_18/sum15_18Counter)/15
06113 <<" +/- "<<100*(h15_18->GetRMS()/sqrt(h15_18->GetEntries()))/
06114 h15_18->GetMean()<<"%"<<endl
06115 <<"MIPs in sliding window 15_18:"<<endl
06116 <<" MIPs dep="<<sum15_18Mip
06117 <<" (N="<<sum15_18MipCounter<<")"<<endl
06118 <<" Av MIPs dep="<<sum15_18Mip/sum15_18MipCounter
06119 <<endl;
06120 if (sumSigCorTotalCounter!=0){
06121 MSG("CDAnalysis",Msg::kInfo)
06122 <<"SigCor of whole event:"<<endl
06123 <<" Sum of SigCor dep="<<sumSigCorTotal
06124 <<" (N="<<sumSigCorTotalCounter<<")"<<endl
06125 <<" Av sigCor dep="
06126 <<sumSigCorTotal/sumSigCorTotalCounter<<endl
06127 <<" 1 sigCor="
06128 <<1800/(sumSigCorTotal/sumSigCorTotalCounter)<<" MeV"
06129 <<endl;
06130 }
06131 if (sumMipTotalCounter!=0){
06132 MSG("CDAnalysis",Msg::kInfo)
06133 <<"MIPs of whole event:"<<endl
06134 <<" Sum of MIPs dep="<<sumMipTotal
06135 <<" (N="<<sumMipTotalCounter<<")"<<endl
06136 <<" Av MIPs dep="
06137 <<sumMipTotal/sumMipTotalCounter<<endl
06138 <<" 1 MIP="
06139 <<1800/(sumMipTotal/sumMipTotalCounter)<<" MeV"<<endl
06140 <<" 1 GeV="
06141 <<(sumMipTotal/sumMipTotalCounter)/1.8<<" MIPs"
06142 <<endl<<endl;
06143 }
06144 }
06145
06146 MSG("CDAnalysis",Msg::kInfo)
06147 <<" ** Finished MuonResponse method **"<<endl;
06148 }
06149
06150
06151
06152 void CDAnalysis::MuonNearFar()
06153 {
06154 MSG("CDAnalysis",Msg::kInfo)
06155 <<" ** Running MuonNearFar method... **"<<endl;
06156
06157
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
06209
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
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
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
06234
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
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
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
06275
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
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
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
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
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
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
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
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
06400
06401
06402
06403
06404
06405
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
06436 TClonesArray &cTrk=*fTrkHitInfo;
06437 Int_t numTrkHits=fTrkHitInfo->GetEntries();
06438 TClonesArray &cUnTrk = *fUnTrkHitInfo;
06439 Int_t numUnTrkHits = fUnTrkHitInfo->GetEntries();
06440
06441 TClonesArray &cXTalk = *fXTalkHits;
06442 Int_t numXTalkHits=fXTalkHits->GetEntries();
06443
06444 Int_t numTruthHits=0;
06445 if (fTruthHitInfo) numTruthHits=fTruthHitInfo->GetEntries();
06446
06447
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
06456 }
06457
06459
06461 for (Int_t hit=0;hit<numUnTrkHits;hit++){
06462
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
06479 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06480
06481
06482 numPlanesHitAll[fPlane]++;
06483
06484
06485 this->StandardSanityChecks();
06486
06487
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
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
06515 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06516
06517
06518 numPlanesHitAll[fPlane]++;
06519
06520
06521 this->StandardSanityChecks();
06522
06523
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
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
06557 if (this->CutOnBadPedestals(fPlane,fStrip,fStripend)) continue;
06558
06559
06560 this->StandardSanityChecks();
06561
06562
06563 this->CalcFirstLastPlane(fPlane);
06564
06565
06566 numPlanesHit[fPlane]++;
06567 numPlanesHitAll[fPlane]++;
06568
06569 if (fLastPlane==fPlane && fPlane%2==0){
06570
06571
06572 if (fLastPlane!=previousfLastPlane){
06573 lastPlaneE1Hit=false;
06574 lastPlaneE2Hit=false;
06575 }
06576 previousfLastPlane=fLastPlane;
06577
06578
06579 if (fStripend==1) lastPlaneE1Hit=true;
06580 if (fStripend==2) lastPlaneE2Hit=true;
06581
06582
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
06598 if (fLastPlane!=previousfLastPlane){
06599 lastPlaneO1Hit=false;
06600 lastPlaneO2Hit=false;
06601 }
06602 previousfLastPlane=fLastPlane;
06603
06604
06605 if (fStripend==1) lastPlaneO1Hit=true;
06606 if (fStripend==2) lastPlaneO2Hit=true;
06607
06608
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
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
06643
06644
06645 if (fFirstPlane<0 || fFirstPlane>59) continue;
06646
06647
06648
06649
06650
06651 if (this->CutOnEventLength()) continue;
06652
06653 if (this->CutOnTrackQuality()) continue;
06654
06656
06658 const Int_t os=fLastPlane;
06659
06660
06661
06662
06663 this->FillProfHisto(pSigCorVsPlane,num,planeSigCor);
06664 this->FillProfHisto(pSigCorVsPlaneX,numX,planeSigCorX);
06665 this->FillProfHisto(pSigCorVsPlaneT,numT,planeSigCorT);
06666
06667 this->FillProfHisto(pSigCorVsOsPlane,numOs,planeSigCor,os);
06668 this->FillProfHisto(pSigCorVsOsPlaneX,numOsX,planeSigCorX,os);
06669 this->FillProfHisto(pSigCorVsOsPlaneT,numOsT,planeSigCorT,os);
06670
06671
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
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
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
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
06725 if (localSumMipTotalCounter!=0){
06726 sumMipTotal+=localSumMipTotal;
06727 sumMipTotalCounter++;
06728 }
06729
06731
06733 Int_t minEventLength=35;
06734 if (fLastPlane<minEventLength) continue;
06735
06736
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
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
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
06797 for (Int_t i=0;i<*windowSize;i++){
06798 Int_t plane=windowStart-i;
06799
06800
06801
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
06819
06820
06821 if (*windowSize==15 && windowStart==fLastPlane-18){
06822 localSum15_18+=planeSigCorT[plane];
06823 localSum15_18Counter++;
06824 localSum15_18Mip+=planeMipT[plane];
06825 localSum15_18MipCounter++;
06826
06827
06828 if (windowStart%2==0) oneMoreEvenPlane=true;
06829
06830
06831 if (plane%2==0){
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){
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
06848 if (plane%2==0){
06849 localSumE1+=planeSigCorE1T[plane];
06850 localSumCounterE1++;
06851 localSumE2+=planeSigCorE2T[plane];
06852 localSumCounterE2++;
06853 }
06854 else if (plane%2==1){
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
06869 if (*windowSize==15){
06870
06871
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
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;
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 }
06949
06953
06954 MSG("CDAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06955
06956
06957 gStyle->SetOptStat(0);
06958
06959
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
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
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
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
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 }
07157
07158
07159
07160 Float_t CDAnalysis::ReCalibrate(Float_t chargeAdc,Int_t plane,
07161 Int_t strip,Int_t stripend) const
07162 {
07163 if (fDoReCalibration && fSimFlag==SimFlag::kData){
07164 MAXMSG("CDAnalysis",Msg::kInfo,10)
07165 <<"Running ReCalibrate: fSec="<<fSec
07166 <<", simFlag="<<fSimFlag<<endl;
07167
07168
07169 Calibrator& cal=Calibrator::Instance();
07170
07171 VldTimeStamp vldts(fSec,0);
07172 VldContext vc(Detector::kCalDet,fSimFlag,vldts);
07173 cal.ReInitialise(vc);
07174 MAXMSG("CDAnalysis",Msg::kVerbose,100)
07175 <<"Calibrator reinitialised sucessfully"<<endl;
07176
07177
07178 PlexStripEndId seid(Detector::kCalDet,plane,strip,
07179 static_cast<StripEnd::EStripEnd>(stripend));
07180
07181 MAXMSG("CDAnalysis",Msg::kVerbose,100)
07182 <<"Now calibrating drift..."<<endl;
07183
07184 Float_t tmpCharge=chargeAdc;
07185 tmpCharge=cal.GetDriftCorrected(tmpCharge,seid);
07186 MAXMSG("CDAnalysis",Msg::kVerbose,100)
07187 <<"Now calibrating sts..."<<endl;
07188 tmpCharge=cal.GetStripToStripCorrected(tmpCharge,seid);
07189
07190 MAXMSG("CDAnalysis",Msg::kInfo,50)
07191 <<"ReCalibrate: fChargeSigCor="<<fChargeSigCor
07192 <<", newSigCor="<<tmpCharge
07193 <<", temperature="<<cal.GetTemperature()<<endl;
07194
07195
07196 return tmpCharge;
07197 }
07198 else {
07199
07200 return fChargeSigCor;
07201 }
07202 }
07203
07204
07205
07206 void CDAnalysis::StoppingMuonCalibration()
07207 {
07208
07209 fOutFile=this->OpenFile(fRunNumber,"StopMuCal");
07210
07211
07212 fDoReCalibration=false;
07213
07214 VldTimeStamp ts;
07215 cout<<"Time in secs right now is:"<<ts.GetSec()<<endl;
07217 Int_t minRunTime=4;
07218 if (ts.GetSec()>minRunTime){
07219
07220 this->ElectronResponse();
07221 }
07222
07223 MSG("CDAnalysis",Msg::kInfo)
07224 <<" ** Running StoppingMuonCalibration method... **"<<endl;
07225
07226 vector<TH1F*> meuHistos(60);
07227 vector<TH1F*> sigCorNoPLCorHistos(60);
07228
07229 for (Int_t i=0;i<60;i++){
07230 string sName="hMeuPlane";
07231 string sNameSigCor="hSigCorNoPLCorPlane";
07232
07233 string sNum=Form("%d",i);
07234 sName+=sNum;
07235 sNameSigCor+=sNum;
07236
07237
07238 meuHistos[i]=new TH1F(sName.c_str(),sName.c_str(),300,-2,3000);
07239 meuHistos[i]->SetBit(TH1::kCanRebin);
07240
07241
07242
07243 sigCorNoPLCorHistos[i]=new TH1F
07244 (sNameSigCor.c_str(),sNameSigCor.c_str(),300,-2,3000);
07245
07246
07247 }
07248
07249 TH1F *hMeu=new TH1F("hMeu","hMeu",1000,-2,1000);
07250 hMeu->GetXaxis()->SetTitle("SigCors");
07251 hMeu->GetXaxis()->CenterTitle();
07252 hMeu->GetYaxis()->SetTitle("");
07253 hMeu->GetYaxis()->CenterTitle();
07254 hMeu->SetFillColor(0);
07255 hMeu->SetBit(TH1::kCanRebin);
07256
07257 TH1F* hGeVPerMeu=new TH1F("hGeVPerMeu","hGeVPerMeu",3000,-0.001,0.3);
07258 hGeVPerMeu->SetFillColor(0);
07259 hGeVPerMeu->SetTitle("GeV/MEU");
07260 hGeVPerMeu->GetXaxis()->SetTitle("GeV/MEU");
07261 hGeVPerMeu->GetXaxis()->CenterTitle();
07262
07263 TH1F *hMeuPLCor=new TH1F("hMeuPLCor","hMeuPLCor",1000,-2,1000);
07264 hMeuPLCor->GetXaxis()->SetTitle("SigCors");
07265 hMeuPLCor->GetXaxis()->CenterTitle();
07266 hMeuPLCor->GetYaxis()->SetTitle("");
07267 hMeuPLCor->GetYaxis()->CenterTitle();
07268 hMeuPLCor->SetFillColor(0);
07269 hMeuPLCor->SetBit(TH1::kCanRebin);
07270
07271 TH1F *hMeuTruePLCor=new TH1F("hMeuTruePLCor","hMeuTruePLCor",
07272 1000,-2,1000);
07273 hMeuTruePLCor->GetXaxis()->SetTitle("SigCors");
07274 hMeuTruePLCor->GetXaxis()->CenterTitle();
07275 hMeuTruePLCor->GetYaxis()->SetTitle("");
07276 hMeuTruePLCor->GetYaxis()->CenterTitle();
07277 hMeuTruePLCor->SetFillColor(0);
07278 hMeuTruePLCor->SetBit(TH1::kCanRebin);
07279
07280 TH1F *hMeuOnlyEventLengthCut=new TH1F("hMeuOnlyEventLengthCut",
07281 "hMeuOnlyEventLengthCut",
07282 1000,-2,1000);
07283 hMeuOnlyEventLengthCut->GetXaxis()->SetTitle("SigCors");
07284 hMeuOnlyEventLengthCut->GetXaxis()->CenterTitle();
07285 hMeuOnlyEventLengthCut->GetYaxis()->SetTitle("");
07286 hMeuOnlyEventLengthCut->GetYaxis()->CenterTitle();
07287 hMeuOnlyEventLengthCut->SetFillColor(0);
07288 hMeuOnlyEventLengthCut->SetBit(TH1::kCanRebin);
07289
07290 TH1F *hMeuOnlyEL_FidCut=new TH1F("hMeuOnlyEL_FidCut",
07291 "hMeuOnlyEL_FidCut",
07292 1000,-2,1000);
07293 hMeuOnlyEL_FidCut->GetXaxis()->SetTitle("SigCors");
07294 hMeuOnlyEL_FidCut->GetXaxis()->CenterTitle();
07295 hMeuOnlyEL_FidCut->GetYaxis()->SetTitle("");
07296 hMeuOnlyEL_FidCut->GetYaxis()->CenterTitle();
07297 hMeuOnlyEL_FidCut->SetFillColor(0);
07298 hMeuOnlyEL_FidCut->SetBit(TH1::kCanRebin);
07299
07300 TH1F *hMeuOnlyEL_Fid_TimeCut=new TH1F("hMeuOnlyEL_Fid_TimeCut",
07301 "hMeuOnlyEL_Fid_TimeCut",
07302 1000,-2,1000);
07303 hMeuOnlyEL_Fid_TimeCut->GetXaxis()->SetTitle("SigCors");
07304 hMeuOnlyEL_Fid_TimeCut->GetXaxis()->CenterTitle();
07305 hMeuOnlyEL_Fid_TimeCut->GetYaxis()->SetTitle("");
07306 hMeuOnlyEL_Fid_TimeCut->GetYaxis()->CenterTitle();
07307 hMeuOnlyEL_Fid_TimeCut->SetFillColor(0);
07308 hMeuOnlyEL_Fid_TimeCut->SetBit(TH1::kCanRebin);
07309
07310 TH1F *hMeuOnlyEL_TimeCut=new TH1F("hMeuOnlyEL_TimeCut",
07311 "hMeuOnlyEL_TimeCut",
07312 1000,-2,1000);
07313 hMeuOnlyEL_TimeCut->GetXaxis()->SetTitle("SigCors");
07314 hMeuOnlyEL_TimeCut->GetXaxis()->CenterTitle();
07315 hMeuOnlyEL_TimeCut->GetYaxis()->SetTitle("");
07316 hMeuOnlyEL_TimeCut->GetYaxis()->CenterTitle();
07317 hMeuOnlyEL_TimeCut->SetFillColor(0);
07318 hMeuOnlyEL_TimeCut->SetBit(TH1::kCanRebin);
07319
07320 TH1F *hMeuOnlyEL_HppCut=new TH1F("hMeuOnlyEL_HppCut",
07321 "hMeuOnlyEL_HppCut",
07322 1000,-2,1000);
07323 hMeuOnlyEL_HppCut->GetXaxis()->SetTitle("SigCors");
07324 hMeuOnlyEL_HppCut->GetXaxis()->CenterTitle();
07325 hMeuOnlyEL_HppCut->GetYaxis()->SetTitle("");
07326 hMeuOnlyEL_HppCut->GetYaxis()->CenterTitle();
07327 hMeuOnlyEL_HppCut->SetFillColor(0);
07328 hMeuOnlyEL_HppCut->SetBit(TH1::kCanRebin);
07329
07330 TH1F *hMeuOnlyPID_EventLengthCut=new TH1F("hMeuOnlyPID_EventLengthCut",
07331 "hMeuOnlyPID_EventLengthCut",
07332 1000,-2,1000);
07333 hMeuOnlyPID_EventLengthCut->GetXaxis()->SetTitle("SigCors");
07334 hMeuOnlyPID_EventLengthCut->GetXaxis()->CenterTitle();
07335 hMeuOnlyPID_EventLengthCut->GetYaxis()->SetTitle("");
07336 hMeuOnlyPID_EventLengthCut->GetYaxis()->CenterTitle();
07337 hMeuOnlyPID_EventLengthCut->SetFillColor(0);
07338 hMeuOnlyPID_EventLengthCut->SetBit(TH1::kCanRebin);
07339
07340 TH1F *hMeuOnlyPID_EL_FidCut=new TH1F("hMeuOnlyPID_EL_FidCut",
07341 "hMeuOnlyPID_EL_FidCut",
07342 1000,-2,1000);
07343 hMeuOnlyPID_EL_FidCut->GetXaxis()->SetTitle("SigCors");
07344 hMeuOnlyPID_EL_FidCut->GetXaxis()->CenterTitle();
07345 hMeuOnlyPID_EL_FidCut->GetYaxis()->SetTitle("");
07346 hMeuOnlyPID_EL_FidCut->GetYaxis()->CenterTitle();
07347 hMeuOnlyPID_EL_FidCut->SetFillColor(0);
07348 hMeuOnlyPID_EL_FidCut->SetBit(TH1::kCanRebin);
07349
07350 TH1F *hMeuOnlyPID_EL_Fid_TimeCut=new TH1F("hMeuOnlyPID_EL_Fid_TimeCut",
07351 "hMeuOnlyPID_EL_Fid_TimeCut",
07352 1000,-2,1000);
07353 hMeuOnlyPID_EL_Fid_TimeCut->GetXaxis()->SetTitle("SigCors");
07354 hMeuOnlyPID_EL_Fid_TimeCut->GetXaxis()->CenterTitle();
07355 hMeuOnlyPID_EL_Fid_TimeCut->GetYaxis()->SetTitle("");
07356 hMeuOnlyPID_EL_Fid_TimeCut->GetYaxis()->CenterTitle();
07357 hMeuOnlyPID_EL_Fid_TimeCut->SetFillColor(0);
07358 hMeuOnlyPID_EL_Fid_TimeCut->SetBit(TH1::kCanRebin);
07359
07360 TH1F *hMeuOnlyPID_EL_TimeCut=new TH1F("hMeuOnlyPID_EL_TimeCut",
07361 "hMeuOnlyPID_EL_TimeCut",
07362 1000,-2,1000);
07363 hMeuOnlyPID_EL_TimeCut->GetXaxis()->SetTitle("SigCors");
07364 hMeuOnlyPID_EL_TimeCut->GetXaxis()->CenterTitle();
07365 hMeuOnlyPID_EL_TimeCut->GetYaxis()->SetTitle("");
07366 hMeuOnlyPID_EL_TimeCut->GetYaxis()->CenterTitle();
07367 hMeuOnlyPID_EL_TimeCut->SetFillColor(0);
07368 hMeuOnlyPID_EL_TimeCut->SetBit(TH1::kCanRebin);
07369
07370 TH1F *hMeuOnlyPID_EL_HppCut=new TH1F("hMeuOnlyPID_EL_HppCut",
07371 "hMeuOnlyPID_EL_HppCut",
07372 1000,-2,1000);
07373 hMeuOnlyPID_EL_HppCut->GetXaxis()->SetTitle("SigCors");
07374 hMeuOnlyPID_EL_HppCut->GetXaxis()->CenterTitle();
07375 hMeuOnlyPID_EL_HppCut->GetYaxis()->SetTitle("");
07376 hMeuOnlyPID_EL_HppCut->GetYaxis()->CenterTitle();
07377 hMeuOnlyPID_EL_HppCut->SetFillColor(0);
07378 hMeuOnlyPID_EL_HppCut->SetBit(TH1::kCanRebin);
07379
07380 TH1F *hMeuNoPidCut=new TH1F("hMeuNoPidCut","hMeuNoPidCut",
07381 1000,-2,1000);
07382 hMeuNoPidCut->GetXaxis()->SetTitle("SigCors");
07383 hMeuNoPidCut->GetXaxis()->CenterTitle();
07384 hMeuNoPidCut->GetYaxis()->SetTitle("");
07385 hMeuNoPidCut->GetYaxis()->CenterTitle();
07386 hMeuNoPidCut->SetFillColor(0);
07387 hMeuNoPidCut->SetBit(TH1::kCanRebin);
07388
07389 TH1F *hMeuNoEventLengthCut=new TH1F("hMeuNoEventLengthCut",
07390 "hMeuNoEventLengthCut",
07391 1000,-2,1000);
07392 hMeuNoEventLengthCut->GetXaxis()->SetTitle("SigCors");
07393 hMeuNoEventLengthCut->GetXaxis()->CenterTitle();
07394 hMeuNoEventLengthCut->GetYaxis()->SetTitle("");
07395 hMeuNoEventLengthCut->GetYaxis()->CenterTitle();
07396 hMeuNoEventLengthCut->SetFillColor(0);
07397 hMeuNoEventLengthCut->SetBit(TH1::kCanRebin);
07398
07399 TH1F *hMeuNoFidVolCut=new TH1F("hMeuNoFidVolCut","hMeuNoFidVolCut",
07400 1000,-2,1000);
07401 hMeuNoFidVolCut->GetXaxis()->SetTitle(