FEDRA emulsion software from the OPERA Collaboration
EdbCouplesTree Class Reference

#include <EdbCouplesTree.h>

Inheritance diagram for EdbCouplesTree:
Collaboration diagram for EdbCouplesTree:

Public Member Functions

void ApplyCorrections ()
 
void Close ()
 
 EdbCouplesTree ()
 
Int_t Fill ()
 
Int_t Fill (EdbSegP *s1, EdbSegP *s2, EdbSegP *s=0, EdbSegCouple *cp=0, float xv=0, float yv=0, int pid1=0, int pid2=0)
 
int GetCPData (EdbPattern *pat, EdbPattern *p1=0, EdbPattern *p2=0, TIndex2 *trseg=0)
 
int GetCPData (TObjArray &cparr)
 
int GetCPDataAcceptedMask (EdbPattern *pat)
 
int GetEntry (int i)
 
const char * GetFileName () const
 
bool InitCouplesTree (const char *name="couples", const char *fname=0, Option_t *mode="READ")
 
TEventList * InitCutList ()
 
void Print ()
 
int PutCPData (TObjArray &cparr)
 
void RankCouples (TObjArray &cparr)
 
bool WriteTree ()
 
virtual ~EdbCouplesTree ()
 

Public Attributes

EdbMaskeAcceptMask
 id's (entries) of segments to be accepted when read couples tree More...
 
bool eApplyCorrections
 if true - apply corrections stored in ePlate when do GetEntry More...
 
EdbSegCoupleeCP
 couples object More...
 
TCut eCut
 cut to be applied on read More...
 
EdbMaskeEraseMask
 id's (entries) of segments to be erased when read couples tree More...
 
Int_t ePid1
 
Int_t ePid2
 
EdbPlateP ePlate
 
EdbSegPeS
 segments to be written More...
 
EdbSegPeS1
 branches: More...
 
EdbSegPeS2
 
TTree * eTree
 couples tree More...
 
Float_t eXv
 
Float_t eYv
 relative center More...
 

Constructor & Destructor Documentation

◆ EdbCouplesTree()

EdbCouplesTree::EdbCouplesTree ( )

◆ ~EdbCouplesTree()

EdbCouplesTree::~EdbCouplesTree ( )
virtual

most of the members pointers can be the property of other objects If the file should be closed - use Close()

41{
44 //SafeDelete(eTree);
45 //SafeDelete(eS);
46 //SafeDelete(eS1);
47 //SafeDelete(eS2);
48 //SafeDelete(eEraseMask);
49}

Member Function Documentation

◆ ApplyCorrections()

void EdbCouplesTree::ApplyCorrections ( )

196{
197}

◆ Close()

void EdbCouplesTree::Close ( )

63{
64 if (eTree) {
65 TFile *f = (TFile*)(eTree->GetDirectory()->GetFile());
66 if (f) {
67 //f->Print();
68 if(f->IsWritable()) eTree->AutoSave();
69 f->Close();
70 //SafeDelete(eTree);
71 //SafeDelete(f);
72 }
73 //SafeDelete(eTree);
74 //eTree=NULL;
75 }
76}
FILE * f
Definition: RecDispMC.C:150
TTree * eTree
couples tree
Definition: EdbCouplesTree.h:25

◆ Fill() [1/2]

Int_t EdbCouplesTree::Fill ( )
182{
183 return eTree->Fill();
184}

◆ Fill() [2/2]

Int_t EdbCouplesTree::Fill ( EdbSegP s1,
EdbSegP s2,
EdbSegP s = 0,
EdbSegCouple cp = 0,
float  xv = 0,
float  yv = 0,
int  pid1 = 0,
int  pid2 = 0 
)
173{
174 eS1=s1; eS2=s2; eS=s; eCP=cp;
175 eXv=xv; eYv=yv; ePid1=pid1; ePid2=pid2;
176 //eDZ1 = dz1; eDZ2 = dz2; eFlag=flag;
177 return Fill();
178}
Float_t eYv
relative center
Definition: EdbCouplesTree.h:22
EdbSegP * eS2
Definition: EdbCouplesTree.h:20
EdbSegP * eS1
branches:
Definition: EdbCouplesTree.h:20
Int_t ePid1
Definition: EdbCouplesTree.h:23
Float_t eXv
Definition: EdbCouplesTree.h:22
Int_t ePid2
Definition: EdbCouplesTree.h:23
EdbSegCouple * eCP
couples object
Definition: EdbCouplesTree.h:21
Int_t Fill()
Definition: EdbCouplesTree.cxx:181
EdbSegP * eS
segments to be written
Definition: EdbCouplesTree.h:20
s
Definition: check_shower.C:55
EdbSegP * s1
Definition: tlg2couples.C:29
EdbSegP * s2
Definition: tlg2couples.C:30
EdbSegCouple * cp
Definition: tlg2couples.C:28

