#include #include #include IFgdTrackSandMuonControlSample::IFgdTrackSandMuonControlSample() : IControlSampleBase("FgdTrackSandMuon"){ AddValidTrigger(COMET::Trigger::kBeamSpill); fTotPOT = 0; fPrevPOT = 0; fNSelected = 0; } void IFgdTrackSandMuonControlSample::InitHistograms(){ gEventsPOT = new TGraph(); gEventsPOT->SetName("gEventsPOT"); gDirectory->Append(gEventsPOT); hPOTDiff = new TH1F("hPOTDiff", ";POT to last event (10^{13} POT)", 100, 0.0, 1000.0); hNFgd1Tracks = new TH1F("hNFgd1Tracks", ";N_{TRACKS};", 20, -0.5, 19.5); hNFgd2Tracks = new TH1F("hNFgd2Tracks", ";N_{TRACKS};", 20, -0.5, 19.5); hNTpc1Tracks = new TH1F("hNTpc1Tracks", ";N_{TRACKS};", 20, -0.5, 19.5); hNTpc2Tracks = new TH1F("hNTpc2Tracks", ";N_{TRACKS};", 20, -0.5, 19.5); hNTpc3Tracks = new TH1F("hNTpc3Tracks", ";N_{TRACKS};", 20, -0.5, 19.5); } bool IFgdTrackSandMuonControlSample::IsEventSelectedInternal(COMET::ICOMETEvent& event) { // Get the spill number and time for the event int spill = event.GetHeader().GetSpillNumber(); int mcmTime = event.GetHeader().GetMCMSecond(); // Get the Beam Data if(COMET::IRawBeamDataSingleton::Get().GetSpill(spill, mcmTime, 1) ){ // Get the POT double pot = COMET::IRawBeamDataSingleton::Get().GetProtonsPerSpill(4); fTotPOT += pot; } // get the FGD recon information COMET::IHandle FgdResult = event.GetFit("ReconFGD"); if(!FgdResult) return false; COMET::IHandle TrackCont = FgdResult->GetResultsContainer("fittedFgdReconTracks_allFGD"); if(!TrackCont) return false; int nfgd1 =0, nfgd2 = 0; for( COMET::IReconObjectContainer::iterator tr = TrackCont->begin(); tr < TrackCont->end();tr++) { COMET::IHandle track = *tr; if(track->UsesDetector(COMET::IReconBase::kFGD1)) nfgd1++; if(track->UsesDetector(COMET::IReconBase::kFGD2)) nfgd2++; } if(fMakeHistoFile){ hNFgd1Tracks->Fill(nfgd1); hNFgd2Tracks->Fill(nfgd2); } bool select = (nfgd1 == 1 && nfgd2 == 1); if(select){ fNSelected++; if(fMakeHistoFile){ gEventsPOT->SetPoint(fNSelected, fNSelected, fTotPOT/1E13); hPOTDiff->Fill( (fTotPOT - fPrevPOT)/1E13); int ntpc1 =0, ntpc2 = 0, ntpc3 =0; COMET::IHandle TpcResult = event.GetFit("ReconTPC"); if(TpcResult){ COMET::IHandle TrackCont = TpcResult->GetResultsContainer("TPCPids"); if(TrackCont){ for( COMET::IReconObjectContainer::iterator tr = TrackCont->begin(); tr < TrackCont->end();tr++) { COMET::IHandle trackPiD = *tr; if(trackPiD->UsesDetector(COMET::IReconBase::kTPC1)) ntpc1++; if(trackPiD->UsesDetector(COMET::IReconBase::kTPC2)) ntpc2++; if(trackPiD->UsesDetector(COMET::IReconBase::kTPC3)) ntpc3++; } } } hNTpc1Tracks->Fill(ntpc1); hNTpc2Tracks->Fill(ntpc2); hNTpc3Tracks->Fill(ntpc3); } fPrevPOT = fTotPOT; } return select; }