140 const std::vector<o2::dataformats::GlobalFwdTrack>&
getMatchedFwdTracks()
const {
return mMatchedTracks; }
143 const std::vector<o2::dataformats::MatchInfoFwd>&
getMFTMCHMatchInfo()
const {
return mMatchingInfo; }
144 const std::vector<o2::MCCompLabel>&
getMatchLabels()
const {
return mMatchLabels; }
152 void updateTimeDependentParams();
153 void fillBuiltinFunctions();
155 bool prepareMCHData();
156 bool prepareMFTData();
157 bool processMCHMIDMatches();
159 template <
int saveMode>
167 template <
int saveMode>
168 void ROFMatch(
int MFTROFId,
int firstMCHROFId,
int lastMCHROFId);
174 void setMFTRadLength(
float MFT_x2X0) { mMFTDiskThicknessInX0 = MFT_x2X0 / 5.0; }
175 void setAlignResiduals(
Float_t res) { mAlignResidual =
res; }
177 template <
typename T>
178 bool propagateToNextClusterWithMCS(T& track,
double z,
int& startingLayerID,
const int& newLayerID)
184 if (startingLayerID == newLayerID) {
185 LOG(
debug) <<
" => Propagate to next cluster with MCS : startingLayerID = " << startingLayerID <<
" = > "
186 <<
" newLayerID = " << newLayerID <<
" (NLayers = " << std::abs(newLayerID - startingLayerID)
187 <<
") ; track.getZ() = " << track.getZ() <<
" => "
188 <<
"destination cluster z = " <<
z <<
" ; => Same layer: no MCS effects.";
190 if (
z != track.getZ()) {
191 track.propagateToZ(
z, mBz);
197 auto startingZ = track.getZ();
200 auto signum = [](
auto a) {
201 return (0 <
a) - (
a < 0);
203 int direction = signum(newLayerID - startingLayerID);
204 auto currentLayer = startingLayerID;
206 LOG(
debug) <<
" => Propagate to next cluster with MCS : startingLayerID = " << startingLayerID <<
" = > "
207 <<
" newLayerID = " << newLayerID <<
" (NLayers = " << std::abs(newLayerID - startingLayerID)
208 <<
") ; track.getZ() = " << track.getZ() <<
" => "
209 <<
"destination cluster z = " <<
z <<
" ; ";
212 while (currentLayer != newLayerID) {
213 auto nextlayer = currentLayer + direction;
217 if (nextZ - track.getZ() > 0) {
218 NDisksMS = (currentLayer % 2 == 0) ? (currentLayer - nextlayer) / 2 : (currentLayer - nextlayer + 1) / 2;
220 NDisksMS = (currentLayer % 2 == 0) ? (nextlayer - currentLayer + 1) / 2 : (nextlayer - currentLayer) / 2;
223 LOG(
debug) <<
"currentLayer = " << currentLayer <<
" ; "
224 <<
"nextlayer = " << nextlayer <<
" ; "
225 <<
"track.getZ() = " << track.getZ() <<
" ; "
226 <<
"nextZ = " << nextZ <<
" ; "
227 <<
"NDisksMS = " << NDisksMS;
229 if ((NDisksMS * mMFTDiskThicknessInX0) != 0) {
230 track.addMCSEffect(NDisksMS * mMFTDiskThicknessInX0);
231 LOG(
debug) <<
"Track covariances after MCS effects:";
232 LOG(
debug) << track.getCovariances() << std::endl;
235 LOG(
debug) <<
" BeforeExtrap: X = " << track.getX() <<
" Y = " << track.getY() <<
" Z = " << track.getZ() <<
" Tgl = " << track.getTanl() <<
" Phi = " << track.getPhi() <<
" pz = " << track.getPz() <<
" q/pt = " << track.getInvQPt() << std::endl;
237 track.propagateToZ(nextZ, mBz);
239 currentLayer = nextlayer;
241 if (
z != track.getZ()) {
242 track.propagateToZ(
z, mBz);
244 startingLayerID = newLayerID;
248 MatchingFunc_t mMatchFunc = [](
const GlobalFwdTrack& mchtrack,
const TrackParCovFwd& mfttrack) ->
double {
249 throw std::runtime_error(
"MatchGlobalFwd: matching function not configured!");
252 CutFunc_t mCutFunc = [](
const GlobalFwdTrack& mchtrack,
const TrackParCovFwd& mfttrack) ->
bool {
253 throw std::runtime_error(
"MatchGlobalFwd: track pair candidate cut function not configured!");
256 bool loadExternalMatchingFunction()
262 const auto& extFuncMacroFile = matchingParam.extMatchFuncFile;
263 const auto& extFuncName = matchingParam.extMatchFuncName;
265 LOG(info) <<
"Loading external MFTMCH matching function: function name = " << extFuncName <<
" ; Filename = " << extFuncMacroFile;
267 auto func = o2::conf::GetFromMacro<MatchingFunc_t*>(extFuncMacroFile.c_str(), extFuncName.c_str(),
"o2::globaltracking::MatchingFunc_t*",
"mtcFcn");
268 mMatchFunc = (*func);
272 bool loadExternalCutFunction()
278 const auto& extFuncMacroFile = matchingParam.extMatchFuncFile;
279 const auto& extFuncName = matchingParam.extCutFuncName;
281 LOG(info) <<
"Loading external MFTMCH cut function: function name = " << extFuncName <<
" ; Filename = " << extFuncMacroFile;
283 auto func = o2::conf::GetFromMacro<CutFunc_t*>(extFuncMacroFile.c_str(), extFuncName.c_str(),
"o2::globaltracking::CutFunc_t*",
"cutFcn");
290 Float_t mMFTDiskThicknessInX0 = 0.042 / 5;
293 int mMFTROFrameLengthInBC = 0;
294 float mMFTROFrameLengthMUS = -1.;
295 float mMFTROFrameLengthMUSInv = -1.;
296 int mMFTROFrameBiasInBC = 0;
297 float mMFTROFrameBiasMUS = -1.;
298 float mMFTROFrameBiasMUSInv = -1.;
300 std::map<std::string, MatchingFunc_t> mMatchingFunctionMap;
301 std::map<std::string, CutFunc_t> mCutFunctionMap;
304 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchAbove;
305 std::array<int16_t, o2::constants::lhc::LHCMaxBunches> mClosestBunchBelow;
307 bool mMFTTriggered =
false;
310 std::vector<int> mMFTTrackROFContMapping;
313 gsl::span<const o2::mch::TrackMCH> mMCHTracks;
314 gsl::span<const o2::mch::ROFRecord> mMCHTrackROFRec;
315 gsl::span<const o2::mft::TrackMFT> mMFTTracks;
316 gsl::span<const o2::itsmft::ROFRecord> mMFTTrackROFRec;
317 gsl::span<const o2::dataformats::TrackMCHMID> mMCHMIDMatches;
318 gsl::span<const int> mMFTTrackClusIdx;
319 gsl::span<const o2::itsmft::ROFRecord> mMFTClusterROFRec;
320 gsl::span<const o2::dataformats::MatchInfoFwd> mMatchingInfoUpstream;
321 gsl::span<const o2::MCCompLabel> mMFTTrkLabels;
322 gsl::span<const o2::MCCompLabel> mMCHTrkLabels;
324 std::vector<BracketF> mMCHROFTimes;
325 std::vector<TrackLocMCH> mMCHWork;
326 std::vector<int> mMCHID2Work;
327 std::vector<BracketF> mMFTROFTimes;
328 std::vector<TrackLocMFT> mMFTWork;
329 std::vector<MFTCluster> mMFTClusters;
330 std::vector<o2::dataformats::GlobalFwdTrack> mMatchedTracks;
331 std::vector<o2::MCCompLabel> mMatchLabels;
332 std::vector<o2::dataformats::MatchInfoFwd> mMatchingInfo;
333 std::vector<o2::mft::TrackMFT> mMFTMatchPlaneParams;
334 std::vector<o2::track::TrackParCovFwd> mMCHMatchPlaneParams;
336 std::map<int, std::vector<std::pair<float, int>>> mCandidates;
340 bool mMCTruthON =
false;
341 bool mUseMIDMCHMatch =
false;
342 bool mUseTrackTime =
false;
344 int mNCandidates = 5;
346 TGeoManager* mGeoManager;