00001 #include "EventFilter/CSCRawToDigi/interface/CSCAnodeData2007.h"
00002 #include "EventFilter/CSCRawToDigi/interface/CSCALCTHeader.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include <string.h>
00005
00006
00007 CSCAnodeData2007::CSCAnodeData2007(const CSCALCTHeader & header)
00008 : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins())
00009 {
00010 bzero(theDataFrames, sizeInWords()*2);
00011 init(header);
00012 }
00013
00014
00015 CSCAnodeData2007::CSCAnodeData2007(const CSCALCTHeader & header ,
00016 const unsigned short *buf)
00017 : nAFEBs_(header.nLCTChipRead()), nTimeBins_(header.NTBins())
00018 {
00019 init(header);
00020 memcpy(theDataFrames, buf, sizeInWords()*2);
00021 }
00022
00023
00024 void CSCAnodeData2007::init(const CSCALCTHeader & header) {
00028 static unsigned short int layerParts[7] = { 3, 3, 4, 6, 6, 8,10};
00029 static unsigned short int wireGroups[7] = {32,32,48,64,64,96,112};
00030
00031 sizeInWords2007_=(1-header.alctHeader2007().rawOverflow)*6*
00032 header.alctHeader2007().rawBins*layerParts[header.alctHeader2007().boardType];
00033 layerParts_ = layerParts[header.alctHeader2007().boardType];
00034 maxWireGroups_ = wireGroups[header.alctHeader2007().boardType];
00035 }
00036
00037
00038 std::vector<CSCWireDigi> CSCAnodeData2007::wireDigis(int layer) const {
00039 std::vector<CSCWireDigi> digis;
00040 uint32_t tbinbits=0;
00041 uint16_t wireGroup=0;
00042 for(int layerPart = 0; layerPart <layerParts_; ++layerPart) {
00044 for (int j=0; (j<12)&&((layerPart*12+j)<maxWireGroups_) ;++j) {
00047 for(int tbin = 0; tbin < nTimeBins_; ++tbin) {
00048 const CSCAnodeDataFrame2007 & frame = findFrame(tbin, layer, layerPart);
00049 if(frame.data() != 0) {
00050 if(frame.isHit(j)) {
00051 tbinbits=tbinbits + (1<<tbin);
00052 }
00053 }
00054 }
00055 if (tbinbits !=0 ) {
00056 wireGroup = (layerPart*12+j)+1;
00057 CSCWireDigi digi(wireGroup, tbinbits);
00058 LogTrace ("CSCAnodeData|CSCRawToDigi") << "Layer " << layer << " " << digi;
00059 digis.push_back(digi);
00060 tbinbits=0;
00061 }
00062 }
00063 }
00064
00065 return digis;
00066 }
00067
00068
00069 const CSCAnodeDataFrame2007 & CSCAnodeData2007::findFrame(int tbin, int layer, int layerPart) const {
00070 return (const CSCAnodeDataFrame2007 &)(theDataFrames[index(tbin, layer, layerPart)]);
00071 }
00072
00073
00074 CSCAnodeDataFrame2007 & CSCAnodeData2007::findFrame(int tbin, int layer, int layerPart) {
00075 return (CSCAnodeDataFrame2007 &)(theDataFrames[index(tbin, layer, layerPart)]);
00076 }
00077
00078
00079 int CSCAnodeData2007::index(int tbin, int layer, int layerPart) const
00080 {
00081 assert(tbin<nTimeBins_);
00082 assert(layer<=6);
00083 assert(layerPart<layerParts_);
00084 return tbin*6*layerParts_+(layer-1)*layerParts_+layerPart;
00085 }
00086
00087
00088 void CSCAnodeData2007::add(const CSCWireDigi & digi, int layer)
00089 {
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 }
00121