source: ELYSE/HEAD/source/Analysis.cxx @ 286

Last change on this file since 286 was 286, checked in by campagne, 17 years ago

ELYSE sauvegarde provisoire (JEC)

File size: 2.7 KB
Line 
1#include "ELYSE/Analysis.hh"
2
3//AIDA
4#include <AIDA/IAnalysisFactory.h>
5#include <AIDA/ITreeFactory.h>
6#include <AIDA/ITree.h>
7#include <AIDA/ITupleFactory.h>
8
9//Std
10#include <iostream>
11#include <vector>
12#include <string>
13
14ELYSE::Analysis::Analysis(
15 AIDA::IAnalysisFactory* aAIDA
16,const std::string& aFormat
17,bool aBatch)
18:fAIDA(aAIDA)
19,fBatch(aBatch)
20,fTree(0)
21{
22  if(!fAIDA) return;
23
24  AIDA::ITreeFactory* treeFactory = fAIDA->createTreeFactory();
25  if(fBatch) {
26    if( (aFormat=="root") || (aFormat==""))  {
27      //ROOT tree :
28      std::string opts = "export=root";
29      fTree = treeFactory->create("ELYSE.root","root",false,true,opts);
30    } else if(aFormat=="hdf5") {
31      //HDF5 tree :
32      std::string opts = "";
33      fTree = treeFactory->create("ELYSE.hdf5","hdf5",false,true,opts);
34    } else if(aFormat=="xml") {
35      // AIDA XML tree :
36      std::string opts = "compress=yes";
37      fTree = treeFactory->create("ELYSE.xml","xml",false,true,opts);
38    } else {
39      std::cout << "Analysis :"
40                << " file format \"" << aFormat << "\""
41                << " not handled." 
42                << std::endl;
43    }
44  } else {
45    // Memory tree :
46    fTree = treeFactory->create();
47  }
48  delete treeFactory;
49  if(!fTree) {
50    std::cout << "Analysis : FATAL"
51              << " tree not created." << std::endl;
52    return;
53  }
54
55  //Booking Event Tuple
56  AIDA::ITupleFactory* tf = fAIDA->createTupleFactory(*fTree);
57  if(fBatch) {
58    std::string column = "int eventId, vtxvol, "; 
59    column += "ITuple vtxPos = { double x, y, z }, ";
60    column += "int nPart, ";
61    column += "ITuple track = { int pId, parent, float timeStart, ";
62    column +=                  "ITuple direction = { double dx, dy, dz }, ";
63    column +=                  "double  mass, pTot, ETot, ";
64    column +=                  "ITuple momentum  = { double px, py, pz }, ";
65    column +=                  "ITuple startPos  = { double  x,  y,  z }, ";
66    column +=                  "ITuple stopPos   = { double  x,  y,  z } ";
67    column +=                  "int startVol, stopVol ";
68    column +=                "}, ";
69    column += "int nHits,";
70    column += "ITuple hit = { double  time, eTot, x,  y,  z, trkId, parentId, pdg, edep } ";
71   
72    tf->create("Event","ELYSE Event",column,"");     
73  }//batch mode
74 
75
76  //release the TupleFactory
77  delete tf;
78
79}//Ctor
80
81//----------------------------------------------------------------------
82ELYSE::Analysis::~Analysis(){
83  //Not to be changed
84  if(!fTree) return;
85  if(fBatch) {
86    fTree->commit();
87    delete fTree;
88    fTree = 0;
89  }
90}//Dtor
91
92//----------------------------------------------------------------------
93
94void ELYSE::Analysis::closeTree(){
95  if(!fTree) return;
96  if(!fBatch) return;
97  fTree->commit();
98  delete fTree;
99  fTree = 0;
100}
Note: See TracBrowser for help on using the repository browser.