◆ GetCPData() [1/2]

int EdbCouplesTree::GetCPData ( EdbPattern pat,
EdbPattern p1 = 0,
EdbPattern p2 = 0,
TIndex2 trseg = 0 
)

TO CHECK !!!

297{
298 TEventList *lst = InitCutList();
299 int nlst =lst->GetN();
300
301 int nseg = 0, nerase=0;
302 pat->SetID(0);
303
304 int entr=0;
305 for(int i=0; i<nlst; i++ ) {
306 entr = lst->GetEntry(i);
307
308// if(trseg) { //exclude segments participating in tracks
309// if( (trseg->Find(ePlate*1000+ePiece,entr) >= 0) ) continue;
310// }
311
312 if(eEraseMask) if(eEraseMask->At(entr)) {
313 Log(3,"EdbCouplesTree::GetCPData","erase %d\n",entr);
314 nerase++;
315 continue;
316 }
317
318 GetEntry(entr);
319
320 if(pat) {
321 eS->SetZ( eS->Z() + pat->Z() );
322 //ToDo: s->SetVid(ePlate*1000+ePiece,entr);
323 eS->SetChi2(eCP->CHI2P());
324 pat->AddSegment( *eS );
325 nseg++;
326 }
327 if(p1) {
328 eS1->SetZ( eS1->Z() + pat->Z() );
329 p1->AddSegment( *eS1 );
330 nseg++;
331 }
332 if(p2) {
333 eS2->SetZ( eS2->Z() + pat->Z() );
334 p2->AddSegment( *eS2 );
335 nseg++;
336 }
337 }
338
339 SafeDelete(lst);
340
341 Log(2,"EdbCouplesTree::GetCPData","select %d of %d segments by cut %s ; %d are erased by mask",nlst, (int)(eTree->GetEntries()), eCut.GetTitle(), nerase);
342
343 return nseg;
344}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
TCut eCut
cut to be applied on read
Definition: EdbCouplesTree.h:31
int GetEntry(int i)
Definition: EdbCouplesTree.cxx:187
EdbMask * eEraseMask
id's (entries) of segments to be erased when read couples tree
Definition: EdbCouplesTree.h:27
TEventList * InitCutList()
Definition: EdbCouplesTree.cxx:267
int At(int i)
Definition: EdbMask.h:19
void SetID(int id)
Definition: EdbPattern.h:309
float CHI2P() const
Definition: EdbSegCouple.h:62
Float_t Z() const
Definition: EdbSegP.h:153
void SetZ(float z)
Definition: EdbSegP.h:125
void SetChi2(float chi2)
Definition: EdbSegP.h:135
Float_t Z() const
Definition: EdbPattern.h:84
EdbSegP * AddSegment(int i, EdbSegP &s)
Definition: EdbPattern.cxx:72

◆ GetCPData() [2/2]

int EdbCouplesTree::GetCPData ( TObjArray &  cparr)

read segments into array of EdbSegCouple objects

201{
203 TEventList *lst = InitCutList();
204 int nlst =lst->GetN();
205 int nseg = 0, nerase=0;
206 int entr=0;
207 for(int i=0; i<nlst; i++ ) {
208 entr = lst->GetEntry(i);
209
210 if(eEraseMask) if(eEraseMask->At(entr)) {
211 Log(3,"EdbCouplesTree::GetCPData","erase %d\n",entr);
212 nerase++;
213 continue;
214 }
215
216 GetEntry(entr);
218 cp->eS = new EdbSegP(*eS);
219 cp->eS1 = new EdbSegP(*eS1);
220 cp->eS2 = new EdbSegP(*eS2);
221 cparr.Add( cp );
222
223 nseg++;
224 }
225
226 SafeDelete(lst);
227
228 Log(2,"EdbCouplesTree::GetCPData","select %d of %d segments by cut %s ; %d erased by mask",nlst, (int)(eTree->GetEntries()), eCut.GetTitle(), nerase);
229
230 return nseg;
231}
Definition: EdbSegCouple.h:17
EdbSegP * eS
the result of the fit
Definition: EdbSegCouple.h:27
EdbSegP * eS2
Definition: EdbSegCouple.h:29
EdbSegP * eS1
pointers - useful when all segments are in memory
Definition: EdbSegCouple.h:28
Definition: EdbSegP.h:21

