Hi rooters, we use GEANT 3.21 for our monte carlo and ROOT for analysis. We solved the problem of writing the same root-trees as we use in the experiment from GEANT 3.21 the following way: At the start of GEANT we call initroot_ which initalizes the ROOT environment. After each GEANT Trigger we call a function calle filltree_ which receives the pointers to the TTREE and our Eventstructure created by initroot_ as ordianry integers. At the end we Write the TTree usin writetree_ again passing pointers as integers. Attached you will find the code. In our case it seams to work well, any comments? extern "C" void initroot_(UInt_t* pRawEv, UInt_t* pOutTree){ static TROOT api("Test","Test"); TApplication theApp("App", 0, 0); Int_t bsize =64000; Int_t split = 1; static MTEventRaw* RawEv = new MTEventRaw(); TFile* OutFile = new TFile("Test.root","RECREATE","Test"); TTree* OutTree = new TTree("Events","Events"); OutTree->Branch("MTEventRaw","MTEventRaw", &RawEv, bsize, split); OutTree->SetAutoSave(1000000); *pRawEv = (UInt_t)RawEv; *pOutTree = (UInt_t)OutTree; } extern "C" void filltree_(UInt_t* pRawEv, UInt_t* pOutTree, Int_t* data){ MTEventRaw* RawEv; TTree* OutTree; RawEv = (MTEventRaw*)*pRawEv; OutTree = (TTree*)*pOutTree; Int_t* BGO_energy; BGO_energy = data; // Fill Raw Data Structure RawEv->Clear(); for (Int_t i=0;i < 127;i++){ if (BGO_energy[i]>0){ MTDetectorRaw* MyBgo = RawEv->AddBgo(i); MyBgo->SetAdc(BGO_energy[i]); } } //Fill Raw Data Structure into Tree OutTree->Fill(); } #include <stdio.h> #include <iostream.h> #include "TTree.h" extern "C" void writetree_(UInt_t* pOutTree){ TTree* OutTree; OutTree = (TTree*)*pOutTree; OutTree->Write(); } -- Norbert Danneberg ETH Zurich - Institute for Particle Physics Laboratory for Nuclear Physics Phone.: +41-1-633-2034 Hoenggerberg Fax.: +41-1-633-1067 CH-8093 Zurich ETH Zurich - Institute for Particle Physics Paul Scherrer Institute Phone.: +41-56-310-3284 CH-5232 Villigen PSI Fax.: +41-56-310-4362 email: Norbert.Danneberg@psi.ch
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET