CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

APVShotsAnalyzer Class Reference

#include <DPGAnalysis/SiStripTools/plugins/APVShotsAnalyzer.cc>

Inheritance diagram for APVShotsAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

 APVShotsAnalyzer (const edm::ParameterSet &)
 ~APVShotsAnalyzer ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
virtual void endJob ()
virtual void endRun (const edm::Run &, const edm::EventSetup &)
void updateDetCabling (const edm::EventSetup &setup)

Private Attributes

uint32_t _cacheIdDet
 DB cache ID used to establish if the cabling has changed during the run.
const SiStripDetCabling_detCabling
 The cabling object.
edm::InputTag _digicollection
TH1F * _fed
TH1F * _median
TH2F * _medianVsFED
int _nevents
TH1F * _nShots
TH2F * _nShotsVsFED
TProfile * _nShotsVsTime
TH1F * _stripMult
TH1F * _subDetector
std::string _suffix
bool _useCabling
TH1F * _whichAPV
bool _zs
TkHistoMaptkhisto
TkHistoMaptkhisto2

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 66 of file APVShotsAnalyzer.cc.


Constructor & Destructor Documentation

APVShotsAnalyzer::APVShotsAnalyzer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 120 of file APVShotsAnalyzer.cc.

References _fed, _median, _medianVsFED, _nShots, _nShotsVsFED, _nShotsVsTime, _stripMult, _subDetector, _suffix, _useCabling, _whichAPV, _zs, tkhisto, and tkhisto2.

                                                                :
  _digicollection(iConfig.getParameter<edm::InputTag>("digiCollection")),
  _zs(iConfig.getUntrackedParameter<bool>("zeroSuppressed",true)),
  _suffix(iConfig.getParameter<std::string>("mapSuffix")),
  _nevents(0),
  _useCabling(iConfig.getUntrackedParameter<bool>("useCabling",true)),
  _cacheIdDet(0),
  _detCabling(0)
{
   //now do what ever initialization is needed

  if(!_zs) _suffix += "_notZS";

 edm::Service<TFileService> tfserv;

 _nShots = tfserv->make<TH1F>("nShots","Number of Shots per event",200,-0.5,199.5);
 _nShots->GetXaxis()->SetTitle("Shots");  _nShots->GetYaxis()->SetTitle("Events"); 
 _nShots->StatOverflows(kTRUE);

 _nShotsVsTime = tfserv->make<TProfile>("nShotsVsTime","Mean number of shots vs orbit number",3600,0.5,3600*11223+0.5);
 _nShotsVsTime->GetXaxis()->SetTitle("Orbit");  _nShotsVsTime->GetYaxis()->SetTitle("Number of Shots");
 _nShotsVsTime->SetBit(TH1::kCanRebin);

 _whichAPV = tfserv->make<TH1F>("whichAPV","APV with shots",6,-0.5,5.5);
 _whichAPV->GetXaxis()->SetTitle("APV");  _whichAPV->GetYaxis()->SetTitle("Shots"); 

 _stripMult = tfserv->make<TH1F>("stripMultiplicity","Shot Strip Multiplicity",129,-0.5,128.5);
 _stripMult->GetXaxis()->SetTitle("Number of Strips");  _stripMult->GetYaxis()->SetTitle("Shots");

 _median = tfserv->make<TH1F>("median","APV Shot charge median",256,-0.5,255.5);
 _median->GetXaxis()->SetTitle("Charge [ADC]");  _median->GetYaxis()->SetTitle("Shots");

 _subDetector = tfserv->make<TH1F>("subDets","SubDetector Shot distribution",10,-0.5,9.5);
 _subDetector->GetYaxis()->SetTitle("Shots");

 if (_useCabling) {
   _fed = tfserv->make<TH1F>("fed","FED Shot distribution",440,50,490);
   _fed->GetYaxis()->SetTitle("Shots");

   _nShotsVsFED = tfserv->make<TH2F>("nShotsVsFED","Number of Shots per event vs fedid",440,50,490,200,-0.5,199.5);
   _nShotsVsFED->GetXaxis()->SetTitle("fedId");  _nShots->GetYaxis()->SetTitle("Shots");  _nShots->GetZaxis()->SetTitle("Events");
   _nShotsVsFED->StatOverflows(kTRUE);

   _medianVsFED = tfserv->make<TH2F>("medianVsFED","APV Shot charge median vs fedid",440,50,490,256,-0.5,255.5);
   _medianVsFED->GetXaxis()->SetTitle("fedId");_medianVsFED->GetYaxis()->SetTitle("Charge [ADC]");  _median->GetZaxis()->SetTitle("Shots");
 }

 tkhisto      =new TkHistoMap("ShotMultiplicity","ShotMultiplicity",-1); 
 tkhisto2      =new TkHistoMap("StripMultiplicity","StripMultiplicity",-1); 
}
APVShotsAnalyzer::~APVShotsAnalyzer ( )

