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
CastorLedAnalysis Class Reference

#include <CastorLedAnalysis.h>

Classes

struct  CALIBBUNCH
 

Public Member Functions

 CastorLedAnalysis (const edm::ParameterSet &ps)
 Constructor. More...
 
void LedDone ()
 
void LedSampleAnalysis ()
 
void LedSetup (const std::string &m_outputFileROOT)
 
void processLedEvent (const CastorDigiCollection &castor, const CastorDbService &cond)
 
 ~CastorLedAnalysis ()
 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 LedCastorHists (const HcalDetId &detid, const CastorDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const CastorDbService &cond)
 
void LedTrendings (std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 
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
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map
< int, LEDBUNCH > >   LEDTRENDS
 
castorHists
 
int evt
 
int evt_curr
 
std::map< HcalDetId, std::map
< int, float > > 
m_AllPedVals
 
const CastorQIECoderm_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 CastorPedestalm_ped
 
const CastorQIEShapem_shape
 
int m_startTS
 
bool m_usecalib
 
char output [100]
 
int sample
 
std::vector< bool > state
 

Detailed Description

Definition at line 33 of file CastorLedAnalysis.h.

Member Typedef Documentation

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

Definition at line 66 of file CastorLedAnalysis.h.

Constructor & Destructor Documentation

CastorLedAnalysis::CastorLedAnalysis ( const edm::ParameterSet ps)

Constructor.

Definition at line 17 of file CastorLedAnalysis.cc.

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

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

Destructor.

All done, clean up!!

Definition at line 133 of file CastorLedAnalysis.cc.

References i.

133  {
135 
136  for(_meol=castorHists.LEDTRENDS.begin(); _meol!=castorHists.LEDTRENDS.end(); _meol++){
137  for(int i=0; i<15; i++) _meol->second[i].first->Delete();
138  }
139 
140  castorHists.ALLLEDS->Delete();
141  castorHists.LEDRMS->Delete();
142  castorHists.LEDMEAN->Delete();
143  castorHists.CHI2->Delete();
144 }
int i
Definition: DBlmapReader.cc:9
struct CastorLedAnalysis::@35 castorHists
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol

Member Function Documentation

float CastorLedAnalysis::BinsizeCorr ( float  time)
private

Definition at line 622 of file CastorLedAnalysis.cc.

References i.

622  {
623 
624 // this is the bin size correction to be applied for laser data (from Andy),
625 // it comes from a pulse shape measured from TB04 data (from Jordan)
626 // This should eventually be replaced with the more thorough treatment from Phil
627 
628  float corrtime=0.;
629  static const float tstrue[32]={0.003, 0.03425, 0.06548, 0.09675, 0.128,
630  0.15925, 0.1905, 0.22175, 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925,
631  0.4405, 0.47175, 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905,
632  0.72175, 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
633  static const float tsreco[32]={-0.00422, 0.01815, 0.04409, 0.07346, 0.09799,
634  0.12192, 0.15072, 0.18158, 0.21397, 0.24865, 0.28448, 0.31973, 0.35449,
635  0.39208, 0.43282, 0.47244, 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966,
636  0.74086, 0.77496, 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982,
637  0.95072, 0.9726};
638 
639  int inttime=(int)time;
640  float restime=time-inttime;
641  for(int i=0; i<=32; i++) {
642  float lolim=0.; float uplim=1.; float tsdown; float tsup;
643  if(i>0){
644  lolim=tsreco[i-1];
645  tsdown=tstrue[i-1];
646  }
647  else tsdown=tstrue[31]-1.;
648  if(i<32){
649  uplim=tsreco[i];
650  tsup=tstrue[i];
651  }
652  else tsup=tstrue[0]+1.;
653  if(restime>=lolim && restime<uplim){
654  corrtime=(tsdown*(uplim-restime)+tsup*(restime-lolim)) / (uplim-lolim);
655  }
656  }
657  corrtime+=inttime;
658 
659  return corrtime;
660 }
int i
Definition: DBlmapReader.cc:9
void CastorLedAnalysis::GetLedConst ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 155 of file CastorLedAnalysis.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().

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

Definition at line 550 of file CastorLedAnalysis.cc.

References ecalMGPA::adc(), first, CastorDbService::getCastorCoder(), CastorDbService::getCastorShape(), CastorDbService::getPedestal(), i, gen::k, and CastorDataFrame::size().

550  {
551 
552  map<int,LEDBUNCH> _mei;
553  _meol = toolT.find(detid);
554  _mei = _meol->second;
555  // Rest the histos if we're at the end of a 'bunch'
556  if((evt-1)%m_nevtsample==0 && state[0]){
557  for(int k=0; k<(int)state.size();k++) state[k]=false;
558  for(int i=0; i<16; i++) _mei[i].first->Reset();
559  }
560 
561  // now we have the signal in fC, let's get rid of that darn pedestal
562  // Most of this is borrowed from CastorSimpleReconstructor, so thanks Jeremy/Phil
563 
564  float max_fC = 0;
565  float ta = 0;
566  m_coder = cond.getCastorCoder(detid);
567  m_ped = cond.getPedestal(detid);
568  m_shape = cond.getCastorShape();
569  //cout << "New Digi!!!!!!!!!!!!!!!!!!!!!!" << endl;
570  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++){
571  int capid = ledDigi[TS].capid();
572  // BE CAREFUL: this is assuming peds are stored in ADCs
573  int adc = (int)(ledDigi[TS].adc() - m_ped->getValue(capid));
574  if (adc < 0){ adc = 0; } // to prevent negative adcs after ped subtraction, which should really only happen
575  // if you're using the wrong peds.
576  double fC = m_coder->charge(*m_shape,adc,capid);
577  //ta = (fC - m_ped->getValue(capid));
578  ta = fC;
579  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " Ped: " << m_ped->getValue(capid) << " fC: " << fC << endl;
580  _mei[TS].first->Fill(ta);
581  _mei[10].first->AddBinContent(TS+1,ta); // This is average pulse, could probably do better (Profile?)
582  if(m_fitflag>1){
583  if(TS==m_startTS)_mei[11].first->Reset();
584  _mei[11].first->SetBinContent(TS+1,ta);
585  }
586 
587  // keep track of max TS and max amplitude (in fC)
588  if (ta > max_fC){
589  max_fC = ta;
590  }
591  }
592 
593  // Now we have a sample with pedestals subtracted and in units of fC
594  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
595  // we now want to use Phil's timing correction. This is not necessary
596  // if we are performing a Landau fit (m_fitflag = 3)
597 
598  float sum=0.;
599  for(int i=0; i<10; i++)sum=sum+_mei[11].first->GetBinContent(i+1);
600  if(sum>100){
601  if(m_fitflag==2 || m_fitflag==4){
602  float timmean=_mei[11].first->GetMean(); // let's use Phil's way instead
603  float timmeancorr=BinsizeCorr(timmean);
604  _mei[12].first->Fill(timmeancorr);
605  }
606  _mei[16].first->Fill(_mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
607  if(m_fitflag==3 || m_fitflag==4){
608  _mei[11].first->Fit("landau","Q");
609  TF1 *fit = _mei[11].first->GetFunction("landau");
610  _mei[13].first->Fill(fit->GetParameter(1));
611  _mei[14].first->Fill(fit->GetParError(1));
612  _mei[15].first->Fill(fit->GetChisquare()/fit->GetNDF());
613  }
614  }
615 
616 
617 
618 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int i
Definition: DBlmapReader.cc:9
float getValue(int fCapId) const
get value for capId = 0..3
std::vector< bool > state
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
const CastorQIEShape * m_shape
const CastorQIEShape * getCastorShape() const
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
bool first
Definition: L1TdeRCT.cc:75
float BinsizeCorr(float time)
const CastorPedestal * m_ped
int k[5][pyjets_maxn]
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
const CastorQIECoder * m_coder
int size() const
total number of samples in the digi
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
void CastorLedAnalysis::LedDone ( )

Definition at line 460 of file CastorLedAnalysis.cc.

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

461 {
462 
463 // First process the last sample (remaining events).
465 
466 // Now do the end of run analysis: trending histos
467  if(sample>1 && m_fitflag!=4){
468  m_file->cd();
469  m_file->cd("Castor");
470  LedTrendings(castorHists.LEDTRENDS);
471  }
472 
473  // Write other histograms.
474  m_file->cd();
475  m_file->cd("Castor");
476  castorHists.ALLLEDS->Write();
477  castorHists.LEDRMS->Write();
478  castorHists.LEDMEAN->Write();
479 
480  // Write the histo file and close it
481 // m_file->Write();
482  m_file->Close();
483  cout << "Castor histograms written to " << m_outputFileROOT.c_str() << endl;
484 }
struct CastorLedAnalysis::@35 castorHists
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
std::string m_outputFileROOT
tuple cout
Definition: gather_cfg.py:121
void CastorLedAnalysis::LedSampleAnalysis ( )

Definition at line 414 of file CastorLedAnalysis.cc.

References compare_using_db::sample.

414  {
415  // it is called every m_nevtsample events (a sample) and the end of run
416  char LedSampleNum[20];
417 
418  sprintf(LedSampleNum,"LedSample_%d",sample);
419  m_file->cd();
420  m_file->mkdir(LedSampleNum);
421  m_file->cd(LedSampleNum);
422 
423 // Compute LED constants
424  GetLedConst(castorHists.LEDTRENDS);
425 }
struct CastorLedAnalysis::@35 castorHists
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void CastorLedAnalysis::LedSetup ( const std::string &  m_outputFileROOT)

Definition at line 147 of file CastorLedAnalysis.cc.

147  {
148  // open the histogram file, create directories within
149  m_file=new TFile(m_outputFileROOT.c_str(),"RECREATE");
150  m_file->mkdir("Castor");
151  m_file->cd();
152 }
std::string m_outputFileROOT
void CastorLedAnalysis::LedTrendings ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 428 of file CastorLedAnalysis.cc.

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

429 {
430 
431  for(_meol=toolT.begin(); _meol!=toolT.end(); _meol++){
432  char name[1024];
433  HcalDetId detid = _meol->first;
434  sprintf(name,"LED timing trend, eta=%d phi=%d depth=%d",detid.ieta(),detid.iphi(),detid.depth());
435  int bins = _meol->second[10+m_fitflag].second.first[0].size();
436  float lo =0.5;
437  float hi = (float)bins+0.5;
438  _meol->second[10+m_fitflag].second.second.push_back(new TH1F(name,name,bins,lo,hi));
439 
440  std::vector<double>::iterator sample_it;
441 // LED timing - put content and errors
442  int j=0;
443  for(sample_it=_meol->second[10+m_fitflag].second.first[0].begin();
444  sample_it!=_meol->second[10+m_fitflag].second.first[0].end();sample_it++){
445  _meol->second[10+m_fitflag].second.second[0]->SetBinContent(++j,*sample_it);
446  }
447  j=0;
448  for(sample_it=_meol->second[10+m_fitflag].second.first[1].begin();
449  sample_it!=_meol->second[10+m_fitflag].second.first[1].end();sample_it++){
450  _meol->second[10+m_fitflag].second.second[0]->SetBinError(++j,*sample_it);
451  }
452  sprintf(name,"Sample (%d events)",m_nevtsample);
453  _meol->second[10+m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
454  _meol->second[10+m_fitflag].second.second[0]->GetYaxis()->SetTitle("Peak position");
455  _meol->second[10+m_fitflag].second.second[0]->Write();
456  }
457 }
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 CastorLedAnalysis::processLedEvent ( const CastorDigiCollection castor,
const CastorDbService cond 
)

Definition at line 487 of file CastorLedAnalysis.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), i, CastorDataFrame::id(), j, compare_using_db::sample, and edm::SortedCollection< T, SORT >::size().

489 {
490  evt++;
491  sample = (evt-1)/m_nevtsample +1;
494 
495  // HF/Castor
496  try{
497  if(!castor.size()) throw (int)castor.size();
498  for (CastorDigiCollection::const_iterator j=castor.begin(); j!=castor.end(); j++){
499  const CastorDataFrame digi = (const CastorDataFrame)(*j);
500  _meol = castorHists.LEDTRENDS.find(digi.id());
501  if (_meol==castorHists.LEDTRENDS.end()){
502  SetupLEDHists(2,digi.id(),castorHists.LEDTRENDS);
503  }
504  LedCastorHists(digi.id(),digi,castorHists.LEDTRENDS,cond);
505  }
506  }
507  catch (int i ) {
508 // m_logFile << "Event with " << i<<" Castor Digis passed." << std::endl;
509  }
510 
511  // Call the function every m_nevtsample events
513 
514 }
int i
Definition: DBlmapReader.cc:9
std::vector< CastorDataFrame >::const_iterator const_iterator
struct CastorLedAnalysis::@35 castorHists
void LedCastorHists(const HcalDetId &detid, const CastorDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const CastorDbService &cond)
int j
Definition: DBlmapReader.cc:9
const_iterator end() const
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
size_type size() const
const HcalCastorDetId & id() const
const_iterator begin() const
void CastorLedAnalysis::SetupLEDHists ( int  id,
const HcalDetId  detid,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT 
)
private

Definition at line 516 of file CastorLedAnalysis.cc.

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

516  {
517 
518  string type = "HBHE";
519  if(id==1) type = "HO";
520  if(id==2) type = "HF";
521 
522  _meol = toolT.find(detid);
523  if (_meol==toolT.end()){
524 // if histos for this channel do not exist, create them
525  map<int,LEDBUNCH> insert;
526  char name[1024];
527  for(int i=0; i<10; i++){
528  sprintf(name,"%s Pulse height, eta=%d phi=%d depth=%d TS=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth(),i);
529  insert[i].first = new TH1F(name,name,200,0.,2000.);
530  }
531  sprintf(name,"%s LED Mean pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
532  insert[10].first = new TH1F(name,name,10,-0.5,9.5);
533  sprintf(name,"%s LED Pulse, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
534  insert[11].first = new TH1F(name,name,10,-0.5,9.5);
535  sprintf(name,"%s Mean TS, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
536  insert[12].first = new TH1F(name,name,200,0.,10.);
537  sprintf(name,"%s Peak TS, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
538  insert[13].first = new TH1F(name,name,200,0.,10.);
539  sprintf(name,"%s Peak TS error, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
540  insert[14].first = new TH1F(name,name,200,0.,0.05);
541  sprintf(name,"%s Fit chi2, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
542  insert[15].first = new TH1F(name,name,100,0.,50.);
543  sprintf(name,"%s Integrated Signal, eta=%d phi=%d depth=%d",type.c_str(),detid.ieta(),detid.iphi(),detid.depth());
544  insert[16].first = new TH1F(name,name,500,0.,5000.);
545 
546  toolT[detid] = insert;
547  }
548 }
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 CastorLedAnalysis::_meca
private

Definition at line 116 of file CastorLedAnalysis.h.

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

Definition at line 114 of file CastorLedAnalysis.h.

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

Definition at line 112 of file CastorLedAnalysis.h.

TH1F* CastorLedAnalysis::ALLLEDS

Definition at line 107 of file CastorLedAnalysis.h.

struct { ... } CastorLedAnalysis::castorHists
TH1F* CastorLedAnalysis::CHI2

Definition at line 110 of file CastorLedAnalysis.h.

int CastorLedAnalysis::evt
private

Definition at line 119 of file CastorLedAnalysis.h.

int CastorLedAnalysis::evt_curr
private

Definition at line 121 of file CastorLedAnalysis.h.

TH1F* CastorLedAnalysis::LEDMEAN

Definition at line 109 of file CastorLedAnalysis.h.

TH1F* CastorLedAnalysis::LEDRMS

Definition at line 108 of file CastorLedAnalysis.h.

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

Definition at line 106 of file CastorLedAnalysis.h.

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

Definition at line 113 of file CastorLedAnalysis.h.

const CastorQIECoder* CastorLedAnalysis::m_coder
private

Definition at line 103 of file CastorLedAnalysis.h.

int CastorLedAnalysis::m_endTS
private

Definition at line 88 of file CastorLedAnalysis.h.

TFile* CastorLedAnalysis::m_file
private

Definition at line 72 of file CastorLedAnalysis.h.

int CastorLedAnalysis::m_fitflag
private

Definition at line 100 of file CastorLedAnalysis.h.

int CastorLedAnalysis::m_hiSaveflag
private

Definition at line 90 of file CastorLedAnalysis.h.

std::ofstream CastorLedAnalysis::m_logFile
private

Definition at line 83 of file CastorLedAnalysis.h.

int CastorLedAnalysis::m_nevtsample
private

Definition at line 89 of file CastorLedAnalysis.h.

std::ofstream CastorLedAnalysis::m_outFile
private

Definition at line 82 of file CastorLedAnalysis.h.

std::string CastorLedAnalysis::m_outputFileROOT
private

Definition at line 79 of file CastorLedAnalysis.h.

std::string CastorLedAnalysis::m_outputFileText
private

Definition at line 80 of file CastorLedAnalysis.h.

std::string CastorLedAnalysis::m_outputFileX
private

Definition at line 81 of file CastorLedAnalysis.h.

std::ofstream CastorLedAnalysis::m_outputFileXML
private

Definition at line 84 of file CastorLedAnalysis.h.

const CastorPedestal* CastorLedAnalysis::m_ped
private

Definition at line 104 of file CastorLedAnalysis.h.

const CastorQIEShape* CastorLedAnalysis::m_shape
private

Definition at line 102 of file CastorLedAnalysis.h.

int CastorLedAnalysis::m_startTS
private

Definition at line 87 of file CastorLedAnalysis.h.

bool CastorLedAnalysis::m_usecalib
private

Definition at line 91 of file CastorLedAnalysis.h.

char CastorLedAnalysis::output[100]
private

Definition at line 85 of file CastorLedAnalysis.h.

int CastorLedAnalysis::sample
private

Definition at line 120 of file CastorLedAnalysis.h.

Referenced by svgfig.Curve::Path().

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

Definition at line 122 of file CastorLedAnalysis.h.