Message: Re: Create a new 1D histogram at each run in the same ROOT file Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Create a new 1D histogram at each run in the same ROOT file 

Forum: Analysis
Re: None Create a new 1D histogram at each run in the same ROOT file (Delaune Olivier)
Re: None Re: Create a new 1D histogram at each run in the same ROOT file (Ivana Hrivnacova)
Date: 06 Sep, 2017
From: Delaune Olivier <Delaune Olivier>

Thank you for the reply. It is indeed a promising way to do what I want. However, I have still a problem to define my H1s. If I come back to my input file, it looks like something like that

/run/initialize /analysis/setActivation true /analysis/h1/setActivationToAll false

/FRL08/run/setOpenFile true /FRL08/run/setCloseFile false

/gun/particle gamma

/analysis/h1/setActivation 0 true /gun/energy 1173.228 keV /run/beamOn 1000000 #99.85%

/FRL08/run/setOpenFile false

/analysis/h1/setActivation 1 true /gun/energy 1332.492 keV /run/beamOn 1000000 #99.9826%

/analysis/h1/setActivation 2 true /gun/particle ion /gun/ion 27 60 /run/beamOn 1000000

/FRL08/run/setCloseFile true

However, if I do this, I get

### Run 0 start. filename: test.in.root ... open Root main analysis file : test.in.root - done

G4WT0 > ... merge Root all H1 :  - done
G4WT0 > ... merge Root slave ntuples :  - done
G4WT1 > ... merge Root all H1 : - done G4WT1 > ... merge Root slave ntuples : - done
G4WT3 > ... merge Root all H1 :  - done
G4WT3 > ... merge Root slave ntuples :  - done
G4WT6 > ... merge Root all H1 : - done G4WT6 > ... merge Root slave ntuples : - done
G4WT2 > ... merge Root all H1 :  - done
G4WT2 > ... merge Root slave ntuples :  - done
G4WT7 > ... merge Root all H1 : - done G4WT7 > ... merge Root slave ntuples : - done
G4WT5 > ... merge Root all H1 :  - done
G4WT5 > ... merge Root slave ntuples :  - done
G4WT4 > ... merge Root all H1 : - done G4WT4 > ... merge Root slave ntuples : - done ... merge Root main ntuples : - done ... write Root file : test.in.root - done ... close Root file : test.in.root - done ***** COMMAND NOT FOUND </analysis/h1/setActivation 1 true> *****

Actually, the question is that I do not know how to create "on-the-fly" a new H1. In my RunAction, I have something like that

in the constructor

    // Booking Histogramms
    maxHisto = 10;
    for(G4int i=0 ; i<maxHisto ; i++) {
        std::stringstream hname;
        hname << "h" << i;
        analysisManager->CreateH1(hname.str(),"Edep [keV] in Cristal", Nbins, eMin, eMax);
    }

in BeginOfRunAction

   // Open an output file
    if(fOpenFile)
        analysisManager->OpenFile(m_RootFileName);

in EndOfRunAction

    // Open an output file
    if(fCloseFile) {
        analysisManager->Write();
        analysisManager->CloseFile();
    }

    // complete cleanup
    //
    delete G4AnalysisManager::Instance();

And in my EventAction, I whave written in EndOfEventAction

...
    if ( edepInCristal > 0. )
    {
        const G4Run *run = static_cast< const G4Run* >(
                    G4RunManager::GetRunManager()->GetCurrentRun());
        G4int id = run->GetRunID();

        G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
        analysisManager->FillH1(id, edepInCristal);
    }

I understand that it cannot work since my H1s are created at each new run. So, I am still confuse about how to do this in a good way.

Actually, I would be interested by a solution that works even if I do not know a priori the number of run that are in my macro.

Thank you in advance for any help.

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

1 None: Re: Create a new 1D histogram at each run in the same ROOT file   (Ivana Hrivnacova - 07 Sep, 2017)
 Add Message Add Message
to: "Re: Create a new 1D histogram at each run in the same ROOT file"

 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 ]