00001 #include "DQM/HcalMonitorTasks/interface/HcalLaserMonitor.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004
00005
00006 HcalLaserMonitor::HcalLaserMonitor() {}
00007 HcalLaserMonitor::~HcalLaserMonitor() {}
00008 void HcalLaserMonitor::reset() {}
00009 void HcalLaserMonitor::done() {}
00010
00011
00012 void HcalLaserMonitor::setup( const edm::ParameterSet& iConfig, DQMStore* dbe ) {
00013 if( fVerbosity ) printf( "-=-=-=-=-=HcalLaserMonitor Setup=-=-=-=-=-\n" );
00014
00015 HcalBaseMonitor::setup( iConfig, dbe );
00016 baseFolder_ = rootFolder_ + "LaserMonitor";
00017
00018 printf( "====================================================\n" );
00019
00020 doPerChannel_ = iConfig.getUntrackedParameter<bool>( "LaserPerChannel", false );
00021 printf( "Laser Monitor per channel set to %s\n", doPerChannel_ ? "true" : "false" );
00022
00023 etaMax_ = iConfig.getUntrackedParameter<double>( "MaxEta", 41.5 );
00024 etaMin_ = iConfig.getUntrackedParameter<double>( "MinEta", -41.5 );
00025 etaBins_ = (int)(etaMax_ - etaMin_);
00026 cout << "Laser Monitor eta min/max set to " << etaMin_ << "/" << etaMax_ << endl;
00027
00028 phiMax_ = iConfig.getUntrackedParameter<double>( "MaxPhi", 73 );
00029 phiMin_ = iConfig.getUntrackedParameter<double>( "MinPhi", 0 );
00030 phiBins_ = (int)(phiMax_ - phiMin_);
00031 cout << "Laser Monitor phi min/max set to " << phiMin_ << "/" << phiMax_ << endl;
00032
00033 sigS0_ = iConfig.getUntrackedParameter<int>( "FirstSignalBin", 0 );
00034 sigS1_ = iConfig.getUntrackedParameter<int>( "LastSignalBin", 9 );
00035 if( sigS0_ < 0 ) {
00036 printf( "HcalLaserMonitor::setup, illegal range for first sample: %d\n", sigS0_ );
00037 sigS0_ = 0;
00038 }
00039 if( sigS1_ > 9 ) {
00040 printf( "HcalLaserMonitor::setup, illegal range for last sample: %d\n", sigS1_ );
00041 sigS1_ = 9;
00042 }
00043 if( sigS0_ > sigS1_ ) {
00044 printf( "HcalLaserMonitor::setup, illegal range for first/last sample: %d/%d\n", sigS0_, sigS1_ );
00045 sigS0_ = 0; sigS1_ = 9;
00046 }
00047 cout << "Laser Monitor signal window set to " << sigS0_ << "-" << sigS1_ << endl;
00048
00049 adcThresh_ = iConfig.getUntrackedParameter<double>( "Laser_ADC_Thresh", -10000 );
00050 cout << "Laser Monitor threshold set to " << adcThresh_ << endl;
00051
00052 printf( "====================================================\n" );
00053
00054 ievt_ = 0;
00055
00056 if( m_dbe ) {
00057 m_dbe->setCurrentFolder( baseFolder_ );
00058 meEVT_ = m_dbe->bookInt( "Laser Task Event Number" );
00059 meEVT_->Fill( ievt_ );
00060
00061 MEAN_MAP_TIME_L1_ = m_dbe->book2D( "Laser Mean Time Depth 1", "Laser Mean Time Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00062 MEAN_MAP_TIME_L2_ = m_dbe->book2D( "Laser Mean Time Depth 2", "Laser Mean Time Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00063 MEAN_MAP_TIME_L3_ = m_dbe->book2D( "Laser Mean Time Depth 3", "Laser Mean Time Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00064 MEAN_MAP_TIME_L4_ = m_dbe->book2D( "Laser Mean Time Depth 4", "Laser Mean Time Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00065 RMS_MAP_TIME_L1_ = m_dbe->book2D( "Laser RMS Time Depth 1", "Laser RMS Time Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00066 RMS_MAP_TIME_L2_ = m_dbe->book2D( "Laser RMS Time Depth 2", "Laser RMS Time Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00067 RMS_MAP_TIME_L3_ = m_dbe->book2D( "Laser RMS Time Depth 3", "Laser RMS Time Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00068 RMS_MAP_TIME_L4_ = m_dbe->book2D( "Laser RMS Time Depth 4", "Laser RMS Time Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00069
00070 MEAN_MAP_ENERGY_L1_ = m_dbe->book2D( "Laser Mean Energy Depth 1", "Laser Mean Energy Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00071 MEAN_MAP_ENERGY_L2_ = m_dbe->book2D( "Laser Mean Energy Depth 2", "Laser Mean Energy Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00072 MEAN_MAP_ENERGY_L3_ = m_dbe->book2D( "Laser Mean Energy Depth 3", "Laser Mean Energy Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00073 MEAN_MAP_ENERGY_L4_ = m_dbe->book2D( "Laser Mean Energy Depth 4", "Laser Mean Energy Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00074 RMS_MAP_ENERGY_L1_ = m_dbe->book2D( "Laser RMS Energy Depth 1", "Laser RMS Energy Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00075 RMS_MAP_ENERGY_L2_ = m_dbe->book2D( "Laser RMS Energy Depth 2", "Laser RMS Energy Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00076 RMS_MAP_ENERGY_L3_ = m_dbe->book2D( "Laser RMS Energy Depth 3", "Laser RMS Energy Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00077 RMS_MAP_ENERGY_L4_ = m_dbe->book2D( "Laser RMS Energy Depth 4", "Laser RMS Energy Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00078
00079 m_dbe->setCurrentFolder( baseFolder_ + "/2DShape" );
00080 MEAN_MAP_SHAPE_L1_ = m_dbe->book2D( "Laser Mean Shape Depth 1", "Laser Mean Shape Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00081 MEAN_MAP_SHAPE_L2_ = m_dbe->book2D( "Laser Mean Shape Depth 2", "Laser Mean Shape Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00082 MEAN_MAP_SHAPE_L3_ = m_dbe->book2D( "Laser Mean Shape Depth 3", "Laser Mean Shape Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00083 MEAN_MAP_SHAPE_L4_ = m_dbe->book2D( "Laser Mean Shape Depth 4", "Laser Mean Shape Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00084 RMS_MAP_SHAPE_L1_ = m_dbe->book2D( "Laser RMS Shape Depth 1", "Laser RMS Shape Depth 1", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00085 RMS_MAP_SHAPE_L2_ = m_dbe->book2D( "Laser RMS Shape Depth 2", "Laser RMS Shape Depth 2", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00086 RMS_MAP_SHAPE_L3_ = m_dbe->book2D( "Laser RMS Shape Depth 3", "Laser RMS Shape Depth 3", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00087 RMS_MAP_SHAPE_L4_ = m_dbe->book2D( "Laser RMS Shape Depth 4", "Laser RMS Shape Depth 4", etaBins_, etaMin_, etaMax_, phiBins_, phiMin_, phiMax_ );
00088
00089 m_dbe->setCurrentFolder( baseFolder_ + "/HB" );
00090 hbHists.allShapePedSub_ = m_dbe->book1D( "HB Ped Subtracted Pulse Shape", "HB Ped Subtracted Pulse Shape", 10, -0.5, 9.5 );
00091
00092 hbHists.rms_shape_ = m_dbe->book1D( "HB Laser Shape RMS Values", "HB Laser Shape RMS Values", 25, 0, 3 );
00093 hbHists.mean_shape_ = m_dbe->book1D( "HB Laser Shape Mean Values", "HB Laser Shape Mean Values", 100, -0.5, 9.5 );
00094
00095 hbHists.allTime_ = m_dbe->book1D( "HB Average Pulse Time", "HB Average Pulse Time", 100, -0.5, 9.5 );
00096 hbHists.rms_time_ = m_dbe->book1D( "HB Laser Time RMS Values", "HB Laser Time RMS Values", 25, 0, 3 );
00097 hbHists.mean_time_ = m_dbe->book1D( "HB Laser Time Mean Values", "HB Laser Time Mean Values", 100, -0.5, 9.5 );
00098
00099 hbHists.allEnergy_ = m_dbe->book1D( "HB Average Pulse Energy", "HB Average Pulse Energy", 1000, 0, 10000 );
00100 hbHists.rms_energy_ = m_dbe->book1D( "HB Laser Energy RMS Values", "HB Laser Energy RMS Values", 100, 0, 400 );
00101 hbHists.mean_energy_ = m_dbe->book1D( "HB Laser Energy Mean Values", "HB Laser Energy Mean Values", 300, 0, 10000 );
00102
00103 m_dbe->setCurrentFolder( baseFolder_+ "/HE" );
00104 heHists.allShapePedSub_ = m_dbe->book1D( "HE Ped Subtracted Pulse Shape", "HE Ped Subtracted Pulse Shape", 10, -0.5, 9.5 );
00105
00106 heHists.rms_shape_ = m_dbe->book1D( "HE Laser Shape RMS Values", "HE Laser Shape RMS Values", 25, 0, 3 );
00107 heHists.mean_shape_ = m_dbe->book1D( "HE Laser Shape Mean Values", "HE Laser Shape Mean Values", 100, -0.5, 9.5 );
00108
00109 heHists.allTime_ = m_dbe->book1D( "HE Average Pulse Time", "HE Average Pulse Time", 100, -0.5, 9.5 );
00110 heHists.rms_time_ = m_dbe->book1D( "HE Laser Time RMS Values", "HE Laser Time RMS Values", 25, 0, 3 );
00111 heHists.mean_time_ = m_dbe->book1D( "HE Laser Time Mean Values", "HE Laser Time Mean Values", 100, -0.5, 9.5 );
00112
00113 heHists.allEnergy_ = m_dbe->book1D( "HE Average Pulse Energy", "HE Average Pulse Energy", 1000, 0, 10000 );
00114 heHists.rms_energy_ = m_dbe->book1D( "HE Laser Energy RMS Values", "HE Laser Energy RMS Values", 100, 0, 400 );
00115 heHists.mean_energy_ = m_dbe->book1D( "HE Laser Energy Mean Values", "HE Laser Energy Mean Values", 300, 0, 10000 );
00116
00117 m_dbe->setCurrentFolder( baseFolder_+ "/HO" );
00118 hoHists.allShapePedSub_ = m_dbe->book1D( "HO Ped Subtracted Pulse Shape", "HO Ped Subtracted Pulse Shape", 10, -0.5, 9.5 );
00119
00120 hoHists.rms_shape_ = m_dbe->book1D( "HO Laser Shape RMS Values", "HO Laser Shape RMS Values", 25, 0, 3 );
00121 hoHists.mean_shape_ = m_dbe->book1D( "HO Laser Shape Mean Values", "HO Laser Shape Mean Values", 100, -0.5, 9.5 );
00122
00123 hoHists.allTime_ = m_dbe->book1D( "HO Average Pulse Time", "HO Average Pulse Time", 100, -0.5, 9.5 );
00124 hoHists.rms_time_ = m_dbe->book1D( "HO Laser Time RMS Values", "HO Laser Time RMS Values", 25, 0, 3 );
00125 hoHists.mean_time_ = m_dbe->book1D( "HO Laser Time Mean Values", "HO Laser Time Mean Values", 100, -0.5, 9.5 );
00126
00127 hoHists.allEnergy_ = m_dbe->book1D( "HO Average Pulse Energy", "HO Average Pulse Energy", 1000, 0, 10000 );
00128 hoHists.rms_energy_ = m_dbe->book1D( "HO Laser Energy RMS Values", "HO Laser Energy RMS Values", 100, 0, 400 );
00129 hoHists.mean_energy_ = m_dbe->book1D( "HO Laser Energy Mean Values", "HO Laser Energy Mean Values", 300, 0, 10000 );
00130
00131 m_dbe->setCurrentFolder( baseFolder_ + "/HF" );
00132 hfHists.allShapePedSub_ = m_dbe->book1D( "HF Ped Subtracted Pulse Shape", "HF Ped Subtracted Pulse Shape", 10, -0.5, 9.5 );
00133
00134 hfHists.rms_shape_ = m_dbe->book1D( "HF Laser Shape RMS Values", "HF Laser Shape RMS Values", 25, 0, 3 );
00135 hfHists.mean_shape_ = m_dbe->book1D( "HF Laser Shape Mean Values", "HF Laser Shape Mean Values", 100, -0.5, 9.5 );
00136
00137 hfHists.allTime_ = m_dbe->book1D( "HF Average Pulse Time", "HF Average Pulse Time", 100, -0.5, 9.5 );
00138 hfHists.rms_time_ = m_dbe->book1D( "HF Laser Time RMS Values", "HF Laser Time RMS Values", 25, 0, 3 );
00139 hfHists.mean_time_ = m_dbe->book1D( "HF Laser Time Mean Values", "HF Laser Time Mean Values", 100, -0.5, 9.5 );
00140
00141 hfHists.allEnergy_ = m_dbe->book1D( "HF Average Pulse Energy", "HF Average Pulse Energy", 1000, 0, 10000 );
00142 hfHists.rms_energy_ = m_dbe->book1D( "HF Laser Energy RMS Values", "HF Laser Energy RMS Values", 100, 0, 400 );
00143 hfHists.mean_energy_ = m_dbe->book1D( "HF Laser Energy Mean Values", "HF Laser Energy Mean Values", 300, 0, 10000 );
00144
00145 m_dbe->setCurrentFolder( baseFolder_ + "/QADCTDC" );
00146 TDCHists.numChannels_ = m_dbe->book1D( "TDC Number of Channels", "TDC Number of Channels", 4, -0.5, 3.5 );
00147
00148 TDCHists.trigger_ = m_dbe->book1D( "TDC Trigger", "TDC Trigger", 25, 12700, 12800 );
00149 TDCHists.clockOptosync_ = m_dbe->book1D( "TDC Clock Optosync", "TDC Clock Optosync", 50, 13900, 14100 );
00150 TDCHists.rawOptosync_ = m_dbe->book1D( "TDC Raw Optosync", "TDC Raw Optosync", 50, 13800, 14000 );
00151
00152 TDCHists.rawOptosync_Trigger_ = m_dbe->book1D( "TDC Raw Optosync Minus Trigger", "TDC Raw Optosync Minus Trigger", 50, 1050, 1250 );
00153
00154 char temp[128];
00155 for( int i = 0; i < 32; i++ ) {
00156 sprintf( temp,"QDC %02d", i );
00157 QADC_[i] = m_dbe->book1D( temp, temp, 41, 0, 4100 );
00158 }
00159 }
00160 }
00161
00162
00163 void HcalLaserMonitor::processEvent( const HBHEDigiCollection& hbhe, const HODigiCollection& ho, const HFDigiCollection& hf, const HcalLaserDigi& laserDigi, const HcalDbService& cond ) {
00164 if( fVerbosity ) printf( "-=-=-=-=-=HcalLaserMonitor processEvent=-=-=-=-=-\n" );
00165
00166 ievt_++;
00167 meEVT_->Fill( ievt_ );
00168
00169 if( !m_dbe ) {
00170 if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - DQMStore not instantiated!\n" );
00171 return;
00172 }
00173
00174 float pedSubTS[10];
00175
00176
00177 try {
00178 for( int ch = 0; ch < 32; ch++ ) {
00179 QADC_[ch]->Fill( laserDigi.qadc(ch) );
00180 }
00181
00182 TDCHists.numChannels_->Fill( laserDigi.tdcHits() );
00183 double tClockOpto = -1, tTrig = -1, tRawOpto = -1;
00184
00185 for( uint hit = 0; hit < laserDigi.tdcHits(); hit++ ) {
00186 if( laserDigi.hitChannel(hit) == 1 && tClockOpto < 0 ) {
00187 tClockOpto = laserDigi.hitNS(hit);
00188 TDCHists.clockOptosync_->Fill( tClockOpto );
00189 }
00190 if( laserDigi.hitChannel(hit) == 2 && tTrig < 0 ) {
00191 tTrig = laserDigi.hitNS(hit);
00192 TDCHists.trigger_->Fill( tTrig );
00193 }
00194 if( laserDigi.hitChannel(hit) == 3 && tRawOpto < 0 ) {
00195 tRawOpto = laserDigi.hitNS(hit);
00196 TDCHists.rawOptosync_->Fill( tRawOpto );
00197 }
00198 }
00199
00200 if( tRawOpto > 0 && tTrig > 0 ) TDCHists.rawOptosync_Trigger_->Fill( tRawOpto - tTrig );
00201 } catch (...) {
00202 if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - No Laser Digis.\n" );
00203 }
00204
00205
00206 try {
00207 for( HBHEDigiCollection::const_iterator iter = hbhe.begin(); iter != hbhe.end(); iter++ ) {
00208 const HBHEDataFrame digi = (const HBHEDataFrame)(*iter);
00209
00210 calibs_= cond.getHcalCalibrations( digi.id() );
00211 const HcalQIECoder *qieCoder = cond.getHcalCoder( digi.id() );
00212 const HcalQIEShape *qieShape = cond.getHcalShape();
00213 HcalCoderDb coder( *qieCoder, *qieShape );
00214
00215 float en = 0, numerator = 0, denominator = 0, maxADC = 0;
00216 int maxTS = 0;
00217
00218 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00219 if( digi.sample(ts).adc() > maxADC ) { maxADC = digi.sample(ts).adc(); maxTS = ts; }
00220 }
00221
00222 CaloSamples linDigi;
00223 coder.adc2fC( digi, linDigi );
00224
00225 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00226
00227
00228
00229 en += linDigi[ts];
00230 if( ts >= (maxTS-1) && ts <= (maxTS+1) ) {
00231
00232
00233 numerator += ts * linDigi[ts];
00234 denominator += linDigi[ts];
00235 }
00236 }
00237
00238 if( en > adcThresh_ ) {
00239 if( digi.id().subdet() == HcalBarrel ) {
00240 hbHists.allEnergy_->Fill(en);
00241 if( denominator != 0 ) hbHists.allTime_->Fill( numerator / denominator );
00242 else if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - Calculation of HB hit time had a zero denominator!\n" );
00243
00244 for( int ts = 0; ts < digi.size(); ts++ ) {
00245
00246
00247
00248
00249
00250 hbHists.allShapePedSub_->Fill( ts, linDigi[ts] );
00251 pedSubTS[ts] = linDigi[ts];
00252 }
00253
00254 if( doPerChannel_ ) perChanHists( HcalBarrel, digi.id(), pedSubTS, hbHists.perChanShape_, hbHists.perChanTime_, hbHists.perChanEnergy_, baseFolder_ );
00255 }
00256 else if( digi.id().subdet() == HcalEndcap ) {
00257 heHists.allEnergy_->Fill(en);
00258 if( denominator != 0 ) heHists.allTime_->Fill( numerator / denominator );
00259 else if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - Calculation of HE hit time had a zero denominator!\n" );
00260
00261 for( int ts = 0; ts < digi.size(); ts++ ) {
00262
00263
00264
00265
00266
00267 heHists.allShapePedSub_->Fill( ts, linDigi[ts] );
00268 pedSubTS[ts] = linDigi[ts];
00269 }
00270
00271 if( doPerChannel_ ) perChanHists( HcalEndcap, digi.id(), pedSubTS, heHists.perChanShape_, heHists.perChanTime_, heHists.perChanEnergy_, baseFolder_ );
00272 }
00273 }
00274 }
00275 } catch (...) {
00276 if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - No HBHE Digis.\n" );
00277 }
00278
00279
00280 try {
00281 for( HODigiCollection::const_iterator iter = ho.begin(); iter != ho.end(); iter++ ) {
00282 const HODataFrame digi = (const HODataFrame)(*iter);
00283
00284 calibs_ = cond.getHcalCalibrations( digi.id() );
00285 const HcalQIECoder *qieCoder = cond.getHcalCoder( digi.id() );
00286 const HcalQIEShape *qieShape = cond.getHcalShape();
00287 HcalCoderDb coder( *qieCoder, *qieShape );
00288
00289 float en = 0, numerator = 0, denominator = 0, maxADC = 0;
00290 int maxTS = 0;
00291
00292 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00293 if( digi.sample(ts).adc() > maxADC ) { maxADC = digi.sample(ts).adc(); maxTS = ts; }
00294 }
00295
00296 CaloSamples linDigi;
00297 coder.adc2fC( digi, linDigi );
00298
00299 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00300
00301
00302
00303 en += linDigi[ts];
00304 if( ts >= (maxTS-1) && ts <= (maxTS+1) ) {
00305
00306
00307 numerator += ts * linDigi[ts];
00308 denominator += linDigi[ts];
00309 }
00310 }
00311
00312 if( en > adcThresh_ ) {
00313 hoHists.allEnergy_->Fill(en);
00314 if( denominator != 0 ) hoHists.allTime_->Fill( numerator / denominator );
00315 else if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - Calculation of HO hit time had a zero denominator!\n" );
00316
00317 for( int ts = 0; ts < digi.size(); ts++ ) {
00318
00319
00320
00321
00322
00323 hoHists.allShapePedSub_->Fill( ts, linDigi[ts] );
00324 pedSubTS[ts] = linDigi[ts];
00325 }
00326 }
00327
00328 if( doPerChannel_ ) perChanHists( HcalOuter, digi.id(), pedSubTS, hoHists.perChanShape_, hoHists.perChanTime_, hoHists.perChanEnergy_, baseFolder_ );
00329 }
00330 } catch (...) {
00331 if( fVerbosity ) cout << "HcalLaserMonitor::processEvent - No HO Digis." << endl;
00332 }
00333
00334
00335 try {
00336 for( HFDigiCollection::const_iterator iter = hf.begin(); iter != hf.end(); iter++ ) {
00337 const HFDataFrame digi = (const HFDataFrame)(*iter);
00338
00339 calibs_ = cond.getHcalCalibrations( digi.id() );
00340 const HcalQIECoder *qieCoder = cond.getHcalCoder( digi.id() );
00341 const HcalQIEShape *qieShape = cond.getHcalShape();
00342 HcalCoderDb coder( *qieCoder, *qieShape );
00343
00344 float en = 0, numerator = 0, denominator = 0, maxADC = 0;
00345 int maxTS = 0;
00346
00347 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00348 if( digi.sample(ts).adc() > maxADC ) { maxADC = digi.sample(ts).adc(); maxTS = ts; }
00349 }
00350
00351 CaloSamples linDigi;
00352 coder.adc2fC( digi, linDigi );
00353
00354 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00355
00356
00357
00358 en += linDigi[ts];
00359 if( ts >= (maxTS-1) && ts <= (maxTS+1) ) {
00360
00361
00362 numerator += ts * linDigi[ts];
00363 denominator += linDigi[ts];
00364 }
00365 }
00366
00367 if( en > adcThresh_) {
00368 hfHists.allEnergy_->Fill(en);
00369 if( denominator != 0 ) hfHists.allTime_->Fill( numerator / denominator );
00370 else if( fVerbosity ) printf( "HcalLaserMonitor::processEvent - Calculation of HF hit time had a zero denominator!\n" );
00371
00372 for( int ts = 0; ts < digi.size(); ts++ ) {
00373
00374
00375
00376
00377
00378 hfHists.allShapePedSub_->Fill( ts, linDigi[ts] );
00379 pedSubTS[ts] = linDigi[ts]; }
00380 }
00381
00382 if( doPerChannel_ ) perChanHists( HcalForward, digi.id(), pedSubTS, hfHists.perChanShape_, hfHists.perChanTime_, hfHists.perChanEnergy_, baseFolder_ );
00383 }
00384 } catch (...) {
00385 if( fVerbosity ) cout << "HcalLaserMonitor::processEvent - No HF Digis." << endl;
00386 }
00387 }
00388
00389
00390 inline void HcalLaserMonitor::perChanHists( const int id, const HcalDetId detid, const float* pedSubTS, map<HcalDetId, MonitorElement*>& tShape, map<HcalDetId, MonitorElement*>& tTime,
00391 map<HcalDetId, MonitorElement*>& tEnergy, const string baseFolder ) {
00392 MonitorElement* _me;
00393 if( m_dbe == NULL ) {
00394 printf( "HcalLaserMonitor::perChanHists - Null MonitorElement!\n" );
00395 return;
00396 }
00397
00398 string type;
00399 if ( id == HcalBarrel ) type = "HB";
00400 else if( id == HcalEndcap ) type = "HE";
00401 else if( id == HcalOuter ) type = "HO";
00402 else if( id == HcalForward ) type = "HF";
00403 else {
00404 printf( "HcalLaserMonitor::perChanHists - ID not understood!\n" );
00405 return;
00406 }
00407
00408 m_dbe->setCurrentFolder( baseFolder + "/" + type + "/Expert" );
00409
00410 meIter_ = tShape.find(detid);
00411 if( meIter_ != tShape.end() ) {
00412 _me = meIter_->second;
00413 if( _me == NULL ) {
00414 printf( "HcalLaserAnalysis::perChanHists - This histo is NULL!!??\n" );
00415 return;
00416 }
00417 else {
00418 float en = 0, numerator = 0, denominator = 0, maxADC = 0;
00419 int maxTS = 0;
00420
00421 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00422 if( pedSubTS[ts] > maxADC ) { maxADC = pedSubTS[ts]; maxTS = ts; }
00423 }
00424 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00425 en += pedSubTS[ts];
00426 if( ts >= (maxTS-1) && ts <= (maxTS+1) ) {
00427 numerator += ts * pedSubTS[ts];
00428 denominator += pedSubTS[ts];
00429 }
00430 _me->Fill( ts, pedSubTS[ts] );
00431 }
00432
00433 _me = tTime[detid];
00434 if( denominator != 0 ) _me->Fill( numerator / denominator );
00435 else if( fVerbosity ) printf( "HcalLaserMonitor::perChanHists - Calculation of hit time had a zero denominator!\n" );
00436
00437 _me = tEnergy[detid];
00438 _me->Fill( en );
00439 }
00440 }
00441 else {
00442 char name[1024];
00443 float en = 0, numerator = 0, denominator = 0, maxADC = 0;
00444 int maxTS = 0;
00445
00446 sprintf( name, "%s Laser Shape ieta=%+03d iphi=%02d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth() );
00447 MonitorElement* insertShape = m_dbe->book1D( name, name, 10, -0.5, 9.5 );
00448
00449 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00450 if( pedSubTS[ts] > maxADC ) { maxADC = pedSubTS[ts]; maxTS = ts; }
00451 insertShape->Fill( ts, pedSubTS[ts] );
00452 }
00453 for( int ts = sigS0_; ts <= sigS1_; ts++ ) {
00454 en += pedSubTS[ts];
00455 if( ts >= (maxTS-1) && ts <= (maxTS+1) ) {
00456 numerator += ts * pedSubTS[ts];
00457 denominator += pedSubTS[ts];
00458 }
00459 }
00460 tShape[detid] = insertShape;
00461
00462 sprintf( name, "%s Laser Time ieta=%+03d iphi=%02d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth() );
00463 MonitorElement* insertTime = m_dbe->book1D( name, name, 100, 0, 10 );
00464 if( denominator != 0 ) insertTime->Fill( numerator / denominator );
00465 else if( fVerbosity ) printf( "HcalLaserMonitor::perChanHists - Calculation of hit time had a zero denominator!\n" );
00466 tTime[detid] = insertTime;
00467
00468 sprintf( name, "%s Laser Energy ieta=%+03d iphi=%02d depth=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth() );
00469 MonitorElement* insertEnergy = m_dbe->book1D( name, name, 250, 0, 5000 );
00470 insertEnergy->Fill(en);
00471 tEnergy[detid] = insertEnergy;
00472 }
00473 }