CMS 3D CMS Logo

CSCAnodeData2007.cc

Go to the documentation of this file.
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> // for bzero
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         }//end of tbin loop
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   int wireGroup = digi.getWireGroup();
00092   int bxn=digi.getBeamCrossingTag(); 
00093   int alctBoard  = (wireGroup-1) / 16;
00094   int localGroup = (wireGroup-1) % 16;
00095 
00096   // crash if there's a bad wire number, but don't freak out
00097   // if a time bin is out of range 
00098   //  assert(alctBoard < nAFEBs_);
00099   if(alctBoard > nAFEBs_)
00100     {
00101       edm::LogError("CSCAnodeData|CSCRawToDigi") << "Bad Wire Number for this digi.";
00102       return;
00103     }
00104 
00105   if(bxn >= 0 && bxn < nTimeBins_) 
00106     {
00107       // 12 16-bit words per time bin, two per layer
00108       // wiregroups 0-7 go on the first line, 8-15 go on the 2nd.
00109       unsigned halfLayer = (localGroup > 7);
00110       unsigned bitNumber = localGroup % 8;
00111       // and pack it in the 8 bits allocated
00112       rawHit(alctBoard, bxn, layer, halfLayer).addHit(bitNumber);
00113     } 
00114   else 
00115     {
00116       LogTrace("CSCAnodeData|CSCRawToDigi")<< "warning: not saving anode data in bx " << bxn 
00117                               << ": out of range ";
00118     }
00119 */
00120 }
00121 

Generated on Tue Jun 9 17:34:23 2009 for CMSSW by  doxygen 1.5.4