CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TB06Tree.cc
Go to the documentation of this file.
2 #include "TFile.h"
3 #include "TTree.h"
5 
6 #include <iostream>
7 
8 
10  const std::string & treeName):
11  m_file (0), m_tree (0), m_data (0), m_dataSize (0)
12 {
13  TDirectory *dir = gDirectory ;
14  m_file = new TFile (fileName.c_str (),"RECREATE") ;
15  m_file->cd () ;
16  m_tree = new TTree (treeName.c_str(),"Analysis tree") ;
17  m_tree->SetAutoSave (10000000) ;
18  dir->cd () ;
19 
20  // m_tree->cd () ;
21  m_data = new TClonesArray (TB06Reco::Class (), 1) ;
22  m_data->ExpandCreateFast (1) ;
23 
24  // m_tree->Branch ("EGCO", &m_data, 64000, 2) ;
25  m_tree->Branch ("TB06O", &m_data, 64000, 2) ;
26  m_tree->Print () ;
27 
28 }
29 
30 
31 // -------------------------------------------------------------------
32 
34 {
35  std::cout << "[TB06Tree][dtor] saving TTree " << m_tree->GetName ()
36  << " with " << m_tree->GetEntries () << " entries"
37  << " on file: " << m_file->GetName () << std::endl ;
38 
39  m_file->Write () ;
40  delete m_tree ;
41  m_file->Close () ;
42  delete m_file ;
43  delete m_data ;
44 }
45 
46 
47 // -------------------------------------------------------------------
48 
50  void TB06Tree::store (const int & tableIsMoving,
51  const int & run, const int & event,
52  const int & S6adc ,
53  const double & xhodo, const double & yhodo,
54  const double & xslope, const double & yslope,
55  const double & xquality, const double & yquality,
56  const int & icMax,
57  const int & ietaMax, const int & iphiMax,
58  const double & beamEnergy,
59  const double ampl[49])
60 {
61 
62  m_data->Clear () ;
63  TB06Reco * entry = static_cast<TB06Reco*> (m_data->AddrAt (0)) ;
64 
65  entry->reset () ;
66  // reset (entry->myCalibrationMap) ;
67 
68  entry->tableIsMoving = tableIsMoving ;
69  entry->run = run ;
70  entry->event = event ;
71  entry->S6ADC = S6adc ;
72 
73  entry->MEXTLindex = icMax ;
74  entry->MEXTLeta = ietaMax ;
75  entry->MEXTLphi = iphiMax ;
76  entry->MEXTLenergy = ampl[24] ;
77  entry->beamEnergy = beamEnergy ;
78 
79  for (int eta = 0 ; eta<7 ; ++eta)
80  for (int phi = 0 ; phi<7 ; ++phi)
81  {
82  // FIXME capire l'orientamento di phi!
83  // FIXME capire se eta, phi iniziano da 1 o da 0
84  entry->localMap[eta][phi] = ampl[eta*7+phi] ;
85  }
86 
87  entry->xHodo = xhodo ;
88  entry->yHodo = yhodo ;
89  entry->xSlopeHodo = xslope ;
90  entry->ySlopeHodo = yslope ;
91  entry->xQualityHodo = xquality ;
92  entry->yQualityHodo = yquality ;
93 
94  entry->convFactor = 0. ;
95 
96  /*
97  // loop over the 5x5 see (1)
98  for (int xtal=0 ; xtal<25 ; ++xtal)
99  {
100  int ieta = xtal/5 + 3 ;
101  int iphi = xtal%5 + 8 ;
102  entry->myCalibrationMap[ieta][iphi] = ampl[xtal] ;
103  } // loop over the 5x5
104 
105  entry->electron_Tr_Pmag_ = beamEnergy ;
106 
107  entry->centralCrystalEta_ = ietaMax ;
108  entry->centralCrystalPhi_ = iphiMax ;
109  entry->centralCrystalEnergy_ = ampl[12] ;
110 
111  // this is a trick
112  entry->electron_Tr_Peta_ = xhodo ;
113  entry->electron_Tr_Pphi_ = yhodo ;
114  */
115  m_tree->Fill () ;
116 }
117 
118 
119 // -------------------------------------------------------------------
120 
121 
122 void TB06Tree::reset (float crystal[11][21])
123 {
124  for (int eta =0 ; eta<11 ; ++eta)
125  {
126  for (int phi =0 ; phi<21 ; ++phi)
127  {
128  crystal[eta][phi] = -999. ;
129  }
130  }
131 }
132 
133 
134 // -------------------------------------------------------------------
135 
136 
138 {
139  TB06Reco * entry = static_cast<TB06Reco*> (m_data->AddrAt (0)) ;
140 
141  std::cout << "[TB06Tree][check]reading . . . \n" ;
142  std::cout << "[TB06Tree][check] entry->run: " << entry->run << "\n" ;
143  std::cout << "[TB06Tree][check] entry->event: " << entry->event << "\n" ;
144  std::cout << "[TB06Tree][check] entry->tableIsMoving: " << entry->tableIsMoving << "\n" ;
145  std::cout << "[TB06Tree][check] entry->MEXTLeta: " << entry->MEXTLeta << "\n" ;
146  std::cout << "[TB06Tree][check] entry->MEXTLphi: " << entry->MEXTLphi << "\n" ;
147  std::cout << "[TB06Tree][check] entry->MEXTLenergy: " << entry->MEXTLenergy << "\n" ;
148 
149  for (int eta = 0 ; eta<7 ; ++eta)
150  for (int phi = 0 ; phi<7 ; ++phi)
151  std::cout << "[TB06Tree][check] entry->localMap[" << eta
152  << "][" << phi << "]: "
153  << entry->localMap[eta][phi] << "\n" ;
154 
155  std::cout << "[TB06Tree][check] entry->xHodo: " << entry->xHodo << "\n" ;
156  std::cout << "[TB06Tree][check] entry->yHodo: " << entry->yHodo << "\n" ;
157  std::cout << "[TB06Tree][check] entry->xSlopeHodo: " << entry->xSlopeHodo << "\n" ;
158  std::cout << "[TB06Tree][check] entry->ySlopeHodo: " << entry->ySlopeHodo << "\n" ;
159  std::cout << "[TB06Tree][check] entry->xQualityHodo: " << entry->xQualityHodo << "\n" ;
160  std::cout << "[TB06Tree][check] entry->yQualityHodo: " << entry->yQualityHodo << "\n" ;
161  std::cout << "[TB06Tree][check] entry->convFactor: " << entry->convFactor << "\n" ;
162 
163  /* to be implemented with the right variables
164  std::cout << "[TB06Tree][check] ------------------------" << std::endl ;
165  std::cout << "[TB06Tree][check] " << entry->variable_name << std::endl ;
166  */
167 }
168 
169 
170 
171 /* (1) to fill the 25 crystals vector
172 
173  for (UInt_t icry=0 ; icry<25 ; ++icry)
174  {
175  UInt_t row = icry / 5 ;
176  Int_t column = icry % 5 ;
177  try
178  {
179  EBDetId tempo (maxHitId.ieta()+column-2,
180  maxHitId.iphi()+row-2,
181  EBDetId::ETAPHIMODE) ;
182 
183  Xtals5x5.push_back (tempo) ;
184  amplitude [icry] = hits->find (Xtals5x5[icry])->energy () ;
185 
186  }
187  catch ( std::runtime_error &e )
188  {
189  std::cout << "Cannot construct 5x5 matrix around EBDetId "
190  << maxHitId << std::endl ;
191  return ;
192  }
193  } // loop over the 5x5 matrix
194 
195 
196 */
Int_t run
run number
Definition: TB06Reco.h:15
Float_t convFactor
conversion factor from ADC to GeV used
Definition: TB06Reco.h:59
Float_t yHodo
hodoscope y coord (phi)
Definition: TB06Reco.h:46
Float_t localMap[7][7]
energy in 7x7 xtals around the most energetic one
Definition: TB06Reco.h:35
void reset(float crystal[11][21])
Definition: TB06Tree.cc:122
void store(const int &tableIsMoving, const int &run, const int &event, const int &S6adc, const double &xhodo, const double &yhodo, const double &xslope, const double &yslope, const double &xquality, const double &yquality, const int &icMax, const int &ietaMax, const int &iphiMax, const double &beamEnergy, const double ampl[49])
to be called at each loop
Definition: TB06Tree.cc:50
Int_t MEXTLeta
most energetic crystal eta
Definition: TB06Reco.h:26
void check()
Definition: TB06Tree.cc:137
Float_t xQualityHodo
hodoscope x quality (eta)
Definition: TB06Reco.h:54
Int_t event
event number
Definition: TB06Reco.h:17
Float_t MEXTLenergy
most energetic crystal energy
Definition: TB06Reco.h:30
TB06Tree(const std::string &fileName="TB06Tree.root", const std::string &treeName="Analysis")
ctor
Definition: TB06Tree.cc:9
Float_t xSlopeHodo
hodoscope x slope (eta)
Definition: TB06Reco.h:50
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Int_t MEXTLphi
most energetic crystal phi
Definition: TB06Reco.h:28
Float_t beamEnergy
energy of the beam
Definition: TB06Reco.h:32
void reset()
set all the values to 0
Definition: TB06Reco.cc:8
TFile * m_file
Definition: TB06Tree.h:39
Int_t tableIsMoving
if the table is moving
Definition: TB06Reco.h:19
TTree * m_tree
Definition: TB06Tree.h:40
TClonesArray * m_data
Definition: TB06Tree.h:42
Int_t MEXTLindex
most energetic crystal index
Definition: TB06Reco.h:24
tuple cout
Definition: gather_cfg.py:121
Int_t S6ADC
ADC output of the S6 integrated signal.
Definition: TB06Reco.h:21
dbl *** dir
Definition: mlp_gen.cc:35
Float_t yQualityHodo
hodoscope y quality (eta)
Definition: TB06Reco.h:56
Float_t ySlopeHodo
hodoscope y slope (eta)
Definition: TB06Reco.h:52
~TB06Tree()
dtor
Definition: TB06Tree.cc:33
Float_t xHodo
hodoscope x coord (eta)
Definition: TB06Reco.h:44