CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/HLTrigger/HLTanalyzers/src/HLTGetDigi.cc

Go to the documentation of this file.
00001 
00012 #include "HLTrigger/HLTanalyzers/interface/HLTGetDigi.h"
00013 
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 
00018 // system include files
00019 #include <memory>
00020 #include <vector>
00021 #include <map>
00022 
00023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00024 #include "DataFormats/Common/interface/DetSetVector.h"
00025 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
00026 #include "FWCore/Utilities/interface/InputTag.h"
00027 
00028 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00029 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00030 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00031 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00032 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
00033 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00034 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00035 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
00036 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00037 #include "DataFormats/MuonData/interface/MuonDigiCollection.h"
00038 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00039 #include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
00040 #include "DataFormats/CSCDigi/interface/CSCStripDigi.h"
00041 #include "DataFormats/CSCDigi/interface/CSCStripDigiCollection.h"
00042 #include "DataFormats/DTDigi/interface/DTDigi.h"
00043 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
00044 #include "DataFormats/RPCDigi/interface/RPCDigi.h"
00045 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
00046 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
00047 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
00048 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
00049 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00050 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00051 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00052 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
00053 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00054 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00055 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00056 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
00057 #include "CondFormats/L1TObjects/interface/L1GtParameters.h"
00058 #include "CondFormats/DataRecord/interface/L1GtParametersRcd.h"
00059 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00060 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
00061 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00062 
00063 using namespace edm;
00064 using namespace std;
00065 
00066 //
00067 // constructors and destructor
00068 //
00069 HLTGetDigi::HLTGetDigi(const edm::ParameterSet& ps)
00070 {
00071   EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
00072   EEdigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
00073   ESdigiCollection_ = ps.getParameter<edm::InputTag>("ESdigiCollection");
00074   HBHEdigiCollection_ = ps.getParameter<edm::InputTag>("HBHEdigiCollection");
00075   HOdigiCollection_   = ps.getParameter<edm::InputTag>("HOdigiCollection");
00076   HFdigiCollection_   = ps.getParameter<edm::InputTag>("HFdigiCollection");
00077   PXLdigiCollection_ = ps.getParameter<edm::InputTag>("SiPixeldigiCollection");
00078   SSTdigiCollection_ = ps.getParameter<edm::InputTag>("SiStripdigiCollection");
00079   CSCStripdigiCollection_ = ps.getParameter<edm::InputTag>("CSCStripdigiCollection");
00080   CSCWiredigiCollection_ = ps.getParameter<edm::InputTag>("CSCWiredigiCollection");
00081   DTdigiCollection_ = ps.getParameter<edm::InputTag>("DTdigiCollection");
00082   RPCdigiCollection_ = ps.getParameter<edm::InputTag>("RPCdigiCollection");
00083 
00084   GctCaloEmLabel_ = ps.getParameter<edm::InputTag>("L1CaloEmCollection");
00085   GctCaloRegionLabel_ = ps.getParameter<edm::InputTag>("L1CaloRegionCollection");
00086 
00087   GctIsoEmLabel_ = ps.getParameter<edm::InputTag>("GctIsoEmCollection");
00088   GctNonIsoEmLabel_ = ps.getParameter<edm::InputTag>("GctNonIsoEmCollection");
00089 
00090   GctCenJetLabel_ = ps.getParameter<edm::InputTag>("GctCenJetCollection");
00091   GctForJetLabel_ = ps.getParameter<edm::InputTag>("GctForJetCollection");
00092   GctTauJetLabel_ = ps.getParameter<edm::InputTag>("GctTauJetCollection");
00093   GctJetCountsLabel_ = ps.getParameter<edm::InputTag>("GctJetCounts");
00094 
00095   GctEtHadLabel_ = ps.getParameter<edm::InputTag>("GctEtHadCollection");
00096   GctEtMissLabel_ = ps.getParameter<edm::InputTag>("GctEtMissCollection");
00097   GctEtTotalLabel_ = ps.getParameter<edm::InputTag>("GctEtTotalCollection");
00098 
00099   GtEvmRRLabel_ = ps.getParameter<edm::InputTag>("GtEvmReadoutRecord");
00100   GtObjectMapLabel_ = ps.getParameter<edm::InputTag>("GtObjectMapRecord");
00101   GtRRLabel_ = ps.getParameter<edm::InputTag>("GtReadoutRecord");
00102 
00103   GmtCandsLabel_ = ps.getParameter<edm::InputTag>("GmtCands");
00104   GmtReadoutCollection_ = ps.getParameter<edm::InputTag>("GmtReadoutCollection");
00105   
00106   //--- Define which digis we want ---//
00107   getEcalDigis_    = ps.getUntrackedParameter<bool>("getEcal",true) ; 
00108   getEcalESDigis_  = ps.getUntrackedParameter<bool>("getEcalES",true) ; 
00109   getHcalDigis_    = ps.getUntrackedParameter<bool>("getHcal",true) ; 
00110   getPixelDigis_   = ps.getUntrackedParameter<bool>("getPixels",true) ; 
00111   getStripDigis_   = ps.getUntrackedParameter<bool>("getStrips",true) ; 
00112   getCSCDigis_     = ps.getUntrackedParameter<bool>("getCSC",true) ; 
00113   getDTDigis_      = ps.getUntrackedParameter<bool>("getDT",true) ; 
00114   getRPCDigis_     = ps.getUntrackedParameter<bool>("getRPC",true) ; 
00115   getGctEmDigis_   = ps.getUntrackedParameter<bool>("getGctEm",true) ; 
00116   getGctJetDigis_  = ps.getUntrackedParameter<bool>("getGctJet",true) ; 
00117   getGctJetCounts_ = ps.getUntrackedParameter<bool>("getGctJetCounts",true) ; 
00118   getGctEtDigis_   = ps.getUntrackedParameter<bool>("getGctEt",true) ;
00119   getL1Calo_       = ps.getUntrackedParameter<bool>("getL1Calo",true) ;
00120   getGtEvmRR_      = ps.getUntrackedParameter<bool>("getGtEvmRR",true) ;
00121   getGtObjectMap_  = ps.getUntrackedParameter<bool>("getGtObjectMap",true) ;
00122   getGtRR_         = ps.getUntrackedParameter<bool>("getGtReadoutRecord",true) ;
00123   getGmtCands_     = ps.getUntrackedParameter<bool>("getGmtCands",true) ;
00124   getGmtRC_        = ps.getUntrackedParameter<bool>("getGmtReadout",true) ;
00125   
00126 }
00127 
00128 HLTGetDigi::~HLTGetDigi()
00129 { }
00130 
00131 //
00132 // member functions
00133 //
00134 
00135 // ------------ method called to produce the data  ------------
00136 void
00137 HLTGetDigi::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00138 {
00139     using namespace edm;
00140 
00141     //--- L1 GCT and GT Digis ---//
00142     edm::Handle<L1GctEtHad> GctEtHad ; 
00143     edm::Handle<L1GctEtMiss> GctEtMiss ; 
00144     edm::Handle<L1GctEtTotal> GctEtTotal ; 
00145 
00146     const L1GctEtHad*   etHad   = 0 ; 
00147     const L1GctEtMiss*  etMiss  = 0 ; 
00148     const L1GctEtTotal* etTotal = 0 ;
00149 
00150     if (getGctEtDigis_) {
00151         iEvent.getByLabel(GctEtHadLabel_,GctEtHad) ; 
00152         iEvent.getByLabel(GctEtMissLabel_,GctEtMiss) ; 
00153         iEvent.getByLabel(GctEtTotalLabel_,GctEtTotal) ; 
00154         etHad = GctEtHad.product() ; 
00155         etMiss = GctEtMiss.product() ; 
00156         etTotal = GctEtTotal.product() ; 
00157 
00158         LogDebug("DigiInfo") << "Value of L1GctEtHad::et(): " << etHad->et() ; 
00159         LogDebug("DigiInfo") << "Value of L1GctEtMiss::et(): " << etMiss->et() << ", phi(): " << etMiss->phi() ; 
00160         LogDebug("DigiInfo") << "Value of L1GctEtTotal::et(): " << etTotal->et() ; 
00161     }
00162 
00163     edm::Handle<L1GctEmCandCollection> GctIsoEM ; 
00164     edm::Handle<L1GctEmCandCollection> GctNonIsoEM ; 
00165 
00166     const L1GctEmCandCollection* isoEMdigis = 0 ; 
00167     const L1GctEmCandCollection* nonIsoEMdigis = 0 ; 
00168     if (getGctEmDigis_) {
00169         iEvent.getByLabel(GctIsoEmLabel_,GctIsoEM) ;
00170         isoEMdigis = GctIsoEM.product() ; 
00171         iEvent.getByLabel(GctNonIsoEmLabel_,GctNonIsoEM) ; 
00172         nonIsoEMdigis = GctNonIsoEM.product() ; 
00173         LogDebug("DigiInfo") << "total # Gct Iso EM digis: " << isoEMdigis->size() ; 
00174         LogDebug("DigiInfo") << "total # Gct non-Iso EM digis: " << nonIsoEMdigis->size() ;
00175     }
00176     
00177     edm::Handle<L1GctJetCandCollection> GctCenJets ; 
00178     edm::Handle<L1GctJetCandCollection> GctForJets ; 
00179     edm::Handle<L1GctJetCandCollection> GctTauJets ; 
00180     edm::Handle<L1GctJetCounts> GctJetCounts ; 
00181 
00182     const L1GctJetCandCollection* cenJetDigis = 0 ; 
00183     const L1GctJetCandCollection* forJetDigis = 0 ; 
00184     const L1GctJetCandCollection* tauJetDigis = 0 ;
00185     std::auto_ptr<L1GctJetCounts> newCounts( new L1GctJetCounts() ) ;
00186     L1GctJetCounts* counts = newCounts.get() ; 
00187         
00188     if (getGctJetDigis_) {
00189         iEvent.getByLabel(GctCenJetLabel_,GctCenJets) ;
00190         cenJetDigis = GctCenJets.product() ; 
00191         iEvent.getByLabel(GctForJetLabel_,GctForJets) ;
00192         forJetDigis = GctForJets.product() ; 
00193         iEvent.getByLabel(GctTauJetLabel_,GctTauJets) ;
00194         tauJetDigis = GctTauJets.product() ; 
00195         LogDebug("DigiInfo") << "total # Gct central Jet digis: " << cenJetDigis->size() ; 
00196         LogDebug("DigiInfo") << "total # Gct forward Jet digis: " << forJetDigis->size() ;
00197         LogDebug("DigiInfo") << "total # Gct tau Jet digis: " << tauJetDigis->size() ;
00198     }
00199 
00200     if (getGctJetCounts_) {
00201         iEvent.getByLabel(GctJetCountsLabel_,GctJetCounts) ; 
00202         *counts = *GctJetCounts.product() ;
00203     }
00204 
00205     edm::Handle<L1CaloEmCollection> GctCaloEm ; 
00206     edm::Handle<L1CaloRegionCollection> GctCaloRegion ; 
00207     
00208     const L1CaloEmCollection* caloEm = 0 ; 
00209     const L1CaloRegionCollection* caloRegion = 0 ; 
00210 
00211     if (getL1Calo_) {
00212         iEvent.getByLabel(GctCaloEmLabel_,GctCaloEm) ; 
00213         iEvent.getByLabel(GctCaloRegionLabel_,GctCaloRegion) ; 
00214 
00215         caloEm = GctCaloEm.product() ; 
00216         caloRegion = GctCaloRegion.product() ; 
00217 
00218         LogDebug("DigiInfo") << "Calo EM size: " << caloEm->size() ; 
00219         LogDebug("DigiInfo") << "Calo region size: " << caloRegion->size() ; 
00220     }
00221 
00222     edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmRR ;
00223     edm::Handle<L1GlobalTriggerObjectMapRecord> gtMap ;
00224     edm::Handle<L1GlobalTriggerReadoutRecord> gtRR ;
00225 
00226     edm::ESHandle< L1GtParameters > l1GtPar ;
00227     iSetup.get< L1GtParametersRcd >().get( l1GtPar ) ;
00228     int nBx = l1GtPar->gtTotalBxInEvent() ; 
00229     
00230     std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> newGtEvm( new L1GlobalTriggerEvmReadoutRecord(nBx) ) ; 
00231     std::auto_ptr<L1GlobalTriggerObjectMapRecord> newGtMap( new L1GlobalTriggerObjectMapRecord() ) ; 
00232     std::auto_ptr<L1GlobalTriggerReadoutRecord> newGtRR( new L1GlobalTriggerReadoutRecord(nBx) ) ; 
00233     L1GlobalTriggerEvmReadoutRecord* evm = newGtEvm.get() ; 
00234     L1GlobalTriggerObjectMapRecord* map = newGtMap.get() ; 
00235     L1GlobalTriggerReadoutRecord* rr = newGtRR.get() ; 
00236 
00237     if (getGtEvmRR_) {
00238         iEvent.getByLabel(GtEvmRRLabel_, gtEvmRR) ;
00239         *evm = *gtEvmRR.product() ;
00240     }
00241     if (getGtObjectMap_) {
00242         iEvent.getByLabel(GtObjectMapLabel_, gtMap) ;
00243         *map = *gtMap.product() ;
00244     }
00245     if (getGtRR_) {
00246         iEvent.getByLabel(GtRRLabel_, gtRR) ;
00247         *rr = *gtRR.product() ;
00248     }
00249     
00250     edm::Handle< std::vector<L1MuGMTCand> > GmtCands ;
00251     edm::Handle<L1MuGMTReadoutCollection> GmtMuCollection ; 
00252     std::auto_ptr<std::vector<L1MuGMTCand> > cands( new std::vector<L1MuGMTCand> ) ;
00253     std::auto_ptr<L1MuGMTReadoutCollection> muCollection(new L1MuGMTReadoutCollection(nBx)) ;
00254  
00255     if (getGmtCands_) {
00256         iEvent.getByLabel(GmtCandsLabel_,GmtCands) ; 
00257         *cands = *GmtCands.product() ; 
00258     }
00259     if (getGmtRC_) {
00260         iEvent.getByLabel(GmtReadoutCollection_,GmtMuCollection) ;
00261         *muCollection = *GmtMuCollection.product() ;
00262         std::vector<L1MuGMTExtendedCand> muons = muCollection->getRecord().getGMTCands() ;
00263         LogDebug("DigiInfo") << "GMT muons present: " << muons.size() ;
00264     }
00265     
00266     edm::Handle< DetSetVector<PixelDigi> >  input;
00267     auto_ptr<DetSetVector<PixelDigi> > NewPixelDigi(new DetSetVector<PixelDigi> );
00268     DetSetVector<PixelDigi>* tt = NewPixelDigi.get();
00269     if (getPixelDigis_) {
00270         iEvent.getByLabel(PXLdigiCollection_, input);
00271         *tt = *input.product();
00272     }
00273 
00274     edm::Handle< edm::DetSetVector<SiStripDigi> >  input2;
00275     auto_ptr<DetSetVector<SiStripDigi> > NewSiDigi(new DetSetVector<SiStripDigi> );
00276     DetSetVector<SiStripDigi>* uu = NewSiDigi.get();
00277     if (getStripDigis_) {
00278         iEvent.getByLabel(SSTdigiCollection_, input2);
00279         *uu = *input2.product();
00280     }
00281 
00282     Handle<EBDigiCollection> EcalDigiEB;
00283     Handle<EEDigiCollection> EcalDigiEE;
00284     Handle<ESDigiCollection> EcalDigiES;
00285     const EBDigiCollection* EBdigis = 0;
00286     const EEDigiCollection* EEdigis = 0;
00287     const ESDigiCollection* ESdigis = 0; 
00288 
00289     if (getEcalDigis_) {
00290         iEvent.getByLabel( EBdigiCollection_, EcalDigiEB );
00291         EBdigis = EcalDigiEB.product();
00292         LogDebug("DigiInfo") << "total # EBdigis: " << EBdigis->size() ;
00293      
00294         iEvent.getByLabel( EEdigiCollection_, EcalDigiEE );
00295         EEdigis = EcalDigiEE.product();
00296         LogDebug("DigiInfo") << "total # EEdigis: " << EEdigis->size() ;
00297     }
00298 
00299     if (getEcalESDigis_) {
00300         iEvent.getByLabel( ESdigiCollection_, EcalDigiES );
00301         ESdigis = EcalDigiES.product();
00302         LogDebug("DigiInfo") << "total # ESdigis: " << ESdigis->size() ;
00303     }
00304         
00305     Handle<HBHEDigiCollection> HcalDigiHBHE ; 
00306     Handle<HODigiCollection> HcalDigiHO ; 
00307     Handle<HFDigiCollection> HcalDigiHF ; 
00308     const HBHEDigiCollection* HBHEdigis = 0 ;
00309     const HODigiCollection* HOdigis = 0 ;
00310     const HFDigiCollection* HFdigis = 0 ; 
00311 
00312     if (getHcalDigis_) {
00313         iEvent.getByLabel( HBHEdigiCollection_, HcalDigiHBHE );
00314         HBHEdigis = HcalDigiHBHE.product();
00315         LogDebug("DigiInfo") << "total # HBHEdigis: " << HBHEdigis->size() ;
00316      
00317         iEvent.getByLabel( HOdigiCollection_, HcalDigiHO );
00318         HOdigis = HcalDigiHO.product();
00319         LogDebug("DigiInfo") << "total # HOdigis: " << HOdigis->size() ;
00320     
00321         iEvent.getByLabel( HFdigiCollection_, HcalDigiHF );
00322         HFdigis = HcalDigiHF.product();
00323         LogDebug("DigiInfo") << "total # HFdigis: " << HFdigis->size() ;
00324     }
00325     
00326     Handle<CSCStripDigiCollection> CSCDigiStrip ; 
00327     Handle<CSCWireDigiCollection> CSCDigiWire ; 
00328 
00329     if (getCSCDigis_) {
00330         iEvent.getByLabel( CSCStripdigiCollection_, CSCDigiStrip );
00331         iEvent.getByLabel( CSCWiredigiCollection_,  CSCDigiWire );
00332 
00333         int numDigis = 0 ; 
00334         for (CSCStripDigiCollection::DigiRangeIterator iter=CSCDigiStrip->begin();
00335              iter!=CSCDigiStrip->end(); iter++) {
00336             for ( vector<CSCStripDigi>::const_iterator digiIter = (*iter).second.first;
00337                   digiIter != (*iter).second.second; digiIter++) numDigis++ ;
00338         }
00339         LogDebug("DigiInfo") << "total # CSCstripdigis: " << numDigis ;
00340         numDigis = 0 ; 
00341         for (CSCWireDigiCollection::DigiRangeIterator iter=CSCDigiWire->begin();
00342              iter!=CSCDigiWire->end(); iter++) {
00343             for ( vector<CSCWireDigi>::const_iterator digiIter = (*iter).second.first;
00344                   digiIter != (*iter).second.second; digiIter++) numDigis++ ;
00345         }
00346         LogDebug("DigiInfo") << "total # CSCwiredigis: " << numDigis ;
00347     }
00348     
00349     Handle<DTDigiCollection> DTDigiHandle ; 
00350 
00351     if (getDTDigis_) {
00352         iEvent.getByLabel( DTdigiCollection_, DTDigiHandle );
00353     
00354         int numDigis = 0 ; 
00355         for (DTDigiCollection::DigiRangeIterator iter=DTDigiHandle->begin();
00356              iter!=DTDigiHandle->end(); iter++) {
00357             for ( vector<DTDigi>::const_iterator digiIter = (*iter).second.first;
00358                   digiIter != (*iter).second.second; digiIter++) numDigis++ ;
00359         }
00360         LogDebug("DigiInfo") << "total # DTdigis: " << numDigis ;
00361     }
00362         
00363     Handle<RPCDigiCollection> RPCDigiHandle ; 
00364 
00365     if (getRPCDigis_) { 
00366         iEvent.getByLabel( RPCdigiCollection_, RPCDigiHandle );
00367 
00368         int numDigis = 0 ; 
00369         for (RPCDigiCollection::DigiRangeIterator iter=RPCDigiHandle->begin();
00370              iter!=RPCDigiHandle->end(); iter++) {
00371             for ( vector<RPCDigi>::const_iterator digiIter = (*iter).second.first;
00372                   digiIter != (*iter).second.second; digiIter++) numDigis++ ;
00373         }
00374         LogDebug("DigiInfo") << "total # RPCdigis: " << numDigis ;
00375     }
00376     
00377     LogDebug("DigiInfo") << "***--------------- End of Event -----------------***" ;  
00378     
00379 }