#include <SiStripZeroSuppression.h>
Definition at line 16 of file SiStripZeroSuppression.h.
typedef std::vector<edm::InputTag>::const_iterator SiStripZeroSuppression::tag_iterator_t [private] |
Definition at line 40 of file SiStripZeroSuppression.h.
SiStripZeroSuppression::SiStripZeroSuppression | ( | const edm::ParameterSet & | conf | ) | [explicit] |
Definition at line 14 of file SiStripZeroSuppression.cc.
References DigisToMergeVR, DigisToMergeZS, fixCM, edm::ParameterSet::getParameter(), inputTags, mergeCollections, produceBaselinePoints, produceCalculatedBaseline, produceRawDigis, storeCM, and storeInZScollBadAPV.
: inputTags(conf.getParameter<std::vector<edm::InputTag> >("RawDigiProducersList")), algorithms(SiStripRawProcessingFactory::create(conf.getParameter<edm::ParameterSet>("Algorithms"))), storeCM(conf.getParameter<bool>("storeCM")), mergeCollections(conf.getParameter<bool>("mergeCollections")) { produceRawDigis = conf.getParameter<bool>("produceRawDigis"); produceCalculatedBaseline = conf.getParameter<bool>("produceCalculatedBaseline"); produceBaselinePoints = conf.getParameter<bool>("produceBaselinePoints"); storeInZScollBadAPV = conf.getParameter<bool>("storeInZScollBadAPV"); fixCM = conf.getParameter<bool>("fixCM"); if(mergeCollections){ storeCM = false; produceRawDigis = false; DigisToMergeZS = conf.getParameter<edm::InputTag>("DigisToMergeZS"); DigisToMergeVR = conf.getParameter<edm::InputTag>("DigisToMergeVR"); produces< edm::DetSetVector<SiStripDigi> > ("ZeroSuppressed"); } for(tag_iterator_t inputTag = inputTags.begin(); inputTag != inputTags.end(); ++inputTag ){ produces< edm::DetSetVector<SiStripDigi> > (inputTag->instance()); if(produceRawDigis) produces< edm::DetSetVector<SiStripRawDigi> > (inputTag->instance()); if(produceCalculatedBaseline) produces< edm::DetSetVector<SiStripProcessedRawDigi> > ("BADAPVBASELINE"+inputTag->instance()); if(produceBaselinePoints) produces< edm::DetSetVector<SiStripDigi> > ("BADAPVBASELINEPOINTS"+inputTag->instance()); if(storeCM) produces< edm::DetSetVector<SiStripProcessedRawDigi> > ("APVCM"+inputTag->instance()); } }
void SiStripZeroSuppression::CollectionMergedZeroSuppression | ( | edm::Event & | e | ) | [inline, private] |
Definition at line 413 of file SiStripZeroSuppression.cc.
References edm::Event::getByLabel(), inputTags, convertSQLitetoXML_cfg::output, output_base, processRaw(), and edm::Event::put().
{ for(tag_iterator_t inputTag = inputTags.begin(); inputTag != inputTags.end(); ++inputTag ) { edm::Handle< edm::DetSetVector<SiStripDigi> > inputdigi; edm::Handle< edm::DetSetVector<SiStripRawDigi> > inputraw; e.getByLabel(*inputTag,inputdigi); e.getByLabel(*inputTag,inputraw); std::vector<edm::DetSet<SiStripDigi> > outputdigi; std::vector<edm::DetSet<SiStripRawDigi> > outputraw; if (inputraw->size()) processRaw(*inputTag, *inputraw); for ( std::vector<edm::DetSet<SiStripDigi> >::const_iterator itinputdigi = inputdigi->begin(); itinputdigi !=inputdigi->end(); ++itinputdigi) { output_base.push_back(*itinputdigi); } std::auto_ptr< edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>(output_base) ); e.put( output, inputTag->instance() ); } }
void SiStripZeroSuppression::formatRawDigis | ( | edm::DetSetVector< SiStripRawDigi >::const_iterator | rawDigis, |
edm::DetSet< SiStripRawDigi > & | outRawDigis | ||
) | [inline, private] |
Definition at line 146 of file SiStripZeroSuppression.cc.
References algorithms, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), edm::DetSet< T >::push_back(), and strip().
Referenced by processRaw().
{ const std::vector<bool>& apvf = algorithms->GetAPVFlags(); edm::DetSet<SiStripRawDigi>::const_iterator itRawDigis = rawDigis->begin(); uint32_t strip=0; for (; itRawDigis != rawDigis->end(); ++itRawDigis){ int16_t APVn = strip/128; if(apvf[APVn]) outRawDigis.push_back(*itRawDigis); else outRawDigis.push_back(SiStripRawDigi(0)); ++strip; } }
void SiStripZeroSuppression::MergeCollectionsZeroSuppression | ( | edm::Event & | e | ) | [inline, private] |
Definition at line 263 of file SiStripZeroSuppression.cc.
References ecalMGPA::adc(), algorithms, edm::DetSet< T >::begin(), edm::HandleBase::clear(), prof2calltree::count, gather_cfg::cout, DigisToMergeVR, DigisToMergeZS, edm::DetSet< T >::end(), edm::Event::getByLabel(), convertSQLitetoXML_cfg::output, edm::Event::put(), edm::DetSet< T >::size(), and strip().
Referenced by produce().
{ std::cout<< "starting Merging" << std::endl; edm::Handle< edm::DetSetVector<SiStripDigi> > inputdigi; edm::Handle< edm::DetSetVector<SiStripRawDigi> > inputraw; e.getByLabel(DigisToMergeZS,inputdigi); e.getByLabel(DigisToMergeVR,inputraw); std::cout << inputdigi->size() << " " << inputraw->size() << std::endl; if (inputraw->size()){ std::vector<edm::DetSet<SiStripDigi> > outputdigi; outputdigi.clear(); //std::cout << "copying the input ZS to the output ZS collection" << std::endl; for ( edm::DetSetVector<SiStripDigi>::const_iterator Digis = inputdigi->begin(); Digis != inputdigi->end(); ++Digis) outputdigi.push_back(*Digis); std::cout << "looping over the raw data collection" << std::endl; for ( edm::DetSetVector<SiStripRawDigi>::const_iterator rawDigis = inputraw->begin(); rawDigis != inputraw->end(); ++rawDigis) { edm::DetSet<SiStripRawDigi>::const_iterator itRawDigis = rawDigis->begin(); uint16_t nAPV = rawDigis->size()/128; uint32_t rawDetId = rawDigis->id; std::vector<bool> restoredAPV; restoredAPV.clear(); restoredAPV.insert(restoredAPV.begin(), nAPV, false); bool isModuleRestored = false; for( uint16_t strip =0; strip < rawDigis->size();++strip){ if(itRawDigis[strip].adc()!=0){ restoredAPV[strip/128] = true; isModuleRestored = true; } } if(isModuleRestored){ std::cout << "apply the ZS to the raw data collection" << std::endl; edm::DetSet<SiStripDigi> suppressedDigis(rawDetId); std::vector<int16_t> processedRawDigis(rawDigis->size()); algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis); if(suppressedDigis.size()){ std::cout << "looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl; std::vector<edm::DetSet<SiStripDigi> >::iterator zsModule = outputdigi.begin(); //std::vector<edm::DetSet<SiStripDigi> >::iterator LastLowerIdDigis = zsModule; uint32_t zsDetId = zsModule->id; bool isModuleInZscollection = false; while((zsDetId <= rawDetId)&&(zsModule != outputdigi.end())&&(!isModuleInZscollection)){ //std::cout << rawDetId << " ==== " << zsDetId << std::endl; if( zsDetId == rawDetId){ isModuleInZscollection = true; }else{ ++zsModule; zsDetId = zsModule->id; } } std::cout << "after the look " << rawDetId << " ==== " << zsDetId << std::endl; std::cout << "exiting looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl; //creating the map containing the digis (in rawdigi format) merged std::vector<uint16_t> MergedRawDigis; MergedRawDigis.clear(); MergedRawDigis.insert(MergedRawDigis.begin(), nAPV*128, 0); uint32_t count=0; // to be removed... edm::DetSet<SiStripDigi> newDigiToIndert(rawDetId); if(!isModuleInZscollection){ std::cout << "WE HAVE A PROBLEM, THE MODULE IS NTOT FOUND" << std::endl; outputdigi.insert(zsModule, newDigiToIndert); --zsModule; std::cout << "new module id -1 " << zsModule->id << std::endl; ++zsModule; std::cout << "new module id " << zsModule->id << std::endl; ++zsModule; std::cout << "new module id +1 " << zsModule->id << std::endl; --zsModule; } else { std::cout << "inserting only the digis for not restored APVs" << std::endl; std::cout << "size : " << zsModule->size() << std::endl; edm::DetSet<SiStripDigi>::iterator itZsModule = zsModule->begin(); for(; itZsModule != zsModule->end(); ++itZsModule){ uint16_t adc = itZsModule->adc(); uint16_t strip = itZsModule->strip(); if(!restoredAPV[strip/128]){ MergedRawDigis[strip] = adc; ++count; std::cout << "original count: "<< count << " strip: " << strip << " adc: " << adc << std::endl; } } } std::cout << "size of digis to keep: " << count << std::endl; std::cout << "inserting only the digis for the restored APVs" << std::endl; std::cout << "size : " << suppressedDigis.size() << std::endl; edm::DetSet<SiStripDigi>::iterator itSuppDigi = suppressedDigis.begin(); for(; itSuppDigi != suppressedDigis.end(); ++itSuppDigi){ uint16_t adc = itSuppDigi->adc(); uint16_t strip = itSuppDigi->strip(); if(restoredAPV[strip/128]){ MergedRawDigis[strip] = adc; std::cout << "new suppressed strip: " << strip << " adc: " << adc << std::endl; } } std::cout << "suppressing the raw digis" << std::endl; zsModule->clear(); for(uint16_t strip=0; strip < MergedRawDigis.size(); ++strip){ uint16_t adc = MergedRawDigis[strip]; if(adc) zsModule->push_back(SiStripDigi(strip, adc)); } std::cout << "size zsModule after the merging: " << zsModule->size() << std::endl; if((count + suppressedDigis.size()) != zsModule->size()) std::cout << "WE HAVE A PROBLEM!!!! THE NUMBER OF DIGIS IS NOT RIGHT==============" << std::endl; std::cout << "exiting suppressing the raw digis" << std::endl; }//if new ZS digis size } //if module restored }//loop over raw data collection uint32_t oldid =0; for(edm::DetSetVector<SiStripDigi>::const_iterator dg = outputdigi.begin(); dg != outputdigi.end(); ++dg){ uint32_t iddg = dg->id; if(iddg < oldid){ std::cout<< "NOT IN THE RIGHT ORGER" << std:: endl; std::cout<< "======================="<< std:: endl; } oldid = iddg; } std::cout << "write the output vector" << std::endl; std::auto_ptr< edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>(outputdigi) ); e.put( output, "ZeroSuppressed" ); }//if inputraw.size }
void SiStripZeroSuppression::processRaw | ( | const edm::InputTag & | inputTag, |
const edm::DetSetVector< SiStripRawDigi > & | input | ||
) | [inline, private] |
Definition at line 103 of file SiStripZeroSuppression.cc.
References algorithms, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), Exception, formatRawDigis(), edm::InputTag::instance(), output_apvcm, output_base, output_base_raw, output_baseline, output_baseline_points, produceBaselinePoints, produceCalculatedBaseline, produceRawDigis, edm::DetSet< T >::size(), storeCM, storeExtraOutput(), and storeInZScollBadAPV.
Referenced by CollectionMergedZeroSuppression(), and StandardZeroSuppression().
{ output_apvcm.clear(); output_baseline.clear(); output_baseline_points.clear(); output_base.clear(); output_base_raw.clear(); if(storeCM) output_apvcm.reserve(16000); if(produceCalculatedBaseline) output_baseline.reserve(16000); if(produceBaselinePoints) output_baseline_points.reserve(16000); if(produceRawDigis) output_base_raw.reserve(16000); output_base.reserve(16000); for ( edm::DetSetVector<SiStripRawDigi>::const_iterator rawDigis = input.begin(); rawDigis != input.end(); ++rawDigis) { edm::DetSet<SiStripDigi> suppressedDigis(rawDigis->id); int16_t nAPVflagged = 0; if ( "ProcessedRaw" == inputTag.instance()) nAPVflagged = algorithms->SuppressProcessedRawData(*rawDigis, suppressedDigis); else if ( "VirginRaw" == inputTag.instance()) nAPVflagged = algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis); else throw cms::Exception("Unknown input type") << inputTag.instance() << " unknown. SiStripZeroZuppression can only process types \"VirginRaw\" and \"ProcessedRaw\" "; //here storing the output this->storeExtraOutput(rawDigis->id, nAPVflagged); if (suppressedDigis.size() && (storeInZScollBadAPV || nAPVflagged ==0)) output_base.push_back(suppressedDigis); if (produceRawDigis && nAPVflagged > 0){ edm::DetSet<SiStripRawDigi> outRawDigis(rawDigis->id); this->formatRawDigis(rawDigis, outRawDigis); output_base_raw.push_back(outRawDigis); } } }
void SiStripZeroSuppression::produce | ( | edm::Event & | e, |
const edm::EventSetup & | es | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 51 of file SiStripZeroSuppression.cc.
References algorithms, mergeCollections, MergeCollectionsZeroSuppression(), and StandardZeroSuppression().
{ algorithms->initialize(es, e); if(mergeCollections){ this->MergeCollectionsZeroSuppression(e); }else{ this->StandardZeroSuppression(e); } }
void SiStripZeroSuppression::StandardZeroSuppression | ( | edm::Event & | e | ) | [inline, private] |
Definition at line 62 of file SiStripZeroSuppression.cc.
References edm::Event::getByLabel(), LaserDQM_cfg::input, inputTags, convertSQLitetoXML_cfg::output, output_apvcm, output_base, output_base_raw, output_baseline, output_baseline_points, processRaw(), produceBaselinePoints, produceCalculatedBaseline, produceRawDigis, edm::Event::put(), and storeCM.
Referenced by produce().
{ for(tag_iterator_t inputTag = inputTags.begin(); inputTag != inputTags.end(); ++inputTag ) { edm::Handle< edm::DetSetVector<SiStripRawDigi> > input; e.getByLabel(*inputTag,input); if (input->size()) processRaw(*inputTag, *input); std::auto_ptr< edm::DetSetVector<SiStripDigi> > output(new edm::DetSetVector<SiStripDigi>(output_base) ); e.put( output, inputTag->instance() ); if(produceRawDigis){ std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > outputraw(new edm::DetSetVector<SiStripRawDigi>(output_base_raw) ); e.put(outputraw, inputTag->instance() ); } if(produceCalculatedBaseline){ std::auto_ptr< edm::DetSetVector<SiStripProcessedRawDigi> > outputbaseline(new edm::DetSetVector<SiStripProcessedRawDigi>(output_baseline) ); e.put(outputbaseline, "BADAPVBASELINE"+inputTag->instance() ); } if(produceBaselinePoints){ std::auto_ptr< edm::DetSetVector<SiStripDigi> > outputbaselinepoints(new edm::DetSetVector<SiStripDigi>(output_baseline_points) ); e.put(outputbaselinepoints, "BADAPVBASELINEPOINTS"+inputTag->instance() ); } if(storeCM){ std::auto_ptr< edm::DetSetVector<SiStripProcessedRawDigi> > outputAPVCM(new edm::DetSetVector<SiStripProcessedRawDigi>(output_apvcm) ); e.put( outputAPVCM,"APVCM"+inputTag->instance()); } } }
void SiStripZeroSuppression::storeBaseline | ( | uint32_t | id, |
const std::vector< std::pair< short, float > > & | vmedians | ||
) | [inline, private] |
Definition at line 176 of file SiStripZeroSuppression.cc.
References algorithms, i, output_baseline, edm::DetSet< T >::push_back(), edm::DetSet< T >::size(), and strip().
Referenced by storeExtraOutput().
{ std::map< uint16_t, std::vector < int16_t> >& baselinemap = algorithms->GetBaselineMap(); edm::DetSet<SiStripProcessedRawDigi> baselineDetSet(id); std::map< uint16_t, std::vector < int16_t> >::iterator itBaselineMap; for(size_t i=0;i<vmedians.size();++i){ uint16_t APVn = vmedians[i].first; float median = vmedians[i].second; itBaselineMap = baselinemap.find(APVn); if(itBaselineMap==baselinemap.end()){ for(size_t strip=0; strip < 128; ++strip) baselineDetSet.push_back(SiStripProcessedRawDigi(median)); } else { for(size_t strip=0; strip < 128; ++strip) baselineDetSet.push_back(SiStripProcessedRawDigi((itBaselineMap->second)[strip])); } } if(baselineDetSet.size()) output_baseline.push_back(baselineDetSet); }
void SiStripZeroSuppression::storeBaselinePoints | ( | uint32_t | id | ) | [inline, private] |
Definition at line 201 of file SiStripZeroSuppression.cc.
References algorithms, output_baseline_points, edm::DetSet< T >::push_back(), and edm::DetSet< T >::size().
Referenced by storeExtraOutput().
{ std::map< uint16_t, std::map< uint16_t, int16_t> >& BasPointVec = algorithms->GetSmoothedPoints(); std::map< uint16_t, std::map< uint16_t, int16_t> >::iterator itBasPointVect = BasPointVec.begin() ; std::map< uint16_t, int16_t>::iterator itBaselinePointMap; edm::DetSet<SiStripDigi> baspointDetSet(id); for(; itBasPointVect != BasPointVec.end(); ++itBasPointVect){ uint16_t APVn= itBasPointVect->first; itBaselinePointMap =itBasPointVect->second.begin(); for(;itBaselinePointMap != itBasPointVect->second.end(); ++itBaselinePointMap){ uint16_t bpstrip = (itBaselinePointMap->first) + APVn*128; int16_t bp = itBaselinePointMap->second; baspointDetSet.push_back(SiStripDigi(bpstrip,bp+128)); } } if(baspointDetSet.size()) output_baseline_points.push_back(baspointDetSet); }
void SiStripZeroSuppression::storeCMN | ( | uint32_t | id, |
const std::vector< std::pair< short, float > > & | vmedians | ||
) | [inline, private] |
Definition at line 227 of file SiStripZeroSuppression.cc.
References algorithms, first, fixCM, i, output_apvcm, edm::DetSet< T >::push_back(), edm::second(), and edm::DetSet< T >::size().
Referenced by storeExtraOutput().
{ edm::DetSet<SiStripProcessedRawDigi> apvDetSet(id); short apvNb=0; std::vector<bool> apvf; apvf.clear(); apvf.insert(apvf.begin(), 6, false); if(fixCM){ std::vector<bool>& apvFlagged = algorithms->GetAPVFlags(); for(uint16_t it=0; it< apvFlagged.size(); ++it) apvf[it] = apvFlagged[it]; } for(size_t i=0;i<vmedians.size();++i){ if(vmedians[i].first>apvNb){ for(int i=0;i<vmedians[i].first-apvNb;++i){ apvDetSet.push_back(SiStripProcessedRawDigi(-999.)); apvNb++; } } if(fixCM&&apvf[vmedians[i].first]){ apvDetSet.push_back(SiStripProcessedRawDigi(-999.)); }else{ apvDetSet.push_back(SiStripProcessedRawDigi(vmedians[i].second)); } apvNb++; } if(apvDetSet.size()) output_apvcm.push_back(apvDetSet); }
void SiStripZeroSuppression::storeExtraOutput | ( | uint32_t | id, |
int16_t | nAPVflagged | ||
) | [inline, private] |
Definition at line 164 of file SiStripZeroSuppression.cc.
References algorithms, produceBaselinePoints, produceCalculatedBaseline, storeBaseline(), storeBaselinePoints(), storeCM, and storeCMN().
Referenced by processRaw().
{ const std::vector< std::pair<short,float> >& vmedians = algorithms->getAPVsCM(); if(storeCM) this->storeCMN(id, vmedians); if(nAPVflagged > 0){ if(produceCalculatedBaseline) this->storeBaseline(id, vmedians); if(produceBaselinePoints) this->storeBaselinePoints(id); } }
std::auto_ptr<SiStripRawProcessingAlgorithms> SiStripZeroSuppression::algorithms [private] |
Definition at line 46 of file SiStripZeroSuppression.h.
Referenced by formatRawDigis(), MergeCollectionsZeroSuppression(), processRaw(), produce(), storeBaseline(), storeBaselinePoints(), storeCMN(), and storeExtraOutput().
Definition at line 38 of file SiStripZeroSuppression.h.
Referenced by MergeCollectionsZeroSuppression(), and SiStripZeroSuppression().
Definition at line 37 of file SiStripZeroSuppression.h.
Referenced by MergeCollectionsZeroSuppression(), and SiStripZeroSuppression().
bool SiStripZeroSuppression::fixCM [private] |
Definition at line 54 of file SiStripZeroSuppression.h.
Referenced by SiStripZeroSuppression(), and storeCMN().
std::vector<edm::InputTag> SiStripZeroSuppression::inputTags [private] |
Definition at line 36 of file SiStripZeroSuppression.h.
Referenced by CollectionMergedZeroSuppression(), SiStripZeroSuppression(), and StandardZeroSuppression().
bool SiStripZeroSuppression::mergeCollections [private] |
Definition at line 53 of file SiStripZeroSuppression.h.
Referenced by produce(), and SiStripZeroSuppression().
std::vector< edm::DetSet<SiStripProcessedRawDigi> > SiStripZeroSuppression::output_apvcm [private] |
Definition at line 43 of file SiStripZeroSuppression.h.
Referenced by processRaw(), StandardZeroSuppression(), and storeCMN().
std::vector<edm::DetSet<SiStripDigi> > SiStripZeroSuppression::output_base [private] |
Definition at line 41 of file SiStripZeroSuppression.h.
Referenced by CollectionMergedZeroSuppression(), processRaw(), and StandardZeroSuppression().
std::vector<edm::DetSet<SiStripRawDigi> > SiStripZeroSuppression::output_base_raw [private] |
Definition at line 42 of file SiStripZeroSuppression.h.
Referenced by processRaw(), and StandardZeroSuppression().
std::vector< edm::DetSet<SiStripProcessedRawDigi> > SiStripZeroSuppression::output_baseline [private] |
Definition at line 44 of file SiStripZeroSuppression.h.
Referenced by processRaw(), StandardZeroSuppression(), and storeBaseline().
std::vector< edm::DetSet<SiStripDigi> > SiStripZeroSuppression::output_baseline_points [private] |
Definition at line 45 of file SiStripZeroSuppression.h.
Referenced by processRaw(), StandardZeroSuppression(), and storeBaselinePoints().
bool SiStripZeroSuppression::produceBaselinePoints [private] |
Definition at line 51 of file SiStripZeroSuppression.h.
Referenced by processRaw(), SiStripZeroSuppression(), StandardZeroSuppression(), and storeExtraOutput().
bool SiStripZeroSuppression::produceCalculatedBaseline [private] |
Definition at line 50 of file SiStripZeroSuppression.h.
Referenced by processRaw(), SiStripZeroSuppression(), StandardZeroSuppression(), and storeExtraOutput().
bool SiStripZeroSuppression::produceRawDigis [private] |
Definition at line 49 of file SiStripZeroSuppression.h.
Referenced by processRaw(), SiStripZeroSuppression(), and StandardZeroSuppression().
bool SiStripZeroSuppression::storeCM [private] |
Definition at line 48 of file SiStripZeroSuppression.h.
Referenced by processRaw(), SiStripZeroSuppression(), StandardZeroSuppression(), and storeExtraOutput().
bool SiStripZeroSuppression::storeInZScollBadAPV [private] |
Definition at line 52 of file SiStripZeroSuppression.h.
Referenced by processRaw(), and SiStripZeroSuppression().