CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/HcalMonitorTasks/src/HcalZDCMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalZDCMonitor.h"
00002 
00003 HcalZDCMonitor::HcalZDCMonitor() {
00004 }
00005 HcalZDCMonitor::~HcalZDCMonitor() {
00006 }
00007 void HcalZDCMonitor::reset() {
00008 }
00009 
00010 void HcalZDCMonitor::setup(const edm::ParameterSet & ps, DQMStore * dbe) {
00011     HcalBaseMonitor::setup(ps, dbe);
00012 
00013     baseFolder_ = rootFolder_ + "ZDCMonitor_Hcal";
00014 
00015     if (showTiming) {
00016         cpu_timer.reset();
00017         cpu_timer.start();
00018     }
00019 
00020     if (fVerbosity > 0)
00021         std::cout << "<HcalZDCMonitor::setup>  Setting up histograms" << std::endl;
00022 
00023     if (fVerbosity > 1)
00024         std::cout << "<HcalZDCMonitor::setup> Getting variable values from cfg files" << std::endl;
00025 
00026     // Set initial event # to 0
00027     ievt_ = 0;
00028 
00029 //Histograms
00030     if (m_dbe) {
00031         if (fVerbosity > 1)
00032             std::cout << "<HcalZDCMonitor::setup>  Setting up Histograms" << std::endl;
00033 
00034         m_dbe->setCurrentFolder(baseFolder_);
00035         meEVT_ = m_dbe->bookInt("ZDC Event Number");
00036         meEVT_->Fill(ievt_);
00037         char name[128];
00038         char title[128];
00039         
00040         h_2D_charge = m_dbe->book2D("2D_DigiCharge", "Digi Charge (fC)", 2, 0, 2, 9, 0, 9);
00041         h_2D_charge->setBinLabel(1,"ZDC+",1);
00042         h_2D_charge->setBinLabel(2,"ZDC-",1);
00043         h_2D_charge->setBinLabel(1,"EM1",2);
00044         h_2D_charge->setBinLabel(2,"EM2",2);
00045         h_2D_charge->setBinLabel(3,"EM3",2);
00046         h_2D_charge->setBinLabel(4,"EM4",2);
00047         h_2D_charge->setBinLabel(5,"EM5",2);
00048         h_2D_charge->setBinLabel(6,"HAD1",2);
00049         h_2D_charge->setBinLabel(7,"HAD2",2);
00050         h_2D_charge->setBinLabel(8,"HAD3",2);
00051         h_2D_charge->setBinLabel(9,"HAD4",2);
00052 
00053         h_2D_TSMean = m_dbe->book2D("2D_DigiTiming", "Digi Timing", 2, 0, 2, 9, 0, 9);
00054         h_2D_TSMean->setBinLabel(1,"ZDC+",1);
00055         h_2D_TSMean->setBinLabel(2,"ZDC-",1);
00056         h_2D_TSMean->setBinLabel(1,"EM1",2);
00057         h_2D_TSMean->setBinLabel(2,"EM2",2);
00058         h_2D_TSMean->setBinLabel(3,"EM3",2);
00059         h_2D_TSMean->setBinLabel(4,"EM4",2);
00060         h_2D_TSMean->setBinLabel(5,"EM5",2);
00061         h_2D_TSMean->setBinLabel(6,"HAD1",2);
00062         h_2D_TSMean->setBinLabel(7,"HAD2",2);
00063         h_2D_TSMean->setBinLabel(8,"HAD3",2);
00064         h_2D_TSMean->setBinLabel(9,"HAD4",2);
00065 
00066         h_2D_RecHitEnergy = m_dbe->book2D("2D_RecHitEnergy", "Rechit Energy", 2, 0, 2, 9, 0, 9);
00067         h_2D_RecHitEnergy->setBinLabel(1,"ZDC+",1);
00068         h_2D_RecHitEnergy->setBinLabel(2,"ZDC-",1);
00069         h_2D_RecHitEnergy->setBinLabel(1,"EM1",2);
00070         h_2D_RecHitEnergy->setBinLabel(2,"EM2",2);
00071         h_2D_RecHitEnergy->setBinLabel(3,"EM3",2);
00072         h_2D_RecHitEnergy->setBinLabel(4,"EM4",2);
00073         h_2D_RecHitEnergy->setBinLabel(5,"EM5",2);
00074         h_2D_RecHitEnergy->setBinLabel(6,"HAD1",2);
00075         h_2D_RecHitEnergy->setBinLabel(7,"HAD2",2);
00076         h_2D_RecHitEnergy->setBinLabel(8,"HAD3",2);
00077         h_2D_RecHitEnergy->setBinLabel(9,"HAD4",2);
00078 
00079         h_2D_RecHitTime = m_dbe->book2D("2D_RecHitTime", "Rechit Timing", 2, 0, 2, 9, 0, 9);
00080         h_2D_RecHitTime->setBinLabel(1,"ZDC+",1);
00081         h_2D_RecHitTime->setBinLabel(2,"ZDC-",1);
00082         h_2D_RecHitTime->setBinLabel(1,"EM1",2);
00083         h_2D_RecHitTime->setBinLabel(2,"EM2",2);
00084         h_2D_RecHitTime->setBinLabel(3,"EM3",2);
00085         h_2D_RecHitTime->setBinLabel(4,"EM4",2);
00086         h_2D_RecHitTime->setBinLabel(5,"EM5",2);
00087         h_2D_RecHitTime->setBinLabel(6,"HAD1",2);
00088         h_2D_RecHitTime->setBinLabel(7,"HAD2",2);
00089         h_2D_RecHitTime->setBinLabel(8,"HAD3",2);
00090         h_2D_RecHitTime->setBinLabel(9,"HAD4",2);
00091 
00092         h_2D_saturation = m_dbe->book2D("h_2D_QIE", "Saturation Check", 2, 0, 2, 9, 0, 9);
00093         h_2D_saturation->setBinLabel(1,"ZDC+",1);
00094         h_2D_saturation->setBinLabel(2,"ZDC-",1);
00095         h_2D_saturation->setBinLabel(1,"EM1",2);
00096         h_2D_saturation->setBinLabel(2,"EM2",2);
00097         h_2D_saturation->setBinLabel(3,"EM3",2);
00098         h_2D_saturation->setBinLabel(4,"EM4",2);
00099         h_2D_saturation->setBinLabel(5,"EM5",2);
00100         h_2D_saturation->setBinLabel(6,"HAD1",2);
00101         h_2D_saturation->setBinLabel(7,"HAD2",2);
00102         h_2D_saturation->setBinLabel(8,"HAD3",2);
00103         h_2D_saturation->setBinLabel(9,"HAD4",2);
00104         
00105         m_dbe->setCurrentFolder(baseFolder_ + "/Digis");
00106 
00107         for (int i = 0; i < 5; ++i) {
00108             // pulse Plus Side 
00109             sprintf(title, "h_ZDCP_EMChan_%i_Pulse", i + 1);
00110             sprintf(name, "ZDC Plus EM Section Pulse for channel %i", i + 1);
00111             h_ZDCP_EM_Pulse[i] = m_dbe->book1D(title, name, 10, -0.5, 9.5);
00112             h_ZDCP_EM_Pulse[i]->setAxisTitle("Time Slice id",1);
00113             h_ZDCP_EM_Pulse[i]->setAxisTitle("Pulse Height",2);
00114             // pulse Minus Side
00115             sprintf(title, "h_ZDCM_EMChan_%i_Pulse", i + 1);
00116             sprintf(name, "ZDC Minus EM Section Pulse for channel %i", i + 1);
00117             h_ZDCM_EM_Pulse[i] = m_dbe->book1D(title, name, 10, -0.5, 9.5);
00118             h_ZDCM_EM_Pulse[i]->setAxisTitle("Time Slice id",1);
00119             h_ZDCM_EM_Pulse[i]->setAxisTitle("Pulse Height",2);
00120             // integrated charge over 10 time samples
00121             sprintf(title, "h_ZDCP_EMChan_%i_Charge", i + 1);
00122             sprintf(name, "ZDC Plus EM Section Charge for channel %i", i + 1);
00123             h_ZDCP_EM_Charge[i] = m_dbe->book1D(title, name, 1000, 0., 30000.);
00124             h_ZDCP_EM_Charge[i]->setAxisTitle("Charge (fC)",1);
00125             h_ZDCP_EM_Charge[i]->setAxisTitle("Events",2);
00126             // integrated charge over 10 time samples
00127             sprintf(title, "h_ZDCM_EMChan_%i_Charge", i + 1);
00128             sprintf(name, "ZDC Minus EM Section Charge for channel %i", i + 1);
00129             h_ZDCM_EM_Charge[i] = m_dbe->book1D(title, name, 1000, 0., 30000.);
00130             h_ZDCM_EM_Charge[i]->setAxisTitle("Charge (fC)",1);
00131             h_ZDCM_EM_Charge[i]->setAxisTitle("Events",2);
00132             // charge weighted time slice
00133             sprintf(title, "h_ZDCP_EMChan_%i_TSMean", i + 1);
00134             sprintf(name, "ZDC Plus EM Section TSMean for channel %i", i + 1);
00135             h_ZDCP_EM_TSMean[i] = m_dbe->book1D(title, name, 100, -0.5, 9.5);
00136             h_ZDCP_EM_TSMean[i]->setAxisTitle("Timing",1);
00137             h_ZDCP_EM_TSMean[i]->setAxisTitle("Events",2);
00138             // charge weighted time slice
00139             sprintf(title, "h_ZDCM_EMChan_%i_TSMean", i + 1);
00140             sprintf(name, "ZDC Minus EM Section TSMean for channel %i", i + 1);
00141             h_ZDCM_EM_TSMean[i] = m_dbe->book1D(title, name, 100, -0.5, 9.5);
00142             h_ZDCM_EM_TSMean[i]->setAxisTitle("Timing",1);
00143             h_ZDCM_EM_TSMean[i]->setAxisTitle("Events",2);
00144         }
00145 
00146         for (int i = 0; i < 4; ++i) {
00147             // pulse Plus Side 
00148             sprintf(title, "h_ZDCP_HADChan_%i_Pulse", i + 1);
00149             sprintf(name, "ZDC Plus HAD Section Pulse for channel %i", i + 1);
00150             h_ZDCP_HAD_Pulse[i] = m_dbe->book1D(title, name, 10, -0.5, 9.5);
00151             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Time Slice id",1);
00152             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Pulse Height",2);
00153             // pulse Minus Side 
00154             sprintf(title, "h_ZDCM_HADChan_%i_Pulse", i + 1);
00155             sprintf(name, "ZDC Minus HAD Section Pulse for channel %i", i + 1);
00156             h_ZDCM_HAD_Pulse[i] = m_dbe->book1D(title, name, 10, -0.5, 9.5);
00157             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Time Slice id",1);
00158             h_ZDCP_HAD_Pulse[i]->setAxisTitle("Pulse Height",2);
00159             // integrated charge over 10 time samples 
00160             sprintf(title, "h_ZDCP_HADChan_%i_Charge", i + 1);
00161             sprintf(name, "ZDC Plus HAD Section Charge for channel %i", i + 1);
00162             h_ZDCP_HAD_Charge[i] = m_dbe->book1D(title, name, 1000, 0., 30000.);
00163             h_ZDCP_HAD_Charge[i]->setAxisTitle("Charge (fC)",1);
00164             h_ZDCP_HAD_Charge[i]->setAxisTitle("Events",2);
00165             // integrated charge over 10 time samples 
00166             sprintf(title, "h_ZDCM_HADChan_%i_Charge", i + 1);
00167             sprintf(name, "ZDC Minus HAD Section Charge for channel %i", i + 1);
00168             h_ZDCM_HAD_Charge[i] = m_dbe->book1D(title, name, 1000, 0., 30000.);
00169             h_ZDCM_HAD_Charge[i]->setAxisTitle("Charge (fC)",1);
00170             h_ZDCM_HAD_Charge[i]->setAxisTitle("Events",2);
00171             // charge weighted time slice 
00172             sprintf(title, "h_ZDCP_HADChan_%i_TSMean", i + 1);
00173             sprintf(name, "ZDC Plus HAD Section TSMean for channel %i", i + 1);
00174             h_ZDCP_HAD_TSMean[i] = m_dbe->book1D(title, name, 100, -0.5, 9.5);
00175             h_ZDCP_HAD_TSMean[i]->setAxisTitle("Timing",1);
00176             h_ZDCP_HAD_TSMean[i]->setAxisTitle("Events",2);
00177             // charge weighted time slice 
00178             sprintf(title, "h_ZDCM_HADChan_%i_TSMean", i + 1);
00179             sprintf(name, "ZDC Minus HAD Section TSMean for channel %i", i + 1);
00180             h_ZDCM_HAD_TSMean[i] = m_dbe->book1D(title, name, 100, -0.5, 9.5);
00181             h_ZDCM_HAD_TSMean[i]->setAxisTitle("Timing",1);
00182             h_ZDCM_HAD_TSMean[i]->setAxisTitle("Events",2);
00183         }
00184 
00185         m_dbe->setCurrentFolder(baseFolder_ + "/RecHits");
00186 
00187         for (int i = 0; i < 5; ++i) {
00188             //RecHitEnergy Plus Side
00189             sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Energy",i+1);
00190             sprintf(name,"ZDC EM Section Rechit Energy for channel %i",i+1);
00191             h_ZDCP_EM_RecHitEnergy[i] = m_dbe->book1D(title, name, 1010, -100., 10000.);
00192             h_ZDCP_EM_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00193             h_ZDCP_EM_RecHitEnergy[i]->setAxisTitle("Events",2);
00194             //RecHitEnergy Minus Side
00195             sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Energy",i+1);
00196             sprintf(name,"ZDC EM Section Rechit Energy for channel %i",i+1);
00197             h_ZDCM_EM_RecHitEnergy[i] = m_dbe->book1D(title, name, 1010, -100., 10000.);
00198             h_ZDCM_EM_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00199             h_ZDCM_EM_RecHitEnergy[i]->setAxisTitle("Events",2);
00200             //RecHit Timing Plus Side 
00201             sprintf(title,"h_ZDCP_EMChan_%i_RecHit_Timing",i+1);
00202             sprintf(name,"ZDC EM Section Rechit Timing for channel %i",i+1);
00203             h_ZDCP_EM_RecHitTiming[i] = m_dbe->book1D(title, name, 100, -100., 100.);
00204             h_ZDCP_EM_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00205             h_ZDCP_EM_RecHitTiming[i]->setAxisTitle("Events",2);
00206             //RecHit Timing Minus Side 
00207             sprintf(title,"h_ZDCM_EMChan_%i_RecHit_Timing",i+1);
00208             sprintf(name,"ZDC EM Section Rechit Timing for channel %i",i+1);
00209             h_ZDCM_EM_RecHitTiming[i] = m_dbe->book1D(title, name, 100, -100., 100.);   
00210             h_ZDCM_EM_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00211             h_ZDCM_EM_RecHitTiming[i]->setAxisTitle("Events",2);
00212         }
00213 
00214         for (int i = 0; i < 4; ++i) {
00215             //RecHitEnergy Plus Side
00216             sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Energy",i+1);
00217             sprintf(name,"ZDC HAD Section Rechit Energy for channel %i",i+1);
00218             h_ZDCP_HAD_RecHitEnergy[i] = m_dbe->book1D(title, name, 1010, -100., 10000.);
00219             h_ZDCP_HAD_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00220             h_ZDCP_HAD_RecHitEnergy[i]->setAxisTitle("Events",2);
00221             //RecHitEnergy Minus Side
00222             sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Energy",i+1);
00223             sprintf(name,"ZDC HAD Section Rechit Energy for channel %i",i+1);
00224             h_ZDCM_HAD_RecHitEnergy[i] = m_dbe->book1D(title, name, 1010, -100., 10000.);
00225             h_ZDCM_HAD_RecHitEnergy[i]->setAxisTitle("Energy (GeV)",1);
00226             h_ZDCM_HAD_RecHitEnergy[i]->setAxisTitle("Events",2);
00227             //RecHit Timing Plus Side 
00228             sprintf(title,"h_ZDCP_HADChan_%i_RecHit_Timing",i+1);
00229             sprintf(name,"ZDC HAD Section Rechit Timing for channel %i",i+1);
00230             h_ZDCP_HAD_RecHitTiming[i] = m_dbe->book1D(title, name, 100, -100., 100.);  
00231             h_ZDCP_HAD_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00232             h_ZDCP_HAD_RecHitTiming[i]->setAxisTitle("Events",2);
00233             //RecHit Timing Minus Side 
00234             sprintf(title,"h_ZDCM_HADChan_%i_RecHit_Timing",i+1);
00235             sprintf(name,"ZDC HAD Section Rechit Timing for channel %i",i+1);
00236             h_ZDCM_HAD_RecHitTiming[i] = m_dbe->book1D(title, name, 100, -100., 100.);  
00237             h_ZDCM_HAD_RecHitTiming[i]->setAxisTitle("RecHit Time",1);
00238             h_ZDCM_HAD_RecHitTiming[i]->setAxisTitle("Events",2);
00239         }
00240 
00241     }
00242     return;
00243 }
00244 
00245 void HcalZDCMonitor::processEvent(const ZDCDigiCollection& digi, const ZDCRecHitCollection& rechit) {
00246     if (fVerbosity > 0)
00247         std::cout << "<HcalZDCMonitor::processEvent> Processing Event..." << std::endl;
00248     if (showTiming) 
00249       {
00250         cpu_timer.reset();
00251         cpu_timer.start();
00252     }
00253     ++ievt_;
00254     meEVT_->Fill(ievt_);
00255 
00256     //--------------------------------------
00257     // ZDC Digi part 
00258     //--------------------------------------
00259     double fSum = 0.;
00260     std::vector<double> fData;
00261     double digiThresh = 99.5; //corresponds to 40 ADC counts
00262     //int digiThreshADC = 40;
00263     int digiSaturation = 127;
00264     //double ZDCQIEConst = 2.6; 
00265 
00266     for (ZDCDigiCollection::const_iterator digi_iter = digi.begin(); 
00267          digi_iter != digi.end(); ++digi_iter) 
00268       {
00269         const ZDCDataFrame digi = (const ZDCDataFrame) (*digi_iter);
00270         //HcalZDCDetId id(digi_iter->id());
00271         int iSide = digi_iter->id().zside();
00272         int iSection = digi_iter->id().section();
00273         int iChannel = digi_iter->id().channel();
00274         
00275         unsigned int fTS = digi_iter->size();
00276         while (fData.size()<fTS)
00277           fData.push_back(-999);
00278         while (fData.size()>fTS)
00279           fData.pop_back(); // delete last elements 
00280 
00281         fSum = 0.;
00282         bool saturated = false;
00283         for (unsigned int i = 0; i < fTS; ++i) 
00284           {
00285              //fData[i]=digi[i].nominal_fC() * ZDCQIEConst;
00286              fData[i]=digi[i].nominal_fC();
00287              if (digi[i].adc()==digiSaturation){
00288                  saturated=true;
00289              }
00290           }
00291       
00292         double fTSMean = getTime(fData, 4, 6, fSum); // tsmin = 4, tsmax = 6.
00293         //std::cout << "Side= " << iSide << " Section= " << iSection << " Channel= " << iChannel << "\tCharge\t" << fSum <<std::endl; 
00294           if (saturated==true){
00295              h_2D_saturation->Fill(iSide==1?0:1,iSection==1?iChannel-1:iChannel+4,1);
00296           }
00297       
00298         if (iSection == 1) 
00299           {    // EM
00300             if (iSide == 1) {   // Plus
00301               for (unsigned int i = 0; i < fTS; ++i) {
00302                 if (fData[i] > digiThresh) h_ZDCP_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00303               }
00304               if (fSum > digiThresh) {
00305                 h_ZDCP_EM_Charge[iChannel - 1]->Fill(fSum);
00306                 h_ZDCP_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00307                 //std::cout<< "fSum " << fSum << " fTSMean " << fTSMean <<std::endl;
00308               }
00309             } // Plus
00310             if (iSide == -1) {  // Minus
00311               for (unsigned int i = 0; i < fTS; ++i) {
00312                 if (fData[i] > digiThresh) h_ZDCM_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00313               }
00314               if (fSum > digiThresh) {
00315                 h_ZDCM_EM_Charge[iChannel - 1]->Fill(fSum);
00316                 h_ZDCM_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00317               }
00318             } // Minus
00319           }// EM
00320       
00321         else if (iSection == 2) 
00322           {    // HAD
00323             if (iSide == 1) {   // Plus 
00324               for (unsigned int i = 0; i < fTS; ++i) {
00325                 if (fData[i] > digiThresh) h_ZDCP_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00326               }
00327               if (fSum > digiThresh) {
00328                 h_ZDCP_HAD_Charge[iChannel - 1]->Fill(fSum);
00329                 h_ZDCP_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00330               }
00331             } // Plus
00332             if (iSide == -1) {  // Minus
00333               for (unsigned int i = 0; i < fTS; ++i) {
00334                 if (fData[i] > digiThresh) h_ZDCM_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00335               } 
00336               if (fSum > digiThresh) {
00337                 h_ZDCM_HAD_Charge[iChannel - 1]->Fill(fSum);
00338                 h_ZDCM_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00339               }
00340             }// Minus
00341           } // HAD 
00342       } // loop on zdc digi collection
00343 
00344 
00345     //--------------------------------------
00346     // ZDC RecHit part 
00347     //--------------------------------------
00348     for (ZDCRecHitCollection::const_iterator rechit_iter = rechit.begin(); 
00349          rechit_iter != rechit.end(); ++rechit_iter)
00350       {         
00351         HcalZDCDetId id(rechit_iter->id());
00352         int Side      = (rechit_iter->id()).zside();
00353         int Section   = (rechit_iter->id()).section();
00354         int Channel   = (rechit_iter->id()).channel();
00355         //std::cout << "RecHitEnergy  " << zhit->energy() << "  RecHitTime  " << zhit->time() << std::endl;
00356 
00357         if(Section==1)
00358           { //EM
00359             if (Side ==1 ){ // Plus
00360               h_ZDCP_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00361               h_ZDCP_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00362             }
00363             if (Side == -1 ){ //Minus
00364               h_ZDCM_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00365               h_ZDCM_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00366             }
00367           } //EM
00368         else if(Section==2)
00369           { //HAD
00370             if (Side ==1 ){ //Plus
00371               h_ZDCP_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00372               h_ZDCP_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00373             }
00374             if (Side == -1 ){ //Minus
00375               h_ZDCM_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00376               h_ZDCM_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00377             }
00378           } // HAD
00379       } // loop on rechits
00380     
00381 } // end of event processing 
00382 /*
00383 ------------------------------------------------------------------------------------
00384 // This is what we did to find the good signal. After we've started to use only time slice 4,5,6.
00385 bool HcalZDCMonitor::isGood(std::vector<double>fData, double fCut, double fPercentage) {
00386   bool dec = false;
00387   int ts_max = -1;
00388   
00389   ts_max = getTSMax(fData);
00390   if (ts_max == 0 || ts_max == (int)(fData.size() - 1))
00391     return false;
00392   float sum = fData[ts_max - 1] + fData[ts_max + 1];
00393   
00394   // cout << "tsMax " << ts_max << " data[tsmax] " << mData[ts_max] << " sum " << sum << endl;
00395   if (fData[ts_max] > fCut && sum > (fData[ts_max] * fPercentage))
00396     dec = true;
00397   return dec;
00398 } // bool HcalZDCMonitor::isGood
00399 
00400 int HcalZDCMonitor::getTSMax(std::vector<double>fData) 
00401 {
00402   int ts_max = -100;
00403   double max = -999.;
00404   
00405   for (unsigned int j = 0; j < fData.size(); ++j) {
00406     if (max < fData[j]) {
00407       max = fData[j];
00408       ts_max = j;
00409     }
00410   }
00411   return ts_max;
00412 } // int HcalZDCMonitor::getTSMax()
00413 ------------------------------------------------------------------------------------
00414 */
00415 double HcalZDCMonitor::getTime(std::vector<double>fData, unsigned int ts_min, unsigned int ts_max, double &fSum) {
00416   double weightedTime = 0.;
00417   double SumT = 0.; 
00418   double Time = -999.;
00419   double digiThreshf = 99.5;
00420  
00421   for (unsigned int ts=ts_min; ts<=ts_max; ++ts) {
00422     if (fData[ts] > digiThreshf){ 
00423     weightedTime += ts * fData[ts];
00424     SumT += fData[ts];
00425     }
00426   }
00427 
00428   if (SumT > 0.) {
00429     Time = weightedTime / SumT;
00430   }
00431 
00432   fSum = SumT;
00433 
00434   return Time;
00435 
00436 } //double HcalZDCMonitor::getTime()
00437 
00438 
00439 void HcalZDCMonitor::endLuminosityBlock() 
00440 {
00441 
00442     for (int i = 0; i < 5; ++i) {   // EM Channels 
00443         // ZDC Plus 
00444         h_2D_charge->setBinContent(1, i + 1, h_ZDCP_EM_Charge[i]->getMean());
00445         h_2D_TSMean->setBinContent(1, i + 1, h_ZDCP_EM_TSMean[i]->getMean());
00446         h_2D_RecHitEnergy->setBinContent(1, i + 1, h_ZDCP_EM_RecHitEnergy[i]->getMean());
00447         h_2D_RecHitTime->setBinContent(1, i + 1, h_ZDCP_EM_RecHitTiming[i]->getMean());
00448         // ZDC Minus
00449         h_2D_charge->setBinContent(2, i + 1, h_ZDCM_EM_Charge[i]->getMean());
00450         h_2D_TSMean->setBinContent(2, i + 1, h_ZDCM_EM_TSMean[i]->getMean());
00451         h_2D_RecHitEnergy->setBinContent(2, i + 1, h_ZDCM_EM_RecHitEnergy[i]->getMean());
00452         h_2D_RecHitTime->setBinContent(2, i + 1, h_ZDCM_EM_RecHitTiming[i]->getMean());
00453     }
00454 
00455     for (int i = 0; i < 4; ++i) {   // HAD channels 
00456         // ZDC Plus 
00457         h_2D_charge->setBinContent(1, i + 6, h_ZDCP_HAD_Charge[i]->getMean());
00458         h_2D_TSMean->setBinContent(1, i + 6, h_ZDCP_HAD_TSMean[i]->getMean());
00459         h_2D_RecHitEnergy->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitEnergy[i]->getMean());
00460         h_2D_RecHitTime->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitTiming[i]->getMean());
00461         // ZDC Minus
00462         //h_ZDCM_HAD_Pulse[i]->Scale(10. / h_ZDCM_HAD_Pulse[i]->getEntries());
00463         h_2D_charge->setBinContent(2, i + 6, h_ZDCM_HAD_Charge[i]->getMean());
00464         h_2D_TSMean->setBinContent(2, i + 6, h_ZDCM_HAD_TSMean[i]->getMean());
00465         h_2D_RecHitEnergy->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitEnergy[i]->getMean());
00466         h_2D_RecHitTime->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitTiming[i]->getMean());
00467     }
00468 } // void HcalZDCMonitor::endLuminosityBlock()
00469