16 :
inputTags(conf.getParameter<
std::vector<
edm::InputTag> >(
"RawDigiProducersList")),
34 produces< edm::DetSetVector<SiStripDigi> > (
"ZeroSuppressed");
38 produces< edm::DetSetVector<SiStripDigi> > (
inputTag->instance());
40 if(produceCalculatedBaseline) produces< edm::DetSetVector<SiStripProcessedRawDigi> > (
"BADAPVBASELINE"+
inputTag->instance());
41 if(produceBaselinePoints) produces< edm::DetSetVector<SiStripDigi> > (
"BADAPVBASELINEPOINTS"+
inputTag->instance());
42 if(
storeCM) produces< edm::DetSetVector<SiStripProcessedRawDigi> > (
"APVCM"+
inputTag->instance());
116 rawDigis = input.
begin(); rawDigis != input.
end(); ++rawDigis) {
119 int16_t nAPVflagged = 0;
121 if (
"ProcessedRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressProcessedRawData(*rawDigis, suppressedDigis);
122 else if (
"VirginRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
125 << inputTag.
instance() <<
" unknown. SiStripZeroZuppression can only process types \"VirginRaw\" and \"ProcessedRaw\" ";
146 const std::vector<bool>& apvf =
algorithms->GetAPVFlags();
150 for (; itRawDigis != rawDigis->
end(); ++itRawDigis){
151 int16_t APVn = strip/128;
152 if(apvf[APVn]) outRawDigis.
push_back(*itRawDigis);
163 const std::vector< std::pair<short,float> >& vmedians =
algorithms->getAPVsCM();
175 std::map< uint16_t, std::vector < int16_t> >& baselinemap =
algorithms->GetBaselineMap();
178 std::map< uint16_t, std::vector < int16_t> >::iterator itBaselineMap;
180 for(
size_t i=0;
i<vmedians.size();++
i){
181 uint16_t APVn = vmedians[
i].first;
182 float median = vmedians[
i].second;
183 itBaselineMap = baselinemap.find(APVn);
184 if(itBaselineMap==baselinemap.end()){
192 if(!baselineDetSet.
empty())
200 std::map< uint16_t, std::map< uint16_t, int16_t> >& BasPointVec =
algorithms->GetSmoothedPoints();
201 std::map< uint16_t, std::map< uint16_t, int16_t> >::iterator itBasPointVect = BasPointVec.begin() ;
202 std::map< uint16_t, int16_t>::iterator itBaselinePointMap;
206 for(; itBasPointVect != BasPointVec.end(); ++itBasPointVect){
207 uint16_t APVn= itBasPointVect->first;
208 itBaselinePointMap =itBasPointVect->second.begin();
209 for(;itBaselinePointMap != itBasPointVect->second.end(); ++itBaselinePointMap){
210 uint16_t bpstrip = (itBaselinePointMap->first) + APVn*128;
211 int16_t bp = itBaselinePointMap->second;
218 if(!baspointDetSet.
empty())
229 std::vector<bool> apvf;
231 apvf.insert(apvf.begin(), 6,
false);
234 std::vector<bool>& apvFlagged =
algorithms->GetAPVFlags();
235 for(uint16_t it=0; it< apvFlagged.size(); ++it) apvf[it] = apvFlagged[it];
238 for(
size_t i=0;
i<vmedians.size();++
i){
239 if(vmedians[
i].
first>apvNb){
240 for(
int i=0;
i<vmedians[
i].first-apvNb;++
i){
254 if(!apvDetSet.
empty())
262 std::cout<<
"starting Merging" << std::endl;
268 std::cout << inputdigi->size() <<
" " << inputraw->size() << std::endl;
270 if (!inputraw->empty()){
272 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
279 std::cout <<
"looping over the raw data collection" << std::endl;
283 uint16_t nAPV = rawDigis->size()/128;
284 uint32_t rawDetId = rawDigis->id;
286 std::vector<bool> restoredAPV;
288 restoredAPV.insert(restoredAPV.begin(), nAPV,
false);
291 bool isModuleRestored =
false;
294 restoredAPV[
strip/128] =
true;
295 isModuleRestored =
true;
300 if(isModuleRestored){
301 std::cout <<
"apply the ZS to the raw data collection" << std::endl;
303 std::vector<int16_t> processedRawDigis(rawDigis->size());
304 algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
306 if(!suppressedDigis.
empty()){
307 std::cout <<
"looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
308 std::vector<edm::DetSet<SiStripDigi> >::iterator zsModule = outputdigi.begin();
311 uint32_t zsDetId = zsModule->id;
312 bool isModuleInZscollection =
false;
313 while((zsDetId <= rawDetId)&&(zsModule != outputdigi.end())&&(!isModuleInZscollection)){
315 if( zsDetId == rawDetId){
316 isModuleInZscollection =
true;
319 zsDetId = zsModule->id;
322 std::cout <<
"after the look " << rawDetId <<
" ==== " << zsDetId << std::endl;
323 std::cout <<
"exiting looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
326 std::vector<uint16_t> MergedRawDigis;
327 MergedRawDigis.clear();
328 MergedRawDigis.insert(MergedRawDigis.begin(), nAPV*128, 0);
333 if(!isModuleInZscollection){
334 std::cout <<
"WE HAVE A PROBLEM, THE MODULE IS NTOT FOUND" << std::endl;
335 outputdigi.insert(zsModule, newDigiToIndert);
337 std::cout <<
"new module id -1 " << zsModule->id << std::endl;
339 std::cout <<
"new module id " << zsModule->id << std::endl;
341 std::cout <<
"new module id +1 " << zsModule->id << std::endl;
345 std::cout <<
"inserting only the digis for not restored APVs" << std::endl;
346 std::cout <<
"size : " << zsModule->size() << std::endl;
348 for(; itZsModule != zsModule->
end(); ++itZsModule){
349 uint16_t
adc = itZsModule->adc();
350 uint16_t
strip = itZsModule->strip();
351 if(!restoredAPV[strip/128]){
354 std::cout <<
"original count: "<< count <<
" strip: " << strip <<
" adc: " << adc << std::endl;
360 std::cout <<
"size of digis to keep: " << count << std::endl;
361 std::cout <<
"inserting only the digis for the restored APVs" << std::endl;
362 std::cout <<
"size : " << suppressedDigis.
size() << std::endl;
364 for(; itSuppDigi != suppressedDigis.
end(); ++itSuppDigi){
365 uint16_t
adc = itSuppDigi->adc();
366 uint16_t
strip = itSuppDigi->strip();
367 if(restoredAPV[strip/128]){
369 std::cout <<
"new suppressed strip: " << strip <<
" adc: " << adc << std::endl;
375 std::cout <<
"suppressing the raw digis" << std::endl;
378 uint16_t
adc = MergedRawDigis[
strip];
381 std::cout <<
"size zsModule after the merging: " << zsModule->size() << std::endl;
382 if((count + suppressedDigis.
size()) != zsModule->size())
std::cout <<
"WE HAVE A PROBLEM!!!! THE NUMBER OF DIGIS IS NOT RIGHT==============" << std::endl;
383 std::cout <<
"exiting suppressing the raw digis" << std::endl;
390 uint32_t iddg = dg->id;
392 std::cout<<
"NOT IN THE RIGHT ORGER" << std:: endl;
393 std::cout<<
"======================="<< std:: endl;
399 std::cout <<
"write the output vector" << std::endl;
418 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
419 std::vector<edm::DetSet<SiStripRawDigi> > outputraw;
422 if (!inputraw->empty())
426 for ( std::vector<
edm::DetSet<SiStripDigi> >::const_iterator itinputdigi = inputdigi->begin(); itinputdigi !=inputdigi->end(); ++itinputdigi) {
int adc(sample_type sample)
get the ADC sample (12 bits)
std::vector< edm::InputTag > inputTags
T getParameter(std::string const &) const
void formatRawDigis(edm::DetSetVector< SiStripRawDigi >::const_iterator, edm::DetSet< SiStripRawDigi > &)
void storeBaselinePoints(uint32_t)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void push_back(const T &t)
std::vector< edm::DetSet< SiStripDigi > > output_base
void CollectionMergedZeroSuppression(edm::Event &)
collection_type::iterator iterator
def create(alignables, pedeDump, additionalData, outputFile, config)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::Event &, const edm::EventSetup &) override
A signed Digi for the silicon strip detector, containing only adc information, and suitable for stori...
bool produceCalculatedBaseline
void processRaw(const edm::InputTag &, const edm::DetSetVector< SiStripRawDigi > &)
std::vector< edm::DetSet< SiStripDigi > > output_baseline_points
void StandardZeroSuppression(edm::Event &)
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
bool produceBaselinePoints
static std::string const input
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > DigisToMergeZS
U second(std::pair< T, U > const &p)
std::auto_ptr< SiStripRawProcessingAlgorithms > algorithms
void storeExtraOutput(uint32_t, int16_t)
void storeCMN(uint32_t, const std::vector< std::pair< short, float > > &)
void MergeCollectionsZeroSuppression(edm::Event &)
std::vector< edm::DetSet< SiStripProcessedRawDigi > > output_apvcm
std::vector< edm::DetSet< SiStripProcessedRawDigi > > output_baseline
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
iterator end()
Return the off-the-end iterator.
void storeBaseline(uint32_t, const std::vector< std::pair< short, float > > &)
std::vector< edm::DetSet< SiStripRawDigi > > output_base_raw
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > DigisToMergeVR
SiStripZeroSuppression(const edm::ParameterSet &)
token_v::const_iterator token_iterator_t
iterator begin()
Return an iterator to the first DetSet.
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
std::vector< edm::InputTag >::const_iterator tag_iterator_t