Skip to content

Commit

Permalink
Remove superfluous includes and substitute couts by LogTrace/LogWarnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CesarBernardes authored and mmusich committed Sep 6, 2018
1 parent b31c5db commit f96ca06
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,14 @@
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"

#include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
#include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"

#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripPedestalsSubtractor.h"
#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripCommonModeNoiseSubtractor.h"
#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripRawProcessingFactory.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CommonTools/Utils/interface/TFileDirectory.h"

#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"

//ROOT inclusion
#include "TROOT.h"
#include "TFile.h"
#include "TNtuple.h"
#include "TMath.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TH1I.h"
#include "TH2F.h"
#include "TProfile.h"
#include "TList.h"
#include "TString.h"
#include "TStyle.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "THStack.h"
#include <vector>

//
// class decleration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,14 @@
#include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
#include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"

#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripPedestalsSubtractor.h"
#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripCommonModeNoiseSubtractor.h"
#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripRawProcessingFactory.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CommonTools/Utils/interface/TFileDirectory.h"

#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"

//ROOT inclusion
#include "TROOT.h"
#include "TFile.h"
#include "TNtuple.h"
#include "TMath.h"
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TProfile.h"
#include "TList.h"
#include "TString.h"
#include "TStyle.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "THStack.h"


