Go to the documentation of this file.00001 #include "../interface/PedestalTask.h"
00002
00003 #include <algorithm>
00004
00005 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
00006 #include "DataFormats/DetId/interface/DetId.h"
00007 #include "DataFormats/EcalDigi/interface/EcalDataFrame.h"
00008
00009 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00010
00011 namespace ecaldqm {
00012
00013 PedestalTask::PedestalTask(const edm::ParameterSet &_params, const edm::ParameterSet& _paths) :
00014 DQWorkerTask(_params, _paths, "PedestalTask"),
00015 MGPAGains_(),
00016 MGPAGainsPN_()
00017 {
00018 using namespace std;
00019
00020 collectionMask_ =
00021 (0x1 << kEBDigi) |
00022 (0x1 << kEEDigi) |
00023 (0x1 << kPnDiodeDigi);
00024
00025 edm::ParameterSet const& commonParams(_params.getUntrackedParameterSet("Common"));
00026 MGPAGains_ = commonParams.getUntrackedParameter<std::vector<int> >("MGPAGains");
00027 MGPAGainsPN_ = commonParams.getUntrackedParameter<std::vector<int> >("MGPAGainsPN");
00028
00029 for(std::vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr)
00030 if(*gainItr != 1 && *gainItr != 6 && *gainItr != 12) throw cms::Exception("InvalidConfiguration") << "MGPA gain" << std::endl;
00031
00032 for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr)
00033 if(*gainItr != 1 && *gainItr != 16) throw cms::Exception("InvalidConfiguration") << "PN diode gain" << std::endl;
00034
00035 map<string, string> replacements;
00036 stringstream ss;
00037
00038 for(vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr){
00039 ss.str("");
00040 ss << *gainItr;
00041 replacements["gain"] = ss.str();
00042
00043 unsigned offset(0);
00044 switch(*gainItr){
00045 case 1: offset = 0; break;
00046 case 6: offset = 1; break;
00047 case 12: offset = 2; break;
00048 default: break;
00049 }
00050
00051 MEs_[kOccupancy + offset]->name(replacements);
00052 MEs_[kPedestal + offset]->name(replacements);
00053 }
00054
00055 for(vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
00056 ss.str("");
00057 ss << *gainItr;
00058 replacements["pngain"] = ss.str();
00059
00060 unsigned offset(0);
00061 switch(*gainItr){
00062 case 1: offset = 0; break;
00063 case 16: offset = 1; break;
00064 default: break;
00065 }
00066
00067 MEs_[kPNOccupancy + offset]->name(replacements);
00068 MEs_[kPNPedestal + offset]->name(replacements);
00069 }
00070 }
00071
00072 PedestalTask::~PedestalTask()
00073 {
00074 }
00075
00076 void
00077 PedestalTask::bookMEs()
00078 {
00079 for(std::vector<int>::iterator gainItr(MGPAGains_.begin()); gainItr != MGPAGains_.end(); ++gainItr){
00080 unsigned offset(0);
00081 switch(*gainItr){
00082 case 1: offset = 0; break;
00083 case 6: offset = 1; break;
00084 case 12: offset = 2; break;
00085 default: break;
00086 }
00087
00088 MEs_[kOccupancy + offset]->book();
00089 MEs_[kPedestal + offset]->book();
00090 }
00091 for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
00092 unsigned offset(0);
00093 switch(*gainItr){
00094 case 1: offset = 0; break;
00095 case 16: offset = 1; break;
00096 default: break;
00097 }
00098
00099 MEs_[kPNOccupancy + offset]->book();
00100 MEs_[kPNPedestal + offset]->book();
00101 }
00102 }
00103
00104 bool
00105 PedestalTask::filterRunType(const std::vector<short>& _runType)
00106 {
00107 bool enable(false);
00108
00109 for(int iFED(0); iFED < 54; iFED++){
00110 if(_runType[iFED] == EcalDCCHeaderBlock::PEDESTAL_STD ||
00111 _runType[iFED] == EcalDCCHeaderBlock::PEDESTAL_GAP){
00112 enable = true;
00113 enable_[iFED] = true;
00114 }
00115 }
00116
00117 return enable;
00118 }
00119
00120 void
00121 PedestalTask::runOnDigis(const EcalDigiCollection &_digis)
00122 {
00123 for(EcalDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
00124 DetId id(digiItr->id());
00125
00126 int iDCC(dccId(id) - 1);
00127
00128 if(!enable_[iDCC]) continue;
00129
00130
00131 EcalDataFrame dataFrame(*digiItr);
00132
00133 unsigned offset(0);
00134 int gain(0);
00135 switch(dataFrame.sample(0).gainId()){
00136 case 1: offset = 2; gain = 12; break;
00137 case 2: offset = 1; gain = 6; break;
00138 case 3: offset = 0; gain = 1; break;
00139 default: continue;
00140 }
00141
00142 if(std::find(MGPAGains_.begin(), MGPAGains_.end(), gain) == MGPAGains_.end()) continue;
00143
00144 MEs_[kOccupancy + offset]->fill(id);
00145
00146 float mean(0.);
00147 for(int iSample(0); iSample < 10; iSample++)
00148 mean += dataFrame.sample(iSample).adc();
00149 mean /= 10.;
00150
00151 MEs_[kPedestal + offset]->fill(id, mean);
00152 }
00153 }
00154
00155 void
00156 PedestalTask::runOnPnDigis(const EcalPnDiodeDigiCollection &_digis)
00157 {
00158 for(EcalPnDiodeDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
00159 EcalPnDiodeDetId id(digiItr->id());
00160
00161 int iDCC(dccId(id) - 1);
00162
00163 if(!enable_[iDCC]) continue;
00164
00165 unsigned offset(0);
00166 int gain(0);
00167 switch(digiItr->sample(0).gainId()){
00168 case 0: offset = 0; gain = 1; break;
00169 case 1: offset = 1; gain = 16; break;
00170 default: continue;
00171 }
00172
00173 if(std::find(MGPAGainsPN_.begin(), MGPAGainsPN_.end(), gain) == MGPAGainsPN_.end()) continue;
00174
00175 MEs_[kPNOccupancy + offset]->fill(id);
00176
00177 float mean(0.);
00178 for(int iSample(0); iSample < 50; iSample++)
00179 mean += digiItr->sample(iSample).adc();
00180 mean /= 50.;
00181
00182 MEs_[kPNPedestal + offset]->fill(id, mean);
00183 }
00184 }
00185
00186
00187 void
00188 PedestalTask::setMEData(std::vector<MEData>& _data)
00189 {
00190 for(unsigned iGain(0); iGain < nGain; iGain++){
00191 _data[kOccupancy + iGain] = MEData("Occupancy", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
00192 _data[kPedestal + iGain] = MEData("Pedestal", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TPROFILE2D);
00193 }
00194 for(unsigned iPNGain(0); iPNGain < nPNGain; iPNGain++){
00195 _data[kPNOccupancy + iPNGain] = MEData("PNOccupancy", BinService::kEcalMEM2P, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F);
00196 _data[kPNPedestal + iPNGain] = MEData("PNPedestal", BinService::kSMMEM, BinService::kCrystal, MonitorElement::DQM_KIND_TPROFILE);
00197 }
00198 }
00199
00200 DEFINE_ECALDQM_WORKER(PedestalTask);
00201 }