CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TB06TreeH2.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 (TB06RecoH2::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 << "[TB06TreeH2][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 TB06TreeH2::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  const int &wcAXo,const int &wcAYo,
61  const int &wcBXo,const int &wcBYo,
62  const int &wcCXo,const int &wcCYo,
63  const double & xwA, const double & ywA,
64  const double & xwB, const double & ywB,
65  const double & xwC, const double & ywC,
66  const float &S1adc, const float &S2adc,
67  const float &S3adc, const float &S4adc,
68  const float &VM1,const float &VM2,const float &VM3,
69  const float &VM4,const float &VM5,const float &VM6,
70  const float &VM7,const float &VM8,const float &VMF,
71  const float &VMB,
72  const float &CK1,const float &CK2, const float &CK3,
73  const float &BH1,const float &BH2,const float &BH3,
74  const float &BH4,
75  const float &TOF1S, const float &TOF2S,
76  const float &TOF1J,const float &TOF2J
77  )
78 {
79 
80  m_data->Clear () ;
81  TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
82 
83  entry->reset () ;
84  // reset (entry->myCalibrationMap) ;
85 
86  entry->tableIsMoving = tableIsMoving ;
87  entry->run = run ;
88  entry->event = event ;
89  entry->S6ADC = S6adc ;
90 
91  entry->MEXTLindex = icMax ;
92  entry->MEXTLeta = ietaMax ;
93  entry->MEXTLphi = iphiMax ;
94  entry->MEXTLenergy = ampl[24] ;
95  entry->beamEnergy = beamEnergy ;
96 
97  for (int eta = 0 ; eta<7 ; ++eta)
98  for (int phi = 0 ; phi<7 ; ++phi)
99  {
100  // FIXME capire l'orientamento di phi!
101  // FIXME capire se eta, phi iniziano da 1 o da 0
102  entry->localMap[eta][phi] = ampl[eta*7+phi] ;
103  }
104 
105  //[Edgar] S1 uncleaned, uncalibrated energy
106  entry->S1uncalib_ = ampl[24];
107 
108  //[Edgar] S25 uncleaned, uncalibrated energy
109  for (int eta = 1 ; eta<6 ; ++eta)
110  for (int phi = 1 ; phi<6 ; ++phi)
111  {
112  entry->S25uncalib_ += entry->localMap[eta][phi] ;
113  }
114 
115  //[Edgar] S49 uncleaned, uncalibrated energy
116  for (int eta = 0 ; eta<7 ; ++eta)
117  for (int phi = 0 ; phi<7 ; ++phi)
118  {
119  entry->S49uncalib_ += entry->localMap[eta][phi] ;
120  }
121 
122  //[Edgar] S9 uncleaned, uncalibrated energy
123  for (int eta = 2 ; eta<5 ; ++eta)
124  for (int phi = 2 ; phi<5 ; ++phi)
125  {
126  entry->S9uncalib_ += entry->localMap[eta][phi] ;
127  }
128 
129  entry->xHodo = xhodo ;
130  entry->yHodo = yhodo ;
131  entry->xSlopeHodo = xslope ;
132  entry->ySlopeHodo = yslope ;
133  entry->xQualityHodo = xquality ;
134  entry->yQualityHodo = yquality ;
135  entry->wcAXo_ = wcAXo;
136  entry->wcAYo_ = wcAYo;
137  entry->wcBXo_ = wcBXo;
138  entry->wcBYo_ = wcBYo;
139  entry->wcCXo_ = wcCXo;
140  entry->wcCYo_ = wcCYo;
141  entry->xwA_ = xwA;
142  entry->ywA_ = ywA;
143  entry->xwB_ = xwB;
144  entry->ywB_ = ywB;
145  entry->xwC_ = xwC;
146  entry->ywC_ = ywC;
147  entry->S1adc_ = S1adc;
148  entry->S2adc_ = S2adc;
149  entry->S3adc_ = S3adc;
150  entry->S4adc_ = S4adc;
151  entry->VM1_ = VM1;
152  entry->VM2_ = VM2;
153  entry->VM3_ = VM3;
154  entry->VM4_ = VM4;
155  entry->VM5_ = VM5;
156  entry->VM6_ = VM6;
157  entry->VM7_ = VM7;
158  entry->VM8_ = VM8;
159  entry->VMF_ = VMF;
160  entry->VMB_ = VMB;
161  entry->CK1_ = CK1;
162  entry->CK2_ = CK2;
163  entry->CK3_ = CK3;
164  entry->BH1_ = BH1;
165  entry->BH2_ = BH2;
166  entry->BH3_ = BH3;
167  entry->BH4_ = BH4;
168  entry->TOF1S_ = TOF1S;
169  entry->TOF2S_ = TOF2S;
170  entry->TOF1J_ = TOF1J;
171  entry->TOF2J_ = TOF2J;
172 
173  entry->convFactor = 0. ;
174 
175  /*
176  // loop over the 5x5 see (1)
177  for (int xtal=0 ; xtal<25 ; ++xtal)
178  {
179  int ieta = xtal/5 + 3 ;
180  int iphi = xtal%5 + 8 ;
181  entry->myCalibrationMap[ieta][iphi] = ampl[xtal] ;
182  } // loop over the 5x5
183 
184  entry->electron_Tr_Pmag_ = beamEnergy ;
185 
186  entry->centralCrystalEta_ = ietaMax ;
187  entry->centralCrystalPhi_ = iphiMax ;
188  entry->centralCrystalEnergy_ = ampl[12] ;
189 
190  // this is a trick
191  entry->electron_Tr_Peta_ = xhodo ;
192  entry->electron_Tr_Pphi_ = yhodo ;
193  */
194  m_tree->Fill () ;
195 }
196 
197 
198 // -------------------------------------------------------------------
199 
200 
201 void TB06TreeH2::reset (float crystal[11][21])
202 {
203  for (int eta =0 ; eta<11 ; ++eta)
204  {
205  for (int phi =0 ; phi<21 ; ++phi)
206  {
207  crystal[eta][phi] = -999. ;
208  }
209  }
210 }
211 
212 
213 // -------------------------------------------------------------------
214 
215 
217 {
218  TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
219 
220  std::cout << "[TB06TreeH2][check]reading . . . \n" ;
221  std::cout << "[TB06TreeH2][check] entry->run: " << entry->run << "\n" ;
222  std::cout << "[TB06TreeH2][check] entry->event: " << entry->event << "\n" ;
223  std::cout << "[TB06TreeH2][check] entry->tableIsMoving: " << entry->tableIsMoving << "\n" ;
224  std::cout << "[TB06TreeH2][check] entry->MEXTLeta: " << entry->MEXTLeta << "\n" ;
225  std::cout << "[TB06TreeH2][check] entry->MEXTLphi: " << entry->MEXTLphi << "\n" ;
226  std::cout << "[TB06TreeH2][check] entry->MEXTLenergy: " << entry->MEXTLenergy << "\n" ;
227 
228  for (int eta = 0 ; eta<7 ; ++eta)
229  for (int phi = 0 ; phi<7 ; ++phi)
230  std::cout << "[TB06TreeH2][check] entry->localMap[" << eta
231  << "][" << phi << "]: "
232  << entry->localMap[eta][phi] << "\n" ;
233 
234  std::cout << "[TB06TreeH2][check] entry->xHodo: " << entry->xHodo << "\n" ;
235  std::cout << "[TB06TreeH2][check] entry->yHodo: " << entry->yHodo << "\n" ;
236  std::cout << "[TB06TreeH2][check] entry->xSlopeHodo: " << entry->xSlopeHodo << "\n" ;
237  std::cout << "[TB06TreeH2][check] entry->ySlopeHodo: " << entry->ySlopeHodo << "\n" ;
238  std::cout << "[TB06TreeH2][check] entry->xQualityHodo: " << entry->xQualityHodo << "\n" ;
239  std::cout << "[TB06TreeH2][check] entry->yQualityHodo: " << entry->yQualityHodo << "\n" ;
240  std::cout << "[TB06TreeH2][check] entry->convFactor: " << entry->convFactor << "\n" ;
241 
242  /* to be implemented with the right variables
243  std::cout << "[TB06TreeH2][check] ------------------------" << std::endl ;
244  std::cout << "[TB06TreeH2][check] " << entry->variable_name << std::endl ;
245  */
246 }
247 
248 
249 
250 /* (1) to fill the 25 crystals vector
251 
252  for (UInt_t icry=0 ; icry<25 ; ++icry)
253  {
254  UInt_t row = icry / 5 ;
255  Int_t column = icry % 5 ;
256  try
257  {
258  EBDetId tempo (maxHitId.ieta()+column-2,
259  maxHitId.iphi()+row-2,
260  EBDetId::ETAPHIMODE) ;
261 
262  Xtals5x5.push_back (tempo) ;
263  amplitude [icry] = hits->find (Xtals5x5[icry])->energy () ;
264 
265  }
266  catch ( std::runtime_error &e )
267  {
268  std::cout << "Cannot construct 5x5 matrix around EBDetId "
269  << maxHitId << std::endl ;
270  return ;
271  }
272  } // loop over the 5x5 matrix
273 
274 
275 */
Float_t TOF1S_
Definition: TB06RecoH2.h:105
float ywA_
Definition: TB06RecoH2.h:72
TClonesArray * m_data
Definition: TB06TreeH2.h:59
Float_t CK1_
Definition: TB06RecoH2.h:96
Float_t S1adc_
Definition: TB06RecoH2.h:77
int wcBXo_
Definition: TB06RecoH2.h:67
float ywB_
Definition: TB06RecoH2.h:74
Float_t TOF2S_
Definition: TB06RecoH2.h:106
Float_t BH2_
Definition: TB06RecoH2.h:101
float ywC_
Definition: TB06RecoH2.h:76
Float_t S9uncalib_
Definition: TB06RecoH2.h:63
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], const int &wcAXo, const int &wcAYo, const int &wcBXo, const int &wcBYo, const int &wcCXo, const int &wcCYo, const double &xwA, const double &ywA, const double &xwB, const double &ywB, const double &xwC, const double &ywC, const float &S1adc, const float &S2adc, const float &S3adc, const float &S4adc, const float &VM1, const float &VM2, const float &VM3, const float &VM4, const float &VM5, const float &VM6, const float &VM7, const float &VM8, const float &VMF, const float &VMB, const float &CK1, const float &CK2, const float &CK3, const float &BH1, const float &BH2, const float &BH3, const float &BH4, const float &TOF1S, const float &TOF2S, const float &TOF1J, const float &TOF2J)
to be called at each loop
Definition: TB06TreeH2.cc:50
int wcCYo_
Definition: TB06RecoH2.h:70
Float_t TOF1J_
Definition: TB06RecoH2.h:107
int wcCXo_
Definition: TB06RecoH2.h:69
Float_t xSlopeHodo
hodoscope x slope (eta)
Definition: TB06RecoH2.h:50
Int_t S6ADC
ADC output of the S6 integrated signal.
Definition: TB06RecoH2.h:21
Float_t yHodo
hodoscope y coord (phi)
Definition: TB06RecoH2.h:46
Float_t xHodo
hodoscope x coord (eta)
Definition: TB06RecoH2.h:44
void reset()
set all the values to 0
Definition: TB06RecoH2.cc:8
Int_t MEXTLeta
most energetic crystal eta
Definition: TB06RecoH2.h:26
Float_t S3adc_
Definition: TB06RecoH2.h:79
Int_t tableIsMoving
if the table is moving
Definition: TB06RecoH2.h:19
Float_t VM8_
Definition: TB06RecoH2.h:91
Float_t S4adc_
Definition: TB06RecoH2.h:80
~TB06TreeH2()
dtor
Definition: TB06TreeH2.cc:33
Int_t event
event number
Definition: TB06RecoH2.h:17
float xwC_
Definition: TB06RecoH2.h:75
Float_t VM3_
Definition: TB06RecoH2.h:86
Float_t MEXTLenergy
most energetic crystal energy
Definition: TB06RecoH2.h:30
float xwB_
Definition: TB06RecoH2.h:73
Float_t ySlopeHodo
hodoscope y slope (eta)
Definition: TB06RecoH2.h:52
int wcAXo_
Definition: TB06RecoH2.h:65
Float_t VM5_
Definition: TB06RecoH2.h:88
float xwA_
Definition: TB06RecoH2.h:71
Float_t S49uncalib_
Definition: TB06RecoH2.h:62
Float_t CK2_
Definition: TB06RecoH2.h:97
Float_t S2adc_
Definition: TB06RecoH2.h:78
Float_t S1uncalib_
Definition: TB06RecoH2.h:60
Float_t S25uncalib_
Definition: TB06RecoH2.h:61
TB06TreeH2(const std::string &fileName="TB06Tree.root", const std::string &treeName="Analysis")
ctor
Definition: TB06TreeH2.cc:9
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
Float_t VM7_
Definition: TB06RecoH2.h:90
Float_t VMF_
Definition: TB06RecoH2.h:92
Int_t MEXTLphi
most energetic crystal phi
Definition: TB06RecoH2.h:28
Float_t VM4_
Definition: TB06RecoH2.h:87
void reset(float crystal[11][21])
Definition: TB06TreeH2.cc:201
Float_t VMB_
Definition: TB06RecoH2.h:93
Float_t convFactor
conversion factor from ADC to GeV used
Definition: TB06RecoH2.h:111
Float_t BH1_
Definition: TB06RecoH2.h:100
Float_t BH3_
Definition: TB06RecoH2.h:102
TTree * m_tree
Definition: TB06TreeH2.h:57
Float_t VM2_
Definition: TB06RecoH2.h:85
Float_t yQualityHodo
hodoscope y quality (eta)
Definition: TB06RecoH2.h:56
Int_t run
run number
Definition: TB06RecoH2.h:15
Float_t xQualityHodo
hodoscope x quality (eta)
Definition: TB06RecoH2.h:54
int wcAYo_
Definition: TB06RecoH2.h:66
void check()
Definition: TB06TreeH2.cc:216
list entry
Definition: mps_splice.py:62
tuple cout
Definition: gather_cfg.py:145
dbl *** dir
Definition: mlp_gen.cc:35
Float_t CK3_
Definition: TB06RecoH2.h:98
Float_t VM6_
Definition: TB06RecoH2.h:89
Float_t BH4_
Definition: TB06RecoH2.h:103
Float_t VM1_
Definition: TB06RecoH2.h:84
TFile * m_file
Definition: TB06TreeH2.h:56
Int_t MEXTLindex
most energetic crystal index
Definition: TB06RecoH2.h:24
Float_t localMap[7][7]
energy in 7x7 xtals around the most energetic one
Definition: TB06RecoH2.h:35
int wcBYo_
Definition: TB06RecoH2.h:68
Float_t TOF2J_
Definition: TB06RecoH2.h:108
Float_t beamEnergy
energy of the beam
Definition: TB06RecoH2.h:32