CMS 3D CMS Logo

HcalMTCCMonitor.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorTasks/interface/HcalMTCCMonitor.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 
00004 HcalMTCCMonitor::HcalMTCCMonitor() {
00005   occThresh_ = 1.0;
00006   ievt_=0;
00007   shape_=NULL;
00008 }
00009 
00010 HcalMTCCMonitor::~HcalMTCCMonitor() {}
00011 
00012 void HcalMTCCMonitor::reset(){}
00013 
00014 void HcalMTCCMonitor::clearME(){
00015 
00016   if(m_dbe){
00017     m_dbe->setCurrentFolder(baseFolder_);
00018     m_dbe->removeContents();    
00019 
00020     m_dbe->setCurrentFolder(baseFolder_+"/HB");
00021     m_dbe->removeContents();
00022     
00023     m_dbe->setCurrentFolder(baseFolder_+"/HE");
00024     m_dbe->removeContents();
00025 
00026     m_dbe->setCurrentFolder(baseFolder_+"/HO");
00027     m_dbe->removeContents();
00028 
00029   }
00030   return;
00031 }
00032 
00033 void HcalMTCCMonitor::setup(const edm::ParameterSet& ps, DQMStore* dbe){
00034   HcalBaseMonitor::setup(ps,dbe);
00035   baseFolder_ = rootFolder_+"MTCCMonitor";
00036 
00037   etaMax_ = ps.getUntrackedParameter<double>("MaxEta", 29.5);
00038   etaMin_ = ps.getUntrackedParameter<double>("MinEta", -29.5);
00039   etaBins_ = (int)(etaMax_ - etaMin_);
00040   cout << "MTCC eta min/max set to " << etaMin_ << "/" << etaMax_ << endl;
00041   
00042   phiMax_ = ps.getUntrackedParameter<double>("MaxPhi", 73);
00043   phiMin_ = ps.getUntrackedParameter<double>("MinPhi", 0);
00044   phiBins_ = (int)(phiMax_ - phiMin_);
00045   cout << "MTCC phi min/max set to " << phiMin_ << "/" << phiMax_ << endl;
00046   
00047   occThresh_ = ps.getUntrackedParameter<double>("MTCCOccThresh", 10);
00048   cout << "MTCC occupancy threshold set to " << occThresh_ << endl;
00049   
00050   dumpThresh_ = ps.getUntrackedParameter<double>("DumpThreshold", -1);
00051   dumpEtaLo_ = ps.getUntrackedParameter<int>("DumpEtaLow", -1);
00052   dumpEtaHi_ = ps.getUntrackedParameter<int>("DumpEtaHigh", -1);
00053   dumpPhiLo_ = ps.getUntrackedParameter<int>("DumpPhiLow", -1);
00054   dumpPhiHi_ = ps.getUntrackedParameter<int>("DumpPhiHigh", -1);
00055 
00056   ievt_=0;
00057   
00058   if ( m_dbe !=NULL ) {    
00059     m_dbe->setCurrentFolder(baseFolder_);
00060     meTrig_  = m_dbe->book1D("LTC Trigger","LTC Trigger",6,0,5);
00061 
00062     meEVT_ = m_dbe->bookInt("MTCC Event Number");    
00063     meEVT_->Fill(ievt_);
00064  
00065     m_dbe->setCurrentFolder(baseFolder_+"/HB");
00066     hbC.OCC = m_dbe->book2D("HB Geo Occupancy Map","HB Geo Occupancy Map",etaBins_,etaMin_,etaMax_,phiBins_,phiMin_,phiMax_);
00067     hbC.E = m_dbe->book1D("HB Hit Energy","HB Hit Energy",100,0,50);
00068     hbC.DT = m_dbe->book1D("HB DT Trigger Time","HB DT Trigger Time",100,0,9);
00069 
00070     m_dbe->setCurrentFolder(baseFolder_+"/HE");
00071     heC.CSC = m_dbe->book1D("HE Bottom CSC Trigger Time","HE Bottom CSC Trigger Time",100,0,9);
00072     heC.E = m_dbe->book1D("HE Bottom Hit Energy","HE Bottom Hit Energy",100,0,50);
00073     heC.OCC = m_dbe->book2D("HE Bottom Geo Occupancy Map","HE Bottom Geo Occupancy Map",etaBins_,etaMin_,etaMax_,phiBins_,phiMin_,phiMax_);
00074     
00075 
00076     m_dbe->setCurrentFolder(baseFolder_+"/HO");
00077     hoP1.DT = m_dbe->book1D("HO YB2 Top DT Trigger Time","HO YB2 Top DT Trigger Time",100,0,9);
00078     hoM1.DT = m_dbe->book1D("HO YB2 Bottom DT Trigger Time","HO YB2 Bottom DT Trigger Time",100,0,9);
00079     hoP2.DT = m_dbe->book1D("HO YB1/0 Top DT Trigger Time","HO YB1/0 Top DT Trigger Time",100,0,9);
00080     hoM2.DT = m_dbe->book1D("HO YB1/0 Bottom DT Trigger Time","HO YB1/0 Bottom DT Trigger Time",100,0,9);
00081     hoC.OCC = m_dbe->book2D("HO YB Geo Occupancy Map","HO YB Geo Occupancy Map",etaBins_,etaMin_,etaMax_,phiBins_,phiMin_,phiMax_);
00082     hoC.E = m_dbe->book1D("HO YB Hit Energy","HO YB Hit Energy",100,0,50);
00083 
00084   }
00085 
00086   return;
00087 }
00088 
00089 void HcalMTCCMonitor::processEvent(const HBHEDigiCollection& hbhe,
00090                                    const HODigiCollection& ho,
00091                                    const LTCDigiCollection& ltc,
00092                                    const HcalDbService& cond){
00093   
00094   if(!m_dbe) { printf("HcalMTCCMonitor::processEvent   DQMStore not instantiated!!!\n");  return; }
00095   
00096   ievt_++;
00097   meEVT_->Fill(ievt_);
00098   
00099   // get conditions
00100   if(!shape_) shape_ = cond.getHcalShape(); // this one is generic  
00101   dumpDigi(hbhe, ho, cond);
00102 
00103 
00104   if(ltc.size()<1) return;        
00105   LTCDigi trig; 
00106   LTCDigiCollection::const_iterator digiItr = ltc.begin();    
00107   trig = *digiItr;
00108 
00109   if ( m_dbe !=NULL ) {
00110     
00111     for(int t = 0; t<6; t++) if(trig.HasTriggered(t)) meTrig_->Fill(t);
00112 
00113     try{      
00114       for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); j++){
00115         const HBHEDataFrame digi = (const HBHEDataFrame)(*j);   
00116 
00117         calibs_= cond.getHcalCalibrations(digi.id());  // Old method was made private.
00118         const HcalQIECoder* channelCoder = cond.getHcalCoder(digi.id());
00119         HcalCoderDb coder(*channelCoder, *shape_);
00120         CaloSamples tool;
00121         coder.adc2fC(digi,tool);
00122         
00123         int maxI = -1; double maxA = -1e10; float ta=0;
00124         double fc_ampl=0; double mtime = -1;
00125         for (int i=0; i<tool.size(); i++) {
00126           int capid=digi[i].capid();
00127           ta = (tool[i]-calibs_.pedestal(capid)); // pedestal subtraction
00128           fc_ampl+=ta; 
00129           ta*= calibs_.respcorrgain(capid); // fC --> GeV
00130           if(ta>maxA){
00131             maxA=ta;
00132             maxI=i;
00133           }
00134         }
00135         if(fc_ampl<occThresh_) continue;
00136 
00137         double m1 = 0, z=0, p1=0;
00138         int capid=0;
00139         if(maxI!=0){
00140           capid=digi[maxI-1].capid();
00141           m1 = (tool[maxI-1]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00142         }
00143         capid=digi[maxI].capid();
00144         z = (tool[maxI]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00145         
00146         if(maxI!=(tool.size()-1)){
00147           capid=digi[maxI+1].capid();
00148           p1 = (tool[maxI+1]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00149         }
00150         
00151         mtime = m1*(maxI-1) + z*maxI + p1*(maxI+1);
00152         mtime /= (m1 + z + p1);
00153 
00154         if(digi.id().iphi()<73){
00155           if(digi.id().subdet()==HcalBarrel){
00156             hbC.OCC->Fill(digi.id().ieta(),digi.id().iphi());
00157             hbC.E->Fill(fc_ampl);
00158             if(trig.HasTriggered(0)) hbC.DT->Fill(mtime);           
00159           }
00160           else if(digi.id().subdet()==HcalEndcap){
00161             heC.OCC->Fill(digi.id().ieta(),digi.id().iphi());
00162             heC.E->Fill(fc_ampl);           
00163             if(trig.HasTriggered(1)) heC.CSC->Fill(mtime);
00164           }
00165         }
00166       }//loop over digis
00167     }catch (exception& ex) {      
00168       printf("HcalMTCCMonitor::processEvent  No HBHE Digis.\n");
00169     }
00170     
00171     try{      
00172       for (HODigiCollection::const_iterator j=ho.begin(); j!=ho.end(); j++){
00173         const HODataFrame digi = (const HODataFrame)(*j);       
00174         
00175         calibs_= cond.getHcalCalibrations(digi.id());  // Old method was made private.
00176         const HcalQIECoder* channelCoder = cond.getHcalCoder(digi.id());
00177         HcalCoderDb coder(*channelCoder, *shape_);
00178         CaloSamples tool;
00179         coder.adc2fC(digi,tool);
00180         
00181         int maxI = -1; double maxA = -1e10; float ta=0;
00182         double fc_ampl=0; double mtime = -1;
00183         for (int i=0; i<tool.size(); i++) {
00184           int capid=digi[i].capid();
00185           ta = (tool[i]-calibs_.pedestal(capid)); // pedestal subtraction
00186           fc_ampl+=ta; 
00187           ta*=calibs_.respcorrgain(capid); // fC --> GeV
00188           if(ta>maxA){
00189             maxA=ta;
00190             maxI=i;
00191           }
00192         }
00193         if(fc_ampl<occThresh_) continue;
00194 
00195         double m1 = 0, z=0, p1=0;
00196         int capid=0;
00197         if(maxI!=0){
00198           capid=digi[maxI-1].capid();
00199           m1 = (tool[maxI-1]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00200         }
00201         capid=digi[maxI].capid();
00202         z = (tool[maxI]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00203         
00204         if(maxI!=(tool.size()-1)){
00205           capid=digi[maxI+1].capid();
00206           p1 = (tool[maxI+1]-calibs_.pedestal(capid))*calibs_.respcorrgain(capid);
00207         }
00208         
00209         mtime = m1*(maxI-1) + z*maxI + p1*(maxI+1);
00210         mtime /= (m1 + z + p1);
00211 
00212         if(digi.id().iphi()<73){
00213           if(digi.id().ieta()>-5){
00214             hoC.OCC->Fill(digi.id().ieta(),digi.id().iphi());
00215             hoC.E->Fill(fc_ampl);
00216           }
00217         }
00218 
00219         if(digi.id().iphi()<30){
00220           if(digi.id().ieta()>10){
00221             if(trig.HasTriggered(0)) hoP1.DT->Fill(mtime);
00222           }//ieta
00223           else{
00224             if(trig.HasTriggered(0)) hoP2.DT->Fill(mtime);
00225           }//ieta
00226         }//iphi
00227         else{       
00228           if(digi.id().ieta()>10){
00229             if(trig.HasTriggered(0)) hoM1.DT->Fill(mtime);
00230           }//ieta
00231           else{
00232             if(trig.HasTriggered(0)) hoM2.DT->Fill(mtime);
00233           }//ieta
00234         }//iphi
00235       }//loop over digis   
00236     }catch (...) {
00237       printf("HcalMTCCMonitor::processEvent  No HBHE Digis.\n");
00238     }
00239   }//if mdbe
00240   return;
00241 }
00242 
00243 
00244 void HcalMTCCMonitor::dumpDigi(const HBHEDigiCollection& hbhe, const HODigiCollection& ho, const HcalDbService& cond){
00245   if(dumpThresh_<0) return;
00246 
00247   float fc_ampl = 0;
00248   float ta = 0;  
00249   int myPhi = -1;
00250   try{      
00251     bool done = false;
00252     for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end() && !done; j++){
00253       const HBHEDataFrame digi = (const HBHEDataFrame)(*j);     
00254       if(digi.id().ieta()>dumpEtaHi_) continue;
00255       if(digi.id().iphi()>dumpPhiHi_) continue;
00256       if(digi.id().ieta()<dumpEtaLo_) continue;
00257       if(digi.id().iphi()<dumpPhiLo_) continue;
00258 
00259       calibs_= cond.getHcalCalibrations(digi.id());  // Old method was made private.
00260       const HcalQIECoder* channelCoder = cond.getHcalCoder(digi.id());
00261       HcalCoderDb coder(*channelCoder, *shape_);
00262       CaloSamples tool;
00263       coder.adc2fC(digi,tool);
00264 
00265       fc_ampl=0;
00266       for (int i=0; i<tool.size(); i++) {
00267         int capid=digi[i].capid();
00268         ta = (tool[i]-calibs_.pedestal(capid)); // pedestal subtraction
00269         fc_ampl+=ta; 
00270       }
00271       if(fc_ampl>dumpThresh_){done = true; myPhi = digi.id().iphi(); }
00272     }
00273   }catch (...) {
00274     printf("HcalMTCCMonitor::processEvent  No HBHE Digis.\n");
00275   }
00276 
00277   if(fc_ampl>dumpThresh_){
00278     try{      
00279       for(int ieta = dumpEtaLo_; ieta<=dumpEtaHi_; ieta++){
00280         for (HBHEDigiCollection::const_iterator j=hbhe.begin(); j!=hbhe.end(); j++){
00281           const HBHEDataFrame digi = (const HBHEDataFrame)(*j); 
00282           if(digi.id().ieta()!=ieta) continue;
00283           if(digi.id().iphi()!=myPhi) continue;
00284           
00285           calibs_= cond.getHcalCalibrations(digi.id());  // Old method was made private.
00286           const HcalQIECoder* channelCoder = cond.getHcalCoder(digi.id());
00287           HcalCoderDb coder(*channelCoder, *shape_);
00288           CaloSamples tool;
00289           coder.adc2fC(digi,tool);
00290           
00291           printf("iPhi: %d, iEta: %d, BX ampl:",myPhi,ieta);
00292           for (int i=0; i<tool.size(); i++) {
00293             int capid=digi[i].capid();
00294             ta = (tool[i]-calibs_.pedestal(capid)); // pedestal subtraction
00295             printf(" %.3f,",ta);
00296           }
00297           printf("\n");
00298         }
00299       }      
00300     }catch (...) {
00301       printf("HcalMTCCMonitor::processEvent  No HBHE Digis.\n");
00302     }
00303   }
00304 
00305 }
00306 
00307 
00308 //HB (here i define HB as depth=1 and eta <=15)
00309 //HE (here i define HE as depth=2 and eta>16)
00310 //HO(YB+2) (here i define HO/yb+2 as depth=4 and eta>10
00311 //HO(yb+1,yb0) (depth=4 and eta<=10)

Generated on Tue Jun 9 17:33:02 2009 for CMSSW by  doxygen 1.5.4