4 #include <qautils/QAHistManagerDef.h>
58 return phi - 2. * M_PI;
59 else if (phi <= -M_PI)
60 return phi + 2. * M_PI;
67 int count_clusters(
const std::vector<TrkrDefs::cluskey>& keys)
69 return std::count_if(keys.begin(), keys.end(),
94 h =
new TH2F(TString(
get_histo_prefix()) +
"betadz",
";tan#beta; #Deltaz [cm]", 100, -0.5, 0.5, 100, -0.5, 0.5);
98 h =
new TH2F(TString(
get_histo_prefix()) +
"alphardphi",
";tan#alpha; r#Delta#phi [cm]", 100, -0.5, 0.5, 100, -0.5, 0.5);
101 h =
new TH2F(TString(
get_histo_prefix()) +
"rphiResid",
";r [cm]; #Deltar#phi [cm]", 60, 20, 80, 500, -2, 2);
104 h =
new TH2F(TString(
get_histo_prefix()) +
"zResid",
";z [cm]; #Deltaz [cm]", 200, -100, 100, 1000, -2, 2);
107 h =
new TH2F(TString(
get_histo_prefix()) +
"etaResid",
";#eta;#Delta#eta", 20, -1, 1, 500, -0.2, 0.2);
110 h =
new TH2F(TString(
get_histo_prefix()) +
"etaResidLayer",
";r [cm]; #Delta#eta", 60, 20, 80, 500, -0.2, 0.2);
113 h =
new TH2F(TString(
get_histo_prefix()) +
"zResidLayer",
";r [cm]; #Deltaz [cm]", 60, 20, 80, 1000, -2, 2);
116 h =
new TH2F(TString(
get_histo_prefix()) +
"deltarphi_layer",
";layer; r.#Delta#phi_{track-cluster} (cm)", 57, 0, 57, 500, -2, 2);
119 h =
new TH2F(TString(
get_histo_prefix()) +
"deltaz_layer",
";layer; #Deltaz_{track-cluster} (cm)", 57, 0, 57, 100, -2, 2);
122 h =
new TH2F(TString(
get_histo_prefix()) +
"statez_pulls",
"layer; #Deltaz_{track-cluster}/#sigma_{z}^{state}", 57, 0, 57, 100, -5, 5);
125 h =
new TH2F(TString(
get_histo_prefix()) +
"staterphi_pulls",
"layer; #Deltar#phi_{track-cluster}/#sigma_{rphi}^{state}", 57, 0, 57, 100, -5, 5);
128 h =
new TH2F(TString(
get_histo_prefix()) +
"clusz_pulls",
"layer; #Deltaz_{track-cluster}/#sigma_{z}^{clus}", 57, 0, 57, 100, -5, 5);
131 h =
new TH2F(TString(
get_histo_prefix()) +
"clusrphi_pulls",
"layer; #Deltar#phi_{track-cluster}/#sigma_{r#phi}^{clus}", 57, 0, 57, 100, -5, 5);
136 t =
new TTree(TString(
get_histo_prefix()) +
"residTree",
"tpc residual info");
137 t->Branch(
"tanAlpha", &
m_tanAlpha,
"tanAlpha/D");
138 t->Branch(
"tanBeta", &
m_tanBeta,
"tanBeta/D");
139 t->Branch(
"drphi", &
m_drphi,
"drphi/D");
140 t->Branch(
"dz", &
m_dz,
"dz/D");
141 t->Branch(
"clusR", &
m_clusR,
"clusR/D");
142 t->Branch(
"clusPhi", &
m_clusPhi,
"clusPhi/D");
143 t->Branch(
"clusZ", &
m_clusZ,
"clusZ/D");
144 t->Branch(
"statePhi", &
m_statePhi,
"statePhi/D");
145 t->Branch(
"stateZ", &
m_stateZ,
"stateZ/D");
146 t->Branch(
"stateR", &
m_stateR,
"stateR/D");
148 t->Branch(
"stateZErr", &
m_stateZErr,
"stateZErr/D");
150 t->Branch(
"clusZErr", &
m_clusZErr,
"clusZErr/D");
151 t->Branch(
"cluskey", &
m_cluskey,
"cluskey/l");
152 t->Branch(
"event", &
m_event,
"event/I");
162 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxSiliconMMTrackMap");
163 m_clusterContainer = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
165 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
167 if (not
m_trackMap or not m_clusterContainer or not m_tGeometry)
169 std::cout <<
PHWHERE <<
"Necessary distortion container not on node tree. Bailing."
206 assert(h_deltarphi_layer);
215 assert(h_staterphi_pulls);
232 auto tpcSeed = track->get_tpc_seed();
233 auto siliconSeed = track->get_silicon_seed();
236 if (not tpcSeed or not siliconSeed)
241 for (
auto iter = track->begin_states(); iter != track->end_states(); ++iter)
243 auto state = iter->second;
247 if ((
state->get_name()).find(
"UNKNOWN") != std::string::npos)
258 const float clusR =
get_r(clusGlobPosition(0), clusGlobPosition(1));
259 const float clusPhi = std::atan2(clusGlobPosition(1), clusGlobPosition(0));
260 const float clusZ = clusGlobPosition(2);
263 const float clusRPhiErr = cluster->getRPhiError();
264 const float clusZErr = cluster->getZError();
273 const float stateRPhiErr =
state->get_rphi_error();
274 const float stateZErr =
state->get_z_error();
276 const float stateR =
get_r(stateGlobPosition(0), stateGlobPosition(1));
278 const auto dr = clusR - stateR;
279 const auto trackDrDt = (stateGlobPosition(0) * stateGlobMom(0) + stateGlobPosition(1) * stateGlobMom(1)) / stateR;
280 const auto trackDxDr = stateGlobMom(0) / trackDrDt;
281 const auto trackDyDr = stateGlobMom(1) / trackDrDt;
282 const auto trackDzDr = stateGlobMom(2) / trackDrDt;
284 const auto trackX = stateGlobPosition(0) + dr * trackDxDr;
285 const auto trackY = stateGlobPosition(1) + dr * trackDyDr;
286 const auto trackZ = stateGlobPosition(2) + dr * trackDzDr;
287 const float statePhi = std::atan2(trackY, trackX);
288 const float stateZ = trackZ;
291 const float drphi = clusR *
deltaPhi(clusPhi - statePhi);
292 const float dz = clusZ - stateZ;
294 const auto trackPPhi = -stateGlobMom(0) * std::sin(statePhi) + stateGlobMom(1) * std::cos(statePhi);
295 const auto trackPR = stateGlobMom(0) * std::cos(statePhi) + stateGlobMom(1) * std::sin(statePhi);
296 const auto trackPZ = stateGlobMom(2);
298 const auto trackAlpha = -trackPPhi / trackPR;
299 const auto trackBeta = -trackPZ / trackPR;
300 const auto trackEta = std::atanh(stateGlobMom(2) / stateGlobMom.norm());
301 const auto clusEta = std::atanh(clusZ / clusGlobPosition.norm());
303 h_alpha->Fill(trackAlpha, drphi);
304 h_beta->Fill(trackBeta, dz);
305 h_rphiResid->Fill(clusR, drphi);
306 h_zResid->Fill(stateZ, dz);
307 h_etaResid->Fill(trackEta, clusEta - trackEta);
308 h_zResidLayer->Fill(clusR, dz);
309 h_etaResidLayer->Fill(clusR, clusEta - trackEta);
312 h_deltarphi_layer->Fill(
layer, drphi);
313 h_deltaz_layer->Fill(
layer, dz);
315 h_statez_pulls->Fill(
layer, dz / stateZErr);
316 h_staterphi_pulls->Fill(
layer, drphi / stateRPhiErr);
317 h_clusz_pulls->Fill(
layer, dz / clusZErr);
318 h_clusrphi_pulls->Fill(
layer, drphi / clusRPhiErr);
346 if (track->
get_pt() < 0.5)
353 if (count_clusters<TrkrDefs::mvtxId>(cluster_keys) < 2)
return false;
354 if (count_clusters<TrkrDefs::inttId>(cluster_keys) < 2)
return false;
355 if (count_clusters<TrkrDefs::micromegasId>(cluster_keys) < 2)
365 std::vector<TrkrDefs::cluskey>
out;
370 std::copy(
seed->begin_cluster_keys(),
seed->end_cluster_keys(), std::back_inserter(out));