CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DPGAnalysis/SiStripTools/src/DigiCollectionProfiler.cc

Go to the documentation of this file.
00001 //#include <vector>
00002 #include "FWCore/Framework/interface/Frameworkfwd.h"
00003 #include "TH2F.h"
00004 #include "TProfile.h"
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00007 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00008 #include "DataFormats/Common/interface/DetSetVector.h"
00009 #include "DataFormats/Common/interface/DetSet.h"
00010 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00011 
00012 #include "DPGAnalysis/SiStripTools/interface/DigiCollectionProfiler.h"
00013 
00014 DigiCollectionProfiler::DigiCollectionProfiler():
00015   m_nevent(0),
00016   m_tibprof(0),m_tobprof(0),m_tecpprof(0),m_tecmprof(0),
00017   m_tib2d(0),m_tob2d(0),m_tecp2d(0),m_tecm2d(0),m_maskedmod() { }
00018 
00019 DigiCollectionProfiler::DigiCollectionProfiler(TProfile* tibprof,
00020                                                TProfile* tobprof,
00021                                                TProfile* tecpprof,
00022                                                TProfile* tecmprof,
00023                                                TH2F* tib2d,
00024                                                TH2F* tob2d,
00025                                                TH2F* tecp2d,
00026                                                TH2F* tecm2d):
00027   m_nevent(0),
00028   m_tibprof(tibprof),m_tobprof(tobprof),m_tecpprof(tecpprof),m_tecmprof(tecmprof),
00029   m_tib2d(tib2d),m_tob2d(tob2d),m_tecp2d(tecp2d),m_tecm2d(tecm2d),m_maskedmod() { }
00030 
00031 void DigiCollectionProfiler::analyze(edm::Handle<edm::DetSetVector<SiStripDigi> > digis) {
00032 
00033   m_nevent++;
00034 
00035   for(edm::DetSetVector<SiStripDigi>::const_iterator mod = digis->begin();mod!=digis->end();mod++) {
00036 
00037     const SiStripDetId detid(mod->detId());
00038 
00039     if(!ismasked(detid)) {
00040       TProfile* tobefilledprof=0;
00041       TH2F* tobefilled2d=0;
00042       if(detid.subDetector()==SiStripDetId::TIB || detid.subDetector()==SiStripDetId::TID) {
00043         tobefilledprof=m_tibprof;
00044         tobefilled2d=m_tib2d;
00045       }
00046       else if(detid.subDetector()==SiStripDetId::TOB) {
00047         tobefilledprof=m_tobprof;
00048         tobefilled2d=m_tob2d;
00049       }
00050       else if(detid.subDetector()==SiStripDetId::TEC) {
00051         const TECDetId tecid(detid);
00052         if(tecid.side()==1) {
00053           tobefilledprof=m_tecpprof;
00054           tobefilled2d=m_tecp2d;
00055         }
00056         else if(tecid.side()==2) {
00057           tobefilledprof=m_tecmprof;
00058           tobefilled2d=m_tecm2d;
00059         }
00060       }
00061       
00062       for(edm::DetSet<SiStripDigi>::const_iterator digi=mod->begin();digi!=mod->end();digi++) {
00063         
00064         if(digi->adc()>0) {
00065           if(tobefilledprof) tobefilledprof->Fill(digi->strip()%256,digi->adc());
00066           if(tobefilled2d) tobefilled2d->Fill(digi->strip()%256,digi->adc());
00067         }
00068       }
00069     }
00070   }
00071 }
00072 
00073 void DigiCollectionProfiler::setMaskedModules(std::vector<unsigned int> maskedmod) {
00074   
00075   m_maskedmod = maskedmod;
00076   sort(m_maskedmod.begin(),m_maskedmod.end());
00077   
00078 }
00079 
00080 
00081 int DigiCollectionProfiler::ismasked(const DetId& mod) const {
00082 
00083   int masked=0;
00084   for(std::vector<unsigned int>::const_iterator it=m_maskedmod.begin();it!=m_maskedmod.end()&&masked==0&&mod>=(*it);it++) {
00085     if(mod.rawId() == (*it)) masked = 1;
00086   }
00087   return masked;
00088 
00089 }