#include #include #include "IGeometryDatabase.hxx" #include "IOARuntimeParameters.hxx" #include "ICyDetReconEventFunction.hxx" #include "IHitSelection.hxx" #include "IDataHit.hxx" #include "IMCHit.hxx" //====================================================================== // Constructor //====================================================================== ICyDetReconEventFunction::ICyDetReconEventFunction() : IReconEventFunction("CyDet") { // Prepare parameters COMET::IOARuntimeParameters& param = COMET::IOARuntimeParameters::Get(); Bool_t useExtFieldMapFile = (param.GetParameterI("ReconCyDet.UseExternalFieldMapFile")==0)? false : true; Bool_t useExtGeometryFile = (param.GetParameterI("ReconCyDet.UseExternalGeometryFile")==0)? false : true; std::string fieldMapFileName = param.GetParameterS("ReconCyDet.FieldMapFileName"); std::string geometryFileName = param.GetParameterS("ReconCyDet.GeometryFileName"); Int_t smearDriftDist = param.GetParameterI("ReconCyDet.EnableSmearing"); Double_t sigmaDist = param.GetParameterD("ReconCyDet.PositionResolution"); // Prepare algorithm fMCTrackFinder = new IMCTrackFinder("IMCTrackFinder_CyDet", "MC track finder for CyDet"); fMCTrackFinder->Init(); fGenFitter = new IGenFitter("IGenFitter_CyDet", "GenFit based track fitter for CyDet"); if (useExtFieldMapFile) { fFieldMapFileName = fieldMapFileName; fGenFitter->SetFieldMap(fFieldMapFileName); } if (useExtGeometryFile) { fGeometryFileName = geometryFileName; fGenFitter->SetGeometry(fGeometryFileName); } if (!smearDriftDist) fGenFitter->SetSmearing(false); else fGenFitter->SetSmearing(true); fGenFitter->SetSigmaDistance(sigmaDist); fGenFitter->Init(); } //====================================================================== // Destructor //====================================================================== ICyDetReconEventFunction::~ICyDetReconEventFunction() { fMCTrackFinder->Finish(); fGenFitter->Finish(); delete fMCTrackFinder; delete fGenFitter; } //====================================================================== // Usage //====================================================================== void ICyDetReconEventFunction::Usage() { std::cout << "Track Finding -> Track Fitting." << std::endl << std::endl << "Options:\n" << " No options yet.\n" << std::endl; } //====================================================================== // SetOption //====================================================================== bool ICyDetReconEventFunction::SetOption(TString option, TString value) { // No specific option now return false; } //====================================================================== // BeginOfEvent //====================================================================== void ICyDetReconEventFunction::BeginOfEvent() { COMETNamedInfo(GetFullName(), "BeginOfEvent()"); fGenFitter->BeginOfEvent(); } //====================================================================== // EndOfEvent //====================================================================== void ICyDetReconEventFunction::EndOfEvent() { } //====================================================================== // PrepareHits //====================================================================== COMET::IHandle ICyDetReconEventFunction::PrepareHits(COMET::ICOMETEvent& event) { COMET::IHandle result(new COMET::IAlgorithmResult("ReconCyDet_1stHitSel", "1st level hit selection for ReconCyDet")); /* // Iterate for digits COMET::IHandle digits = event.GetDigits("CyDet"); if(!digits){ COMETNamedVerbose(GetFullName(), "Cannot find digits"); } else{ COMET::IHitSelection* hits = MakeHitSelection(digits); if(hits) result->AddHitSelection(hits); } */ COMET::IHandle hits = event.GetHitSelection("mcCDC"); if (hits) { COMET::IHitSelection* hitSelection = fMCTrackFinder->MakeMCHitSelection(hits); if (hitSelection && !hitSelection->empty()) result->AddHitSelection(hitSelection); else COMETDebug("Cannot find hitSelection"); } else { COMETDebug("Cannot find hits"); } // Add IAlgorithmResult event.AddFit(result); return result; } //====================================================================== // MakeHitSelection //====================================================================== COMET::IHitSelection* ICyDetReconEventFunction::MakeHitSelection(COMET::IHandle& digits) { COMET::IHitSelection* hits = new COMET::IHitSelection("1stCyDetHits", "1st CyDet Hit Selection"); COMETNamedVerbose(GetFullName(), "Digits CyDet has " << digits->size() << " components."); for(COMET::IDigitContainer::iterator digitIt = digits->begin(); digitIt != digits->end(); digitIt++){ COMET::ICDCDigit* digit = static_cast(*digitIt); if(!digit){ COMETNamedVerbose(GetFullName(), "Cannot get a digit from digits CyDet"); continue; } COMET::IWritableDataHit* hit = MakeDataHit(digit); if(!hit){ COMETNamedVerbose(GetFullName(), "No data hit."); continue; } // Set digit proxy COMET::IDigitProxy proxy(*digits, digitIt); // if(! proxy.IsValid()){ // COMETNamedVerbose(GetFullName(), "A digit proxy is invalid."); // continue; // } hit->SetDigit(proxy); // Add hit hits->AddHit(COMET::IHandle(hit)); } // Check size if(hits->size() == 0){ COMETNamedVerbose(GetFullName(), "Cannot make hit selection: 1stCyDetHits"); delete hits; hits = NULL; } return hits; } //====================================================================== // MakeDataHit //====================================================================== COMET::IWritableDataHit* ICyDetReconEventFunction::MakeDataHit(COMET::ICDCDigit* digit) { // Not used now COMET::IWritableDataHit* hit = new COMET::IWritableDataHit(); return hit; } //====================================================================== // ProcessAlgorithms //====================================================================== COMET::IHandle ICyDetReconEventFunction::ProcessAlgorithms(const COMET::IAlgorithmResult& input, COMET::ICOMETEvent& event) { if (!(input.GetHitSelection()) || (input.GetHitSelection())->empty()) { COMET::IHandle dummy; return dummy; } COMET::IHandle mcTrackCandidates = fMCTrackFinder->Process(input); if (!mcTrackCandidates) { COMETNamedInfo("ICyDetReconEventFunction", "MC track candidates not found"); return mcTrackCandidates; } else { event.AddFit(mcTrackCandidates); COMET::IHandle genfitTracks = fGenFitter->Process(*mcTrackCandidates); if (genfitTracks) event.AddFit(genfitTracks); return genfitTracks; } }