CMS 3D CMS Logo

DTTPDeadWriter.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2008/02/19 15:15:34 $
00005  *  $Revision: 1.1 $
00006  *  \author S. Bolognesi
00007  */
00008 
00009 #include "CalibMuon/DTCalibration/plugins/DTTPDeadWriter.h"
00010 #include "CalibMuon/DTCalibration/interface/DTCalibDBUtils.h"
00011 
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00016 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00018 
00019 #include "CondFormats/DTObjects/interface/DTT0.h"
00020 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
00021 #include "CondFormats/DataRecord/interface/DTDeadFlagRcd.h"
00022 #include "CondFormats/DTObjects/interface/DTDeadFlag.h"
00023 
00024 /* C++ Headers */
00025 #include <vector> 
00026 #include <set>
00027 #include <iostream>
00028 #include <fstream>
00029 #include <string>
00030 #include <sstream>
00031 #include "TFile.h"
00032 #include "TH1.h"
00033 
00034 using namespace std;
00035 using namespace edm;
00036 
00037 
00038 // Constructor
00039 DTTPDeadWriter::DTTPDeadWriter(const ParameterSet& pset) {
00040   // get selected debug option
00041   debug = pset.getUntrackedParameter<bool>("debug", "false"); 
00042 
00043   // Create the object to be written to DB
00044   tpDeadList = new DTDeadFlag();
00045 
00046   if(debug)
00047     cout << "[DTTPDeadWriter]Constructor called!" << endl;
00048 }
00049 
00050 // Destructor
00051 DTTPDeadWriter::~DTTPDeadWriter(){
00052   if(debug)
00053     cout << "[DTTPDeadWriter]Destructor called!" << endl;
00054 }
00055 
00056 void DTTPDeadWriter::beginJob(const EventSetup& setup) {
00057    // Get the t0 map  
00058    ESHandle<DTT0> t0;
00059    setup.get<DTT0Rcd>().get(t0);
00060    tZeroMap = &*t0;
00061 
00062    // Get the muon Geometry  
00063    setup.get<MuonGeometryRecord>().get(muonGeom);
00064 }
00065 
00066 // Do the job
00067 void DTTPDeadWriter::analyze(const Event & event, const EventSetup& eventSetup) {
00068   set<DTLayerId> analyzedLayers;
00069 
00070   //Loop on tzero map
00071   for(DTT0::const_iterator tzero = tZeroMap->begin();
00072       tzero != tZeroMap->end(); tzero++){
00073 
00074     //Consider what layers have been already considered
00075     DTLayerId layerId = (DTWireId((*tzero).first.wheelId,
00076                                   (*tzero).first.stationId,
00077                                   (*tzero).first.sectorId,
00078                                   (*tzero).first.slId,
00079                                   (*tzero).first.layerId,
00080                                   (*tzero).first.cellId)).layerId();
00081     if(analyzedLayers.find(layerId)==analyzedLayers.end()){
00082       analyzedLayers.insert(layerId);
00083 
00084       //Take the layer topology
00085       const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
00086       const int firstWire = dtTopo.firstChannel();
00087       //const int lastWire = dtTopo.lastChannel();
00088       const int nWires = muonGeom->layer(layerId)->specificTopology().channels();
00089 
00090       //Loop on wires
00091       for(int wire=firstWire; wire<=nWires; wire++){
00092         DTWireId wireId(layerId,wire);
00093         float t0 = 0;
00094         float t0rms = 0;
00095         tZeroMap->cellT0(wireId,
00096                          t0,
00097                          t0rms,
00098                          DTTimeUnits::ns);
00099 
00100         //If no t0 stored then is a tp dead channel
00101         if(!t0){
00102           tpDeadList->setCellDead_TP(wireId, true);
00103           cout<<"Wire id "<<wireId<<" is TP dead"<<endl;          
00104         }
00105       }
00106     }
00107   }
00108 }
00109 
00110 // Write objects to DB
00111 void DTTPDeadWriter::endJob() {
00112   if(debug) 
00113         cout << "[DTTPDeadWriter]Writing ttrig object to DB!" << endl;
00114 
00115   // FIXME: to be read from cfg?
00116   string deadRecord = "DTDeadFlagRcd";
00117   
00118   // Write the object to DB
00119   DTCalibDBUtils::writeToDB(deadRecord, tpDeadList);
00120 
00121 }  
00122 

Generated on Tue Jun 9 17:25:29 2009 for CMSSW by  doxygen 1.5.4