#include #include #include #include #include #include #include #include #include #include IECalPairProducedElectronControlSample::IECalPairProducedElectronControlSample() : IControlSampleBase("ECalPairProducedElectron") { fMinTpcHits = COMET::IOARuntimeParameters::Get().GetParameterI("oaControlSample.ECalPairProducedElectron.MinTpcHits"); fMinElePullAccept = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MinElePullAccept"); fMaxElePullAccept = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MaxElePullAccept"); fMinMuonPullReject = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MinMuonPullReject"); fMaxMuonPullReject = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MaxMuonPullReject"); fMinProtonPullReject = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MinProtonPullReject"); fMaxProtonPullReject = COMET::IOARuntimeParameters::Get().GetParameterD("oaControlSample.ECalPairProducedElectron.MaxProtonPullReject"); AddValidTrigger(COMET::Trigger::kBeamSpill); } IECalPairProducedElectronControlSample::~IECalPairProducedElectronControlSample() { } double IECalPairProducedElectronControlSample::GetCharge( COMET::IHandle object){ COMET::IHandle firstState = TrackingUtils::GetFirstState(*object); if (!firstState) { return -1000.; } double charge = TrackingUtils::GetCharge(firstState); return charge; } bool IECalPairProducedElectronControlSample::PassesPullCuts(COMET::IHandle object) { COMET::IHandle pid = object; double pullMuon = 10000, pullProton = 10000, pullEle = 10000; if (pid) { COMET::IHandle test_datum = (pid)->Get ("tpcPid_NTrun"); if (test_datum) { pullMuon = pid->Get ("tpcPid_PullMuon")->GetValue(); pullEle = pid->Get ("tpcPid_PullEle")->GetValue(); pullProton = pid->Get ("tpcPid_PullProton")->GetValue(); } else { return false; } } if (pullEle < fMinElePullAccept || pullEle > fMaxElePullAccept) { return false; } if (pullProton > fMinProtonPullReject && pullProton < fMaxProtonPullReject) { return false; } if (pullMuon > fMinMuonPullReject && pullMuon < fMaxMuonPullReject) { return false; } return true; } bool IECalPairProducedElectronControlSample::AtECalFrontFace(COMET::IHandle object) { COMET::IHandle lastState = TrackingUtils::GetLastState(*object); if (!lastState) { return false; } TLorentzVector backPos = TrackingUtils::GetPosition(lastState); double barrelLeft = 890.; double barrelRight = -890.; double barrelBottom = -980.; double barrelTop = 1085.; double barrelFront = 600.; double barrelBack = 2600.; double DsFront = 2665; double DsTop = 930; double DsBottom = -910; double DsLeft = 920; double DsRight = -920; if ((backPos.X() > barrelLeft || backPos.X() < barrelRight || backPos.Y() < barrelBottom || backPos.Y() > barrelTop) && (backPos.Z() > barrelFront && backPos.Z() < barrelBack)) { return true; // entered Barrel } else if ( backPos.X() < DsLeft && backPos.X() > DsRight && backPos.Y() > DsBottom && backPos.Y() < DsTop && backPos.Z() > DsFront ) { return true; // entered DsECal } else {return false;} } TLorentzVector IECalPairProducedElectronControlSample::GetFrontPosition(COMET::IHandle object) { COMET::IHandle firstState = TrackingUtils::GetFirstState(*object); if (!firstState) { TLorentzVector defVector(-10000., -10000., -10000., -10000.); return defVector; } TLorentzVector pos = TrackingUtils::GetPosition(firstState); return pos; } int IECalPairProducedElectronControlSample::FGDStartPoint(TLorentzVector frontPosition) { TLorentzVector pos = frontPosition; TVector3 fgd1Min = TVector3(-832.2, -777.2, 123.45); TVector3 fgd1Max = TVector3(832.2, 887.2, 446.95); TVector3 fgd2Min = TVector3(-832.2, -777.2, 1481.45); TVector3 fgd2Max = TVector3(832.2, 887.2, 1807.95); if (pos.X() < fgd1Max.X() && pos.X() > fgd1Min.X() && pos.Y() < fgd1Max.Y() && pos.Y() > fgd1Min.Y() && pos.Z() < fgd1Max.Z() && pos.Z() > fgd1Min.Z() ){ return 1; } else if (pos.X() < fgd2Max.X() && pos.X() > fgd2Min.X() && pos.Y() < fgd2Max.Y() && pos.Y() > fgd2Min.Y() && pos.Z() < fgd2Max.Z() && pos.Z() > fgd2Min.Z() ){ return 2; } else {return 0;} } bool IECalPairProducedElectronControlSample::IsEventSelectedInternal(COMET::ICOMETEvent& event) { std::vector< COMET::IHandle > foundObjects; COMET::IHandle reconResult = event.GetFit("ReconGlobal"); if (!reconResult) { return false; } COMET::IHandle roc = reconResult->GetResultsContainer("final"); if (!roc) { return false; } for (COMET::IReconObjectContainer::iterator it = roc->begin(); it != roc->end(); it++) { COMET::IHandle object = *it; if (!object || !object->UsesDetector(COMET::IReconBase::kTPC) || !object->CheckStatus(COMET::IReconBase::kSuccess)) { continue; } COMET::IHandle tpcObject; if (object->UsesDetector(COMET::IReconBase::kTPC3)) { tpcObject = ReconObjectUtils::GetConstituentInDetector(object, COMET::IReconBase::kTPC3); } else if (object->UsesDetector(COMET::IReconBase::kTPC2)) { tpcObject = ReconObjectUtils::GetConstituentInDetector(object, COMET::IReconBase::kTPC2); } else if (object->UsesDetector(COMET::IReconBase::kTPC1)) { tpcObject = ReconObjectUtils::GetConstituentInDetector(object, COMET::IReconBase::kTPC1); } if (!tpcObject) { continue; } TLorentzVector frontPosition = GetFrontPosition(object); int whichFGD = FGDStartPoint(frontPosition); // ignore object if it doesnt start within a bunch time or in an FGD FV if (whichFGD == 0 ){ continue; } int nHits = 0; if (tpcObject->GetHits()) { nHits = tpcObject->GetHits()->size(); } if (nHits > fMinTpcHits) { foundObjects.push_back(tpcObject); } } if (foundObjects.size() > 1) { // loop through all pairs in found objects - if startpositions within 10cm then check both for pullCuts and save event if they pass. for (std::vector >::iterator object_1_it = foundObjects.begin() ; object_1_it != foundObjects.end() - 1; object_1_it++) { COMET::IHandle object_1 = (*object_1_it); COMET::IHandle tpcObject_1; if (object_1->UsesDetector(COMET::IReconBase::kTPC3)) { tpcObject_1 = ReconObjectUtils::GetConstituentInDetector(object_1, COMET::IReconBase::kTPC3); } else if (object_1->UsesDetector(COMET::IReconBase::kTPC2)) { tpcObject_1 = ReconObjectUtils::GetConstituentInDetector(object_1, COMET::IReconBase::kTPC2); } else if (object_1->UsesDetector(COMET::IReconBase::kTPC1)) { tpcObject_1 = ReconObjectUtils::GetConstituentInDetector(object_1, COMET::IReconBase::kTPC1); } for (std::vector >::iterator object_2_it = object_1_it + 1 ; object_2_it != foundObjects.end(); object_2_it++) { COMET::IHandle object_2 = (*object_2_it); COMET::IHandle tpcObject_2; TLorentzVector frontPosition_1 = GetFrontPosition(object_1); TLorentzVector frontPosition_2 = GetFrontPosition(object_2); double distance = ( frontPosition_1.Vect() - frontPosition_2.Vect() ).Mag(); if (object_1_it == object_2_it){ continue; } if (object_2->UsesDetector(COMET::IReconBase::kTPC3)) { tpcObject_2 = ReconObjectUtils::GetConstituentInDetector(object_2, COMET::IReconBase::kTPC3); } else if (object_2->UsesDetector(COMET::IReconBase::kTPC2)) { tpcObject_2 = ReconObjectUtils::GetConstituentInDetector(object_2, COMET::IReconBase::kTPC2); } else if (object_2->UsesDetector(COMET::IReconBase::kTPC1)) { tpcObject_2 = ReconObjectUtils::GetConstituentInDetector(object_2, COMET::IReconBase::kTPC1); } // check start within 10cm of each other and opposite charge if (distance > 100){continue;} if (GetCharge(tpcObject_1) * GetCharge(tpcObject_2) > 0){continue;} // check that they both pass pull cuts if (PassesPullCuts(tpcObject_1) && PassesPullCuts(tpcObject_2) ) { // if either make it into an ECal then save the event if ( AtECalFrontFace(tpcObject_1) || AtECalFrontFace(tpcObject_2) ) { return true; } } } } } return false; }