Message: Making some histograms for ROOT Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Making some histograms for ROOT 

Forum: Analysis
Date: 12 Jun, 2007
From: Adam <ax_blais@laurentian.ca>

I am using the example found here: ftp://root.cern.ch/root/IcaG4.tar/gz

I transferred the Analysis.cc class to one of my own programs. I have set my environment variable, namely G4ANALYSIS_USE_ROOT = 1 but when running I get no histograms at all. It's as if the ROOT code isn't even there. I tried using a cout to figure out the problem, and it appears that my code is ignoring whatever is inside the "if defined".

You can see that my G4cout comes right after the if defined.

void ExN02Analysis::OnceAWhileDoIt(const G4bool DoItNow) {

  time_t Now = time(0); // get the current time (measured in seconds)
  if ( (!DoItNow) && (LastDoItTime > (Now - 10)) ) return; // every 10 seconds
  LastDoItTime = Now;

#if defined (G4ANALYSIS_USE_ROOT)
  G4cout << "ROOT IS BEING DONE" << G4endl;

  TVirtualPad *CurrentPad = gPad;

  const char OnceAWhileCanvas[] = "ExN02AnalysisCanvas";

  TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject(OnceAWhileCanvas);

  if ( DoItNow && (!c) && ((G4RunManager::GetRunManager())->GetVerboseLevel() > 1) )
    {
      // first, try to make sure we do not run in batch mode
      if (!gApplication)
        new TApplication("Application", ((int *)0), ((char **)0));
      // then, create the TCanvas
      c = new TCanvas(OnceAWhileCanvas, OnceAWhileCanvas);
      if (c) {
        c->Divide(2,2);
        c->cd(1); if (hStepLength) hStepLength->Draw();
        c->cd(2); if (hStepTotELoss) hStepTotELoss->Draw();
        c->cd(3); if (hOPWaveLength) hOPWaveLength->Draw();
        c->cd(4); if (hTotELossNorm) hTotELossNorm->Draw();
        c->cd(0);
      }
    }

  if (c) {
    //c->cd(0);
    c->Draw();
    c->Update();
  }
  G4cout << "ROOT IS BEING DONE" << G4endl;
TFile f("g4hist.root", "new");
  hStepLength->Write();
  if (CurrentPad) CurrentPad->cd();

  if (gSystem) gSystem->ProcessEvents();

#endif /* defined (G4ANALYSIS_USE_ROOT) */ }

I get no output like this. However, if I put the cout before that line, like this:

void ExN02Analysis::OnceAWhileDoIt(const G4bool DoItNow)
{
  G4cout << "ROOT IS BEING DONE" << G4endl;

  time_t Now = time(0); // get the current time (measured in seconds)
  if ( (!DoItNow) && (LastDoItTime > (Now - 10)) ) return; // every 10 seconds
  LastDoItTime = Now;

#if defined (G4ANALYSIS_USE_ROOT)

  TVirtualPad *CurrentPad = gPad;

I get the output with this. I don't understand why this isn't working. Like I said, my environment variable is set so I don't know what's wrong.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Making some histograms for ROOT"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]