23 #include "Identifier/Identifier.h"
34 #include "GaudiKernel/ISvcLocator.h"
35 #include "GaudiKernel/GaudiException.h"
43 ISvcLocator* pSvcLocator )
44 : base_class(
name,pSvcLocator),
45 m_detStore(
"DetectorStore",
name),
58 ATH_MSG_DEBUG(
"TRT_StrawNeighbourSvc initialize method called");
60 if (StatusCode::SUCCESS!=
m_detStore.retrieve()) {
62 return StatusCode::FAILURE;
68 return StatusCode::FAILURE;
72 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};
74 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};
77 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};
79 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};
82 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};
84 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};
89 int chipIndexToChipHardware_A0[] = {2, 1, 3, 0, 6, 5, 7, 4, 10, 9, 11, 8};
90 int chipIndexToChipHardware_A8[] = {8, 11, 9, 10, 4, 7, 5, 6, 0, 3, 1, 2};
91 int chipIndexToChipHardware_C0[] = {1, 2, 0, 3, 5, 6, 4, 7, 9, 10, 8, 11};
92 int chipIndexToChipHardware_C8[] = {11, 8, 10, 9, 7, 4, 6, 5, 3, 0, 2, 1};
94 int *chip_list[] = {chipIndexToChipHardware_A0, chipIndexToChipHardware_A8, chipIndexToChipHardware_C0, chipIndexToChipHardware_C8};
95 for (
int i=0;
i<4;
i++)
for (
int j=0; j<12; j++) map_list[
i][j] = chip_list[
i][j];
102 SmartIF<IRDBAccessSvc> iAccessSvc{service(
"RDBAccessSvc")};
105 throw GaudiException(
"Could not initalize RDBAccessSvc",
"TRT_GeoModel",StatusCode::FAILURE);
108 SmartIF<IGeoModelSvc> geoModel{service(
"GeoModelSvc")};
111 throw GaudiException(
"Could not locate GeoModelSvc",
"TRT_GeoModel",StatusCode::FAILURE);
114 const std::string& detectorKey = versionKey.
tag();
115 const std::string& detectorNode = versionKey.
node();
116 IRDBRecordset_ptr RDB_TRTElec = iAccessSvc->getRecordsetPtr(
"TRTBarElecToStrawRel",detectorKey,detectorNode);
118 if (RDB_TRTElec->size()==0) {
119 RDB_TRTElec = iAccessSvc->getRecordsetPtr(
"TRTBarElecToStrawRel",
"TRTBarElecToStrawRel-02");
120 msg(MSG::INFO) <<
"The folder: InnerDetector->TRT->TRTBarrel->TRTBarrelElectronics not found in DetDesc tag. Using hardcoded tag: TRTBarElecToStrawRel-02" <<
endmsg;
126 const int numberOfm1layers=19;
127 const int numberOfm2layers=24;
128 const int numberOfm3layers=30;
130 int layer_m1_array[numberOfm1layers]= {15,16,16,16,16,17,17,17,17,17,18,18,18,18,18,19,19,19,18};
131 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};
132 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};
137 for (
i=0;
i<numberOfm1layers ;
i++){
139 acc +=layer_m1_array[
i];
144 for (
i=0;
i<numberOfm2layers;
i++){
146 acc +=layer_m2_array[
i];
151 for (
i=0;
i<numberOfm3layers;
i++){
153 acc +=layer_m3_array[
i];
164 int stnm=0, pad=0, previous_pad=1,
layer = 0, pad_rel_mod=0;
167 std::vector<std::vector<int> >
dummy1;
168 std::vector<int> dummy12;
169 std::vector<std::vector<int> >
dummy2;
171 std::vector<std::vector<int> >
dummy3;
172 std::vector<int> dummy32;
174 std::vector<std::vector<int> > dumdumdum1;
175 std::vector<std::vector<int> > dumdumdum2;
176 std::vector<std::vector<int> > dumdumdum3;
177 std::vector<int> dumdum ;
178 for (
unsigned int d =0;
d<=100;
d++ ) {
179 dumdumdum1.push_back(dumdum);
180 dumdumdum2.push_back(dumdum);
181 dumdumdum3.push_back(dumdum);
194 if (!(
layer==0))
break;
195 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
196 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
197 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
198 m_m1.push_back(pad_rel_mod);
199 if (pad==previous_pad) dummy12.push_back(stnm);
200 else if (pad != previous_pad) {
202 dummy1.push_back(dummy12);
204 dummy12.push_back(stnm);
206 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
208 (dumdumdum1[(
int)chip]).push_back(
straw+1);
221 if (!(
layer==1))
break;
222 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
223 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
224 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
225 m_m2.push_back(pad_rel_mod);
226 if (pad==previous_pad)
dummy22.push_back(stnm);
227 else if (pad != previous_pad) {
233 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
235 (dumdumdum2[(
int)chip]).push_back(
straw+1-329);
247 if (
straw>1641)
break;
250 if (!(
layer==2))
break;
251 stnm = RDBVars__TRTElec->
getInt(
"STRAWNUM");
252 pad = RDBVars__TRTElec->
getInt(
"HVPADRELSTRAW");
253 pad_rel_mod = RDBVars__TRTElec->
getInt(
"HVPADRELMOD");
254 m_m3.push_back(pad_rel_mod);
255 if (pad==previous_pad) dummy32.push_back(stnm);
256 else if (pad != previous_pad) {
258 dummy3.push_back(dummy32);
260 dummy32.push_back(stnm);
262 chip=(RDBVars__TRTElec->
getDouble(
"CHIPRELSTRAW"));
264 (dumdumdum3[(
int)chip]).push_back(
straw+1-329-520);
274 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");
278 int numberOfStraws[75] = {0,
302 int TripletOrientation[2][32] = {
315 for(
int j=0; j<2; j++)
316 for(
int jj=0; jj<32; jj++)
320 return StatusCode::SUCCESS;
333 msg(MSG::INFO) <<
"TRT_StrawNeighbourSvc finalize method called" <<
endmsg;
334 return StatusCode::SUCCESS;
353 else if (moduleType==1) {
362 else if (moduleType==2) {
387 msg(MSG::ERROR) <<
"Sorry, getRunningNumbering only works for barrel" <<
endmsg;
399 strawnumber -=
straw;
401 else if (moduleType==1) {
403 strawnumber -=
straw;
405 else if (moduleType==2) {
407 strawnumber -=
straw;
417 msg(MSG::ERROR) <<
"Sorry, this only works for barrel"<<
endmsg;
447 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;}
463 if (strawlayer%8 >= 4) chip++;
465 int nominal_reversed = 1 - ( (
phi -
phi%8)/8 ) %2 ;
475 else {
msg(MSG::ERROR) <<
"Something is very wrong: endcap chip mapping " <<
bec <<
endmsg; chip = 12; }
479 int board = layer_or_wheel;
480 if (board<6) { board *= 2;
if (strawlayer>7) board++; }
562 if (layer_or_wheel == 0) {
565 else if (layer_or_wheel == 1) {
568 else if (layer_or_wheel == 2){
571 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;}
577 msg(MSG::WARNING) <<
" Sorry getPin only implemented for barrel so far. Returning pin=0 " <<
endmsg;
593 pad= temp_straw_layer*3+temp_straw+1;
602 strawnumber=strawnumber%1642;
607 pad =
m_m1[strawnumber];
610 else if (moduleType==1) {
611 pad =
m_m2[strawnumber];
614 else if (moduleType==2) {
615 pad =
m_m3[strawnumber];
618 msg(MSG::ERROR) <<
"Something went wrong: Pad not found, returning 0" <<
endmsg;
641 for (
int temp_it = temp_straw * 8 ; temp_it < temp_straw * 8 +8 ; temp_it++){
642 for (
int temp_it2 = temp_straw_layer * 4 ; temp_it2 < temp_straw_layer * 4 +4 ; temp_it2++){
649 neighbourIDs.push_back(outputID);
659 neighbourIDs.push_back(outputID);
661 msg(MSG::ERROR) <<
" Error in getStrawsFromPad. Returning "<<
endmsg;
688 for(
unsigned int i = 0 ;
i < 4 ;
i ++ ) {
689 for(
unsigned int j = 0 ; j < 4 ; j ++ ) {
705 ( straw_layer + j - local_straw_layer),
706 (
straw +
i - local_straw));
707 neighbourIDs.push_back(outputID);
717 int chip = 0, chiptest=-10;
724 neighbourIDs.push_back(outputID);
726 msg(MSG::ERROR) <<
" Error in getStrawsFromChip. Returning "<<
endmsg;
732 msg(MSG::ERROR) <<
"Attempt to use getStrawsFromChip based on a non-TRT identifier. barrel_ec(inputID) = " <<
m_trtid->
barrel_ec(inputID) <<
endmsg; }
757 ( straw_layer - local_straw_layer),
758 (
straw - local_straw ) );
770 else {
msg(MSG::ERROR) <<
"Attempt to use getFirstStrawFromChip based on a non-TRT identifier. barrel_ec(inputID) = "<<
m_trtid->
barrel_ec(inputID) <<
endmsg; }
783 int hardwarechip = 0;
785 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;
787 if (abs(
layer)==0) hardwarechip = chip -1;
788 else if (abs(
layer)==1) hardwarechip = chip + 20;
789 else if (abs(
layer)==2) hardwarechip = chip + 20 + 33;
804 int list[] = {10, 11, 15, 9, 9, 11, 12, 13, 14};
806 for (
int i=0;
i<9;
i++) {
808 if (hardwarechip <
count)
return i;
813 msg(MSG::ERROR) <<
"Something went wrong in chipToBoardBarrel - please contact the author "<<
endmsg;
831 return (16*wheel + strawlayer) / 4;
833 return (16*6+8*(wheel-6) + strawlayer) /4;
859 int addToStrawNumber=0;
860 int addToStrawNumberNext=0;
888 else if (abs(
bec)==2) {
892 else if (
side==-2) phi1=31-phi_stack,
side=0;
905 if (strawlayerNumber>7) strawlayerNumber =
int(
strawNumber/24) + 8;
922 int strawNumberNew=0;
924 if(LayerNumber<6 && strawlayerNumber>7)
926 strawNumberNew=strawNumberNew+(384*LayerNumber);
927 strawNumberNew=strawNumberNew+192+(strawlayerNumber%8)+(
strawNumber*8);
929 else if(LayerNumber<6 && strawlayerNumber<8)
931 strawNumberNew=strawNumberNew+(384*LayerNumber);
932 strawNumberNew=strawNumberNew + (strawlayerNumber%8) + (
strawNumber*8);
935 else if(LayerNumber>5 && strawlayerNumber>7)
937 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
938 strawNumberNew = strawNumberNew + 192 + (strawlayerNumber%8) + (8*
strawNumber);
940 else if(LayerNumber>5 && strawlayerNumber<8)
942 strawNumberNew = strawNumberNew + 2304 + 192*(LayerNumber-6);
943 strawNumberNew = strawNumberNew + (strawlayerNumber%8) + (8*
strawNumber);
951 msg(MSG::ERROR) <<
"corrupted input identifier to TRT_StrawNeighbourSvc::strawNumber(). barrel_ec=" <<
bec<<
endmsg;
972 else if(LayerNumber==1)
976 else if(LayerNumber==2)
984 msg(MSG::ERROR) <<
"Sorry, TRT_StrawNeighbourSvc::strawLayerNumber only works for barrel" <<
endmsg;