ATLAS Offline Software
Loading...
Searching...
No Matches
OfflineOnlineIdConversion.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "GaudiKernel/MsgStream.h"
8
9#include "cstdlib"
10
11namespace MuonCalib {
12
13MuonFixedId OnlineToOffline(const std::string& online_id)
14 {
15 MuonFixedId ret(0), invalid;
16 ret.set_mdt();
17//minimum size of idenifier is 7
18 if (online_id.size()!=7 && online_id.size()!=9)
19 {
20 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
21 log<<MSG::WARNING<<"Wrong length for online_id="<<online_id<<endmsg;
22 return invalid;
23 }
24//check for A/C side
25 bool c_side(false);
26 if(online_id[4]!='A' && online_id[4]!='C' && online_id[4]!='B')
27 {
28 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
29 log<<MSG::WARNING<<"Invalid side for online_id="<<online_id<<endmsg;
30 return invalid;
31 }
32 if(online_id[4]=='C')
33 {
34 c_side=true;
35 }
36//set station name
37 std::string station_nm_string(online_id, 0, 3);
38 int station_mm = MuonFixedId::stationStringToFixedStationNumber(station_nm_string);
39 if (station_mm<0)
40 {
41 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
42 log<<MSG::WARNING<<"Invalid station name for online_id="<<online_id<<endmsg;
43 return invalid;
44 }
45//set eta
46 ret.setStationName(station_mm);
47 char eta_str[2];
48 char *endptr;
49 eta_str[0]=online_id[3];
50 eta_str[1]='\0';
51 long int eta=strtol(eta_str, &endptr, 10);
52 if(endptr!=&(eta_str[1]))
53 {
54 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
55 log<<MSG::WARNING<<"eta is not a number for online_id="<<online_id<<endmsg;
56 return invalid;
57 }
58//set phi
59 char phi_str[3];
60 phi_str[0]=online_id[5];
61 phi_str[1]=online_id[6];
62 phi_str[2]='\0';
63 long int phi=strtol(phi_str, &endptr, 10);
64 if(endptr!=&(phi_str[2]))
65 {
66 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
67 log<<MSG::WARNING<<"phi is not a number for online_id="<<online_id<<endmsg;
68 return invalid;
69 }
70//treat special cases
71 if(phi==13 && eta>3 && station_nm_string=="BML")
72 {
73 eta--;
74 }
75 if(station_nm_string=="BOF")
76 eta=(eta+1)/2;
77 else if(station_nm_string=="BOG")
78 eta/=2;
79 else
80 {
81 if((phi==1 || phi==9) && station_nm_string=="EIL")
82 {
83 if(eta==5) eta=4;
84 else if(eta==4) eta=5;
85 }
86 if(phi==5 && station_nm_string=="EEL") eta=1;
87 }
88//convert online to offline phi
89 if(station_nm_string[2]=='L' || station_nm_string[2]=='M' || station_nm_string[2]=='R')
90 {
91 phi++;
92 }
93 phi/=2;
94 ret.setStationEta(c_side?(eta*-1):eta);
95 ret.setStationPhi(phi);
96//set multilayer id if present
97 if(online_id.size()==9)
98 {
99 switch(online_id[8])
100 {
101 case '1':
102 ret.setMdtMultilayer(1);
103 break;
104 case '2':
105 ret.setMdtMultilayer(2);
106 break;
107 default:
108 MsgStream log(Athena::getMessageSvc(),"OnlineToOffline");
109 log<<MSG::WARNING<<"Multilayer is neither 1 or 2 for online_id="<<online_id<<endmsg;
110 return invalid;
111 }
112 return ret.mdtMultilayerId();
113 }
114 return ret.mdtChamberId();
115 }
116
117
118}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
Implements fixed identifiers not dependent upon Athena Identifier for internal use in the calibration...
Definition MuonFixedId.h:50
static int stationStringToFixedStationNumber(const std::string &station)
void set_mdt()
set identifier to MDT technology type
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
MuonFixedId OnlineToOffline(const std::string &online_id)