@@ -241,6 +241,22 @@ struct muonQa {
241241 Configurable<int64_t > nolaterthanRealign{" ccdb-no-later-than-new" , std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count (), " latest acceptable timestamp of creation for the object of new basis" };
242242 } configCCDB;
243243
244+ // Derived version of mch::Track class that handles the associated clusters as internal objects and deletes them in the destructor
245+ class TrackRealigned : public mch ::Track
246+ {
247+ public:
248+ TrackRealigned () = default ;
249+ ~TrackRealigned ()
250+ {
251+ // delete the clusters associated to this track
252+ for (const auto & par : *this ) {
253+ if (par.getClusterPtr ()) {
254+ delete par.getClusterPtr ();
255+ }
256+ }
257+ }
258+ };
259+
244260 // // Variables for histograms configuration
245261 Configurable<int > fNCandidatesMax {" nCandidatesMax" , 5 , " " };
246262
@@ -1465,7 +1481,7 @@ struct muonQa {
14651481 }
14661482
14671483 template <typename TMCHTrack, typename TFwdCls, typename Var>
1468- bool FillClusters (TMCHTrack const & muon, TFwdCls const & mchcls, Var& fgValues, mch::Track & convertedTrack)
1484+ bool FillClusters (TMCHTrack const & muon, TFwdCls const & mchcls, Var& fgValues, TrackRealigned & convertedTrack)
14691485 {
14701486 int removable = 0 ;
14711487 auto clustersSliced = mchcls.sliceBy (perMuon, muon.globalIndex ()); // Slice clusters by muon id
@@ -2325,7 +2341,7 @@ struct muonQa {
23252341 }
23262342
23272343 // // Fill MCH clusters: do re-alignment if asked
2328- mch::Track mchrealignedTmp;
2344+ TrackRealigned mchrealignedTmp;
23292345 VarClusters fgValuesClsTmp;
23302346 if (!FillClusters (muon, clusters, fgValuesClsTmp, mchrealignedTmp)) {
23312347 continue ; // Refit is not valid
@@ -2424,7 +2440,7 @@ struct muonQa {
24242440 FillPropagation<1 >(muon, fgValuesColl, fgValuesMCH, fgValuesMCHpv); // copied in a separate variable
24252441
24262442 // // Fill MCH clusters: re-align clusters if required
2427- mch::Track mchrealigned;
2443+ TrackRealigned mchrealigned;
24282444 VarClusters fgValuesCls;
24292445 if (!FillClusters (muon, clusters, fgValuesCls, mchrealigned)) {
24302446 continue ; // if refit was not passed
@@ -2501,7 +2517,7 @@ struct muonQa {
25012517 FillPropagation<1 >(mchtrack, fgValuesCollMCH, VarTrack{}, fgValuesMCHpv); // saved in separate variable fgValuesMCHpv
25022518
25032519 // // Fill MCH clusters: re-align clusters if required
2504- mch::Track mchrealigned;
2520+ TrackRealigned mchrealigned;
25052521 VarClusters fgValuesCls;
25062522 if (!FillClusters (mchtrack, clusters, fgValuesCls, mchrealigned)) {
25072523 continue ; // if refit was not passed
@@ -2589,7 +2605,7 @@ struct muonQa {
25892605
25902606 VarTrack fgValuesMuon1, fgValuesMuonPV1;
25912607 VarTrack fgValuesMuon2, fgValuesMuonPV2;
2592- mch::Track mchrealigned1, mchrealigned2;
2608+ TrackRealigned mchrealigned1, mchrealigned2;
25932609 VarClusters fgValuesCls1, fgValuesCls2;
25942610 if (!FillClusters (muonTrack1, clusters, fgValuesCls1, mchrealigned1) || !FillClusters (muonTrack2, clusters, fgValuesCls2, mchrealigned2)) {
25952611 continue ; // Refit is not valid
@@ -3092,7 +3108,7 @@ struct muonQa {
30923108
30933109 VarTrack fgValuesMuon1, fgValuesMuonPV1;
30943110 VarTrack fgValuesMuon2, fgValuesMuonPV2;
3095- mch::Track mchrealigned1, mchrealigned2;
3111+ TrackRealigned mchrealigned1, mchrealigned2;
30963112 VarClusters fgValuesCls1, fgValuesCls2;
30973113 if (!FillClusters (muonTrack1, clusters, fgValuesCls1, mchrealigned1) || !FillClusters (muonTrack2, clusters, fgValuesCls2, mchrealigned2)) {
30983114 continue ; // Refit is not valid
@@ -3249,7 +3265,7 @@ struct muonQa {
32493265 FillMatching (muonTrack1, fgValuesMCH1, fgValuesMFT1);
32503266 FillMatching (muonTrack2, fgValuesMCH2, fgValuesMFT2);
32513267
3252- mch::Track mchrealigned1, mchrealigned2;
3268+ TrackRealigned mchrealigned1, mchrealigned2;
32533269 VarClusters fgValuesCls1, fgValuesCls2;
32543270 if (!FillClusters (mchTrack1, clusters, fgValuesCls1, mchrealigned1) || !FillClusters (mchTrack2, clusters, fgValuesCls2, mchrealigned2)) {
32553271 continue ; // Refit is not valid
0 commit comments