190#include "TRestTrackAnalysisProcess.h"
195TRestTrackAnalysisProcess::TRestTrackAnalysisProcess() {
Initialize(); }
197TRestTrackAnalysisProcess::TRestTrackAnalysisProcess(
const char* configFilename) {
203TRestTrackAnalysisProcess::~TRestTrackAnalysisProcess() {
delete fOutputTrackEvent; }
205void TRestTrackAnalysisProcess::LoadDefaultConfig() { SetTitle(
"Default config"); }
211 fInputTrackEvent =
nullptr;
214 fCutsEnabled =
false;
216 fEnableTwistParameters =
false;
219void TRestTrackAnalysisProcess::LoadConfig(
const string& configFilename,
const string& name) {
224 std::vector<string> fObservables;
225 fObservables = TRestEventProcess::ReadObservables();
227 for (
unsigned int i = 0; i < fObservables.size(); i++)
228 if (fObservables[i].find(
"nTracks_LE_") != string::npos) {
229 Double_t energy =
StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
231 fTrack_LE_EnergyObservables.emplace_back(fObservables[i]);
232 fTrack_LE_Threshold.emplace_back(energy);
233 nTracks_LE.emplace_back(0);
236 for (
unsigned int i = 0; i < fObservables.size(); i++)
237 if (fObservables[i].find(
"nTracks_HE_") != string::npos) {
238 Double_t energy =
StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
240 fTrack_HE_EnergyObservables.emplace_back(fObservables[i]);
241 fTrack_HE_Threshold.emplace_back(energy);
242 nTracks_HE.emplace_back(0);
245 for (
unsigned int i = 0; i < fObservables.size(); i++)
246 if (fObservables[i].find(
"nTracks_En_") != string::npos) {
247 Double_t energy =
StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
249 fTrack_En_EnergyObservables.emplace_back(fObservables[i]);
250 fTrack_En_Threshold.emplace_back(energy);
251 nTracks_En.emplace_back(0);
254 for (
unsigned int i = 0; i < fObservables.size(); i++)
255 if (fObservables[i].find(
"twistLow_") != string::npos) {
256 Double_t tailPercentage =
257 StringToDouble(fObservables[i].substr(9, fObservables[i].length()).c_str());
259 fTwistLowObservables.emplace_back(fObservables[i]);
260 fTwistLowTailPercentage.emplace_back(tailPercentage);
261 fTwistLowValue.emplace_back(0);
264 for (
unsigned int i = 0; i < fObservables.size(); i++)
265 if (fObservables[i].find(
"twistHigh_") != string::npos) {
266 Double_t tailPercentage =
267 StringToDouble(fObservables[i].substr(10, fObservables[i].length()).c_str());
269 fTwistHighObservables.emplace_back(fObservables[i]);
270 fTwistHighTailPercentage.emplace_back(tailPercentage);
271 fTwistHighValue.emplace_back(0);
274 for (
unsigned int i = 0; i < fObservables.size(); i++)
275 if (fObservables[i].find(
"twistBalance_") != string::npos) {
276 Double_t tailPercentage =
277 StringToDouble(fObservables[i].substr(13, fObservables[i].length()).c_str());
279 fTwistBalanceObservables.emplace_back(fObservables[i]);
280 fTwistBalanceTailPercentage.emplace_back(tailPercentage);
281 fTwistBalanceValue.emplace_back(0);
284 for (
unsigned int i = 0; i < fObservables.size(); i++)
285 if (fObservables[i].find(
"twistRatio_") != string::npos) {
286 Double_t tailPercentage =
287 StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
289 fTwistRatioObservables.emplace_back(fObservables[i]);
290 fTwistRatioTailPercentage.emplace_back(tailPercentage);
291 fTwistRatioValue.emplace_back(0);
294 for (
unsigned int i = 0; i < fObservables.size(); i++)
295 if (fObservables[i].find(
"twistWeightedLow_") != string::npos) {
296 Double_t tailPercentage =
297 StringToDouble(fObservables[i].substr(17, fObservables[i].length()).c_str());
299 fTwistWeightedLowObservables.emplace_back(fObservables[i]);
300 fTwistWeightedLowTailPercentage.emplace_back(tailPercentage);
301 fTwistWeightedLowValue.emplace_back(0);
304 for (
unsigned int i = 0; i < fObservables.size(); i++)
305 if (fObservables[i].find(
"twistWeightedHigh_") != string::npos) {
306 Double_t tailPercentage =
307 StringToDouble(fObservables[i].substr(18, fObservables[i].length()).c_str());
309 fTwistWeightedHighObservables.emplace_back(fObservables[i]);
310 fTwistWeightedHighTailPercentage.emplace_back(tailPercentage);
311 fTwistWeightedHighValue.emplace_back(0);
314 for (
unsigned int i = 0; i < fObservables.size(); i++)
315 if (fObservables[i].find(
"twistLow_X_") != string::npos) {
316 Double_t tailPercentage =
317 StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
319 fTwistLowObservables_X.emplace_back(fObservables[i]);
320 fTwistLowTailPercentage_X.emplace_back(tailPercentage);
321 fTwistLowValue_X.emplace_back(0);
324 for (
unsigned int i = 0; i < fObservables.size(); i++)
325 if (fObservables[i].find(
"twistHigh_X_") != string::npos) {
326 Double_t tailPercentage =
327 StringToDouble(fObservables[i].substr(12, fObservables[i].length()).c_str());
329 fTwistHighObservables_X.emplace_back(fObservables[i]);
330 fTwistHighTailPercentage_X.emplace_back(tailPercentage);
331 fTwistHighValue_X.emplace_back(0);
334 for (
unsigned int i = 0; i < fObservables.size(); i++)
335 if (fObservables[i].find(
"twistBalance_X_") != string::npos) {
336 Double_t tailPercentage =
337 StringToDouble(fObservables[i].substr(15, fObservables[i].length()).c_str());
339 fTwistBalanceObservables_X.emplace_back(fObservables[i]);
340 fTwistBalanceTailPercentage_X.emplace_back(tailPercentage);
341 fTwistBalanceValue_X.emplace_back(0);
344 for (
unsigned int i = 0; i < fObservables.size(); i++)
345 if (fObservables[i].find(
"twistRatio_X_") != string::npos) {
346 Double_t tailPercentage =
347 StringToDouble(fObservables[i].substr(13, fObservables[i].length()).c_str());
349 fTwistRatioObservables_X.emplace_back(fObservables[i]);
350 fTwistRatioTailPercentage_X.emplace_back(tailPercentage);
351 fTwistRatioValue_X.emplace_back(0);
354 for (
unsigned int i = 0; i < fObservables.size(); i++)
355 if (fObservables[i].find(
"twistWeightedLow_X_") != string::npos) {
356 Double_t tailPercentage =
357 StringToDouble(fObservables[i].substr(19, fObservables[i].length()).c_str());
359 fTwistWeightedLowObservables_X.emplace_back(fObservables[i]);
360 fTwistWeightedLowTailPercentage_X.emplace_back(tailPercentage);
361 fTwistWeightedLowValue_X.emplace_back(0);
364 for (
unsigned int i = 0; i < fObservables.size(); i++)
365 if (fObservables[i].find(
"twistWeightedHigh_X_") != string::npos) {
366 Double_t tailPercentage =
367 StringToDouble(fObservables[i].substr(20, fObservables[i].length()).c_str());
369 fTwistWeightedHighObservables_X.emplace_back(fObservables[i]);
370 fTwistWeightedHighTailPercentage_X.emplace_back(tailPercentage);
371 fTwistWeightedHighValue_X.emplace_back(0);
374 for (
unsigned int i = 0; i < fObservables.size(); i++)
375 if (fObservables[i].find(
"twistLow_Y_") != string::npos) {
376 Double_t tailPercentage =
377 StringToDouble(fObservables[i].substr(11, fObservables[i].length()).c_str());
379 fTwistLowObservables_Y.emplace_back(fObservables[i]);
380 fTwistLowTailPercentage_Y.emplace_back(tailPercentage);
381 fTwistLowValue_Y.emplace_back(0);
384 for (
unsigned int i = 0; i < fObservables.size(); i++)
385 if (fObservables[i].find(
"twistHigh_Y_") != string::npos) {
386 Double_t tailPercentage =
387 StringToDouble(fObservables[i].substr(12, fObservables[i].length()).c_str());
389 fTwistHighObservables_Y.emplace_back(fObservables[i]);
390 fTwistHighTailPercentage_Y.emplace_back(tailPercentage);
391 fTwistHighValue_Y.emplace_back(0);
394 for (
unsigned int i = 0; i < fObservables.size(); i++)
395 if (fObservables[i].find(
"twistBalance_Y_") != string::npos) {
396 Double_t tailPercentage =
397 StringToDouble(fObservables[i].substr(15, fObservables[i].length()).c_str());
399 fTwistBalanceObservables_Y.emplace_back(fObservables[i]);
400 fTwistBalanceTailPercentage_Y.emplace_back(tailPercentage);
401 fTwistBalanceValue_Y.emplace_back(0);
404 for (
unsigned int i = 0; i < fObservables.size(); i++)
405 if (fObservables[i].find(
"twistRatio_Y_") != string::npos) {
406 Double_t tailPercentage =
407 StringToDouble(fObservables[i].substr(13, fObservables[i].length()).c_str());
409 fTwistRatioObservables_Y.emplace_back(fObservables[i]);
410 fTwistRatioTailPercentage_Y.emplace_back(tailPercentage);
411 fTwistRatioValue_Y.emplace_back(0);
414 for (
unsigned int i = 0; i < fObservables.size(); i++)
415 if (fObservables[i].find(
"twistWeightedLow_Y_") != string::npos) {
416 Double_t tailPercentage =
417 StringToDouble(fObservables[i].substr(19, fObservables[i].length()).c_str());
419 fTwistWeightedLowObservables_Y.emplace_back(fObservables[i]);
420 fTwistWeightedLowTailPercentage_Y.emplace_back(tailPercentage);
421 fTwistWeightedLowValue_Y.emplace_back(0);
424 for (
unsigned int i = 0; i < fObservables.size(); i++)
425 if (fObservables[i].find(
"twistWeightedHigh_Y_") != string::npos) {
426 Double_t tailPercentage =
427 StringToDouble(fObservables[i].substr(20, fObservables[i].length()).c_str());
429 fTwistWeightedHighObservables_Y.emplace_back(fObservables[i]);
430 fTwistWeightedHighTailPercentage_Y.emplace_back(tailPercentage);
431 fTwistWeightedHighValue_Y.emplace_back(0);
439 for (
int tck = 0; tck < fInputTrackEvent->GetNumberOfTracks(); tck++)
440 fOutputTrackEvent->AddTrack(fInputTrackEvent->GetTrack(tck));
443 fInputTrackEvent->PrintOnlyTracks();
446 Int_t nTracksX = 0, nTracksY = 0, nTracksXYZ = 0;
447 nTracksX = fInputTrackEvent->GetNumberOfTracks(
"X");
448 nTracksY = fInputTrackEvent->GetNumberOfTracks(
"Y");
449 nTracksXYZ = fInputTrackEvent->GetNumberOfTracks(
"XYZ");
459 for (
unsigned int n = 0; n < nTracks_HE.size(); n++) nTracks_HE[n] = 0;
461 for (
unsigned int n = 0; n < nTracks_LE.size(); n++) nTracks_LE[n] = 0;
463 for (
unsigned int n = 0; n < nTracks_En.size(); n++) nTracks_En[n] = 0;
465 for (
int tck = 0; tck < fInputTrackEvent->GetNumberOfTracks(); tck++) {
466 if (!fInputTrackEvent->isTopLevel(tck))
continue;
468 TRestTrack* t = fInputTrackEvent->GetTrack(tck);
469 Double_t en = t->GetEnergy();
471 if ((t->isXYZ()) || (t->isXZ()) || (t->isYZ())) {
473 for (
unsigned int n = 0; n < fTrack_HE_EnergyObservables.size(); n++)
474 if (en > fTrack_HE_Threshold[n]) nTracks_HE[n]++;
476 for (
unsigned int n = 0; n < fTrack_LE_EnergyObservables.size(); n++)
477 if (en < fTrack_LE_Threshold[n]) nTracks_LE[n]++;
479 for (
unsigned int n = 0; n < fTrack_En_EnergyObservables.size(); n++)
480 if (en > fTrack_En_Threshold[n] - fDeltaEnergy && en < fTrack_En_Threshold[n] + fDeltaEnergy)
485 for (
unsigned int n = 0; n < fTrack_LE_EnergyObservables.size(); n++) {
489 for (
unsigned int n = 0; n < fTrack_HE_EnergyObservables.size(); n++) {
493 for (
unsigned int n = 0; n < fTrack_En_EnergyObservables.size(); n++) {
498 TRestTrack* tXYZ = fInputTrackEvent->GetMaxEnergyTrack(
"XYZ");
499 TRestTrack* tX = fInputTrackEvent->GetMaxEnergyTrack(
"X");
500 TRestTrack* tY = fInputTrackEvent->GetMaxEnergyTrack(
"Y");
502 if (fEnableTwistParameters) {
505 Double_t twist = -1, twistWeighted = -1;
507 for (
unsigned int n = 0; n < fTwistWeightedHighValue.size(); n++) fTwistWeightedHighValue[n] = -1;
509 for (
unsigned int n = 0; n < fTwistWeightedLowValue.size(); n++) fTwistWeightedLowValue[n] = -1;
511 for (
unsigned int n = 0; n < fTwistLowValue.size(); n++) fTwistLowValue[n] = -1;
513 for (
unsigned int n = 0; n < fTwistHighValue.size(); n++) fTwistHighValue[n] = -1;
515 for (
unsigned int n = 0; n < fTwistBalanceValue.size(); n++) fTwistBalanceValue[n] = -1;
517 for (
unsigned int n = 0; n < fTwistRatioValue.size(); n++) fTwistRatioValue[n] = -1;
521 Int_t Nhits = hits->GetNumberOfHits();
526 for (
unsigned int n = 0; n < fTwistLowObservables.size(); n++) {
527 Int_t Nend = fTwistLowTailPercentage[n] * Nhits / 100.;
529 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
531 if (twistStart < twistEnd)
532 fTwistLowValue[n] = twistStart;
534 fTwistLowValue[n] = twistEnd;
537 for (
unsigned int n = 0; n < fTwistHighObservables.size(); n++) {
538 Int_t Nend = fTwistHighTailPercentage[n] * Nhits / 100.;
540 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
542 if (twistStart > twistEnd)
543 fTwistHighValue[n] = twistStart;
545 fTwistHighValue[n] = twistEnd;
548 for (
unsigned int n = 0; n < fTwistBalanceObservables.size(); n++) {
549 Int_t Nend = fTwistBalanceTailPercentage[n] * Nhits / 100.;
551 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
553 if (twistStart < twistEnd)
554 fTwistBalanceValue[n] = (twistEnd - twistStart) / (twistEnd + twistStart);
556 fTwistBalanceValue[n] = (twistStart - twistEnd) / (twistEnd + twistStart);
559 for (
unsigned int n = 0; n < fTwistRatioObservables.size(); n++) {
560 Int_t Nend = fTwistRatioTailPercentage[n] * Nhits / 100.;
562 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
564 if (twistStart > twistEnd) {
565 if (twistEnd <= 0) twistEnd = -1;
566 fTwistRatioValue[n] = twistStart / twistEnd;
568 if (twistStart <= 0) twistStart = -1;
569 fTwistRatioValue[n] = twistEnd / twistStart;
573 for (
unsigned int n = 0; n < fTwistWeightedLowObservables.size(); n++) {
574 Int_t Nend = fTwistWeightedLowTailPercentage[n] * Nhits / 100.;
578 if (twistStart < twistEnd)
579 fTwistWeightedLowValue[n] = twistStart;
581 fTwistWeightedLowValue[n] = twistEnd;
584 for (
unsigned int n = 0; n < fTwistWeightedHighObservables.size(); n++) {
585 Int_t Nend = fTwistWeightedHighTailPercentage[n] * Nhits / 100.;
589 if (twistStart > twistEnd)
590 fTwistWeightedHighValue[n] = twistStart;
592 fTwistWeightedHighValue[n] = twistEnd;
596 for (
unsigned int n = 0; n < fTwistLowObservables.size(); n++) {
600 for (
unsigned int n = 0; n < fTwistHighObservables.size(); n++) {
604 for (
unsigned int n = 0; n < fTwistBalanceObservables.size(); n++) {
608 for (
unsigned int n = 0; n < fTwistRatioObservables.size(); n++) {
612 for (
unsigned int n = 0; n < fTwistWeightedLowObservables.size(); n++) {
613 SetObservableValue((
string)fTwistWeightedLowObservables[n], fTwistWeightedLowValue[n]);
616 for (
unsigned int n = 0; n < fTwistWeightedHighObservables.size(); n++) {
617 SetObservableValue((
string)fTwistWeightedHighObservables[n], fTwistWeightedHighValue[n]);
626 Double_t twist_X = -1, twistWeighted_X = -1;
628 for (
unsigned int n = 0; n < fTwistWeightedHighValue_X.size(); n++) fTwistWeightedHighValue_X[n] = -1;
630 for (
unsigned int n = 0; n < fTwistWeightedLowValue_X.size(); n++) fTwistWeightedLowValue_X[n] = -1;
632 for (
unsigned int n = 0; n < fTwistLowValue_X.size(); n++) fTwistLowValue_X[n] = -1;
634 for (
unsigned int n = 0; n < fTwistHighValue_X.size(); n++) fTwistHighValue_X[n] = -1;
636 for (
unsigned int n = 0; n < fTwistBalanceValue_X.size(); n++) fTwistBalanceValue_X[n] = -1;
638 for (
unsigned int n = 0; n < fTwistRatioValue_X.size(); n++) fTwistRatioValue_X[n] = -1;
642 Int_t Nhits = hits->GetNumberOfHits();
647 for (
unsigned int n = 0; n < fTwistLowObservables_X.size(); n++) {
648 Int_t Nend = fTwistLowTailPercentage_X[n] * Nhits / 100.;
650 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
652 if (twistStart < twistEnd)
653 fTwistLowValue_X[n] = twistStart;
655 fTwistLowValue_X[n] = twistEnd;
658 for (
unsigned int n = 0; n < fTwistHighObservables_X.size(); n++) {
659 Int_t Nend = fTwistHighTailPercentage_X[n] * Nhits / 100.;
661 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
663 if (twistStart > twistEnd)
664 fTwistHighValue_X[n] = twistStart;
666 fTwistHighValue_X[n] = twistEnd;
669 for (
unsigned int n = 0; n < fTwistBalanceObservables_X.size(); n++) {
670 Int_t Nend = fTwistBalanceTailPercentage_X[n] * Nhits / 100.;
672 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
674 if (twistStart < twistEnd)
675 fTwistBalanceValue_X[n] = (twistEnd - twistStart) / (twistEnd + twistStart);
677 fTwistBalanceValue_X[n] = (twistStart - twistEnd) / (twistEnd + twistStart);
680 for (
unsigned int n = 0; n < fTwistRatioObservables_X.size(); n++) {
681 Int_t Nend = fTwistRatioTailPercentage_X[n] * Nhits / 100.;
683 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
685 if (twistStart > twistEnd) {
686 if (twistEnd <= 0) twistEnd = -1;
687 fTwistRatioValue[n] = twistStart / twistEnd;
689 if (twistStart <= 0) twistStart = -1;
690 fTwistRatioValue[n] = twistEnd / twistStart;
694 for (
unsigned int n = 0; n < fTwistWeightedLowObservables_X.size(); n++) {
695 Int_t Nend = fTwistWeightedLowTailPercentage_X[n] * Nhits / 100.;
699 if (twistStart < twistEnd)
700 fTwistWeightedLowValue_X[n] = twistStart;
702 fTwistWeightedLowValue_X[n] = twistEnd;
705 for (
unsigned int n = 0; n < fTwistWeightedHighObservables_X.size(); n++) {
706 Int_t Nend = fTwistWeightedHighTailPercentage_X[n] * Nhits / 100.;
710 if (twistStart > twistEnd)
711 fTwistWeightedHighValue_X[n] = twistStart;
713 fTwistWeightedHighValue_X[n] = twistEnd;
717 for (
unsigned int n = 0; n < fTwistLowObservables_X.size(); n++) {
721 for (
unsigned int n = 0; n < fTwistHighObservables_X.size(); n++) {
725 for (
unsigned int n = 0; n < fTwistBalanceObservables_X.size(); n++) {
729 for (
unsigned int n = 0; n < fTwistRatioObservables_X.size(); n++) {
733 for (
unsigned int n = 0; n < fTwistWeightedLowObservables_X.size(); n++) {
734 SetObservableValue((
string)fTwistWeightedLowObservables_X[n], fTwistWeightedLowValue_X[n]);
737 for (
unsigned int n = 0; n < fTwistWeightedHighObservables_X.size(); n++) {
738 SetObservableValue((
string)fTwistWeightedHighObservables_X[n], fTwistWeightedHighValue_X[n]);
747 Double_t twist_Y = -1, twistWeighted_Y = -1;
749 for (
unsigned int n = 0; n < fTwistWeightedHighValue_Y.size(); n++) fTwistWeightedHighValue_Y[n] = -1;
751 for (
unsigned int n = 0; n < fTwistWeightedLowValue_Y.size(); n++) fTwistWeightedLowValue_Y[n] = -1;
753 for (
unsigned int n = 0; n < fTwistLowValue_Y.size(); n++) fTwistLowValue_Y[n] = -1;
755 for (
unsigned int n = 0; n < fTwistHighValue_Y.size(); n++) fTwistHighValue_Y[n] = -1;
757 for (
unsigned int n = 0; n < fTwistBalanceValue_Y.size(); n++) fTwistBalanceValue_Y[n] = -1;
759 for (
unsigned int n = 0; n < fTwistRatioValue_Y.size(); n++) fTwistRatioValue_Y[n] = -1;
763 Int_t Nhits = hits->GetNumberOfHits();
768 for (
unsigned int n = 0; n < fTwistLowObservables_Y.size(); n++) {
769 Int_t Nend = fTwistLowTailPercentage_Y[n] * Nhits / 100.;
771 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
773 if (twistStart < twistEnd)
774 fTwistLowValue_Y[n] = twistStart;
776 fTwistLowValue_Y[n] = twistEnd;
779 for (
unsigned int n = 0; n < fTwistHighObservables_Y.size(); n++) {
780 Int_t Nend = fTwistHighTailPercentage_Y[n] * Nhits / 100.;
782 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
784 if (twistStart > twistEnd)
785 fTwistHighValue_Y[n] = twistStart;
787 fTwistHighValue_Y[n] = twistEnd;
790 for (
unsigned int n = 0; n < fTwistBalanceObservables_Y.size(); n++) {
791 Int_t Nend = fTwistBalanceTailPercentage_Y[n] * Nhits / 100.;
793 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
795 if (twistStart < twistEnd)
796 fTwistBalanceValue_Y[n] = (twistEnd - twistStart) / (twistEnd + twistStart);
798 fTwistBalanceValue_Y[n] = (twistStart - twistEnd) / (twistEnd + twistStart);
801 for (
unsigned int n = 0; n < fTwistRatioObservables_Y.size(); n++) {
802 Int_t Nend = fTwistRatioTailPercentage_Y[n] * Nhits / 100.;
804 Double_t twistEnd = hits->
GetHitsTwist(Nhits - Nend, Nhits);
806 if (twistStart > twistEnd) {
807 if (twistEnd <= 0) twistEnd = -1;
808 fTwistRatioValue[n] = twistStart / twistEnd;
810 if (twistStart <= 0) twistStart = -1;
811 fTwistRatioValue[n] = twistEnd / twistStart;
815 for (
unsigned int n = 0; n < fTwistWeightedLowObservables_Y.size(); n++) {
816 Int_t Nend = fTwistWeightedLowTailPercentage_Y[n] * Nhits / 100.;
820 if (twistStart < twistEnd)
821 fTwistWeightedLowValue_Y[n] = twistStart;
823 fTwistWeightedLowValue_Y[n] = twistEnd;
826 for (
unsigned int n = 0; n < fTwistWeightedHighObservables_Y.size(); n++) {
827 Int_t Nend = fTwistWeightedHighTailPercentage_Y[n] * Nhits / 100.;
831 if (twistStart > twistEnd)
832 fTwistWeightedHighValue_Y[n] = twistStart;
834 fTwistWeightedHighValue_Y[n] = twistEnd;
838 for (
unsigned int n = 0; n < fTwistLowObservables_Y.size(); n++) {
842 for (
unsigned int n = 0; n < fTwistHighObservables_Y.size(); n++) {
846 for (
unsigned int n = 0; n < fTwistBalanceObservables_Y.size(); n++) {
850 for (
unsigned int n = 0; n < fTwistRatioObservables_Y.size(); n++) {
854 for (
unsigned int n = 0; n < fTwistWeightedLowObservables_Y.size(); n++) {
855 SetObservableValue((
string)fTwistWeightedLowObservables_Y[n], fTwistWeightedLowValue_Y[n]);
858 for (
unsigned int n = 0; n < fTwistWeightedHighObservables_Y.size(); n++) {
859 SetObservableValue((
string)fTwistWeightedHighObservables_Y[n], fTwistWeightedHighValue_Y[n]);
869 Double_t tckMaxEnXYZ = 0, tckMaxEnX = 0, tckMaxEnY = 0;
870 Double_t tckMaxXYZ_SigmaX = 0, tckMaxXYZ_SigmaY = 0, tckMaxXYZ_SigmaZ = 0;
871 Double_t tckMaxXZ_SigmaX = 0;
872 Double_t tckMaxXZ_SigmaZ = 0;
873 Double_t tckMaxYZ_SigmaY = 0;
874 Double_t tckMaxYZ_SigmaZ = 0;
875 Double_t tckMaxXZ_nHits = 0;
876 Double_t tckMaxYZ_nHits = 0;
877 Double_t tckMaxXYZ_gausSigmaX = 0, tckMaxXYZ_gausSigmaY = 0, tckMaxXYZ_gausSigmaZ = 0;
878 Double_t tckMaxXZ_gausSigmaX = 0, tckMaxXZ_gausSigmaZ_XZ = 0;
879 Double_t tckMaxYZ_gausSigmaY = 0, tckMaxYZ_gausSigmaZ_YZ = 0;
880 Double_t tckMaxTrack_XYZ_GaussSigmaZ = 0;
881 Double_t tckMaxTrack_XYZ_SigmaZ2 = 0;
882 Double_t tckMaxTrack_XYZ_skewXY = 0, tckMaxTrack_XYZ_skewZ = 0;
884 if (fInputTrackEvent->GetMaxEnergyTrack()) {
885 tckMaxEnXYZ = fInputTrackEvent->GetMaxEnergyTrack()->GetEnergy();
886 tckMaxXYZ_SigmaX = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetSigmaX();
887 tckMaxXYZ_SigmaY = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetSigmaY();
888 tckMaxXYZ_SigmaZ = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetSigmaZ2();
889 RESTDebug <<
"id: " << fInputTrackEvent->GetID() <<
" " << fInputTrackEvent->GetSubEventTag()
890 <<
" tckMaxEnXYZ: " << tckMaxEnXYZ <<
RESTendl;
891 tckMaxXYZ_gausSigmaX = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetGaussSigmaX();
892 tckMaxXYZ_gausSigmaY = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetGaussSigmaY();
893 tckMaxXYZ_gausSigmaZ = fInputTrackEvent->GetMaxEnergyTrack()->GetHits()->
GetGaussSigmaZ();
903 if (fInputTrackEvent->GetMaxEnergyTrack(
"X")) {
904 tckMaxEnX = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetEnergy();
905 tckMaxXZ_SigmaX = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetHits()->
GetSigmaX();
906 tckMaxXZ_SigmaZ = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetHits()->
GetSigmaZ2();
907 tckMaxXZ_gausSigmaX = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetHits()->
GetGaussSigmaX();
908 tckMaxXZ_gausSigmaZ_XZ = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetHits()->
GetGaussSigmaZ();
909 tckMaxXZ_nHits = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetNumberOfHits();
910 RESTDebug <<
"id: " << fInputTrackEvent->GetID() <<
" " << fInputTrackEvent->GetSubEventTag()
911 <<
" tckMaxEnX: " << tckMaxEnX <<
RESTendl;
921 if (fInputTrackEvent->GetMaxEnergyTrack(
"Y")) {
922 tckMaxEnY = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetEnergy();
923 tckMaxYZ_SigmaY = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetHits()->
GetSigmaY();
924 tckMaxYZ_SigmaZ = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetHits()->
GetSigmaZ2();
925 tckMaxYZ_gausSigmaY = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetHits()->
GetGaussSigmaY();
926 tckMaxYZ_gausSigmaZ_YZ = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetHits()->
GetGaussSigmaZ();
927 tckMaxYZ_nHits = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetNumberOfHits();
928 RESTDebug <<
"id: " << fInputTrackEvent->GetID() <<
" " << fInputTrackEvent->GetSubEventTag()
929 <<
" tckMaxEnY: " << tckMaxEnY <<
RESTendl;
939 SetObservableValue(
"MaxTrackxySigmaGausBalance", (tckMaxXZ_gausSigmaX - tckMaxYZ_gausSigmaY) /
940 (tckMaxXZ_gausSigmaX + tckMaxYZ_gausSigmaY));
943 (tckMaxXZ_SigmaX - tckMaxYZ_SigmaY) / (tckMaxXZ_SigmaX + tckMaxYZ_SigmaY));
945 SetObservableValue(
"MaxTrackEnergyBalanceXY", (tckMaxEnX - tckMaxEnY) / (tckMaxEnX + tckMaxEnY));
947 Double_t tckMaxEnergy = tckMaxEnX + tckMaxEnY + tckMaxEnXYZ;
949 Double_t totalEnergy = fInputTrackEvent->GetEnergy();
951 Double_t trackEnergyRatio = (totalEnergy - tckMaxEnergy) / totalEnergy;
956 SetObservableValue(
"MaxTrackZSigmaGausBalance", (tckMaxXZ_gausSigmaZ_XZ - tckMaxYZ_gausSigmaZ_YZ) /
957 (tckMaxXZ_gausSigmaZ_XZ + tckMaxYZ_gausSigmaZ_YZ));
960 (tckMaxXZ_SigmaZ - tckMaxYZ_SigmaZ) / (tckMaxXZ_SigmaZ + tckMaxYZ_SigmaZ));
962 SetObservableValue(
"MaxTrackEnergyBalanceXY", (tckMaxEnX - tckMaxEnY) / (tckMaxEnX + tckMaxEnY));
967 if (fInputTrackEvent->GetMaxEnergyTrack(
"X"))
968 hitsXZ = fInputTrackEvent->GetMaxEnergyTrack(
"X")->GetHits();
969 if (fInputTrackEvent->GetMaxEnergyTrack(
"Y"))
970 hitsYZ = fInputTrackEvent->GetMaxEnergyTrack(
"Y")->GetHits();
972 auto hitsBoth = {hitsXZ, hitsYZ};
974 for (
auto arg : hitsBoth) {
975 if (arg ==
nullptr)
continue;
976 for (
unsigned int n = 0; n < arg->GetNumberOfHits(); n++) {
978 Double_t eDep = arg->GetEnergy(n);
980 Double_t x = arg->GetX(n);
981 Double_t y = arg->GetY(n);
982 Double_t z = arg->GetZ(n);
984 auto time = arg->GetTime(n);
985 auto type = arg->GetType(n);
987 hits.
AddHit({x, y, z}, eDep, time, type);
992 tckMaxTrack_XYZ_skewZ = hits.
GetSkewZ();
993 tckMaxTrack_XYZ_skewXY = hits.
GetSkewXY();
1001 Double_t tckSecondMaxXYZ_SigmaX = 0, tckSecondMaxXYZ_SigmaY = 0;
1002 Double_t tckSecondMaxXYZ_gausSigmaX = 0, tckSecondMaxXYZ_gausSigmaY = 0;
1003 Double_t tckSecondMaxXZ_gausSigmaX = 0, tckSecondMaxXZ_gausSigmaZ_XZ = 0;
1004 Double_t tckSecondMaxYZ_gausSigmaY = 0, tckSecondMaxYZ_gausSigmaZ_YZ = 0;
1006 if (fInputTrackEvent->GetSecondMaxEnergyTrack() !=
nullptr) {
1007 tckSecondMaxXYZ_SigmaX = fInputTrackEvent->GetSecondMaxEnergyTrack()->GetHits()->
GetSigmaX();
1008 tckSecondMaxXYZ_SigmaY = fInputTrackEvent->GetSecondMaxEnergyTrack()->GetHits()->
GetSigmaY();
1009 tckSecondMaxXYZ_gausSigmaX = fInputTrackEvent->GetSecondMaxEnergyTrack()->GetHits()->
GetGaussSigmaX();
1010 tckSecondMaxXYZ_gausSigmaY = fInputTrackEvent->GetSecondMaxEnergyTrack()->GetHits()->
GetGaussSigmaY();
1013 Double_t tckSecondMaxEnergy_X = 0;
1014 Double_t tckSecondMaxXZ_SigmaX = 0;
1015 Double_t tckSecondMaxXZ_SigmaZ = 0;
1016 if (fInputTrackEvent->GetSecondMaxEnergyTrack(
"X") !=
nullptr) {
1017 tckSecondMaxXZ_SigmaX = fInputTrackEvent->GetSecondMaxEnergyTrack(
"X")->GetHits()->
GetSigmaX();
1018 tckSecondMaxXZ_SigmaZ = fInputTrackEvent->GetSecondMaxEnergyTrack(
"X")->GetHits()->
GetSigmaZ2();
1019 tckSecondMaxEnergy_X = fInputTrackEvent->GetSecondMaxEnergyTrack(
"X")->GetEnergy();
1020 tckSecondMaxXZ_gausSigmaX =
1021 fInputTrackEvent->GetSecondMaxEnergyTrack(
"X")->GetHits()->
GetGaussSigmaX();
1022 tckSecondMaxXZ_gausSigmaZ_XZ =
1023 fInputTrackEvent->GetSecondMaxEnergyTrack(
"X")->GetHits()->
GetGaussSigmaZ();
1026 Double_t tckSecondMaxEnergy_Y = 0;
1027 Double_t tckSecondMaxYZ_SigmaY = 0;
1028 Double_t tckSecondMaxYZ_SigmaZ = 0;
1029 if (fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y") !=
nullptr) {
1030 tckSecondMaxYZ_SigmaY = fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y")->GetHits()->
GetSigmaY();
1031 tckSecondMaxYZ_SigmaZ = fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y")->GetHits()->
GetSigmaZ2();
1032 tckSecondMaxEnergy_Y = fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y")->GetEnergy();
1033 tckSecondMaxYZ_gausSigmaY =
1034 fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y")->GetHits()->
GetGaussSigmaY();
1035 tckSecondMaxYZ_gausSigmaZ_YZ =
1036 fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y")->GetHits()->
GetGaussSigmaZ();
1039 Double_t trackSecondMaxEnergy = tckSecondMaxEnergy_X + tckSecondMaxEnergy_Y;
1040 if (fInputTrackEvent->GetSecondMaxEnergyTrack(
"XYZ") !=
nullptr) {
1041 trackSecondMaxEnergy = fInputTrackEvent->GetSecondMaxEnergyTrack(
"XYZ")->GetEnergy();
1047 SetObservableValue((
string)
"SecondMaxTrackGaussSigmaX", tckSecondMaxXYZ_gausSigmaX);
1048 SetObservableValue((
string)
"SecondMaxTrackGaussSigmaY", tckSecondMaxXYZ_gausSigmaY);
1053 SetObservableValue((
string)
"SecondMaxTrack_XZ_GaussSigmaX", tckSecondMaxXZ_gausSigmaX);
1054 SetObservableValue((
string)
"SecondMaxTrack_XZ_GaussSigmaZ", tckSecondMaxXZ_gausSigmaZ_XZ);
1059 SetObservableValue((
string)
"SecondMaxTrack_YZ_GaussSigmaY", tckSecondMaxYZ_gausSigmaY);
1060 SetObservableValue((
string)
"SecondMaxTrack_YZ_GaussSigmaZ", tckSecondMaxYZ_gausSigmaZ_YZ);
1063 (tckSecondMaxXZ_gausSigmaX - tckSecondMaxYZ_gausSigmaY) /
1064 (tckSecondMaxXZ_gausSigmaX + tckSecondMaxYZ_gausSigmaY));
1066 SetObservableValue(
"SecondMaxTrackxySigmaBalance", (tckSecondMaxXZ_SigmaX - tckSecondMaxYZ_SigmaY) /
1067 (tckSecondMaxXZ_SigmaX + tckSecondMaxYZ_SigmaY));
1068 SetObservableValue(
"SecondMaxTrackZSigmaBalance", (tckSecondMaxXZ_SigmaZ - tckSecondMaxYZ_SigmaZ) /
1069 (tckSecondMaxXZ_SigmaZ + tckSecondMaxYZ_SigmaZ));
1071 (tckSecondMaxXZ_gausSigmaZ_XZ - tckSecondMaxYZ_gausSigmaZ_YZ) /
1072 (tckSecondMaxXZ_gausSigmaZ_XZ + tckSecondMaxYZ_gausSigmaZ_YZ));
1073 SetObservableValue(
"SecondMaxTrackEnergyBalanceXY", (tckSecondMaxEnergy_X - tckSecondMaxEnergy_Y) /
1074 (tckSecondMaxEnergy_X + tckSecondMaxEnergy_Y));
1079 Double_t tckLenX = fInputTrackEvent->GetMaxEnergyTrackLength(
"X");
1080 Double_t tckLenY = fInputTrackEvent->GetMaxEnergyTrackLength(
"Y");
1081 Double_t tckLenXYZ = fInputTrackEvent->GetMaxEnergyTrackLength();
1089 Double_t tckVolX = fInputTrackEvent->GetMaxEnergyTrackVolume(
"X");
1090 Double_t tckVolY = fInputTrackEvent->GetMaxEnergyTrackVolume(
"Y");
1091 Double_t tckVolXYZ = fInputTrackEvent->GetMaxEnergyTrackVolume();
1102 Double_t maxX = 0, maxY = 0, maxZ = 0;
1103 Double_t sMaxX = 0, sMaxY = 0, sMaxZ = 0;
1104 Double_t dX = 0, dY = 0, dZ = 0;
1105 Double_t dXZ = 0, dYZ = 0, dXYZ = 0;
1108 TRestTrack* tMax = fInputTrackEvent->GetMaxEnergyTrack();
1110 if (tMax !=
nullptr) {
1111 maxX = tMax->GetMeanPosition().X();
1112 maxY = tMax->GetMeanPosition().Y();
1113 maxZ = tMax->GetMeanPosition().Z();
1121 TRestTrack* tSecondMax = fInputTrackEvent->GetSecondMaxEnergyTrack();
1123 if (tSecondMax !=
nullptr) {
1124 sMaxX = tSecondMax->GetMeanPosition().X();
1125 sMaxY = tSecondMax->GetMeanPosition().Y();
1126 sMaxZ = tSecondMax->GetMeanPosition().Z();
1133 if (sMaxX != 0) dX = abs(maxX - sMaxX);
1134 if (sMaxY != 0) dY = abs(maxY - sMaxY);
1135 if (sMaxZ != 0) dZ = abs(maxZ - sMaxZ);
1137 if (dX != 0 || dY != 0 || dZ != 0) dXYZ = TMath::Sqrt(dX * dX + dY * dY + dZ * dZ);
1142 maxX = 0, maxY = 0, maxZ = 0;
1143 dX = 0, dY = 0, dZ = 0;
1144 tMax = fInputTrackEvent->GetMaxEnergyTrack(
"X");
1145 if (tMax !=
nullptr) {
1146 maxX = tMax->GetMeanPosition().X();
1147 maxZ = tMax->GetMeanPosition().Z();
1153 sMaxX = 0, sMaxY = 0, sMaxZ = 0;
1154 tSecondMax = fInputTrackEvent->GetSecondMaxEnergyTrack(
"X");
1155 if (tSecondMax !=
nullptr) {
1156 sMaxX = tSecondMax->GetMeanPosition().X();
1157 sMaxZ = tSecondMax->GetMeanPosition().Z();
1163 if (sMaxX != 0) dX = abs(maxX - sMaxX);
1164 if (sMaxZ != 0) dZ = abs(maxZ - sMaxZ);
1166 if (dX != 0 || dY != 0 || dZ != 0) dXZ = TMath::Sqrt(dX * dX + dZ * dZ);
1171 maxX = 0, maxY = 0, maxZ = 0;
1172 dX = 0, dY = 0, dZ = 0;
1174 tMax = fInputTrackEvent->GetMaxEnergyTrack(
"Y");
1175 if (tMax !=
nullptr) {
1176 maxY = tMax->GetMeanPosition().Y();
1177 maxZ = tMax->GetMeanPosition().Z();
1183 sMaxX = 0, sMaxY = 0, sMaxZ = 0;
1184 tSecondMax = fInputTrackEvent->GetSecondMaxEnergyTrack(
"Y");
1185 if (tSecondMax !=
nullptr) {
1186 sMaxY = tSecondMax->GetMeanPosition().Y();
1187 sMaxZ = tSecondMax->GetMeanPosition().Z();
1193 if (sMaxY != 0) dY = abs(maxY - sMaxY);
1194 if (sMaxZ != 0) dZ = abs(maxZ - sMaxZ);
1196 if (dX != 0 || dY != 0 || dZ != 0) dYZ = TMath::Sqrt(dY * dY + dZ * dZ);
1199 Double_t dXZ_YZ = 0.5 * TMath::Sqrt(dYZ * dYZ + dXZ * dXZ);
1203 Double_t x = 0, y = 0, z = 0;
1205 if (tXYZ !=
nullptr) {
1206 x = tXYZ->GetMeanPosition().X();
1207 y = tXYZ->GetMeanPosition().Y();
1208 z = tXYZ->GetMeanPosition().Z();
1212 if (tX !=
nullptr) {
1213 x = tX->GetMeanPosition().X();
1214 zxz += tX->GetMeanPosition().Z();
1217 if (tY !=
nullptr) {
1218 y = tY->GetMeanPosition().Y();
1219 zxz += tY->GetMeanPosition().Z();
1223 z = i == 0 ? i : zxz / i;
1235 Double_t evTimeDelay = 0;
1236 if (fPreviousEventTime.size() > 0) evTimeDelay = fInputTrackEvent->GetTime() - fPreviousEventTime.back();
1239 Double_t meanRate = 0;
1240 if (fPreviousEventTime.size() == 100)
1241 meanRate = 100. / (fInputTrackEvent->GetTime() - fPreviousEventTime.front());
1245 if (nTracksX < fNTracksXCut.X() || nTracksX > fNTracksXCut.Y())
return nullptr;
1246 if (nTracksY < fNTracksYCut.X() || nTracksY > fNTracksYCut.Y())
return nullptr;
1251 return fOutputTrackEvent;
1272 fDeltaEnergy = GetDblParameterWithUnits(
"deltaEnergy", 1);
1274 if (
GetParameter(
"cutsEnabled",
"false") ==
"true") fCutsEnabled =
true;
1276 if (
GetParameter(
"enableTwistParameters",
"false") ==
"true") fEnableTwistParameters =
true;
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
It saves a 3-coordinate position and an energy for each punctual deposition.
Double_t GetSkewXY() const
It returns the 2-dimensional skewness on the XY-plane which is a measure of the hits distribution asy...
Double_t GetHitsTwistWeighted(Int_t n, Int_t m) const
Same as GetHitsTwist but weighting with the energy.
Double_t GetGaussSigmaX(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the X-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetSigmaX() const
It calculates the hits standard deviation in the X-coordinate.
Double_t GetHitsTwist(Int_t n, Int_t m) const
A parameter measuring how straight is a given sequence of hits. If the value is close to zero,...
Double_t GetGaussSigmaZ(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Z-coordinate. It adds a hit to the right and a hit to the left,...
void AddHit(const TVector3 &position, Double_t energy, Double_t time=0, REST_HitType type=XYZ)
Adds a new hit to the list of hits using a TVector3.
Double_t GetGaussSigmaY(Double_t error=150.0, Int_t nHitsMin=100000)
It computes the gaussian sigma in the Y-coordinate. It adds a hit to the right and a hit to the left,...
Double_t GetSigmaZ2() const
It returns the hits distribution variance on the Z-axis.
Double_t GetSkewZ() const
It returns the hits distribution skewness, or asymmetry on the Z-axis.
Double_t GetSigmaY() const
It calculates the hits standard deviation in the Y-coordinate.
@ REST_Extreme
show everything
@ REST_Debug
+show the defined debug messages
An analysis REST process to extract valuable information from Track type of data.
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void Initialize() override
Making default settings.
void EndProcess() override
To be executed at the end of the run (outside event loop)
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
Double_t StringToDouble(std::string in)
Gets a double from a string.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.