15 : inputTags(conf.getParameter<std::vector<edm::InputTag> >(
"RawDigiProducersList")),
17 storeCM(conf.getParameter<bool>(
"storeCM")),
18 mergeCollections(conf.getParameter<bool>(
"mergeCollections"))
33 produces< edm::DetSetVector<SiStripDigi> > (
"ZeroSuppressed");
37 produces< edm::DetSetVector<SiStripDigi> > (inputTag->instance());
38 if(
produceRawDigis) produces< edm::DetSetVector<SiStripRawDigi> > (inputTag->instance());
39 if(produceCalculatedBaseline) produces< edm::DetSetVector<SiStripProcessedRawDigi> > (
"BADAPVBASELINE"+inputTag->instance());
40 if(produceBaselinePoints) produces< edm::DetSetVector<SiStripDigi> > (
"BADAPVBASELINEPOINTS"+inputTag->instance());
41 if(
storeCM) produces< edm::DetSetVector<SiStripProcessedRawDigi> > (
"APVCM"+inputTag->instance());
73 e.
put( output, inputTag->instance() );
77 e.
put(outputraw, inputTag->instance() );
82 e.
put(outputbaseline,
"BADAPVBASELINE"+inputTag->instance() );
87 e.
put(outputbaselinepoints,
"BADAPVBASELINEPOINTS"+inputTag->instance() );
92 e.
put( outputAPVCM,
"APVCM"+inputTag->instance());
119 rawDigis = input.
begin(); rawDigis != input.
end(); ++rawDigis) {
122 int16_t nAPVflagged = 0;
124 if (
"ProcessedRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressProcessedRawData(*rawDigis, suppressedDigis);
125 else if (
"VirginRaw" == inputTag.
instance()) nAPVflagged =
algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
128 << inputTag.
instance() <<
" unknown. SiStripZeroZuppression can only process types \"VirginRaw\" and \"ProcessedRaw\" ";
149 const std::vector<bool>& apvf =
algorithms->GetAPVFlags();
153 for (; itRawDigis != rawDigis->
end(); ++itRawDigis){
154 int16_t APVn = strip/128;
155 if(apvf[APVn]) outRawDigis.
push_back(*itRawDigis);
166 const std::vector< std::pair<short,float> >& vmedians =
algorithms->getAPVsCM();
178 std::map< uint16_t, std::vector < int16_t> >& baselinemap =
algorithms->GetBaselineMap();
181 std::map< uint16_t, std::vector < int16_t> >::iterator itBaselineMap;
183 for(
size_t i=0;
i<vmedians.size();++
i){
184 uint16_t APVn = vmedians[
i].first;
185 float median = vmedians[
i].second;
186 itBaselineMap = baselinemap.find(APVn);
187 if(itBaselineMap==baselinemap.end()){
195 if(baselineDetSet.
size())
203 std::map< uint16_t, std::map< uint16_t, int16_t> >& BasPointVec =
algorithms->GetSmoothedPoints();
204 std::map< uint16_t, std::map< uint16_t, int16_t> >::iterator itBasPointVect = BasPointVec.begin() ;
205 std::map< uint16_t, int16_t>::iterator itBaselinePointMap;
209 for(; itBasPointVect != BasPointVec.end(); ++itBasPointVect){
210 uint16_t APVn= itBasPointVect->first;
211 itBaselinePointMap =itBasPointVect->second.begin();
212 for(;itBaselinePointMap != itBasPointVect->second.end(); ++itBaselinePointMap){
213 uint16_t bpstrip = (itBaselinePointMap->first) + APVn*128;
214 int16_t bp = itBaselinePointMap->second;
221 if(baspointDetSet.
size())
232 std::vector<bool> apvf;
234 apvf.insert(apvf.begin(), 6,
false);
237 std::vector<bool>& apvFlagged =
algorithms->GetAPVFlags();
238 for(uint16_t it=0; it< apvFlagged.size(); ++it) apvf[it] = apvFlagged[it];
241 for(
size_t i=0;
i<vmedians.size();++
i){
242 if(vmedians[
i].
first>apvNb){
243 for(
int i=0;
i<vmedians[
i].first-apvNb;++
i){
265 std::cout<<
"starting Merging" << std::endl;
271 std::cout << inputdigi->size() <<
" " << inputraw->size() << std::endl;
273 if (inputraw->size()){
275 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
282 std::cout <<
"looping over the raw data collection" << std::endl;
286 uint16_t nAPV = rawDigis->size()/128;
287 uint32_t rawDetId = rawDigis->id;
289 std::vector<bool> restoredAPV;
291 restoredAPV.insert(restoredAPV.begin(), nAPV,
false);
294 bool isModuleRestored =
false;
297 restoredAPV[
strip/128] =
true;
298 isModuleRestored =
true;
303 if(isModuleRestored){
304 std::cout <<
"apply the ZS to the raw data collection" << std::endl;
306 std::vector<int16_t> processedRawDigis(rawDigis->size());
307 algorithms->SuppressVirginRawData(*rawDigis, suppressedDigis);
309 if(suppressedDigis.
size()){
310 std::cout <<
"looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
311 std::vector<edm::DetSet<SiStripDigi> >::iterator zsModule = outputdigi.begin();
314 uint32_t zsDetId = zsModule->id;
315 bool isModuleInZscollection =
false;
316 while((zsDetId <= rawDetId)&&(zsModule != outputdigi.end())&&(!isModuleInZscollection)){
318 if( zsDetId == rawDetId){
319 isModuleInZscollection =
true;
322 zsDetId = zsModule->id;
325 std::cout <<
"after the look " << rawDetId <<
" ==== " << zsDetId << std::endl;
326 std::cout <<
"exiting looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
329 std::vector<uint16_t> MergedRawDigis;
330 MergedRawDigis.clear();
331 MergedRawDigis.insert(MergedRawDigis.begin(), nAPV*128, 0);
336 if(!isModuleInZscollection){
337 std::cout <<
"WE HAVE A PROBLEM, THE MODULE IS NTOT FOUND" << std::endl;
338 outputdigi.insert(zsModule, newDigiToIndert);
340 std::cout <<
"new module id -1 " << zsModule->id << std::endl;
342 std::cout <<
"new module id " << zsModule->id << std::endl;
344 std::cout <<
"new module id +1 " << zsModule->id << std::endl;
348 std::cout <<
"inserting only the digis for not restored APVs" << std::endl;
349 std::cout <<
"size : " << zsModule->size() << std::endl;
351 for(; itZsModule != zsModule->
end(); ++itZsModule){
352 uint16_t
adc = itZsModule->adc();
353 uint16_t
strip = itZsModule->strip();
354 if(!restoredAPV[strip/128]){
357 std::cout <<
"original count: "<< count <<
" strip: " << strip <<
" adc: " << adc << std::endl;
363 std::cout <<
"size of digis to keep: " << count << std::endl;
364 std::cout <<
"inserting only the digis for the restored APVs" << std::endl;
365 std::cout <<
"size : " << suppressedDigis.
size() << std::endl;
367 for(; itSuppDigi != suppressedDigis.
end(); ++itSuppDigi){
368 uint16_t
adc = itSuppDigi->adc();
369 uint16_t
strip = itSuppDigi->strip();
370 if(restoredAPV[strip/128]){
372 std::cout <<
"new suppressed strip: " << strip <<
" adc: " << adc << std::endl;
378 std::cout <<
"suppressing the raw digis" << std::endl;
381 uint16_t
adc = MergedRawDigis[
strip];
384 std::cout <<
"size zsModule after the merging: " << zsModule->size() << std::endl;
385 if((count + suppressedDigis.
size()) != zsModule->size())
std::cout <<
"WE HAVE A PROBLEM!!!! THE NUMBER OF DIGIS IS NOT RIGHT==============" << std::endl;
386 std::cout <<
"exiting suppressing the raw digis" << std::endl;
393 uint32_t iddg = dg->id;
395 std::cout<<
"NOT IN THE RIGHT ORGER" << std:: endl;
396 std::cout<<
"======================="<< std:: endl;
402 std::cout <<
"write the output vector" << std::endl;
404 e.
put( output,
"ZeroSuppressed" );
422 std::vector<edm::DetSet<SiStripDigi> > outputdigi;
423 std::vector<edm::DetSet<SiStripRawDigi> > outputraw;
426 if (inputraw->size())
430 for ( std::vector<
edm::DetSet<SiStripDigi> >::const_iterator itinputdigi = inputdigi->begin(); itinputdigi !=inputdigi->end(); ++itinputdigi) {
435 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
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 &)
bool produceBaselinePoints
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 > > &)
edm::InputTag DigisToMergeVR
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
edm::InputTag DigisToMergeZS
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
SiStripZeroSuppression(const edm::ParameterSet &)
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