CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HcalLedAnalysis Class Reference

#include <HcalLedAnalysis.h>

Classes

struct  CALIBBUNCH
 

Public Member Functions

 HcalLedAnalysis (const edm::ParameterSet &ps)
 Constructor. More...
 
void LedDone ()
 
void LedSampleAnalysis ()
 
void LedSetup (const std::string &m_outputFileROOT)
 
void processLedEvent (const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection &calib, const HcalDbService &cond)
 
 ~HcalLedAnalysis ()
 Destructor. More...
 

Private Types

typedef std::pair< TH1F
*, std::pair< std::map< int,
std::vector< double >
>, std::vector< TH1F * > > > 
LEDBUNCH
 

Private Member Functions

float BinsizeCorr (float time)
 
void GetLedConst (std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 
void LedHBHEHists (const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedHFHists (const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedHOHists (const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedTrendings (std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 
void ProcessCalibEvent (int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
 
void SetupLEDHists (int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 

Private Attributes

std::map< HcalCalibDetId,
CALIBBUNCH >::iterator 
_meca
 
std::map< HcalDetId, std::map
< int, float > >::iterator 
_meee
 
std::map< HcalDetId, std::map
< int, LEDBUNCH > >::iterator 
_meol
 
std::map< HcalCalibDetId,
CALIBBUNCH
calibHists
 
int evt
 
int evt_curr
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map
< int, LEDBUNCH > >   LEDTRENDS
 
hbHists
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map
< int, LEDBUNCH > >   LEDTRENDS
 
hfHists
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map
< int, LEDBUNCH > >   LEDTRENDS
 
hoHists
 
std::map< HcalDetId, std::map
< int, float > > 
m_AllPedVals
 
const HcalQIECoderm_coder
 
int m_endTS
 
TFile * m_file
 
int m_fitflag
 
int m_hiSaveflag
 
std::ofstream m_logFile
 
int m_nevtsample
 
std::ofstream m_outFile
 
std::string m_outputFileROOT
 
std::string m_outputFileText
 
std::string m_outputFileX
 
std::ofstream m_outputFileXML
 
const HcalPedestalm_ped
 
const HcalQIEShapem_shape
 
int m_startTS
 
bool m_usecalib
 
char output [100]
 
int sample
 
std::vector< bool > state
 

Detailed Description

Definition at line 32 of file HcalLedAnalysis.h.

Member Typedef Documentation

typedef std::pair<TH1F*,std::pair<std::map<int, std::vector<double> >,std::vector<TH1F*> > > HcalLedAnalysis::LEDBUNCH
private

Definition at line 68 of file HcalLedAnalysis.h.

Constructor & Destructor Documentation

HcalLedAnalysis::HcalLedAnalysis ( const edm::ParameterSet ps)

Constructor.

Definition at line 12 of file HcalLedAnalysis.cc.

References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), roll_playback::k, convertSQLitetoXML_cfg::output, and compare_using_db::sample.

13 {
14  // init
15 
16  m_coder = 0;
17  m_ped = 0;
18  m_shape = 0;
19  evt=0;
20  sample=0;
21  m_file=0;
22  // output files
23  for(int k=0;k<4;k++) state.push_back(true); // 4 cap-ids (do we care?)
24  m_outputFileText = ps.getUntrackedParameter<string>("outputFileText", "");
25  m_outputFileX = ps.getUntrackedParameter<string>("outputFileXML","");
26  if ( m_outputFileText.size() != 0 ) {
27  cout << "Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
28  m_outFile.open(m_outputFileText.c_str());
29  }
30  m_outputFileROOT = ps.getUntrackedParameter<string>("outputFileHist", "");
31  if ( m_outputFileROOT.size() != 0 ) {
32  cout << "Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
33  }
34 
35  m_nevtsample = ps.getUntrackedParameter<int>("nevtsample",9999999);
36  if(m_nevtsample<1)m_nevtsample=9999999;
37  m_hiSaveflag = ps.getUntrackedParameter<int>("hiSaveflag",0);
40  m_fitflag = ps.getUntrackedParameter<int>("analysisflag",2);
41  if(m_fitflag<0)m_fitflag=0;
42  if(m_fitflag>4)m_fitflag=4;
43  m_startTS = ps.getUntrackedParameter<int>("firstTS", 0);
44  if(m_startTS<0) m_startTS=0;
45  m_endTS = ps.getUntrackedParameter<int>("lastTS", 9);
46  m_usecalib = ps.getUntrackedParameter<bool>("usecalib",false);
47  m_logFile.open("HcalLedAnalysis.log");
48 
49  int runNum = ps.getUntrackedParameter<int>("runNumber",999999);
50 
51  // histogram booking
52  hbHists.ALLLEDS = new TH1F("HBHE All LEDs","HB/HE All Leds",10,0,9);
53  hbHists.LEDRMS= new TH1F("HBHE All LED RMS","HB/HE All LED RMS",100,0,3);
54  hbHists.LEDMEAN= new TH1F("HBHE All LED Means","HB/HE All LED Means",100,0,9);
55  hbHists.CHI2= new TH1F("HBHE Chi2 by ndf for Landau fit","HB/HE Chi2/ndf Landau",200,0.,50.);
56 
57  hoHists.ALLLEDS = new TH1F("HO All LEDs","HO All Leds",10,0,9);
58  hoHists.LEDRMS= new TH1F("HO All LED RMS","HO All LED RMS",100,0,3);
59  hoHists.LEDMEAN= new TH1F("HO All LED Means","HO All LED Means",100,0,9);
60  hoHists.CHI2= new TH1F("HO Chi2 by ndf for Landau fit","HO Chi2/ndf Landau",200,0.,50.);
61 
62  hfHists.ALLLEDS = new TH1F("HF All LEDs","HF All Leds",10,0,9);
63  hfHists.LEDRMS= new TH1F("HF All LED RMS","HF All LED RMS",100,0,3);
64  hfHists.LEDMEAN= new TH1F("HF All LED Means","HF All LED Means",100,0,9);
65  hfHists.CHI2= new TH1F("HF Chi2 by ndf for Landau fit","HF Chi2/ndf Landau",200,0.,50.);
66 
67 
68  //XML file header
69  m_outputFileXML.open(m_outputFileX.c_str());
70 
71  m_outputFileXML << "<?xml version='1.0' encoding='UTF-8'?>" << endl;
72 
73  m_outputFileXML << "<ROOT>" << endl;
74 
75  m_outputFileXML << " <HEADER>" << endl;
76 
77  m_outputFileXML << " <TYPE>" << endl;
78 
79  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
80 
81  m_outputFileXML << " <NAME>HCAL LED Timing</NAME>" << endl;
82 
83  m_outputFileXML << " </TYPE>" << endl;
84 
85  m_outputFileXML << " <RUN>" << endl;
86 
87  m_outputFileXML << " <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
88 
89  sprintf(output, " <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
90  m_outputFileXML << output << endl;
91 
92  m_outputFileXML << " <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
93 
94  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
95 
96  m_outputFileXML << " </RUN>" << endl;
97 
98  m_outputFileXML << " </HEADER>" << endl;
99 
100  m_outputFileXML << "<!-- Tags secton -->" << endl;
101 
102  m_outputFileXML << " <ELEMENTS>" << endl;
103 
104  m_outputFileXML << " <DATA_SET id='-1'/>" << endl;
105 
106  m_outputFileXML << " <IOV id='1'>" << endl;
107 
108  m_outputFileXML << " <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
109 
110  m_outputFileXML << " <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
111 
112  m_outputFileXML << " </IOV>" << endl;
113 
114  m_outputFileXML << " <TAG id='2' mode='auto'>" << endl;
115 
116  sprintf(output, " <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
117  m_outputFileXML << output << endl;
118 
119  m_outputFileXML << " <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
120 
121  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
122 
123  m_outputFileXML << " </TAG>" << endl;
124 
125  m_outputFileXML << " </ELEMENTS>" << endl;
126 
127  m_outputFileXML << " <MAPS>" << endl;
128 
129  m_outputFileXML << " <TAG idref ='2'>" << endl;
130 
131  m_outputFileXML << " <IOV idref='1'>" << endl;
132 
133  m_outputFileXML << " <DATA_SET idref='-1' />" << endl;
134 
135  m_outputFileXML << " </IOV>" << endl;
136 
137  m_outputFileXML << " </TAG>" << endl;
138 
139  m_outputFileXML << " </MAPS>" << endl;
140 
141 }
T getUntrackedParameter(std::string const &, T const &) const
struct HcalLedAnalysis::@58 hfHists
std::vector< bool > state
std::ofstream m_logFile
std::string m_outputFileROOT
const HcalPedestal * m_ped
struct HcalLedAnalysis::@58 hbHists
std::string m_outputFileX
const HcalQIECoder * m_coder
std::ofstream m_outputFileXML
std::ofstream m_outFile
struct HcalLedAnalysis::@58 hoHists
const HcalQIEShape * m_shape
tuple cout
Definition: gather_cfg.py:121
std::string m_outputFileText
HcalLedAnalysis::~HcalLedAnalysis ( )

Destructor.

All done, clean up!!

Definition at line 144 of file HcalLedAnalysis.cc.

References i.

144  {
146  for(_meol=hbHists.LEDTRENDS.begin(); _meol!=hbHists.LEDTRENDS.end(); _meol++){
147  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
148  }
149  for(_meol=hoHists.LEDTRENDS.begin(); _meol!=hoHists.LEDTRENDS.end(); _meol++){
150  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
151  }
152  for(_meol=hfHists.LEDTRENDS.begin(); _meol!=hfHists.LEDTRENDS.end(); _meol++){
153  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
154  }
155  hbHists.ALLLEDS->Delete();
156  hbHists.LEDRMS->Delete();
157  hbHists.LEDMEAN->Delete();
158  hbHists.CHI2->Delete();
159 
160  hoHists.ALLLEDS->Delete();
161  hoHists.LEDRMS->Delete();
162  hoHists.LEDMEAN->Delete();
163  hoHists.CHI2->Delete();
164 
165  hfHists.ALLLEDS->Delete();
166  hfHists.LEDRMS->Delete();
167  hfHists.LEDMEAN->Delete();
168  hfHists.CHI2->Delete();
169 }
int i
Definition: DBlmapReader.cc:9
struct HcalLedAnalysis::@58 hfHists
struct HcalLedAnalysis::@58 hbHists
struct HcalLedAnalysis::@58 hoHists
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol

Member Function Documentation

float HcalLedAnalysis::BinsizeCorr ( float  time)
private

Definition at line 848 of file HcalLedAnalysis.cc.

References i.

848  {
849 
850 // this is the bin size correction to be applied for laser data (from Andy),
851 // it comes from a pulse shape measured from TB04 data (from Jordan)
852 // This should eventually be replaced with the more thorough treatment from Phil
853 
854  float corrtime=0.;
855  static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
856  0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
857  0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
858  0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
859  static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
860  0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
861  0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
862  0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
863  0.95072, 0.9726};
864 
865  int inttime=(int)time;
866  float restime=time-inttime;
867  for(int i=0; i<=32; i++) {
868  float lolim=0.; float uplim=1.; float tsdown; float tsup;
869  if(i>0){
870  lolim=tsreco[i-1];
871  tsdown=tstrue[i-1];
872  }
873  else tsdown=tstrue[31]-1.;
874  if(i<32){
875  uplim=tsreco[i];
876  tsup=tstrue[i];
877  }
878  else tsup=tstrue[0]+1.;
879  if(restime>=lolim && restime<uplim){
880  corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
881  }
882  }
883  corrtime+=inttime;
884 
885  return corrtime;
886 }
int i
Definition: DBlmapReader.cc:9
void HcalLedAnalysis::GetLedConst ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 207 of file HcalLedAnalysis.cc.

References HcalDetId::depth(), cond::rpcobgas::detid, i, HcalDetId::ietaAbs(), HcalDetId::iphi(), j, convertSQLitetoXML_cfg::output, DetId::rawId(), mathSSE::sqrt(), HcalDetId::subdet(), and HcalDetId::zside().

207  {
208  double time2=0; double time1=0; double time3=0; double time4=0;
209  double dtime2=0; double dtime1=0; double dtime3=0; double dtime4=0;
210 
211  if (m_outputFileText!=""){
212  if(m_fitflag==0 || m_fitflag==2) m_outFile<<"Det Eta,Phi,D Mean Error"<<std::endl;
213  else if(m_fitflag==1 || m_fitflag==3) m_outFile<<"Det Eta,Phi,D Peak Error"<<std::endl;
214  else if(m_fitflag==4) m_outFile<<"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"<<std::endl;
215  }
216  for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
217 // scale the LED pulse to 1 event
218  _meol->second[10].first->Scale(1./evt_curr);
219  if(m_fitflag==0 || m_fitflag==4){
220  time1 = _meol->second[10].first->GetMean();
221  dtime1 = _meol->second[10].first->GetRMS()/sqrt((float)evt_curr*(m_endTS-m_startTS+1));
222  }
223  if(m_fitflag==1 || m_fitflag==4){
224 // put proper errors
225  for(int j=0; j<10; j++) _meol->second[10].first->SetBinError(j+1,_meol->second[j].first->GetRMS()/sqrt((float)evt_curr));
226  }
227  if(m_fitflag==1 || m_fitflag==3 || m_fitflag==4){
228  _meol->second[10].first->Fit("landau","Q");
229 // _meol->second[10].first->Fit("gaus","Q");
230  TF1 *fit = _meol->second[10].first->GetFunction("landau");
231 // TF1 *fit = _meol->second[10].first->GetFunction("gaus");
232  time2=fit->GetParameter(1);
233  dtime2=fit->GetParError(1);
234  }
235  if(m_fitflag==2 || m_fitflag==4){
236  time3 = _meol->second[12].first->GetMean();
237  dtime3 = _meol->second[12].first->GetRMS()/sqrt((float)_meol->second[12].first->GetEntries());
238  }
239  if(m_fitflag==3 || m_fitflag==4){
240  time4 = _meol->second[13].first->GetMean();
241  dtime4 = _meol->second[13].first->GetRMS()/sqrt((float)_meol->second[13].first->GetEntries());
242  }
243  for (int i=0; i<10; i++){
244  _meol->second[i].first->GetXaxis()->SetTitle("Pulse height (fC)");
245  _meol->second[i].first->GetYaxis()->SetTitle("Counts");
246 // if(m_hiSaveflag>0)_meol->second[i].first->Write();
247  }
248  _meol->second[10].first->GetXaxis()->SetTitle("Time slice");
249  _meol->second[10].first->GetYaxis()->SetTitle("Averaged pulse (fC)");
250  if(m_hiSaveflag>0)_meol->second[10].first->Write();
251  _meol->second[10].second.first[0].push_back(time1);
252  _meol->second[10].second.first[1].push_back(dtime1);
253  _meol->second[11].second.first[0].push_back(time2);
254  _meol->second[11].second.first[1].push_back(dtime2);
255  _meol->second[12].first->GetXaxis()->SetTitle("Mean TS");
256  _meol->second[12].first->GetYaxis()->SetTitle("Counts");
257  if(m_fitflag==2 && m_hiSaveflag>0)_meol->second[12].first->Write();
258  _meol->second[12].second.first[0].push_back(time3);
259  _meol->second[12].second.first[1].push_back(dtime3);
260  _meol->second[13].first->GetXaxis()->SetTitle("Peak TS");
261  _meol->second[13].first->GetYaxis()->SetTitle("Counts");
262  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[13].first->Write();
263  _meol->second[13].second.first[0].push_back(time4);
264  _meol->second[13].second.first[1].push_back(dtime4);
265  _meol->second[14].first->GetXaxis()->SetTitle("Peak TS error");
266  _meol->second[14].first->GetYaxis()->SetTitle("Counts");
267  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[14].first->Write();
268  _meol->second[15].first->GetXaxis()->SetTitle("Chi2/NDF");
269  _meol->second[15].first->GetYaxis()->SetTitle("Counts");
270  if(m_fitflag>2 && m_hiSaveflag>0)_meol->second[15].first->Write();
271  _meol->second[16].first->GetXaxis()->SetTitle("Integrated Signal");
272  _meol->second[16].first->Write();
273 
274 
275 // Ascii printout (need to modify to include new info)
276  HcalDetId detid = _meol->first;
277 
278  if (m_outputFileText!=""){
279  if(m_fitflag==0) {
280  m_outFile<<detid<<" "<<time1<<" "<<dtime1<<std::endl;
281  m_outputFileXML << " <DATA_SET>" << endl;
282  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
283  m_outputFileXML << " <CHANNEL>" << endl;
284  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
285  sprintf(output, " <ETA>%2i</ETA>", detid.ietaAbs() );
286  m_outputFileXML << output << endl;
287  sprintf(output, " <PHI>%2i</PHI>", detid.iphi() );
288  m_outputFileXML << output << endl;
289  sprintf(output, " <DEPTH>%2i</DEPTH>", detid.depth() );
290  m_outputFileXML << output << endl;
291  sprintf(output, " <Z>%2i</Z>", detid.zside() );
292  m_outputFileXML << output << endl;
293 
294  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
295  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
296  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
297  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
298  sprintf(output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
299  m_outputFileXML << output << endl;
300  m_outputFileXML << " </CHANNEL>" << endl;
301  m_outputFileXML << " <DATA>" << endl;
302  sprintf(output, " <MEAN_TIME>%7f</MEAN_TIME>", time1);
303  m_outputFileXML << output << endl;
304  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
305  sprintf(output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
306  m_outputFileXML << output << endl;
307  sprintf(output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
308  m_outputFileXML << output << endl;
309  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
310  m_outputFileXML << " </DATA>" << endl;
311  m_outputFileXML << " </DATA_SET>" << endl;
312 
313  }
314  else if(m_fitflag==1){
315  m_outFile<<detid<<" "<<time2<<" "<<dtime2<<std::endl;
316  m_outputFileXML << " <DATA_SET>" << endl;
317  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
318  m_outputFileXML << " <CHANNEL>" << endl;
319  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
320  sprintf(output, " <ETA>%2i</ETA>", detid.ietaAbs() );
321  m_outputFileXML << output << endl;
322  sprintf(output, " <PHI>%2i</PHI>", detid.iphi() );
323  m_outputFileXML << output << endl;
324  sprintf(output, " <DEPTH>%2i</DEPTH>", detid.depth() );
325  m_outputFileXML << output << endl;
326  sprintf(output, " <Z>%2i</Z>", detid.zside() );
327  m_outputFileXML << output << endl;
328  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>"<< endl;
329  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>"<< endl;
330  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>"<< endl;
331  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>"<< endl;
332  sprintf(output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
333  m_outputFileXML << output << endl;
334  m_outputFileXML << " </CHANNEL>" << endl;
335  m_outputFileXML << " <DATA>" << endl;
336  sprintf(output, " <MEAN_TIME>%7f</MEAN_TIME>", time2);
337  m_outputFileXML << output << endl;
338  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
339  sprintf(output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
340  m_outputFileXML << output << endl;
341  sprintf(output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
342  m_outputFileXML << output << endl;
343  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
344  m_outputFileXML << " </DATA>" << endl;
345  m_outputFileXML << " </DATA_SET>" << endl;
346  }
347 
348  else if(m_fitflag==2){
349  m_outFile<<detid<<" "<<time3<<" "<<dtime3<<std::endl;
350  m_outputFileXML << " <DATA_SET>" << endl;
351  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
352  m_outputFileXML << " <CHANNEL>" << endl;
353  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
354  sprintf(output, " <ETA>%2i</ETA>", detid.ietaAbs() );
355  m_outputFileXML << output << endl;
356  sprintf(output, " <PHI>%2i</PHI>", detid.iphi() );
357  m_outputFileXML << output << endl;
358  sprintf(output, " <DEPTH>%2i</DEPTH>", detid.depth() );
359  m_outputFileXML << output << endl;
360  sprintf(output, " <Z>%2i</Z>", detid.zside() );
361  m_outputFileXML << output << endl;
362  if(detid.subdet() == 1) m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
363  if(detid.subdet() == 2) m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
364  if(detid.subdet() == 3) m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
365  if(detid.subdet() == 4) m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
366  sprintf(output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
367  m_outputFileXML << output << endl;
368  m_outputFileXML << " </CHANNEL>" << endl;
369  m_outputFileXML << " <DATA>" << endl;
370  sprintf(output, " <MEAN_TIME>%7f</MEAN_TIME>", time3);
371  m_outputFileXML << output << endl;
372  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
373  sprintf(output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
374  m_outputFileXML << output << endl;
375  sprintf(output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
376  m_outputFileXML << output << endl;
377  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
378  m_outputFileXML << " </DATA>" << endl;
379  m_outputFileXML << " </DATA_SET>" << endl;
380  }
381  else if(m_fitflag==3){
382  m_outFile<<detid<<" "<<time4<<" "<<dtime4<<std::endl;
383  m_outputFileXML << " <DATA_SET>" << endl;
384  m_outputFileXML <<" <VERSION>version:1</VERSION>" << endl;
385  m_outputFileXML << " <CHANNEL>" << endl;
386  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
387  sprintf(output, " <ETA>%2i</ETA>", detid.ietaAbs() );
388  m_outputFileXML << output << endl;
389  sprintf(output, " <PHI>%2i</PHI>", detid.iphi() );
390  m_outputFileXML << output << endl;
391  sprintf(output, " <DEPTH>%2i</DEPTH>", detid.depth() );
392  m_outputFileXML << output << endl;
393  sprintf(output, " <Z>%2i</Z>", detid.zside() );
394  m_outputFileXML << output << endl;
395  if(detid.subdet() == 1) m_outputFileXML <<" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
396  if(detid.subdet() == 2) m_outputFileXML <<" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
397  if(detid.subdet() == 3) m_outputFileXML <<" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
398  if(detid.subdet() == 4) m_outputFileXML <<" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
399  sprintf(output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId() );
400  m_outputFileXML << output << endl;
401  m_outputFileXML << " </CHANNEL>" << endl;
402  m_outputFileXML << " <DATA>" << endl;
403  sprintf(output, " <MEAN_TIME>%7f</MEAN_TIME>", time4);
404  m_outputFileXML << output << endl;
405  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
406  sprintf(output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
407  m_outputFileXML << output << endl;
408  sprintf(output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag+1);
409  m_outputFileXML << output << endl;
410  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
411  m_outputFileXML << " </DATA>" << endl;
412  m_outputFileXML << " </DATA_SET>" << endl;
413  }
414 
415  else if(m_fitflag==4){
416  m_outFile<<detid<<" "<<time1<<" "<<dtime1<<" "<<time2<<" "<<dtime2<<" "<<time3<<" "<<dtime3<<" "<<time4<<" "<<dtime4<<std::endl;
417  }
418  }
419  }
420 }
int i
Definition: DBlmapReader.cc:9
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:32
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int depth() const
get the tower depth
Definition: HcalDetId.h:40
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
std::ofstream m_outputFileXML
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:34
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
std::ofstream m_outFile
std::string m_outputFileText
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
void HcalLedAnalysis::LedDone ( )

Definition at line 471 of file HcalLedAnalysis.cc.

References gather_cfg::cout, and compare_using_db::sample.

472 {
473 
474 // First process the last sample (remaining events).
476 
477 // Now do the end of run analysis: trending histos
478  if(sample>1 && m_fitflag!=4){
479  m_file->cd();
480  m_file->cd("HBHE");
481  LedTrendings(hbHists.LEDTRENDS);
482  m_file->cd();
483  m_file->cd("HO");
484  LedTrendings(hoHists.LEDTRENDS);
485  m_file->cd();
486  m_file->cd("HF");
487  LedTrendings(hfHists.LEDTRENDS);
488  }
489 
490  // Write other histograms.
491  // HB
492  m_file->cd();
493  m_file->cd("HBHE");
494  hbHists.ALLLEDS->Write();
495  hbHists.LEDRMS->Write();
496  hbHists.LEDMEAN->Write();
497  // HO
498  m_file->cd();
499  m_file->cd("HO");
500  hoHists.ALLLEDS->Write();
501  hoHists.LEDRMS->Write();
502  hoHists.LEDMEAN->Write();
503  // HF
504  m_file->cd();
505  m_file->cd("HF");
506  hfHists.ALLLEDS->Write();
507  hfHists.LEDRMS->Write();
508  hfHists.LEDMEAN->Write();
509  // Calib
510  m_file->cd();
511  m_file->cd("Calib");
512  for(_meca=calibHists.begin(); _meca!=calibHists.end(); _meca++){
513  _meca->second.avePulse->Write();
514  _meca->second.integPulse->Write();
515  }
516 
517  // Write the histo file and close it
518 // m_file->Write();
519  m_file->Close();
520  cout << "Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
521 }
struct HcalLedAnalysis::@58 hfHists
std::map< HcalCalibDetId, CALIBBUNCH > calibHists
std::string m_outputFileROOT
struct HcalLedAnalysis::@58 hbHists
std::map< HcalCalibDetId, CALIBBUNCH >::iterator _meca
struct HcalLedAnalysis::@58 hoHists
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
tuple cout
Definition: gather_cfg.py:121
void HcalLedAnalysis::LedHBHEHists ( const HcalDetId detid,
const HBHEDataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 644 of file HcalLedAnalysis.cc.

References ecalMGPA::adc(), first, HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalDbService::getPedestal(), i, roll_playback::k, and HBHEDataFrame::size().

644  {
645 
646  map<int,LEDBUNCH> _mei;
647  _meol = toolT.find(detid);
648  _mei = _meol->second;
649 
650  // Reset the histos if we're at the end of a 'bunch'
651  if((evt-1)%m_nevtsample==0 && state[0]){
652  for(int k=0; k<(int)state.size();k++) state[k]=false;
653  for(int i=0; i<16; i++) _mei[i].first->Reset();
654  }
655 
656  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
657 
658 
659  // int maxTS = -1;
660  float max_fC = 0;
661  float ta = 0;
662  m_coder = cond.getHcalCoder(detid);
663  m_ped = cond.getPedestal(detid);
664  m_shape = cond.getHcalShape(m_coder);
665  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
666  int capid = ledDigi[TS].capid();
667  int adc = ledDigi[TS].adc();
668  double fC = m_coder->charge(*m_shape,adc,capid);
669  ta = (fC - m_ped->getValue(capid));
670  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " fC: " << fC << endl;
671  _mei[TS].first->Fill(ta);
672  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
673  if(m_fitflag>1){
674  if(TS==m_startTS)_mei[11].first->Reset();
675  _mei[11].first->SetBinContent(TS+1,ta);
676  }
677  // keep track of max TS and max amplitude (in fC)
678  if (ta > max_fC){
679  max_fC = ta;
680  // maxTS = TS;
681  }
682  }
683 
684  // Now we have a sample with pedestals subtracted and in units of fC
685  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
686  // we now want to use Phil's timing correction. This is not necessary
687  // if we are performing a Landau fit (m_fitflag = 3)
688 
689  float sum=0.;
690  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
691  if(sum>100){
692  if(m_fitflag==2 || m_fitflag==4){
693  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
694  float timmeancorr=BinsizeCorr(timmean);
695  _mei[12].first->Fill(timmeancorr);
696  }
697  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
698  if(m_fitflag==3 || m_fitflag==4){
699  _mei[11].first->Fit("landau","Q");
700  TF1 *fit = _mei[11].first->GetFunction("landau");
701  _mei[13].first->Fill(fit->GetParameter(1));
702  _mei[14].first->Fill(fit->GetParError(1));
703  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
704  }
705  }
706 
707 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
std::vector< bool > state
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
bool first
Definition: L1TdeRCT.cc:75
float BinsizeCorr(float time)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const HcalQIEShape * m_shape
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22
void HcalLedAnalysis::LedHFHists ( const HcalDetId detid,
const HFDataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 774 of file HcalLedAnalysis.cc.

References ecalMGPA::adc(), first, HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalDbService::getPedestal(), i, roll_playback::k, and HFDataFrame::size().

774  {
775 
776  map<int,LEDBUNCH> _mei;
777  _meol = toolT.find(detid);
778  _mei = _meol->second;
779  // Rest the histos if we're at the end of a 'bunch'
780  if((evt-1)%m_nevtsample==0 && state[0]){
781  for(int k=0; k<(int)state.size();k++) state[k]=false;
782  for(int i=0; i<16; i++) _mei[i].first->Reset();
783  }
784 
785  // now we have the signal in fC, let's get rid of that darn pedestal
786  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
787 
788  // int maxTS = -1;
789  float max_fC = 0;
790  float ta = 0;
791  m_coder = cond.getHcalCoder(detid);
792  m_ped = cond.getPedestal(detid);
793  m_shape = cond.getHcalShape(m_coder);
794  //cout << "New Digi!!!!!!!!!!!!!!!!!!!!!!" << endl;
795  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
796  int capid = ledDigi[TS].capid();
797  // BE CAREFUL: this is assuming peds are stored in ADCs
798  int adc = (int)(ledDigi[TS].adc() - m_ped->getValue(capid));
799  if (adc < 0){ adc = 0; } // to prevent negative adcs after ped subtraction, which should really only happen
800  // if you're using the wrong peds.
801  double fC = m_coder->charge(*m_shape,adc,capid);
802  //ta = (fC - m_ped->getValue(capid));
803  ta = fC;
804  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " Ped: " << m_ped->getValue(capid) << " fC: " << fC << endl;
805  _mei[TS].first->Fill(ta);
806  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
807  if(m_fitflag>1){
808  if(TS==m_startTS)_mei[11].first->Reset();
809  _mei[11].first->SetBinContent(TS+1,ta);
810  }
811 
812  // keep track of max TS and max amplitude (in fC)
813  if (ta > max_fC){
814  max_fC = ta;
815  // maxTS = TS;
816  }
817  }
818 
819  // Now we have a sample with pedestals subtracted and in units of fC
820  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
821  // we now want to use Phil's timing correction. This is not necessary
822  // if we are performing a Landau fit (m_fitflag = 3)
823 
824  float sum=0.;
825  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
826  if(sum>100){
827  if(m_fitflag==2 || m_fitflag==4){
828  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
829  float timmeancorr=BinsizeCorr(timmean);
830  _mei[12].first->Fill(timmeancorr);
831  }
832  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
833  if(m_fitflag==3 || m_fitflag==4){
834  _mei[11].first->Fit("landau","Q");
835  TF1 *fit = _mei[11].first->GetFunction("landau");
836  _mei[13].first->Fill(fit->GetParameter(1));
837  _mei[14].first->Fill(fit->GetParError(1));
838  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
839  }
840  }
841 
842 
843 
844 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
std::vector< bool > state
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
bool first
Definition: L1TdeRCT.cc:75
float BinsizeCorr(float time)
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const HcalQIEShape * m_shape
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22
void HcalLedAnalysis::LedHOHists ( const HcalDetId detid,
const HODataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 710 of file HcalLedAnalysis.cc.

References ecalMGPA::adc(), first, HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalDbService::getPedestal(), i, roll_playback::k, and HODataFrame::size().

710  {
711 
712  map<int,LEDBUNCH> _mei;
713  _meol = toolT.find(detid);
714  _mei = _meol->second;
715  // Rest the histos if we're at the end of a 'bunch'
716  if((evt-1)%m_nevtsample==0 && state[0]){
717  for(int k=0; k<(int)state.size();k++) state[k]=false;
718  for(int i=0; i<16; i++) _mei[i].first->Reset();
719  }
720 
721  // now we have the signal in fC, let's get rid of that darn pedestal
722  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
723 
724  // int maxTS = -1;
725  float max_fC = 0;
726  float ta = 0;
727  m_coder = cond.getHcalCoder(detid);
728  m_ped = cond.getPedestal(detid);
729  m_shape = cond.getHcalShape(m_coder);
730  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
731  int capid = ledDigi[TS].capid();
732  int adc = ledDigi[TS].adc();
733  double fC = m_coder->charge(*m_shape,adc,capid);
734  ta = (fC - m_ped->getValue(capid));
735  _mei[TS].first->Fill(ta);
736  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
737  if(m_fitflag>1){
738  if(TS==m_startTS)_mei[11].first->Reset();
739  _mei[11].first->SetBinContent(TS+1,ta);
740  }
741  // keep track of max TS and max amplitude (in fC)
742  if (ta > max_fC){
743  max_fC = ta;
744  // maxTS = TS;
745  }
746  }
747 
748  // Now we have a sample with pedestals subtracted and in units of fC
749  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
750  // we now want to use Phil's timing correction. This is not necessary
751  // if we are performing a Landau fit (m_fitflag = 3)
752 
753  float sum=0.;
754  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
755  if(sum>100){
756  if(m_fitflag==2 || m_fitflag==4){
757  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
758  float timmeancorr=BinsizeCorr(timmean);
759  _mei[12].first->Fill(timmeancorr);
760  }
761  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
762  if(m_fitflag==3 || m_fitflag==4){
763  _mei[11].first->Fit("landau","Q");
764  TF1 *fit = _mei[11].first->GetFunction("landau");
765  _mei[13].first->Fill(fit->GetParameter(1));
766  _mei[14].first->Fill(fit->GetParError(1));
767  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
768  }
769  }
770 
771 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
std::vector< bool > state
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:21
bool first
Definition: L1TdeRCT.cc:75
float BinsizeCorr(float time)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
const HcalQIEShape * m_shape
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22
void HcalLedAnalysis::LedSampleAnalysis ( )

Definition at line 423 of file HcalLedAnalysis.cc.

References compare_using_db::sample.

423  {
424  // it is called every m_nevtsample events (a sample) and the end of run
425  char LedSampleNum[20];
426 
427  sprintf(LedSampleNum,"LedSample_%d",sample);
428  m_file->cd();
429  m_file->mkdir(LedSampleNum);
430  m_file->cd(LedSampleNum);
431 
432 // Compute LED constants for each HB/HE, HO, HF
433  GetLedConst(hbHists.LEDTRENDS);
434  GetLedConst(hoHists.LEDTRENDS);
435  GetLedConst(hfHists.LEDTRENDS);
436 }
struct HcalLedAnalysis::@58 hfHists
struct HcalLedAnalysis::@58 hbHists
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
struct HcalLedAnalysis::@58 hoHists
void HcalLedAnalysis::LedSetup ( const std::string &  m_outputFileROOT)

Definition at line 172 of file HcalLedAnalysis.cc.

172  {
173  // open the histogram file, create directories within
174  m_file=new TFile(m_outputFileROOT.c_str(),"RECREATE");
175  m_file->mkdir("HBHE");
176  m_file->cd();
177  m_file->mkdir("HO");
178  m_file->cd();
179  m_file->mkdir("HF");
180  m_file->cd();
181  m_file->mkdir("Calib");
182  m_file->cd();
183 }
std::string m_outputFileROOT
void HcalLedAnalysis::LedTrendings ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 439 of file HcalLedAnalysis.cc.

References HcalDetId::depth(), cond::rpcobgas::detid, HcalDetId::ieta(), HcalDetId::iphi(), j, and mergeVDriftHistosByStation::name.

440 {
441 
442  for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
443  char name[1024];
444  HcalDetId detid = _meol->first;
445  sprintf(name,"LED timing trend, eta=%d phi=%d depth=%d",detid.ieta(),detid.iphi(),detid.depth());
446  int bins = _meol->second[10+m_fitflag].second.first[0].size();
447  float lo =0.5;
448  float hi = (float)bins+0.5;
449  _meol->second[10+m_fitflag].second.second.push_back(new TH1F(name,name,bins,lo,hi));
450 
451  std::vector<double>::iterator sample_it;
452 // LED timing - put content and errors
453  int j=0;
454  for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
455  sample_it!=_meol->second[10+m_fitflag].second.first[0].end();sample_it++){
456  _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
457  }
458  j=0;
459  for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
460  sample_it!=_meol->second[10+m_fitflag].second.first[1].end();sample_it++){
461  _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
462  }
463  sprintf(name,"Sample (%d events)",m_nevtsample);
464  _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
465  _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle("Peak position");
466  _meol->second[10+m_fitflag].second.second[0]->Write();
467  }
468 }
int depth() const
get the tower depth
Definition: HcalDetId.h:40
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
int j
Definition: DBlmapReader.cc:9
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
void HcalLedAnalysis::ProcessCalibEvent ( int  fiberChan,
HcalCalibDetId  calibId,
const HcalCalibDataFrame digi 
)
private

Definition at line 893 of file HcalLedAnalysis.cc.

References HcalQIESample::adc(), HcalCalibDetId::calibFlavor(), HcalCalibDetId::CalibrationBox, HcalCalibDetId::cboxChannelString(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, HcalCalibDetId::hcalSubdet(), i, HcalCalibDetId::ieta(), HcalCalibDetId::iphi(), mergeVDriftHistosByStation::name, prof2calltree::prefix, HcalCalibDataFrame::sample(), HcalCalibDataFrame::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

893  {
894 
895  _meca = calibHists.find(calibId);
896  if (_meca==calibHists.end()){
897  // if histos for this channel do not exist, first create them
898  char name[1024];
901  std::string sector=(calibId.hcalSubdet()==HcalBarrel)?("HB"):
902  (calibId.hcalSubdet()==HcalEndcap)?("HE"):
903  (calibId.hcalSubdet()==HcalOuter)?("HO"):
904  (calibId.hcalSubdet()==HcalForward)?("HF"):"";
905  sprintf(name,"%s %+d iphi=%d %s",sector.c_str(),calibId.ieta(),calibId.iphi(),calibId.cboxChannelString().c_str());
906  prefix=name;
907  }
908 
909  sprintf(name,"%s Pin Diode Mean",prefix.c_str());
910  calibHists[calibId].avePulse = new TProfile(name,name,10,-0.5,9.5,0,1000);
911  sprintf(name,"%s Pin Diode Current Pulse",prefix.c_str());
912  calibHists[calibId].thisPulse = new TH1F(name,name,10,-0.5,9.5);
913  sprintf(name,"%s Pin Diode Integrated Pulse",prefix.c_str());
914  calibHists[calibId].integPulse = new TH1F(name,name,200,0,500);
915  }
916  else {
917  for (int i=m_startTS; i<digi.size() && i<=m_endTS; i++) {
918  calibHists[calibId].avePulse->Fill(i,digi.sample(i).adc());
919  calibHists[calibId].thisPulse->SetBinContent(i+1,digi.sample(i).adc());
920  }
921  calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
922  }
923 }
int i
Definition: DBlmapReader.cc:9
CalibDetType calibFlavor() const
get the flavor of this calibration detid
std::map< HcalCalibDetId, CALIBBUNCH > calibHists
int adc() const
get the ADC sample
Definition: HcalQIESample.h:22
int ieta() const
get the rbx name (if relevant)
int size() const
total number of samples in the digi
std::string cboxChannelString() const
get the calibration box channel as a string (if relevant)
std::map< HcalCalibDetId, CALIBBUNCH >::iterator _meca
const HcalQIESample & sample(int i) const
access a sample
int iphi() const
get the low-edge iphi (if relevant)
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
void HcalLedAnalysis::processLedEvent ( const HBHEDigiCollection hbhe,
const HODigiCollection ho,
const HFDigiCollection hf,
const HcalCalibDigiCollection calib,
const HcalDbService cond 
)

Definition at line 524 of file HcalLedAnalysis.cc.

References edm::SortedCollection< T, SORT >::begin(), HcalCalibDataFrame::elecId(), edm::SortedCollection< T, SORT >::end(), HcalElectronicsId::fiberChanId(), i, HBHEDataFrame::id(), HFDataFrame::id(), HcalCalibDataFrame::id(), HODataFrame::id(), j, roll_playback::k, compare_using_db::sample, and edm::SortedCollection< T, SORT >::size().

529 {
530  evt++;
531  sample = (evt-1)/m_nevtsample +1;
534 
535  // Calib
536 
537  if (m_usecalib){
538  try{
539  if(!calib.size()) throw (int)calib.size();
540  // this is effectively a loop over electronic channels
541  for (HcalCalibDigiCollection::const_iterator j=calib.begin(); j!=calib.end(); j++){
542  const HcalCalibDataFrame digi = (const HcalCalibDataFrame)(*j);
543  HcalElectronicsId elecId = digi.elecId();
544  HcalCalibDetId calibId = digi.id();
545  ProcessCalibEvent(elecId.fiberChanId(),calibId,digi); //Shouldn't depend on anything in elecId but not sure how else to do it
546  }
547  }
548  catch (int i ) {
549  // m_logFile<< "Event with " << i<<" Calib Digis passed." << std::endl;
550  }
551  }
552 
553 
554  // HB + HE
555  try{
556  if(!hbhe.size()) throw (int)hbhe.size();
557 // this is effectively a loop over electronic channels
558  for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); j++){
559  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
560  for(int k=0; k<(int)state.size();k++) state[k]=true;
561  // See if histos exist for this channel, and if not, create them
562  _meol = hbHists.LEDTRENDS.find(digi.id());
563  if (_meol==hbHists.LEDTRENDS.end()){
564  SetupLEDHists(0,digi.id(),hbHists.LEDTRENDS);
565  }
566  LedHBHEHists(digi.id(),digi,hbHists.LEDTRENDS,cond);
567  }
568  }
569  catch (int i ) {
570 // m_logFile<< "Event with " << i<<" HBHE Digis passed." << std::endl;
571  }
572 
573  // HO
574  try{
575  if(!ho.size()) throw (int)ho.size();
576  for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); j++){
577  const HODataFrame digi = (const HODataFrame)(*j);
578  _meol = hoHists.LEDTRENDS.find(digi.id());
579  if (_meol==hoHists.LEDTRENDS.end()){
580  SetupLEDHists(1,digi.id(),hoHists.LEDTRENDS);
581  }
582  LedHOHists(digi.id(),digi,hoHists.LEDTRENDS,cond);
583  }
584  }
585  catch (int i ) {
586 // m_logFile << "Event with " << i<<" HO Digis passed." << std::endl;
587  }
588 
589  // HF
590  try{
591  if(!hf.size()) throw (int)hf.size();
592  for (HFDigiCollection::const_iterator j=hf.begin(); j!=hf.end(); j++){
593  const HFDataFrame digi = (const HFDataFrame)(*j);
594  _meol = hfHists.LEDTRENDS.find(digi.id());
595  if (_meol==hfHists.LEDTRENDS.end()){
596  SetupLEDHists(2,digi.id(),hfHists.LEDTRENDS);
597  }
598  LedHFHists(digi.id(),digi,hfHists.LEDTRENDS,cond);
599  }
600  }
601  catch (int i ) {
602 // m_logFile << "Event with " << i<<" HF Digis passed." << std::endl;
603  }
604 
605  // Call the function every m_nevtsample events
607 
608 }
int i
Definition: DBlmapReader.cc:9
struct HcalLedAnalysis::@58 hfHists
void LedHBHEHists(const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
std::vector< bool > state
std::vector< HcalCalibDataFrame >::const_iterator const_iterator
const HcalDetId & id() const
Definition: HODataFrame.h:23
const HcalElectronicsId & elecId() const
struct HcalLedAnalysis::@58 hbHists
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
const HcalCalibDetId & id() const
int j
Definition: DBlmapReader.cc:9
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
const_iterator end() const
void LedHFHists(const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
struct HcalLedAnalysis::@58 hoHists
size_type size() const
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
void LedHOHists(const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
const HcalDetId & id() const
Definition: HFDataFrame.h:22
Readout chain identification for Hcal.
const_iterator begin() const
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
void HcalLedAnalysis::SetupLEDHists ( int  id,
const HcalDetId  detid,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT 
)
private

Definition at line 610 of file HcalLedAnalysis.cc.

References HcalDetId::depth(), cond::rpcobgas::detid, i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), and mergeVDriftHistosByStation::name.

610  {
611 
612  string type = "HBHE";
613  if(id==1) type = "HO";
614  if(id==2) type = "HF";
615 
616  _meol = toolT.find(detid);
617  if (_meol==toolT.end()){
618 // if histos for this channel do not exist, create them
619  map<int,LEDBUNCH> insert;
620  char name[1024];
621  for(int i=0; i<10; i++){
622  sprintf(name,"%s Pulse height, eta=%d phi=%d depth=%d TS=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i);
623  insert[i].first = new TH1F(name,name,200,0.,2000.);
624  }
625  sprintf(name,"%s LED Mean pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
626  insert[10].first = new TH1F(name,name,10,-0.5,9.5);
627  sprintf(name,"%s LED Pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
628  insert[11].first = new TH1F(name,name,10,-0.5,9.5);
629  sprintf(name,"%s Mean TS, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
630  insert[12].first = new TH1F(name,name,200,0.,10.);
631  sprintf(name,"%s Peak TS, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
632  insert[13].first = new TH1F(name,name,200,0.,10.);
633  sprintf(name,"%s Peak TS error, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
634  insert[14].first = new TH1F(name,name,200,0.,0.05);
635  sprintf(name,"%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
636  insert[15].first = new TH1F(name,name,100,0.,50.);
637  sprintf(name,"%s Integrated Signal, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
638  insert[16].first = new TH1F(name,name,500,0.,5000.);
639 
640  toolT[detid] = insert;
641  }
642 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
int depth() const
get the tower depth
Definition: HcalDetId.h:40
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol

Member Data Documentation

std::map<HcalCalibDetId,CALIBBUNCH>::iterator HcalLedAnalysis::_meca
private

Definition at line 122 of file HcalLedAnalysis.h.

std::map<HcalDetId,std::map<int,float> >::iterator HcalLedAnalysis::_meee
private

Definition at line 119 of file HcalLedAnalysis.h.

std::map<HcalDetId,std::map<int, LEDBUNCH > >::iterator HcalLedAnalysis::_meol
private

Definition at line 117 of file HcalLedAnalysis.h.

TH1F* HcalLedAnalysis::ALLLEDS

Definition at line 112 of file HcalLedAnalysis.h.

std::map<HcalCalibDetId,CALIBBUNCH> HcalLedAnalysis::calibHists
private

Definition at line 121 of file HcalLedAnalysis.h.

TH1F* HcalLedAnalysis::CHI2

Definition at line 115 of file HcalLedAnalysis.h.

int HcalLedAnalysis::evt
private

Definition at line 125 of file HcalLedAnalysis.h.

int HcalLedAnalysis::evt_curr
private

Definition at line 127 of file HcalLedAnalysis.h.

struct { ... } HcalLedAnalysis::hbHists
struct { ... } HcalLedAnalysis::hfHists
struct { ... } HcalLedAnalysis::hoHists
TH1F* HcalLedAnalysis::LEDMEAN

Definition at line 114 of file HcalLedAnalysis.h.

TH1F* HcalLedAnalysis::LEDRMS

Definition at line 113 of file HcalLedAnalysis.h.

std::map<HcalDetId,std::map<int, LEDBUNCH > > HcalLedAnalysis::LEDTRENDS

Definition at line 111 of file HcalLedAnalysis.h.

std::map<HcalDetId,std::map<int,float> > HcalLedAnalysis::m_AllPedVals
private

Definition at line 118 of file HcalLedAnalysis.h.

const HcalQIECoder* HcalLedAnalysis::m_coder
private

Definition at line 108 of file HcalLedAnalysis.h.

int HcalLedAnalysis::m_endTS
private

Definition at line 93 of file HcalLedAnalysis.h.

TFile* HcalLedAnalysis::m_file
private

Definition at line 74 of file HcalLedAnalysis.h.

int HcalLedAnalysis::m_fitflag
private

Definition at line 105 of file HcalLedAnalysis.h.

int HcalLedAnalysis::m_hiSaveflag
private

Definition at line 95 of file HcalLedAnalysis.h.

std::ofstream HcalLedAnalysis::m_logFile
private

Definition at line 88 of file HcalLedAnalysis.h.

int HcalLedAnalysis::m_nevtsample
private

Definition at line 94 of file HcalLedAnalysis.h.

std::ofstream HcalLedAnalysis::m_outFile
private

Definition at line 87 of file HcalLedAnalysis.h.

std::string HcalLedAnalysis::m_outputFileROOT
private

Definition at line 84 of file HcalLedAnalysis.h.

std::string HcalLedAnalysis::m_outputFileText
private

Definition at line 85 of file HcalLedAnalysis.h.

std::string HcalLedAnalysis::m_outputFileX
private

Definition at line 86 of file HcalLedAnalysis.h.

std::ofstream HcalLedAnalysis::m_outputFileXML
private

Definition at line 89 of file HcalLedAnalysis.h.

const HcalPedestal* HcalLedAnalysis::m_ped
private

Definition at line 109 of file HcalLedAnalysis.h.

const HcalQIEShape* HcalLedAnalysis::m_shape
private

Definition at line 107 of file HcalLedAnalysis.h.

int HcalLedAnalysis::m_startTS
private

Definition at line 92 of file HcalLedAnalysis.h.

bool HcalLedAnalysis::m_usecalib
private

Definition at line 96 of file HcalLedAnalysis.h.

char HcalLedAnalysis::output[100]
private

Definition at line 90 of file HcalLedAnalysis.h.

int HcalLedAnalysis::sample
private

Definition at line 126 of file HcalLedAnalysis.h.

Referenced by svgfig.Curve::Path().

std::vector<bool> HcalLedAnalysis::state
private

Definition at line 128 of file HcalLedAnalysis.h.