CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTTTrigWriter Class Reference

#include <DTTTrigWriter.h>

Inheritance diagram for DTTTrigWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 Compute the ttrig by fiting the TB rising edge.
 DTTTrigWriter (const edm::ParameterSet &pset)
 Constructor.
void endJob ()
 Write ttrig in the DB.
virtual ~DTTTrigWriter ()
 Destructor.

Private Member Functions

std::string getTBoxName (const DTSuperLayerId &slId) const

Private Attributes

bool debug
double kFactor
TFile * theFile
DTTimeBoxFittertheFitter
std::string theRootInputFile
DTTtrigtTrig

Detailed Description

Definition at line 29 of file DTTTrigWriter.h.


Constructor & Destructor Documentation

DTTTrigWriter::DTTTrigWriter ( const edm::ParameterSet pset)

Constructor.

Definition at line 41 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, edm::ParameterSet::getUntrackedParameter(), and interactiveExample::theFile.

                                                     {
  // get selected debug option
  debug = pset.getUntrackedParameter<bool>("debug",false);

  // Open the root file which contains the histos
  theRootInputFile = pset.getUntrackedParameter<string>("rootFileName");
  theFile = new TFile(theRootInputFile.c_str(), "READ");
  theFile->cd();
  theFitter = new DTTimeBoxFitter();
  if(debug)
    theFitter->setVerbosity(1);

  double sigmaFit = pset.getUntrackedParameter<double>("sigmaTTrigFit",10.);
  theFitter->setFitSigma(sigmaFit);

  // the kfactor to be uploaded in the ttrig DB
  kFactor = pset.getUntrackedParameter<double>("kFactor",-0.7);

  // Create the object to be written to DB
  tTrig = new DTTtrig();
  
  if(debug)
    cout << "[DTTTrigWriter]Constructor called!" << endl;
}
DTTTrigWriter::~DTTTrigWriter ( ) [virtual]

Destructor.

Definition at line 69 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, and interactiveExample::theFile.

                             {
  if(debug)
    cout << "[DTTTrigWriter]Destructor called!" << endl;
  theFile->Close();
  delete theFitter;
}

Member Function Documentation

void DTTTrigWriter::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Compute the ttrig by fiting the TB rising edge.

Implements edm::EDAnalyzer.

Definition at line 79 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, edm::EventSetup::get(), timingPdfMaker::histo, DTTimeUnits::ns, and interactiveExample::theFile.

                                                                             {
  if(debug)
    cout << "[DTTTrigWriter]Analyzer called!" << endl;

  // Get the DT Geometry
  ESHandle<DTGeometry> dtGeom;
  eventSetup.get<MuonGeometryRecord>().get(dtGeom);

  // Get all the sls from the setup
  const vector<DTSuperLayer*> superLayers = dtGeom->superLayers(); 
    
  // Loop over all SLs
  for(vector<DTSuperLayer*>::const_iterator  sl = superLayers.begin();
      sl != superLayers.end(); sl++) {
      
    // Get the histo from file
    DTSuperLayerId slId = (*sl)->id();
    TH1F* histo = (TH1F*)theFile->Get((getTBoxName(slId)).c_str());
    if(histo) { // Check that the histo exists
      // Compute mean and sigma of the rising edge
      pair<double, double> meanAndSigma = theFitter->fitTimeBox(histo);

      // Write them in DB object
      tTrig->set(slId,
                 meanAndSigma.first,
                 meanAndSigma.second,
                 kFactor,
                 DTTimeUnits::ns);
      if(debug) {
        cout << " SL: " << slId
             << " mean = " << meanAndSigma.first
             << " sigma = " << meanAndSigma.second << endl;
      }
    }
  }
}
void DTTTrigWriter::endJob ( void  ) [virtual]

Write ttrig in the DB.

Reimplemented from edm::EDAnalyzer.

Definition at line 119 of file DTTTrigWriter.cc.

References gather_cfg::cout, debug, and DTCalibDBUtils::writeToDB().

                           {
  if(debug) 
        cout << "[DTTTrigWriter]Writing ttrig object to DB!" << endl;

  // FIXME: to be read from cfg?
  string tTrigRecord = "DTTtrigRcd";
  
  // Write the object to DB
  DTCalibDBUtils::writeToDB(tTrigRecord, tTrig);

}  
string DTTTrigWriter::getTBoxName ( const DTSuperLayerId slId) const [private]

Definition at line 134 of file DTTTrigWriter.cc.

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

                                                                  {
  string histoName;
  stringstream theStream;
  theStream << "Ch_" << slId.wheel() << "_" << slId.station() << "_" << slId.sector()
            << "_SL" << slId.superlayer() << "_hTimeBox";
  theStream >> histoName;
  return histoName;
}

Member Data Documentation

bool DTTTrigWriter::debug [private]

Definition at line 53 of file DTTTrigWriter.h.

double DTTTrigWriter::kFactor [private]

Definition at line 55 of file DTTTrigWriter.h.

TFile* DTTTrigWriter::theFile [private]

Definition at line 58 of file DTTTrigWriter.h.

Definition at line 64 of file DTTTrigWriter.h.

std::string DTTTrigWriter::theRootInputFile [private]

Definition at line 61 of file DTTTrigWriter.h.

Definition at line 67 of file DTTTrigWriter.h.