19 #include "GaudiKernel/EventIDRange.h"
21 #include "CLHEP/Units/SystemOfUnits.h"
37 return StatusCode::SUCCESS;
44 if( !cablingCondData.
range( id_range ) ) {
45 ATH_MSG_ERROR(
"Failed to retrieve validity range for " << cablingCondData.
key());
54 if( !managerHandle.
range( id_range ) ) {
62 std::vector<Identifier>::const_iterator idfirst =
helper->module_begin();
63 std::vector<Identifier>::const_iterator idlast =
helper->module_end();
69 std::unique_ptr<RegSelSiLUT>
lut = std::make_unique<RegSelSiLUT>();
73 for ( std::vector<Identifier>::const_iterator itr=idfirst ; itr!=idlast ; ++itr ) {
77 int gethash_code =
helper->get_hash(prdId, prdHashId, &ModuleContext);
78 if (gethash_code != 0 ) {
79 ATH_MSG_DEBUG(
"Failed retrieving IdentifierHash for PRD Identifier = " << prdId.
getString() <<
". Skipping to the next PRD.");
83 std::vector<uint32_t> robIds;
84 if ( (
cabling->giveROB_fromPRD(prdHashId, robIds)).isFailure() ) {
91 ATH_MSG_DEBUG(
"There is no ROB associated with the PRD HashId = " << (
unsigned int)prdHashId <<
". Skipping to the next PRD.");
94 if (robIds.size()!=1 && robIds.size()!=2 && robIds.size()!=4) {
95 ATH_MSG_WARNING(
"Unhandled number of ROBs per one PRD. Expected 1, 2 or 4, got " << robIds.size() <<
". Omitting the PRD HashId = " << (
unsigned int)prdHashId);
100 if (
helper->get_expanded_id( prdId, exp_id, &ModuleContext) ) {
101 ATH_MSG_DEBUG(
"Failed retrieving ExpandedIdentifier for PRD Identifier = " << prdId.
getString() <<
". Skipping to the next PRD.");
105 int detid = ( exp_id[2]<0 ? -1 : 1 );
106 int layerid = exp_id[1];
107 if ( layerid==0 ) layerid = 11;
109 int ndbz =
helper->doubletZMax(prdId);
111 double zmin = 99999999;
112 double zmax = -99999999;
113 double rmin = 99999999;
114 double rmax = -99999999;
115 double phimin = 999999;
116 double phimax = -999999;
120 for (
int dbz=1; dbz<=ndbz; dbz++) {
123 int ndbp =
helper->doubletPhiMax(prdId);
125 for (
int dbp=1; dbp<=ndbp; dbp++) {
130 if ( rpc != rpcold ) {
136 double zminMod = rpcPos.z()-0.5*rpc->
getZsize();
137 double zmaxMod = rpcPos.z()+0.5*rpc->
getZsize();
139 double rcen = std::sqrt(rpcPos.mag()*rpcPos.mag()-rpcPos.z()*rpcPos.z());
141 double rminMod = rcen-0.5*rpc->
getRsize();
142 double rmaxMod = rcen+0.5*rpc->
getRsize();
144 double dphi = std::atan2(rpc->
getSsize()/2,rpcPos.perp());
145 double pminMod = rpcPos.phi() - dphi;
146 double pmaxMod = rpcPos.phi() + dphi;
148 if (zminMod <
zmin) {
153 if (zmaxMod >
zmax) {
158 if (rminMod < rmin) {
161 if (rmaxMod > rmax) {
164 if (pminMod < phimin) phimin = pminMod;
165 if (pmaxMod > phimax) phimax = pmaxMod;
171 double phiMinFirst = phimin;
172 double phiMaxFirst = 0.5*(phimin+phimax);
173 double phiMinSecond = phiMaxFirst;
174 double phiMaxSecond = phimax;
176 if (phiMinFirst < 0) phiMinFirst += 2*
M_PI;
177 if (phiMaxFirst < 0) phiMaxFirst += 2*
M_PI;
178 if (phiMinSecond < 0) phiMinSecond += 2*
M_PI;
179 if (phiMaxSecond < 0) phiMaxSecond += 2*
M_PI;
182 if (robIds.size()==1) {
185 RegSelModule m1(
zmin,
zmax, rmin, rmax, phiMinFirst, phiMaxSecond, layerid, detid, robIds[0], lowerHashId );
186 lut->addModule(
m1 );
190 else if (robIds.size()==2) {
193 if ( ((robIds[0] & 0xff) == 0) && ((robIds[1] & 0xff) == 15) ) {
194 lowerRobId = robIds[1];
195 higherRobId = robIds[0];
198 lowerRobId = robIds[0];
199 higherRobId = robIds[1];
204 RegSelModule m1(
zmin,
zmax, rmin, rmax, phiMinFirst, phiMaxFirst, layerid, detid, lowerRobId, lowerHashId );
205 RegSelModule m2(
zmin,
zmax, rmin, rmax, phiMinSecond, phiMaxSecond, layerid, detid, higherRobId, higherHashId );
206 lut->addModule(
m1 );
207 lut->addModule(
m2 );
209 else if (robIds.size()==4) {
210 uint32_t sideA_lowerRobId = robIds[0];
211 uint32_t sideA_higherRobId = robIds[1];
212 uint32_t sideC_lowerRobId = robIds[2];
213 uint32_t sideC_higherRobId = robIds[3];
214 IdentifierHash sideA_lowerHashId( (1<<16) | (
unsigned int)prdHashId );
215 IdentifierHash sideA_higherHashId( (2<<16) | (
unsigned int)prdHashId );
216 IdentifierHash sideC_lowerHashId( (3<<16) | (
unsigned int)prdHashId );
217 IdentifierHash sideC_higherHashId( (4<<16) | (
unsigned int)prdHashId );
219 RegSelModule m1( 0,
zmax, rmin, rmax, phiMinFirst, phiMaxFirst, layerid, detid, sideA_lowerRobId, sideA_lowerHashId );
220 RegSelModule m2( 0,
zmax, rmin, rmax, phiMinSecond, phiMaxSecond, layerid, detid, sideA_higherRobId, sideA_higherHashId );
221 RegSelModule m3(
zmin, 0, rmin, rmax, phiMinFirst, phiMaxFirst, layerid, detid, sideC_lowerRobId, sideC_lowerHashId );
222 RegSelModule m4(
zmin, 0, rmin, rmax, phiMinSecond, phiMaxSecond, layerid, detid, sideC_higherRobId, sideC_higherHashId );
223 lut->addModule(
m1 );
224 lut->addModule(
m2 );
225 lut->addModule(
m3 );
226 lut->addModule( m4 );