CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TEcnaRootFile.cc
Go to the documentation of this file.
1 //----------Author's Names: FX Gentit, B.Fabbro DSM/IRFU/SPP CEA-Saclay
2 //----------Copyright:Those valid for CEA sofware
3 //----------Modified:22/03/2010
4 
6 #include "Riostream.h"
7 
9 
10 ClassImp(TEcnaRootFile)
11 //___________________________________________________________________________
12 //
13 // Reading of the ROOT file written by TEcnaRunEB
14 //
16 //constructor without arguments
17 
18  // cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << endl;
19 
20  Init();
21 }
22 
24 //constructor
25 
26  // cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << endl;
27 
28  Init();
30 }
31 
32 TEcnaRootFile::TEcnaRootFile(const Text_t *name, TString status) {
33 //constructor
34 
35  // cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << endl;
36 
37  Init();
40 }
41 
43 //destructor
44 
45  //cout << "[Info Management] CLASS: TEcnaRootFile. DESTROY OBJECT: this = " << this << endl;
46 
47  if( fCnaIndivResult != 0 ){delete fCnaIndivResult;}
48 }
49 
51 {
52 //Set default values in all variables
53  fRootFileName = "";
54  fRootFileStatus = "";
55  fRootFile = 0;
57  fNbEntries = 0;
58  fCnaResultsTree = 0;
60  fCnaIndivResult = 0;
61 }
62 
64 //Close the CNA root file for reading
65  fRootFile->Close();
66  delete fRootFile; fRootFile = 0;
68  fCnaResultsTree = 0;
70 }
71 
72 Bool_t TEcnaRootFile::OpenR(const Text_t *name) {
73 //Open the CNA root file for reading
74  Bool_t ok;
75  TString sEmpty = "";
76  if( name != sEmpty ){fRootFileName = name;}
77 
78  if( fRootFile == 0 ){fRootFile = new TFile(fRootFileName.Data(),"READ");}
79 
80  ok = fRootFile->IsOpen();
81  if (ok) {
82  fCnaResultsTree = (TTree *)fRootFile->Get("CNAResults");
83  if (fCnaResultsTree) {
85  fCnaResultsBranch = fCnaResultsTree->GetBranch("Results");
86  fCnaResultsBranch->SetAddress(&fCnaIndivResult);
87  fNbEntries = (Int_t) fCnaResultsTree->GetEntries();
88  }
89  else ok = kFALSE;
90  }
91  return ok;
92 }
93 
94 Bool_t TEcnaRootFile::OpenW(const Text_t *name) {
95 //Open root file for writing
96  Bool_t ok = kTRUE;
97  TString sEmpty = "";
98  if( name != sEmpty ){fRootFileName = name;}
99 
100  if( fRootFile == 0 ){fRootFile = new TFile(fRootFileName.Data(),"RECREATE");}
101  if (fRootFile) {
102  fCnaResultsTree = new TTree("CNAResults","CNAResults");
105  Branch("Results","TEcnaResultType", &fCnaIndivResult, 64000, 0);
106  }
107  else ok = kFALSE;
108  return ok;
109 }
110 
112 //Read element i
113  Bool_t ok = kTRUE;
115  return ok;
116 }
117 
119 //Look for kth element of type typ
120  Bool_t ok = kFALSE;
121  Int_t i = 0;
122  do {
124  ok = ( ( fCnaIndivResult->fIthElement == k ) &&
125  ( fCnaIndivResult->fTypOfCnaResult == typ ));
126  i++;
127  } while ((i<fNbEntries) && (!ok));
128  return ok;
129 }
130 
132 //Look for kth element of type typ and return the next entry number
133  Bool_t ok = kFALSE;
134 
135  Int_t i = 0;
136  do {
138  ok = ( ( fCnaIndivResult->fIthElement == k ) &&
139  ( fCnaIndivResult->fTypOfCnaResult == typ ));
140  i++;
141  } while ((i<fNbEntries) && (!ok));
142 
143  if( ok == kFALSE ){i = -1;}
144  return i;
145 }
TEcnaResultType * fCnaIndivResult
Definition: TEcnaRootFile.h:28
Bool_t OpenR(const Text_t *="")
int i
Definition: DBlmapReader.cc:9
CnaResultTyp
TBranch * fCnaResultsBranch
Definition: TEcnaRootFile.h:27
CnaResultTyp fTypOfCnaResult
TString fRootFileStatus
Definition: TEcnaRootFile.h:19
int k[5][pyjets_maxn]
Int_t fCounterBytesCnaResults
Definition: TEcnaRootFile.h:21
Int_t ReadElementNextEntryNumber(CnaResultTyp, Int_t)
TString fRootFileName
Definition: TEcnaRootFile.h:18
R__EXTERN TCnaRootFile * gCnaRootFile
Definition: TCnaRootFile.h:43
Bool_t ReadElement(Int_t)
Bool_t OpenW(const Text_t *="")
tuple status
Definition: ntuplemaker.py:245
TTree * fCnaResultsTree
Definition: TEcnaRootFile.h:23
TFile * fRootFile
Definition: TEcnaRootFile.h:20