◆ GetCPDataAcceptedMask()

int EdbCouplesTree::GetCPDataAcceptedMask ( EdbPattern pat)

TO CHECK !!!

348{
349 if(!eAcceptMask) return 0;
350 int n = eAcceptMask->N();
351 pat->SetID(0);
352 int nseg=0;
353 for(int i=0; i<n; i++ ) {
354 if(eAcceptMask->At(i)>0) {
355 GetEntry(i);
356 if(pat) {
357 eS->SetZ( eS->Z() + pat->Z() );
358 //ToDo: s->SetVid(ePlate*1000+ePiece,entr);
359 eS->SetChi2(eCP->CHI2P());
360 pat->AddSegment( *eS );
361 nseg++;
362 }
363 }
364 }
365
366 Log(2,"EdbCouplesTree::GetCPDataAcceptedMask","select %d of %d segments",nseg, (int)(eTree->GetEntries()));
367
368 return nseg;
369}
EdbMask * eAcceptMask
id's (entries) of segments to be accepted when read couples tree
Definition: EdbCouplesTree.h:28
int N()
Definition: EdbMask.h:18

◆ GetEntry()

int EdbCouplesTree::GetEntry ( int  i)

188{
189 int size = eTree->GetEntry(i);
191 return size;
192}
void ApplyCorrections()
Definition: EdbCouplesTree.cxx:195
bool eApplyCorrections
if true - apply corrections stored in ePlate when do GetEntry
Definition: EdbCouplesTree.h:32

◆ GetFileName()

const char * EdbCouplesTree::GetFileName ( ) const
inline
51{ if(eTree->GetCurrentFile()) return eTree->GetCurrentFile()->GetName(); else return 0;}

◆ InitCouplesTree()

bool EdbCouplesTree::InitCouplesTree ( const char *  name = "couples",
const char *  fname = 0,
Option_t *  mode = "READ" 
)
80{
81 Log(3,"EdbCouplesTree::InitCouplesTree","%s at file %s as %s",name,fname,mode);
82 if(fname) { // if fname==0 - assumed that file is already opened
83 //TFile *f = new TFile(fname, mode);
84 //printf("\n ROOT dir before:\n"); gDirectory->ls(); printf("\n");
85 TFile *f = TFile::Open(fname, mode);
86 //printf("\n ROOT dir after:\n"); gDirectory->ls(); printf("\n");
87 if (!f->IsOpen()) return 0;
88 f->cd();
89 }
90 if( (strcmp(mode,"READ")==0)||(strcmp(mode,"UPDATE")==0)) {
91 eTree = (TTree*)gDirectory->Get(name);
92 if(!eTree) {Log(1,"EdbCouplesTree::InitCouplesTree","ERROR: can not open tree %s",name); return 0;}
93
94 eTree->SetBranchAddress("pid1", &ePid1);
95 eTree->SetBranchAddress("pid2", &ePid2);
96 eTree->SetBranchAddress("xv" , &eXv);
97 eTree->SetBranchAddress("yv" , &eYv);
98 eTree->SetBranchAddress("cp" , &eCP);
99 eTree->SetBranchAddress("s1." , &eS1);
100 eTree->SetBranchAddress("s2." , &eS2);
101 eTree->SetBranchAddress("s." , &eS);
102 } else {
103 eTree = new TTree(name, "couples tree (s1:s2:s)");
104 eTree->SetMaxTreeSize(15000000000LL); //set 15 Gb file size limit)
105
106 eTree->Branch("pid1", &ePid1,"pid1/I");
107 eTree->Branch("pid2", &ePid2,"pid2/I");
108 eTree->Branch("xv" , &eXv,"xv/F");
109 eTree->Branch("yv" , &eYv,"yv/F");
110 eTree->Branch("cp" , &eCP,32000,99);
111 eTree->Branch("s1." , &eS1,32000,99);
112 eTree->Branch("s2." , &eS2,32000,99);
113 eTree->Branch("s." , &eS,32000,99);
114 }
115
116 return 1;
117}
const char * fname
Definition: mc2raw.cxx:41
const char * name
Definition: merge_Energy_SytematicSources_Electron.C:24

◆ InitCutList()

TEventList * EdbCouplesTree::InitCutList ( )

268{
269 if(!eTree) return 0;
270 int nentr = (int)(eTree->GetEntries()); if(nentr<1) return 0;
271 eTree->Draw(">>lst", eCut );
272 TEventList *lst = (TEventList*)(gDirectory->GetList()->FindObject("lst"));
273 if(!lst) {Log(1,"EdbCouplesTree::GetCPData","ERROR!: events list (lst) did not found! In couples tree %d entries",nentr); return 0;}
274 return lst;
275}

