40 #define COUT std::cout << "VI "
42 #define COUT LogDebug("")
48 std::unique_ptr<sistrip::FEDBuffer> buffer;
57 <<
"[ClustersFromRawProducer::"
60 <<
" NULL pointer to FEDRawData for FED id "
70 <<
"[ClustersFromRawProducer::"
72 <<
" FEDRawData has zero size for FED id "
81 if unlikely(!buffer->doChecks(
false))
throw cms::Exception(
"FEDBuffer") <<
"FED Buffer check fails for FED ID" << fedId <<
".";
86 <<
"Exception caught when creating FEDBuffer object for FED " << fedId <<
": " << e.
what();
88 return std::unique_ptr<sistrip::FEDBuffer>();
111 bool idoAPVEmulatorCheck):
115 doAPVEmulatorCheck(idoAPVEmulatorCheck){
117 for (
auto &
d :
done)
d=
nullptr;
121 ~ClusterFiller() { printStat();}
128 std::unique_ptr<sistrip::FEDBuffer> buffers[1024];
129 std::atomic<sistrip::FEDBuffer*>
done[1024];
139 bool doAPVEmulatorCheck;
144 Stat() : totDet(0), detReady(0),detSet(0),detAct(0),detNoZ(0),totClus(0){}
145 std::atomic<int> totDet;
146 std::atomic<int> detReady;
147 std::atomic<int> detSet;
148 std::atomic<int> detAct;
149 std::atomic<int> detNoZ;
150 std::atomic<int> totClus;
155 void incTot(
int n)
const { stat.totDet=
n;}
156 void incReady()
const { stat.detReady++;}
157 void incSet()
const { stat.detSet++;}
158 void incAct()
const { stat.detAct++;}
159 void incNoZ()
const { stat.detNoZ++;}
160 void incClus(
int n)
const { stat.totClus+=
n;}
161 void printStat()
const {
162 COUT <<
"VI clusters " << stat.totDet <<
','<< stat.detReady <<
','<< stat.detSet <<
','<< stat.detAct<<
','<< stat.detNoZ <<
','<< stat.totClus << std::endl;
166 static void zeroStat(){}
167 static void incTot(
int){}
168 static void incReady() {}
169 static void incSet() {}
170 static void incAct() {}
171 static void incNoZ() {}
172 static void incClus(
int){}
173 static void printStat(){}
188 onDemand(conf.getParameter<bool>(
"onDemand")),
192 doAPVEmulatorCheck_(conf.existsAs<bool>(
"DoAPVEmulatorCheck") ? conf.getParameter<bool>(
"DoAPVEmulatorCheck") :
true)
195 produces< edmNew::DetSetVector<SiStripCluster> > ();
215 std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >
225 output->reserve(15000,12*10000);
231 COUT <<
output->dataSize() <<
" clusters from "
232 <<
output->size() <<
" modules"
256 std::auto_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
272 (*clusterizer_).initialize(es);
273 cabling_ = (*clusterizer_).cabling();
274 (*rawAlgos_).initialize(es);
290 if(record.empty()) record.abort();
299 auto idet= record.id();
301 COUT <<
"filling " << idet << std::endl;
303 auto const & det =
clusterizer.stripByStripBegin(idet);
304 if (!det.valid())
return;
310 for (
auto const conn :
clusterizer.currentConnection(det)) {
316 if unlikely( !fedId || !conn->isConnected() ) {
continue; }
322 buffer = fillBuffer(
fedId, rawColl).release();
323 if (!buffer) {
continue;}
325 if (
done[
fedId].compare_exchange_strong(exp, buffer)) buffers[
fedId].reset(buffer);
326 else {
delete buffer; buffer =
done[
fedId]; }
331 const uint8_t fedCh = conn->fedCh();
335 std::ostringstream
ss;
336 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
343 uint16_t ipair = conn->apvPairNumber();
367 std::ostringstream
ss;
368 ss <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " << e.
what();
392 std::ostringstream
ss;
393 ss <<
"Unordered clusters for channel " << fedCh <<
" on FED " <<
fedId <<
": " << e.
what();
404 std::vector<int16_t> digis;
406 digis.push_back(unpacker.
adc());
411 uint32_t
id = conn->detId();
416 uint16_t firstAPV = ipair*2;
417 rawAlgos.SuppressVirginRawData(
id, firstAPV,digis, zsdigis);
429 std::vector<int16_t> digis;
431 digis.push_back(unpacker.
adc());
436 uint32_t
id = conn->detId();
440 uint16_t firstAPV = ipair*2;
441 rawAlgos.SuppressProcessedRawData(
id, firstAPV,digis, zsdigis);
447 <<
"[ClustersFromRawProducer::"
449 <<
" FEDRawData readout mode "
453 <<
" not supported.";
462 if(!record.empty()) incNoZ();
464 COUT <<
"filled " << record.size() << std::endl;
465 for (
auto const &
cl : record )
COUT <<
cl.firstStrip() <<
','<<
cl.amplitudes().size() << std::endl;
466 incClus(record.size());
static FEDRawChannelUnpacker procRawModeUnpacker(const FEDChannel &channel)
virtual char const * what() const
T getParameter(std::string const &) const
static FEDZSChannelUnpacker zeroSuppressedModeUnpacker(const FEDChannel &channel)
void run(const FEDRawDataCollection &rawColl, edmNew::DetSetVector< SiStripCluster > &output)
static const char mlRawToCluster_[]
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
std::auto_ptr< SiStripRawProcessingAlgorithms > rawAlgos_
static FEDRawChannelUnpacker virginRawModeUnpacker(const FEDChannel &channel)
FEDReadoutMode readoutMode() const
std::auto_ptr< StripClusterizerAlgorithm > clusterizer_
void initialize(const edm::EventSetup &es)
friend class TSFastFiller
virtual bool channelGood(const uint8_t internalFEDannelNum, const bool doAPVeCheck=true) const
size_t size() const
Lenght of the data buffer in bytes.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void beginRun(const edm::Run &, const edm::EventSetup &es)
void produce(edm::Event &ev, const edm::EventSetup &es)
const FEDChannel & channel(const uint8_t internalFEDChannelNum) const
static FEDZSChannelUnpacker zeroSuppressedLiteModeUnpacker(const FEDChannel &channel)
SiStripDetCabling const * cabling_
SiStripClusterizerFromRaw(const edm::ParameterSet &conf)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
collection_type::const_iterator const_iterator
edm::EDGetTokenT< FEDRawDataCollection > productToken_