ATLAS Offline Software
CscRawDataCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuonRDO/CscRawData.h"
6 #include "CscRawDataCnv_p2.h"
7 #include "GaudiKernel/GaudiException.h"
8 #include <TString.h> // for Form
9 
10 void
11 CscRawDataCnv_p2::transToPers(const CscRawData* trans, CscRawData_p2* pers, MsgStream &)
12 {
13  pers->m_amps = trans->samples();
14  pers->m_address = trans->address();
15  pers->m_id = trans->identify();
16  pers->m_time = trans->time();
17  pers->m_rpuID = trans->rpuID();
18  pers->m_width = trans->width();
19  pers->m_isTimeComputed = trans->isTimeComputed();
20  if (m_idHelp) {
21  // translate the transient (positional) hash into a geometrical hash as expected by the p2 persistent data format
22  if (!m_idHelp->hasCSC()) std::cout << "CscRawDataCnv_p2::transToPers: !m_idHelp.hasCSC()" << std::endl;
24  Identifier id;
25  IdentifierHash geoHash;
26  if (!m_idHelp->cscIdHelper().get_id(trans->hashId(), id, &context)) {
27  if (!m_idHelp->cscIdHelper().get_channel_hash(id, geoHash)) pers->m_hashId = geoHash;
28  }
29  } else {
30  throw std::runtime_error(Form("File: %s, Line: %d\nCscRawDataCnv_p2::transToPers() - No MuonIdHelperSvc present (needed for channel hash conversion)", __FILE__, __LINE__));
31  }
32 }
33 
34 
35 // schema evolution for case a) below https://savannah.cern.ch/bugs/?56002
36 // There can be two cases:
37 // (a) Reco in 15.5.X.Y or after reading RDO made in 15.3.X.Y and before.
38 // (b) both reco and simulation in 15.5.X.Y or after
39 void
40 CscRawDataCnv_p2::persToTrans(const CscRawData_p2* pers, CscRawData* trans, MsgStream &)
41 {
42  // Fix for CSC phi strip - see https://savannah.cern.ch/bugs/?56002
43  int stationEta = ( ((pers->m_address & 0x00001000) >> 12 ) == 0x0) ? -1 : 1;
44  int measuresPhi = ( (pers->m_address & 0x00000100) >> 8);
45 
46  uint32_t address = 0;
47  if (stationEta==1 && measuresPhi ==1) { // for Wheel A phi strips
48  uint32_t oldFirstStrip = uint32_t (pers->m_address & 0x000000FF); // ( 0 ~ 47 )
49  uint32_t newFirstStrip = uint32_t(47-oldFirstStrip) - pers->m_width + 1; // flip and then shift the firstStrip by 1 - width
50  // width is a number of strips in cluster
51  uint32_t flippedAddress = pers->m_address - oldFirstStrip + newFirstStrip;
52  address = flippedAddress;
53 
55  // log message to confirm "flip and shift" correctly. stripId ranges ( 1-48 )
57  // std::cout << " CscRawDataCnv_p2 " << std::hex << pers->m_address << " ===> " << address << std::dec
58  // << " Strips [" << int(oldFirstStrip+1) << "," << int(oldFirstStrip+trans->m_width) << "] ===> ["
59  // << int(newFirstStrip)+1 << "," << int(newFirstStrip + trans->m_width) << "] "
60  // << " compared to Correct [" << 47-int(oldFirstStrip)+1 << "," << 47-int(oldFirstStrip) - int(trans->m_width)+1+1 << "]"
61  // << std::endl;
62 
63  } else {
64  address = pers->m_address;
65  }
66 
67  *trans = CscRawData (pers->m_amps,
68  address,
69  pers->m_id,
70  pers->m_rpuID,
71  pers->m_width);
72  // translate the persistent p2 (geometrical) hash into a positional hash (as expected by the transient data format)
73  trans->setHashID(pers->m_hashId);
74  if (pers->m_isTimeComputed)
75  trans->setTime (pers->m_time);
76 }
CscRawDataCnv_p2::transToPers
virtual void transToPers(const CscRawData *transObj, CscRawData_p2 *persObj, MsgStream &log)
Definition: CscRawDataCnv_p2.cxx:11
CscRawData_p2::m_hashId
uint32_t m_hashId
offline hash identifier of the first strip in the online cluster
Definition: CscRawData_p2.h:57
CscRawData::rpuID
uint16_t rpuID() const
data access methods
Definition: CscRawData.h:125
CscRawData::address
uint32_t address() const
Definition: CscRawData.h:131
CscRawData_p2::m_id
uint16_t m_id
online identifier of the collection in which this strip is
Definition: CscRawData_p2.h:42
MuonIdHelper::get_id
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK)
Definition: MuonIdHelper.cxx:69
Muon::IMuonIdHelperSvc::hasCSC
virtual bool hasCSC() const =0
returns whether the CSC identifiers are loaded
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
MuonIdHelper::channel_context
IdContext channel_context() const
id for channel
Definition: MuonIdHelper.cxx:745
CscRawData_p2::m_rpuID
uint16_t m_rpuID
SPU -Sparsifier Processing Unit - identifier in which this strip is.
Definition: CscRawData_p2.h:51
CscRawData::isTimeComputed
bool isTimeComputed() const
Definition: CscRawData.h:129
CscRawData
CscRawData
Definition: MuonEventAthenaPoolTPCnv.cxx:59
CscRawData_p2::m_isTimeComputed
bool m_isTimeComputed
failed to compute the time in the ROD or not - if failure m_time = 0
Definition: CscRawData_p2.h:55
CscRawDataCnv_p2.h
CscRawData_p2::m_time
uint16_t m_time
online peaking time of the first strip: this is 0 if failed to compute time in the ROD
Definition: CscRawData_p2.h:49
CscRawData_p2::m_width
uint16_t m_width
number of consecutive strips forming the on-line cluster
Definition: CscRawData_p2.h:53
CscRawData_p2::m_amps
std::vector< uint16_t > m_amps
in common with _p1
Definition: CscRawData_p2.h:38
CscRawData::width
uint16_t width() const
Definition: CscRawData.h:128
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
CscRawDataCnv_p2::persToTrans
virtual void persToTrans(const CscRawData_p2 *persObj, CscRawData *transObj, MsgStream &log)
Definition: CscRawDataCnv_p2.cxx:40
CscRawData::identify
uint16_t identify() const
Definition: CscRawData.h:126
CscRawData::setHashID
void setHashID(uint32_t hash)
Definition: CscRawData.h:121
CscRawData::hashId
uint32_t hashId() const
Definition: CscRawData.h:132
MuonIdHelper::get_channel_hash
virtual int get_channel_hash(const Identifier &id, IdentifierHash &hash_id) const
Definition: MuonIdHelper.cxx:138
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
CscRawData::samples
const std::vector< uint16_t > & samples() const
Definition: CscRawData.h:130
CscRawDataCnv_p2::m_idHelp
Muon::IMuonIdHelperSvc * m_idHelp
Definition: CscRawDataCnv_p2.h:30
CscRawData.h
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
Muon::IMuonIdHelperSvc::cscIdHelper
virtual const CscIdHelper & cscIdHelper() const =0
access to CscIdHelper
CscRawData::time
uint16_t time() const
Definition: CscRawData.h:127
CscRawData
Class to hold the electronic output for a single CSC readout channel: n sampling ADC data + the addre...
Definition: CscRawData.h:21
CscRawData_p2
Definition: CscRawData_p2.h:17
CscRawData_p2::m_address
uint32_t m_address
online identifier of the first strip in the ROD cluster
Definition: CscRawData_p2.h:40
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
IdentifierHash
Definition: IdentifierHash.h:38
CscRawData::setTime
void setTime(uint16_t time)
Definition: CscRawData.h:119
IdContext
class IdContext
Definition: IdContext.h:34