function newCvd = applyDataMask(this, targetCvIds)
%

%   Copyright 2018-2019 The MathWorks, Inc.
    [metricNames, toMetricNames] = getEnabledMetricNames(this);
    deleteIdx = contains(metricNames, {'sigrange', 'sigsize'});
    metricNames(deleteIdx == 1) = [];
    allMetricNames = [metricNames, toMetricNames];
    
    
    tmpCvd = cvdata;
    tmpCvd.createDerivedData(this,  this, this.metrics, this.trace);
    tmpCvd.testRunInfo = this.testRunInfo; % Masked cvdata refers to the same simulation as the original
    joinedAggregatedTestInfo =  cvdata.createAggregatedTestInfo(tmpCvd);
    
    
    targetIndexMap = tmpCvd.getMetricIndices(tmpCvd, targetCvIds, allMetricNames);
    
    [metricStruct, traceStruct] = cvdata.processSubsystemMetric(tmpCvd.rootID, tmpCvd, targetIndexMap, ...
                                                    [], targetIndexMap, ...
                                                    joinedAggregatedTestInfo, ...
                                                    metricNames, toMetricNames, 'reset', true);


    
    newCvd = cvdata;
    newCvd.createDerivedData(this,  this, metricStruct, traceStruct);
    newCvd.testRunInfo = this.testRunInfo; % Masked cvdata refers to the same simulation as the original
    newCvd.aggregatedTestInfo = cvdata.createAggregatedTestInfo(newCvd);
end

