168 if (fPath.Contains(
"eos"))
175 histoMan->
fBeams = fBeams;
181 TH1F***** h = histoMan->
GetH1();
182 TH2F* h2 = histoMan->
GetH2();
183 TH2F* h3 = histoMan->
GetH3();
184 TH2F***** h4 = histoMan->
GetH4();
185 TH1F***** h5 = histoMan->
GetH5();
187 Long_t nTotalGlobTrack[fBeams.size()][fTargets.size()]
189 for (
size_t iBeam = 0; iBeam < fBeams.size(); iBeam++)
190 for (
size_t iTarget = 0; iTarget < fTargets.size(); iTarget++)
191 for (
size_t iTrigger = 0; iTrigger < fTriggers.size(); iTrigger++)
192 nTotalGlobTrack[iBeam][iTarget][iTrigger] = 0;
194 if (!anal1 && !anal2 && !anal3)
210 pair<Bool_t, Int_t> isBeamInAnal = make_pair(kFALSE, -1);
211 pair<Bool_t, Int_t> isTargetInAnal = make_pair(kFALSE, -1);
212 pair<Bool_t, Int_t> isTriggerInAnal = make_pair(kFALSE, -1);
214 TString target = targ;
220 for (
size_t iEle = 0; iEle < fBeams.size(); iEle++) {
221 if (fBeams[iEle] == beam) {
222 isBeamInAnal.first = kTRUE;
223 isBeamInAnal.second = iEle;
228 for (
size_t iEle = 0; iEle < fTargets.size(); iEle++) {
229 if (fTargets[iEle] == target) {
230 isTargetInAnal.first = kTRUE;
231 isTargetInAnal.second = iEle;
236 for (
size_t iEle = 0; iEle < fTriggers.size(); iEle++) {
237 if (fTriggers[iEle] == trigger) {
238 isTriggerInAnal.first = kTRUE;
239 isTriggerInAnal.second = iEle;
244 if (!isBeamInAnal.first || !isTargetInAnal.first || !isTriggerInAnal.first)
248 TChain* dst =
new TChain(
"bmndata");
252 TString path = fPath +
"/" + TString::Format(
"bmndst_%d.root", iDst);
253 TString command =
"xrdcp -DIRedirCntTimeout 30 " + fEosHost + path +
" .";
255 gSystem->Exec(command.Data());
256 TString dstFile = TString::Format(
"bmndst_%d.root", iDst);
257 dst->Add(dstFile.Data());
259 TString path = fPath +
"/" + TString::Format(
"bmndst_%d.root", iDst);
260 dst->Add(path.Data());
263 if (!dst->GetFile()) {
272 fAna->SetField(fMagField);
280 h2->Fill(fTriggers[isTriggerInAnal.second], fTargets[isTargetInAnal.second], dst->GetEntries() / 1e6);
282 dst->SetBranchAddress(
"DstEventHeader.", &hDst);
283 dst->SetBranchAddress(
"BmnGlobalTrack", &fGlobTracks);
284 dst->SetBranchAddress(
"BmnVertex", &fVertices);
285 dst->SetBranchAddress(
"BmnTof400Hit", &fTof400Hits);
286 dst->SetBranchAddress(
"BmnTof700Hit", &fTof700Hits);
287 dst->SetBranchAddress(
"BmnDchHit", &fDchHits);
288 dst->SetBranchAddress(
"BmnCSCHit", &fCscHits);
291 UInt_t nEventsWithMoreThanOneTrack = 0;
294 for (Int_t iEvent = 0; iEvent < dst->GetEntries(); iEvent++) {
296 dst->GetEntry(iEvent);
298 if (iEvent % 10000 == 0)
299 cout <<
"Processing file# " << iDst <<
" Event# " << iEvent << endl;
301 Int_t totMult = fGlobTracks->GetEntriesFast();
303 nEventsWithMoreThanOneTrack++;
306 h3->Fill(fTriggers[isTriggerInAnal.second], fTargets[isTargetInAnal.second],
307 nEventsWithMoreThanOneTrack / 1e6);
311 for (Int_t iEvent = 0; iEvent < dst->GetEntries(); iEvent++) {
313 dst->GetEntry(iEvent);
315 if (iEvent % 10000 == 0)
316 cout <<
"Processing file# " << iDst <<
" Event# " << iEvent << endl;
319 h[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][0]->Fill(vertex->
GetZ());
321 Int_t totMult = fGlobTracks->GetEntriesFast();
322 h[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][1]->Fill(totMult);
325 nEventsWithMoreThanOneTrack++;
331 for (Int_t iTrack = 0; iTrack < fGlobTracks->GetEntriesFast(); iTrack++) {
339 h[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][4]->Fill(track->
GetP());
343 h[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][2]->Fill(nPos);
346 h[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][3]->Fill(nNeg);
351 TH2F* H0 = h4[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][0];
352 TH2F* H1 = h4[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][1];
353 TH2F* H2 = h4[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][2];
356 TH2F* beta400 = h4[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][3];
357 TH2F* beta700 = h4[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second][4];
360 TH1F** residuals = h5[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second];
362 for (Int_t iEvent = 0; iEvent < dst->GetEntries(); iEvent++) {
364 dst->GetEntry(iEvent);
366 if (iEvent % 10000 == 0)
367 cout <<
"Processing file# " << iDst <<
" Event# " << iEvent << endl;
370 nTotalGlobTrack[isBeamInAnal.second][isTargetInAnal.second][isTriggerInAnal.second] +=
373 for (Int_t iTrack = 0; iTrack < fGlobTracks->GetEntriesFast(); iTrack++) {
376 Double_t b400 = track->
GetBeta(1);
377 Double_t b700 = track->
GetBeta(2);
380 beta400->Fill(TMath::Abs(track->
GetP()), b400);
382 beta700->Fill(TMath::Abs(track->
GetP()), b700);
393 BmnHit* tof400Hit =
nullptr;
394 BmnHit* tof700Hit =
nullptr;
400 tof400Hit = (
BmnHit*)fTof400Hits->UncheckedAt(mTof1);
401 Double_t alreadyFilled =
402 H0->GetBinContent(FindBinXY(
"tof400").first, FindBinXY(
"tof400").second);
403 H0->SetBinContent(FindBinXY(
"tof400").first, FindBinXY(
"tof400").second, alreadyFilled + 1.);
407 tof700Hit = (
BmnHit*)fTof700Hits->UncheckedAt(mTof2);
408 Double_t alreadyFilled =
409 H0->GetBinContent(FindBinXY(
"tof700").first, FindBinXY(
"tof700").second);
410 H0->SetBinContent(FindBinXY(
"tof700").first, FindBinXY(
"tof700").second, alreadyFilled + 1.);
414 cscHit = (
BmnHit*)fCscHits->UncheckedAt(mCsc);
415 Double_t alreadyFilled = H0->GetBinContent(FindBinXY(
"csc").first, FindBinXY(
"csc").second);
416 H0->SetBinContent(FindBinXY(
"csc").first, FindBinXY(
"csc").second, alreadyFilled + 1.);
419 if (mDch1 != -1 || mDch2 != -1 || mDch != -1) {
420 dchHit = (
BmnHit*)fDchHits->UncheckedAt(mDch);
421 Double_t alreadyFilled = H0->GetBinContent(FindBinXY(
"dch").first, FindBinXY(
"dch").second);
422 H0->SetBinContent(FindBinXY(
"dch").first, FindBinXY(
"dch").second, alreadyFilled + 1.);
426 if (mTof1 != -1 && mTof2 != -1) {
427 Double_t alreadyFilled =
428 H0->GetBinContent(FindBinXY(
"tof400+tof700").first, FindBinXY(
"tof400+tof700").second);
429 H0->SetBinContent(FindBinXY(
"tof400+tof700").first, FindBinXY(
"tof400+tof700").second,
433 if (mTof1 != -1 && mCsc != -1) {
434 Double_t alreadyFilled =
435 H0->GetBinContent(FindBinXY(
"tof400+csc").first, FindBinXY(
"tof400+csc").second);
436 H0->SetBinContent(FindBinXY(
"tof400+csc").first, FindBinXY(
"tof400+csc").second,
440 if (mTof1 != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
441 Double_t alreadyFilled =
442 H0->GetBinContent(FindBinXY(
"tof400+dch").first, FindBinXY(
"tof400+dch").second);
443 H0->SetBinContent(FindBinXY(
"tof400+dch").first, FindBinXY(
"tof400+dch").second,
447 if (mTof2 != -1 && mCsc != -1) {
448 Double_t alreadyFilled =
449 H0->GetBinContent(FindBinXY(
"tof700+csc").first, FindBinXY(
"tof700+csc").second);
450 H0->SetBinContent(FindBinXY(
"tof700+csc").first, FindBinXY(
"tof700+csc").second,
454 if (mTof2 != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
455 Double_t alreadyFilled =
456 H0->GetBinContent(FindBinXY(
"tof700+dch").first, FindBinXY(
"tof700+dch").second);
457 H0->SetBinContent(FindBinXY(
"tof700+dch").first, FindBinXY(
"tof700+dch").second,
461 if (mCsc != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
462 Double_t alreadyFilled =
463 H0->GetBinContent(FindBinXY(
"csc+dch").first, FindBinXY(
"csc+dch").second);
464 H0->SetBinContent(FindBinXY(
"csc+dch").first, FindBinXY(
"csc+dch").second, alreadyFilled + 1.);
468 if (mTof1 != -1 && mTof2 != -1 && mCsc != -1) {
469 Double_t alreadyFilled = H1->GetBinContent(FindBinXY(
"tof400+tof700+csc").first,
470 FindBinXY(
"tof400+tof700+csc").second);
471 H1->SetBinContent(FindBinXY(
"tof400+tof700+csc").first, FindBinXY(
"tof400+tof700+csc").second,
475 if (mTof1 != -1 && mTof2 != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
476 Double_t alreadyFilled = H1->GetBinContent(FindBinXY(
"tof400+tof700+dch").first,
477 FindBinXY(
"tof400+tof700+dch").second);
478 H1->SetBinContent(FindBinXY(
"tof400+tof700+dch").first, FindBinXY(
"tof400+tof700+dch").second,
482 if (mTof2 != -1 && mCsc != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
483 Double_t alreadyFilled =
484 H1->GetBinContent(FindBinXY(
"tof700+csc+dch").first, FindBinXY(
"tof700+csc+dch").second);
485 H1->SetBinContent(FindBinXY(
"tof700+csc+dch").first, FindBinXY(
"tof700+csc+dch").second,
489 if (mTof1 != -1 && mCsc != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
490 Double_t alreadyFilled =
491 H1->GetBinContent(FindBinXY(
"tof400+csc+dch").first, FindBinXY(
"tof400+csc+dch").second);
492 H1->SetBinContent(FindBinXY(
"tof400+csc+dch").first, FindBinXY(
"tof400+csc+dch").second,
497 if (mTof1 != -1 && mTof2 != -1 && mCsc != -1 && (mDch != -1 || mDch1 != -1 || mDch2 != -1)) {
498 Double_t alreadyFilled = H2->GetBinContent(FindBinXY(
"tof400+tof700+csc+dch").first,
499 FindBinXY(
"tof400+tof700+csc+dch").second);
500 H2->SetBinContent(FindBinXY(
"tof400+tof700+csc+dch").first,
501 FindBinXY(
"tof400+tof700+csc+dch").second, alreadyFilled + 1.);
505 vector<BmnHit*> outerTrackerHits{tof400Hit, tof700Hit, cscHit, dchHit};
506 map<Int_t, pair<Double_t, Double_t>> detIdxResXY = GetResiduals(track, outerTrackerHits);
510 pair<Double_t, Double_t> resid =
detector.second;
512 residuals[2 * idx]->Fill(resid.first);
513 residuals[2 * idx + 1]->Fill(resid.second);
522 gSystem->Exec(Form(
"rm bmndst_%d.root", iDst));
531 for (
size_t iBeam = 0; iBeam < fBeams.size(); iBeam++)
532 for (
size_t iTarget = 0; iTarget < fTargets.size(); iTarget++)
533 for (
size_t iTrigger = 0; iTrigger < fTriggers.size(); iTrigger++) {
534 if (nTotalGlobTrack[iBeam][iTarget][iTrigger] == 0)
537 TH2F* H0 = h4[iBeam][iTarget][iTrigger][0];
538 TH2F* H1 = h4[iBeam][iTarget][iTrigger][1];
539 TH2F* H2 = h4[iBeam][iTarget][iTrigger][2];
541 vector<TH2F*> H{H0, H1, H2};
543 for (TH2F* histo : H) {
544 for (Int_t iBinX = 1; iBinX < histo->GetNbinsX() + 1; iBinX++)
545 for (Int_t iBinY = 1; iBinY < histo->GetNbinsY() + 1; iBinY++) {
546 Double_t contentBefore = histo->GetBinContent(iBinX, iBinY);
548 Double_t contentAfter = contentBefore / nTotalGlobTrack[iBeam][iTarget][iTrigger];
549 histo->SetBinContent(iBinX, iBinY, 100. * contentAfter);