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()
override { 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),detAbrt(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> detAbrt;
151 std::atomic<int> totClus;
156 void incTot(
int n)
const { stat.totDet=
n;}
157 void incReady()
const { stat.detReady++;}
158 void incSet()
const { stat.detSet++;}
159 void incAct()
const { stat.detAct++;}
160 void incNoZ()
const { stat.detNoZ++;}
161 void incAbrt()
const { stat.detAbrt++;}
162 void incClus(
int n)
const { stat.totClus+=
n;}
163 void printStat()
const {
164 COUT <<
"VI clusters " << stat.totDet <<
','<< stat.detReady <<
','<< stat.detSet <<
','<< stat.detAct<<
','<< stat.detNoZ <<
','<<stat.detAbrt <<
','<<stat.totClus << std::endl;
168 static void zeroStat(){}
169 static void incTot(
int){}
170 static void incReady() {}
171 static void incSet() {}
172 static void incAct() {}
173 static void incNoZ() {}
174 static void incAbrt(){}
175 static void incClus(
int){}
176 static void printStat(){}
195 doAPVEmulatorCheck_(conf.existsAs<
bool>(
"DoAPVEmulatorCheck") ? conf.getParameter<
bool>(
"DoAPVEmulatorCheck") :
true)
198 produces< edmNew::DetSetVector<SiStripCluster> > ();
199 assert(clusterizer_.get());
200 assert(rawAlgos_.get());
218 std::unique_ptr< edmNew::DetSetVector<SiStripCluster> >
221 *rawAlgos_, doAPVEmulatorCheck_)
223 clusterizer_->allDetIds())
228 output->reserve(15000,24*10000);
234 COUT <<
output->dataSize() <<
" clusters from " 235 <<
output->size() <<
" modules" 259 std::unique_ptr<SiStripRawProcessingAlgorithms>
rawAlgos_;
275 (*clusterizer_).initialize(es);
276 cabling_ = (*clusterizer_).cabling();
277 (*rawAlgos_).initialize(es);
284 ClusterFiller
filler(rawColl, *clusterizer_, *rawAlgos_, doAPVEmulatorCheck_);
287 for (
auto idet : clusterizer_->allDetIds()) {
293 if(record.empty()) record.abort();
302 auto idet= record.id();
304 COUT <<
"filling " << idet << std::endl;
306 auto const & det =
clusterizer.stripByStripBegin(idet);
307 if (!det.valid())
return;
313 for (
auto const conn :
clusterizer.currentConnection(det)) {
316 const uint16_t
fedId = conn->fedId();
319 if unlikely( !fedId || !conn->isConnected() ) {
continue; }
325 buffer = fillBuffer(fedId, rawColl).release();
326 if (!buffer) {
continue;}
328 if (done[fedId].compare_exchange_strong(exp, buffer)) buffers[
fedId].reset(buffer);
334 const uint8_t fedCh = conn->fedCh();
338 std::ostringstream ss;
339 ss <<
"Problem unpacking channel " << fedCh <<
" on FED " <<
fedId;
346 uint16_t ipair = conn->apvPairNumber();
370 std::ostringstream ss;
371 ss <<
"Unordered clusters for channel " << fedCh <<
" on FED " << fedId <<
": " << e.
what();
395 std::ostringstream ss;
396 ss <<
"Unordered clusters for channel " << fedCh <<
" on FED " << fedId <<
": " << e.
what();
407 std::vector<int16_t> digis;
409 digis.push_back(unpacker.
adc());
414 uint32_t
id = conn->detId();
419 uint16_t firstAPV = ipair*2;
420 rawAlgos.SuppressVirginRawData(
id, firstAPV,digis, zsdigis);
432 std::vector<int16_t> digis;
434 digis.push_back(unpacker.
adc());
439 uint32_t
id = conn->detId();
443 uint16_t firstAPV = ipair*2;
444 rawAlgos.SuppressProcessedRawData(
id, firstAPV,digis, zsdigis);
450 <<
"[ClustersFromRawProducer::" 452 <<
" FEDRawData readout mode " 456 <<
" not supported.";
472 if(!record.empty()) incNoZ();
474 COUT <<
"filled " << record.size() << std::endl;
475 for (
auto const &
cl : record )
COUT <<
cl.firstStrip() <<
','<<
cl.amplitudes().size() << std::endl;
476 incClus(record.size());
static FEDRawChannelUnpacker procRawModeUnpacker(const FEDChannel &channel)
T getParameter(std::string const &) const
static AlgebraicMatrix initialize()
static FEDZSChannelUnpacker zeroSuppressedModeUnpacker(const FEDChannel &channel)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void beginRun(const edm::Run &, const edm::EventSetup &es) override
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)
static FEDRawChannelUnpacker virginRawModeUnpacker(const FEDChannel &channel)
FEDReadoutMode readoutMode() const
char const * what() const override
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.
void produce(edm::Event &ev, const edm::EventSetup &es) override
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static std::auto_ptr< StripClusterizerAlgorithm > create(const edm::ParameterSet &)
std::unique_ptr< StripClusterizerAlgorithm > clusterizer_
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
std::unique_ptr< SiStripRawProcessingAlgorithms > rawAlgos_
edm::EDGetTokenT< FEDRawDataCollection > productToken_