ATLAS Offline Software
TileL2Cnv_p2.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // TileL2Cnv_p2.cxx
8 // Implementation file for class TileL2Cnv_p2
9 // Author: Aranzazu Ruiz <aranzazu.ruiz.martinez@cern.ch>
10 // Date: July 2008
12 
13 // TileEvent includes
14 #include "TileEvent/TileL2.h"
15 
16 // TileTPCnv includes
17 #include "TileTPCnv/TileL2Cnv_p2.h"
18 #include <atomic>
19 
20 // #define TILEL2_DEBUG true
21 
22 #ifdef TILEL2_DEBUG
23 #include <iostream>
24 #endif
25 
26 static std::atomic<bool> old_format_print=true;
27 
28 void TileL2Cnv_p2::transToPers(const TileL2* transObj, TileL2_p2* persObj, MsgStream &log) const {
29 
30  unsigned int l1 = transObj->sumEVec().size();
31  unsigned int l2 = transObj->eta().size();
32  unsigned int l3 = transObj->val().size();
33  unsigned int l4 = transObj->qual().size();
34 
35  if (l1>15 || l2>15 || l3>15 || l4>15) {
36  log << MSG::ERROR << "TOO BIG SIZE IN TileL2Cnv_p2::transToPers !!! "
37  << " l1=" << l1
38  << " l2=" << l2
39  << " l3=" << l3
40  << " l4=" << l4
41  << endmsg;
42  persObj->m_ID = (transObj->identify() & 0xFFFF);
43  return;
44  }
45 
46  persObj->m_fval.clear();
47  persObj->m_ival.clear();
48  persObj->m_fval.reserve(l1+4*l2);
49  persObj->m_ival.reserve(l3+l4);
50 
51  // Transverse energy
52  if (l1>0) {
53  bool allzeros=true;
54  for (float f : transObj->sumEVec()) {
55  persObj->m_fval.push_back( f );
56  if (fabs(f) > 1.e-6) allzeros=false;
57  }
58  if (allzeros) {
59  l1=0;
60  persObj->m_fval.clear();
61  }
62  }
63 
64  // Drawer ID
65  persObj->m_ID = (l1<<28) | (l2<<24) | (l3<<20) | (l4<<16) | (transObj->identify() & 0xFFFF);
66 
67  if (l2) {
68  // Muon eta coordinate
69  persObj->m_fval.insert (persObj->m_fval.end(),
70  transObj->eta().begin(),
71  transObj->eta().end());
72 
73  // Energy in the innermost layer
74  persObj->m_fval.insert (persObj->m_fval.end(),
75  transObj->enemu0().begin(),
76  transObj->enemu0().end());
77 
78 
79  // Energy in the central layer
80  persObj->m_fval.insert (persObj->m_fval.end(),
81  transObj->enemu1().begin(),
82  transObj->enemu1().end());
83 
84  // Energy in the outermost layer
85  persObj->m_fval.insert (persObj->m_fval.end(),
86  transObj->enemu2().begin(),
87  transObj->enemu2().end());
88 
89  if (l1 + 4*l2 != persObj->m_fval.size()) {
90  log << MSG::ERROR << "WRONG SIZE IN TileL2Cnv_p2::transToPers !!! "
91  << " l1=" << l1
92  << " l2=" << l2
93  << "(" << transObj->eta().size()
94  << "," << transObj->enemu0().size()
95  << "," << transObj->enemu1().size()
96  << "," << transObj->enemu2().size()
97  << ") f_size=" << persObj->m_fval.size()
98  << endmsg;
99  }
100  }
101 
102  // Encoded 32-bit words
103  persObj->m_ival.insert (persObj->m_ival.end(),
104  transObj->val().begin(),
105  transObj->val().end());
106 
107  // Quality factor
108  persObj->m_ival.insert (persObj->m_ival.end(),
109  transObj->qual().begin(),
110  transObj->qual().end());
111 
112 
113 #ifdef TILEL2_DEBUG
114  transObj->print();
115  std::cout << "pers TileL2 0x"<< std::hex << persObj->m_ID << " " << std::dec;
116  for (unsigned int i=0; i<persObj->m_fval.size(); ++i)
117  std::cout << persObj->m_fval[i] << " ";
118  for (unsigned int i=0; i<persObj->m_ival.size(); ++i)
119  std::cout << " " << persObj->m_ival[i];
120  std::cout << std::endl;
121 #endif
122 }
123 
124 
125 void TileL2Cnv_p2::persToTrans(const TileL2_p2* persObj, TileL2* transObj, MsgStream &log) const {
126 
127  unsigned int l0 = persObj->m_ID;
128 
129  // Drawer ID
130  *transObj = TileL2 (l0 & 0xFFFF);
131 
132  unsigned int l1 = (l0 >> 28) & 0xF;
133  unsigned int l2 = (l0 >> 24) & 0xF;
134  unsigned int l3 = (l0 >> 20) & 0xF;
135  unsigned int l4 = (l0 >> 16) & 0xF;
136 
137  std::vector<float>::const_iterator it = persObj->m_fval.begin();
138  std::vector<unsigned int>::const_iterator iti = persObj->m_ival.begin();
139 
140  if (l1 + 4*l2 != persObj->m_fval.size() || l3+l4 != persObj->m_ival.size()) {
141  log << MSG::ERROR << "WRONG SIZE IN TileL2Cnv_p2::persToTrans !!! "
142  << " id=0x" << MSG::hex << l0 << MSG::dec
143  << " f_size=" << persObj->m_fval.size()
144  << " i_size=" << persObj->m_ival.size()
145  << endmsg;
146  return;
147  }
148 
149  std::vector<float> sumE;
150  if (l1>2 || l3 == 2*l2 ) { // new format, usually with 3 sumE values
151  sumE.assign (it, it+l1); it += l1;
152  } else { // decode all old formats (used between July 2010 and June 2011)
153  // sumE vector is not saved, only Et might be present
154 
155  if (old_format_print) {
156  old_format_print=false;
157  log << MSG::INFO << "Old format detected in TileL2Cnv_p2::persToTrans"
158  << " l1="<<l1
159  << " l2="<<l2
160  << " l3="<<l3
161  << " l4="<<l4
162  << endmsg;
163  }
164 
165  sumE.resize(1,0.0);
166 
167  if (l3>0) {
168  sumE[0] = (*iti++)-9000.; // take Et from integer applying offset
169  --l3; // and ignore first integer value - Et is not kept in val array in new format
170  }
171 
172  if (l1>0) { // old format with Et and phi saved as two floats
173  sumE[0] = (*it++); // use Et value from float array directly
174  if (l1>1) ++it; // ignore phi value
175  }
176  }
177 
178  transObj->setEt (std::move(sumE));
179 
180  // Muon eta coordinate
181  std::vector<float> eta (it, it+l2); it += l2;
182  // Energy in the innermost layer
183  std::vector<float> enemu0 (it, it+l2); it += l2;
184  // Energy in the central layer
185  std::vector<float> enemu1 (it, it+l2); it += l2;
186  // Energy in the outermost layer
187  std::vector<float> enemu2 (it, it+l2); it += l2;
188 
189  // Encoded 32-bit words
190  std::vector<unsigned int> val (iti, iti+l3); iti += l3;
191 
192  // Quality factor
193  std::vector<unsigned int> qual (iti, iti+l4); iti += l4;
194 
195  transObj->setMu (std::move(eta),
196  std::move(enemu0),
197  std::move(enemu1),
198  std::move(enemu2),
199  std::move(qual),
200  std::move(val));
201 
202 #ifdef TILEL2_DEBUG
203  transObj->print();
204  std::cout << "pers TileL2 0x"<< std::hex << persObj->m_ID << " " << std::dec;
205  for (unsigned int i=0; i<persObj->m_fval.size(); ++i)
206  std::cout << persObj->m_fval[i] << " ";
207  for (unsigned int i=0; i<persObj->m_ival.size(); ++i)
208  std::cout << " " << persObj->m_ival[i];
209  std::cout << std::endl;
210 #endif
211 }
212 
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TileL2Cnv_p2.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TileL2_p2
Definition: TileL2_p2.h:20
TileL2_p2::m_fval
std::vector< float > m_fval
Definition: TileL2_p2.h:35
TileL2::identify
int identify(void) const
Return Identifier.
Definition: TileL2.h:86
TileL2::val
unsigned int val(unsigned int i) const
Return Data.
Definition: TileL2.h:92
TileL2_p2::m_ID
int m_ID
Definition: TileL2_p2.h:33
TileL2::sumEVec
const std::vector< float > & sumEVec() const
Definition: TileL2.h:154
TileL2_p2::m_ival
std::vector< unsigned int > m_ival
Definition: TileL2_p2.h:34
TileL2::print
void print(void) const
Printing for debugging.
Definition: TileL2.cxx:49
skel.l2
l2
Definition: skel.GENtoEVGEN.py:399
TileL2::eta
float eta(unsigned int ind) const
Return eta (computed as the average of the eta values of the TileCal cells where the muon goes throug...
Definition: TileL2.h:99
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TileL2.h
hist_file_dump.f
f
Definition: hist_file_dump.py:135
TileL2::enemu1
float enemu1(unsigned int ind) const
Return energy deposited in central layer (BC cells)
Definition: TileL2.h:116
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TileL2Cnv_p2::transToPers
virtual void transToPers(const TileL2 *transObj, TileL2_p2 *persObj, MsgStream &log) const override
Method creating the persistent representation TileL2_p2 from its transient representation TileL2.
Definition: TileL2Cnv_p2.cxx:28
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
ReadCellNoiseFromCoolCompare.l0
l0
Definition: ReadCellNoiseFromCoolCompare.py:359
beamspotman.qual
qual
Definition: beamspotman.py:481
TileL2::setEt
void setEt(std::vector< float > &&sumE)
Set sumE vector in TileL2.
Definition: TileL2.h:81
skel.l1
l1
Definition: skel.GENtoEVGEN.py:398
TileL2::enemu0
float enemu0(unsigned int ind) const
Return energy deposited in innermost layer (A cells)
Definition: TileL2.h:112
TileL2::enemu2
float enemu2(unsigned int ind) const
Return energy deposited in outermost layer (D cells)
Definition: TileL2.h:120
TileL2::setMu
void setMu(const std::vector< float > &eta, const std::vector< float > &enemu0, const std::vector< float > &enemu1, const std::vector< float > &enemu2, const std::vector< unsigned int > &qual, const std::vector< unsigned int > &val)
Set Muon Info in TileL2.
Definition: TileL2.h:50
TileL2
Class to store TileMuId and Et quantities computed at the TileCal ROD DSPs.
Definition: TileL2.h:33
TileL2Cnv_p2::persToTrans
virtual void persToTrans(const TileL2_p2 *persObj, TileL2 *transObj, MsgStream &log) const override
Method creating the transient representation TileL2 from its persistent representation TileL2_p2.
Definition: TileL2Cnv_p2.cxx:125
TileL2::qual
unsigned int qual(unsigned int ind) const
Return quality flag (0 or 1): set to 0 if the "energy deposition path" is MIP like in all three sampl...
Definition: TileL2.h:127