Definition at line 172 of file APVShotsAnalyzer.cc.

References _detCabling.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)
  if ( _detCabling ) _detCabling = 0;

}

Member Function Documentation

void APVShotsAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 188 of file APVShotsAnalyzer.cc.

References _detCabling, _digicollection, _fed, _median, _medianVsFED, _nevents, _nShots, _nShotsVsFED, _nShotsVsTime, _stripMult, _subDetector, _useCabling, _whichAPV, _zs, TkHistoMap::add(), gather_cfg::cout, sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, TkHistoMap::fill(), edm::Event::getByLabel(), SiStripDetCabling::getConnections(), APVShotFinder::getShots(), edm::EventBase::orbitNumber(), tkhisto, tkhisto2, and updateDetCabling().

{
   using namespace edm;

   if (_useCabling){
     //retrieve cabling
     updateDetCabling( iSetup );
   }

   _nevents++;

   Handle<edm::DetSetVector<SiStripDigi> > digis;
   iEvent.getByLabel(_digicollection,digis);

   // loop on detector with digis

   int nshots=0;
   std::vector<int> nshotsperFed;

   const uint16_t lNumFeds = sistrip::FED_ID_MAX-sistrip::FED_ID_MIN+1;
   if (_useCabling){
     nshotsperFed.resize(lNumFeds,0);
   }

   APVShotFinder apvsf(*digis,_zs);
   const std::vector<APVShot>& shots = apvsf.getShots();

   for(std::vector<APVShot>::const_iterator shot=shots.begin();shot!=shots.end();++shot) {
     if(shot->isGenuine()) {

       //get the fedid from the detid

       uint32_t det=shot->detId();
       if (_useCabling){
         const std::vector<const FedChannelConnection *> & conns = _detCabling->getConnections( det );

         if (!(conns.size())) continue;
         uint16_t lFedId = 0;
         for (uint32_t ch = 0; ch<conns.size(); ch++) {
           lFedId = conns[ch]->fedId();
           //uint16_t lFedCh = conns[ch]->fedCh();
   
           if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
             std::cout << " -- Invalid fedid " << lFedId << " for detid " << det << " connection " << ch << std::endl;
             continue;
           }
           else break;
         }

         if (lFedId < sistrip::FED_ID_MIN || lFedId > sistrip::FED_ID_MAX){
           std::cout << " -- No valid fedid (=" << lFedId << ") found for detid " << det << std::endl;
           continue;
         }
         ++nshotsperFed[lFedId-sistrip::FED_ID_MIN];
         _fed->Fill(lFedId);
         _medianVsFED->Fill(lFedId,shot->median());


       }

       ++nshots;


       _whichAPV->Fill(shot->apvNumber());
       _median->Fill(shot->median());
       _stripMult->Fill(shot->nStrips());
       _subDetector->Fill(shot->subDet());
       tkhisto2->fill(det,shot->nStrips());;
       tkhisto->add(det,1);



     }
   }

   _nShots->Fill(nshots);
   if (_useCabling){
     for (uint16_t lFed(0); lFed<lNumFeds; lFed++){
       _nShotsVsFED->Fill(lFed+sistrip::FED_ID_MIN,nshotsperFed[lFed]);
     }
   }

   _nShotsVsTime->Fill(iEvent.orbitNumber(),nshots);
   

}
void APVShotsAnalyzer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 287 of file APVShotsAnalyzer.cc.