◆ Print()

void EdbCouplesTree::Print ( )
53{
54 Log(1,"EdbCouplesTree::Print","s1 s2 s cp:");
55 if(eS1) eS1->PrintNice();
56 if(eS2) eS2->PrintNice();
57 if(eS) eS->PrintNice();
58 if(eCP) eCP->Print();
59}
void Print()
Definition: EdbSegCouple.cxx:68
void PrintNice() const
Definition: EdbSegP.cxx:392

◆ PutCPData()

int EdbCouplesTree::PutCPData ( TObjArray &  cparr)

279{
280 int n = cparr.GetEntries();
281 for(int i=0; i<n; i++)
282 {
283 EdbSegCouple *cp = (EdbSegCouple *)cparr.UncheckedAt(i);
284 if(cp) {
285 eCP = cp;
286 eS = cp->eS;
287 eS1 = cp->eS1;
288 eS2 = cp->eS2;
289 Fill();
290 }
291 }
292 return n;
293}

◆ RankCouples()

void EdbCouplesTree::RankCouples ( TObjArray &  cparr)

rank couples if in cparr the same segment's pointer appare in several combinations

235{
237 EdbSegCouple::SetSortFlag(0); // sort by CHI2P
238 cparr.UnSort();
239 cparr.Sort();
240
241 int ncp = cparr.GetEntries();
242
243 for(int i=0; i<ncp; i++) {
244 EdbSegCouple *sc = (EdbSegCouple*)(cparr.UncheckedAt(i));
245 sc->eS1->SetFlag(0);
246 sc->eS2->SetFlag(0);
247 }
248
249 for(int i=0; i<ncp; i++) {
250 EdbSegCouple *sc = (EdbSegCouple*)(cparr.UncheckedAt(i));
251 sc->eS1->SetFlag( sc->eS1->Flag()+1 );
252 sc->eS2->SetFlag( sc->eS2->Flag()+1 );
253 sc->SetN1(sc->eS1->Flag());
254 sc->SetN2(sc->eS2->Flag());
255 }
256
257 for(int i=0; i<ncp; i++) {
258 EdbSegCouple *sc = (EdbSegCouple*)(cparr.UncheckedAt(i));
259 sc->SetN1tot(sc->eS1->Flag());
260 sc->SetN2tot(sc->eS2->Flag());
261 }
262
263 Log(2,"EdbCouplesTree::RankCouples","%d couples ok", ncp );
264}
void SetN1(int n1)
Definition: EdbSegCouple.h:43
void SetN2(int n2)
Definition: EdbSegCouple.h:44
void SetN1tot(int n)
Definition: EdbSegCouple.h:45
void SetN2tot(int n)
Definition: EdbSegCouple.h:46
static void SetSortFlag(int s=0)
Definition: EdbSegCouple.cxx:62
void SetFlag(int flag)
Definition: EdbSegP.h:130
Int_t Flag() const
Definition: EdbSegP.h:149

◆ WriteTree()

bool EdbCouplesTree::WriteTree ( )
164{
165 if(!eTree) return 0;
166 eTree->Write();
167 SafeDelete(eTree);
168 return 1;
169}

Member Data Documentation

◆ eAcceptMask

EdbMask* EdbCouplesTree::eAcceptMask

id's (entries) of segments to be accepted when read couples tree

Correction parameters

◆ eApplyCorrections

bool EdbCouplesTree::eApplyCorrections

if true - apply corrections stored in ePlate when do GetEntry

◆ eCP

EdbSegCouple* EdbCouplesTree::eCP

couples object

◆ eCut

TCut EdbCouplesTree::eCut

cut to be applied on read

◆ eEraseMask

EdbMask* EdbCouplesTree::eEraseMask

id's (entries) of segments to be erased when read couples tree

◆ ePid1

Int_t EdbCouplesTree::ePid1

◆ ePid2

Int_t EdbCouplesTree::ePid2

◆ ePlate

EdbPlateP EdbCouplesTree::ePlate

◆ eS

EdbSegP * EdbCouplesTree::eS

segments to be written

◆ eS1

EdbSegP* EdbCouplesTree::eS1

branches:

◆ eS2

EdbSegP * EdbCouplesTree::eS2

◆ eTree

TTree* EdbCouplesTree::eTree

couples tree

◆ eXv

Float_t EdbCouplesTree::eXv

◆ eYv

Float_t EdbCouplesTree::eYv

relative center


The documentation for this class was generated from the following files: