1313#include " PWGUD/Core/UPCHelpers.h"
1414#include " PWGUD/DataModel/UDTables.h"
1515
16+ #include " Framework/AnalysisDataModel.h"
17+ #include " Framework/AnalysisTask.h"
18+ #include " Framework/runDataProcessing.h"
19+
1620#include " CCDB/BasicCCDBManager.h"
1721#include " CommonConstants/LHCConstants.h"
18- #include " DataFormatsFIT/Triggers.h"
1922#include " DataFormatsParameters/GRPMagField.h"
2023#include " DetectorsBase/Propagator.h"
2124#include " Field/MagneticField.h"
22- #include " Framework/AnalysisDataModel.h"
23- #include " Framework/AnalysisTask.h"
24- #include " Framework/runDataProcessing.h"
2525#include " GlobalTracking/MatchGlobalFwd.h"
2626#include " MCHTracking/TrackExtrap.h"
27- #include " MCHTracking/TrackParam.h"
2827#include " ReconstructionDataFormats/TrackFwd.h"
2928
3029#include " Math/SMatrix.h"
3130#include " TGeoGlobalMagField.h"
3231
3332#include < algorithm>
34- #include < limits>
3533#include < map>
36- #include < unordered_map>
37- #include < unordered_set>
38- #include < utility>
3934#include < vector>
4035
4136using namespace o2 ::framework;
@@ -57,13 +52,13 @@ struct UpcCandProducerMuon {
5752 Produces<o2::aod::UDCollisionsSelsFwd> eventCandidatesSelsFwd;
5853 Produces<o2::aod::UDZdcsReduced> udZdcsReduced;
5954
60- Configurable<int > fSignalGenID {" signalGenID " , 1 , " Signal generator ID" };
55+ Configurable<int > fSignalGenID {" fSignalGenID " , 1 , " Signal generator ID" };
6156
62- UPCCutparHolder upcCuts = UPCCutparHolder();
63- MutableConfigurable<UPCCutparHolder> inputCuts{ " UPCCuts " , {}, " UPC event cuts" };
64- Configurable<uint64_t > fBCWindowFITAmps { " bcWindowFITAmps " , 20 , " BC range for T0A/V0A amplitudes array [-range, +(range-1)]" };
65- Configurable<int > fBcWindowMCH {" bcWindowMCH " , 20 , " Time window for MCH-MID to MCH-only matching for Muon candidates" };
66- Configurable<float > fMaxFV0Amp {" maxFV0Amp " , 100 .f , " Max FV0 amplitude in the same BC" };
57+ UPCCutparHolder fUpcCuts = UPCCutparHolder();
58+ MutableConfigurable<UPCCutparHolder> fUpcCutsConf { " fUpcCutsConf " , {}, " UPC event cuts" };
59+ Configurable<uint64_t > fBcWindowFITAmps { " fBcWindowFITAmps " , 20 , " BC range for T0A/V0A amplitudes array [-range, +(range-1)]" };
60+ Configurable<int > fBcWindowMCH {" fBcWindowMCH " , 20 , " Time window for MCH-MID to MCH-only matching for Muon candidates" };
61+ Configurable<float > fMaxFV0Amp {" fMaxFV0Amp " , 100 .f , " Max FV0 amplitude in the same BC" };
6762
6863 using ForwardTracks = o2::soa::Join<o2::aod::FwdTracks, o2::aod::FwdTracksCov>;
6964
@@ -76,8 +71,8 @@ struct UpcCandProducerMuon {
7671
7772 void init (InitContext&)
7873 {
79- upcCuts = (UPCCutparHolder)inputCuts ;
80- if (upcCuts .getUseFwdCuts ()) {
74+ fUpcCuts = (UPCCutparHolder)fUpcCutsConf ;
75+ if (fUpcCuts .getUseFwdCuts ()) {
8176 fCCDB ->setURL (" http://alice-ccdb.cern.ch" );
8277 fCCDB ->setCaching (true );
8378 fCCDB ->setLocalObjectValidityChecking ();
@@ -95,17 +90,18 @@ struct UpcCandProducerMuon {
9590
9691 bool cut (const o2::dataformats::GlobalFwdTrack& pft, const ForwardTracks::iterator& fwdTrack)
9792 {
93+ constexpr double absorberMid = 26.5 ;
9894 histRegistry.fill (HIST (" MuonsSelCounter" ), upchelpers::kFwdSelAll , 1 );
9995 auto pt = pft.getPt ();
10096 auto eta = pft.getEta ();
10197 auto pdca = fwdTrack.pDca ();
10298 auto rabs = fwdTrack.rAtAbsorberEnd ();
10399 auto chi2 = fwdTrack.chi2 ();
104- bool passPt = pt > upcCuts .getFwdPtLow () && pt < upcCuts .getFwdPtHigh ();
105- bool passEta = eta > upcCuts .getFwdEtaLow () && eta < upcCuts .getFwdEtaHigh ();
106- bool passRabs = rabs > upcCuts .getMuonRAtAbsorberEndLow () && rabs < upcCuts .getMuonRAtAbsorberEndHigh ();
107- bool passPDca = rabs < 26.5 ? pdca < upcCuts .getMuonPDcaHighFirst () : pdca < upcCuts .getMuonPDcaHighSecond ();
108- bool passChi2 = chi2 > upcCuts .getFwdChi2Low () && chi2 < upcCuts .getFwdChi2High ();
100+ bool passPt = pt > fUpcCuts .getFwdPtLow () && pt < fUpcCuts .getFwdPtHigh ();
101+ bool passEta = eta > fUpcCuts .getFwdEtaLow () && eta < fUpcCuts .getFwdEtaHigh ();
102+ bool passRabs = rabs > fUpcCuts .getMuonRAtAbsorberEndLow () && rabs < fUpcCuts .getMuonRAtAbsorberEndHigh ();
103+ bool passPDca = rabs < absorberMid ? pdca < fUpcCuts .getMuonPDcaHighFirst () : pdca < fUpcCuts .getMuonPDcaHighSecond ();
104+ bool passChi2 = chi2 > fUpcCuts .getFwdChi2Low () && chi2 < fUpcCuts .getFwdChi2High ();
109105 if (passPt)
110106 histRegistry.fill (HIST (" MuonsSelCounter" ), upchelpers::kFwdSelPt , 1 );
111107 if (passEta)
@@ -157,7 +153,7 @@ struct UpcCandProducerMuon {
157153 // collecting new mother IDs
158154 if (mcPart.has_mothers ()) {
159155 const auto & motherIDs = mcPart.mothersIds ();
160- for (auto motherID : motherIDs) {
156+ for (const auto & motherID : motherIDs) {
161157 if (motherID >= nMCParticles) {
162158 continue ;
163159 }
@@ -273,7 +269,7 @@ struct UpcCandProducerMuon {
273269 {
274270 auto fillMchIds = [&outMchTrkIds](std::map<uint64_t , std::vector<int64_t >>::iterator& inIt, uint64_t gbc) {
275271 std::vector<int64_t >& ids = inIt->second ;
276- for (auto id : ids)
272+ for (const auto & id : ids)
277273 outMchTrkIds[id] = gbc;
278274 };
279275 scrollBackForth (inGbc, maxDbc, mchTracksPerBC, fillMchIds);
@@ -327,7 +323,7 @@ struct UpcCandProducerMuon {
327323 const auto & track = fwdTracks.iteratorAt (trackId);
328324 float px, py, pz;
329325 int sign;
330- if (upcCuts .getUseFwdCuts ()) {
326+ if (fUpcCuts .getUseFwdCuts ()) {
331327 auto pft = propagateToZero (track);
332328 bool pass = cut (pft, track);
333329 if (!pass)
@@ -363,8 +359,11 @@ struct UpcCandProducerMuon {
363359 o2::aod::Zdcs const & zdcs,
364360 const o2::aod::McFwdTrackLabels* mcFwdTrackLabels)
365361 {
362+ using o2::aod::fwdtrack::ForwardTrackTypeEnum::MCHStandaloneTrack;
363+ using o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack;
364+
366365 int32_t runNumber = bcs.iteratorAt (0 ).runNumber ();
367- if (upcCuts .getUseFwdCuts ()) {
366+ if (fUpcCuts .getUseFwdCuts ()) {
368367 if (runNumber != fRun ) {
369368 fRun = runNumber;
370369 std::map<std::string, std::string> metadata;
@@ -391,17 +390,19 @@ struct UpcCandProducerMuon {
391390 }
392391
393392 std::map<uint64_t , int64_t > mapGlobalBcWithV0A{};
393+ constexpr float fv0ValidTime = 15 .f ;
394394 for (const auto & fv0 : fv0s) {
395- if (std::abs (fv0.time ()) > 15 . f )
395+ if (std::abs (fv0.time ()) > fv0ValidTime )
396396 continue ;
397397 uint64_t globalBC = vGlobalBCs[fv0.bcId ()];
398398 mapGlobalBcWithV0A[globalBC] = fv0.globalIndex ();
399399 }
400400 auto nFV0s = mapGlobalBcWithV0A.size ();
401401
402402 std::map<uint64_t , int64_t > mapGlobalBcWithZdc{};
403+ constexpr float zdcValidTime = 2 .f ;
403404 for (const auto & zdc : zdcs) {
404- if (std::abs (zdc.timeZNA ()) > 2 . f && std::abs (zdc.timeZNC ()) > 2 . f )
405+ if (std::abs (zdc.timeZNA ()) > zdcValidTime && std::abs (zdc.timeZNC ()) > zdcValidTime )
405406 continue ;
406407 uint64_t globalBC = vGlobalBCs[zdc.bcId ()];
407408 mapGlobalBcWithZdc[globalBC] = zdc.globalIndex ();
@@ -420,34 +421,34 @@ struct UpcCandProducerMuon {
420421 std::map<uint64_t , std::vector<int64_t >> mapGlobalBcsWithMCHMIDTrackIds;
421422 std::map<uint64_t , std::vector<int64_t >> mapGlobalBcsWithMCHTrackIds;
422423 for (const auto & fwdTrack : fwdTracks) {
423- if (fwdTrack.trackType () != 3 && fwdTrack.trackType () != 4 )
424+ if (fwdTrack.trackType () != MCHStandaloneTrack && fwdTrack.trackType () != MuonStandaloneTrack )
424425 continue ;
425426 auto trackId = fwdTrack.globalIndex ();
426427 int64_t indexBC = vAmbFwdTrackIndex[trackId] < 0 ? vColIndexBCs[fwdTrack.collisionId ()] : vAmbFwdTrackIndexBCs[vAmbFwdTrackIndex[trackId]];
427428 auto globalBC = vGlobalBCs[indexBC] + TMath::FloorNint (fwdTrack.trackTime () / o2::constants::lhc::LHCBunchSpacingNS + 1 .);
428- if (fwdTrack.trackType () == 3 )
429+ if (fwdTrack.trackType () == MuonStandaloneTrack )
429430 mapGlobalBcsWithMCHMIDTrackIds[globalBC].push_back (trackId);
430- if (fwdTrack.trackType () == 4 )
431+ if (fwdTrack.trackType () == MCHStandaloneTrack )
431432 mapGlobalBcsWithMCHTrackIds[globalBC].push_back (trackId);
432433 }
433434
434435 int32_t candId = 0 ;
435- for (auto & gbc_muids : mapGlobalBcsWithMCHMIDTrackIds) {
436+ for (const auto & gbc_muids : mapGlobalBcsWithMCHMIDTrackIds) {
436437 uint64_t globalBcMid = gbc_muids.first ;
437438 auto itFv0Id = mapGlobalBcWithV0A.find (globalBcMid);
438439 if (itFv0Id != mapGlobalBcWithV0A.end ()) {
439440 auto fv0Id = itFv0Id->second ;
440441 const auto & fv0 = fv0s.iteratorAt (fv0Id);
441442 float fv0Amp = 0 .f ;
442- for (auto amp : fv0.amplitude ())
443+ for (const auto & amp : fv0.amplitude ())
443444 fv0Amp += amp;
444445 if (fv0Amp > fMaxFV0Amp )
445446 continue ;
446447 }
447448 uint16_t numContrib = 0 ;
448449 auto & vMuonIds = gbc_muids.second ;
449450 // writing MCH-MID tracks
450- for (auto imuon : vMuonIds) {
451+ for (const auto & imuon : vMuonIds) {
451452 if (!addToFwdTable (candId, imuon, globalBcMid, 0 ., fwdTracks, mcFwdTrackLabels))
452453 continue ;
453454 numContrib++;
@@ -457,7 +458,7 @@ struct UpcCandProducerMuon {
457458 std::map<int64_t , uint64_t > mapMchIdBc{};
458459 getMchTrackIds (globalBcMid, mapGlobalBcsWithMCHTrackIds, fBcWindowMCH , mapMchIdBc);
459460 // writing MCH-only tracks
460- for (auto & [imch, gbc] : mapMchIdBc) {
461+ for (const auto & [imch, gbc] : mapMchIdBc) {
461462 if (!addToFwdTable (candId, imch, gbc, (gbc - globalBcMid) * o2::constants::lhc::LHCBunchSpacingNS, fwdTracks, mcFwdTrackLabels))
462463 continue ;
463464 numContrib++;
@@ -468,7 +469,7 @@ struct UpcCandProducerMuon {
468469 std::vector<float > amplitudesT0A{};
469470 std::vector<int8_t > relBCsT0A{};
470471 if (nFV0s > 0 ) {
471- getFV0Amplitudes (globalBcMid, fv0s, fBCWindowFITAmps , mapGlobalBcWithV0A, amplitudesV0A, relBCsV0A);
472+ getFV0Amplitudes (globalBcMid, fv0s, fBcWindowFITAmps , mapGlobalBcWithV0A, amplitudesV0A, relBCsV0A);
472473 }
473474 eventCandidatesSelsFwd (0 ., 0 ., amplitudesT0A, relBCsT0A, amplitudesV0A, relBCsV0A);
474475 if (nZdcs > 0 ) {
0 commit comments