 |
Belle II Software
release-05-01-25
|
11 #include <reconstruction/modules/HitLevelInfoWriter/HitLevelInfoWriter.h>
12 #include <reconstruction/dataobjects/DedxConstants.h>
13 #include <mdst/dataobjects/PIDLikelihood.h>
23 setDescription(
"Extract dE/dx information for calibration development.");
25 addParam(
"outputBaseName", m_strOutputBaseName,
"Suffix for output file name", std::string(
"HLInfo.root"));
26 addParam(
"particleLists", m_strParticleList,
"Vector of ParticleLists to save", std::vector<std::string>());
27 addParam(
"enableHitLevel", enableHitLevel,
"True or False for Hit level variables",
false);
28 addParam(
"enableExtraVar", enableExtraVar,
"True or False for extra track/hit level variables",
false);
29 addParam(
"nodeadwire", nodeadwire,
"True or False for deadwire hit variables",
true);
38 B2INFO(
"Creating a ROOT file for the hit level information...");
41 m_dedxTracks.isRequired();
42 m_tracks.isRequired();
43 m_trackFitResults.isRequired();
44 m_eclClusters.isOptional();
45 m_klmClusters.isOptional();
48 std::map<std::string, std::string> pdgMap = {{
"pi+",
"211"}, {
"K+",
"321"}, {
"mu+",
"13"}, {
"e+",
"11"}, {
"p+",
"2212"}, {
"deuteron",
"1000010020"}};
51 if (m_strParticleList.size() == 0) bookOutput(m_strOutputBaseName);
54 for (
unsigned int i = 0; i < m_strParticleList.size(); i++) {
56 std::string pdg = pdgMap[m_strParticleList[i].substr(0, m_strParticleList[i].find(
":"))];
57 std::string filename = std::string(m_strOutputBaseName +
"_PID" + pdg +
".root");
66 int nParticleList = m_strParticleList.size();
72 if (nParticleList == 0) {
73 for (
int idedx = 0; idedx < m_dedxTracks.getEntries(); idedx++) {
77 B2WARNING(
"No dedx related track...");
83 B2WARNING(
"No related track...");
89 B2WARNING(
"No related fit for this track...");
93 if (dedxTrack->
size() == 0 || dedxTrack->
size() > 200)
continue;
98 m_expID = evtMetaData->getExperiment();
99 m_runID = evtMetaData->getRun();
100 m_eventID = evtMetaData->getEvent();
111 if (klmCluster) m_klmLayers = klmCluster->
getLayers();
115 fillTrack(fitResult);
131 for (
int iList = 0; iList < nParticleList; iList++) {
134 if (!particlelist or particlelist->getListSize(
true) == 0) {
141 for (
unsigned int iPart = 0; iPart < particlelist->getListSize(
true); iPart++) {
142 Particle* part = particlelist->getParticle(iPart,
true);
144 B2WARNING(
"No particles...");
149 B2WARNING(
"No related PID likelihood...");
154 B2WARNING(
"No related track...");
159 B2WARNING(
"No related CDCDedxTrack...");
162 std::string ptype = m_strParticleList[iList].substr(0, m_strParticleList[iList].find(
":"));
164 if (ptype !=
"pi+") {
165 if (ptype ==
"K+") fitResult = track->getTrackFitResultWithClosestMass(
Const::kaon);
166 else if (ptype ==
"p+") fitResult = track->getTrackFitResultWithClosestMass(
Const::proton);
167 else if (ptype ==
"deuteron") fitResult = track->getTrackFitResultWithClosestMass(
Const::deuteron);
168 else if (ptype ==
"mu+") fitResult = track->getTrackFitResultWithClosestMass(
Const::muon);
169 else if (ptype ==
"e+") fitResult = track->getTrackFitResultWithClosestMass(
Const::electron);
172 B2WARNING(
"No related fit for this track...");
176 if (dedxTrack->
size() == 0 || dedxTrack->
size() > 200)
continue;
178 if (dedxTrack->
getCosTheta() < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
179 if (dedxTrack->
getCosTheta() > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
183 m_expID = evtMetaData->getExperiment();
184 m_runID = evtMetaData->getRun();
185 m_eventID = evtMetaData->getEvent();
194 if (klmCluster) m_klmLayers = klmCluster->
getLayers();
198 fillTrack(fitResult);
204 m_tree[iList]->Fill();
212 for (
unsigned int i = 0; i < m_file.size(); i++) {
213 B2INFO(
"Done writing out the hit level information...\t" << m_tree[i]->GetEntries() <<
" tracks");
226 m_p = trackMom.Mag();
227 m_pt = trackMom.Pt();
228 m_phi = trackMom.Phi();
230 m_theta = trackMom.Theta() * 180. / TMath::Pi();
231 if (m_theta > 17. && m_theta < 150.)m_inCDC = 1;
240 m_vx0 = trackPos.x();
241 m_vy0 = trackPos.y();
242 m_vz0 = trackPos.z();
244 m_d0 = fitResult->
getD0();
245 m_z0 = fitResult->
getZ0();
255 m_dr = frame.getVertex(helix.getPerigee()).Perp();
256 m_dphi = frame.getVertex(helix.getPerigee()).Phi();
257 m_dz = frame.getVertex(helix.getPerigee()).Z();
266 m_trackID = dedxTrack->
trackID();
270 m_PDG = dedxTrack->
getPDG();
277 h_nhits = dedxTrack->
size();
282 m_trunc = dedxTrack->
getDedx();
287 m_scale = m_DBScaleFactor->getScaleFactor();
288 m_runGain = m_DBRunGain->getRunGain();
289 m_cosCor = m_DBCosineCor->getMean(m_cosTheta);
291 if (m_cosTheta <= -0.850 || m_cosTheta >= 0.950) {
292 m_cosEdgeCor = m_DBCosEdgeCor->getMean(m_cosTheta);
298 m_chie = dedxTrack->
getChi(0);
299 m_chimu = dedxTrack->
getChi(1);
300 m_chipi = dedxTrack->
getChi(2);
301 m_chik = dedxTrack->
getChi(3);
302 m_chip = dedxTrack->
getChi(4);
303 m_chid = dedxTrack->
getChi(5);
320 double lout = 0, lin = 0, increment = 0;
322 for (
int il = 0; il < l_nhits; ++il) {
325 l_layer[il] = dedxTrack->
getLayer(il);
329 if (l_layer[il] > lastlayer) lout++;
330 else if (l_layer[il] < lastlayer) lin++;
333 lastlayer = l_layer[il];
336 m_ioasym = (lout - lin) / increment;
339 if (enableHitLevel) {
340 for (
int ihit = 0; ihit < h_nhits; ++ihit) {
342 if (nodeadwire && m_DBWireGains->getWireGain(h_wire[ihit]) == 0)
continue;
344 h_wire[ihit] = dedxTrack->
getWire(ihit);
346 h_path[ihit] = dedxTrack->
getPath(ihit);
347 h_dedx[ihit] = dedxTrack->
getDedx(ihit);
350 h_doca[ihit] = dedxTrack->
getDoca(ihit);
353 h_enta[ihit] = dedxTrack->
getEnta(ihit);
354 h_entaRS[ihit] = dedxTrack->
getEntaRS(ihit);
355 h_driftT[ihit] = dedxTrack->
getDriftT(ihit);
356 h_driftD[ihit] = dedxTrack->
getDriftD(ihit);
359 if (enableExtraVar) {
367 h_wireGain[ihit] = m_DBWireGains->getWireGain(h_wire[ihit]);
368 h_twodCor[ihit] = m_DB2DCell->getMean(h_layer[ihit], h_ndocaRS[ihit], h_entaRS[ihit]);
369 h_onedCor[ihit] = m_DB1DCell->getMean(h_layer[ihit], h_entaRS[ihit]);
377 for (
int il = 0; il < 200; ++il) {
378 l_nhitscombined[il] = 0;
379 l_wirelongesthit[il] = 0;
385 if (enableHitLevel) {
386 for (
int ihit = 0; ihit < 200; ++ihit) {
401 h_facnladc[ihit] = 0;
402 h_wireGain[ihit] = 0;
405 h_WeightPionHypo[ihit] = 0;
406 h_WeightKaonHypo[ihit] = 0;
407 h_WeightProtonHypo[ihit] = 0;
408 h_foundByTrackFinder[ihit] = 0;
417 m_file.push_back(
new TFile(filename.c_str(),
"RECREATE"));
418 m_tree.push_back(
new TTree(
"track",
"dE/dx information"));
420 int i = m_tree.size() - 1;
421 m_tree[i]->SetDirectory(0);
424 m_tree[i]->Branch(
"exp", &m_expID,
"exp/I");
425 m_tree[i]->Branch(
"run", &m_runID,
"run/I");
426 m_tree[i]->Branch(
"event", &m_eventID,
"event/I");
429 m_tree[i]->Branch(
"d0", &m_d0,
"d0/D");
430 m_tree[i]->Branch(
"z0", &m_z0,
"z0/D");
431 m_tree[i]->Branch(
"dz", &m_dz,
"dz/D");
432 m_tree[i]->Branch(
"dr", &m_dr,
"dr/D");
433 m_tree[i]->Branch(
"dphi", &m_dphi,
"dphi/D");
434 m_tree[i]->Branch(
"vx0", &m_vx0,
"vx0/D");
435 m_tree[i]->Branch(
"vy0", &m_vy0,
"vy0/D");
436 m_tree[i]->Branch(
"vz0", &m_vz0,
"vz0/D");
437 m_tree[i]->Branch(
"tanlambda", &m_tanlambda,
"tanlambda/D");
438 m_tree[i]->Branch(
"phi0", &m_phi0,
"phi0/D");
439 m_tree[i]->Branch(
"chi2", &m_chi2,
"chi2/D");
442 m_tree[i]->Branch(
"nCDChits", &m_nCDChits,
"nCDChits/D");
443 m_tree[i]->Branch(
"inCDC", &m_inCDC,
"inCDC/I");
444 m_tree[i]->Branch(
"track", &m_trackID,
"track/I");
445 m_tree[i]->Branch(
"length", &m_length,
"length/D");
446 m_tree[i]->Branch(
"charge", &m_charge,
"charge/I");
447 m_tree[i]->Branch(
"costh", &m_cosTheta,
"costh/D");
448 m_tree[i]->Branch(
"pF", &m_pCDC,
"pF/D");
449 m_tree[i]->Branch(
"p", &m_p,
"p/D");
450 m_tree[i]->Branch(
"pt", &m_pt,
"pt/D");
451 m_tree[i]->Branch(
"ioasym", &m_ioasym,
"ioasym/D");
452 m_tree[i]->Branch(
"phi", &m_phi,
"phi/D");
453 m_tree[i]->Branch(
"pdg", &m_PDG,
"pdg/D");
455 m_tree[i]->Branch(
"mean", &m_mean,
"mean/D");
456 m_tree[i]->Branch(
"dedx", &m_trunc,
"dedx/D");
457 m_tree[i]->Branch(
"dedxnosat", &m_truncNoSat,
"dedxnosat/D");
458 m_tree[i]->Branch(
"dedxerr", &m_error,
"dedxerr/D");
462 m_tree[i]->Branch(
"eop", &m_eop,
"eop/D");
463 m_tree[i]->Branch(
"e", &m_e,
"e/D");
464 m_tree[i]->Branch(
"e1_9", &m_e1_9,
"e1_9/D");
465 m_tree[i]->Branch(
"e9_21", &m_e9_21,
"e9_21/D");
466 m_tree[i]->Branch(
"klmLayers", &m_klmLayers,
"klmLayers/I");
469 m_tree[i]->Branch(
"scale", &m_scale,
"scale/D");
470 m_tree[i]->Branch(
"coscor", &m_cosCor,
"coscor/D");
471 m_tree[i]->Branch(
"cosedgecor", &m_cosEdgeCor,
"cosedgecor/D");
472 m_tree[i]->Branch(
"rungain", &m_runGain,
"rungain/D");
475 m_tree[i]->Branch(
"chiE", &m_chie,
"chiE/D");
476 m_tree[i]->Branch(
"chiMu", &m_chimu,
"chiMu/D");
477 m_tree[i]->Branch(
"chiPi", &m_chipi,
"chiPi/D");
478 m_tree[i]->Branch(
"chiK", &m_chik,
"chiK/D");
479 m_tree[i]->Branch(
"chiP", &m_chip,
"chiP/D");
480 m_tree[i]->Branch(
"chiD", &m_chid,
"chiD/D");
482 m_tree[i]->Branch(
"pmeanE", &m_pmeane,
"pmeanE/D");
483 m_tree[i]->Branch(
"pmeanMu", &m_pmeanmu,
"pmeanMu/D");
484 m_tree[i]->Branch(
"pmeanPi", &m_pmeanpi,
"pmeanPi/D");
485 m_tree[i]->Branch(
"pmeanK", &m_pmeank,
"pmeanK/D");
486 m_tree[i]->Branch(
"pmeanP", &m_pmeanp,
"pmeanP/D");
487 m_tree[i]->Branch(
"pmeanD", &m_pmeand,
"pmeanD/D");
489 m_tree[i]->Branch(
"presE", &m_prese,
"presE/D");
490 m_tree[i]->Branch(
"presMu", &m_presmu,
"presMu/D");
491 m_tree[i]->Branch(
"presPi", &m_prespi,
"presPi/D");
492 m_tree[i]->Branch(
"presK", &m_presk,
"presK/D");
493 m_tree[i]->Branch(
"presP", &m_presp,
"presP/D");
494 m_tree[i]->Branch(
"presD", &m_presd,
"presD/D");
497 m_tree[i]->Branch(
"lNHits", &l_nhits,
"lNHits/I");
498 m_tree[i]->Branch(
"lNHitsUsed", &l_nhitsused,
"lNHitsUsed/I");
499 m_tree[i]->Branch(
"lNHitsCombined", l_nhitscombined,
"lNHitsCombined[lNHits]/I");
500 m_tree[i]->Branch(
"lWireLongestHit", l_wirelongesthit,
"lWireLongestHit[lNHits]/I");
501 m_tree[i]->Branch(
"lLayer", l_layer,
"lLayer[lNHits]/I");
502 m_tree[i]->Branch(
"lPath", l_path,
"lPath[lNHits]/D");
503 m_tree[i]->Branch(
"lDedx", l_dedx,
"lDedx[lNHits]/D");
506 if (enableHitLevel) {
507 m_tree[i]->Branch(
"hNHits", &h_nhits,
"hNHits/I");
508 m_tree[i]->Branch(
"hLWire", h_lwire,
"hLWire[hNHits]/I");
509 m_tree[i]->Branch(
"hWire", h_wire,
"hWire[hNHits]/I");
510 m_tree[i]->Branch(
"hLayer", h_layer,
"hLayer[hNHits]/I");
511 m_tree[i]->Branch(
"hPath", h_path,
"hPath[hNHits]/D");
512 m_tree[i]->Branch(
"hDedx", h_dedx,
"hDedx[hNHits]/D");
513 m_tree[i]->Branch(
"hADCRaw", h_adcraw,
"hADCRaw[hNHits]/D");
514 m_tree[i]->Branch(
"hADCCorr", h_adccorr,
"hADCCorr[hNHits]/D");
515 m_tree[i]->Branch(
"hDoca", h_doca,
"hDoca[hNHits]/D");
516 m_tree[i]->Branch(
"hNDoca", h_ndoca,
"hNDoca[hNHits]/D");
517 m_tree[i]->Branch(
"hNDocaRS", h_ndocaRS,
"hNDocaRS[hNHits]/D");
518 m_tree[i]->Branch(
"hEnta", h_enta,
"hEnta[hNHits]/D");
519 m_tree[i]->Branch(
"hEntaRS", h_entaRS,
"hEntaRS[hNHits]/D");
520 m_tree[i]->Branch(
"hDriftT", h_driftT,
"hDriftT[hNHits]/D");
521 m_tree[i]->Branch(
"hDriftD", h_driftD,
"hDriftD[hNHits]/D");
522 m_tree[i]->Branch(
"hFacnlADC", h_facnladc,
"hFacnlADC[hNHits]/D");
523 m_tree[i]->Branch(
"hWireGain", h_wireGain,
"hWireGain[hNHits]/D");
524 m_tree[i]->Branch(
"hTwodcor", h_twodCor,
"hTwodcor[hNHits]/D");
525 m_tree[i]->Branch(
"hOnedcor", h_onedCor,
"hOnedcor[hNHits]/D");
527 if (enableExtraVar) {
528 m_tree[i]->Branch(
"hWeightPionHypo", h_WeightPionHypo,
"hWeightPionHypo[hNHits]/D");
529 m_tree[i]->Branch(
"hWeightKaonHypo", h_WeightKaonHypo,
"hWeightKaonHypo[hNHits]/D");
530 m_tree[i]->Branch(
"hWeightProtonHypo", h_WeightProtonHypo,
"hWeightProtonHypo[hNHits]/D");
531 m_tree[i]->Branch(
"hFoundByTrackFinder", h_foundByTrackFinder,
"hFoundByTrackFinder[hNHits]/I");
double getPDG() const
Get the identity of the particle.
double getDedxNoSat() const
Get dE/dx truncated mean without the saturation correction for this track.
int getHitLayer(int i) const
Return the (global) layer number for a hit.
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
double getE9oE21() const
Return E9/E21 (shower shape variable).
virtual void event() override
This method is called for each event.
double getDedx() const
Get dE/dx truncated mean for this track.
double getEntaRS(int i) const
Return rescaled enta value for cell height=width assumption.
int getLayers() const
Get number of layers with hits.
double getChi(int i) const
Return the PID (chi) value.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
int getWire(int i) const
Return the sensor ID for this hit: wire number for CDC (0-14336)
static const ChargedStable electron
electron particle
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Extracts dE/dx information for calibration testing.
int getLayer(int i) const
Return the (global) layer number for a layer hit.
void fillDedx(CDCDedxTrack *dedxTrack)
Fill the TTree with the information from a CDCDedxTrack object.
double getPValue() const
Getter for Chi2 Probability of the track fit.
double getMomentum() const
Return the track momentum valid in the CDC.
@ c_nPhotons
CR is split into n photons (N1)
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
void fillTrack(const TrackFitResult *fitResult)
Fill the TTree with the information from the track fit.
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
double getTanLambda() const
Getter for tanLambda.
int getADCCount(int i) const
Return the adcCount for this hit.
double passiveMoveBy(const TVector3 &by)
Moves origin of the coordinate system (passive transformation) by the given vector.
double getLength() const
Return the total path length for this track.
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
double getEnta(int i) const
Return the entrance angle in the CDC cell for this hit.
int size() const
Return the number of hits for this track.
Values of the result of a track fit with a given particle hypothesis.
double getLayerDedx(int i) const
Return the total dE/dx for this layer.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
int getCharge() const
Return the charge for this track.
void bookOutput(std::string filename)
Create the output TFiles and TTrees.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
double getZ0() const
Getter for z0.
Class for accessing objects in the database.
static const ChargedStable kaon
charged kaon particle
double getDriftD(int i) const
Return the drift distance for this hit.
int getFoundByTrackFinder(int i) const
Return the TrackFinder which added the given hit to track.
double getEnergy(const EHypothesisBit &hypothesis) const
Return Energy (GeV).
static const ChargedStable pion
charged pion particle
double getPath(int i) const
Return the path length through the cell for this hit.
double getLayerPath(int i) const
Return the distance travelled in this layer.
Abstract base class for different kinds of events.
int getWireLongestHit(int i) const
Return the wire number of the longest hit per layer.
Type-safe access to single objects in the data store.
static const ChargedStable deuteron
deuteron particle
double getDedxMean() const
Get the dE/dx mean for this track.
int getWireInLayer(int i) const
Return the sensor ID for this hit: wire number in the layer.
double getDoca(int i) const
Return the distance of closest approach to the sense wire for this hit.
int getNHitsCombined(int i) const
Return the number of hits combined per layer.
double getPhi0() const
Getter for phi0.
int getDriftT(int i) const
Return the drift time for this hit.
double getNLayerHitsUsed() const
Return the number of hits used to determine the truncated mean.
double getDedxError() const
Get the error on the dE/dx truncated mean for this track.
double getCellHalfWidth(int i) const
Return the half-width of the CDC cell.
int getADCBaseCount(int i) const
Return the base adcCount (no non-linearity) for this hit.
virtual ~HitLevelInfoWriterModule()
Destructor.
Class to store reconstructed particles.
double getPreso(int i) const
Return the PID (predicted reso) value.
double getWeightPionHypo(int i) const
Return the max weights from KalmanFitterInfo using pion hypothesis.
double getWeightKaonHypo(int i) const
Return the max weights from KalmanFitterInfo using kaon hypothesis.
UncertainHelix getUncertainHelix() const
Conversion to framework Uncertain Helix (i.e., with covariance).
double getE1oE9() const
Return E1/E9 (shower shape variable).
static const ReferenceFrame & GetCurrent()
Get current rest frame.
static const ChargedStable proton
proton particle
double getPmean(int i) const
Return the PID (predicted mean) value.
double trackID() const
Return the track ID.
double getCosTheta() const
Return cos(theta) for this track.
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
static const ChargedStable muon
muon particle
Class that bundles various TrackFitResults.
Accessor to arrays stored in the data store.
Debug output for CDCDedxPID module.
int getNLayerHits() const
Return the number of layer hits for this track.
double getDocaRS(int i) const
Return rescaled doca value for cell height=width assumption.
virtual void initialize() override
Initialize the module.
double getWeightProtonHypo(int i) const
Return the max weights from KalmanFitterInfo using proton hypothesis.
double getNonLADCCorrection(int i) const
Return the factor introduce for adcCount (non-linearity) correction.
short getChargeSign() const
Return track charge (1 or -1).
void clearEntries()
Clear the arrays before filling an event.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
virtual void terminate() override
End of the event processing.
double getD0() const
Getter for d0.