Build all beam detectors raw objects from m_rodBlock using H6 convention. Objects are recorded in SG if they do not correspond to unrec_code Will return faillure if : -one of the object could not be recorded in SG -the requested object (unrec_code) was not found
505{
512
514 logstr << MSG::DEBUG <<
"H6BuildObject called for " << unrec_code<<
endmsg;
515
516 const EventContext& ctx = Gaudi::Hive::currentContext();
517
519
520
521
522
523 std::ostringstream
os;
524
525
527 if (
sc!=StatusCode::SUCCESS)
531 logstr << MSG::ERROR <<
"ReadRodBlock: RodBlock too small!" <<
endmsg;
532 return StatusCode::FAILURE;
533 }
534
535
536
537
543
546
547 std::string
name1,name2;
549 TBTDCRaw* dummytdc = new TBTDCRaw("dummy",true,0,true);
551
553 TBADCRaw* dummyadc = new TBADCRaw("dummy",true,0);
555
556 SG::ReadCondHandle<LArCalibLineMapping> calibLine (
m_CLKey, ctx);
557
558
559
567 case 0x01:
568 {
570
576
587 }
588 break;
589
590 case 0x02:
591 {
592 logstr << MSG::DEBUG <<
" Found mini-ROD data in beam crate fragment, size " <<
m_subfrag_size <<
endmsg;
593
594
595
596 short m_feedthrough[8] = {0,0,0,0,1,1,1,1};
597 int m_sampleOrder[32] = {
598 0,1,2,3,4,5,6,7,8,9,10,
599 11,12,13,14,15,16,17,18,19,20,
600 21,22,23,24,25,26,27,28,29,30,
601 31};
602 int m_sort[64] = { 55, 39, 23, 7, 119, 103, 87, 71,
603 54, 38, 22, 6, 118, 102, 86, 70,
604 53, 37, 21, 5, 117, 101, 85, 69,
605 52, 36, 20, 4, 116, 100, 84, 68,
606 51, 35, 19, 3, 115, 99, 83, 67,
607 50, 34, 18, 2, 114, 98, 82, 66,
608 49, 33, 17, 1, 113, 97, 81, 65,
609 48, 32, 16, 0, 112, 96, 80, 64
610 } ;
611
612
613 constexpr short m_slot[8]={5,7,9,11,3,4,5,6};
614
615 constexpr int NWREC = 8;
617 for(
unsigned int nfeb=0;nfeb<
m_boards.size();nfeb++){
619 if(
m_dump) logstr << MSG::DEBUG <<
" Board "<< nfeb <<
endmsg;
622 int samp;
623 for(
unsigned int g=0;
g<
m_gains.size();
g++){
624 int gainmode;
625
626
630 {
632 }
633 }
634 else {
635 gainmode=0;
636 if((m_sampleOrder[0]=
m_febgain[nfeb])!=0){
637 for(
int j=0;j<
m_febgain[nfeb];j++) {m_sampleOrder[j+1]=j;}
638 }
639 }
640 samp=m_sampleOrder[
s];
641
642 if(
m_dump&&(gainmode==2)) logstr << MSG::DEBUG <<
" channels ";
643 for(
int i= 0 ;
i<64;
i++){
645
647 unsigned short gain1 = ((tmp1>>12)&3) - 1;
649
651 unsigned short gain2 = ((
tmp2>>12)&3) - 1;
653
656
657
658
659 if(
m_dump&&(gainmode==2)) logstr << MSG::DEBUG <<
" (," <<
chan <<
","<< gainmode <<
"," << samp <<
","<<
m_arrayofsample[
chan+8][gainmode][samp]<<
")";
661 }
662
663 if(
m_dump&&(gainmode==2)) logstr << MSG::DEBUG <<
endmsg;
664 }
665 }
667 logstr << MSG::DEBUG <<
" Creating LArDigit for board "<< nfeb <<
". m_febgain=" <<
m_febgain[nfeb] <<
endmsg;
668
669 for(
unsigned int g=0;
g<
m_gains.size();
g++){
670 int gainmode;
673 } else {
674 gainmode=0;
675 }
676
677 logstr << MSG::DEBUG <<
"Gain mode="<< gainmode <<
endmsg;
678 for(
int i=0;
i<128;
i++) {
679
684 LArDigit * lardig= new LArDigit(hwid,gain,samplevec);
687 bool isPulsed=false;
688 const std::vector<HWIdentifier>& calibChannelIDs=calibLine->calibSlotLine(hwid);
689 if (calibChannelIDs.size() != 0) {
690
691
692
693 for (HWIdentifier calChan : calibChannelIDs) {
697
699 isPulsed = true;
700 }
701 }
702 }
705 }
706 }
708 break;
709 }
710 }
711 }
712
713 }
714 break;
715
716 case 0x03:
717 {
719 name1=
"word1frag0x03chan";
720 name2="word2frag0x03chan";
721
722
724 logstr<<MSG::ERROR<<
"Beam counter subfrag (0x03) has not expected size" <<
endmsg;
725 sc=StatusCode::FAILURE;
726 break;
727 }
730
733
734 if(
m_dump) logstr << MSG::INFO <<
" sub frag 0x03 : word1="<<tmp1<<
" word2="<<
tmp2 <<
endmsg;
735
736 TBTDCRaw * clocktdc = new TBTDCRaw(name1+'0',false,tmp1,false);
737 TBTDCRaw * clock_deltdc = new TBTDCRaw(name2+'0',false,tmp2,false);
740
743
744 if(
m_dump) logstr << MSG::INFO <<
" sub frag 0x03 : word1="<<tmp1<<
" word2="<<
tmp2 <<
endmsg;
745
746 TBTDCRaw *
scale1 =
new TBTDCRaw(name1+
'1',
false,tmp1,
false);
747 TBTDCRaw * scale1bis = new TBTDCRaw(name2+'1',false,tmp2,false);
750
753
754 if(
m_dump) logstr << MSG::INFO <<
" sub frag 0x03 : word1="<<tmp1<<
" word2="<<
tmp2 <<
endmsg;
755
756 TBTDCRaw *
scale2 =
new TBTDCRaw(name1+
'2',
false,tmp1,
false);
757 TBTDCRaw * scale2bis = new TBTDCRaw(name2+'2',false,tmp2,false);
760
761 }
762 break;
763 case 0x04:
764 {
765 name1=
"word1frag0x06chan";
766 name2="word2frag0x06chan";
767 std::string tcname="tc";
768 std::vector<TBScintillatorRaw *> theScints;
770 logstr<<MSG::ERROR<<
"Beam counter subfrag (0x04) has not expected size" <<
endmsg;
771 sc=StatusCode::FAILURE;
772 break;
773 }
774 logstr << MSG::DEBUG <<
"H6BuildObject : building tailcatcher " <<
endmsg;
775 for(
unsigned int i=0;
i<24;
i++){
780
783
786 TBADCRaw* adc1 =
new TBADCRaw(
os.str(),
false,abs(tmp1));
789 TBADCRaw* adc2 =
new TBADCRaw(
os.str(),
false,abs(tmp2));
798 os << tcname << 2*
i+1;
800 theScints.push_back(s1);
801 theScints.push_back(s2);
802 }
803
804 m_tailcatchraw =
new TBTailCatcherRaw(
"TailCatherRaw",
false,theScints);
805
806 }
807 break;
808
809 case 0x05:
810 {
811 name1=
"word1frag0x05chan";
812 name2="word2frag0x05chan";
813
815 logstr << MSG::DEBUG <<
"H6BuildObject : number of BPCRaw "<< bpcnum <<
endmsg;
816
817 for(
int i=0;
i<bpcnum;
i++){
818 std::string bpcname = "BPC";
822 std::vector<const TBTDCRaw*> theTDCs;
823 std::vector<const TBADCRaw*> theADCs;
825
826 unsigned int tmp1,
tmp2;
831 TBADCRaw* tbadcH =
new TBADCRaw(
os.str(),(tmp1>1023),tmp1);
833 os << name2 << (
i*3);
834 TBADCRaw* tbadcV =
new TBADCRaw(
os.str(),(tmp1>1023),tmp2);
837
838
842 os << name2 << (
i*3+1);
843 TBTDCRaw * tbtdcL =
new TBTDCRaw(
os.str(),(tmp2>2047),tmp2,0);
846 TBTDCRaw * tbtdcR =
new TBTDCRaw(
os.str(),(tmp1>2047),tmp1,0);
847
850 MSG::hex(logstr) << MSG::DEBUG << bpcname<< " "<< tmp1;
851 MSG::hex(logstr) <<
" "<<
tmp2<<
" ";
852
857 TBTDCRaw * tbtdcU =
new TBTDCRaw(
os.str(),(tmp1>2047),tmp1,0);
859 os << name2 << (
i*3+2);
860 TBTDCRaw * tbtdcD =
new TBTDCRaw(
os.str(),(tmp2>2047),tmp2,0);
861
864 MSG::hex(logstr) << MSG::DEBUG << bpcname<< " "<< tmp1;
866
867
868 theTDCs.push_back(tbtdcL);
869 theTDCs.push_back(tbtdcR);
870 theTDCs.push_back(tbtdcU);
871 theTDCs.push_back(tbtdcD);
872 theADCs.push_back(tbadcH);
873 theADCs.push_back(tbadcV);
876 }
877
878
879 }
880 break;
881
882 case 0x06:
883 {
884 name1=
"word1frag0x06chan";
885 name2="word2frag0x06chan";
887 logstr<<MSG::ERROR<<
"Beam counter subfrag (0x06) has not expected size" <<
endmsg;
888 sc=StatusCode::FAILURE;
889 break;
890 }
891
892 logstr << MSG::DEBUG <<
" Building TBScintillatorRawCont with key " <<
m_keys[6] <<
endmsg;
893
894 TBScintillatorRaw *
S1 =
new TBScintillatorRaw(
"S1");
895 TBScintillatorRaw *
S2 =
new TBScintillatorRaw(
"S2");
896 TBScintillatorRaw *
S3 =
new TBScintillatorRaw(
"S3");
897 TBScintillatorRaw *
B =
new TBScintillatorRaw(
"B");
898 TBScintillatorRaw *
Veto =
new TBScintillatorRaw(
"Veto");
899 TBScintillatorRaw * Halo = new TBScintillatorRaw("Halo");
900 TBScintillatorRaw *
muon[8];
901
902 logstr << MSG::DEBUG << " building muon counters:";
903 for(
int i=0;
i<8;
i++) {
904 std::string scintname="muon";
906 os << scintname << (
i+1);
908 logstr << MSG::DEBUG << " " << scintname;
909 muon[
i] =
new TBScintillatorRaw(scintname);
910 }
912
917
920
921 TBADCRaw* Badc = new TBADCRaw(name1+'0',false,abs(tmp1));
922 TBADCRaw* Haloadc = new TBADCRaw(name2+'0',false,abs(tmp2));
927
930 TBADCRaw* S3adc = new TBADCRaw(name1+'1',false,abs(tmp1));
931 TBADCRaw* S2adc = new TBADCRaw(name2+'1',false,abs(tmp2));
936
938 TBADCRaw* S1adc = new TBADCRaw(name1+'2',false,abs(tmp1));
941
942 for(
int i=0;
i<4;
i++) {
947 TBADCRaw* adc1 =
new TBADCRaw(
os.str(),
false,abs(tmp1));
949 os << name2 << (0+3+
i);
950 TBADCRaw* adc2 =
new TBADCRaw(
os.str(),
false,abs(tmp2));
951
952
953 if(
testbit(10,word1)) adc1->setOverflow();
954 if(
testbit(10,word2)) adc2->setOverflow();
959 }
960
961
963 TBTDCRaw* S2tdc = new TBTDCRaw(name2+'6',false,abs(tmp1),0);
965
966
969 TBTDCRaw* S3tdc = new TBTDCRaw(name1+'7',false,abs(tmp1),0);
970 TBTDCRaw* Btdc = new TBTDCRaw(name2+'7',false,abs(tmp2),0);
973
976 TBTDCRaw* Halotdc = new TBTDCRaw(name1+'8',false,abs(tmp1),0);
977 TBTDCRaw* VetoORtdc = new TBTDCRaw(name2+'8',false,abs(tmp2),0);
980
981
982
985
986
987
988
989
994
1001 for(
int i=0;
i<8;
i++) {
1003 }
1004
1005 logstr << MSG::DEBUG <<
" Should I record TBScintillatorRawCont with key " <<
m_keys[6] <<
" ? " <<
endmsg;
1006
1007 }
1008 break;
1009
1010 case 0x07:
1011 {
1014 logstr << MSG::DEBUG <<
" Found MWPC subfragment. Nword= "<<nword <<
endmsg;
1015
1016 std::string mwpcnames[8]= {"X2","Y2","X3","Y3","X4","Y4","X5","Y5"};
1017 bool isX[9]={true,false,true,false,true,false,true,false};
1018 TBMWPCRaw * mwpcraw[8];
1019 for(
int i=0;
i<8;
i++){
1020 mwpcraw[
i] =
new TBMWPCRaw(mwpcnames[i]);
1021 }
1022
1024
1026 else {
1031 int wire;
1032
1033 w = (
int) (word1>>12);
c = (
int) ((0xfff & word1) - w/2 + !(w&1));
1036
1037 if(chamber>7){logstr << MSG::DEBUG <<
"Wrong MWPC chamber number : "<<
chamber <<
endmsg;}
1038 else{
1042 logstr << MSG::DEBUG <<
" MWPC chamber="<<
chamber<<
" wire=" << wire <<
" (w="<<
w<<
")" <<
" c="<<
c<<
endmsg;
1043 }
1044 }
1045
1046 if(status != 0x1000) {MSG::hex(logstr)<< MSG::DEBUG <<
"MWPC status word error =" <<
status <<
endmsg; }
1047
1054 int wire;
1055
1056 w = (
int) (word1>>12);
c = (
int) ((0xfff & word1) - w/2 + !(w&1));
1059
1060 if(chamber>7){logstr << MSG::DEBUG <<
"Wrong MWPC chamber number : "<<
chamber <<
endmsg;}
1061 else{
1065 logstr << MSG::DEBUG <<
" MWPC chamber="<<
chamber<<
" wire=" << wire <<
" (w="<<
w<<
")" <<
" c="<<
c<<
endmsg;
1066 }
1067
1068 w = (
int) (word2>>12);
c = (
int) ((0xfff & word2) - w/2 + !(w&1));
1071
1072
1073 if(chamber>7){logstr << MSG::INFO <<
"Wrong MWPC chamber number : "<<
chamber <<
endmsg;}
1074 else{
1078 logstr << MSG::DEBUG <<
" MWPC chamber="<<
chamber<<
" wire=" << wire <<
" (w="<<
w<<
")" <<
" c="<<
c<<
endmsg;
1079 }
1080
1081 }
1082
1083 for(
int i=0;
i<8;
i++){
1085 }
1086
1087 logstr << MSG::DEBUG <<
" End of MWPC subfragment " <<
endmsg;
1088
1089
1090 }
1091 break;
1092 case 0xf1:
1093 {
1095 char *strw;
1097 if(nword%16){
1098 logstr << MSG::ERROR <<
"bad number of lines. nwords=" << nword <<
endmsg;
1099 break;
1100 }
1101 int nline= nword / 16;
1103 for(
int i=0;
i<nline;
i++){
1104
1105 std::string sline="";
1106 std::string skey="";
1107 for(int j=0;j<63;j++) {
1108 if(strw[i*64+j]==0) break;
1109 sline+=strw[
i*64+j];
1110 }
1111
1112 std::istringstream iss (sline);
1113 iss >> skey;
1114 if(skey=="RunNumber") {
1115 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1117 }
1118 if(skey=="BeamMomentum") {
1119 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1121 }
1122 if(skey=="BeamParticle") {
1123 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1125 }
1126 if(skey=="CryoX") {
1127 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1129 }
1130 if(skey=="CryoAngle") {
1131 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1133 }
1134 if(skey=="TableY") {
1135 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1137 }
1138 if(skey=="miniROD") {
1139 logstr << MSG::DEBUG << sline <<
endmsg;
1141 int board;
1142
1143 while(iss.good()) {iss>>board;
m_boards.push_back(board);}
1144 logstr << MSG::DEBUG <<
"Found nboards="<<
m_boards.size() <<
endmsg;
1146 logstr << MSG::DEBUG<<
endmsg;
1147 }
1148 if(skey=="FebSamples") {
1149 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1152
1154 MSG::dec(logstr) << MSG::DEBUG <<
"nsample="<<
m_samples.size() <<
endmsg;
1156 logstr << MSG::DEBUG<<
endmsg;
1157 }
1158 if(skey=="FebGains") {
1159 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1162
1163 while(iss.good()) {iss>>
gain;
m_gains.push_back(gain);}
1166 MSG::dec(logstr) << MSG::DEBUG <<
"numb of gains="<<
m_gains.size() <<
endmsg;
1167 for(
unsigned i=0;
i<
m_gains.size();
i++)logstr << MSG::DEBUG <<
m_gains[i]<<
" ";
1168 logstr << MSG::DEBUG<<
endmsg;
1169 }
1170 if(skey=="FebAuto") {
1171 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1174
1176 MSG::dec(logstr) << MSG::DEBUG <<
"n febauto="<<
m_febgain.size() <<
" " <<
endmsg;
1178 logstr << MSG::DEBUG<<
endmsg;
1179 }
1180 if(skey=="FebFirstSample") {
1181 MSG::dec(logstr) << MSG::DEBUG << sline <<
endmsg;
1183 int firstsample;
1184
1185 while(iss.good()) {iss>>firstsample;
m_firstsamples.push_back(firstsample);}
1187 }
1188 }
1189
1190
1192
1194
1195
1196
1197
1199
1208
1209
1210
1211 }
1212 break;
1213 case 0xff :
1214 {
1217 logstr << MSG::DEBUG <<
" Found Calib_ID subfragment. Nword= "<<nword <<
endmsg;
1218 if(nword!=6) {
1219 logstr<<MSG::ERROR<<
"Calibration subfrag (0xff) has not expected size" <<
endmsg;
1220 sc=StatusCode::FAILURE;
1221 break;
1222 }
1223
1225
1226 for(
int i=0;
i<4;
i++){
1229
1234 }
1235
1236 logstr << MSG::DEBUG <<
"Found calibration header information " <<
endmsg;
1237 logstr << MSG::DEBUG <<
" Calib pattern: " <<
endmsg;
1238 for(int byte=0; byte<16; byte++) {
1239 logstr << MSG::DEBUG << " byte " << byte << " : " ;
1240 for(int bit=0; bit<8; bit++) {
1241
1243 logstr << MSG::DEBUG << onoff << "/" ;
1244 }
1245 logstr << MSG::DEBUG <<
endmsg;
1246 }
1247
1248
1249
1250
1252
1256
1257
1258
1259
1260
1263 }
1264 break;
1267 break;
1268 }
1269 }
1270
1273
1274
1275}
struct TBPatternUnitContext Veto
struct TBPatternUnitContext S2
struct TBPatternUnitContext S3
struct TBPatternUnitContext S1
virtual void setOverflow()
void setXchambers(bool isX)
void addNwires(int nwire)
void addCwireno(int cwire)
void setSignals(const TBTDCRawCont *tdcCont, TBTDCRaw *tbtdc, const TBADCRawCont *adcCont, TBADCRaw *tbadc)