Reading input files

Hi all,

I have managed to make PROOF work more or less, but I am still having difficulties when trying to use input files. I have thoroughly looked for an answer in previous topics but I am not able to find one.

So basically my issue is as follows, in this case of “2D Cuts” for telescope detectors. I declare the “cuts” in the Begin() routine:

void FillHistoPbgamma::Begin(TTree * /*tree*/)
{
...

TFile *fcuts = TFile::Open("/data128/ricardo/cuts_sc3.root");
TString cutname;

for(int cint=0; cint<4; cint++)
   {
   cutname = Form("c3_c6d6%d",cint+1);
   Cut_3[cint] = (TCutG*)fcuts->Get(cutname.Data());
   fInput->Add(Cut_3[cint]);
   } 

...

Then use them in the Process() routine:

...

for(int ic=0; ic<4; ic++){
if(Cut_3[ic]->IsInside(EgammaC6D6cal[ic],TAC_C6D6[ic])==1)
      {
      hEgammaC6D6[ic]->Fill(EgammaC6D6cal[ic]);
      }
         
...

But I get a crash, which I don’t when using ROOT without PROOF, which the only change I would do into the code is removing the “fInput->Add(Cut_3[cint]);”. Should I use “dynamic_cast” to declare the cuts? Any ideas?

Thank you all in advance.

Ricardo

Dear Ricardo,

Likely the problem is that the cuts are not automatically redefined in the workers. If you add them to the input list yo have to retrieve from (or point to them in) there, before using then in Process. You may do this in SlaveBegin:

void FillHistoPbgamma::SlaveBegin(TTree * /*tree*/)
{
...

TString cutname;
for(int cint=0; cint<4; cint++) {
   cutname.Form("c3_c6d6%d",cint+1);
   Cut_3[cint] = (TCutG*)fInput->FindObject(cutname.Data());
} 

...
}

If you are using ProofLite and the file /data128/ricardo/cuts_sc3.root is local to all the workers, you may also the initialization of the cuts from file (i.e. what you do now in Begin) in SlaveBegin.

Hope it helps.

G Ganis

Thank you G Ganis,

Fortunately this did work, and I did not need to add the cuts to the input list!

A post was split to a new topic: Error in PROOF