tree title will be file name
This commit is contained in:
parent
91f2727802
commit
f0bcd2abae
|
@ -1,12 +1,14 @@
|
|||
#define PreAnalyzer_cxx
|
||||
|
||||
#include "PreAnalyzer.h"
|
||||
#include <TStyle.h>
|
||||
#include <TMath.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define TREESTRUCT 1 // if 0 = multi, 1 = array.
|
||||
|
||||
#include "PreAnalyzer.h"
|
||||
|
||||
//############################################ BEGIN
|
||||
void PreAnalyzer::Begin(TTree * tree){
|
||||
|
||||
|
@ -153,19 +155,32 @@ Bool_t PreAnalyzer::Process(Long64_t entry){
|
|||
//################ Gamma-Paritcle
|
||||
for( int i = 0 ; i < NCLOVER; i++){
|
||||
if( gamma[i] > 0 ) {
|
||||
gammaID[multi_N] = i;
|
||||
gamma_N[multi_N] = gamma[i];
|
||||
gamma_t[multi_N] = gammaTime[i];
|
||||
multi_N++;
|
||||
|
||||
if( TREESTRUCT == 0 ){
|
||||
gammaID[multi_N] = i;
|
||||
gamma_N[multi_N] = gamma[i];
|
||||
gamma_t[multi_N] = gammaTime[i];
|
||||
}else{
|
||||
gamma_N[i] = gamma[i];
|
||||
gamma_t[i] = gammaTime[i];
|
||||
}
|
||||
multi_N++;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0 ; i < NGAGG ; i++){
|
||||
if( count[i] == 2 ){
|
||||
gaggID[multiGagg_N] = i;
|
||||
gagg_tail[multiGagg_N] = (tail[i][0]+tail[i][1])/2.;
|
||||
gagg_peak[multiGagg_N] = (peak[i][0]+peak[i][1])/2.;
|
||||
gagg_t[multiGagg_N] = gaggTime[i];
|
||||
|
||||
if ( TREESTRUCT == 0 ){
|
||||
gaggID[multiGagg_N] = i;
|
||||
gagg_tail[multiGagg_N] = (tail[i][0]+tail[i][1])/2.;
|
||||
gagg_peak[multiGagg_N] = (peak[i][0]+peak[i][1])/2.;
|
||||
gagg_t[multiGagg_N] = gaggTime[i];
|
||||
}else{
|
||||
gagg_tail[i] = (tail[i][0]+tail[i][1])/2.;
|
||||
gagg_peak[i] = (peak[i][0]+peak[i][1])/2.;
|
||||
gagg_t[i] = gaggTime[i];
|
||||
}
|
||||
multiGagg_N++;
|
||||
}
|
||||
}
|
||||
|
@ -186,9 +201,10 @@ void PreAnalyzer::Terminate(){
|
|||
|
||||
saveFile->cd(); //set focus on this file
|
||||
newTree->Write();
|
||||
Long64_t nEntries = newTree->GetEntries();
|
||||
saveFile->Close();
|
||||
|
||||
printf("-------------- done, saved in %s.\n", saveFileName.Data());
|
||||
printf("-------------- done, saved in %s. number of entry : %lld\n", saveFileName.Data(), nEntries);
|
||||
|
||||
gROOT->ProcessLine(".q");
|
||||
|
||||
|
|
|
@ -141,14 +141,18 @@ void PreAnalyzer::Init(TTree *tree)
|
|||
eCorr = LoadCorrectionParameters("correction_e.dat");
|
||||
|
||||
///======================== open a new file
|
||||
saveFileName = "haha.root";
|
||||
|
||||
//TODO, if it is TChain, then we can get file name, else, use option
|
||||
if( option == "" ){
|
||||
saveFileName = "haha.root";
|
||||
}else{
|
||||
saveFileName = option;
|
||||
}
|
||||
saveFile = new TFile( saveFileName,"recreate");
|
||||
|
||||
TMacro e_corr("correction_e.dat");
|
||||
e_corr.Write("correction_e");
|
||||
|
||||
newTree = new TTree("tree", "tree");
|
||||
newTree = new TTree("tree", saveFileName);
|
||||
|
||||
eventID = -1;
|
||||
runID = 0;
|
||||
|
@ -156,18 +160,27 @@ void PreAnalyzer::Init(TTree *tree)
|
|||
multi_N = 0;
|
||||
multiGagg_N = 0;
|
||||
|
||||
newTree->Branch("eventID", &eventID, "eventID/l");
|
||||
newTree->Branch("runID", &runID_N, "runID/I");
|
||||
newTree->Branch("multi", &multi_N, "multi/I");
|
||||
newTree->Branch("multiGagg", &multiGagg_N, "multiGagg/I");
|
||||
newTree->Branch("gammaID", gammaID, "gammaID[multi]/S");
|
||||
newTree->Branch("gamma", gamma_N, "gamma[multi]/D");
|
||||
newTree->Branch("gamma_t", gamma_t, "gamma_t[multi]/l");
|
||||
newTree->Branch("gaggID", gaggID, "gaggID[multiGagg]/I");
|
||||
newTree->Branch("gaggP", gagg_peak, "gaggP[multiGagg]/D");
|
||||
newTree->Branch("gaggT", gagg_tail, "gaggT[multiGagg]/D");
|
||||
newTree->Branch("gagg_t", gagg_t, "gagg_t[multiGagg]/l");
|
||||
|
||||
if( TREESTRUCT == 0 ){
|
||||
newTree->Branch("eventID", &eventID, "eventID/l");
|
||||
newTree->Branch("runID", &runID_N, "runID/I");
|
||||
newTree->Branch("multi", &multi_N, "multi/I");
|
||||
newTree->Branch("multiGagg", &multiGagg_N, "multiGagg/I");
|
||||
newTree->Branch("gammaID", gammaID, "gammaID[multi]/S");
|
||||
newTree->Branch("gamma", gamma_N, "gamma[multi]/D");
|
||||
newTree->Branch("gamma_t", gamma_t, "gamma_t[multi]/l");
|
||||
newTree->Branch("gaggID", gaggID, "gaggID[multiGagg]/I");
|
||||
newTree->Branch("gaggP", gagg_peak, "gaggP[multiGagg]/D");
|
||||
newTree->Branch("gaggT", gagg_tail, "gaggT[multiGagg]/D");
|
||||
newTree->Branch("gagg_t", gagg_t, "gagg_t[multiGagg]/l");
|
||||
}else{
|
||||
newTree->Branch("eventID", &eventID, "eventID/l");
|
||||
newTree->Branch("runID", &runID_N, "runID/I");
|
||||
newTree->Branch("gamma", gamma_N, Form("gamma[%d]/D", NCLOVER));
|
||||
newTree->Branch("gamma_t", gamma_t, Form("gamma_t[%d]/l", NCLOVER));
|
||||
newTree->Branch("gaggP", gagg_peak, Form("gaggP[%d]/D", NGAGG));
|
||||
newTree->Branch("gaggT", gagg_tail, Form("gaggT[%d]/D", NGAGG));
|
||||
newTree->Branch("gagg_t", gagg_t, Form("gagg_t[%d]/l", NGAGG));
|
||||
}
|
||||
printf("======================== Start processing....\n");
|
||||
StpWatch.Start();
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ int main(int argn, char **argv){
|
|||
printf(">>> Create output tree\n");
|
||||
TFile * saveFile = new TFile(outFileName, "recreate");
|
||||
saveFile->cd();
|
||||
TTree * newtree = new TTree("tree", "tree");
|
||||
TTree * newtree = new TTree("tree", outFileName);
|
||||
|
||||
Int_t eventID = 0 ;
|
||||
Int_t multi = 0; /// this is total multipicilty for all detectors
|
||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
TFile * outRootFile = new TFile(outFileName, "recreate");
|
||||
outRootFile->cd();
|
||||
TTree * tree = new TTree("tree", "tree");
|
||||
TTree * tree = new TTree("tree", outFileName);
|
||||
|
||||
unsigned long long evID = 0;
|
||||
int multi = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user