QString &InfoText::TrackInfo(AMSEventR *event, int itrk) { static QString str; str = ""; if (!event) return str; TrTrackR *trk = event->pTrTrack(itrk); if (!trk) return str; int id1 = TrTrackR::kChoutko; int id2 = TrTrackR::kChoutko+TrTrackR::kMultScat; if (!trk->ParExists(id1)) id1 = TrTrackR::kLinear; if (!trk->ParExists(id2)) id2 = id1; if (!trk->ParExists(id1)) return str; int fpat[8]; for (int i = 0; i < 8; i++) fpat[i] = 0; for (int i = 0; i < trk->GetNhits(); i++) { TrRecHitR *hit = trk->GetHit(i); int ily = hit->GetLayer()-1; if (hit->OnlyY()) fpat[ily] = 1; else fpat[ily] = 2; } TString spat; for (int i = 0; i < 8; i++) { if (fpat[i] == 0) spat += "_"; if (fpat[i] == 1) spat += "Y"; if (fpat[i] == 2) spat += "O"; } str += Form("Track[%d]\n", itrk); str += Form(" nHit: %d\n", trk->GetNhits()); str += Form(" nHitXY: %d\n", trk->GetNhitsXY()); str += Form(" Pattern: %d [%s]\n", trk->GetPattern(), spat.Data()); str += "\n"; str += Form(" Rigidity (noMS): %.2f\n", trk->GetRigidity(id1)); str += Form(" Rigidity (Fast): %.2f\n", trk->GetRigidity(id2)); str += Form(" errRinv (Fast): %.2f\n", trk->GetErrRinv (id2)); str += "\n"; str += Form(" Chi2Fast: %.2f\n", trk->GetChisq (id2)); str += Form(" Chi2X/Ndf: %.2f/%d\n", trk->GetChisqX (id2), trk->GetNdofX (id2)); str += Form(" Chi2Y/Ndf: %.2f/%d\n", trk->GetChisqY (id2), trk->GetNdofY (id2)); str += "\n"; str += Form(" P0: (%.2f, %.2f, %.2f)\n", trk->GetP0x(id2), trk->GetP0y(id2), trk->GetP0z(id2)); str += Form(" th/ph: (%.1f, %.1f)\n", trk->GetTheta(id2)*TMath::RadToDeg(), trk->GetPhi (id2)*TMath::RadToDeg()); for (int i = 0; i < trk->GetNhits(); i++) { TrRecHitR *hit = trk->GetHit(i); if (!hit) continue; int lay = hit->GetLayer(); str += Form("\nHit[%d]\n ", i); str += hit->Info(i); str += Form("Residual: %.4f %.4f\n", trk->GetResidualO(lay).x(), trk->GetResidualO(lay).y()); } return str; }
void trcls(const char *fname, const char *oname, const char *tkdbc) { AMSChain ch; TString sfn = fname; if (!sfn.Contains(".root")) sfn += "*.root"; if (ch.Add(sfn) <= 0) return; Int_t ntr = ch.GetNtrees(); Int_t nent = ch.GetEntries(); if (ntr <= 0 || nent <= 0) return; cout << "Ntr,Nent= " << ntr << " " << nent << endl; for (Int_t i = 0; i < ntr; i++) cout << ch.GetListOfFiles()->At(i)->GetTitle() << endl; Int_t idata[13]; Float_t fdata[28]; TFile of(oname, "recreate"); TTree *tree = new TTree("tree", "trcls"); tree->Branch("idata", idata, "run/I:event/I:ient/I:time/I:tkml[9]/I"); tree->Branch("fdata", fdata, "engc/F:enge/F:rgt/F:chrg/F:" "p0x/F:p0y/F:dzx/F:dzy/F:csqx/F:csqy/F:" "xcog[9]/F:ycog[9]/F"); if (tkdbc && tkdbc[0] && tkdbc[0] != '0') { ch.GetEvent(0); TkDBc::Head->init(3, tkdbc); } TrExtAlignDB::OverLoadFlag = 0; Int_t malg = 2; // kAlcaraz | kMultScat Int_t pat0 = 3; // Inner only Int_t nevt = 0; Int_t nrsl = 0; Int_t npsl = 0; Int_t nfil = 0; Int_t intv = 10000; signal(SIGTERM, handler); signal(SIGINT, handler); TStopwatch timer; timer.Start(); for (Int_t ient = 0; ient < nent && !SigTERM; ient++) { AMSEventR *evt = ch.GetEvent(ient); nevt++; if (nevt%intv == 0 || nevt == nent) { Double_t tm = timer.RealTime(); timer.Continue(); cout << Form("%6d %6d %6d %7d (%5.1f%%) %4.0f sec (%4.1f kHz)", nrsl, npsl, nfil, nevt, 100.*nevt/nent, tm, nevt/tm*1e-3) << endl; } if (evt->nTrRecHit() >= 1600) continue; if (evt->nTrTrack () != 1) continue; TrTrackR *trk = evt->pTrTrack(0); if (!trk) continue; Double_t chgp = TrCharge::GetQ(trk, 1); Double_t chgn = TrCharge::GetQ(trk, 0); if (chgp <= 0 || chgn <= 0) continue; Int_t mfp = trk->iTrTrackPar(malg, pat0, 0); if (mfp < 0) continue; Double_t rgtp = trk->GetRigidity(mfp); if (TMath::Abs(rgtp) < 5) continue; //////////////////// Recalc and refit //////////////////// trk->RecalcHitCoordinates(); Int_t mf0 = trk->iTrTrackPar(malg, pat0, 2); if (mf0 < 0) continue; Double_t rgt0 = trk->GetRigidity(mf0); if (TMath::Abs(rgt0) < 10) continue; nrsl++; //////////////////// Pre-selection //////////////////// Bool_t psel = kTRUE; Int_t span = (TrTrackSelection::GetSpanFlags(trk) & 0xff); if (!(span & TrTrackSelection::kMaxInt) || !(span & TrTrackSelection::kAllPlane)) psel = kFALSE; if (!(span & TrTrackSelection::kHalfL1N)) { if (!(span & TrTrackSelection::kHalfL9)) psel = kFALSE; AMSPoint pnt = trk->InterpolateLayerJ(9); if (TMath::Abs(pnt.x()) > 33) psel = kFALSE; } if (psel) npsl++; TrTrackR::AdvancedFitBits = 0x0f; TrRecon trec; Int_t nadd = trec.MergeExtHits(trk, mf0); if (!psel && nadd <= 0) continue; //////////////////// Remerge //////////////////// if (nadd > 0) { psel = kTRUE; span = (TrTrackSelection::GetSpanFlags(trk) & 0xff); if (!(span & TrTrackSelection::kMaxInt) || !(span & TrTrackSelection::kAllPlane)) psel = kFALSE; if (!(span & TrTrackSelection::kHalfL1N)) { if (!(span & TrTrackSelection::kHalfL9)) psel = kFALSE; AMSPoint pnt = trk->InterpolateLayerJ(9); if (TMath::Abs(pnt.x()) > 33) psel = kFALSE; } } if (!psel) continue; idata[0] = evt->Run(); idata[1] = evt->Event(); idata[2] = ient; idata[3] = evt->fHeader.Time[0]; EcalShowerR *ecal = evt->pEcalShower(0); fdata[0] = (ecal) ? ecal->EnergyC : 0; fdata[1] = (ecal) ? ecal->EnergyE : 0; fdata[2] = rgt0; fdata[3] = (chgp+chgn)/2; fdata[4] = trk->GetP0x(mf0); fdata[5] = trk->GetP0y(mf0); fdata[6] = trk->GetThetaXZ(mf0); fdata[7] = trk->GetThetaYZ(mf0); fdata[8] = trk->GetNormChisqX(mf0); fdata[9] = trk->GetNormChisqY(mf0); if (evt->nMCEventg() > 0) { MCEventgR *mcg = evt->pMCEventg(0); if (mcg) fdata[0] = mcg->Momentum; } Int_t *tkml = &idata[ 4]; Float_t *xcog = &fdata[10]; Float_t *ycog = &fdata[19]; for (Int_t i = 0; i < 9; i++) { tkml[i] = 0; xcog[i] = ycog[i] = 0; } for (Int_t i = 0; i < trk->GetNhits(); i++) { TrRecHitR *hit = trk->GetHit(i); if (!hit) continue; Int_t layer = hit->GetLayer(); //if (layer != 8 && layer != 9) continue; Int_t il = layer-1;//layer-8; Int_t tkid = hit->GetTkId(); Int_t imlt = hit->GetResolvedMultiplicity(); TrClusterR *clx = hit->GetXCluster(); TrClusterR *cly = hit->GetYCluster(); tkml[il] = TMath::Sign(imlt*1000+TMath::Abs(tkid), tkid); xcog[il] = (!clx) ? -(hit->GetDummyX()+640) : clx->GetCofG()+clx->GetSeedAddress(); ycog[il] = cly->GetCofG()+cly->GetSeedAddress(); } tree->Fill(); nfil++; } of.cd(); tree->Write(); }