Skip to content

Commit

Permalink
[TOF] add delta MC
Browse files Browse the repository at this point in the history
  • Loading branch information
njacazio authored Aug 29, 2024
1 parent 24ceedf commit 43febf0
Showing 1 changed file with 79 additions and 63 deletions.
142 changes: 79 additions & 63 deletions DPG/Tasks/AOTTrack/PID/TOF/qaPIDTOFEvTime.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,21 @@ struct tofPidCollisionTimeQa {
return;
}
const AxisSpec diffAxis{1000, -1000, 1000, "Difference"};
histos.add<TH1>("MC/diff/All", "All", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t_{MC}-t_{All} (ps)");
histos.add<TH1>("MC/diff/FT0", "FT0", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t_{MC}-t_{FT0} (ps)");
histos.add<TH1>("MC/diff/TOF", "TOF", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t_{MC}-t_{TOF} (ps)");
histos.add<TH1>("MC/diff/All", "All", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t^{All}_{ev} (ps)");
histos.add<TH1>("MC/diff/FT0", "FT0", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{FT0}_{ev} (ps)");
histos.add<TH1>("MC/diff/TOF", "TOF", HistType::kTH1F, {diffAxis})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{TOF}_{ev} (ps)");

histos.add<TH2>("MC/diffvsZ/All", "All", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t_{MC}-t_{All} (ps)");
histos.add<TH2>("MC/diffvsZ/FT0", "FT0", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t_{MC}-t_{FT0} (ps)");
histos.add<TH2>("MC/diffvsZ/TOF", "TOF", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t_{MC}-t_{TOF} (ps)");
histos.add<TH2>("MC/diffvsZ/All", "All", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t^{All}_{ev}_{ev} (ps)");
histos.add<TH2>("MC/diffvsZ/FT0", "FT0", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{FT0}_{ev} (ps)");
histos.add<TH2>("MC/diffvsZ/TOF", "TOF", HistType::kTH2F, {diffAxis, {100, -20, 20}})->GetXaxis()->SetTitle("t^{MC}_{ev}-t_{TOF}_{ev} (ps)");

// pion
histos.add("MC/particle/pdg211/all/particleDiff", "", HistType::kTH2F, {pAxis, diffAxis});
histos.add("MC/particle/pdg211/all/delta", "", HistType::kTH2F, {pAxis, diffAxis});
histos.addClone("MC/particle/pdg211/all/particleDiff", "MC/particle/pdg211/prm/particleDiff");
histos.add<TH2>("MC/particle/pdg211/all/particleDiff", "particleDiff", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t^{MC}_{ev}-t^{part}_{MC} (ps)");
histos.add<TH2>("MC/particle/pdg211/all/delta", "delta", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)");
histos.add<TH2>("MC/particle/pdg211/all/deltaTRD", "deltaTRD", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)");
histos.add<TH2>("MC/particle/pdg211/all/deltaNoTRD", "deltaNoTRD", HistType::kTH2F, {ptAxis, diffAxis})->GetYaxis()->SetTitle("t_{TOF}-t^{MC}_{ev}-t_{exp} (ps)");
histos.addClone("MC/particle/pdg211/all/", "MC/particle/pdg211/prm/");

histos.addClone("MC/particle/pdg211/", "MC/particle/pdgNeg211/");

// kaon
Expand Down Expand Up @@ -446,15 +449,79 @@ struct tofPidCollisionTimeQa {
for (auto& trk : tracks) {
if (!trk.has_collision()) { // Track was not assigned to a collision
continue;
} else if (trk.collisionId() == lastCollisionId) { // Event was already processed
continue;
}
lastCollisionId = trk.collisionId(); /// Cache last collision ID
const auto& collision = trk.collision_as<EvTimeCollisionsMC>();
if (!collision.has_mcCollision()) {
continue;
}
const auto& collisionMC = collision.mcCollision_as<aod::McCollisions>();
const int64_t bcMCtime = static_cast<int64_t>((collisionMC.t() + 2.f) / o2::constants::lhc::LHCBunchSpacingNS);
const float eventtimeMC = (collisionMC.t() - bcMCtime * o2::constants::lhc::LHCBunchSpacingNS) * 1000.f;

if (trk.has_mcParticle()) {
const auto& particle = trk.mcParticle();
const auto& mcCollTimeMinusFormationTime = particle.vt() - collisionMC.t();
const auto& mcTOFvalue = trk.tofSignal() - eventtimeMC - trk.tofExpTime(2);
LOG(debug) << "Track " << particle.vt() << " vs " << eventtimeMC;
switch (particle.pdgCode()) {
case 211:
histos.fill(HIST("MC/particle/pdg211/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
histos.fill(HIST("MC/particle/pdg211/all/delta"), particle.pt(), mcTOFvalue);
if (trk.hasTRD()) {
histos.fill(HIST("MC/particle/pdg211/all/deltaTRD"), particle.pt(), mcTOFvalue);
} else {
histos.fill(HIST("MC/particle/pdg211/all/deltaNoTRD"), particle.pt(), mcTOFvalue);
}
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg211/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
case -211:
histos.fill(HIST("MC/particle/pdgNeg211/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
histos.fill(HIST("MC/particle/pdgNeg211/all/delta"), particle.pt(), mcTOFvalue);
histos.fill(HIST("MC/particle/pdgNeg211/all/delta"), particle.pt(), mcTOFvalue);
if (trk.hasTRD()) {
histos.fill(HIST("MC/particle/pdgNeg211/all/deltaTRD"), particle.pt(), mcTOFvalue);
} else {
histos.fill(HIST("MC/particle/pdgNeg211/all/deltaNoTRD"), particle.pt(), mcTOFvalue);
}
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg211/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
case 321:
histos.fill(HIST("MC/particle/pdg321/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg321/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
case -321:
histos.fill(HIST("MC/particle/pdgNeg321/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg321/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
case 2212:
histos.fill(HIST("MC/particle/pdg2212/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg2212/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
case -2212:
histos.fill(HIST("MC/particle/pdgNeg2212/all/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg2212/prm/particleDiff"), particle.pt(), mcCollTimeMinusFormationTime);
}
break;
default:
break;
}
}

if (trk.collisionId() == lastCollisionId) { // Event was already processed
continue;
}
lastCollisionId = trk.collisionId(); /// Cache last collision ID

float t0AC[2] = {0.f, 0.f};
// const auto& ft0 = collision.foundFT0();
Expand Down Expand Up @@ -515,8 +582,6 @@ struct tofPidCollisionTimeQa {
// timeInBCNS + bc2ns();
// bc* o2::constants::lhc::LHCBunchSpacingNS + orbit* o2::constants::lhc::LHCOrbitNS;
// int64_t(mcBC.globalBC() * o2::constants::lhc::LHCBunchSpacingNS * 1e-3))
const int64_t bcMCtime = static_cast<int64_t>((collisionMC.t() + 2.f) / o2::constants::lhc::LHCBunchSpacingNS);
const float eventtimeMC = (collisionMC.t() - bcMCtime * o2::constants::lhc::LHCBunchSpacingNS) * 1000.f;

histos.fill(HIST("MC/CollisionTime/eventtimeMC"), eventtimeMC);
histos.fill(HIST("MC/CollisionTime/All"), trk.tofEvTime());
Expand All @@ -532,55 +597,6 @@ struct tofPidCollisionTimeQa {
histos.fill(HIST("MC/diffvsZ/All"), eventtimeMC - trk.tofEvTime(), collisionMC.posZ());
histos.fill(HIST("MC/diffvsZ/FT0"), eventtimeMC - t0AC[0], collisionMC.posZ());
histos.fill(HIST("MC/diffvsZ/TOF"), eventtimeMC - trk.evTimeTOF(), collisionMC.posZ());

if (!trk.has_mcParticle()) {
continue;
}
const auto& particle = trk.mcParticle();
const auto& tMimusFormationTime = collisionMC.t() - particle.vt();
// const auto & mcTOFvalue = eventtimeMC - trk.tofSignal() - ;
LOG(debug) << "Track " << particle.vt() << " vs " << eventtimeMC;
switch (particle.pdgCode()) {
case 211:
histos.fill(HIST("MC/particle/pdg211/all/particleDiff"), particle.pt(), tMimusFormationTime);
// histos.fill(HIST("MC/particle/pdg211/all/delta"), particle.pt(), mcTOFvalue);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg211/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
case -211:
histos.fill(HIST("MC/particle/pdgNeg211/all/particleDiff"), particle.pt(), tMimusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg211/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
case 321:
histos.fill(HIST("MC/particle/pdg321/all/particleDiff"), particle.pt(), tMimusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg321/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
case -321:
histos.fill(HIST("MC/particle/pdgNeg321/all/particleDiff"), particle.pt(), tMimusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg321/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
case 2212:
histos.fill(HIST("MC/particle/pdg2212/all/particleDiff"), particle.pt(), tMimusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdg2212/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
case -2212:
histos.fill(HIST("MC/particle/pdgNeg2212/all/particleDiff"), particle.pt(), tMimusFormationTime);
if (particle.isPhysicalPrimary()) {
histos.fill(HIST("MC/particle/pdgNeg2212/prm/particleDiff"), particle.pt(), tMimusFormationTime);
}
break;
default:
break;
}
}
}
PROCESS_SWITCH(tofPidCollisionTimeQa, processMC, "Process MC", false);
Expand Down

0 comments on commit 43febf0

Please sign in to comment.