src/common/MTreeOutput.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "midas.h"
#include <TROOT.h>
#include <TPluginManager.h>
#include <TFile.h>
#include <TTree.h>
#include <TBranch.h>
#include "TGlobalData.h"
#include "TSetupData.h"
#include "TVacuumData.h"

Go to the source code of this file.

Functions

INT MTreeOutput_init (void)
INT MTreeOutput_exit (void)
INT MTreeOutput (EVENT_HEADER *, void *)

Variables

HNDLE hDB
TGlobalDatagData
 Object to hold data used and produced by modules throughout alcapana stage of analysis.
TSetupDatagSetup
 Hardware information about digitizers and detectors to be used during alcapana stage of analysis.
TVacuumDatagVacuum
 Vacuum data slow control.
char * gMiasTreeOutputFileName
static TFile * fTreeFile = NULL
static TTree * fEventTree = NULL
static TBranch * fEventBranch = NULL
static TTree * fSetupTree = NULL
static TBranch * fSetupBranch = NULL
static TTree * fVacuumTree = NULL
static TBranch * fVacuumBranch = NULL
ANA_MODULE MTreeOutput_module
TROOT * gROOT
static bool PLUGIN_LOADED = false

Function Documentation

INT MTreeOutput ( EVENT_HEADER *  pheader,
void *  pevent 
)

This method writes the data in gData into the branches of the tree

Definition at line 121 of file MTreeOutput.cpp.

References fEventTree, and fVacuumTree.

00122 {
00123   fEventTree->Fill();
00124   fVacuumTree->Fill();
00125   return SUCCESS;
00126 }

INT MTreeOutput_exit (  ) 

This method writes the tree and closes the tree file

Definition at line 129 of file MTreeOutput.cpp.

References fTreeFile.

00130 {
00131   if(fTreeFile){
00132     fTreeFile->Write();
00133     fTreeFile->Close();
00134   }
00135 
00136   return SUCCESS;
00137 }

INT MTreeOutput_init (  ) 

This method initializes the tree file and tree

Definition at line 69 of file MTreeOutput.cpp.

References fEventBranch, fEventTree, fSetupBranch, fSetupTree, fTreeFile, fVacuumBranch, fVacuumTree, gMiasTreeOutputFileName, gROOT, and PLUGIN_LOADED.

00070 {
00071   if (!PLUGIN_LOADED) {
00072     if(gROOT->GetPluginManager()->FindHandler("TVirtualStreamerInfo") == NULL)
00073       gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo","*","TStreamerInfo","RIO","TStreamerInfo()");
00074     PLUGIN_LOADED = true;
00075   }
00076     
00077   if(gMiasTreeOutputFileName){
00078     fTreeFile = TFile::Open(gMiasTreeOutputFileName, "recreate");
00079     if(!fTreeFile || fTreeFile->IsZombie()){
00080       printf("Could not open tree file %s!\n", gMiasTreeOutputFileName);
00081       return ANA_SKIP;
00082     }  
00083   }
00084   fTreeFile->cd();
00085   
00086   fEventTree = new TTree("EventTree","All readout channels");
00087   fEventTree->SetAutoSave(300000000); // autosave when 300 Mbyte written.
00088   fEventTree->SetMaxVirtualSize(300000000); // 300 Mbyte
00089   int split = 1;
00090   int bufsize = 64000;
00091   Int_t branchstyle = 1;
00092 
00093   if (split < 0) {branchstyle = 0; split = -1-split;}
00094   TTree::SetBranchStyle(branchstyle);
00095 
00096   fEventBranch = fEventTree->Branch("Event", "TGlobalData", &gData, bufsize, split);
00097   fEventBranch->SetAutoDelete(kFALSE);
00098 
00099   // The TTree with the setup information
00100   fSetupTree = new TTree("SetupTree","All setup information");
00101   fSetupTree->SetAutoSave(300000000); // autosave when 300 Mbyte written.
00102   fSetupTree->SetMaxVirtualSize(300000000); // 300 Mbyte
00103 
00104   fSetupBranch = fSetupTree->Branch("Setup", "TSetupData", &gSetup, bufsize, split);
00105   fSetupBranch->SetAutoDelete(kFALSE);
00106   
00107   fSetupTree->Fill();
00108 
00109   // The TTree with the Vacuum information
00110   fVacuumTree = new TTree("VacuumTree","All setup information");
00111   fVacuumTree->SetAutoSave(300000000); // autosave when 300 Mbyte written.
00112   fVacuumTree->SetMaxVirtualSize(300000000); // 300 Mbyte
00113 
00114   fVacuumBranch = fVacuumTree->Branch("Vacuum", "TVacuumData", &gVacuum, bufsize, split);
00115   fVacuumBranch->SetAutoDelete(kFALSE);
00116   
00117   return SUCCESS;
00118 }


Variable Documentation

TBranch* fEventBranch = NULL [static]

Definition at line 44 of file MTreeOutput.cpp.

Referenced by MTreeOutput_init().

TTree* fEventTree = NULL [static]

Definition at line 43 of file MTreeOutput.cpp.

Referenced by MTreeOutput(), and MTreeOutput_init().

TBranch* fSetupBranch = NULL [static]

Definition at line 46 of file MTreeOutput.cpp.

Referenced by MTreeOutput_init().

TTree* fSetupTree = NULL [static]

Definition at line 45 of file MTreeOutput.cpp.

Referenced by MTreeOutput_init().

TFile* fTreeFile = NULL [static]

Definition at line 42 of file MTreeOutput.cpp.

Referenced by MTreeOutput_exit(), and MTreeOutput_init().

TBranch* fVacuumBranch = NULL [static]

Definition at line 48 of file MTreeOutput.cpp.

Referenced by MTreeOutput_init().

TTree* fVacuumTree = NULL [static]

Definition at line 47 of file MTreeOutput.cpp.

Referenced by MTreeOutput(), and MTreeOutput_init().

Referenced by MTreeOutput_init().

TROOT* gROOT

Referenced by main(), and MTreeOutput_init().

HNDLE hDB
ANA_MODULE MTreeOutput_module
Initial value:
{
  "MTreeOutput",                 
  "Peter Winter",                
  MTreeOutput,                   
  NULL,                          
  NULL,                          
  MTreeOutput_init,              
  MTreeOutput_exit,              
  NULL,                          
  0,                             
  NULL,                          
}

Definition at line 50 of file MTreeOutput.cpp.

bool PLUGIN_LOADED = false [static]

Definition at line 65 of file MTreeOutput.cpp.

Referenced by MTreeOutput_init().


Generated on 15 Jun 2016 for AlcapDAQ by  doxygen 1.6.1