CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TkVoltageMapCreator.cc
Go to the documentation of this file.
1 //G.Benelli Aug 26 2010
2 //Plugin adapted from Andrea Venturi's myTkAnalyses/PSTools to create Voltage (LV/HV) ON/OFF Tracke maps in the context of Strip DCS O2O.
3 
4 // system include files
5 #include <memory>
6 
7 // user include files
8 
9 #include <iostream>
10 #include <fstream>
11 #include <string>
12 
15 
18 
20 
22 
25 
26 //
27 // class decleration
28 //
29 
31  public:
32  explicit TkVoltageMapCreator(const edm::ParameterSet&);
34 
35 
36  private:
37  virtual void beginJob() ;
38  virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
39  virtual void endRun(const edm::Run&, const edm::EventSetup&) ;
40  virtual void analyze(const edm::Event&, const edm::EventSetup&);
41  virtual void endJob() ;
42 
43  // ----------member data ---------------------------
44 
45  const std::string _lvfile;
46  const std::string _lvtkmapname;
47  const std::string _hvfile;
48  const std::string _hvtkmapname;
49 
50 };
51 
52 //
53 // constants, enums and typedefs
54 //
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64  _lvfile(iConfig.getParameter<std::string>("LVStatusFile")),
65  _lvtkmapname(iConfig.getParameter<std::string>("LVTkMapName")),
66  _hvfile(iConfig.getParameter<std::string>("HVStatusFile")),
67  _hvtkmapname(iConfig.getParameter<std::string>("HVTkMapName"))
68 
69 {
70  //now do what ever initialization is needed
71 }
72 
73 
75 {
76 
77  // do anything here that needs to be done at desctruction time
78  // (e.g. close files, deallocate resources etc.)
79 
80 }
81 
82 
83 //
84 // member functions
85 //
86 
87 // ------------ method called to for each event ------------
88 void
90 {
91  using namespace edm;
92 
93 }
94 
95 void
97 {
98  TrackerMap lvmap,hvmap;
99 
100  TkHistoMap lvhisto("LV_Status","LV_Status",-1);
101  TkHistoMap hvhisto("HV_Status","HV_Status",-1);
102 
103  ifstream lvdata(_lvfile.c_str());
104  ifstream hvdata(_hvfile.c_str());
105 
106  // HV channel map filling
107 
108  unsigned int detid;
109  std::string lvstatus;
110 
111  while(lvdata >> detid >> lvstatus) {
112  double cha =0.;
113  if(lvstatus=="ON") cha = 0.5; //GREEN
114  if(lvstatus=="OFF") cha = 1.; //RED
115  lvhisto.fill(detid,cha);
116  }
117 
118  std::string hvstatus;
119 
120  while(hvdata >> detid >> hvstatus) {
121  double cha =0.;
122  if(hvstatus=="ON") cha = 0.5; //GREEN
123  if(hvstatus=="OFF") cha = 1.; //RED
124  hvhisto.fill(detid,cha);
125  }
126 
127  lvmap.setPalette(1);
128  hvmap.setPalette(1);
129 
130  lvhisto.dumpInTkMap(&lvmap);
131  hvhisto.dumpInTkMap(&hvmap);
132 
133  lvmap.save(true,0,0,_lvtkmapname);
134  hvmap.save(true,0,0,_hvtkmapname);
135 
136  //TODO could make the root file name a parameter to avoid overwriting everytime...
137  std::string rootmapname = "VoltageStatus.root";
138  lvhisto.save(rootmapname);
139  hvhisto.save(rootmapname);
140 }
141 
142 void
144 {
145 }
146 
147 
148 // ------------ method called once each job just before starting event loop ------------
149 void
151 {
152 
153 }
154 
155 // ------------ method called once each job just after ending the event loop ------------
156 void
158 
159 
160 //define this as a plug-in
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
const std::string _hvfile
virtual void endRun(const edm::Run &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TkVoltageMapCreator(const edm::ParameterSet &)
const std::string _lvtkmapname
const std::string _hvtkmapname
void save(std::string filename)
Definition: TkHistoMap.cc:41
int iEvent
Definition: GenABIO.cc:243
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:130
void setPalette(int numpalette)
Definition: TrackerMap.h:68
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:632
void dumpInTkMap(TrackerMap *tkmap, bool dumpEntries=false)
Definition: TkHistoMap.cc:184
virtual void analyze(const edm::Event &, const edm::EventSetup &)
const std::string _lvfile
Definition: Run.h:33