//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
Expand Down Expand Up @@ -35,17 +36,17 @@ SiStripMergeZeroSuppression::SiStripMergeZeroSuppression(const edm::ParameterSet

void SiStripMergeZeroSuppression::produce(edm::Event& event, const edm::EventSetup& /*eventSetup*/)
{
std::cout<< "starting Merging" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "Starting merging " << "\n";
edm::Handle<edm::DetSetVector<SiStripDigi>> inputdigi;
edm::Handle<edm::DetSetVector<SiStripRawDigi>> inputraw;
event.getByToken(m_rawDigisToMerge, inputdigi);
event.getByToken(m_zsDigisToMerge, inputraw);

std::cout << inputdigi->size() << " " << inputraw->size() << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << inputdigi->size() << " " << inputraw->size() << "\n";
if ( ! inputraw->empty() ) {
std::vector<edm::DetSet<SiStripDigi>> outputdigi(inputdigi->begin(), inputdigi->end());

std::cout << "looping over the raw data collection" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "Looping over the raw data collection " << "\n";
for ( const auto& rawDigis : *inputraw ) {
edm::DetSet<SiStripRawDigi>::const_iterator itRawDigis = rawDigis.begin();
uint16_t nAPV = rawDigis.size()/128;
Expand All @@ -62,12 +63,12 @@ void SiStripMergeZeroSuppression::produce(edm::Event& event, const edm::EventSet
}

if ( isModuleRestored ) {
std::cout << "apply the ZS to the raw data collection" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "Apply the ZS to the raw data collection " << "\n";
edm::DetSet<SiStripDigi> suppressedDigis(rawDetId);
m_algorithms->suppressVirginRawData(rawDigis, suppressedDigis);

if ( ! suppressedDigis.empty() ) {
std::cout << "looking for the detId with the new ZS in the collection of the zero suppressed data" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "Looking for the detId with the new ZS in the collection of the zero suppressed data" << "\n";
bool isModuleInZscollection = false;
uint32_t zsDetId{0};
auto zsModule = std::lower_bound(std::begin(outputdigi), std::end(outputdigi), rawDetId,
Expand All @@ -76,56 +77,56 @@ void SiStripMergeZeroSuppression::produce(edm::Event& event, const edm::EventSet
isModuleInZscollection = true;
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;
LogTrace("SiStripMergeZeroSuppression::produce") << "After the look " << rawDetId << " ==== " << zsDetId << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "Exiting looking for the detId with the new ZS in the collection of the zero suppressed data" << "\n";

//creating the map containing the digis (in rawdigi format) merged
std::vector<uint16_t> mergedRawDigis(size_t(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;
LogTrace("SiStripMergeZeroSuppression::produce") << "WE HAVE A PROBLEM, THE MODULE IS NTOT FOUND" << "\n";
zsModule = outputdigi.insert(zsModule, newDigiToIndert);
std::cout << "new module id -1 " << (zsModule-1)->id << std::endl;
std::cout << "new module id " << zsModule->id << std::endl;
std::cout << "new module id +1 " << (zsModule+1)->id << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "new module id -1 " << (zsModule-1)->id << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "new module id " << zsModule->id << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "new module id +1 " << (zsModule+1)->id << "\n";
} else {
std::cout << "inserting only the digis for not restored APVs" << std::endl;
std::cout << "size : " << zsModule->size() << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "inserting only the digis for not restored APVs" << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "size : " << zsModule->size() << "\n";
for ( const auto itZsMod : *zsModule ) {
const uint16_t adc = itZsMod.adc();
const uint16_t strip = itZsMod.strip();
if ( ! restoredAPV[strip/128] ) {
mergedRawDigis[strip] = adc;
++count;
std::cout << "original count: "<< count << " strip: " << strip << " adc: " << adc << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "original count: "<< count << " strip: " << strip << " adc: " << adc << "\n";
}
}
}

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;
LogTrace("SiStripMergeZeroSuppression::produce") << "size of digis to keep: " << count << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "inserting only the digis for the restored APVs" << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "size : " << suppressedDigis.size() << "\n";
for ( const auto itSuppDigi : suppressedDigis ) {
const uint16_t adc = itSuppDigi.adc();
const uint16_t strip = itSuppDigi.strip();
if ( restoredAPV[strip/128] ) {
mergedRawDigis[strip] = adc;
std::cout << "new suppressed strip: " << strip << " adc: " << adc << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "new suppressed strip: " << strip << " adc: " << adc << "\n";
}
}

std::cout << "suppressing the raw digis" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "suppressing the raw digis" << "\n";
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;
LogTrace("SiStripMergeZeroSuppression::produce") << "size zsModule after the merging: " << zsModule->size() << "\n";
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;
LogTrace("SiStripMergeZeroSuppression::produce") << "WE HAVE A PROBLEM!!!! THE NUMBER OF DIGIS IS NOT RIGHT==============" << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "exiting suppressing the raw digis" << "\n";
}//if new ZS digis size
} //if module restored
}//loop over raw data collection
Expand All @@ -134,13 +135,13 @@ void SiStripMergeZeroSuppression::produce(edm::Event& event, const edm::EventSet
for ( const auto& dg : outputdigi ) {
uint32_t iddg = dg.id;
if ( iddg < oldid ) {
std::cout << "NOT IN THE RIGHT ORGER" << std:: endl;
std::cout << "=======================" << std:: endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "NOT IN THE RIGHT ORGER" << "\n";
LogTrace("SiStripMergeZeroSuppression::produce") << "=======================" << "\n";
}
oldid = iddg;
}

std::cout << "write the output vector" << std::endl;
LogTrace("SiStripMergeZeroSuppression::produce") << "write the output vector" << "\n";
event.put(std::make_unique<edm::DetSetVector<SiStripDigi>>(outputdigi), "ZeroSuppressed" );
}
}
17 changes: 2 additions & 15 deletions RecoLocalTracker/SiStripZeroSuppression/src/SiStripAPVRestorer.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripAPVRestorer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -196,7 +197,6 @@ inline uint16_t SiStripAPVRestorer::baselineFollowerInspect(uint16_t firstAPV, c
std::copy_n(std::begin(digis)+128*(iAPV-firstAPV), 128, std::back_inserter(singleAPVdigi));

const float DeltaCM = median_[iAPV] - MeanAPVCM;
//std::cout << "Delta CM: " << DeltaCM << " CM: " << median_[APV] << " detId " << (uint32_t) detId_ << std::endl;
if ( ( DeltaCM < 0 ) && ( std::abs(DeltaCM) > deltaCMThreshold_ ) ) {
if ( ! flatRegionsFinder(singleAPVdigi, smoothedmap, iAPV) ) {
apvFlags_[iAPV]= restoreAlgo_; //specify any algo to make the restore
Expand Down Expand Up @@ -326,11 +326,9 @@ inline uint16_t SiStripAPVRestorer::hybridEmulationInspect(uint16_t firstAPV, co
MeanAPVCM = itCMMap->second[iAPV];

const float DeltaCM = median_[iAPV] - MeanAPVCM;
//std::cout << "Delta CM: " << DeltaCM << " CM: " << median_[APV] << " detId " << (uint32_t) detId_ << std::endl;
if ( ( DeltaCM < 0 ) && ( std::abs(DeltaCM) > deltaCMThreshold_ ) ) {
apvFlags_[iAPV] = "HybridEmulation";
++nAPVflagged;
//std::cout << "and it is APV: " << APV << "Delta CM: " << DeltaCM << " median " << median_[APV] << " Mean APV " << MeanAPVCM << " marked bad " << markedVRAPVs[APV] << std::endl; //to be removed
}
}
}
Expand Down Expand Up @@ -534,7 +532,6 @@ void inline SiStripAPVRestorer::cleaner_LocalMinimumAdder(const digivector_t& ad
const float adc = adcs[strip];
const auto noise = static_cast<float>(noiseHandle->getNoiseFast(strip+apvN*128,detNoiseRange));
if ( adc < (adc1 + m * itStrip - 2 * noise) ) {
//std::cout << "applying correction strip: " << strip + apvN*128 << " adc " << adc << " detId: " << detId_ << std::endl;
smoothedpoints.emplace_hint(itNext, strip, adc);
++it;
}
Expand Down Expand Up @@ -991,16 +988,6 @@ void SiStripAPVRestorer::createCMMapCMstored(const edm::DetSetVector<SiStripProc
//============================================================================
void SiStripAPVRestorer::derivativeFollowerRestore(uint16_t apvN, uint16_t firstAPV, digivector_t& digis)
{
//std::cout << "++++++++" << "SiStripAPVRestorer::DerivativeFollowe" << std::endl;
// int gradient_threshold_ =12;
// std::cout <<"DT: "<< gradient_threshold_ << std::endl;
// int last_gradient_ = 10;
// int width_cluster_ = 64;
// int size_window_ = 1;
// std::cout << "LG: " << last_gradient_ << std::endl;
// std::cout << "SW: " << size_window_ << std::endl;
// std::cout << "WC: " << width_cluster_ << std::endl;
// std::cout << "detId: " << detId_ << std::endl;

digivector_t singleAPVdigi;
singleAPVdigi.clear();
Expand Down Expand Up @@ -1212,7 +1199,7 @@ void SiStripAPVRestorer::derivativeFollowerRestore(uint16_t apvN, uint16_t first

if ((firstStrip <= strip) && (strip <= lastStrip) && (0 < (singleAPVdigi[strip]- firstADC - ((secondADC-firstADC)/(lastStrip-firstStrip))*(strip-firstStrip)-gradient_threshold_))){
digis[(apvN-firstAPV)*128+strip]= singleAPVdigi[strip]- firstADC - (((secondADC-firstADC)/(lastStrip-firstStrip))*(strip-firstStrip));
std::cout << "no baseline " << digis[(apvN-firstAPV)*128+strip] << std::endl;
edm::LogWarning("NoBaseline") << "No baseline " << digis[(apvN-firstAPV)*128+strip] << "\n";
} else {
digis[(apvN-firstAPV)*128+strip]=0;
}
Expand Down

0 comments on commit f96ca06

Please sign in to comment.