CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTTPAnalyzer Class Reference

Inheritance diagram for DTTPAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
void beginRun (const edm::Run &, const edm::EventSetup &)
 DTTPAnalyzer (const edm::ParameterSet &)
void endJob ()
virtual ~DTTPAnalyzer ()

Private Member Functions

std::string getHistoName (const DTLayerId &)

Private Attributes

edm::InputTag digiLabel_
edm::ESHandle< DTGeometrydtGeom_
std::map< DTWireId, int > nDigisPerWire_
TFile * rootFile_
bool subtractT0_
std::map< DTWireId, double > sumW2PerWire_
std::map< DTWireId, double > sumWPerWire_
DTTTrigBaseSynctTrigSync_

Detailed Description

Date:
2011/02/10 20:38:59
Revision:
1.1
Author:
A. Vilela Pereira

Definition at line 22 of file DTTPAnalyzer.cc.


Constructor & Destructor Documentation

DTTPAnalyzer::DTTPAnalyzer ( const edm::ParameterSet pset)

Definition at line 70 of file DTTPAnalyzer.cc.

References reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), rootFile_, dtT0WireCalibration_cfg::rootFileName, subtractT0_, and tTrigSync_.

                                                     :
  subtractT0_(pset.getParameter<bool>("subtractT0")),
  digiLabel_(pset.getParameter<edm::InputTag>("digiLabel")),
  tTrigSync_(0) {

  std::string rootFileName = pset.getUntrackedParameter<std::string>("rootFileName");
  rootFile_ = new TFile(rootFileName.c_str(), "RECREATE");
  rootFile_->cd();

  if(subtractT0_) 
     tTrigSync_ = DTTTrigSyncFactory::get()->create(pset.getParameter<std::string>("tTrigMode"),
                                                    pset.getParameter<edm::ParameterSet>("tTrigModeConfig"));

}
DTTPAnalyzer::~DTTPAnalyzer ( ) [virtual]

Definition at line 85 of file DTTPAnalyzer.cc.

References rootFile_.

                           {  
  rootFile_->Close();
}

Member Function Documentation

void DTTPAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 101 of file DTTPAnalyzer.cc.

