23 #include "Identifier/Identifier.h"
34 #include "GaudiKernel/Bootstrap.h"
35 #include "GaudiKernel/ISvcLocator.h"
36 #include "GaudiKernel/GaudiException.h"
44 ISvcLocator* pSvcLocator )
46 m_detStore(
"DetectorStore",
name),
59 ATH_MSG_DEBUG(
"TRT_StrawNeighbourSvc initialize method called");
61 if (StatusCode::SUCCESS!=
m_detStore.retrieve()) {
63 return StatusCode::FAILURE;
69 return StatusCode::FAILURE;
73 int chipConversionSocketToChip_m1[]={0,1,2,3,4,21,7,6,5,20,19,8,9,16,17,18,10,15,14,13,12,11};
75 int chipConversionChipToSocket_m1[] = {0,1,2,3,4,8,7,6,11,12,16,21,20,19,18,17,13,14,15,10,9,5};
78 int chipConversionSocketToChip_m2[] = {0,5,4,3,2,1,33,6,7,8,9,32,31,12,11,10,27,28,29,30,13,14,26,25,24,23,22,15,16,17,18,19,20,21};
80 int chipConversionChipToSocket_m2[] = {0,5,4,3,2,1,7,8,9,10,15,14,13,20,21,27,28,29,30,31,32,33,26,25,24,23,22,16,17,18,19,12,11,6};
83 int chipConversionSocketToChip_m3[] = {0,1,2,3,4,5,6,50,11,10,9,8,7,49,12,13,14,15,48,47,46,18,17,16,42,43,44,45,19,20,41,40,39,38,37,22,21,31,32,33,34,35,36,23,30,29,28,27,26,25,24};
85 int chipConversionChipToSocket_m3[] = {0,1,2,3,4,5,6,12,11,10,9,8,14,15,16,17,23,22,21,28,29,36,35,43,50,49,48,47,46,45,44,37,38,39,40,41,42,34,33,32,31,30,24,25,26,27,20,19,18,13,7};
90 int chipIndexToChipHardware_A0[] = {2, 1, 3, 0, 6, 5, 7, 4, 10, 9, 11, 8};
91 int chipIndexToChipHardware_A8[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2};
92 int chipIndexToChipHardware_C0[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11};
93 int chipIndexToChipHardware_C8[] = {11, 8, 10, 9, 7, 4, 6, 5, 3, 0, 2, 1};
95 int *chip_list[] = {chipIndexToChipHardware_A0, chipIndexToChipHardware_A8, chipIndexToChipHardware_C0, chipIndexToChipHardware_C8};
96 for (
int i=0;
i<4;
i++)
for (
int j=0; j<12; j++) map_list[
i][j] = chip_list[
i][j];
103 ISvcLocator* svcLocator = Gaudi::svcLocator();
106 if (
result.isFailure() || iAccessSvc ==
nullptr ) {
108 throw GaudiException(
"Could not initalize RDBAccessSvc",
"TRT_GeoModel",StatusCode::FAILURE);
112 result = svcLocator->service (
"GeoModelSvc",geoModel);
113 if (
result.isFailure()) {
115 throw GaudiException(
"Could not locate GeoModelSvc",
"TRT_GeoModel",StatusCode::FAILURE);
118 const std::string& detectorKey = versionKey.
tag();
119 const std::string& detectorNode = versionKey.
node();
122 if (RDB_TRTElec->size()==0) {
123 RDB_TRTElec = iAccessSvc->
getRecordsetPtr(
"TRTBarElecToStrawRel",
"TRTBarElecToStrawRel-02");
124 msg(MSG::INFO) <<
"The folder: InnerDetector->TRT->TRTBarrel->TRTBarrelElectronics not found in DetDesc tag. Using hardcoded tag: TRTBarElecToStrawRel-02" <<
endmsg;
130 const int numberOfm1layers=19;
131 const int numberOfm2layers=24;
132 const int numberOfm3layers=30;
134 int layer_m1_array[numberOfm1layers]= {15,16,16,16,16,17,17,17,17,17,18,18,18,18,18,19,19,19,18};
135 int layer_m2_array[numberOfm2layers]= {19,20,20,20,20,20,21,21,21,21,21,22,22,22,22,22,23,23,23,23,23,24,24,23};
136 int layer_m3_array[numberOfm3layers]= {23,24,24,24,24,25,25,25,25,25,26,26,26,26,26,27,27,27,27,27,28,28,28,28,28,29,29,29,29,28};
141 for (
i=0;
i<numberOfm1layers ;
i++){
143 acc +=layer_m1_array[
i];
148 for (
i=0;
i<numberOfm2layers;
i++){
150 acc +=layer_m2_array[
i];
155 for (
i=0;
i<numberOfm3layers;
i++){
157 acc +=layer_m3_array[
i];
168 int stnm=0, pad=0, previous_pad=1,
layer = 0, pad_rel_mod=0;
171 std::vector<std::vector<int> >
dummy1;
172 std::vector<int> dummy12;
173 std::vector<std::vector<int> >
dummy2;
175 std::vector<std::vector<int> >
dummy3;
176 std::vector<int> dummy32;
178 std::vector<std::vector<int> > dumdumdum1;
179 std::vector<std::vector<int> > dumdumdum2;
180 std::vector<std::vector<int> > dumdumdum3;
181 std::vector<int> dumdum ;
182 for (
unsigned int d =0;
d<=100;
d++ ) {
183 dumdumdum1.push_back(dumdum);
184 dumdumdum2.push_back(dumdum);
185 dumdumdum3.push_back(dumdum);
198 if (!(
layer==0))
break;
199 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
200 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
201 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
202 m_m1.push_back(pad_rel_mod);
203 if (pad==previous_pad) dummy12.push_back(stnm);
204 else if (pad != previous_pad) {
206 dummy1.push_back(dummy12);
208 dummy12.push_back(stnm);
210 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
212 (dumdumdum1[(
int)chip]).push_back(
straw+1);
225 if (!(
layer==1))
break;
226 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
227 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
228 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
229 m_m2.push_back(pad_rel_mod);
230 if (pad==previous_pad)
dummy22.push_back(stnm);
231 else if (pad != previous_pad) {
237 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
239 (dumdumdum2[(
int)chip]).push_back(
straw+1-329);
251 if (
straw>1641)
break;
254 if (!(
layer==2))
break;
255 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
256 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
257 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
258 m_m3.push_back(pad_rel_mod);
259 if (pad==previous_pad) dummy32.push_back(stnm);
260 else if (pad != previous_pad) {
262 dummy3.push_back(dummy32);
264 dummy32.push_back(stnm);
266 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
268 (dumdumdum3[(
int)chip]).push_back(
straw+1-329-520);
278 if (!((
m_m1.size()==330)&&(
m_m2.size()==521)&&(
m_m3.size()==794) ))
ATH_MSG_WARNING(
"Initialization of TRT_StrawNeighbourTool incomplete. Depending on usage, this can give rise to runtime problems");
282 int numberOfStraws[75] = {0,
306 int TripletOrientation[2][32] = {
319 for(
int j=0; j<2; j++)
320 for(
int jj=0; jj<32; jj++)
324 return StatusCode::SUCCESS;
337 msg(MSG::INFO) <<
"TRT_StrawNeighbourSvc finalize method called" <<
endmsg;
338 return StatusCode::SUCCESS;
357 else if (moduleType==1) {
366 else if (moduleType==2) {
391 msg(MSG::ERROR) <<
"Sorry, getRunningNumbering only works for barrel" <<
endmsg;
403 strawnumber -=
straw;
405 else if (moduleType==1) {
407 strawnumber -=
straw;
409 else if (moduleType==2) {
411 strawnumber -=
straw;
421 msg(MSG::ERROR) <<
"Sorry, this only works for barrel"<<
endmsg;
451 else {
msg(MSG::ERROR) <<
"Something is very wrong: According to identifier, straw belongs to a barrel module which is not of type 1,2 or 3 (corresponding to offline numbering: layer_or_wheel = 0,1 or 2) " <<
endmsg;}
467 if (strawlayer%8 >= 4) chip++;
469 int nominal_reversed = 1 - ( (
phi -
phi%8)/8 ) %2 ;
479 else {
msg(MSG::ERROR) <<
"Something is very wrong: endcap chip mapping " <<
bec <<
endmsg; chip = 12; }
483 int board = layer_or_wheel;
484 if (board<6) { board *= 2;
if (strawlayer>7) board++; }
566 if (layer_or_wheel == 0) {
569 else if (layer_or_wheel == 1) {
572 else if (layer_or_wheel == 2){
575 else {
msg(MSG::ERROR) <<
"Something is very wrong: According to identifier, straw belongs to a barrel module which is not of type 1,2 or 3 (corresponding to offline numbering: layer_or_wheel = 0,1 or 2) " <<
endmsg;}
581 msg(MSG::WARNING) <<
" Sorry getPin only implemented for barrel so far. Returning pin=0 " <<
endmsg;
597 pad= temp_straw_layer*3+temp_straw+1;
606 strawnumber=strawnumber%1642;
611 pad =
m_m1[strawnumber];
614 else if (moduleType==1) {
615 pad =
m_m2[strawnumber];
618 else if (moduleType==2) {
619 pad =
m_m3[strawnumber];
622 msg(MSG::ERROR) <<
"Something went wrong: Pad not found, returning 0" <<
endmsg;
645 for (
int temp_it = temp_straw * 8 ; temp_it < temp_straw * 8 +8 ; temp_it++){
646 for (
int temp_it2 = temp_straw_layer * 4 ; temp_it2 < temp_straw_layer * 4 +4 ; temp_it2++){
653 neighbourIDs.push_back(outputID);
663 neighbourIDs.push_back(outputID);
665 msg(MSG::ERROR) <<
" Error in getStrawsFromPad. Returning "<<
endmsg;
692 for(
unsigned int i = 0 ;
i < 4 ;
i ++ ) {
693 for(
unsigned int j = 0 ; j < 4 ; j ++ ) {
709 ( straw_layer + j - local_straw_layer),
710 (
straw +
i - local_straw));
711 neighbourIDs.push_back(outputID);
721 int chip = 0, chiptest=-10;
728 neighbourIDs.push_back(outputID);
730 msg(MSG::ERROR) <<
" Error in getStrawsFromChip. Returning "<<
endmsg;
736 msg(MSG::ERROR) <<
"Attempt to use getStrawsFromChip based on a non-TRT identifier. barrel_ec(inputID) = " <<
m_trtid->
barrel_ec(inputID) <<
endmsg; }
761 ( straw_layer - local_straw_layer),
762 (
straw - local_straw ) );
774 else {
msg(MSG::ERROR) <<
"Attempt to use getFirstStrawFromChip based on a non-TRT identifier. barrel_ec(inputID) = "<<
m_trtid->
barrel_ec(inputID) <<
endmsg; }
787 int hardwarechip = 0;
789 if ( (chip<1) || (chip > 50) || (abs(
layer)>2) )
msg(MSG::ERROR) <<
"Attempt to use chipToBoard(int chip, int layer) with input outside bounds: 1<=chip<=50 and 0<=|layer|<=2 . Input was: chip = "<<chip<<
" layer = "<<
layer <<
endmsg;
791 if (abs(
layer)==0) hardwarechip = chip -1;
792 else if (abs(
layer)==1) hardwarechip = chip + 20;
793 else if (abs(
layer)==2) hardwarechip = chip + 20 + 33;
808 int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
810 for (
int i=0;
i<9;
i++) {
812 if (hardwarechip <
count)
return i;
817 msg(MSG::ERROR) <<
"Something went wrong in chipToBoardBarrel - please contact the author "<<
endmsg;
835 return (16*wheel + strawlayer) / 4;
837 return (16*6+8*(wheel-6) + strawlayer) /4;
863 int addToStrawNumber=0;
864 int addToStrawNumberNext=0;
892 else if (abs(
bec)==2) {
896 else if (
side==-2) phi1=31-phi_stack,
side=0;
909 if (strawlayerNumber>7) strawlayerNumber =
int(
strawNumber/24) + 8;
926 int strawNumberNew=0;
928 if(LayerNumber<6 && strawlayerNumber>7)
930 strawNumberNew=strawNumberNew+(384*LayerNumber);
931 strawNumberNew=strawNumberNew+192+(strawlayerNumber%8)+(
strawNumber*8);
933 else if(LayerNumber<6 && strawlayerNumber<8)
935 strawNumberNew=strawNumberNew+(384*LayerNumber);
936 strawNumberNew=strawNumberNew + (strawlayerNumber%8) + (
strawNumber*8);
939 else if(LayerNumber>5 && strawlayerNumber>7)
941 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
942 strawNumberNew = strawNumberNew + 192 + (strawlayerNumber%8) + (8*
strawNumber);
944 else if(LayerNumber>5 && strawlayerNumber<8)
946 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
947 strawNumberNew = strawNumberNew + (strawlayerNumber%8) + (8*
strawNumber);
955 msg(MSG::ERROR) <<
"corrupted input identifier to TRT_StrawNeighbourSvc::strawNumber(). barrel_ec=" <<
bec<<
endmsg;
976 else if(LayerNumber==1)
980 else if(LayerNumber==2)
988 msg(MSG::ERROR) <<
"Sorry, TRT_StrawNeighbourSvc::strawLayerNumber only works for barrel" <<
endmsg;