CMS 3D CMS Logo

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:30/09/2011
4 
6 #include "Riostream.h"
7 
8 //--------------------------------------
9 // TEcnaRootFile.cc
10 // Class creation: 03 Dec 2002
11 // Documentation: see TEcnaRootFile.h
12 //--------------------------------------
13 
15 
17 //___________________________________________________________________________
18 //
19 // Reading of the ROOT file written by TEcnaRunEB
20 //
22  //constructor without arguments
23 
24  // std::cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << std::endl;
25 
26  Init();
27 }
28 
29 TEcnaRootFile::TEcnaRootFile(TEcnaObject *pObjectManager, const Text_t *name, const TString &status) {
30  //constructor
31 
32  // std::cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << std::endl;
33 
34  Init();
35  Long_t i_this = (Long_t)this;
36  pObjectManager->RegisterPointer("TEcnaRootFile", i_this);
37 
40 }
41 
42 TEcnaRootFile::TEcnaRootFile(TEcnaObject *pObjectManager, const Text_t *name) {
43  //constructor
44 
45  // std::cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << std::endl;
46 
47  Init();
48  Long_t i_this = (Long_t)this;
49  pObjectManager->RegisterPointer("TEcnaRootFile", i_this);
50 
52  fRootFileStatus = "READ";
53 }
54 
55 TEcnaRootFile::TEcnaRootFile(const Text_t *name, const TString &status) {
56  //constructor
57 
58  // std::cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << std::endl;
59 
60  Init();
63 }
64 
66  //constructor
67 
68  // std::cout << "[Info Management] CLASS: TEcnaRootFile. CREATE OBJECT: this = " << this << std::endl;
69 
70  Init();
72  fRootFileStatus = "READ";
73 }
74 
76  //destructor
77 
78  //std::cout << "[Info Management] CLASS: TEcnaRootFile. DESTROY OBJECT: this = " << this << std::endl;
79 
80  if (fCnaIndivResult != nullptr) {
81  delete fCnaIndivResult;
82  }
83 }
84 
86  //Set default values in all variables
87 
88  TString sEmpty = "";
89  fRootFileName = sEmpty.Data();
90  fRootFileStatus = sEmpty.Data();
91 
92  fRootFile = nullptr;
94  fNbEntries = 0;
95  fCnaResultsTree = nullptr;
96  fCnaResultsBranch = nullptr;
97  fCnaIndivResult = nullptr;
98 }
99 
100 void TEcnaRootFile::ReStart(const Text_t *name) {
101  // Set default values + fRootFileName + fRootFileStatus
102 
103  Init();
105  fRootFileStatus = "READ";
106 }
107 
108 void TEcnaRootFile::ReStart(const Text_t *name, const TString &status) {
109  // Set default values + fRootFileName + fRootFileStatus
110 
111  Init();
114 }
115 
117  //Close the CNA root file for reading
118  if (fRootFile != nullptr) {
119  fRootFile->Close();
120  delete fRootFile;
121  fRootFile = nullptr;
122  }
124  fCnaResultsTree = nullptr;
125  fCnaResultsBranch = nullptr;
126 }
127 
128 Bool_t TEcnaRootFile::OpenR(const Text_t *name) {
129  //Open the CNA root file for reading
130  Bool_t ok;
131  TString sEmpty = "";
132  if (name != sEmpty) {
134  }
135 
136  if (fRootFile == nullptr) {
137  fRootFile = new TFile(fRootFileName.Data(), "READ");
138  }
139 
140  ok = fRootFile->IsOpen();
141  if (ok) {
142  fCnaResultsTree = (TTree *)fRootFile->Get("CNAResults");
143  if (fCnaResultsTree) {
144  if (fCnaIndivResult == nullptr) {
146  }
147  fCnaResultsBranch = fCnaResultsTree->GetBranch("Results");
148  fCnaResultsBranch->SetAddress(&fCnaIndivResult);
149  fNbEntries = (Int_t)fCnaResultsTree->GetEntries();
150  } else
151  ok = kFALSE;
152  }
153  return ok;
154 }
155 
156 Bool_t TEcnaRootFile::OpenW(const Text_t *name) {
157  //Open root file for writing
158  Bool_t ok = kTRUE;
159  TString sEmpty = "";
160  if (name != sEmpty) {
162  }
163 
164  if (fRootFile == nullptr) {
165  fRootFile = new TFile(fRootFileName.Data(), "RECREATE");
166  }
167  if (fRootFile) {
168  fCnaResultsTree = new TTree("CNAResults", "CNAResults");
170  fCnaResultsBranch = fCnaResultsTree->Branch("Results", "TEcnaResultType", &fCnaIndivResult, 64000, 0);
171  } else
172  ok = kFALSE;
173  return ok;
174 }
175 
177  //Read element i
178  Bool_t ok = kTRUE;
180  return ok;
181 }
182 
184  //Look for kth element of type typ
185  Bool_t ok = kFALSE;
186  Int_t i = 0;
187  do {
190  i++;
191  } while ((i < fNbEntries) && (!ok));
192  return ok;
193 }
194 
196  //Look for kth element of type typ and return the next entry number
197  Bool_t ok = kFALSE;
198 
199  Int_t i = 0;
200  do {
203  i++;
204  } while ((i < fNbEntries) && (!ok));
205 
206  if (ok == kFALSE) {
207  i = -1;
208  }
209  return i;
210 }
TEcnaRootFile::fCounterBytesCnaResults
Int_t fCounterBytesCnaResults
Definition: TEcnaRootFile.h:35
mps_fire.i
i
Definition: mps_fire.py:428
TEcnaRootFile::fCnaResultsBranch
TBranch * fCnaResultsBranch
Definition: TEcnaRootFile.h:41
TEcnaResultType::fTypOfCnaResult
CnaResultTyp fTypOfCnaResult
Definition: TEcnaResultType.h:56
mps_update.status
status
Definition: mps_update.py:69
TEcnaResultType
Definition: TEcnaResultType.h:53
TEcnaRootFile
Definition: TEcnaRootFile.h:25
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
TEcnaRootFile::fRootFileStatus
TString fRootFileStatus
Definition: TEcnaRootFile.h:31
CnaResultTyp
CnaResultTyp
Definition: TEcnaResultType.h:24
TEcnaRootFile::ReStart
void ReStart(const Text_t *)
Definition: TEcnaRootFile.cc:100
TEcnaRootFile::fRootFileName
TString fRootFileName
Definition: TEcnaRootFile.h:30
TEcnaRootFile::~TEcnaRootFile
~TEcnaRootFile() override
Definition: TEcnaRootFile.cc:75
TEcnaRootFile::Init
void Init()
Definition: TEcnaRootFile.cc:85
TEcnaRootFile::fNbEntries
Int_t fNbEntries
Definition: TEcnaRootFile.h:36
TEcnaObject::RegisterPointer
Bool_t RegisterPointer(const TString &, const Long_t &)
Definition: TEcnaObject.cc:100
TEcnaRootFile::TEcnaRootFile
TEcnaRootFile()
Definition: TEcnaRootFile.cc:21
dqmdumpme.k
k
Definition: dqmdumpme.py:60
TEcnaRootFile.h
TEcnaRootFile::OpenR
Bool_t OpenR(const Text_t *="")
Definition: TEcnaRootFile.cc:128
TEcnaObject
Definition: TEcnaObject.h:25
TEcnaRootFile::ReadElement
Bool_t ReadElement(Int_t)
Definition: TEcnaRootFile.cc:176
TEcnaRootFile::fRootFile
TFile * fRootFile
Definition: TEcnaRootFile.h:33
ClassImp
ClassImp(TEcnaRootFile)
TEcnaResultType::fIthElement
Int_t fIthElement
Definition: TEcnaResultType.h:57
TEcnaRootFile::ReadElementNextEntryNumber
Int_t ReadElementNextEntryNumber(CnaResultTyp, Int_t)
Definition: TEcnaRootFile.cc:195
TEcnaRootFile::fCnaIndivResult
TEcnaResultType * fCnaIndivResult
Definition: TEcnaRootFile.h:42
gCnaRootFile
TEcnaRootFile * gCnaRootFile
Definition: TEcnaRootFile.cc:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TEcnaRootFile::fCnaResultsTree
TTree * fCnaResultsTree
Definition: TEcnaRootFile.h:37
TEcnaRootFile::OpenW
Bool_t OpenW(const Text_t *="")
Definition: TEcnaRootFile.cc:156
TEcnaRootFile::CloseFile
void CloseFile()
Definition: TEcnaRootFile.cc:116