Reading Histos from file in process using TProof on TSelector


I am running a TSelector in Proof and I need to read some histograms from an other root file (data/jet_unc.root) in Process. It works in direct, however in Proof it does not work, when I run it, it says multiple times:

[quote]caught exception triggered by signal ‘1’ -1
SysError in TUnixSystem::UnixRecv: recv (Connection reset by peer)
Info in TProofLite::MarkBad:
+++ Message from master at : marking (0.23) as bad
+++ Reason: problems receiving a message in TProof::CollectInputFrom(…)

+++ Message from master at : marking (0.23) as bad
+++ Reason: problems receiving a message in TProof::CollectInputFrom(…)

+++ Most likely your code crashed
+++ Please check the session logs for error messages either using
+++ the ‘Show logs’ button or executing
+++ root [] TProof::Mgr(“”)->GetSessionLogs()->Display("*")

And I dont undersant the error and this is what I am doing:

In MetSign::Begin(TTree * /tree/) I read the histos from the file:

h_phi_reso_pt20 = 0 ;
h_phi_reso_pt50 = 0 ;
h_phi_reso_pt100 = 0 ;

TFile *m_file = new TFile("/data/atlas0/dportill/PerformanceROC/data/jet_unc.root");

h_phi_reso_pt20 = static_cast<TH2F *>(m_file->Get(“phi_reso_pt20”));
if(!h_phi_reso_pt20) std::cerr << “Jet Uncertainty Histogram not valid” << std::endl;
h_phi_reso_pt50 = static_cast<TH2F *>(m_file->Get(“phi_reso_pt50”));
if(!h_phi_reso_pt50) std::cerr << “Jet Uncertainty Histogram not valid” << std::endl;
h_phi_reso_pt100 = static_cast<TH2F *>(m_file->Get(“phi_reso_pt100”));
if(!h_phi_reso_pt100) std::cerr << “Jet Uncertainty Histogram not valid” << std::endl;

and they are already defined in the header:

   TH2F *h_phi_reso_pt20; //!
   TH2F *h_phi_reso_pt50; //!
   TH2F *h_phi_reso_pt100; //!

Then, in MetSign::Process(Long64_t entry) I need to read this histograms with a function:

Double_t VarPhi = MetSign::GetPhiUnc(basejet_eta[i], basejet_phi[i], basejet_pt[i]*basejet_fracUsedInMET[i]*0.001);//PHI RESOLUTION

And this function is defines as:

double MetSign::GetPhiUnc(double jet_eta, double jet_phi,double jet_pt)
  unsigned xbin=0, ybin=0;
  if(-4.5<jet_eta && -3.8>=jet_eta)      xbin=1;
  else if(-3.8<jet_eta && -3.5>=jet_eta) xbin=2;
  else if(-3.5<jet_eta && -3.0>=jet_eta) xbin=3;
  else if(-3.0<jet_eta && -2.7>=jet_eta) xbin=4;
  else if(-2.7<jet_eta && -2.4>=jet_eta) xbin=5;
  else if(-2.4<jet_eta && -1.5>=jet_eta) xbin=6;
  else if(-1.5<jet_eta && -0.5>=jet_eta) xbin=7;
  else if(-0.5<jet_eta &&  0.0>=jet_eta) xbin=8;
  else if(0.0<jet_eta  &&  0.5>=jet_eta) xbin=9;
  else if(0.5<jet_eta  &&  1.5>=jet_eta) xbin=10;
  else if(1.5<jet_eta  &&  2.4>=jet_eta) xbin=11;
  else if(2.4<jet_eta  &&  2.7>=jet_eta) xbin=12;
  else if(2.7<jet_eta  &&  3.0>=jet_eta) xbin=13;
  else if(3.0<jet_eta  &&  3.5>=jet_eta) xbin=14;
  else if(3.5<jet_eta  &&  3.8>=jet_eta) xbin=15;
  else if(3.8<jet_eta                  ) xbin=16;

  ybin = jet_phi>0.0? int(jet_phi/0.4)+9:int(jet_phi/0.4)+8;

  // Stored as bin content = Mean, error = RMS, add them in quadrature
    return sqrt(h_phi_reso_pt20->GetBinContent(xbin, ybin)*h_phi_reso_pt20->GetBinContent(xbin, ybin)+h_phi_reso_pt20->GetBinError(xbin, ybin)*h_phi_reso_pt20->GetBinContent(xbin, ybin));
  else if(jet_pt<100.0)
    return sqrt(h_phi_reso_pt50->GetBinContent(xbin, ybin)*h_phi_reso_pt50->GetBinContent(xbin, ybin)+h_phi_reso_pt50->GetBinError(xbin, ybin)*h_phi_reso_pt50->GetBinContent(xbin, ybin));
  return sqrt(h_phi_reso_pt100->GetBinContent(xbin, ybin)*h_phi_reso_pt100->GetBinContent(xbin, ybin)+h_phi_reso_pt100->GetBinError(xbin, ybin)*h_phi_reso_pt100->GetBinContent(xbin, ybin));

Which is defined in the header as

virtual double  GetPhiUnc(double, double,double);

Does someone knows what i need to do in order to use the information of histograms stored in a root file when I run a TSelector in Proof?

PS: I run it in this way:

  TChain* mychain=new TChain("CollectionTree");


Dear dportill,

Begin is only run on the client.
Can you try by doing booking and reading … in SlaveBegin? See the example selectors in tutorials/proof and tutorials/tree.

Hope it helps.

G Ganis

Hi ganis!


It makes sense and it worked!