CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 /*
00002  * \file L1TRPCTPG.cc
00003  *
00004  * $Date: 2012/09/25 21:30:20 $
00005  * $Revision: 1.13 $
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     int numberofDigi[3] = {0,0,0};
00208     
00209 
00210   RPCDigiCollection::DigiRangeIterator collectionItr;
00211   for(collectionItr=rpcdigis->begin(); collectionItr!=rpcdigis->end(); ++collectionItr){
00212 
00213     /*RPCDetId detId=(*collectionItr ).first; 
00214 
00215     
00216     uint32_t id=detId();
00217     char detUnitLabel[328];
00218     RPCGeomServ RPCname(detId);
00219     std::string nameRoll = RPCname.name();
00220     sprintf(detUnitLabel ,"%s",nameRoll.c_str());
00221     sprintf(layerLabel ,"%s",nameRoll.c_str());
00222     std::map<uint32_t, std::map<std::string,MonitorElement*> >::iterator meItr = rpctpgmeCollection.find(id);
00223     if (meItr == rpctpgmeCollection.end() || (rpctpgmeCollection.size()==0)) {
00224       rpctpgmeCollection[id]=L1TRPCBookME(detId);
00225     }
00226     std::map<std::string, MonitorElement*> meMap=rpctpgmeCollection[id];*/
00227     
00228 
00229 //      std::vector<int> strips;
00230 //      std::vector<int> bxs;
00231 //      strips.clear(); 
00232 //      bxs.clear();
00233      RPCDigiCollection::const_iterator digiItr; 
00234      for (digiItr = ((*collectionItr ).second).first;
00235           digiItr!=((*collectionItr).second).second; ++digiItr){
00236        
00237        // strips is a list of hit strips (regardless of bx) for this roll
00238 //        int strip= (*digiItr).strip();
00239 //        strips.push_back(strip);
00240        int bx=(*digiItr).bx();
00241        rpctpgbx->Fill(bx);
00242        //
00243 
00244        if ( nRPCTrackBarrel == 0 &&  nDTTrack != 0) {
00245           m_digiBxDT->Fill(bx);
00246        } else if ( nRPCTrackBarrel != 0 &&  nDTTrack == 0) {
00247           m_digiBxRPCBar->Fill(bx);
00248        }
00249 
00250        if ( nRPCTrackEndcap == 0 &&  nCSCTrack != 0) {
00251           m_digiBxCSC->Fill(bx);
00252        } else if ( nRPCTrackEndcap != 0 &&  nCSCTrack == 0) {
00253           m_digiBxRPCEnd->Fill(bx);
00254        }
00255 
00256 
00257 
00258 
00259        
00260        if (bx == -1) 
00261        {
00262         numberofDigi[0]++;
00263        }
00264        if (bx == 0) 
00265        { 
00266 //         sprintf(meId,"Occupancy_%s",detUnitLabel);
00267 //      meMap[meId]->Fill(strip);
00268         numberofDigi[1]++;
00269        }
00270        if (bx == 2) 
00271        {
00272         numberofDigi[2]++;
00273        }
00274        
00275 //        sprintf(meId,"BXN_%s",detUnitLabel);
00276 //        meMap[meId]->Fill(bx);
00277 //        sprintf(meId,"BXN_vs_strip_%s",detUnitLabel);
00278 //        meMap[meId]->Fill(strip,bx);
00279       
00280      }
00281   }
00282 
00283       rpctpgndigi[0]->Fill(numberofDigi[0]);
00284       rpctpgndigi[1]->Fill(numberofDigi[1]);
00285       rpctpgndigi[2]->Fill(numberofDigi[2]);
00286 
00287 }
00288