Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variability.cc
Go to the documentation of this file.
1 
2 #include "variability.hh"
3 #include "TH2.h"
4 #include "TStyle.h"
5 #include "TCanvas.h"
6 
7 ClassImp(variability) // used by THtml doc
8 
10 {
11  fChain= NULL;
12  fCurrent= a.fCurrent;
13  nevent= a.nevent;
14  ifo= a.ifo;
15  value= a.value;
16  time= a.time;
17  gps= a.gps;
18  return *this;
19 }
20 
21 // Set branch addresses
22 void variability::Init(TTree *tree)
23 {
24  if (tree == 0) return;
25  fChain = tree;
26  fCurrent = -1;
27  fChain->SetMakeClass(1);
28 
29  fChain->SetBranchAddress("nevent",&nevent);
30  fChain->SetBranchAddress("ifo",&ifo);
31  fChain->SetBranchAddress("value",&value);
32  fChain->SetBranchAddress("time",&time);
33  fChain->SetBranchAddress("gps",&gps);
34 
35  Notify();
36 }
37 
38 
39 //++++++++++++++++++++++++++++++++++++++++++++++
40 // set noise variability tree
41 //++++++++++++++++++++++++++++++++++++++++++++++
43 {
44  TTree* waveTree = new TTree("variability","variability");
45 
46  //==================================
47  // Define trigger tree
48  //==================================
49 
50  waveTree->Branch("nevent", &nevent, "nevent/I");
51  waveTree->Branch("ifo", &ifo, "ifo/I");
52  waveTree->Branch("value", &value, "value/F");
53  waveTree->Branch("time", &time, "time/D");
54  waveTree->Branch("gps", &gps, "gps/D");
55 
56  return waveTree;
57 }
58 
59 
60 //++++++++++++++++++++++++++++++++++++++++++++++++++++
61 // dump noise variability into tree
62 //++++++++++++++++++++++++++++++++++++++++++++++++++++
63 void variability::output(TTree* waveTree, wavearray<float>* p, int ifo_var, double t_var)
64 {
65  size_t i;
66  size_t n = p->size();
67  double rate_var = p->rate();
68  size_t m = size_t(t_var*rate_var+0.5); // time offset
69 
70  this->gps = p->start();
71 
72  if(m>n || !n) return;
73 
74 //Fill tree
75 
76  for(i=m; i<n-m; i++){
77  this->nevent= i;
78  this->ifo= ifo_var;
79  this->value= p->data[i];
80  this->time= this->gps + i/rate_var;
81  waveTree->Fill();
82  }
83 }
84 
85 
86 
88 {
89  // Called when loading a new file.
90  // Get branch pointers.
91  b_nevent = fChain->GetBranch("nevent");
92  b_ifo = fChain->GetBranch("ifo");
93  b_value = fChain->GetBranch("value");
94  b_time = fChain->GetBranch("time");
95  return kTRUE;
96 }
97 
99 {
100  if (!fChain) return 0;
101  return fChain->GetEntry(entry);
102 };
103 
105 {
106 // Print contents of entry.
107 // If entry is not specified, print current entry
108  if (!fChain) return;
109  fChain->Show(entry);
110 }
111 
112 /*
113 Int_t variability::LoadTree(Int_t entry)
114 {
115 // Set the environment to read one entry
116  if (!fChain) return -5;
117  Int_t centry = fChain->LoadTree(entry);
118  if (centry < 0) return centry;
119  if (fChain->IsA() != TChain::Class()) return centry;
120  TChain *chain = (TChain*)fChain;
121  if (chain->GetTreeNumber() != fCurrent) {
122  fCurrent = chain->GetTreeNumber();
123  Notify();
124  }
125  return centry;
126 }
127 
128 Int_t variability::Cut(Int_t entry)
129 {
130 // This function may be called from Loop.
131 // returns 1 if entry is accepted.
132 // returns -1 otherwise.
133  return 1;
134 }
135 
136 void variability::Loop()
137 {
138 // In a ROOT session, you can do:
139 // Root > .L variability.C
140 // Root > variability t
141 // Root > t.GetEntry(12); // Fill t data members with entry number 12
142 // Root > t.Show(); // Show values of entry 12
143 // Root > t.Show(16); // Read and show values of entry 16
144 // Root > t.Loop(); // Loop on all entries
145 //
146 
147 // This is the loop skeleton where:
148 // jentry is the global entry number in the chain
149 // ientry is the entry number in the current Tree
150 // Note that the argument to GetEntry must be:
151 // jentry for TChain::GetEntry
152 // ientry for TTree::GetEntry and TBranch::GetEntry
153 //
154 // To read only selected branches, Insert statements like:
155 // METHOD1:
156 // fChain->SetBranchStatus("*",0); // disable all branches
157 // fChain->SetBranchStatus("branchname",1); // activate branchname
158 // METHOD2: replace line
159 // fChain->GetEntry(jentry); //read all branches
160 //by b_branchname->GetEntry(ientry); //read only this branch
161  if (fChain == 0) return;
162 
163  Int_t nentries = Int_t(fChain->GetEntriesFast());
164 
165  Int_t nbytes = 0, nb = 0;
166  for (Int_t jentry=0; jentry<nentries;jentry++) {
167  Int_t ientry = LoadTree(jentry);
168  if (ientry < 0) break;
169  nb = fChain->GetEntry(jentry); nbytes += nb;
170  // if (Cut(ientry) < 0) continue;
171  }
172 }
173 */
174 
175 
176 
177 
178 
179 
180 
181 
TTree * tree
Definition: TimeSortTree.C:20
virtual size_t size() const
Definition: wavearray.hh:127
TTree * setTree()
Definition: variability.cc:42
par[0] value
virtual void rate(double r)
Definition: wavearray.hh:123
wavearray< double > a(hp.size())
int n
Definition: cwb_net.C:10
TBranch * b_ifo
Definition: variability.hh:35
TTree * fChain
Definition: variability.hh:20
int m
Definition: cwb_net.C:10
virtual void start(double s)
Definition: wavearray.hh:119
i drho i
TBranch * b_nevent
Definition: variability.hh:34
Double_t gps
Definition: variability.hh:30
char ifo[NIFO_MAX][8]
double time[6]
Definition: cbc_plots.C:435
Int_t GetEntry(Int_t)
Definition: variability.cc:98
TBranch * b_value
Definition: variability.hh:36
Int_t fCurrent
pointer to the analyzed TTree or TChain
Definition: variability.hh:21
double * entry
Definition: cwb_setcuts.C:206
Int_t nevent
current Tree number in a TChain
Definition: variability.hh:26
void Show(Int_t entry=-1)
Definition: variability.cc:104
double gps
Double_t time
Definition: variability.hh:29
void Init(TTree *)
Definition: variability.cc:22
TBranch * b_time
Definition: variability.hh:37
Float_t value
Definition: variability.hh:28
DataType_t * data
Definition: wavearray.hh:301
void output(TTree *, wavearray< float > *, int=0, double=0.)
Definition: variability.cc:63
Bool_t Notify()
Definition: variability.cc:87