{

}
void APVShotsAnalyzer::beginRun ( const edm::Run iRun,
const edm::EventSetup  
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 276 of file APVShotsAnalyzer.cc.

{}
void APVShotsAnalyzer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 294 of file APVShotsAnalyzer.cc.

References _nevents, _suffix, TkHistoMap::dumpInTkMap(), TkHistoMap::save(), TrackerMap::save(), TrackerMap::setPalette(), tkhisto, and tkhisto2.

                         {

  edm::LogInfo("EndOfJob") << _nevents << " analyzed events";

#include "CommonTools/TrackerMap/interface/TrackerMap.h"
  TrackerMap tkmap,tkmap2;

  tkmap.setPalette(1);
  tkmap2.setPalette(1);
  tkhisto->dumpInTkMap(&tkmap);
  tkhisto2->dumpInTkMap(&tkmap2);
  std::string tkshotmultmapname = "ShotMultiplicity_" + _suffix + ".png";
  tkmap.save(true,0,0,tkshotmultmapname);
  std::string tkstripmultmapname = "StripMultiplicity_" + _suffix + ".png";
  tkmap2.save(true,0,0,tkstripmultmapname);

  std::string rootmapname = "TKMap_"+_suffix+".root";
  tkhisto->save(rootmapname);
  tkhisto2->save(rootmapname);
}
void APVShotsAnalyzer::endRun ( const edm::Run iRun,
const edm::EventSetup  
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 280 of file APVShotsAnalyzer.cc.

{
}
void APVShotsAnalyzer::updateDetCabling ( const edm::EventSetup setup) [private]

Definition at line 316 of file APVShotsAnalyzer.cc.

References _cacheIdDet, _detCabling, _useCabling, trackerHits::c, edm::EventSetup::get(), and edm::ESHandle< T >::product().

Referenced by analyze().

{
  if (_useCabling){
    uint32_t cache_id = setup.get<SiStripDetCablingRcd>().cacheIdentifier();//.get( cabling_ );
   
    if ( _cacheIdDet != cache_id ) { // If the cache ID has changed since the last update...
      // Update the cabling object
      edm::ESHandle<SiStripDetCabling> c;
      setup.get<SiStripDetCablingRcd>().get( c );
      _detCabling = c.product();
      _cacheIdDet = cache_id;
    } // end of new cache ID check
  }
}

Member Data Documentation

uint32_t APVShotsAnalyzer::_cacheIdDet [private]

DB cache ID used to establish if the cabling has changed during the run.

Definition at line 104 of file APVShotsAnalyzer.cc.

Referenced by updateDetCabling().

The cabling object.

Definition at line 105 of file APVShotsAnalyzer.cc.

Referenced by analyze(), updateDetCabling(), and ~APVShotsAnalyzer().

Definition at line 83 of file APVShotsAnalyzer.cc.

Referenced by analyze().

TH1F* APVShotsAnalyzer::_fed [private]

Definition at line 94 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

TH1F* APVShotsAnalyzer::_median [private]

Definition at line 92 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 96 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 86 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and endJob().

TH1F* APVShotsAnalyzer::_nShots [private]

Definition at line 88 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 97 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

TProfile* APVShotsAnalyzer::_nShotsVsTime [private]

Definition at line 89 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 91 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 93 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

std::string APVShotsAnalyzer::_suffix [private]

Definition at line 85 of file APVShotsAnalyzer.cc.

Referenced by APVShotsAnalyzer(), and endJob().

Definition at line 103 of file APVShotsAnalyzer.cc.

Referenced by analyze(), APVShotsAnalyzer(), and updateDetCabling().

TH1F* APVShotsAnalyzer::_whichAPV [private]

Definition at line 90 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

bool APVShotsAnalyzer::_zs [private]

Definition at line 84 of file APVShotsAnalyzer.cc.

Referenced by analyze(), and APVShotsAnalyzer().

Definition at line 100 of file APVShotsAnalyzer.cc.

Referenced by analyze(), APVShotsAnalyzer(), and endJob().

Definition at line 100 of file APVShotsAnalyzer.cc.

Referenced by analyze(), APVShotsAnalyzer(), and endJob().