FEDRA emulsion software from the OPERA Collaboration
chain2run.C File Reference

Functions

void chain2run (TChain &c, char *rout="r.root")
 
bool GoodEvent (EdbView *v)
 

Function Documentation

◆ chain2run()

void chain2run ( TChain &  c,
char *  rout = "r.root" 
)
11 {
12  // input - chain of files(runs) - output is one run
13 
14  EdbRun r( rout, "RECREATE" );
15  r.GetFile()->SetCompressionLevel(9);
16  EdbView *v = r.GetView();
17 
18  c.SetBranchStatus("clusters", 0 );
19  c.SetBranchAddress("frames", v->GetFramesAddr() );
20  c.SetBranchAddress("headers", v->GetHeaderAddr() );
21  c.SetBranchAddress("segments", v->GetSegmentsAddr() );
22 
23  int n=c.GetEntries();
24  printf("entries=%d\n",n);
25  for(int i=0; i<n; i++) {
26  c.GetEntry(i);
27 
28  if( !GoodEvent(v) ) continue; // selections
29  v->GetHeader()->SetStatus( c.GetTreeNumber() ); // keep memory about each tree (if needed)
30  r.AddView(v);
31  if( !(i%1000) ) printf("%d (%d\%)\n",i,100*i/n);
32  }
33  r.Close();
34 }
bool GoodEvent(EdbView *v)
Definition: chain2run.C:37
Definition: EdbRun.h:74
void SetStatus(int st)
Definition: EdbView.h:106
Definition: EdbView.h:134
EdbViewHeader * GetHeader() const
Definition: EdbView.h:163
void * GetSegmentsAddr()
Definition: EdbView.h:171
void * GetFramesAddr()
Definition: EdbView.h:173
void * GetHeaderAddr()
Definition: EdbView.h:169
void r(int rid=2)
Definition: test.C:201

◆ GoodEvent()

bool GoodEvent ( EdbView v)
38 {
39  // do all selections here
40 
41  if( v->Nsegments() < 0) return 0;
42  TObjArray *segs = v->GetSegments();
43  int n = v->Nsegments();
44  for(int i=0; i<n; i++) {
45  s = v->GetSegment(i);
46  if( s->GetPuls()<8 )
47  { segs->RemoveAt(i); continue; }
48  if( TMath::Sqrt(s->GetTx()*s->GetTx() + s->GetTy()*s->GetTy()) >0.5 )
49  { segs->RemoveAt(i); continue;}
50  }
51  segs->Compress();
52 
53  return true;
54 }
Int_t Nsegments() const
Definition: EdbView.h:216
EdbSegment * GetSegment(int i) const
Definition: EdbView.h:219
TClonesArray * GetSegments() const
Definition: EdbView.h:165
EdbSegP * s
Definition: tlg2pattern.C:32