CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQM/CastorMonitor/src/CastorEventDisplay.cc

Go to the documentation of this file.
00001 #include "DQM/CastorMonitor/interface/CastorEventDisplay.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004 
00005 //***************************************************//
00006 //********** CastorEventDisplay: *******************//
00007 //********** Author: Dmytro Volyanskyy   ************//
00008 //********** Date  : 04.05.2010 (first version) ******// 
00009 //***************************************************//
00012 
00013 //==================================================================//
00014 //======================= Constructor ==============================//
00015 //==================================================================//
00016 CastorEventDisplay::CastorEventDisplay() {
00017   ievt_=0;
00018 }
00019 
00020 //==================================================================//
00021 //======================= Destructor ==============================//
00022 //==================================================================//
00023 CastorEventDisplay::~CastorEventDisplay(){
00024 }
00025 
00026 void CastorEventDisplay::reset(){
00027 }
00028 
00029 
00030 //==========================================================//
00031 //========================= setup ==========================//
00032 //==========================================================//
00033 
00034 void CastorEventDisplay::setup(const edm::ParameterSet& ps, DQMStore* dbe){
00035   
00036   CastorBaseMonitor::setup(ps,dbe);
00037   baseFolder_ = rootFolder_+"CastorEventDisplay";
00038   
00039 
00040   offline_             = ps.getUntrackedParameter<bool>("OfflineMode", false); 
00041 
00042   if(fVerbosity>0) std::cout << "CastorEventDisplay::setup (start)" << std::endl;
00043   
00045   ievt_=0;  allEnergyEvent=0.; maxEnergyEvent=0.;
00046   X_pos=0.; Y_pos=0.; Z_pos=0.;
00047   X_pos_maxE=0.; Y_pos_maxE=0.; Z_pos_maxE=0.;
00048 
00049   if ( m_dbe !=NULL ) {    
00050   m_dbe->setCurrentFolder(baseFolder_);
00051 
00053   meEVT_ = m_dbe->bookInt("EventDisplay Event Number"); // meEVT_->Fill(ievt_);
00054   
00056   meCastor3Dhits = m_dbe->book3D("CASTOR 3D hits- cumulative", "CASTOR 3D hits - cumulative", 30, 1420, 1600, 35, -35, 35, 35, -35, 35);
00057 
00058 
00059   if( offline_ ){
00060   //-- swap z and y axis 
00061   TH3F* Castor3Dhits = meCastor3Dhits->getTH3F();
00062   Castor3Dhits->GetXaxis()->SetTitle("Z [cm]"); //-- also swap x and z
00063   Castor3Dhits->GetYaxis()->SetTitle("X [cm]");
00064   Castor3Dhits->GetZaxis()->SetTitle("Y [cm]");
00065   }
00066 
00068   meCastor3DhitsMaxEnergy = m_dbe->book3D("CASTOR 3D hits- event with the largest deposited E", "CASTOR 3D hits- event with the largest deposited E",  30, 1420, 1600, 20, -30, 30, 20, -30, 30); //-- swap z and y axis
00069 
00070   if( offline_ ){
00071   TH3F* Castor3DhitsMaxEnergy = meCastor3DhitsMaxEnergy->getTH3F();
00072   Castor3DhitsMaxEnergy->GetXaxis()->SetTitle("Z [cm]"); //-- also swap x and z
00073   Castor3DhitsMaxEnergy->GetYaxis()->SetTitle("X [cm]");
00074   Castor3DhitsMaxEnergy->GetZaxis()->SetTitle("Y [cm]");
00075   Castor3DhitsMaxEnergy->SetDrawOption("LEGO2");
00076   }
00077 
00078  } 
00079 
00080   else{
00081   if(fVerbosity>0) std::cout << "CastorEventDisplay::setup - NO DQMStore service" << std::endl; 
00082   }
00083 
00084   if(fVerbosity>0) std::cout << "CastorEventDisplay::setup (end)" << std::endl;
00085   
00086   return;
00087 }
00088 
00089 //==========================================================//
00090 //================== processEvent ==========================//
00091 //==========================================================//
00092 
00093 void CastorEventDisplay::processEvent(const CastorRecHitCollection& castorHits, const CaloGeometry& caloGeometry ){
00094   
00095   if(fVerbosity>0) std::cout << "==>CastorEventDisplay::processEvent !!!"<< std::endl;
00096 
00098    meEVT_->Fill(ievt_);
00099 
00100   if(!m_dbe) { 
00101     if(fVerbosity>0) std::cout <<"CastorEventDisplay::processEvent => DQMStore is not instantiated !!!"<<std::endl;  
00102     return; 
00103   }
00104 
00105    allEnergyEvent=0.;
00106 
00107 
00109   CastorRecHitCollection::const_iterator CASTORiter;
00110 
00111      if(castorHits.size()>0)
00112     {    
00113        if(fVerbosity>0) std::cout << "==>CastorEventDisplay::processEvent: castorHits.size()>0 !!!" << std::endl; 
00114 
00116        for (CASTORiter=castorHits.begin(); CASTORiter!=castorHits.end(); ++CASTORiter) { 
00117         
00119          energy = CASTORiter->energy();    
00120 
00122         HcalCastorDetId CastorID(CASTORiter->detid().rawId());
00123 
00125         //const CaloSubdetectorGeometry* subdetectorGeometry=caloGeometry.getSubdetectorGeometry(CastorID) ; 
00126         //const CaloCellGeometry* cellGeometry =  subdetectorGeometry->getGeometry(CastorID) ;
00127         //X_pos = cellGeometry->getPosition().x() ; Y_pos = cellGeometry->getPosition().y() ; 
00128         //Z_pos = cellGeometry->getPosition().z() ;
00129        
00130         X_pos = caloGeometry.getSubdetectorGeometry(CastorID)->getGeometry(CastorID)->getPosition().x() ;
00131         Y_pos = caloGeometry.getSubdetectorGeometry(CastorID)->getGeometry(CastorID)->getPosition().y() ;
00132         Z_pos = caloGeometry.getSubdetectorGeometry(CastorID)->getGeometry(CastorID)->getPosition().z() ;
00133         
00134         if (energy>0){
00136          allEnergyEvent= allEnergyEvent+energy ;
00138          meCastor3Dhits->Fill(std::abs(Z_pos),X_pos,Y_pos, energy);
00139         }
00140 
00141         if(fVerbosity>0)  std::cout<<"ENERGY="<< energy <<" X_pos="<< X_pos <<" Y_pos="<< Y_pos <<" Z_pos="<< Z_pos << std::endl;   
00142       } //-- end of for loop
00143 
00144 
00145     if(fVerbosity>0)  std::cout<<"TOTAL ENERGY in an event="<< allEnergyEvent << std::endl;
00146 
00147 
00148 
00150     if (allEnergyEvent > maxEnergyEvent) { 
00151      maxEnergyEvent = allEnergyEvent;
00152      meCastor3DhitsMaxEnergy->Reset();
00153      if(fVerbosity>0) std::cout<<"LARGEST ENERGY in an event="<< maxEnergyEvent << std::endl;
00154  
00156      for (CASTORiter=castorHits.begin(); CASTORiter!=castorHits.end(); ++CASTORiter){
00157        HcalCastorDetId CastorID_maxE(CASTORiter->detid().rawId());
00158        X_pos_maxE = caloGeometry.getSubdetectorGeometry(CastorID_maxE)->getGeometry(CastorID_maxE)->getPosition().x() ;
00159        Y_pos_maxE = caloGeometry.getSubdetectorGeometry(CastorID_maxE)->getGeometry(CastorID_maxE)->getPosition().y() ;
00160        Z_pos_maxE = caloGeometry.getSubdetectorGeometry(CastorID_maxE)->getGeometry(CastorID_maxE)->getPosition().z() ;
00161        meCastor3DhitsMaxEnergy->Fill(std::abs(Z_pos_maxE),X_pos_maxE,Y_pos_maxE, CASTORiter->energy() );
00162       }
00163      meCastor3DhitsMaxEnergy->getTH3F()->SetOption("BOX");
00164      meCastor3DhitsMaxEnergy->update();
00165     }
00166   } 
00167 
00168   else { if(fVerbosity>0) std::cout<<"CastorEventDisplay::processEvent NO Castor RecHits !!!"<<std::endl; }
00169 
00170 
00171   if (showTiming) { 
00172       cpu_timer.stop(); std::cout << " TIMER::CastorEventDisplay -> " << cpu_timer.cpuTime() << std::endl; 
00173       cpu_timer.reset(); cpu_timer.start();  
00174     }
00175     
00177   ievt_++; 
00178   
00179   return;
00180 }
00181 
00182