#include <EventFilter/HcalRawToDigi/interface/HcalPacker.h>
Public Member Functions | |
void | pack (int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const Collections &inputs, const HcalElectronicsMap &emap, FEDRawData &output) |
Private Member Functions | |
int | findSamples (const DetId &did, const Collections &inputs, unsigned short *buffer, int &presamples) |
Classes | |
struct | Collections |
Definition at line 14 of file HcalPacker.h.
int HcalPacker::findSamples | ( | const DetId & | did, | |
const Collections & | inputs, | |||
unsigned short * | buffer, | |||
int & | presamples | |||
) | [private] |
Definition at line 48 of file HcalPacker.cc.
References HcalPacker::Collections::calibCont, DetId::det(), HcalGenericDetId::genericSubdet(), HcalPacker::Collections::hbhe, DetId::Hcal, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenCalibration, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, HcalGenericDetId::HcalGenZDC, HcalPacker::Collections::hfCont, HcalPacker::Collections::hoCont, size, and HcalPacker::Collections::zdcCont.
Referenced by pack().
00049 { 00050 if (did.det()!=DetId::Hcal) return 0; 00051 int size=0; 00052 HcalGenericDetId genId(did); 00053 00054 switch (genId.genericSubdet()) { 00055 case(HcalGenericDetId::HcalGenBarrel): 00056 case(HcalGenericDetId::HcalGenEndcap): 00057 size=process<HBHEDigiCollection,HcalDetId>(inputs.hbhe,did,buffer,presamples); 00058 break; 00059 case(HcalGenericDetId::HcalGenOuter): 00060 size=process<HODigiCollection,HcalDetId>(inputs.hoCont,did,buffer,presamples); 00061 break; 00062 case(HcalGenericDetId::HcalGenForward): 00063 size=process<HFDigiCollection,HcalDetId>(inputs.hfCont,did,buffer,presamples); 00064 break; 00065 case(HcalGenericDetId::HcalGenZDC): 00066 size=process<ZDCDigiCollection,HcalZDCDetId>(inputs.zdcCont,did,buffer,presamples); 00067 break; 00068 case(HcalGenericDetId::HcalGenCalibration): 00069 size=process<HcalCalibDigiCollection,HcalCalibDetId>(inputs.calibCont,did,buffer,presamples); 00070 break; 00071 default: size=0; 00072 } 00073 return size; 00074 }
void HcalPacker::pack | ( | int | fedid, | |
int | dccnumber, | |||
int | nl1a, | |||
int | orbitn, | |||
int | bcn, | |||
const Collections & | inputs, | |||
const HcalElectronicsMap & | emap, | |||
FEDRawData & | output | |||
) |
pack into HcalHTRData
Definition at line 76 of file HcalPacker.cc.
References HcalHTRData::allocate(), HcalHTRData::CHANNELS_PER_SPIGOT, HcalDCCHeader::clear(), evf::compute_crc(), HcalDCCHeader::copySpigotData(), FEDRawData::data(), findSamples(), HcalHTRData::getRawLength(), HcalElectronicsId::htrSlot(), HcalElectronicsId::htrTopBottom(), HcalElectronicsMap::lookup(), HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL, DetId::null(), HcalHTRData::pack(), HcalHTRData::packHeaderTrailer(), processTrig(), HcalTriggerPrimitiveSample::raw(), HcalQIESample::raw(), HcalElectronicsId::readoutVMECrateId(), FEDRawData::resize(), FEDTrailer::set(), HcalDCCHeader::setHeader(), FEDRawData::size(), and HcalPacker::Collections::tpCont.
Referenced by HcalDigiToRaw::produce().
00080 { 00081 std::vector<unsigned short> precdata(HcalHTRData::CHANNELS_PER_SPIGOT*HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL); 00082 std::vector<unsigned short> trigdata(HcalHTRData::CHANNELS_PER_SPIGOT*HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL); 00083 std::vector<unsigned char> preclen(HcalHTRData::CHANNELS_PER_SPIGOT); 00084 std::vector<unsigned char> triglen(HcalHTRData::CHANNELS_PER_SPIGOT); 00085 static const int HTRFormatVersion=3; 00086 00087 HcalHTRData spigots[15]; 00088 // loop over all valid channels in the given dcc, spigot by spigot. 00089 for (int spigot=0; spigot<15; spigot++) { 00090 spigots[spigot].allocate(HTRFormatVersion); 00091 HcalElectronicsId exampleEId; 00092 int npresent=0; 00093 int presamples=-1, samples=-1; 00094 for (int fiber=1; fiber<=8; fiber++) 00095 for (int fiberchan=0; fiberchan<3; fiberchan++) { 00096 int linear=(fiber-1)*3+fiberchan; 00097 HcalQIESample chanSample(0,0,fiber,fiberchan,false,false); 00098 unsigned short chanid=chanSample.raw()&0xF800; 00099 preclen[linear]=0; 00100 00101 HcalElectronicsId partialEid(fiberchan,fiber,spigot,dccnumber); 00102 // does this partial id exist? 00103 HcalElectronicsId fullEid; 00104 HcalGenericDetId genId; 00105 if (!emap.lookup(partialEid,fullEid,genId)) continue; 00106 00107 00108 // next, see if there is a digi with this id 00109 unsigned short* database=&(precdata[linear*HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL]); 00110 int mypresamples; 00111 int mysamples=findSamples(genId,inputs,database,mypresamples); 00112 00113 if (mysamples>0) { 00114 if (samples<0) samples=mysamples; 00115 else if (samples!=mysamples) { 00116 edm::LogError("HCAL") << "Mismatch of samples in a single HTR (unsupported) " << mysamples << " != " << samples; 00117 continue; 00118 } 00119 if (presamples<0) { 00120 presamples=mypresamples; 00121 exampleEId=fullEid; 00122 } else if (mypresamples!=presamples) { 00123 edm::LogError("HCAL") << "Mismatch of presamples in a single HTR (unsupported) " << mypresamples << " != " << presamples; 00124 continue; 00125 } 00126 for (int ii=0; ii<samples; ii++) 00127 database[ii]=(database[ii]&0x7FF)|chanid; 00128 preclen[linear]=(unsigned char)(samples); 00129 npresent++; 00130 } 00131 } 00132 for (int slb=1; slb<=6; slb++) 00133 for (int slbchan=0; slbchan<=3; slbchan++) { 00134 int linear=(slb-1)*4+slbchan; 00135 HcalTriggerPrimitiveSample idCvt(0,0,slb,slbchan); 00136 unsigned short chanid=idCvt.raw()&0xF800; 00137 triglen[linear]=0; 00138 00139 HcalElectronicsId partialEid(slbchan,slb,spigot,dccnumber,0,0,0); 00140 // does this partial id exist? 00141 HcalElectronicsId fullEid; 00142 HcalTrigTowerDetId tid; 00143 if (!emap.lookup(partialEid,fullEid,tid)) { 00144 // std::cout << "TPGPACK : no match for " << partialEid << std::endl; 00145 continue; 00146 } //else std::cout << "TPGPACK : converted " << partialEid << " to " << fullEid << "/" << tid << std::endl; 00147 00148 // finally, what about a trigger channel? 00149 if (!tid.null()) { 00150 unsigned short* trigbase=&(trigdata[linear*HcalHTRData::MAXIMUM_SAMPLES_PER_CHANNEL]); 00151 triglen[linear]=processTrig(inputs.tpCont,tid,trigbase); 00152 00153 for (unsigned char q=0; q<triglen[linear]; q++) 00154 trigbase[q]=(trigbase[q]&0x7FF)|chanid; 00155 } 00156 } 00158 if (npresent>0) { 00159 spigots[spigot].pack(&(preclen[0]),&(precdata[0]), 00160 &(triglen[0]),&(trigdata[0]), 00161 false); 00162 static const int pipeline=0x22; 00163 static const int firmwareRev=0; 00164 int submodule=exampleEId.htrTopBottom()&0x1; 00165 submodule|=(exampleEId.htrSlot()&0x1F)<<1; 00166 submodule|=(exampleEId.readoutVMECrateId()&0x1f)<<6; 00167 spigots[spigot].packHeaderTrailer(nl1a, 00168 bcn, 00169 submodule, 00170 orbitn, 00171 pipeline, 00172 samples, 00173 presamples, 00174 firmwareRev); 00175 00176 } 00177 } 00178 // calculate the total length, and resize the FEDRawData 00179 int theSize=0; 00180 for (int spigot=0; spigot<15; spigot++) { 00181 theSize+=spigots[spigot].getRawLength()*sizeof(unsigned short); 00182 } 00183 theSize+=sizeof(HcalDCCHeader)+8; // 8 for trailer 00184 theSize+=(8-(theSize%8))%8; // even number of 64-bit words. 00185 output.resize(theSize); 00186 00187 // construct the bare DCC Header 00188 HcalDCCHeader* dcc=(HcalDCCHeader*)(output.data()); 00189 dcc->clear(); 00190 dcc->setHeader(fedid,bcn,nl1a,orbitn); 00191 00192 // pack the HTR data into the FEDRawData block using HcalDCCHeader 00193 for (int spigot=0; spigot<15; spigot++) { 00194 if (spigots[spigot].getRawLength()>0) 00195 dcc->copySpigotData(spigot,spigots[spigot],true,0); 00196 } 00197 // trailer 00198 FEDTrailer fedTrailer(output.data()+(output.size()-8)); 00199 fedTrailer.set(output.data()+(output.size()-8), 00200 output.size()/8, 00201 evf::compute_crc(output.data(),output.size()), 0, 0); 00202 }