CMS 3D CMS Logo

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