References digiLabel_, nDigisPerWire_, evf::evtn::offset(), DTTTrigBaseSync::offset(), subtractT0_, sumW2PerWire_, sumWPerWire_, and tTrigSync_.

                                                                             {

  // Get the digis from the event
  edm::Handle<DTDigiCollection> digis; 
  event.getByLabel(digiLabel_, digis);

  // Iterate through all digi collections ordered by LayerId   
  DTDigiCollection::DigiRangeIterator dtLayerIt;
  for (dtLayerIt = digis->begin();
       dtLayerIt != digis->end();
       ++dtLayerIt){
    // Get the iterators over the digis associated with this LayerId
    const DTDigiCollection::Range& digiRange = (*dtLayerIt).second;
  
    // Get the layerId
    const DTLayerId layerId = (*dtLayerIt).first; //FIXME: check to be in the right sector

    // Loop over all digis in the given layer
    for (DTDigiCollection::const_iterator digi = digiRange.first;
         digi != digiRange.second;
         digi++) {
       const DTWireId wireId( layerId, (*digi).wire() );

       double t0 = (*digi).countsTDC();

       //FIXME: Reject digis not coming from TP

       if(subtractT0_) {
          const DTLayer* layer = 0; //fake
          const GlobalPoint glPt; //fake
          double offset = tTrigSync_->offset(layer, wireId, glPt);
          t0 -= offset;
       }

       if(nDigisPerWire_.find(wireId) == nDigisPerWire_.end()){
          nDigisPerWire_[wireId] = 0;
          sumWPerWire_[wireId] = 0.;
          sumW2PerWire_[wireId] = 0.;  
       }

       ++nDigisPerWire_[wireId]; 
       sumWPerWire_[wireId] += t0;
       sumW2PerWire_[wireId] += t0*t0;
    }

  }
}
void DTTPAnalyzer::beginRun ( const edm::Run run,
const edm::EventSetup setup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 89 of file DTTPAnalyzer.cc.

References dtGeom_, edm::EventSetup::get(), DTTTrigBaseSync::setES(), subtractT0_, and tTrigSync_.

                                                                         {
  // Get the t0 map from the DB
  if(subtractT0_){ 
     /*ESHandle<DTT0> t0;
     setup.get<DTT0Rcd>().get(t0);
     tZeroMap_ = &*t0;*/
     tTrigSync_->setES(setup);
  }
  // Get the DT Geometry  
  setup.get<MuonGeometryRecord>().get(dtGeom_);
}
void DTTPAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 149 of file DTTPAnalyzer.cc.

References dtGeom_, getHistoName(), combine::key, DTWireId::layerId(), plotscripts::mean(), nDigisPerWire_, plotscripts::rms(), rootFile_, mathSSE::sqrt(), sumW2PerWire_, sumWPerWire_, and DTWireId::wire().

                          {
  rootFile_->cd();
  std::map<DTLayerId, TH1F*> meanHistoMap;
  std::map<DTLayerId, TH1F*> sigmaHistoMap; 
  for(std::map<DTWireId, int>::const_iterator wireIdIt = nDigisPerWire_.begin();
                                              wireIdIt != nDigisPerWire_.end(); ++wireIdIt){
     DTWireId wireId((*wireIdIt).first);

     int nDigis = nDigisPerWire_[wireId];
     double sumW = sumWPerWire_[wireId];
     double sumW2 = sumW2PerWire_[wireId]; 

     double mean = sumW/nDigis;
     double rms = sumW2/nDigis - mean*mean;
     rms = sqrt(rms);

     DTLayerId layerId = wireId.layerId();
     if(meanHistoMap.find(layerId) == meanHistoMap.end()) {
        std::string histoName = getHistoName(layerId);
        const int firstChannel = dtGeom_->layer(layerId)->specificTopology().firstChannel();
        const int nWires = dtGeom_->layer(layerId)->specificTopology().channels();
        TH1F* meanHistoTP = new TH1F((histoName + "_tpMean").c_str(),"mean from test pulses by channel", 
                                      nWires,firstChannel,(firstChannel + nWires));
        TH1F* sigmaHistoTP = new TH1F((histoName + "_tpSigma").c_str(),"sigma from test pulses by channel",
                                      nWires,firstChannel,(firstChannel + nWires));
        meanHistoMap[layerId] = meanHistoTP;
        sigmaHistoMap[layerId] = sigmaHistoTP;
     }
     // Fill the histograms
     int nBin = meanHistoMap[layerId]->GetXaxis()->FindFixBin(wireId.wire());
     meanHistoMap[layerId]->SetBinContent(nBin,mean);
     sigmaHistoMap[layerId]->SetBinContent(nBin,rms);
  }

  for(std::map<DTLayerId, TH1F*>::const_iterator key = meanHistoMap.begin();
                                                 key != meanHistoMap.end(); ++key){
     meanHistoMap[(*key).first]->Write();
     sigmaHistoMap[(*key).first]->Write(); 
  } 

}
std::string DTTPAnalyzer::getHistoName ( const DTLayerId lId) [private]

Definition at line 191 of file DTTPAnalyzer.cc.

References DTLayerId::layer(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), and DTChamberId::wheel().

Referenced by endJob().

                                                         {
  std::string histoName;
  std::stringstream theStream;
  theStream << "Ch_" << lId.wheel() << "_" << lId.station() << "_" << lId.sector()
            << "_SL" << lId.superlayer() << "_L" << lId.layer();
  theStream >> histoName;
  return histoName;
}

Member Data Documentation

Definition at line 36 of file DTTPAnalyzer.cc.

Referenced by analyze().

Definition at line 40 of file DTTPAnalyzer.cc.

Referenced by beginRun(), and endJob().

std::map<DTWireId, int> DTTPAnalyzer::nDigisPerWire_ [private]

Definition at line 44 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

TFile* DTTPAnalyzer::rootFile_ [private]

Definition at line 38 of file DTTPAnalyzer.cc.

Referenced by DTTPAnalyzer(), endJob(), and ~DTTPAnalyzer().

bool DTTPAnalyzer::subtractT0_ [private]

Definition at line 35 of file DTTPAnalyzer.cc.

Referenced by analyze(), beginRun(), and DTTPAnalyzer().

std::map<DTWireId, double> DTTPAnalyzer::sumW2PerWire_ [private]

Definition at line 46 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

std::map<DTWireId, double> DTTPAnalyzer::sumWPerWire_ [private]

Definition at line 45 of file DTTPAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 41 of file DTTPAnalyzer.cc.

Referenced by analyze(), beginRun(), and DTTPAnalyzer().