00001 #include "../interface/TrigPrimTask.h"
00002
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Common/interface/TriggerResultsByName.h"
00006
00007 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00008 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00009
00010 namespace ecaldqm {
00011
00012 TrigPrimTask::TrigPrimTask(const edm::ParameterSet &_params, const edm::ParameterSet& _paths) :
00013 DQWorkerTask(_params, _paths, "TrigPrimTask"),
00014 ttMap_(0),
00015 realTps_(0),
00016 runOnEmul_(true),
00017 expectedTiming_(0),
00018 HLTCaloPath_(""),
00019 HLTMuonPath_(""),
00020 HLTCaloBit_(false),
00021 HLTMuonBit_(false),
00022 bxBin_(0.),
00023 towerReadouts_()
00024 {
00025 collectionMask_ =
00026 (0x1 << kRun) |
00027 (0x1 << kEBDigi) |
00028 (0x1 << kEEDigi) |
00029 (0x1 << kTrigPrimDigi) |
00030 (0x1 << kTrigPrimEmulDigi);
00031
00032 dependencies_.push_back(std::pair<Collections, Collections>(kTrigPrimEmulDigi, kEBDigi));
00033 dependencies_.push_back(std::pair<Collections, Collections>(kTrigPrimEmulDigi, kEEDigi));
00034 dependencies_.push_back(std::pair<Collections, Collections>(kTrigPrimEmulDigi, kTrigPrimDigi));
00035
00036 edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
00037
00038 runOnEmul_ = taskParams.getUntrackedParameter<bool>("runOnEmul");
00039 expectedTiming_ = taskParams.getUntrackedParameter<int>("expectedTiming");
00040 HLTCaloPath_ = taskParams.getUntrackedParameter<std::string>("HLTCaloPath");
00041 HLTMuonPath_ = taskParams.getUntrackedParameter<std::string>("HLTMuonPath");
00042
00043
00044 int binEdges[nBXBins + 1] = {1, 271, 541, 892, 1162, 1432, 1783, 2053, 2323, 2674, 2944, 3214, 3446, 3490, 3491, 3565};
00045 for(int i(0); i < nBXBins + 1; i++) bxBinEdges_[i] = binEdges[i];
00046
00047 if(!runOnEmul_) collectionMask_ &= ~(0x1 << kTrigPrimEmulDigi);
00048 }
00049
00050 TrigPrimTask::~TrigPrimTask()
00051 {
00052 }
00053
00054 void
00055 TrigPrimTask::bookMEs()
00056 {
00057 std::stringstream ss;
00058
00059 if(runOnEmul_){
00060 DQWorker::bookMEs();
00061 MEs_[kEmulMaxIndex]->setBinLabel(-1, 1, "no emul", 1);
00062 for(int i(2); i <= 6; i++){
00063 ss.str("");
00064 ss << (i - 1);
00065 MEs_[kEmulMaxIndex]->setBinLabel(-1, i, ss.str(), 1);
00066 }
00067 }
00068 else{
00069 unsigned bookList[] = {kEtReal, kEtRealMap, kEtSummary, kEtVsBx, kOccVsBx,
00070 kLowIntMap, kMedIntMap, kHighIntMap, kTTFlags, kTTFMismatch};
00071 for(unsigned iME(0); iME < sizeof(bookList) / sizeof(unsigned); iME++)
00072 MEs_[bookList[iME]]->book();
00073 }
00074
00075 int iBin(1);
00076 for(int i(1); i < nBXBins + 1; i++){
00077 ss.str("");
00078 if(bxBinEdges_[i] - bxBinEdges_[i - 1] == 1) ss << bxBinEdges_[i - 1];
00079 else ss << bxBinEdges_[i - 1] << " - " << (bxBinEdges_[i] - 1);
00080 MEs_[kEtVsBx]->setBinLabel(-1, iBin, ss.str(), 1);
00081 MEs_[kOccVsBx]->setBinLabel(-1, iBin, ss.str(), 1);
00082 iBin++;
00083 }
00084 }
00085
00086 void
00087 TrigPrimTask::beginRun(const edm::Run &, const edm::EventSetup &_es)
00088 {
00089 edm::ESHandle<EcalTrigTowerConstituentsMap> ttMapHndl;
00090 _es.get<IdealGeometryRecord>().get(ttMapHndl);
00091 ttMap_ = ttMapHndl.product();
00092 }
00093
00094 void
00095 TrigPrimTask::beginEvent(const edm::Event &_evt, const edm::EventSetup &)
00096 {
00097 using namespace std;
00098
00099 towerReadouts_.clear();
00100
00101 realTps_ = 0;
00102
00103 HLTCaloBit_ = false;
00104 HLTMuonBit_ = false;
00105
00106 int* pBin(std::upper_bound(bxBinEdges_, bxBinEdges_ + nBXBins + 1, _evt.bunchCrossing()));
00107 bxBin_ = static_cast<int>(pBin - bxBinEdges_) - 0.5;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 }
00166
00167 void
00168 TrigPrimTask::runOnDigis(const EcalDigiCollection &_digis)
00169 {
00170 for(EcalDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
00171 EcalTrigTowerDetId ttid(ttMap_->towerOf(digiItr->id()));
00172 towerReadouts_[ttid.rawId()]++;
00173 }
00174 }
00175
00176 void
00177 TrigPrimTask::runOnRealTPs(const EcalTrigPrimDigiCollection &_tps)
00178 {
00179 realTps_ = &_tps;
00180
00181 float nTP(0.);
00182
00183 for(EcalTrigPrimDigiCollection::const_iterator tpItr(_tps.begin()); tpItr != _tps.end(); ++tpItr){
00184 EcalTrigTowerDetId ttid(tpItr->id());
00185 float et(tpItr->compressedEt());
00186
00187 if(et > 0.){
00188 nTP += 1.;
00189 MEs_[kEtVsBx]->fill(ttid, bxBin_, et);
00190 }
00191
00192 MEs_[kEtReal]->fill(ttid, et);
00193 MEs_[kEtRealMap]->fill(ttid, et);
00194 MEs_[kEtSummary]->fill(ttid, et);
00195
00196 int interest(tpItr->ttFlag() & 0x3);
00197
00198 switch(interest){
00199 case 0:
00200 MEs_[kLowIntMap]->fill(ttid);
00201 break;
00202 case 1:
00203 MEs_[kMedIntMap]->fill(ttid);
00204 break;
00205 case 3:
00206 MEs_[kHighIntMap]->fill(ttid);
00207 break;
00208 default:
00209 break;
00210 }
00211
00212 MEs_[kTTFlags]->fill(ttid, float(tpItr->ttFlag()));
00213
00214 if((interest == 1 || interest == 3) && towerReadouts_[ttid.rawId()] != ttMap_->constituentsOf(ttid).size())
00215 MEs_[kTTFMismatch]->fill(ttid);
00216 }
00217
00218 MEs_[kOccVsBx]->fill(bxBin_, nTP);
00219 }
00220
00221 void
00222 TrigPrimTask::runOnEmulTPs(const EcalTrigPrimDigiCollection &_tps)
00223 {
00224 for(EcalTrigPrimDigiCollection::const_iterator tpItr(_tps.begin()); tpItr != _tps.end(); ++tpItr){
00225 EcalTrigTowerDetId ttid(tpItr->id());
00226 int et(tpItr->compressedEt());
00227
00228
00229
00230
00231
00232 float maxEt(0);
00233 int iMax(0);
00234 for(int iDigi(0); iDigi < 5; iDigi++){
00235 float sampleEt((*tpItr)[iDigi].compressedEt());
00236
00237 if(sampleEt > maxEt){
00238 maxEt = sampleEt;
00239 iMax = iDigi + 1;
00240 }
00241 }
00242
00243 MEs_[kEtMaxEmul]->fill(ttid, maxEt);
00244 MEs_[kEmulMaxIndex]->fill(ttid, iMax + 0.5);
00245
00246 bool match(true);
00247 bool matchFG(true);
00248
00249 EcalTrigPrimDigiCollection::const_iterator realItr(realTps_->find(ttid));
00250 if(realItr != realTps_->end()){
00251
00252 int realEt(realItr->compressedEt());
00253
00254 if(realEt <= 0) continue;
00255
00256 int interest(realItr->ttFlag() & 0x3);
00257 if((interest == 1 || interest == 3) && towerReadouts_[ttid.rawId()] == ttMap_->constituentsOf(ttid).size()){
00258
00259 if(et != realEt) match = false;
00260 if(tpItr->fineGrain() != realItr->fineGrain()) matchFG = false;
00261
00262 std::vector<int> matchedIndex(0);
00263 for(int iDigi(0); iDigi < 5; iDigi++){
00264 if((*tpItr)[iDigi].compressedEt() == realEt)
00265 matchedIndex.push_back(iDigi + 1);
00266 }
00267
00268 if(!matchedIndex.size()) matchedIndex.push_back(0);
00269 for(std::vector<int>::iterator matchItr(matchedIndex.begin()); matchItr != matchedIndex.end(); ++matchItr){
00270 MEs_[kMatchedIndex]->fill(ttid, *matchItr + 0.5);
00271
00272
00273
00274
00275
00276 if(*matchItr != expectedTiming_) MEs_[kTimingError]->fill(ttid);
00277 }
00278
00279 }
00280 }
00281 else{
00282 match = false;
00283 matchFG = false;
00284 }
00285
00286 if(!match) MEs_[kEtEmulError]->fill(ttid);
00287 if(!matchFG) MEs_[kFGEmulError]->fill(ttid);
00288 }
00289 }
00290
00291
00292 void
00293 TrigPrimTask::setMEData(std::vector<MEData>& _data)
00294 {
00295 BinService::AxisSpecs indexAxis;
00296 indexAxis.nbins = 6;
00297 indexAxis.low = 0.;
00298 indexAxis.high = 6.;
00299 indexAxis.title = "TP index";
00300
00301 BinService::AxisSpecs etAxis;
00302 etAxis.nbins = 128;
00303 etAxis.low = 0.;
00304 etAxis.high = 256.;
00305 etAxis.title = "TP Et";
00306
00307 BinService::AxisSpecs bxAxis;
00308 bxAxis.nbins = 15;
00309 bxAxis.low = 0.;
00310 bxAxis.high = bxAxis.nbins;
00311
00312 BinService::AxisSpecs flagAxis;
00313 flagAxis.nbins = 8;
00314 flagAxis.low = 0.;
00315 flagAxis.high = 8.;
00316 flagAxis.title = "TT flag";
00317
00318 _data[kEtReal] = MEData("EtReal", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &etAxis);
00319 _data[kEtMaxEmul] = MEData("EtMaxEmul", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &etAxis);
00320 _data[kEtRealMap] = MEData("EtRealMap", BinService::kSM, BinService::kTriggerTower, MonitorElement::DQM_KIND_TPROFILE2D, 0, 0, &etAxis);
00321
00322 _data[kEtSummary] = MEData("EtRealMap", BinService::kEcal2P, BinService::kTriggerTower, MonitorElement::DQM_KIND_TPROFILE2D, 0, 0, &etAxis);
00323 _data[kMatchedIndex] = MEData("MatchedIndex", BinService::kSM, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH2F, 0, &indexAxis);
00324 _data[kEmulMaxIndex] = MEData("EmulMaxIndex", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &indexAxis);
00325 _data[kTimingError] = MEData("TimingError", BinService::kChannel, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH1F);
00326 _data[kEtVsBx] = MEData("EtVsBx", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TPROFILE, &bxAxis);
00327 _data[kOccVsBx] = MEData("OccVsBx", BinService::kEcal, BinService::kUser, MonitorElement::DQM_KIND_TPROFILE, &bxAxis);
00328 _data[kLowIntMap] = MEData("LowIntMap", BinService::kEcal3P, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH2F);
00329 _data[kMedIntMap] = MEData("MedIntMap", BinService::kEcal3P, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH2F);
00330 _data[kHighIntMap] = MEData("HighIntMap", BinService::kEcal3P, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH2F);
00331 _data[kTTFlags] = MEData("TTFlags", BinService::kEcal2P, BinService::kDCC, MonitorElement::DQM_KIND_TH2F, 0, &flagAxis);
00332 _data[kTTFMismatch] = MEData("TTFMismatch", BinService::kEcal2P, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH2F);
00333
00334
00335 _data[kEtEmulError] = MEData("EtEmulError", BinService::kChannel, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH1F);
00336 _data[kFGEmulError] = MEData("FGEmulError", BinService::kChannel, BinService::kTriggerTower, MonitorElement::DQM_KIND_TH1F);
00337 }
00338
00339 DEFINE_ECALDQM_WORKER(TrigPrimTask);
00340 }
00341
00342