File indexing completed on 2026-10-15 08:17:25
0001 #include "corral_class.h"
0002 #include "fluct_common.h" // SIPHIMASK windows (README_PID.md sec 10.3)
0003 #include "corral_version.h" // CORRAL_GIT, CORRAL_BUILD_TIME (made at build time, CMakeLists.txt)
0004 #include <TNamed.h>
0005 #include <TParameter.h>
0006
0007
0008
0009
0010
0011 TChain* corral::BuildInputChain(TTree *tree){
0012
0013 if (tree != 0){
0014
0015
0016 TChain *given = dynamic_cast<TChain*>(tree);
0017 if (given) return given;
0018 TChain *wrap = new TChain(tree->GetName());
0019 wrap->Add(tree->GetCurrentFile()->GetName());
0020 return wrap;
0021 }
0022
0023
0024
0025
0026
0027 const char* env = getenv("CORRAL_TREES");
0028 TString GLOB = (env && *env) ? TString(env) : TString("/rs/rs_grp_rhi/sPHENIX/ana573/795*/outputCollect_*.root");
0029 TChain *chain = new TChain("outTree","Collect tree chain");
0030 int nf = chain->Add(GLOB.Data());
0031 cout<<"corral -- input trees "<<GLOB<<((env && *env)?" ($CORRAL_TREES)":" (default; set CORRAL_TREES to change)")<<": "<<nf<<" files"<<endl;
0032 if (nf==0) cout<<"corral -- WARNING: no input files match "<<GLOB<<" (unmounted disk? wrong CORRAL_TREES?)"<<endl;
0033 return chain;
0034 }
0035
0036
0037 corral::corral(TTree *tree, int ntd, TString runstr, TString outname)
0038 : ntodo(ntd)
0039 , RunString(runstr)
0040 , OutputName(outname)
0041 , doCrossing(true)
0042 , doOldPID(false)
0043 , doSiPhiMask(true)
0044 , doCMMask(true)
0045 , doSegVeto(false)
0046 , doSepMaps(false)
0047 , valCMMaskLo(-0.07)
0048 , valCMMaskHi(0.10)
0049 , nSiPhiMask(NSIPHIMASK_MAIN)
0050 , doQCut(false)
0051 , FinePhiBinning(false)
0052 , valQCut(-1.0)
0053 , valSLCut(0.18)
0054
0055
0056
0057
0058
0059 , valSiKeyCut(0.10)
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 , valRadialGapCut(0.45)
0071
0072
0073 , DISABLE_LScuts(false)
0074
0075 , DISABLE_RG(false)
0076
0077 , doSplitRemoval(true)
0078
0079
0080
0081
0082
0083
0084 , doLooperVeto(true)
0085 , valLooperRSum(0.08)
0086 , valZvtxNB(16)
0087 , doULSTest(true)
0088
0089
0090
0091
0092
0093 , doDauCheck(true)
0094 , valULSTestCut(0.05)
0095
0096
0097
0098
0099
0100 , doXTFClean(true)
0101 , doMixNoAdjTF(true)
0102 , doXTFStrict(true)
0103 , nXTF_pairs(0), nXTF_byINTT(0), nXTF_byQuality(0), nXTF_neither(0), nXTF_losers(0)
0104 , doTFDup(true)
0105 , nTFDup_rows(0), TFDup_maxAbsDvz(0)
0106 , doIsoVtx(false), valIsoNX(0), valIsoDZ(0.)
0107 , ONLY_FIRST_XINGPOS(false)
0108 , xingSel(3)
0109 , ONLY_FIRST_TF(false)
0110 , valDcaxyCut(1.5)
0111 , valDcazCut(1.5)
0112 , NTPCCUT(18)
0113 , PTMINCUT(0.1)
0114 , valFullMVTX(2), valFullMVTXdinv(0.0), valPregateDEta(0.040)
0115 , valTSepDy(0.06), valTSepDphi(2.0), valISepDphi(2.), valVzMax(16.), valNchLo(0), valNchHi(9999), valFinZMax(8.)
0116 , valDPsW(2.0), valDPsR(0.06)
0117 , nentriesfile(0)
0118 , fChain(BuildInputChain(tree))
0119 , fReader(fChain)
0120 , run(fReader,"run")
0121 , segment(fReader,"segment")
0122 , evt(fReader,"evt")
0123 , trigVec(fReader,"trigVec")
0124 , nvtx(fReader,"nvtx")
0125 , vtxntr(fReader,"vtxntr")
0126 , vtxx(fReader,"vtxx")
0127 , vtxy(fReader,"vtxy")
0128 , vtxz(fReader,"vtxz")
0129 , crossing(fReader,"crossing")
0130 , etotem(fReader,"etotem")
0131 , etotih(fReader,"etotih")
0132 , etotoh(fReader,"etotoh")
0133 , etotioh(fReader,"etotioh")
0134 , etotepd(fReader,"etotepd")
0135 , ntr(fReader,"ntr")
0136 , pid(fReader,"pid")
0137 , indv0(fReader,"indv0")
0138 , primary(fReader,"primary")
0139 , quality(fReader,"quality")
0140 , chisq(fReader,"chisq")
0141 , chg(fReader,"chg")
0142 , ptot(fReader,"ptot")
0143 , eta(fReader,"eta")
0144 , phi(fReader,"phi")
0145 , pt(fReader,"pt")
0146 , seedeta(fReader,"seedeta")
0147 , seedphi(fReader,"seedphi")
0148 , seedpt(fReader,"seedpt")
0149 , ntpc(fReader,"ntpc")
0150 , nmvtx(fReader,"nmvtx")
0151 , nintt(fReader,"nintt")
0152 , dcaxy(fReader,"dcaxy")
0153 , dcaz(fReader,"dcaz")
0154 , dedx70n(fReader,"dedx70n")
0155 , dedx70s(fReader,"dedx70s")
0156 , dedxKFP(fReader,"dedxKFP")
0157 , layermask(fReader,"layermask")
0158 , siclukey(fReader,"siclukey")
0159 , tpcsector(fReader,"tpcsector")
0160 , tpcarclen(fReader,"tpcarclen")
0161 , tpcz(fReader,"tpcz")
0162 , nv0(fReader,"nv0")
0163 , v0pid(fReader,"v0pid")
0164 , v0x(fReader,"v0x")
0165 , v0y(fReader,"v0y")
0166 , v0z(fReader,"v0z")
0167 , v0px(fReader,"v0px")
0168 , v0py(fReader,"v0py")
0169 , v0pz(fReader,"v0pz")
0170 , v0pt(fReader,"v0pt")
0171 , v0ptot(fReader,"v0ptot")
0172 , v0eta(fReader,"v0eta")
0173 , v0phi(fReader,"v0phi")
0174 , v0ene(fReader,"v0ene")
0175 , v0mass(fReader,"v0mass")
0176 , v0ctau(fReader,"v0ctau")
0177 , v0decaylen(fReader,"v0decaylen")
0178 , v0chi2ndf(fReader,"v0chi2ndf")
0179 , v0dira(fReader,"v0dira")
0180 , v0pvdca(fReader,"v0pvdca")
0181 , v0decayx(fReader,"v0decayx")
0182 , v0decayy(fReader,"v0decayy")
0183 , v0decayz(fReader,"v0decayz")
0184 , v0indtr1(fReader,"v0indtr1")
0185 , v0indtr2(fReader,"v0indtr2")
0186 {
0187
0188 gPrintViaErrorHandler = kTRUE;
0189 gErrorIgnoreLevel = kWarning;
0190
0191
0192
0193 {
0194 static const char* RAW_TOKENS = "noLS_noulstest_noXTF_noTFdup_nolooper_notsep_noisep_nocross_nocmmask";
0195 if (RunString.Contains("Raw",TString::kIgnoreCase)){
0196 RunString += TString("_")+RAW_TOKENS;
0197
0198 if (!RunString.Contains("Xing0",TString::kIgnoreCase) && !RunString.Contains("NearX0",TString::kIgnoreCase)
0199 && !RunString.Contains("ZB",TString::kIgnoreCase)) RunString += "_AllX";
0200 cout<<"reader::reader -- Raw = "<<RAW_TOKENS<<" (+ AllX unless Xing0/NearX0/ZB) -> RunString="<<RunString<<endl;
0201 }
0202 }
0203
0204
0205 if (RunString.Contains("nocross",TString::kIgnoreCase)){
0206 doCrossing = false;
0207 cout<<"RunString="<<RunString<<"\t doCrossing="<<(int)doCrossing<<endl;
0208 }
0209
0210
0211 if (RunString.Contains("oldpid",TString::kIgnoreCase)){
0212 doOldPID = true;
0213 cout<<"RunString="<<RunString<<"\t doOldPID="<<(int)doOldPID<<endl;
0214 }
0215
0216 if (RunString.Contains("nosiphimask",TString::kIgnoreCase)){
0217 doSiPhiMask = false;
0218 cout<<"RunString="<<RunString<<"\t doSiPhiMask="<<(int)doSiPhiMask<<endl;
0219 }
0220 if (RunString.Contains("siphimaskall",TString::kIgnoreCase)){
0221 nSiPhiMask = NSIPHIMASK;
0222 cout<<"RunString="<<RunString<<"\t nSiPhiMask="<<nSiPhiMask<<" (all vertex-phi windows)"<<endl;
0223 }
0224
0225
0226 auto saneOrDie = [&](const char* tok, double v, double lo, double hi){
0227 if (v<lo || v>hi){
0228 cout<<"reader::reader -- run-string token '"<<tok<<"' gives "<<v<<", outside the sane range ["<<lo<<","<<hi<<"]. Exiting."<<endl;
0229 exit(1);
0230 }
0231 };
0232 if (RunString.Contains("ntpc",TString::kIgnoreCase)){
0233 int ij = RunString.Index("ntpc",0,TString::kIgnoreCase);
0234 TString sntpc = RunString(ij+4,2);
0235 NTPCCUT = sntpc.IsDigit() ? atoi(sntpc.Data()) : -1;
0236 saneOrDie("ntpcNN",NTPCCUT,10,40);
0237 cout<<"RunString="<<RunString<<"\t sntpc="<<sntpc<<"\t NTPCCUT="<<NTPCCUT<<endl;
0238 }
0239
0240
0241 if (RunString.Contains("dcz",TString::kIgnoreCase)){
0242 int ij = RunString.Index("dcz",0,TString::kIgnoreCase);
0243 TString sd = RunString(ij+3,2);
0244 if (!sd.IsDigit()){ cout<<"RunString="<<RunString<<": dcz needs 2 digits (dczNN = |dcaz| < NN/10 cm)"<<endl; exit(1); }
0245 valDcazCut = atoi(sd.Data())/10.;
0246 saneOrDie("dczNN",valDcazCut,0.2,1.5);
0247 }
0248 cout<<"reader::reader -- track |dcaz| < "<<valDcazCut<<" cm"<<(valDcazCut!=1.5 ? " (dcz)" : " (default)")<<endl;
0249
0250
0251 if (RunString.Contains("dxy",TString::kIgnoreCase)){
0252 int ij = RunString.Index("dxy",0,TString::kIgnoreCase);
0253 TString sd = RunString(ij+3,2);
0254 if (!sd.IsDigit()){ cout<<"RunString="<<RunString<<": dxy needs 2 digits (dxyNN = |dcaxy| < NN/100 cm)"<<endl; exit(1); }
0255 valDcaxyCut = atoi(sd.Data())/100.;
0256 saneOrDie("dxyNN",valDcaxyCut,0.05,0.99);
0257 }
0258 cout<<"reader::reader -- track |dcaxy| < "<<valDcaxyCut<<" cm"<<(valDcaxyCut!=1.5 ? " (dxy)" : " (default)")<<endl;
0259
0260
0261
0262
0263
0264
0265 if (RunString.Contains("dps",TString::kIgnoreCase)){
0266 int ij = RunString.Index("dps",0,TString::kIgnoreCase);
0267 TString sw = RunString(ij+3,2);
0268 valDPsW = sw.IsDigit() ? atoi(sw.Data())/10. : -1;
0269 saneOrDie("dpsNN",valDPsW,1.0,4.0);
0270 }
0271 if (RunString.Contains("notsep",TString::kIgnoreCase)){
0272 valTSepDy = 0.;
0273 } else if (RunString.Contains("tsepm",TString::kIgnoreCase)){
0274 int ij = RunString.Index("tsepm",0,TString::kIgnoreCase);
0275 TString sy = RunString(ij+5,2), sp = RunString(ij+7,2);
0276 valTSepDy = sy.IsDigit() ? atoi(sy.Data())/100. : -1;
0277 valTSepDphi = sp.IsDigit() ? atoi(sp.Data())/10. : -1;
0278 saneOrDie("tsepmYYPP (dy)",valTSepDy,0.02,0.10);
0279 saneOrDie("tsepmYYPP (dphi*)",valTSepDphi,1.0,4.0);
0280 }
0281
0282
0283 if (RunString.Contains("noisep",TString::kIgnoreCase)){
0284 valISepDphi = 0.;
0285 } else if (RunString.Contains("isep",TString::kIgnoreCase)){
0286 int ij = RunString.Index("isep",0,TString::kIgnoreCase);
0287 TString sw = RunString(ij+4,3);
0288 valISepDphi = sw.IsDigit() ? atoi(sw.Data())/10. : -1;
0289 saneOrDie("isepPPP",valISepDphi,0.3,4.0);
0290 }
0291
0292 if (RunString.Contains("vz",TString::kIgnoreCase)){
0293 int ij = RunString.Index("vz",0,TString::kIgnoreCase);
0294 TString sw = RunString(ij+2,2);
0295 valVzMax = sw.IsDigit() ? atoi(sw.Data()) : -1;
0296 saneOrDie("vzNN",valVzMax,6.,16.);
0297 }
0298 cout<<"reader::reader -- event abs(zvtx) < "<<valVzMax<<" cm"<<endl;
0299
0300
0301 if (RunString.Contains("nch",TString::kIgnoreCase)){
0302 int ij = RunString.Index("nch",0,TString::kIgnoreCase);
0303 TString sl = RunString(ij+3,2), sh = RunString(ij+5,2);
0304 valNchLo = sl.IsDigit() ? atoi(sl.Data()) : -1;
0305 valNchHi = sh.IsDigit() ? atoi(sh.Data()) : -1;
0306 saneOrDie("nchLLHH (LL)",valNchLo,0,40);
0307 saneOrDie("nchLLHH (HH)",valNchHi,valNchLo,99);
0308 cout<<"reader::reader -- multiplicity class: only events with "<<valNchLo<<" <= N_ch <= "<<valNchHi<<" reach CalcRm"<<endl;
0309 }
0310
0311 if (RunString.Contains("fz",TString::kIgnoreCase)){
0312 int ij = RunString.Index("fz",0,TString::kIgnoreCase);
0313 TString sw = RunString(ij+2,2);
0314 valFinZMax = sw.IsDigit() ? atoi(sw.Data()) : -1;
0315 saneOrDie("fzNN",valFinZMax,2.,16.);
0316 }
0317 cout<<"reader::reader -- near-vertex two-track pair cut (isep) "<<(valISepDphi>0?Form("ON: reject abs(dphi*(R=3 cm))<%.1f deg at abs(dy)<1.0, LS and ULS, sibling and mixed",valISepDphi):"OFF")<<endl;
0318 cout<<"reader::reader -- LS pregate: centred on the split peak, abs(dphi) within "<<valDPsW<<" deg of dphi0(R="<<valDPsR<<" m), deta semi-axis "<<valPregateDEta<<endl;
0319
0320
0321 if (RunString.Contains("noMVTX",TString::kIgnoreCase)) valFullMVTX = 0;
0322 cout<<"reader::reader -- LS path 3 (MVTX match): "<<(valFullMVTX>0?Form(">= %d matched MVTX layers",valFullMVTX):"DISABLED (noMVTX)")<<endl;
0323 cout<<"reader::reader -- two-track LS pair cut "<<(valTSepDy>0?Form("ON: reject abs(dy)<%.2f && min over R=0.30-0.78 m of abs(dphi*)<%.1f deg, sibling and mixed",valTSepDy,valTSepDphi):"OFF (notsep)")<<endl;
0324
0325 if (RunString.Contains("qcut",TString::kIgnoreCase)){
0326 doQCut = true;
0327 valQCut = 0.150;
0328 }
0329 if (doQCut){ cout<<"reader::reader -- Q cut enabled... valQCut = "<<valQCut<<endl; }
0330
0331
0332
0333
0334
0335 if (RunString.Contains("skf",TString::kIgnoreCase)){
0336 int ij = RunString.Index("skf",0,TString::kIgnoreCase);
0337 TString sskf = RunString(ij+3,2);
0338 valSiKeyCut = sskf.IsDigit() ? atoi(sskf.Data())/100. : -1;
0339 saneOrDie("skfNN",valSiKeyCut,0.05,0.95);
0340 cout<<"reader::reader -- pre-pass SiSplitScore gate overridden via 'skf' token... valSiKeyCut = "<<valSiKeyCut<<endl;
0341 }
0342
0343
0344
0345 if (RunString.Contains("removecut",TString::kIgnoreCase)){
0346 int ij = RunString.Index("removecut",0,TString::kIgnoreCase);
0347 TString sremove = RunString(ij+9,2);
0348 valSLCut = sremove.IsDigit() ? atoi(sremove.Data())/100. : -1;
0349 saneOrDie("removecutNN",valSLCut,0.05,0.60);
0350 cout<<"reader::reader -- pre-pass SL threshold overridden via 'removecut' token... valSLCut = "<<valSLCut<<endl;
0351 }
0352
0353
0354
0355 if (RunString.Contains("radialgap",TString::kIgnoreCase)){
0356 int ij = RunString.Index("radialgap",0,TString::kIgnoreCase);
0357 TString srg = RunString(ij+9,2);
0358 valRadialGapCut = srg.IsDigit() ? atoi(srg.Data())/100. : -1;
0359 saneOrDie("radialgapNN",valRadialGapCut,0.20,0.90);
0360 cout<<"reader::reader -- pre-pass RadialGap threshold overridden via 'radialgap' token... valRadialGapCut = "<<valRadialGapCut<<endl;
0361 }
0362
0363
0364
0365
0366
0367
0368
0369 if (RunString.Contains("noLS",TString::kIgnoreCase)){
0370 DISABLE_LScuts = true;
0371 }
0372 if (RunString.Contains("noRG",TString::kIgnoreCase)){
0373 DISABLE_RG = true;
0374 }
0375 doSplitRemoval = !DISABLE_LScuts;
0376 cout<<"reader::reader -- split-track REMOVAL pre-pass "<<(doSplitRemoval?"enabled":"DISABLED")
0377 <<"... valSLCut = "<<valSLCut<<", valSiKeyCut = "<<valSiKeyCut<<", valRadialGapCut = "<<valRadialGapCut
0378 <<", RadialGap path "<<(DISABLE_RG?"DISABLED (noRG)":"enabled")<<endl;
0379
0380
0381 if (RunString.Contains("segveto",TString::kIgnoreCase)) doSegVeto = true;
0382 cout<<"reader::reader -- segment veto "<<(doSegVeto?"ON (segveto)":"OFF")<<endl;
0383
0384 if (RunString.Contains("sepmaps",TString::kIgnoreCase)) doSepMaps = true;
0385 cout<<"reader::reader -- separation maps (README_CQcomparison sec 2.3) "<<(doSepMaps?"ON (sepmaps)":"OFF")<<endl;
0386
0387 if (RunString.Contains("nocmmask",TString::kIgnoreCase)){
0388 doCMMask = false;
0389 cout<<"RunString="<<RunString<<"\t doCMMask="<<(int)doCMMask<<endl;
0390 } else if (RunString.Contains("cmmask",TString::kIgnoreCase)){
0391 int ij = RunString.Index("cmmask",0,TString::kIgnoreCase);
0392 while (ij>=0 && !TString(RunString(ij+6,4)).IsDigit()) ij = RunString.Index("cmmask",ij+1,TString::kIgnoreCase);
0393 if (ij<0) ij = RunString.Index("cmmask",0,TString::kIgnoreCase);
0394 TString sl = RunString(ij+6,2), sh = RunString(ij+8,2);
0395 if (!sl.IsDigit() || !sh.IsDigit()){ cout<<"RunString="<<RunString<<": cmmask needs 4 digits (cmmaskAABB)"<<endl; exit(1); }
0396 doCMMask = true;
0397 valCMMaskLo = -atoi(sl.Data())/100.; valCMMaskHi = atoi(sh.Data())/100.;
0398 saneOrDie("cmmaskAABB (lo)",-valCMMaskLo,0.,0.20); saneOrDie("cmmaskAABB (hi)",valCMMaskHi,0.,0.20);
0399 cout<<"RunString="<<RunString<<"\t central-membrane mask ON, w in ["<<valCMMaskLo<<","<<valCMMaskHi<<")"<<endl;
0400 }
0401
0402 if (RunString.Contains("nolooper",TString::kIgnoreCase)){
0403 doLooperVeto = false;
0404 cout<<"RunString="<<RunString<<"\t doLooperVeto="<<(int)doLooperVeto<<endl;
0405 } else if (RunString.Contains("looper",TString::kIgnoreCase)){
0406 int ij = RunString.Index("looper",0,TString::kIgnoreCase);
0407 TString sl = RunString(ij+6,2);
0408 if (sl.IsDigit()){ valLooperRSum = atoi(sl.Data())/100.; saneOrDie("looperNN",valLooperRSum,0.02,0.10); }
0409 cout<<"RunString="<<RunString<<"\t looper veto relative-sum cut = "<<valLooperRSum<<endl;
0410 }
0411
0412
0413
0414
0415 if (RunString.Contains("noulstest",TString::kIgnoreCase)){
0416 doULSTest = false;
0417 } else if (RunString.Contains("ulstest",TString::kIgnoreCase)){
0418 int ij = RunString.Index("ulstest",0,TString::kIgnoreCase);
0419 TString sulstest = RunString(ij+7,2);
0420 doULSTest = true;
0421 valULSTestCut = sulstest.IsDigit() ? atoi(sulstest.Data())/100. : -1;
0422 saneOrDie("ulstestNN",valULSTestCut,0.02,0.95);
0423 }
0424 cout<<"reader::reader -- ULS pair veto (sec 15) "<<(doULSTest?"enabled":"DISABLED")
0425 <<"... valULSTestCut = "<<valULSTestCut<<endl;
0426
0427
0428 if (RunString.Contains("nodau",TString::kIgnoreCase)) doDauCheck = false;
0429 cout<<"reader::reader -- V0-daughter partners (README_CQcomparison sec 2.2): "<<(doDauCheck?"on (Lambda/Lbar daughters: LS paths dR<0.05 except pion-tagged partners of a p/pbar, ULS never an (anti)proton partner of a pion daughter; not K0S)":"OFF")<<endl;
0430
0431
0432
0433
0434 if (RunString.Contains("onlyfirsttf",TString::kIgnoreCase)){
0435 ONLY_FIRST_TF = true;
0436 }
0437 cout<<"reader::reader -- ONLY_FIRST_TF (sec 18.21) "<<(ONLY_FIRST_TF?"enabled -- ~85% stats cost":"DISABLED")<<endl;
0438
0439
0440
0441
0442
0443
0444
0445
0446 if (RunString.Contains("noXTF",TString::kIgnoreCase)){
0447 doXTFClean = false;
0448 doXTFStrict = false;
0449 doMixNoAdjTF = false;
0450 }
0451 if (RunString.Contains("XTFclean",TString::kIgnoreCase)){
0452 doXTFClean = true;
0453 doXTFStrict = false;
0454 }
0455 if (RunString.Contains("mixAdjTF",TString::kIgnoreCase)){
0456 doMixNoAdjTF = false;
0457 }
0458 cout<<"reader::reader -- doMixNoAdjTF (sec 18.23) "<<(doMixNoAdjTF?(doXTFClean?"enabled -- skip |devt|==1":"enabled -- XTFclean OFF, so skip |devt|<=1 (same-TF too)"):"DISABLED")<<endl;
0459 cout<<"reader::reader -- doXTFClean (sec 18.22) "<<(doXTFClean?"enabled":"DISABLED")
0460 <<(doXTFStrict?" -- STRICT (neither-case: drop both copies)":"")<<endl;
0461
0462
0463 if (RunString.Contains("noTFdup",TString::kIgnoreCase)){
0464 doTFDup = false;
0465 }
0466 cout<<"reader::reader -- doTFDup (overlapping-TF copies, key run+bco+crossing) "<<(doTFDup?"enabled":"DISABLED")<<endl;
0467
0468 if (RunString.Contains("isovtx",TString::kIgnoreCase)){
0469 int ij = RunString.Index("isovtx",0,TString::kIgnoreCase);
0470 TString sn = RunString(ij+6,2), sz = RunString(ij+8,2);
0471 if (!sn.IsDigit() || !sz.IsDigit()){ cout<<"RunString="<<RunString<<": isovtx needs 4 digits (isovtxNNZZ)"<<endl; exit(1); }
0472 doIsoVtx = true; valIsoNX = atoi(sn.Data()); valIsoDZ = atoi(sz.Data());
0473 saneOrDie("isovtxNNZZ (NN crossings)",valIsoNX,1,50); saneOrDie("isovtxNNZZ (ZZ cm)",valIsoDZ,1,30);
0474 }
0475 cout<<"reader::reader -- isolated vertices only "<<(doIsoVtx?Form("ON: no other vertex within +-%d crossings and |dz| < %.0f cm (isovtx)",valIsoNX,valIsoDZ):"OFF")<<endl;
0476
0477
0478 if (RunString.Contains("XingPos",TString::kIgnoreCase)){
0479 ONLY_FIRST_XINGPOS = true;
0480 }
0481 cout<<"reader::reader -- ONLY_FIRST_XINGPOS (sec 18.21) "<<(ONLY_FIRST_XINGPOS?"enabled -- first crossing>0 row per TF only":"DISABLED")<<endl;
0482
0483
0484
0485 {
0486 int nsel = 0;
0487 if (RunString.Contains("AllX",TString::kIgnoreCase)){ xingSel = 0; ++nsel; }
0488 if (RunString.Contains("Xing0",TString::kIgnoreCase)){ xingSel = 1; ++nsel; }
0489 if (RunString.Contains("NearX0",TString::kIgnoreCase)){ xingSel = 2; ++nsel; }
0490 if (RunString.Contains("ZB",TString::kIgnoreCase)){ xingSel = 3; ++nsel; }
0491 if (nsel>1){ cout<<"reader::reader -- more than one of Xing0 / NearX0 / ZB / AllX given, they exclude each other"<<endl; exit(1); }
0492 }
0493 cout<<"reader::reader -- crossing selection: "<<(xingSel==1?TString("Xing0 -- crossing==0 only (triggered collision)"):
0494 xingSel==2?TString::Format("NearX0 -- %d<=crossing<=%d, crossing!=0 (trigger neighbours)",XNEAR_LO,XNEAR_HI):
0495 xingSel==3?TString::Format("ZB -- %d<=crossing<%d or %d<crossing<=%d (streaming, away from the trigger and the readout edges)",ZB_LO,XNEAR_LO,XNEAR_HI,ZB_HI):TString("all crossings"))<<endl;
0496
0497 if (RunString.Contains("548",TString::kIgnoreCase)){ FinePhiBinning = true; }
0498 if (FinePhiBinning){ cout<<"reader::reader -- FinePhiBinning enabled..."<<endl; }
0499
0500
0501
0502
0503
0504
0505
0506
0507 const Long64_t nentriesfile_ana532 = 50498542;
0508
0509 const Long64_t nentriesfile_ana573_795xx = 642480426;
0510
0511
0512 (void)nentriesfile_ana532;
0513 const char* envTrees = getenv("CORRAL_TREES");
0514 if (tree==0 && !(envTrees && *envTrees))
0515 nentriesfile = nentriesfile_ana573_795xx;
0516
0517 if (nentriesfile==0){
0518 cout<<"Getting tree Nevt..."<<endl;
0519 nentriesfile = fChain->GetEntries();
0520 }
0521 cout<<"Nentriesfile = "<<nentriesfile<<endl;
0522
0523 }
0524
0525
0526 corral::~corral()
0527 {
0528
0529
0530
0531
0532 }
0533
0534
0535
0536
0537
0538
0539
0540
0541 TString corral::SettingsText(){
0542 TString s;
0543 auto L = [&](const TString &t){ s += t; s += "\n"; };
0544 auto on = [](bool b){ return b ? "ON" : "OFF"; };
0545 L(Form("events: |vtx x|,|vtx y| < 0.5 cm, |z_{vtx}| < %.0f cm in %d slices (the physics range is chosen in Finalize, fz)",valVzMax,valZvtxNB));
0546 L(TString("crossing selection: ")+(xingSel==0 ? TString("AllX (all crossings)") : xingSel==1 ? TString("Xing0 (crossing 0, the triggered collision)") :
0547 xingSel==2 ? TString::Format("NearX0 (%d..%d without 0)",XNEAR_LO,XNEAR_HI) : TString::Format("ZB (%d..%d outside NearX0 %d..%d)",ZB_LO,ZB_HI,XNEAR_LO,XNEAR_HI)));
0548 L(Form("segment veto (segveto) %s; isolated vertices (isovtx) %s",on(doSegVeto),doIsoVtx ? Form("ON: +-%d crossings, |dz| < %.0f cm",valIsoNX,valIsoDZ) : "OFF"));
0549 if (valNchHi<9999) L(Form("multiplicity class (nch): %d <= N_ch <= %d",valNchLo,valNchHi));
0550 L(Form("overlapping-TF copies skipped (TFdup) %s; cross-crossing duplicate cleaner (XTF) %s%s; adjacent-TF mixing exclusion %s",
0551 on(doTFDup),on(doXTFClean),doXTFClean ? (doXTFStrict ? " strict" : " non-strict") : "",on(doMixNoAdjTF)));
0552 L(Form("tracks: %.2f < p_{T} < 20.1 GeV/c, ntpc >= %d, |dca_{xy}| < %.2f cm, |dca_{z}| < %.2f cm",PTMINCUT,NTPCCUT,valDcaxyCut,valDcazCut));
0553 { TString w; if (doSiPhiMask) for (int k=0;k<nSiPhiMask;k++) w += Form(" [%.0f,%.0f)",SIPHIMASK_LO[k],SIPHIMASK_HI[k]);
0554 L(Form("SiPhiMask %s%s; central-membrane mask %s",on(doSiPhiMask),doSiPhiMask ? Form(", vertex phi (deg):%s",w.Data()) : "",
0555 doCMMask ? Form("ON, w in [%.2f,%.2f)",valCMMaskLo,valCMMaskHi) : "OFF")); }
0556 L(doOldPID ? TString("PID: legacy (oldpid), pi = dedx70s < 400") :
0557 TString::Format("PID: KFP dE/dx gates, pi then p (outside K) then K (outside p); p_{max} pi %.1f, K %.1f, p %.1f GeV/c",Species_pmax_pid[0],Species_pmax_pid[1],Species_pmax_pid[2]));
0558 L(Form("pair p_{T} min: pi %.2f, K %.2f, p %.2f GeV/c; |y| max: pi %.2f, K %.2f, p %.2f, V0 %.2f; h+- |eta| < %.2f",
0559 Species_ptmin[0],Species_ptmin[1],Species_ptmin[2],Species_yu[0],Species_yu[1],Species_yu[2],Species_yu[5],Hadron_etau));
0560 L(Form("V0s in pairs: within %.0f sigma of the mass peak (K0S %.4f+-%.4f, La %.4f+-%.4f, Lbar %.4f+-%.4f GeV); daughters in no pair type",
0561 V0PEAK_NSIG,V0PEAK_MU[0],V0PEAK_SIG[0],V0PEAK_MU[1],V0PEAK_SIG[1],V0PEAK_MU[2],V0PEAK_SIG[2]));
0562 L(Form("LS split-track removal %s (SL < %.2f & SiSplitScore >= %.2f; RadialGap >= %.2f %s; MVTX path %s); pregate dps %.1f deg",
0563 on(doSplitRemoval),valSLCut,valSiKeyCut,valRadialGapCut,DISABLE_RG ? "OFF" : "ON",valFullMVTX>0 ? "ON" : "OFF",valDPsW));
0564 L(Form("ULS veto %s (SiSplitScore >= %.2f); V0-daughter partners (dau) %s; looper veto %s (|p| < %.2f, p-sum < %.2f)",
0565 on(doULSTest),valULSTestCut,on(doDauCheck),on(doLooperVeto),LOOPER_PMAX,valLooperRSum));
0566 L(Form("two-track cuts: tsep %s, isep %s",valTSepDy>0 ? Form("|dy| < %.2f & |dphi*| < %.1f deg",valTSepDy,valTSepDphi) : "OFF",
0567 valISepDphi>0 ? Form("|dy| < 1.0 & |dphi*(3 cm)| < %.1f deg",valISepDphi) : "OFF"));
0568 L(Form("crossing correction %s; Q cut %s; (dy,dphi) binning %s",on(doCrossing),doQCut ? Form("Q > %.3f GeV",valQCut) : "OFF",FinePhiBinning ? "5 x 48" : "default"));
0569 return s;
0570 }
0571 void corral::WriteInfo(TDirectory *top, const std::vector<std::pair<TString,TString>> &texts, const std::vector<std::pair<TString,double>> &counts){
0572 TDirectory *keep = gDirectory;
0573 TDirectory *d = top->GetDirectory("info") ? top->GetDirectory("info") : top->mkdir("info","how this output was made (README.md, info/)");
0574 d->cd();
0575 TNamed("runstring",RunString.Data()).Write("",TObject::kOverwrite);
0576 TNamed("settings",SettingsText().Data()).Write("",TObject::kOverwrite);
0577 TNamed("list",(ListName!="" ? ListName : TString("default input glob")).Data()).Write("",TObject::kOverwrite);
0578 TNamed("code",Form("git %s (commit date %s), built %s",CORRAL_GIT,CORRAL_GIT_DATE,CORRAL_BUILD_TIME)).Write("",TObject::kOverwrite);
0579 for (auto &t : texts) TNamed(t.first.Data(),t.second.Data()).Write("",TObject::kOverwrite);
0580 for (auto &c : counts) TParameter<double>(("count_"+c.first).Data(),c.second).Write("",TObject::kOverwrite);
0581
0582 const std::vector<std::pair<const char*,double>> cuts = {{"ptmin",PTMINCUT},{"ntpc",(double)NTPCCUT},{"dcaxy",valDcaxyCut},{"dcaz",valDcazCut},
0583 {"vzmax",valVzMax},{"vxymax",0.5},{"xingsel",(double)xingSel},{"siphimask",doSiPhiMask ? (double)nSiPhiMask : 0.}};
0584 for (auto &c : cuts) TParameter<double>(Form("cut_%s",c.first),c.second).Write("",TObject::kOverwrite);
0585 keep->cd();
0586 }