27const std::vector<std::string>
PARTICLES = {
"pi",
"K",
"p",
"d",
"t",
"He3"};
28const std::vector<std::string>
ZONES = {
"clean",
"overlap",
"accepted"};
61 cout <<
"BmnGlobalTracking::Init started\n";
65 FairRootManager* ioman = FairRootManager::Instance();
67 Fatal(
"Init",
"FairRootManager is not instantiated");
83 printf(
"BmnGlobalTracking::Init(): branch with inner tracks was not found! Task will be deactivated \n");
89 TString workdir = getenv(
"VMCWORKDIR");
96 cout <<
"BmnGlobalTracking::Init finished\n";
112 cout <<
"\n======================== Global tracking exec started =====================\n" << endl;
143 Int_t pdg = (globTr.
GetP() > 0) ? 211 : -211;
162 fKalman->Update(&parF, &virtualVertexHit, chi);
179 cout <<
"\n======================== Global tracking exec finished ====================\n" << endl;
184 Int_t tofID = (tof400) ? 1 : 2;
185 TString tofName = (tof400) ?
"TOF-400" :
"TOF-700";
187 cout <<
"Matching of " << tofName <<
" started" << endl;
197 for (
auto const& distPair : distPairs) {
199 pair<Int_t, Int_t> idxes = distPair.second;
209 Int_t pdg = (track->
GetP() > 0) ? 2212 : -211;
210 fKalman->TGeoTrackPropagate(&par, hit->GetZ(), pdg,
nullptr, &len);
217 Int_t chamber = ((hit->GetDetectorID() & 0x0000FF00) >> 8) - 1;
224 Float_t xDist = xExtr_stage2 - hit->GetX();
225 Float_t yDist = yExtr_stage2 - hit->GetY();
226 bool isWithinSigma = (
Abs(xDist) < 3 * sigmaX_stage2) && (
Abs(yDist) < 3 * sigmaY_stage2);
246 std::string zone =
"accepted";
254 xDist = xExtr_stage2 + xCorr_stage3 - hit->GetX();
255 yDist = yExtr_stage2 + yCorr_stage3 - hit->GetY();
256 isWithinSigma = (
Abs(xDist) < 3 * sigmaX_stage3) && (
Abs(yDist) < 3 * sigmaY_stage3);
274 cout <<
"Matching of ScWall started " <<
fScWall << endl;
289 Int_t pdg = (tr->
GetP() > 0) ? 2212 : -211;
291 if (
fKalman->TGeoTrackPropagate(&par, z, pdg,
nullptr,
nullptr) ==
kBMNERROR)
294 for (
Int_t i = 1;
i <= nCells; ++
i) {
299 Float_t dX = par.GetX() - cell->GetX();
300 Float_t dY = par.GetY() - cell->GetY();
302 if (
Abs(dX) < xCut &&
Abs(dY) < yCut &&
Abs(dX) <
Abs(minDX) &&
Abs(dY) <
Abs(minDY)) {
321 cout <<
"Matching of Ndet started " <<
fNdet << endl;
324 auto* cells =
fNdet->GetCells();
325 if (cells->GetEntriesFast() == 0)
332 for (
int ice = 0, nce = cells->GetEntriesFast(); ice < nce; ++ice) {
333 auto* cell =
static_cast<BmnNdetCell*
>(cells->At(ice));
336 Int_t pdg = (tr->
GetP() > 0) ? 2212 : -211;
338 if (
fKalman->TGeoTrackPropagate(&par, cell->GetZ(), pdg,
nullptr,
nullptr) ==
kBMNERROR)
341 Float_t dX = par.GetX() - cell->GetX();
342 Float_t dY = par.GetY() - cell->GetY();
344 if (
Abs(dX) < 5 * cell->GetDx() &&
Abs(dY) < 5 * cell->GetDy()) {
358 multimap<Float_t, pair<Int_t, Int_t>> distancesPairs;
363 if (hit->GetZ() < minZ)
372 Int_t pdg = (tr->
GetP() > 0) ? 2212 : -211;
373 if (
fKalman->TGeoTrackPropagate(&parMinZ, minZ, pdg,
nullptr,
nullptr) ==
kBMNERROR)
378 FairTrackParam param = parMinZ;
379 if (
fKalman->TGeoTrackPropagate(¶m, hit->GetZ(), pdg,
nullptr,
nullptr) ==
kBMNERROR)
381 Float_t mom = 1.0 / param.GetQp();
382 Int_t chamber = ((hit->GetDetectorID() & 0x0000FF00) >> 8) - 1;
386 Float_t dX = param.GetX() + xMomCorr - hit->GetX();
387 Float_t dY = param.GetY() + yMomCorr - hit->GetY();
391 distancesPairs.insert(pair<
Float_t, pair<Int_t, Int_t>>(
dist, pair<Int_t, Int_t>(trIdx, hitIdx)));
395 return distancesPairs;
401 Int_t pdg = (par.GetQp() > 0) ? 2212 : -211;
402 fKalman->TGeoTrackPropagate(&par, -200, pdg,
nullptr,
nullptr);
406 fKalman->TGeoTrackPropagate(&par, 600, pdg,
nullptr,
nullptr);
415 if (!
IsNaN(momInt) &&
Abs(momInt) > 0.01 &&
Abs(momInt) < 100) {
426 printf(
"Work time of BmnGlobalTracking: %4.2f sec.\n",
fTime);
436 Int_t pdg = (par.GetQp() > 0.) ? 2212 : -211;
437 FairField* field = FairRunAna::Instance()->GetField();
438 fKalman->TGeoTrackPropagate(&par, zMin, pdg, NULL, NULL,
kTRUE);
443 fKalman->TGeoTrackPropagate(&par, z, pdg, NULL, NULL,
kTRUE);
444 integral += field->GetBy(par.GetX(), par.GetY(), par.GetZ());
452 printf(
"================================================================================\n");
453 printf(
"======= Statistics of Global tracking\n");
454 printf(
"======= Number of input inner tracks: %ld\n",
fNInnerTracks);
455 printf(
"======= Number of input inner tracks with 4+ hits extrapolated to the Vertex: %ld (%4.1f%%)\n",
457 printf(
"======= Number of tracks matched with TOF-400: %ld\n",
fNMatchedTof400);
458 printf(
"======= Number of tracks matched with TOF-700: %ld\n",
fNMatchedTof700);
459 printf(
"================================================================================\n");
475 std::cout <<
"\n=== Loading Akima corrections for " << (isTOF400 ?
"TOF400" :
"TOF700") <<
" ===" << std::endl;
476 std::cout <<
"=== File: " << filename <<
" ===" << std::endl;
482 std::cerr <<
"ERROR: Cannot open file: " << filename << std::endl;
498 while ((key = (
TKey*)next())) {
512 while ((key = (
TKey*)next())) {
526 while ((key = (
TKey*)next())) {
540 while ((key = (
TKey*)next())) {
557 while ((key = (
TKey*)next())) {
565 }
else if (name.
Contains(
"sigma")) {
577 while ((key = (
TKey*)next())) {
585 }
else if (name.
Contains(
"sigma")) {
597 while ((key = (
TKey*)next())) {
605 }
else if (name.
Contains(
"sigma")) {
617 while ((key = (
TKey*)next())) {
625 }
else if (name.
Contains(
"sigma")) {
641 for (
const auto& zone :
ZONES) {
642 TString dxDirName =
Form(
"dx_%s_%s_positive", particle.c_str(), zone.c_str());
647 while ((key = (
TKey*)next())) {
656 }
else if (name.
Contains(
"sigma")) {
664 TString dyDirName =
Form(
"dy_%s_%s_positive", particle.c_str(), zone.c_str());
669 while ((key = (
TKey*)next())) {
678 }
else if (name.
Contains(
"sigma")) {
691 std::cout <<
"Loaded " << cont.
loaded_count <<
" AkimaFunction objects for " << (isTOF400 ?
"TOF400" :
"TOF700")
710 if (stage ==
"stage1") {
712 if (region ==
"negative") {
715 return -it->second->Eval(qp);
718 return -it->second->Eval(-qp);
722 return -it->second->Eval(qp);
725 if (region ==
"negative") {
728 return -it->second->Eval(qp);
731 return -it_pos->second->Eval(-qp);
735 return -it->second->Eval(qp);
738 }
else if (stage ==
"stage2") {
740 if (region ==
"negative") {
743 return -it->second->Eval(qp);
746 return -it_pos->second->Eval(-qp);
750 return -it->second->Eval(qp);
753 if (region ==
"negative") {
756 return -it->second->Eval(qp);
759 return -it_pos->second->Eval(-qp);
763 return -it->second->Eval(qp);
766 }
else if (stage ==
"stage3") {
769 if (particle ==
"" || zone ==
"")
777 return -it->second->Eval(qp);
781 return -it->second->Eval(qp);
804 if (stage ==
"stage2") {
806 if (region ==
"negative") {
809 Float_t sigma = it->second->Eval(qp);
810 return (sigma > 0) ? sigma : 1.0;
814 Float_t sigma = it_pos->second->Eval(-qp);
815 return (sigma > 0) ? sigma : 1.0;
820 Float_t sigma = it->second->Eval(qp);
821 return (sigma > 0) ? sigma : 1.0;
825 if (region ==
"negative") {
828 Float_t sigma = it->second->Eval(qp);
829 return (sigma > 0) ? sigma : 1.0;
833 Float_t sigma = it_pos->second->Eval(-qp);
834 return (sigma > 0) ? sigma : 1.0;
839 Float_t sigma = it->second->Eval(qp);
840 return (sigma > 0) ? sigma : 1.0;
845 }
else if (stage ==
"stage3") {
847 return GetAkimaSigma(chamber, -qp, isDx,
"stage2", isTOF400,
"",
"");
848 if (particle ==
"" || zone ==
"")
856 Float_t sigma = it->second->Eval(qp);
857 return (sigma > 0) ? sigma : 1.0;
862 Float_t sigma = it->second->Eval(qp);
863 return (sigma > 0) ? sigma : 1.0;
874 return (qp < 0) ?
"negative" :
"positive";
880 if (qp < 0 && qp > -0.5)
882 if (qp > 0 && qp < 0.5)
885 if (qp < 0 && qp > -0.7)
887 if (qp > 0 && qp < 0.7)
BmnStatus
Define status code.
const std::vector< std::string > PARTICLES
const std::vector< std::string > ZONES
vector< Double_t > dist(vector< Double_t > qp, Double_t mu)
const UShort_t numChambers
void Fatal(const char *location, const char *msgfmt,...)
char * Form(const char *fmt,...)
void SetMass2(Int_t tofID, Float_t m2)
void SetResX(Int_t tofID, Float_t res)
TString GetParticleName(ParticleType type)
void SetNdetHitIndex(Int_t iNdet)
void SetDCAInVertex(Float_t chi)
void SetChi2InVertex(Float_t chi)
void SetGemTrackIndex(Int_t iGem)
Modifiers.
void SetTof2HitIndex(Int_t iTof2Hit)
void SetScWallSignal(Float_t sig)
void SetScWallCellId(Int_t iScWall)
void SetResY(Int_t tofID, Float_t res)
void SetTof1HitIndex(Int_t iTof1Hit)
BmnKalmanFilter * fKalman
vertex information
BmnGlobalTracking()
Constructor.
Float_t AdjustQP(Float_t qp, Bool_t isTOF400=false)
TString fInnerTrackBranchName
virtual ~BmnGlobalTracking()
Destructor.
Float_t GetAkimaSigma(Int_t chamber, Float_t qp, Bool_t isDx, const TString &stage, Bool_t isTOF400, const TString &particle="", const TString &zone="")
virtual void Exec(Option_t *opt)
Inherited from FairTask.
std::string GetRegionFromQP(Float_t qp)
TClonesArray * fStsTracks
virtual void OnlineWrite(const std::unique_ptr< TTree > &resultTree)
Write task resul to tree.
Float_t GetAkimaCorrection(Int_t chamber, Float_t qp, Bool_t isDx, const TString &stage, Bool_t isTOF400, const TString &particle="", const TString &zone="")
multimap< Float_t, pair< Int_t, Int_t > > FindPairsTof(TClonesArray *tracks, TClonesArray *hits, Bool_t tof400)
BmnStatus MatchingTOF(Bool_t tof400)
virtual InitStatus Init()
Inherited from FairTask.
BmnStatus UpdateMomentum(BmnGlobalTrack *tr)
void LoadAllAkimaCorrections(const TString &filename, Bool_t isTOF400)
TClonesArray * fGlobalTracks
BmnStatus MatchingScWall()
Double_t MagFieldIntegral(FairTrackParam &par, Double_t zMin, Double_t zMax, Double_t step)
virtual void Finish()
Inherited from FairTask.
void SetLength(Double_t len)
void SetUsing(Bool_t use)
Class for Bmn Ndet data container in event.
Class for Bmn ScWall module data container in event.
float GetSignal() const
Deposited Signal.
Class for Bmn ScWall data container in event.
void SetChi2(Double_t chi2)
Float_t GetLength() const
void SetParamLast(FairTrackParam &par)
FairTrackParam * GetParamFirst()
Int_t GetNHits() const
Accessors.
void SetUsing(Bool_t flag)
void SetParamFirst(FairTrackParam &par)
Modifiers.
FairTrackParam * GetParamLast()
void SetLength(Double_t length)
FairTrackParam * GetParamLast()
Int_t GetNStsHits() const
Accessors.
FairTrackParam * GetParamFirst()
T * Get(const char *namecycle)
virtual TObject * Get(const char *namecycle)
virtual TList * GetListOfKeys() const
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
void Close(Option_t *option="") override
virtual TObject * ReadObj()
const char * GetName() const override
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Bool_t InheritsFrom(const char *classname) const
void Start(Bool_t reset=kTRUE)
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
double beta(double x, double y)
Double_t Sqrt(Double_t x)
map< Int_t, AkimaFunction * > dy_stage2_sigma_pos
map< Int_t, AkimaFunction * > dx_stage2_sigma_pos
map< Stage3Key, AkimaFunction * > dy_stage3_sigma
map< Int_t, AkimaFunction * > dy_stage2_mean_pos
map< Int_t, AkimaFunction * > dy_stage1_pos
map< Int_t, AkimaFunction * > dx_stage1_pos
map< Int_t, AkimaFunction * > dy_stage2_mean_neg
map< Int_t, AkimaFunction * > dx_stage2_mean_pos
map< Stage3Key, AkimaFunction * > dx_stage3_mean
map< Stage3Key, AkimaFunction * > dx_stage3_sigma
map< Int_t, AkimaFunction * > dy_stage2_sigma_neg
map< Stage3Key, AkimaFunction * > dy_stage3_mean
map< Int_t, AkimaFunction * > dy_stage1_neg
map< Int_t, AkimaFunction * > dx_stage1_neg
map< Int_t, AkimaFunction * > dx_stage2_mean_neg
map< Int_t, AkimaFunction * > dx_stage2_sigma_neg