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