CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DQM/L1TMonitor/src/L1TRPCTPG.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TRPCTPG.cc
00003  *
00004  * $Date: 2009/11/19 14:40:21 $
00005  * $Revision: 1.12 $
00006  * \author J. Berryhill
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TRPCTPG.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013 
00014 
00015 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
00016 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00017 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
00018 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00019 using namespace std;
00020 using namespace edm;
00021 
00022 L1TRPCTPG::L1TRPCTPG(const ParameterSet& ps)
00023   : rpctpgSource_( ps.getParameter< InputTag >("rpctpgSource") ),
00024     rpctfSource_( ps.getParameter< InputTag >("rpctfSource") )
00025 {
00026 
00027   // verbosity switch
00028   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00029 
00030   if(verbose_) cout << "L1TRPCTPG: constructor...." << endl;
00031 
00032 
00033   dbe = NULL;
00034   if ( ps.getUntrackedParameter<bool>("DQMStore", false) ) 
00035   {
00036     dbe = Service<DQMStore>().operator->();
00037     dbe->setVerbose(0);
00038   }
00039 
00040   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00041   if ( outputFile_.size() != 0 ) {
00042     cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00043   }
00044 
00045   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00046   if(disable){
00047     outputFile_="";
00048   }
00049 
00050 
00051   if ( dbe !=NULL ) {
00052     dbe->setCurrentFolder("L1T/L1TRPCTPG");
00053   }
00054 
00055 
00056 }
00057 
00058 L1TRPCTPG::~L1TRPCTPG()
00059 {
00060 }
00061 
00062 void L1TRPCTPG::beginJob(void)
00063 {
00064 
00065   nev_ = 0;
00066 
00067   // get hold of back-end interface
00068   DQMStore* dbe = 0;
00069   dbe = Service<DQMStore>().operator->();
00070 
00071   if ( dbe ) {
00072     dbe->setCurrentFolder("L1T/L1TRPCTPG");
00073     dbe->rmdir("L1T/L1TRPCTPG");
00074   }
00075 
00076 
00077   if ( dbe ) 
00078   {
00079     dbe->setCurrentFolder("L1T/L1TRPCTPG");
00080     rpctpgbx = dbe->book1D("RPCTPG_bx", 
00081        "RPC digis bx - all events", 9, -4.5, 4.5 ) ;
00082     
00083     rpctpgndigi[1] = dbe->book1D("RPCTPG_ndigi", 
00084        "RPCTPG nDigi bx 0", 100, -0.5, 99.5 ) ;
00085     rpctpgndigi[2] = dbe->book1D("RPCTPG_ndigi_+1", 
00086        "RPCTPG nDigi bx +1", 100, -0.5, 99.5 ) ;
00087     rpctpgndigi[0] = dbe->book1D("RPCTPG_ndigi_-1", 
00088        "RPCTPG nDigi bx -1", 100, -0.5, 99.5 ) ;
00089 
00090 
00091 
00092     m_digiBxRPCBar = dbe->book1D("RPCDigiRPCBmu_noDTmu_bx",
00093        "RPC digis bx - RPC, !DT", 9, -4.5, 4.5 ) ;
00094 
00095     m_digiBxRPCEnd = dbe->book1D("RPCDigiRPCEmu_noCSCmu_bx",
00096          "RPC digis bx - RPC, !CSC", 9, -4.5, 4.5 ) ;
00097 
00098     m_digiBxDT = dbe->book1D("RPCDigiDTmu_noRPCBmu_bx",
00099          "RPC digis bx - !RPC, DT", 9, -4.5, 4.5 ) ;
00100 
00101     m_digiBxCSC = dbe->book1D("RPCDigiCSCmu_noRPCEmu_bx",
00102          "RPC digis bx - !RPC, CSC", 9, -4.5, 4.5 ) ;
00103    }  
00104 }
00105 
00106 
00107 void L1TRPCTPG::endJob(void)
00108 {
00109   if(verbose_) cout << "L1TRPCTPG: end job...." << endl;
00110   LogInfo("EndJob") << "analyzed " << nev_ << " events"; 
00111 
00112  if ( outputFile_.size() != 0  && dbe ) dbe->save(outputFile_);
00113 
00114  return;
00115 }
00116 
00117 void L1TRPCTPG::analyze(const Event& e, const EventSetup& c)
00118 {
00119   nev_++; 
00120   if(verbose_) cout << "L1TRPCTPG: analyze...." << endl;
00121 
00122   
00124   edm::ESHandle<RPCGeometry> rpcGeo;
00125   c.get<MuonGeometryRecord>().get(rpcGeo);
00126   if (!rpcGeo.isValid()) {
00127     edm::LogInfo("DataNotFound") << "can't find RPCGeometry" << endl;
00128     return;
00129   }
00130 //   char layerLabel[328];
00131 //   char meId [328];
00132  
00133 
00135   edm::Handle<RPCDigiCollection> rpcdigis;
00136   e.getByLabel(rpctpgSource_,rpcdigis);
00137     
00138   if (!rpcdigis.isValid()) {
00139     edm::LogInfo("DataNotFound") << "can't find RPCDigiCollection with label "<< rpctpgSource_ << endl;
00140     return;
00141   }
00142 
00143   // Calculate the number of DT and CSC cands present
00144   edm::Handle<L1MuGMTReadoutCollection> pCollection;
00145   e.getByLabel(rpctfSource_,pCollection);
00146   
00147   if (!pCollection.isValid()) {
00148      edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label "
00149            << rpctfSource_.label() ;
00150      return;
00151   }
00152   
00153   L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
00154   vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
00155   vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
00156   
00157   static int nRPCTrackBarrel, nRPCTrackEndcap , nDTTrack, nCSCTrack;
00158   nRPCTrackBarrel = 0;
00159   nRPCTrackEndcap = 0;
00160   nDTTrack = 0;
00161   nCSCTrack = 0;
00162 
00163   for( RRItr = gmt_records.begin() ;
00164        RRItr != gmt_records.end() ;
00165        RRItr++ )
00166   {
00167      // DTs
00168      vector<L1MuRegionalCand> DTCands = RRItr->getDTBXCands();
00169      for( vector<L1MuRegionalCand>::const_iterator
00170           ECItr = DTCands.begin() ;
00171           ECItr != DTCands.end() ;
00172           ++ECItr )
00173      {
00174         if (!ECItr->empty()) { ++nDTTrack; }
00175      }
00176       // CSCs
00177      vector<L1MuRegionalCand> CSCCands = RRItr->getCSCCands();
00178      for( vector<L1MuRegionalCand>::const_iterator
00179           ECItr = CSCCands.begin() ;
00180           ECItr != CSCCands.end() ;
00181           ++ECItr )
00182      {
00183         if (!ECItr->empty()) { ++nCSCTrack; }
00184      }
00185 
00186      //RPC barrel
00187      vector<L1MuRegionalCand> RPCBCands = RRItr->getBrlRPCCands();
00188      for( vector<L1MuRegionalCand>::const_iterator
00189           ECItr = RPCBCands.begin() ;
00190           ECItr != RPCBCands.end() ;
00191           ++ECItr )
00192      {
00193         if (!ECItr->empty()) { ++nRPCTrackBarrel; }
00194      }
00195 
00196      //RPC endcap
00197      vector<L1MuRegionalCand> RPCECands = RRItr->getFwdRPCCands();
00198      for( vector<L1MuRegionalCand>::const_iterator
00199           ECItr = RPCECands.begin() ;
00200           ECItr != RPCECands.end() ;
00201           ++ECItr )
00202      {
00203         if (!ECItr->empty()) { ++nRPCTrackEndcap; }
00204      }
00205   }
00206 
00207 
00208   
00210   if (0){
00211   edm::Handle<RPCRecHitCollection> rpcHits;
00212   e.getByType(rpcHits);
00213      
00214   if (!rpcHits.isValid()) {
00215     edm::LogInfo("DataNotFound") << "can't find RPCRecHitCollection of any type" << endl;
00216     return;
00217   }  
00218   }
00219 
00220     int numberofDigi[3] = {0,0,0};
00221     
00222 
00223   RPCDigiCollection::DigiRangeIterator collectionItr;
00224   for(collectionItr=rpcdigis->begin(); collectionItr!=rpcdigis->end(); ++collectionItr){
00225 
00226     /*RPCDetId detId=(*collectionItr ).first; 
00227 
00228     
00229     uint32_t id=detId();
00230     char detUnitLabel[328];
00231     RPCGeomServ RPCname(detId);
00232     std::string nameRoll = RPCname.name();
00233     sprintf(detUnitLabel ,"%s",nameRoll.c_str());
00234     sprintf(layerLabel ,"%s",nameRoll.c_str());
00235     std::map<uint32_t, std::map<std::string,MonitorElement*> >::iterator meItr = rpctpgmeCollection.find(id);
00236     if (meItr == rpctpgmeCollection.end() || (rpctpgmeCollection.size()==0)) {
00237       rpctpgmeCollection[id]=L1TRPCBookME(detId);
00238     }
00239     std::map<std::string, MonitorElement*> meMap=rpctpgmeCollection[id];*/
00240     
00241 
00242 //      std::vector<int> strips;
00243 //      std::vector<int> bxs;
00244 //      strips.clear(); 
00245 //      bxs.clear();
00246      RPCDigiCollection::const_iterator digiItr; 
00247      for (digiItr = ((*collectionItr ).second).first;
00248           digiItr!=((*collectionItr).second).second; ++digiItr){
00249        
00250        // strips is a list of hit strips (regardless of bx) for this roll
00251 //        int strip= (*digiItr).strip();
00252 //        strips.push_back(strip);
00253        int bx=(*digiItr).bx();
00254        rpctpgbx->Fill(bx);
00255        //
00256 
00257        if ( nRPCTrackBarrel == 0 &&  nDTTrack != 0) {
00258           m_digiBxDT->Fill(bx);
00259        } else if ( nRPCTrackBarrel != 0 &&  nDTTrack == 0) {
00260           m_digiBxRPCBar->Fill(bx);
00261        }
00262 
00263        if ( nRPCTrackEndcap == 0 &&  nCSCTrack != 0) {
00264           m_digiBxCSC->Fill(bx);
00265        } else if ( nRPCTrackEndcap != 0 &&  nCSCTrack == 0) {
00266           m_digiBxRPCEnd->Fill(bx);
00267        }
00268 
00269 
00270 
00271 
00272        
00273        if (bx == -1) 
00274        {
00275         numberofDigi[0]++;
00276        }
00277        if (bx == 0) 
00278        { 
00279 //         sprintf(meId,"Occupancy_%s",detUnitLabel);
00280 //      meMap[meId]->Fill(strip);
00281         numberofDigi[1]++;
00282        }
00283        if (bx == 2) 
00284        {
00285         numberofDigi[2]++;
00286        }
00287        
00288 //        sprintf(meId,"BXN_%s",detUnitLabel);
00289 //        meMap[meId]->Fill(bx);
00290 //        sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
00291 //        meMap[meId]->Fill(strip,bx);
00292       
00293      }
00294   }
00295 
00296       rpctpgndigi[0]->Fill(numberofDigi[0]);
00297       rpctpgndigi[1]->Fill(numberofDigi[1]);
00298       rpctpgndigi[2]->Fill(numberofDigi[2]);
00299 
00300 }
00301