Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "FWCore/Utilities/interface/typelookup.h"
00012 #include "CalibFormats/SiStripObjects/interface/SiStripDelay.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
00015 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00016 #include <sstream>
00017
00018 void SiStripDelay::fillNewDelay(const SiStripBaseDelay& baseDelay, const int sumSign,
00019 const std::pair<std::string, std::string> & recordLabelPair)
00020 {
00021 baseDelayVector_.push_back(&baseDelay);
00022 sumSignVector_.push_back(sumSign);
00023 recordLabelPair_.push_back(recordLabelPair);
00024 }
00025
00026 float SiStripDelay::getDelay(const uint32_t detId) const
00027 {
00028 boost::unordered_map<uint32_t, double>::const_iterator it = delays_.find(detId);
00029 if( it != delays_.end() ) {
00030 return it->second;
00031 }
00032 return 0.;
00033 }
00034
00035 bool SiStripDelay::makeDelay()
00036 {
00037 if( baseDelayVector_.empty() ) {
00038 return false;
00039 }
00040 std::vector<const SiStripBaseDelay*>::const_iterator it = baseDelayVector_.begin();
00041
00042 if( baseDelayVector_.size() > 1 ) {
00043 for( ; it != baseDelayVector_.end()-1; ++it ) {
00044 if( (*it)->delaysSize() != (*(it+1))->delaysSize() ) {
00045 std::cout << "makeDelay: Error, size of base delays is different!!" << std::endl;
00046 return false;
00047 }
00048 }
00049 }
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 int sumSignIndex = 0;
00076 int sumSign = sumSignVector_[sumSignIndex];
00077 it = baseDelayVector_.begin();
00078 std::vector<uint32_t> detIds;
00079 (*it)->detIds(detIds);
00080 std::vector<uint32_t>::const_iterator detIdIt = detIds.begin();
00081 for( ; detIdIt != detIds.end(); ++detIdIt ) {
00082 delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
00083 }
00084 ++it;
00085 ++sumSignIndex;
00086
00087 for( ; it != baseDelayVector_.end(); ++it, ++sumSignIndex ) {
00088 std::vector<uint32_t> detIds;
00089 (*it)->detIds(detIds);
00090 detIdIt = detIds.begin();
00091 sumSign = sumSignVector_[sumSignIndex];
00092 for( ; detIdIt != detIds.end(); ++detIdIt ) {
00093
00094 boost::unordered_map<uint32_t, double>::iterator delayIt = delays_.find(*detIdIt);
00095 if( delayIt != delays_.end() ) {
00096 delays_[*detIdIt] += (*it)->delay(*detIdIt)*sumSign;
00097 }
00098 else {
00099 std::cout << "makeDelay: Warning, detId = " << *detIdIt << " not present, summing to 0..." << std::cout;
00100 std::cout << "This means that the two baseDelay tags have different detIds. PLEASE, CHECK THAT THIS IS EXPECTED." << std::cout;
00101 delays_[*detIdIt] = (*it)->delay(*detIdIt)*sumSign;
00102 }
00103 }
00104 }
00105
00106 return true;
00107 }
00108
00109 void SiStripDelay::clear()
00110 {
00111 baseDelayVector_.clear();
00112 sumSignVector_.clear();
00113 recordLabelPair_.clear();
00114 delays_.clear();
00115 }
00116
00117 void SiStripDelay::printDebug(std::stringstream & ss) const
00118 {
00119 boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
00120 for( ; it != delays_.end(); ++it ) {
00121 ss << "detId = " << it->first << " delay = " << it->second << std::endl;
00122 }
00123 }
00124
00125 void SiStripDelay::printSummary(std::stringstream& ss) const
00126 {
00127 SiStripDetSummary summaryDelays;
00128 boost::unordered_map<uint32_t, double>::const_iterator it = delays_.begin();
00129 for( ; it != delays_.end(); ++it ) {
00130 summaryDelays.add(it->first, it->second);
00131 }
00132 summaryDelays.print(ss);
00133 }