/[PAMELA software]/PamVMC/src/PamRootManager.cxx
ViewVC logotype

Annotation of /PamVMC/src/PamRootManager.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Fri Jun 12 18:39:28 2009 UTC (15 years, 5 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r0
Changes since 1.1: +5 -4 lines
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

1 nikolas 1.1 #include "PamRootManager.h"
2     #include <TSystem.h>
3     #include <TParticle.h>
4     #include <TObjArray.h>
5     #include <iostream>
6    
7     #include <TList.h>
8     #include <TROOT.h>
9     ClassImp(PamRootManager)
10    
11 pam-rm2 1.5 using namespace std;
12 nikolas 1.1 PamRootManager* PamRootManager::fgInstance = 0;
13    
14     PamRootManager::PamRootManager(const char* projectName, FileMode fileMode)
15     : TObject()
16     {
17     if (fgInstance) {
18     Fatal("PamRootManager", "Singleton instance already exists.");
19     return;
20     }
21    
22    
23     TString fileName = TString(gSystem->Getenv("PWD"))+"/"+projectName;
24     fileName += ".root";
25    
26 pam-rm2 1.5 cout<<"OUTPUT ROOTFILE: "<<fileName<<endl;
27     TString treeTitle("pamtest");
28 nikolas 1.1 treeTitle += " tree";
29    
30     TTree::SetMaxTreeSize(1000*Long64_t(2000000000));
31    
32     switch (fileMode) {
33     case kRead:
34     fFile = new TFile(fileName);
35     fTree = (TTree*) fFile->Get(projectName);
36     break;
37    
38     case kWrite:
39     fFile = new TFile(fileName, "recreate");
40     fTree = new TTree(projectName, treeTitle);
41     ;;
42     }
43    
44    
45     fgInstance = this;
46     }
47    
48     PamRootManager::PamRootManager()
49     : TObject(),
50     fFile(0),
51     fTree(0)
52     {
53    
54     if (fgInstance) {
55     Fatal("PamRootManager", "Singleton instance already exists.");
56     return;
57     }
58    
59 pam-rm2 1.5 fgInstance = this;
60 nikolas 1.1 }
61    
62     PamRootManager::~PamRootManager()
63     {
64     fFile->cd();
65     delete fFile;
66 pam-rm2 1.5 //delete fDirectory;
67 nikolas 1.1 fgInstance = 0;
68     }
69    
70     PamRootManager* PamRootManager::Instance()
71     {
72     // Returns singleton instance.
73    
74     return fgInstance;
75     }
76    
77     void PamRootManager::Register(const char* name, const char* className,
78     void* objAddress)
79     {
80     // Creates a branch of the given name and associates it with
81     // the given address.
82    
83     if (!fTree->GetBranch(name))
84     fTree->Branch(name, className, objAddress, 32000, 99);
85     else
86     fTree->GetBranch(name)->SetAddress(objAddress);
87     }
88    
89     void PamRootManager::Fill()
90     {
91     // Fills the tree.
92     //TString tmp = gDirectory->GetName();
93     fFile->cd();
94     fTree->Fill();
95     //gDirectory->cd(tmp);
96     }
97    
98     void PamRootManager:: WriteAll()
99     {
100     // Erites the tree in the file.
101    
102     //TString tmp = gDirectory->GetName();
103     fFile->cd();
104     std::cout<<"TREE NAME: "<<fTree->GetName()<<std::endl;
105     std::cout<<"DIR NAME: "<<gDirectory->GetName()<<std::endl;
106     fTree->Write();
107     //gDirectory->cd(tmp);
108     std::cout<<"TREE WRITTEN "<<fTree->GetName()<<std::endl;
109     }
110    
111     void PamRootManager::ReadEvent(Int_t i)
112     {
113     // Reads the event data for i-th event for all connected branches.
114    
115     fTree->GetEntry(i);
116     }

  ViewVC Help
Powered by ViewVC 1.1.23