#include #include #include #include #include #include #include #include "TRestTools.h" #include #include // std::pair, std::make_pair using namespace std; #ifndef RestTask_Extract_entries #define RestTask_Extract_entries //This macro will assign variable "id's" in the Region of interest defined in variables //this was particularly written to assign signalID to the corresponding energy Int_t REST_Extract_entries(TString varName, TString rootFileName, double startVal, double endVal, int nBins = 100) { TRestStringOutput cout; cout << "Variable name : " << varName << endl; cout << "Energy range : ( " << startVal << " , " << endVal << " ) " << endl; if (startVal >= endVal) { cout << "Start or End integration values not properly defined!!!" << endl; return -1; } std::vector inputFilesNew = TRestTools::GetFilesMatchingPattern((string)rootFileName); //map where we are going to store the events entry, eventID and its' corresponding energy map, Double_t> even_in_ROI; //TH1D* h = new TH1D("FitHisto", "FitHisto", nBins, startVal, endVal); TRestRun* run = new TRestRun(); if (inputFilesNew.size() == 0) { cout << "Files not found!" << endl; return -1; } for (unsigned int n = 0; n < inputFilesNew.size(); n++) { run->OpenInputFile(inputFilesNew[n]); run->PrintMetadata(); Int_t obsID = run->GetAnalysisTree()->GetObservableID(varName); //Defining another observable ID for the signal id Int_t obsID_sig = run->GetAnalysisTree()->GetObservableID("eventID"); if (obsID == -1) { cout << endl; cout.setcolor(COLOR_BOLDRED); cout << "No observable \"" << varName << "\" in file " << inputFilesNew[n] << endl; continue; } cout << "Variable name : " << varName << " => obsID: " << obsID << endl << "EventID => obsID_sig: " << obsID_sig << endl; for (int i = 0; i < run->GetEntries(); i++) { //just for debugging purposes //cout << i << endl; // "i" IS LITERARY AN ENTRY run->GetAnalysisTree()->GetBranch(varName)->GetEntry(i); Double_t value = run->GetAnalysisTree()->GetDblObservableValue(obsID); Int_t Ev_ID = run->GetAnalysisTree()->GetEventID(); //Int_t Ev_ID = (int)(run->GetAnalysisTree()->GetDblObservableValue(obsID_sig)); //cout << "EventID: " << Ev_ID << endl; if (value >= startVal && value < endVal) { //in case the energy of the event is in the region of interest {startVal, endVal} we are saving it to the map[make_pair(entry, eventID),event energy] even_in_ROI[make_pair(i,Ev_ID)]=value; } } } for (auto item : even_in_ROI){ cout << "Entry number: " << item.first.first << "; EventID: " << item.first.second << "; Event energy: " << item.second <