CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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 = 0;
00293         if (fData.size()>6)
00294     fTSMean = getTime(fData, 4, 6, fSum); // tsmin = 4, tsmax = 6.
00295         //std::cout << "Side= " << iSide << " Section= " << iSection << " Channel= " << iChannel << "\tCharge\t" << fSum <<std::endl; 
00296           if (saturated==true){
00297              h_2D_saturation->Fill(iSide==1?0:1,iSection==1?iChannel-1:iChannel+4,1);
00298           }
00299       
00300         if (iSection == 1) 
00301           {    // EM
00302             if (iSide == 1) {   // Plus
00303               for (unsigned int i = 0; i < fTS; ++i) {
00304                 if (fData[i] > digiThresh) h_ZDCP_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00305               }
00306               if (fSum > digiThresh) {
00307                 h_ZDCP_EM_Charge[iChannel - 1]->Fill(fSum);
00308                 h_ZDCP_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00309                 //std::cout<< "fSum " << fSum << " fTSMean " << fTSMean <<std::endl;
00310               }
00311             } // Plus
00312             if (iSide == -1) {  // Minus
00313               for (unsigned int i = 0; i < fTS; ++i) {
00314                 if (fData[i] > digiThresh) h_ZDCM_EM_Pulse[iChannel - 1]->Fill(i, fData[i]);
00315               }
00316               if (fSum > digiThresh) {
00317                 h_ZDCM_EM_Charge[iChannel - 1]->Fill(fSum);
00318                 h_ZDCM_EM_TSMean[iChannel - 1]->Fill(fTSMean);
00319               }
00320             } // Minus
00321           }// EM
00322       
00323         else if (iSection == 2) 
00324           {    // HAD
00325             if (iSide == 1) {   // Plus 
00326               for (unsigned int i = 0; i < fTS; ++i) {
00327                 if (fData[i] > digiThresh) h_ZDCP_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00328               }
00329               if (fSum > digiThresh) {
00330                 h_ZDCP_HAD_Charge[iChannel - 1]->Fill(fSum);
00331                 h_ZDCP_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00332               }
00333             } // Plus
00334             if (iSide == -1) {  // Minus
00335               for (unsigned int i = 0; i < fTS; ++i) {
00336                 if (fData[i] > digiThresh) h_ZDCM_HAD_Pulse[iChannel - 1]->Fill(i, fData[i]);
00337               } 
00338               if (fSum > digiThresh) {
00339                 h_ZDCM_HAD_Charge[iChannel - 1]->Fill(fSum);
00340                 h_ZDCM_HAD_TSMean[iChannel - 1]->Fill(fTSMean);
00341               }
00342             }// Minus
00343           } // HAD 
00344       } // loop on zdc digi collection
00345 
00346 
00347     //--------------------------------------
00348     // ZDC RecHit part 
00349     //--------------------------------------
00350     for (ZDCRecHitCollection::const_iterator rechit_iter = rechit.begin(); 
00351          rechit_iter != rechit.end(); ++rechit_iter)
00352       {         
00353         HcalZDCDetId id(rechit_iter->id());
00354         int Side      = (rechit_iter->id()).zside();
00355         int Section   = (rechit_iter->id()).section();
00356         int Channel   = (rechit_iter->id()).channel();
00357         //std::cout << "RecHitEnergy  " << zhit->energy() << "  RecHitTime  " << zhit->time() << std::endl;
00358 
00359         if(Section==1)
00360           { //EM
00361             if (Side ==1 ){ // Plus
00362               h_ZDCP_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00363               h_ZDCP_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00364             }
00365             if (Side == -1 ){ //Minus
00366               h_ZDCM_EM_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00367               h_ZDCM_EM_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00368             }
00369           } //EM
00370         else if(Section==2)
00371           { //HAD
00372             if (Side ==1 ){ //Plus
00373               h_ZDCP_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00374               h_ZDCP_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00375             }
00376             if (Side == -1 ){ //Minus
00377               h_ZDCM_HAD_RecHitEnergy[Channel-1]->Fill(rechit_iter->energy());
00378               h_ZDCM_HAD_RecHitTiming[Channel-1]->Fill(rechit_iter->time());
00379             }
00380           } // HAD
00381       } // loop on rechits
00382     
00383 } // end of event processing 
00384 /*
00385 ------------------------------------------------------------------------------------
00386 // This is what we did to find the good signal. After we've started to use only time slice 4,5,6.
00387 bool HcalZDCMonitor::isGood(std::vector<double>fData, double fCut, double fPercentage) {
00388   bool dec = false;
00389   int ts_max = -1;
00390   
00391   ts_max = getTSMax(fData);
00392   if (ts_max == 0 || ts_max == (int)(fData.size() - 1))
00393     return false;
00394   float sum = fData[ts_max - 1] + fData[ts_max + 1];
00395   
00396   // cout << "tsMax " << ts_max << " data[tsmax] " << mData[ts_max] << " sum " << sum << endl;
00397   if (fData[ts_max] > fCut && sum > (fData[ts_max] * fPercentage))
00398     dec = true;
00399   return dec;
00400 } // bool HcalZDCMonitor::isGood
00401 
00402 int HcalZDCMonitor::getTSMax(std::vector<double>fData) 
00403 {
00404   int ts_max = -100;
00405   double max = -999.;
00406   
00407   for (unsigned int j = 0; j < fData.size(); ++j) {
00408     if (max < fData[j]) {
00409       max = fData[j];
00410       ts_max = j;
00411     }
00412   }
00413   return ts_max;
00414 } // int HcalZDCMonitor::getTSMax()
00415 ------------------------------------------------------------------------------------
00416 */
00417 double HcalZDCMonitor::getTime(std::vector<double>fData, unsigned int ts_min, unsigned int ts_max, double &fSum) {
00418   double weightedTime = 0.;
00419   double SumT = 0.; 
00420   double Time = -999.;
00421   double digiThreshf = 99.5;
00422  
00423   for (unsigned int ts=ts_min; ts<=ts_max; ++ts) {
00424     if (fData[ts] > digiThreshf){ 
00425     weightedTime += ts * fData[ts];
00426     SumT += fData[ts];
00427     }
00428   }
00429 
00430   if (SumT > 0.) {
00431     Time = weightedTime / SumT;
00432   }
00433 
00434   fSum = SumT;
00435 
00436   return Time;
00437 
00438 } //double HcalZDCMonitor::getTime()
00439 
00440 
00441 void HcalZDCMonitor::endLuminosityBlock() 
00442 {
00443 
00444     for (int i = 0; i < 5; ++i) {   // EM Channels 
00445         // ZDC Plus 
00446         h_2D_charge->setBinContent(1, i + 1, h_ZDCP_EM_Charge[i]->getMean());
00447         h_2D_TSMean->setBinContent(1, i + 1, h_ZDCP_EM_TSMean[i]->getMean());
00448         h_2D_RecHitEnergy->setBinContent(1, i + 1, h_ZDCP_EM_RecHitEnergy[i]->getMean());
00449         h_2D_RecHitTime->setBinContent(1, i + 1, h_ZDCP_EM_RecHitTiming[i]->getMean());
00450         // ZDC Minus
00451         h_2D_charge->setBinContent(2, i + 1, h_ZDCM_EM_Charge[i]->getMean());
00452         h_2D_TSMean->setBinContent(2, i + 1, h_ZDCM_EM_TSMean[i]->getMean());
00453         h_2D_RecHitEnergy->setBinContent(2, i + 1, h_ZDCM_EM_RecHitEnergy[i]->getMean());
00454         h_2D_RecHitTime->setBinContent(2, i + 1, h_ZDCM_EM_RecHitTiming[i]->getMean());
00455     }
00456 
00457     for (int i = 0; i < 4; ++i) {   // HAD channels 
00458         // ZDC Plus 
00459         h_2D_charge->setBinContent(1, i + 6, h_ZDCP_HAD_Charge[i]->getMean());
00460         h_2D_TSMean->setBinContent(1, i + 6, h_ZDCP_HAD_TSMean[i]->getMean());
00461         h_2D_RecHitEnergy->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitEnergy[i]->getMean());
00462         h_2D_RecHitTime->setBinContent(1, i + 6, h_ZDCP_HAD_RecHitTiming[i]->getMean());
00463         // ZDC Minus
00464         //h_ZDCM_HAD_Pulse[i]->Scale(10. / h_ZDCM_HAD_Pulse[i]->getEntries());
00465         h_2D_charge->setBinContent(2, i + 6, h_ZDCM_HAD_Charge[i]->getMean());
00466         h_2D_TSMean->setBinContent(2, i + 6, h_ZDCM_HAD_TSMean[i]->getMean());
00467         h_2D_RecHitEnergy->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitEnergy[i]->getMean());
00468         h_2D_RecHitTime->setBinContent(2, i + 6, h_ZDCM_HAD_RecHitTiming[i]->getMean());
00469     }
00470 } // void HcalZDCMonitor::endLuminosityBlock()
00471