Hello,
I am having one problem that I cannot solve. I have one TTree called extraVariables and I have one function that would create a TFile and write it with this TTree, and I also have a function that use this TTree to draw a TH1F.
This is the function that writes the TTree:
391 HypoBase::CODE T2CaCommon::WriteTree(const std::string &fileName){
392
393
394 TFile file(fileName.c_str(), "recreate");
395 file.Add(extraVariables);
396 file.Write();
397 extraVariables = static_cast<TTree*>(file.Remove(extraVariables));
398 file.Close();
399
400
401 return HypoBase::OK;
402
403 }
This is the function that draw the TH1:
301 HypoBase::CODE T2CaCommon::DrawCutCounter(const std::string &opt){
302
303 TH1I *hCuts = new TH1I("CutCounter", "L2Calo Hypo Passed Cuts; Cut", 11, -1.5, 9.5);
304
305 int nEntries = static_cast<int>(extraVariables->GetEntries());
306
307 for(int i=0; i<nEntries;++i){
308 extraVariables->GetEntry(i);
309 for(size_t j=0; j<t2CaAns->size();++j){
310 switch (t2CaAns->at(j)){
311 case T2CaCommon::AP:
312 hCuts->Fill(T2CaCommon::c_F1);
313 case T2CaCommon::c_F1:
314 hCuts->Fill(T2CaCommon::et_HAD);
315 case T2CaCommon::et_HAD:
316 hCuts->Fill(T2CaCommon::et_EM);
317 case T2CaCommon::et_EM:
318 hCuts->Fill(T2CaCommon::eRATIO);
319 case T2CaCommon::eRATIO:
320 hCuts->Fill(T2CaCommon::rCORE);
321 case T2CaCommon::rCORE:
322 hCuts->Fill(T2CaCommon::dPHI);
323 case T2CaCommon::dPHI:
324 hCuts->Fill(T2CaCommon::dETA);
325 case T2CaCommon::dETA:
326 hCuts->Fill(T2CaCommon::TRIG);
327 hCuts->Fill(T2CaCommon::LVL2E);
328 break;
329 default:
330 return HypoBase::ERROR;
331 }
332 }
333 }
334
335 hCuts->GetXaxis()->SetBinLabel(1,"Input");
336 hCuts->GetXaxis()->SetBinLabel(2,"has one TrigEMCluster");
337 hCuts->GetXaxis()->SetBinLabel(3,"#Delta #eta L2-L1");
338 hCuts->GetXaxis()->SetBinLabel(4,"#Delta #phi L2-L1");
339 hCuts->GetXaxis()->SetBinLabel(5,"rCore");
340 hCuts->GetXaxis()->SetBinLabel(6,"eRatio");
341 hCuts->GetXaxis()->SetBinLabel(7,"E_{T}^{EM}");
342 hCuts->GetXaxis()->SetBinLabel(8,"E_{T}^{Had}");
343 hCuts->GetXaxis()->SetBinLabel(9,"f_{1}");
344 hCuts->SetEntries(hCuts->GetBinContent(1));
345 hCuts->SetLineColor(color);
346 hCuts->Draw(opt.c_str());
347 return HypoBase::OK;
348
349 }
Well, if I use the DrawCutCounter first it will be all right, it will do what it is supposed to do, but if I run WriteTree and then run DrawCutCounter I will get a segmentation fault x(. I tried many different things but none were successful. What am I missing?
Thank you,
Werner.