CMS 3D CMS Logo

TB06Tree.cc
Go to the documentation of this file.
3 #include "TFile.h"
4 #include "TTree.h"
5 
6 #include <iostream>
7 
9  : m_file(nullptr), m_tree(nullptr), m_data(nullptr), m_dataSize(0) {
10  TDirectory *dir = gDirectory;
11  m_file = new TFile(fileName.c_str(), "RECREATE");
12  m_file->cd();
13  m_tree = new TTree(treeName.c_str(), "Analysis tree");
14  m_tree->SetAutoSave(10000000);
15  dir->cd();
16 
17  // m_tree->cd () ;
18  m_data = new TClonesArray(TB06Reco::Class(), 1);
19  m_data->ExpandCreateFast(1);
20 
21  // m_tree->Branch ("EGCO", &m_data, 64000, 2) ;
22  m_tree->Branch("TB06O", &m_data, 64000, 2);
23  m_tree->Print();
24 }
25 
26 // -------------------------------------------------------------------
27 
29  std::cout << "[TB06Tree][dtor] saving TTree " << m_tree->GetName() << " with " << m_tree->GetEntries() << " entries"
30  << " on file: " << m_file->GetName() << std::endl;
31 
32  m_file->Write();
33  delete m_tree;
34  m_file->Close();
35  delete m_file;
36  delete m_data;
37 }
38 
39 // -------------------------------------------------------------------
40 
42 void TB06Tree::store(const int &tableIsMoving,
43  const int &run,
44  const int &event,
45  const int &S6adc,
46  const double &xhodo,
47  const double &yhodo,
48  const double &xslope,
49  const double &yslope,
50  const double &xquality,
51  const double &yquality,
52  const int &icMax,
53  const int &ietaMax,
54  const int &iphiMax,
55  const double &beamEnergy,
56  const double ampl[49]) {
57  m_data->Clear();
58  TB06Reco *entry = static_cast<TB06Reco *>(m_data->AddrAt(0));
59 
60  entry->reset();
61  // reset (entry->myCalibrationMap) ;
62 
63  entry->tableIsMoving = tableIsMoving;
64  entry->run = run;
65  entry->event = event;
66  entry->S6ADC = S6adc;
67 
68  entry->MEXTLindex = icMax;
69  entry->MEXTLeta = ietaMax;
70  entry->MEXTLphi = iphiMax;
71  entry->MEXTLenergy = ampl[24];
72  entry->beamEnergy = beamEnergy;
73 
74  for (int eta = 0; eta < 7; ++eta)
75  for (int phi = 0; phi < 7; ++phi) {
76  // FIXME capire l'orientamento di phi!
77  // FIXME capire se eta, phi iniziano da 1 o da 0
78  entry->localMap[eta][phi] = ampl[eta * 7 + phi];
79  }
80 
81  entry->xHodo = xhodo;
82  entry->yHodo = yhodo;
83  entry->xSlopeHodo = xslope;
84  entry->ySlopeHodo = yslope;
85  entry->xQualityHodo = xquality;
86  entry->yQualityHodo = yquality;
87 
88  entry->convFactor = 0.;
89 
90  /*
91  // loop over the 5x5 see (1)
92  for (int xtal=0 ; xtal<25 ; ++xtal)
93  {
94  int ieta = xtal/5 + 3 ;
95  int iphi = xtal%5 + 8 ;
96  entry->myCalibrationMap[ieta][iphi] = ampl[xtal] ;
97  } // loop over the 5x5
98 
99  entry->electron_Tr_Pmag_ = beamEnergy ;
100 
101  entry->centralCrystalEta_ = ietaMax ;
102  entry->centralCrystalPhi_ = iphiMax ;
103  entry->centralCrystalEnergy_ = ampl[12] ;
104 
105  // this is a trick
106  entry->electron_Tr_Peta_ = xhodo ;
107  entry->electron_Tr_Pphi_ = yhodo ;
108  */
109  m_tree->Fill();
110 }
111 
112 // -------------------------------------------------------------------
113 
114 void TB06Tree::reset(float crystal[11][21]) {
115  for (int eta = 0; eta < 11; ++eta) {
116  for (int phi = 0; phi < 21; ++phi) {
117  crystal[eta][phi] = -999.;
118  }
119  }
120 }
121 
122 // -------------------------------------------------------------------
123 
125  TB06Reco *entry = static_cast<TB06Reco *>(m_data->AddrAt(0));
126 
127  std::cout << "[TB06Tree][check]reading . . . \n";
128  std::cout << "[TB06Tree][check] entry->run: " << entry->run << "\n";
129  std::cout << "[TB06Tree][check] entry->event: " << entry->event << "\n";
130  std::cout << "[TB06Tree][check] entry->tableIsMoving: " << entry->tableIsMoving << "\n";
131  std::cout << "[TB06Tree][check] entry->MEXTLeta: " << entry->MEXTLeta << "\n";
132  std::cout << "[TB06Tree][check] entry->MEXTLphi: " << entry->MEXTLphi << "\n";
133  std::cout << "[TB06Tree][check] entry->MEXTLenergy: " << entry->MEXTLenergy << "\n";
134 
135  for (int eta = 0; eta < 7; ++eta)
136  for (int phi = 0; phi < 7; ++phi)
137  std::cout << "[TB06Tree][check] entry->localMap[" << eta << "][" << phi << "]: " << entry->localMap[eta][phi]
138  << "\n";
139 
140  std::cout << "[TB06Tree][check] entry->xHodo: " << entry->xHodo << "\n";
141  std::cout << "[TB06Tree][check] entry->yHodo: " << entry->yHodo << "\n";
142  std::cout << "[TB06Tree][check] entry->xSlopeHodo: " << entry->xSlopeHodo << "\n";
143  std::cout << "[TB06Tree][check] entry->ySlopeHodo: " << entry->ySlopeHodo << "\n";
144  std::cout << "[TB06Tree][check] entry->xQualityHodo: " << entry->xQualityHodo << "\n";
145  std::cout << "[TB06Tree][check] entry->yQualityHodo: " << entry->yQualityHodo << "\n";
146  std::cout << "[TB06Tree][check] entry->convFactor: " << entry->convFactor << "\n";
147 
148  /* to be implemented with the right variables
149  std::cout << "[TB06Tree][check] ------------------------" << std::endl ;
150  std::cout << "[TB06Tree][check] " << entry->variable_name << std::endl ;
151  */
152 }
153 
154 /* (1) to fill the 25 crystals vector
155 
156  for (UInt_t icry=0 ; icry<25 ; ++icry)
157  {
158  UInt_t row = icry / 5 ;
159  Int_t column = icry % 5 ;
160  try
161  {
162  EBDetId tempo (maxHitId.ieta()+column-2,
163  maxHitId.iphi()+row-2,
164  EBDetId::ETAPHIMODE) ;
165 
166  Xtals5x5.push_back (tempo) ;
167  amplitude [icry] = hits->find (Xtals5x5[icry])->energy () ;
168 
169  }
170  catch ( std::runtime_error &e )
171  {
172  std::cout << "Cannot construct 5x5 matrix around EBDetId "
173  << maxHitId << std::endl ;
174  return ;
175  }
176  } // loop over the 5x5 matrix
177 
178 
179 */
Int_t run
run number
Definition: TB06Reco.h:13
Float_t convFactor
conversion factor from ADC to GeV used
Definition: TB06Reco.h:57
Float_t yHodo
hodoscope y coord (phi)
Definition: TB06Reco.h:44
Float_t localMap[7][7]
energy in 7x7 xtals around the most energetic one
Definition: TB06Reco.h:33
#define nullptr
void reset(float crystal[11][21])
Definition: TB06Tree.cc:114
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:42
Int_t MEXTLeta
most energetic crystal eta
Definition: TB06Reco.h:24
void check()
Definition: TB06Tree.cc:124
Float_t xQualityHodo
hodoscope x quality (eta)
Definition: TB06Reco.h:52
Int_t event
event number
Definition: TB06Reco.h:15
Float_t MEXTLenergy
most energetic crystal energy
Definition: TB06Reco.h:28
TB06Tree(const std::string &fileName="TB06Tree.root", const std::string &treeName="Analysis")
ctor
Definition: TB06Tree.cc:8
Float_t xSlopeHodo
hodoscope x slope (eta)
Definition: TB06Reco.h:48
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:26
Float_t beamEnergy
energy of the beam
Definition: TB06Reco.h:30
void reset()
set all the values to 0
Definition: TB06Reco.cc:8
TFile * m_file
Definition: TB06Tree.h:42
Int_t tableIsMoving
if the table is moving
Definition: TB06Reco.h:17
TTree * m_tree
Definition: TB06Tree.h:43
TClonesArray * m_data
Definition: TB06Tree.h:45
Int_t MEXTLindex
most energetic crystal index
Definition: TB06Reco.h:22
Int_t S6ADC
ADC output of the S6 integrated signal.
Definition: TB06Reco.h:19
dbl *** dir
Definition: mlp_gen.cc:35
Float_t yQualityHodo
hodoscope y quality (eta)
Definition: TB06Reco.h:54
Float_t ySlopeHodo
hodoscope y slope (eta)
Definition: TB06Reco.h:50
~TB06Tree()
dtor
Definition: TB06Tree.cc:28
Float_t xHodo
hodoscope x coord (eta)
Definition: TB06Reco.h:42
Definition: event.py:1