Skip to content

Commit e7ac315

Browse files
authored
Add files via upload
1 parent 0e2dfee commit e7ac315

File tree

1 file changed

+97
-48
lines changed

1 file changed

+97
-48
lines changed

PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

Lines changed: 97 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,16 +3452,12 @@ struct AnalysisDileptonTrack {
34523452
Configurable<std::string> fConfigTrackCuts{"cfgTrackCuts", "kaonPID", "Comma separated list of track cuts to be correlated with the dileptons"};
34533453
Configurable<float> fConfigDileptonLowMass{"cfgDileptonLowMass", 2.8, "Low mass cut for the dileptons used in analysis"};
34543454
Configurable<float> fConfigDileptonHighMass{"cfgDileptonHighMass", 3.2, "High mass cut for the dileptons used in analysis"};
3455+
Configurable<float> fConfigDileptonpTCut{"cfgDileptonpTCut", 0.0, "pT cut for dileptons used in the triplet vertexing"};
3456+
Configurable<float> fConfigDileptonLxyCut{"cfgDileptonLxyCut", 0.0, "Lxy cut for dileptons used in the triplet vertexing"};
3457+
Configurable<bool> fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"};
34553458
Configurable<float> fConfigDileptonLowpTCut{"cfgDileptonLowpTCut", 0.0, "Low pT cut for dileptons used in the triplet vertexing"};
34563459
Configurable<float> fConfigDileptonHighpTCut{"cfgDileptonHighpTCut", 1E5, "High pT cut for dileptons used in the triplet vertexing"};
34573460
Configurable<float> fConfigDileptonRapCutAbs{"cfgDileptonRapCutAbs", 1.0, "Rap cut for dileptons used in the triplet vertexing"};
3458-
Configurable<float> fConfigDileptonLxyCut{"cfgDileptonLxyCut", 0.0, "Lxy cut for dileptons used in the triplet vertexing"};
3459-
Configurable<bool> fConfigUseKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"};
3460-
Configurable<bool> fConfigUseMCGenpTcut{"cfgUseMCGenpTcut", false, "Use pT cut for dileptons used in the triplet vertexing(generated)"};
3461-
Configurable<bool> fConfigUseMCRapcut{"cfgUseMCRapcut", false, "Use Rap cut for dileptons used in the triplet vertexing(generated and reconstructed)"};
3462-
Configurable<bool> fConfigCaculateEC{"cfgCaculateEC", false, "the switch for caculate the energy correlators"};
3463-
Configurable<bool> fConfigCaculateRE{"cfgCaculateRE", true, "the switch for caculate the RE"};
3464-
34653461
Configurable<std::string> fConfigHistogramSubgroups{"cfgDileptonTrackHistogramsSubgroups", "invmass,vertexing", "Comma separated list of dilepton-track histogram subgroups"};
34663462
Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
34673463

@@ -3484,6 +3480,7 @@ struct AnalysisDileptonTrack {
34843480
Configurable<float> fConfigMCGenHadronPtMin{"cfgMCGenHadronPtMin", 1.0f, "minimum pt for the hadron"};
34853481
Configurable<float> fConfigMCGenDileptonLegEtaAbs{"cfgMCGenDileptonLegEtaAbs", 0.9f, "eta abs range for the dilepton leg"};
34863482
Configurable<float> fConfigMCGenHadronEtaAbs{"cfgMCGenHadronEtaAbs", 0.9f, "eta abs range for the hadron"};
3483+
Configurable<bool> fConfigUseMCRapcut{"cfgUseMCRapcut", false, "Use Rap cut for dileptons used in the triplet vertexing(reconstructed)"};
34873484

34883485
int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc.
34893486
int fNCuts;
@@ -3511,8 +3508,6 @@ struct AnalysisDileptonTrack {
35113508

35123509
// use two values array to avoid mixing up the quantities
35133510
float* fValuesDilepton;
3514-
float* fValuesSignal;
3515-
float* fValuesEC;
35163511
float* fValuesHadron;
35173512
HistogramManager* fHistMan;
35183513

@@ -3526,6 +3521,7 @@ struct AnalysisDileptonTrack {
35263521
bool isMuon = context.mOptions.get<bool>("processMuonSkimmed");
35273522
bool isMCGen = context.mOptions.get<bool>("processMCGen") || context.mOptions.get<bool>("processMCGenWithEventSelection");
35283523
bool isDummy = context.mOptions.get<bool>("processDummy");
3524+
bool isMCGen_energycorrelators = context.mOptions.get<bool>("processMCGenEnergyCorrelators") || context.mOptions.get<bool>("processMCGenEnergyCorrelatorsPion");
35293525

35303526
if (isDummy) {
35313527
if (isBarrel || isMuon || isBarrelAsymmetric || isMCGen) {
@@ -3548,9 +3544,6 @@ struct AnalysisDileptonTrack {
35483544

35493545
fValuesDilepton = new float[VarManager::kNVars];
35503546
fValuesHadron = new float[VarManager::kNVars];
3551-
fValuesSignal = new float[VarManager::kNVars];
3552-
fValuesEC = new float[VarManager::kNVars];
3553-
35543547
fTrackCutBitMap = 0;
35553548
VarManager::SetDefaultVarNames();
35563549
fHistMan = new HistogramManager("analysisHistos", "aa", VarManager::kNVars);
@@ -3810,11 +3803,16 @@ struct AnalysisDileptonTrack {
38103803
DefineHistograms(fHistMan, Form("MCTruthGen_%s", sig->GetName()), "");
38113804
DefineHistograms(fHistMan, Form("MCTruthGenSel_%s", sig->GetName()), "");
38123805
}
3813-
if (fConfigCaculateRE) {
3814-
for (auto& sig : fRecMCSignals) {
3815-
DefineHistograms(fHistMan, Form("MCTruthGenSelBR_%s", sig->GetName()), "");
3816-
DefineHistograms(fHistMan, Form("MCTruthGenSelBRAccepted_%s", sig->GetName()), "");
3817-
}
3806+
for (auto& sig : fRecMCSignals) {
3807+
DefineHistograms(fHistMan, Form("MCTruthGenSelBR_%s", sig->GetName()), "");
3808+
DefineHistograms(fHistMan, Form("MCTruthGenSelBRAccepted_%s", sig->GetName()), "");
3809+
}
3810+
}
3811+
3812+
if (isMCGen_energycorrelators) {
3813+
for (auto& sig : fGenMCSignals) {
3814+
DefineHistograms(fHistMan, Form("MCTruthECDilepton_%s", sig->GetName()), "");
3815+
DefineHistograms(fHistMan, Form("MCTruthECHadron_%s", sig->GetName()), "");
38183816
}
38193817
}
38203818

@@ -3878,7 +3876,6 @@ struct AnalysisDileptonTrack {
38783876
if (dilepton.sign() != 0) {
38793877
continue;
38803878
}
3881-
38823879
// dilepton rap cut
38833880
float rap = dilepton.rap();
38843881
if (fConfigUseMCRapcut && abs(rap) > fConfigDileptonRapCutAbs)
@@ -4203,8 +4200,6 @@ struct AnalysisDileptonTrack {
42034200
void processMCGenWithEventSelection(soa::Filtered<MyEventsVtxCovSelected> const& events,
42044201
ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks)
42054202
{
4206-
VarManager::ResetValues(0, VarManager::kNVars, fValuesSignal);
4207-
VarManager::ResetValues(0, VarManager::kNVars, fValuesEC);
42084203
for (auto& event : events) {
42094204
if (!event.isEventSelected_bit(0)) {
42104205
continue;
@@ -4216,39 +4211,17 @@ struct AnalysisDileptonTrack {
42164211
auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.reducedMCeventId());
42174212
groupedMCTracks.bindInternalIndicesTo(&mcTracks);
42184213
for (auto& track : groupedMCTracks) {
4219-
auto track_raw = mcTracks.rawIteratorAt(track.globalIndex());
4220-
// apply kinematic cuts for signal
4221-
if (fConfigUseMCGenpTcut && (track_raw.pt() < fConfigDileptonLowpTCut || track_raw.pt() > fConfigDileptonHighpTCut))
4222-
continue;
4223-
if (fConfigUseMCRapcut && abs(track_raw.y()) > fConfigDileptonRapCutAbs)
4224-
continue;
4225-
VarManager::FillTrackMC(mcTracks, track_raw, fValuesSignal);
4214+
4215+
VarManager::FillTrackMC(mcTracks, track);
4216+
4217+
auto track_raw = groupedMCTracks.rawIteratorAt(track.globalIndex());
42264218
for (auto& sig : fGenMCSignals) {
42274219
if (sig->CheckSignal(true, track_raw)) {
4228-
fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), fValuesSignal);
4229-
}
4230-
}
4231-
// for the energy correlators
4232-
if (!fConfigCaculateEC)
4233-
continue;
4234-
for (auto& mctrack1 : groupedMCTracks) {
4235-
if (TMath::Abs(mctrack1.pdgCode()) == 443 || TMath::Abs(mctrack1.pdgCode()) == 11 || TMath::Abs(mctrack1.pdgCode()) == 22)
4236-
continue;
4237-
if (mctrack1.pt() < fConfigMCGenHadronPtMin.value || std::abs(mctrack1.eta()) > fConfigMCGenHadronEtaAbs.value)
4238-
continue;
4239-
if (mctrack1.getGenStatusCode() <= 0)
4240-
continue;
4241-
for (auto& sig : fGenMCSignals) {
4242-
VarManager::FillEnergyCorrelators(track_raw, mctrack1, fValuesEC);
4243-
if (sig->CheckSignal(true, track_raw)) {
4244-
fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), fValuesEC);
4245-
}
4220+
fHistMan->FillHistClass(Form("MCTruthGenSel_%s", sig->GetName()), VarManager::fgValues);
42464221
}
42474222
}
42484223
}
42494224

4250-
if (!fConfigCaculateRE)
4251-
continue;
42524225
// make a list of all MC tracks in the MC collision corresponding to the current reconstructed event
42534226
std::vector<size_t> mcTrackIndices;
42544227
for (auto& t : groupedMCTracks) {
@@ -4290,6 +4263,72 @@ struct AnalysisDileptonTrack {
42904263
} // end loop over reconstructed events
42914264
}
42924265

4266+
template <int THadronMassType, typename TEvent, typename TMCTracks>
4267+
void runEnergyCorrelators(TEvent const& event, TMCTracks const& mcTracks)
4268+
{
4269+
VarManager::ResetValues(0, VarManager::kNVars, fValuesHadron);
4270+
VarManager::ResetValues(0, VarManager::kNVars, fValuesDilepton);
4271+
auto groupedMCTracks = mcTracks.sliceBy(perReducedMcEvent, event.reducedMCeventId());
4272+
groupedMCTracks.bindInternalIndicesTo(&mcTracks);
4273+
for (auto& t1 : groupedMCTracks) {
4274+
auto t1_raw = groupedMCTracks.rawIteratorAt(t1.globalIndex());
4275+
// apply kinematic cuts for signal
4276+
if ((t1_raw.pt() < fConfigDileptonLowpTCut || t1_raw.pt() > fConfigDileptonHighpTCut))
4277+
continue;
4278+
if (abs(t1_raw.y()) > fConfigDileptonRapCutAbs)
4279+
continue;
4280+
VarManager::FillTrackMC(mcTracks, t1_raw, fValuesDilepton);
4281+
for (auto& sig : fGenMCSignals) {
4282+
if (sig->CheckSignal(true, t1_raw)) {
4283+
fHistMan->FillHistClass(Form("MCTruthECDilepton_%s", sig->GetName()), fValuesDilepton);
4284+
}
4285+
}
4286+
// for the energy correlators
4287+
for (auto& t2 : groupedMCTracks) {
4288+
auto t2_raw = groupedMCTracks.rawIteratorAt(t2.globalIndex());
4289+
if (TMath::Abs(t2_raw.pdgCode()) == 443 || TMath::Abs(t2_raw.pdgCode()) == 11 || TMath::Abs(t2_raw.pdgCode()) == 22)
4290+
continue;
4291+
if (t2_raw.pt() < fConfigMCGenHadronPtMin.value || std::abs(t2_raw.eta()) > fConfigMCGenHadronEtaAbs.value)
4292+
continue;
4293+
if (t2_raw.getGenStatusCode() <= 0)
4294+
continue;
4295+
VarManager::FillEnergyCorrelators<THadronMassType>(t1_raw, t2_raw, fValuesHadron);
4296+
for (auto& sig : fGenMCSignals) {
4297+
if (sig->CheckSignal(true, t1_raw)) {
4298+
fHistMan->FillHistClass(Form("MCTruthECHadron_%s", sig->GetName()), fValuesHadron);
4299+
}
4300+
}
4301+
}
4302+
}
4303+
}
4304+
void processMCGenEnergyCorrelators(soa::Filtered<MyEventsVtxCovSelected> const& events,
4305+
ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks)
4306+
{
4307+
for (auto& event : events) {
4308+
if (!event.isEventSelected_bit(0)) {
4309+
continue;
4310+
}
4311+
if (!event.has_reducedMCevent()) {
4312+
continue;
4313+
}
4314+
runEnergyCorrelators<VarManager::kRealHadronMass>(event, mcTracks);
4315+
}
4316+
}
4317+
4318+
void processMCGenEnergyCorrelatorsPion(soa::Filtered<MyEventsVtxCovSelected> const& events,
4319+
ReducedMCEvents const& /*mcEvents*/, ReducedMCTracks const& mcTracks)
4320+
{
4321+
for (auto& event : events) {
4322+
if (!event.isEventSelected_bit(0)) {
4323+
continue;
4324+
}
4325+
if (!event.has_reducedMCevent()) {
4326+
continue;
4327+
}
4328+
runEnergyCorrelators<VarManager::kTreatAsPion>(event, mcTracks);
4329+
}
4330+
}
4331+
42934332
void processDummy(MyEvents&)
42944333
{
42954334
// do nothing
@@ -4300,6 +4339,8 @@ struct AnalysisDileptonTrack {
43004339
PROCESS_SWITCH(AnalysisDileptonTrack, processMuonSkimmed, "Run muon dilepton-track pairing, using skimmed data", false);
43014340
PROCESS_SWITCH(AnalysisDileptonTrack, processMCGen, "Loop over MC particle stack and fill generator level histograms", false);
43024341
PROCESS_SWITCH(AnalysisDileptonTrack, processMCGenWithEventSelection, "Loop over MC particle stack and fill generator level histograms", false);
4342+
PROCESS_SWITCH(AnalysisDileptonTrack, processMCGenEnergyCorrelators, "Loop over MC particle stack and fill generator level histograms(energy correlators)", false);
4343+
PROCESS_SWITCH(AnalysisDileptonTrack, processMCGenEnergyCorrelatorsPion, "Loop over MC particle stack and fill generator level histograms(energy correlators)", false);
43034344
PROCESS_SWITCH(AnalysisDileptonTrack, processDummy, "Dummy function", true);
43044345
};
43054346

@@ -4376,7 +4417,6 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses, const char
43764417

43774418
if (classStr.Contains("MCTruthGen")) {
43784419
dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth_track");
4379-
dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "energy_correlator_gen");
43804420
}
43814421

43824422
if (classStr.Contains("DileptonsSelected")) {
@@ -4402,5 +4442,14 @@ void DefineHistograms(HistogramManager* histMan, TString histClasses, const char
44024442
if (classStr.Contains("DileptonHadronCorrelation")) {
44034443
dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "dilepton-hadron-correlation");
44044444
}
4445+
4446+
if (classStr.Contains("MCTruthECDilepton")) {
4447+
dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "mctruth_track");
4448+
}
4449+
4450+
if (classStr.Contains("MCTruthECHadron")) {
4451+
dqhistograms::DefineHistograms(histMan, objArray->At(iclass)->GetName(), "energy-correlator-gen");
4452+
}
4453+
44054454
} // end loop over histogram classes
44064455
}

0 commit comments

Comments
 (0)