Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ES unpacker when the 2nd OptoRX is disabled, but the 1st and 3rd … #11613

Merged
merged 2 commits into from Oct 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 31 additions & 15 deletions EventFilter/ESRawToDigi/src/ESUnpacker.cc
Expand Up @@ -42,7 +42,7 @@ ESUnpacker::ESUnpacker(const edm::ParameterSet& ps)
}

} else {
std::cout<<"ESUnpacker::ESUnpacker : Look up table file can not be found in "<<lookup_.fullPath().c_str()<<std::endl;
edm::LogWarning("Invalid Data")<<"ESUnpacker::ESUnpacker : Look up table file can not be found in "<<lookup_.fullPath().c_str();
}

}
Expand Down Expand Up @@ -77,10 +77,10 @@ void ESUnpacker::interpretRawData(int fedId, const FEDRawData & rawData, ESRawDa
bx_ = ESHeader.bxID();

if (debug_) {
std::cout<<"[ESUnpacker]: FED Header candidate. Is header? "<< ESHeader.check();
LogDebug("ESUnpacker")<<"[ESUnpacker]: FED Header candidate. Is header? "<< ESHeader.check();
if (ESHeader.check())
std::cout <<". BXID: "<<bx_<<" SourceID : "<<fedId_<<" L1ID: "<<lv1_<<std::endl;
else std::cout<<" WARNING!, this is not a ES Header"<<std::endl;
LogDebug("ESUnpacker") <<". BXID: "<<bx_<<" SourceID : "<<fedId_<<" L1ID: "<<lv1_;
else LogDebug("ESUnpacker")<<" WARNING!, this is not a ES Header";
}

moreHeaders = ESHeader.moreHeaders();
Expand Down Expand Up @@ -120,10 +120,10 @@ void ESUnpacker::interpretRawData(int fedId, const FEDRawData & rawData, ESRawDa
}
slinkCRC = (*trailer >> 2 ) & 0x1;
if (debug_) {
std::cout<<"[ESUnpacker]: FED Trailer candidate. Is trailer? "<<ESTrailer.check();
LogDebug("ESUnpacker")<<"[ESUnpacker]: FED Trailer candidate. Is trailer? "<<ESTrailer.check();
if (ESTrailer.check())
std::cout<<". Length of the ES event: "<<ESTrailer.lenght()<<std::endl;
else std::cout<<" WARNING!, this is not a ES Trailer"<<std::endl;
LogDebug("ESUnpacker")<<". Length of the ES event: "<<ESTrailer.lenght();
else LogDebug("ESUnpacker")<<" WARNING!, this is not a ES Trailer";
}

moreTrailers = ESTrailer.moreTrailers();
Expand All @@ -144,7 +144,7 @@ void ESUnpacker::interpretRawData(int fedId, const FEDRawData & rawData, ESRawDa
int dccCRC2_ = 0;
int dccCRC3_ = 0;
for (const Word64* word=(header+1); word!=(header+dccWords+1); ++word) {
if (debug_) std::cout<<"DCC : "<<print(*word)<<std::endl;
if (debug_) LogDebug("ESUnpacker")<<"DCC : "<<print(*word);
dccHead = (*word >> 60) & m4;
if (dccHead == 3) dccHeaderCount++;
dccLine = (*word >> 56) & m4;
Expand Down Expand Up @@ -208,16 +208,30 @@ void ESUnpacker::interpretRawData(int fedId, const FEDRawData & rawData, ESRawDa
ESDCCHeader.setOptoRX1(optoRX1_ + dccCRC2_);
ESDCCHeader.setOptoRX2(optoRX2_ + dccCRC3_);
ESDCCHeader.setFEChannelStatus(FEch_status);
int enableOptoRX[3] = {-1, -1, -1};
int NenableOptoRX = 0;
if (optoRX0_ == 128) {
enableOptoRX[NenableOptoRX] = 0;
NenableOptoRX++;
}
if (optoRX1_ == 128) {
enableOptoRX[NenableOptoRX] = 1;
NenableOptoRX++;
}
if (optoRX2_ == 128) {
enableOptoRX[NenableOptoRX] = 2;
}

// Event data
int opto = 0;
int iopto = 0;
int opto = -1;
for (const Word64* word=(header+dccWords+1); word!=trailer; ++word) {
if (debug_) std::cout<<"Event : "<<print(*word)<<std::endl;
if (debug_) LogDebug("ESUnpacker")<<"Event : "<<print(*word);

head = (*word >> 60) & m4;

if (head == 12) {
if ((opto==1 && ESDCCHeader.getOptoRX0()==129) || (opto==2 && ESDCCHeader.getOptoRX1()==129) || (opto==3 && ESDCCHeader.getOptoRX2()==129))
if ((opto==0 && ESDCCHeader.getOptoRX0()==129) || (opto==1 && ESDCCHeader.getOptoRX1()==129) || (opto==2 && ESDCCHeader.getOptoRX2()==129))
word2digi(kid, kPACE, *word, digis);
} else if (head == 9) {
kid = (*word >> 2) & 0x07ff;
Expand All @@ -242,10 +256,12 @@ void ESUnpacker::interpretRawData(int fedId, const FEDRawData & rawData, ESRawDa
} else if (head == 6) {
optoBC = (*word >> 32) & m16;
optoEC = (*word >> 48) & m8;

opto = enableOptoRX[iopto];
if (opto==0) ESDCCHeader.setOptoBC0(optoBC);
else if (opto==1) ESDCCHeader.setOptoBC1(optoBC);
else if (opto==2) ESDCCHeader.setOptoBC2(optoBC);
opto++;
if (iopto < 2) ++iopto;
}
}

Expand All @@ -265,7 +281,7 @@ void ESUnpacker::word2digi(int kid, int kPACE[4], const Word64 & word, ESDigiCol
adc[2] = (word >> 32) & m16;
int strip = (word >> 48) & m5;

if (debug_) std::cout<<kid<<" "<<strip<<" "<<pace<<" "<<adc[0]<<" "<<adc[1]<<" "<<adc[2]<<std::endl;
if (debug_) LogDebug("ESUnpacker")<<kid<<" "<<strip<<" "<<pace<<" "<<adc[0]<<" "<<adc[1]<<" "<<adc[2];

int zside, plane, ix, iy;
zside = zside_[kid-1][pace];
Expand All @@ -281,7 +297,7 @@ void ESUnpacker::word2digi(int kid, int kPACE[4], const Word64 & word, ESDigiCol
if (zside == -1 && plane == 2 && ix <= 20) strip = 31 - strip;
}

if (debug_) std::cout<<"DetId : "<<zside<<" "<<plane<<" "<<ix<<" "<<iy<<" "<<strip+1<<std::endl;
if (debug_) LogDebug("ESUnpacker")<<"DetId : "<<zside<<" "<<plane<<" "<<ix<<" "<<iy<<" "<<strip+1;

if (ESDetId::validDetId(strip+1, ix, iy, plane, zside)) {

Expand All @@ -294,7 +310,7 @@ void ESUnpacker::word2digi(int kid, int kPACE[4], const Word64 & word, ESDigiCol
digis.push_back(df);

if (debug_)
std::cout<<"Si : "<<detId.zside()<<" "<<detId.plane()<<" "<<detId.six()<<" "<<detId.siy()<<" "<<detId.strip()<<" ("<<kid<<","<<pace<<") "<<df.sample(0).adc()<<" "<<df.sample(1).adc()<<" "<<df.sample(2).adc()<<std::endl;
LogDebug("ESUnpacker")<<"Si : "<<detId.zside()<<" "<<detId.plane()<<" "<<detId.six()<<" "<<detId.siy()<<" "<<detId.strip()<<" ("<<kid<<","<<pace<<") "<<df.sample(0).adc()<<" "<<df.sample(1).adc()<<" "<<df.sample(2).adc();
}

}
Expand Down