16 : inputTags(conf.getParameter<std::vector<edm::InputTag> >(
"RawDigiProducersList")),
18 storeCM(conf.getParameter<bool>(
"storeCM")),
19 mergeCollections(conf.getParameter<bool>(
"mergeCollections"))
34 produces< edm::DetSetVector<SiStripDigi> > (
"ZeroSuppressed");
38 produces< edm::DetSetVector<SiStripDigi> > (inputTag->instance());
39 if(
produceRawDigis) produces< edm::DetSetVector<SiStripRawDigi> > (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());
75 e.
put( output, inputTag->instance() );
79 e.
put(outputraw, inputTag->instance() );
84 e.
put(outputbaseline,
"BADAPVBASELINE"+inputTag->instance() );
89 e.
put(outputbaselinepoints,
"BADAPVBASELINEPOINTS"+inputTag->instance() );
94 e.
put( outputAPVCM,
"APVCM"+inputTag->instance());
121 rawDigis = input.
begin(); rawDigis != input.
end(); ++rawDigis) {
124 int16_t nAPVflagged = 0;
126 if (
"ProcessedRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressProcessedRawData(*rawDigis, suppressedDigis);
127 else if (
"VirginRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
130 << inputTag.
instance() <<
" unknown. SiStripZeroZuppression can only process types \"VirginRaw\" and \"ProcessedRaw\" ";
151 const std::vector<bool>& apvf =
algorithms->GetAPVFlags();
155 for (; itRawDigis != rawDigis->
end(); ++itRawDigis){
156 int16_t APVn = strip/128;
157 if(apvf[APVn]) outRawDigis.
push_back(*itRawDigis);
168 const std::vector< std::pair<short,float> >& vmedians =
algorithms->getAPVsCM();
180 std::map< uint16_t, std::vector < int16_t> >& baselinemap =
algorithms->GetBaselineMap();
183 std::map< uint16_t, std::vector < int16_t> >::iterator itBaselineMap;
185 for(
size_t i=0;
i<vmedians.size();++
i){
186 uint16_t APVn = vmedians[
i].first;
187 float median = vmedians[
i].second;
188 itBaselineMap = baselinemap.find(APVn);
189 if(itBaselineMap==baselinemap.end()){
197 if(baselineDetSet.
size())
205 std::map< uint16_t, std::map< uint16_t, int16_t> >& BasPointVec =
algorithms->GetSmoothedPoints();
206 std::map< uint16_t, std::map< uint16_t, int16_t> >::iterator itBasPointVect = BasPointVec.begin() ;
207 std::map< uint16_t, int16_t>::iterator itBaselinePointMap;
211 for(; itBasPointVect != BasPointVec.end(); ++itBasPointVect){
212 uint16_t APVn= itBasPointVect->first;
213 itBaselinePointMap =itBasPointVect->second.begin();
214 for(;itBaselinePointMap != itBasPointVect->second.end(); ++itBaselinePointMap){
215 uint16_t bpstrip = (itBaselinePointMap->first) + APVn*128;
216 int16_t bp = itBaselinePointMap->second;
223 if(baspointDetSet.
size())
234 std::vector<bool> apvf;
236 apvf.insert(apvf.begin(), 6,
false);
239 std::vector<bool>& apvFlagged =
algorithms->GetAPVFlags();
240 for(uint16_t it=0; it< apvFlagged.size(); ++it) apvf[it] = apvFlagged[it];
243 for(
size_t i=0;
i<vmedians.size();++
i){
244 if(vmedians[
i].
first>apvNb){
245 for(
int i=0;
i<vmedians[
i].first-apvNb;++
i){
267 std::cout<<
"starting Merging" << std::endl;
273 std::cout << inputdigi->size() <<
" " << inputraw->size() << std::endl;
275 if (inputraw->size()){
277 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
284 std::cout <<
"looping over the raw data collection" << std::endl;
288 uint16_t nAPV = rawDigis->size()/128;
289 uint32_t rawDetId = rawDigis->id;
291 std::vector<bool> restoredAPV;
293 restoredAPV.insert(restoredAPV.begin(), nAPV,
false);
296 bool isModuleRestored =
false;
297 for( uint16_t strip =0; strip < rawDigis->size();++strip){
298 if(itRawDigis[strip].
adc()!=0){
299 restoredAPV[strip/128] =
true;
300 isModuleRestored =
true;
305 if(isModuleRestored){
306 std::cout <<
"apply the ZS to the raw data collection" << std::endl;
308 std::vector<int16_t> processedRawDigis(rawDigis->size());
309 algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
311 if(suppressedDigis.
size()){
312 std::cout <<
"looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
313 std::vector<edm::DetSet<SiStripDigi> >::iterator zsModule = outputdigi.begin();
316 uint32_t zsDetId = zsModule->id;
317 bool isModuleInZscollection =
false;
318 while((zsDetId <= rawDetId)&&(zsModule != outputdigi.end())&&(!isModuleInZscollection)){
320 if( zsDetId == rawDetId){
321 isModuleInZscollection =
true;
324 zsDetId = zsModule->id;
327 std::cout <<
"after the look " << rawDetId <<
" ==== " << zsDetId << std::endl;
328 std::cout <<
"exiting looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
331 std::vector<uint16_t> MergedRawDigis;
332 MergedRawDigis.clear();
333 MergedRawDigis.insert(MergedRawDigis.begin(), nAPV*128, 0);
338 if(!isModuleInZscollection){
339 std::cout <<
"WE HAVE A PROBLEM, THE MODULE IS NTOT FOUND" << std::endl;
340 outputdigi.insert(zsModule, newDigiToIndert);
342 std::cout <<
"new module id -1 " << zsModule->id << std::endl;
344 std::cout <<
"new module id " << zsModule->id << std::endl;
346 std::cout <<
"new module id +1 " << zsModule->id << std::endl;
350 std::cout <<
"inserting only the digis for not restored APVs" << std::endl;
351 std::cout <<
"size : " << zsModule->size() << std::endl;
353 for(; itZsModule != zsModule->
end(); ++itZsModule){
354 uint16_t
adc = itZsModule->adc();
355 uint16_t strip = itZsModule->strip();
356 if(!restoredAPV[strip/128]){
357 MergedRawDigis[strip] =
adc;
359 std::cout <<
"original count: "<< count <<
" strip: " << strip <<
" adc: " << adc << std::endl;
365 std::cout <<
"size of digis to keep: " << count << std::endl;
366 std::cout <<
"inserting only the digis for the restored APVs" << std::endl;
367 std::cout <<
"size : " << suppressedDigis.
size() << std::endl;
369 for(; itSuppDigi != suppressedDigis.
end(); ++itSuppDigi){
370 uint16_t
adc = itSuppDigi->adc();
371 uint16_t strip = itSuppDigi->strip();
372 if(restoredAPV[strip/128]){
373 MergedRawDigis[strip] =
adc;
374 std::cout <<
"new suppressed strip: " << strip <<
" adc: " << adc << std::endl;
380 std::cout <<
"suppressing the raw digis" << std::endl;
382 for(uint16_t strip=0; strip < MergedRawDigis.size(); ++strip){
383 uint16_t
adc = MergedRawDigis[strip];
384 if(adc) zsModule->push_back(
SiStripDigi(strip, adc));
386 std::cout <<
"size zsModule after the merging: " << zsModule->size() << std::endl;
387 if((count + suppressedDigis.
size()) != zsModule->size())
std::cout <<
"WE HAVE A PROBLEM!!!! THE NUMBER OF DIGIS IS NOT RIGHT==============" << std::endl;
388 std::cout <<
"exiting suppressing the raw digis" << std::endl;
395 uint32_t iddg = dg->id;
397 std::cout<<
"NOT IN THE RIGHT ORGER" << std:: endl;
398 std::cout<<
"======================="<< std:: endl;
404 std::cout <<
"write the output vector" << std::endl;
406 e.
put( output,
"ZeroSuppressed" );
424 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
425 std::vector<edm::DetSet<SiStripRawDigi> > outputraw;
428 if (inputraw->size())
432 for ( std::vector<
edm::DetSet<SiStripDigi> >::const_iterator itinputdigi = inputdigi->begin(); itinputdigi !=inputdigi->end(); ++itinputdigi) {
437 e.
put( output, inputTag->instance() );
int adc(sample_type sample)
get the ADC sample (12 bits)
std::vector< edm::InputTag > inputTags
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
void formatRawDigis(edm::DetSetVector< SiStripRawDigi >::const_iterator, edm::DetSet< SiStripRawDigi > &)
void storeBaselinePoints(uint32_t)
void push_back(const T &t)
std::vector< edm::DetSet< SiStripDigi > > output_base
void CollectionMergedZeroSuppression(edm::Event &)
collection_type::iterator iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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