CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/DQM/EcalBarrelMonitorTasks/src/EnergyTask.cc

Go to the documentation of this file.
00001 #include "../interface/EnergyTask.h"
00002 
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00005 #include "Geometry/Records/interface/CaloTopologyRecord.h"
00006 
00007 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
00008 
00009 namespace ecaldqm {
00010 
00011   EnergyTask::EnergyTask(const edm::ParameterSet &_params, const edm::ParameterSet& _paths) :
00012     DQWorkerTask(_params, _paths, "EnergyTask"),
00013     topology_(0),
00014     isPhysicsRun_(false),
00015     threshS9_(0.)
00016   {
00017     collectionMask_ = 
00018       (0x1 << kRun) |
00019       (0x1 << kEBRecHit) |
00020       (0x1 << kEERecHit);
00021 
00022     edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
00023 
00024     isPhysicsRun_ = taskParams.getUntrackedParameter<bool>("isPhysicsRun");
00025     threshS9_ = taskParams.getUntrackedParameter<double>("threshS9");
00026 
00027     std::map<std::string, std::string> replacements;
00028     if(!isPhysicsRun_) replacements["oot"] = " (outOfTime)";
00029     else replacements["oot"] = "";
00030 
00031     for(unsigned iME(0); iME < nMESets; iME++)
00032       MEs_[iME]->name(replacements);
00033   }
00034 
00035   EnergyTask::~EnergyTask()
00036   {
00037   }
00038 
00039   void
00040   EnergyTask::beginRun(const edm::Run &, const edm::EventSetup &_es)
00041   {
00042     edm::ESHandle<CaloTopology> topoHndl;
00043     _es.get<CaloTopologyRecord>().get(topoHndl);
00044     topology_ = topoHndl.product();
00045     if(!topology_)
00046       throw cms::Exception("EventSetup") << "CaloTopology missing" << std::endl;
00047   }
00048   
00049   bool
00050   EnergyTask::filterRunType(const std::vector<short>& _runType)
00051   {
00052     for(int iFED(0); iFED < 54; iFED++){
00053       if ( _runType[iFED] == EcalDCCHeaderBlock::COSMIC ||
00054            _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
00055            _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
00056            _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
00057            _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
00058            _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL ) return true;
00059     }
00060 
00061     return false;
00062   }
00063 
00064   void 
00065   EnergyTask::runOnRecHits(const EcalRecHitCollection &_hits)
00066   {
00067     uint32_t mask(~(0x1 << EcalRecHit::kGood));
00068 
00069     for(EcalRecHitCollection::const_iterator hitItr(_hits.begin()); hitItr != _hits.end(); ++hitItr){
00070 
00071       if(isPhysicsRun_ && hitItr->checkFlagMask(mask)) continue;
00072 
00073       float energy(isPhysicsRun_ ? hitItr->energy() : hitItr->outOfTimeEnergy());
00074 
00075       if ( energy < 0. ) energy = 0.0;
00076 
00077       DetId id(hitItr->id());
00078 
00079       MEs_[kHitMap]->fill(id, energy);
00080       MEs_[kHitMapAll]->fill(id, energy);
00081       MEs_[kHit]->fill(id, energy);
00082       MEs_[kHitAll]->fill(id, energy);
00083 
00084       // look for the seeds
00085       float e3x3(energy);
00086       bool isSeed = true;
00087 
00088       EcalRecHitCollection::const_iterator neighborItr;
00089       float neighborE;
00090       std::vector<DetId> window(topology_->getWindow(id, 3, 3));
00091       for(std::vector<DetId>::iterator idItr(window.begin()); idItr != window.end(); ++idItr){
00092         if((neighborItr = _hits.find(*idItr)) == _hits.end()) continue;
00093         if(isPhysicsRun_ && neighborItr->checkFlagMask(mask)) continue;
00094         neighborE = isPhysicsRun_ ? neighborItr->energy() : neighborItr->outOfTimeEnergy();
00095         if(neighborE > energy){
00096           isSeed = false;
00097           break;
00098         }
00099         e3x3 += neighborE;
00100       }
00101 
00102       if(!isSeed) continue;
00103 
00104       if ( e3x3 >= threshS9_ )
00105         MEs_[kMiniCluster]->fill(id, e3x3);
00106 
00107     }
00108   }
00109 
00110   /*static*/
00111   void
00112   EnergyTask::setMEData(std::vector<MEData>& _data)
00113   {
00114     BinService::AxisSpecs xaxis, zaxis;
00115 
00116     zaxis.low = 0.;
00117     zaxis.high = 10.;
00118     _data[kHitMap] = MEData("HitMap", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TPROFILE2D, 0, 0, &zaxis);
00119     _data[kHitMapAll] = MEData("HitMap", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D, 0, 0, &zaxis);
00120 
00121     xaxis.nbins = 50;
00122     xaxis.low = 0.;
00123     xaxis.high = 20.;
00124     _data[kHit] = MEData("Hit", BinService::kSM, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &xaxis);
00125     _data[kHitAll] = MEData("Hit", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &xaxis);
00126 
00127     _data[kMiniCluster] = MEData("MiniCluster", BinService::kSM, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &xaxis);
00128   }
00129 
00130   DEFINE_ECALDQM_WORKER(EnergyTask);
00131 }
00132 
00133