CMS 3D CMS Logo

DQMSourcePi0.cc

Go to the documentation of this file.
00001 #include "FWCore/Framework/interface/Event.h"
00002 #include "FWCore/Framework/interface/EventSetup.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/ServiceRegistry/interface/Service.h"
00005 
00006 // DQM include files
00007 
00008 #include "DQMServices/Core/interface/MonitorElement.h"
00009 
00010 // work on collections
00011 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00012 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00013 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00014 
00015 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00016 
00017 #include "DQMServices/Core/interface/DQMStore.h"
00018 #include "DQMOffline/CalibCalo/src/DQMSourcePi0.h"
00019 
00020 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00021 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00022 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00023 #include "DataFormats/DetId/interface/DetId.h"
00024 #include "DataFormats/Math/interface/Point3D.h"
00025 
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "FWCore/Framework/interface/EventSetup.h"
00028 #include "DataFormats/Common/interface/Handle.h"
00029 #include "FWCore/Framework/interface/ESHandle.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 
00032 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00033 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
00035 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
00036 #include "RecoEcal/EgammaCoreTools/interface/EcalEtaPhiRegion.h"
00037 
00038 #include "TVector3.h"
00039 
00040 #define TWOPI 6.283185308
00041 
00042 
00043 
00044 using namespace std;
00045 using namespace edm;
00046 
00047 
00048 // ******************************************
00049 // constructors
00050 // *****************************************
00051 
00052 DQMSourcePi0::DQMSourcePi0( const edm::ParameterSet& ps ) :
00053 eventCounter_(0)
00054 {
00055   dbe_ = Service<DQMStore>().operator->();
00056   folderName_ = ps.getUntrackedParameter<string>("FolderName","HLT/AlCaEcalPi0");
00057   prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor",1);
00058   productMonitoredEB_= ps.getUntrackedParameter<edm::InputTag>("AlCaStreamEBTag");
00059   productMonitoredEE_= ps.getUntrackedParameter<edm::InputTag>("AlCaStreamEETag");
00060   isMonEB_ = ps.getUntrackedParameter<bool>("isMonEB",false);
00061   isMonEE_ = ps.getUntrackedParameter<bool>("isMonEE",false);
00062 
00063   saveToFile_=ps.getUntrackedParameter<bool>("SaveToFile",false);
00064   fileName_=  ps.getUntrackedParameter<string>("FileName","MonitorAlCaEcalPi0.root");
00065 
00066   gammaCandEtaSize_ = ps.getParameter<int> ("gammaCandEtaSize");
00067   gammaCandPhiSize_ = ps.getParameter<int> ("gammaCandPhiSize");
00068   if ( gammaCandPhiSize_ % 2 == 0 ||  gammaCandEtaSize_ % 2 == 0)
00069     edm::LogError("AlCaPi0RecHitsProducerError") << "Size of eta/phi for sliding window should be odd numbers";
00070 
00071   clusSeedThr_ = ps.getParameter<double> ("clusSeedThr");
00072   clusEtaSize_ = ps.getParameter<int> ("clusEtaSize");
00073   clusPhiSize_ = ps.getParameter<int> ("clusPhiSize");
00074   if ( clusPhiSize_ % 2 == 0 ||  clusEtaSize_ % 2 == 0)
00075     edm::LogError("AlCaPi0RecHitsProducerError") << "Size of eta/phi for simple clustering should be odd numbers";
00076 
00077   selePtGammaOne_ = ps.getParameter<double> ("selePtGammaOne");  
00078   selePtGammaTwo_ = ps.getParameter<double> ("selePtGammaTwo");  
00079   selePtPi0_ = ps.getParameter<double> ("selePtPi0");  
00080   seleMinvMaxPi0_ = ps.getParameter<double> ("seleMinvMaxPi0");  
00081   seleMinvMinPi0_ = ps.getParameter<double> ("seleMinvMinPi0");  
00082   seleXtalMinEnergy_ = ps.getParameter<double> ("seleXtalMinEnergy");
00083   seleNRHMax_ = ps.getParameter<int> ("seleNRHMax");
00084   //New Selection
00085   seleS4S9GammaOne_ = ps.getParameter<double> ("seleS4S9GammaOne");  
00086   seleS4S9GammaTwo_ = ps.getParameter<double> ("seleS4S9GammaTwo");  
00087   selePi0Iso_ = ps.getParameter<double> ("selePi0Iso");  
00088   selePi0BeltDR_ = ps.getParameter<double> ("selePi0BeltDR");  
00089   selePi0BeltDeta_ = ps.getParameter<double> ("selePi0BeltDeta");  
00090 
00091   ParameterLogWeighted_ = ps.getParameter<bool> ("ParameterLogWeighted");
00092   ParameterX0_ = ps.getParameter<double> ("ParameterX0");
00093   ParameterT0_barl_ = ps.getParameter<double> ("ParameterT0_barl");
00094   ParameterW0_ = ps.getParameter<double> ("ParameterW0");
00095 
00096 
00097 
00098 }
00099 
00100 
00101 DQMSourcePi0::~DQMSourcePi0()
00102 {}
00103 
00104 
00105 //--------------------------------------------------------
00106 void DQMSourcePi0::beginJob(const EventSetup& context){
00107 
00108 
00109   // create and cd into new folder
00110   dbe_->setCurrentFolder(folderName_);
00111 
00112   // book some histograms 1D
00113 
00114   hiPhiDistrEB_ = dbe_->book1D("iphiDistributionEB", "RechitEB iphi", 361, 1,361);
00115 
00116   hiPhiDistrEB_->setAxisTitle("i#phi ", 1);
00117   hiPhiDistrEB_->setAxisTitle("# rechits", 2);
00118 
00119 
00120   hiEtaDistrEB_ = dbe_->book1D("iEtaDistributionEB", "RechitEB ieta", 171, -85, 86);
00121   hiEtaDistrEB_->setAxisTitle("eta", 1);
00122   hiEtaDistrEB_->setAxisTitle("#rechits", 2);
00123 
00124 
00125   hRechitEnergyEB_ = dbe_->book1D("rhEnergyEB","rechits energy EB",160,0.,2.0);
00126   hRechitEnergyEB_->setAxisTitle("energy (GeV) ",1);
00127   hRechitEnergyEB_->setAxisTitle("#rechits",2);
00128 
00129   hEventEnergyEB_ = dbe_->book1D("eventEnergyEB","event energy EB",100,0.,20.0);
00130   hEventEnergyEB_->setAxisTitle("energy (GeV) ",1);
00131 
00132   hNRecHitsEB_ = dbe_->book1D("nRechitsEB","#rechits in event EB",100,0.,250.);
00133   hNRecHitsEB_->setAxisTitle("rechits ",1);
00134   
00135   hMeanRecHitEnergyEB_ = dbe_->book1D("meanEnergyEB","Mean rechit energy EB",50,0.,2.);
00136   hMeanRecHitEnergyEB_->setAxisTitle("Mean Energy [GeV] ",1);
00137   
00138   hMinvPi0EB_ = dbe_->book1D("Pi0InvmassEB","Pi0 Invariant Mass in EB",100,0.,0.5);
00139   hMinvPi0EB_->setAxisTitle("Inv Mass [GeV] ",1);
00140 
00141   
00142   hPt1Pi0EB_ = dbe_->book1D("Pt1Pi0EB","Pt 1st most energetic Pi0 photon in EB",100,0.,20.);
00143   hPt1Pi0EB_->setAxisTitle("1st photon Pt [GeV] ",1);
00144   
00145   hPt2Pi0EB_ = dbe_->book1D("Pt2Pi0EB","Pt 2nd most energetic Pi0 photon in EB",100,0.,20.);
00146   hPt2Pi0EB_->setAxisTitle("2nd photon Pt [GeV] ",1);
00147 
00148   
00149   hPtPi0EB_ = dbe_->book1D("PtPi0EB","Pi0 Pt in EB",100,0.,20.);
00150   hPtPi0EB_->setAxisTitle("Pi0 Pt [GeV] ",1);
00151 
00152   hIsoPi0EB_ = dbe_->book1D("IsoPi0EB","Pi0 Iso in EB",50,0.,1.);
00153   hIsoPi0EB_->setAxisTitle("Pi0 Iso",1);
00154 
00155   hS4S91EB_ = dbe_->book1D("S4S91EB","S4S9 1st most energetic Pi0 photon in EB",50,0.,1.);
00156   hS4S91EB_->setAxisTitle("S4S9 of the 1st Pi0 Photon ",1);
00157 
00158   hS4S92EB_ = dbe_->book1D("S4S92EB","S4S9 2nd most energetic Pi0 photon in EB",50,0.,1.);
00159   hS4S92EB_->setAxisTitle("S4S9 of the 2nd Pi0 Photon",1);
00160 
00161   
00162 
00163   hRechitEnergyEE_ = dbe_->book1D("rhEnergyEE","rechits energy EE",160,0.,3.0);
00164   hRechitEnergyEE_->setAxisTitle("energy (GeV) ",1);
00165   hRechitEnergyEE_->setAxisTitle("#rechits",2);
00166 
00167   hEventEnergyEE_ = dbe_->book1D("eventEnergyEE","event energy EE",100,0.,20.0);
00168   hEventEnergyEE_->setAxisTitle("energy (GeV) ",1);
00169 
00170   hNRecHitsEE_ = dbe_->book1D("nRechitsEE","#rechits in event EE" ,100,0.,250.);
00171   hNRecHitsEE_->setAxisTitle("rechits ",1);
00172  
00173   hMeanRecHitEnergyEE_ = dbe_->book1D("meanEnergyEE","Mean rechit energy EE",50,0.,5.);
00174   hMeanRecHitEnergyEE_-> setAxisTitle("Mean Energy [GeV] ",1);
00175   
00176 
00177 }
00178 
00179 //--------------------------------------------------------
00180 void DQMSourcePi0::beginRun(const edm::Run& r, const EventSetup& context) {
00181 
00182 }
00183 
00184 //--------------------------------------------------------
00185 void DQMSourcePi0::beginLuminosityBlock(const LuminosityBlock& lumiSeg, 
00186      const EventSetup& context) {
00187   
00188 }
00189 
00190 //-------------------------------------------------------------
00191 
00192 void DQMSourcePi0::analyze(const Event& iEvent, 
00193                                const EventSetup& iSetup ){  
00194  
00195   if (eventCounter_% prescaleFactor_ ) return; 
00196   eventCounter_++;
00197 
00198   edm::ESHandle<CaloTopology> theCaloTopology;
00199   iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
00200   //  bool accept=false;
00201 
00202   recHitsEB_map= new std::map<DetId, EcalRecHit>();
00203 
00204   std::vector<EcalRecHit> seeds;
00205   seeds.clear();
00206 
00207   vector<EBDetId> usedXtals;
00208   usedXtals.clear();
00209 
00210 
00211 
00212 
00213 
00214 
00215     
00216   edm::Handle<EcalRecHitCollection> rhEB;
00217   edm::Handle<EcalRecHitCollection> rhEE;
00218  
00219   if(isMonEB_) iEvent.getByLabel(productMonitoredEB_, rhEB); 
00220   if(isMonEE_) iEvent.getByLabel(productMonitoredEE_, rhEE);
00221 
00222   EcalRecHitCollection::const_iterator itb;
00223 
00224   // fill EB histos
00225   if(isMonEB_){
00226     if (rhEB.isValid()){
00227       float etot =0;
00228       for(itb=rhEB->begin(); itb!=rhEB->end(); ++itb){
00229         
00230         EBDetId id(itb->id());
00231         double energy = itb->energy();
00232         if (energy > seleXtalMinEnergy_) {
00233           std::pair<DetId, EcalRecHit> map_entry(itb->id(), *itb);
00234           recHitsEB_map->insert(map_entry);
00235         }
00236         if (energy > clusSeedThr_) seeds.push_back(*itb);
00237 
00238         hiPhiDistrEB_->Fill(id.iphi());
00239         hiEtaDistrEB_->Fill(id.ieta());
00240         hRechitEnergyEB_->Fill(itb->energy());
00241         
00242         etot+= itb->energy();    
00243       } // Eb rechits
00244       
00245       hNRecHitsEB_->Fill(rhEB->size());
00246       hMeanRecHitEnergyEB_->Fill(etot/rhEB->size());
00247       hEventEnergyEB_->Fill(etot);
00248 
00249       // Pi0 maker
00250 
00251       //cout<< " RH coll size: "<<rhEB->size()<<endl;
00252       //cout<< " Pi0 seeds: "<<seeds.size()<<endl;
00253 
00254       // Initialize the Position Calc
00255       const CaloSubdetectorGeometry *geometry_p;    
00256       const CaloSubdetectorTopology *topology_p;
00257       const CaloSubdetectorGeometry *geometryES_p;
00258       const EcalRecHitCollection *hitCollection_p = rhEB.product();
00259 
00260       edm::ESHandle<CaloGeometry> geoHandle;
00261       iSetup.get<CaloGeometryRecord>().get(geoHandle);     
00262       geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
00263       geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00264 
00265       std::map<std::string,double> providedParameters;  
00266       providedParameters.insert(std::make_pair("LogWeighted",ParameterLogWeighted_));
00267       providedParameters.insert(std::make_pair("X0",ParameterX0_));
00268       providedParameters.insert(std::make_pair("T0_barl",ParameterT0_barl_));
00269       providedParameters.insert(std::make_pair("W0",ParameterW0_));
00270 
00271       PositionCalc posCalculator_ = PositionCalc(providedParameters);
00272 
00273 
00274       static const int MAXCLUS = 2000;
00275       int nClus;
00276       vector<float> eClus;
00277       vector<float> etClus;
00278       vector<float> etaClus;
00279       vector<float> phiClus;
00280       vector<EBDetId> max_hit;
00281       vector< vector<EcalRecHit> > RecHitsCluster;
00282       vector<float> s4s9Clus;
00283 
00284       nClus=0;
00285 
00286       // Make own simple clusters (3x3, 5x5 or clusPhiSize_ x clusEtaSize_)
00287       sort(seeds.begin(), seeds.end(), ecalRecHitLess());
00288 
00289       for (std::vector<EcalRecHit>::iterator itseed=seeds.begin(); itseed!=seeds.end(); itseed++) {
00290         EBDetId seed_id = itseed->id();
00291         std::vector<EBDetId>::const_iterator usedIds;
00292 
00293         bool seedAlreadyUsed=false;
00294         for(usedIds=usedXtals.begin(); usedIds!=usedXtals.end(); usedIds++){
00295           if(*usedIds==seed_id){
00296             seedAlreadyUsed=true;
00297             //cout<< " Seed with energy "<<itseed->energy()<<" was used !"<<endl;
00298             break; 
00299           }
00300         }
00301         if(seedAlreadyUsed)continue;
00302         topology_p = theCaloTopology->getSubdetectorTopology(DetId::Ecal,EcalBarrel);
00303         std::vector<DetId> clus_v = topology_p->getWindow(seed_id,clusEtaSize_,clusPhiSize_);       
00304         std::vector<DetId> clus_used;
00305         //Reject the seed if not able to build the cluster around it correctly
00306         //if(clus_v.size() < clusEtaSize_*clusPhiSize_){cout<<" Not enough RecHits "<<endl; continue;}
00307         vector<EcalRecHit> RecHitsInWindow;
00308 
00309         double simple_energy = 0; 
00310 
00311         for (std::vector<DetId>::iterator det=clus_v.begin(); det!=clus_v.end(); det++) {
00312           EBDetId EBdet = *det;
00313           //      cout<<" det "<< EBdet<<" ieta "<<EBdet.ieta()<<" iphi "<<EBdet.iphi()<<endl;
00314           bool  HitAlreadyUsed=false;
00315           for(usedIds=usedXtals.begin(); usedIds!=usedXtals.end(); usedIds++){
00316             if(*usedIds==*det){
00317               HitAlreadyUsed=true;
00318               break;
00319             }
00320           }
00321           if(HitAlreadyUsed)continue;
00322           if (recHitsEB_map->find(*det) != recHitsEB_map->end()){
00323             //      cout<<" Used det "<< EBdet<<endl;
00324             std::map<DetId, EcalRecHit>::iterator aHit;
00325             aHit = recHitsEB_map->find(*det);
00326             usedXtals.push_back(*det);
00327             RecHitsInWindow.push_back(aHit->second);
00328             clus_used.push_back(*det);
00329             simple_energy = simple_energy + aHit->second.energy();
00330           }
00331         }
00332    
00333         math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used,hitCollection_p,geometry_p,geometryES_p);
00334         //cout<< "       Simple Clustering: Total energy for this simple cluster : "<<simple_energy<<endl; 
00335         //cout<< "       Simple Clustering: eta phi : "<<clus_pos.eta()<<" "<<clus_pos.phi()<<endl; 
00336         //cout<< "       Simple Clustering: x y z : "<<clus_pos.x()<<" "<<clus_pos.y()<<" "<<clus_pos.z()<<endl; 
00337 
00338         float theta_s = 2. * atan(exp(-clus_pos.eta()));
00339         float p0x_s = simple_energy * sin(theta_s) * cos(clus_pos.phi());
00340         float p0y_s = simple_energy * sin(theta_s) * sin(clus_pos.phi());
00341         //      float p0z_s = simple_energy * cos(theta_s);
00342         float et_s = sqrt( p0x_s*p0x_s + p0y_s*p0y_s);
00343     
00344         //cout << "       Simple Clustering: E,Et,px,py,pz: "<<simple_energy<<" "<<et_s<<" "<<p0x_s<<" "<<p0y_s<<" "<<endl;
00345 
00346         eClus.push_back(simple_energy);
00347         etClus.push_back(et_s);
00348         etaClus.push_back(clus_pos.eta());
00349         phiClus.push_back(clus_pos.phi());
00350         max_hit.push_back(seed_id);
00351         RecHitsCluster.push_back(RecHitsInWindow);
00352         //Compute S4/S9 variable
00353         //We are not sure to have 9 RecHits so need to check eta and phi:
00354         float s4s9_[4];
00355         for(int i=0;i<4;i++)s4s9_[i]= itseed->energy();
00356         for(unsigned int j=0; j<RecHitsInWindow.size();j++){
00357           //cout << " Simple cluster rh, ieta, iphi : "<<((EBDetId)RecHitsInWindow[j].id()).ieta()<<" "<<((EBDetId)RecHitsInWindow[j].id()).iphi()<<endl;
00358         if((((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()-1 && seed_id.ieta()!=1 ) || ( seed_id.ieta()==1 && (((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()-2))){
00359           if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()-1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()-1 ){
00360             s4s9_[0]+=RecHitsInWindow[j].energy();
00361           }else{
00362             if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()){
00363               s4s9_[0]+=RecHitsInWindow[j].energy();
00364               s4s9_[1]+=RecHitsInWindow[j].energy();
00365             }else{
00366               if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()+1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()+1 ){
00367                 s4s9_[1]+=RecHitsInWindow[j].energy(); 
00368               }
00369             }
00370           }
00371         }else{
00372           if(((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()){
00373             if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()-1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()-1 ){
00374               s4s9_[0]+=RecHitsInWindow[j].energy();
00375               s4s9_[3]+=RecHitsInWindow[j].energy();
00376             }else{
00377               if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()+1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()+1 ){
00378                 s4s9_[1]+=RecHitsInWindow[j].energy(); 
00379                 s4s9_[2]+=RecHitsInWindow[j].energy(); 
00380               }
00381             }
00382           }else{
00383             if((((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()+1 && seed_id.ieta()!=-1 ) || ( seed_id.ieta()==-1 && (((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()+2))){
00384               if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()-1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()-1 ){
00385                 s4s9_[3]+=RecHitsInWindow[j].energy();
00386               }else{
00387                 if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()){
00388                   s4s9_[2]+=RecHitsInWindow[j].energy();
00389                   s4s9_[3]+=RecHitsInWindow[j].energy();
00390                 }else{
00391                   if(((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()+1 ||((EBDetId)RecHitsInWindow[j].id()).iphi()-360 == seed_id.iphi()+1 ){
00392                     s4s9_[2]+=RecHitsInWindow[j].energy(); 
00393                   }
00394                 }
00395               }
00396             }else{
00397               cout<<" (EBDetId)RecHitsInWindow[j].id()).ieta() "<<((EBDetId)RecHitsInWindow[j].id()).ieta()<<" seed_id.ieta() "<<seed_id.ieta()<<endl;
00398               cout<<" Problem with S4 calculation "<<endl;return;
00399             }
00400           }
00401         }
00402         }
00403         s4s9Clus.push_back(*max_element( s4s9_,s4s9_+4)/simple_energy);
00404         //    cout<<" s4s9Clus[0] "<<s4s9_[0]/simple_energy<<" s4s9Clus[1] "<<s4s9_[1]/simple_energy<<" s4s9Clus[2] "<<s4s9_[2]/simple_energy<<" s4s9Clus[3] "<<s4s9_[3]/simple_energy<<endl;
00405     //    cout<<" Max "<<*max_element( s4s9_,s4s9_+4)/simple_energy<<endl;
00406     nClus++;
00407     if (nClus == MAXCLUS) return;
00408   }
00409  
00410       // cout<< " Pi0 clusters: "<<nClus<<endl;
00411 
00412       // Selection, based on Simple clustering
00413       //pi0 candidates
00414       static const int MAXPI0S = 200;
00415       int npi0_s=0;
00416 
00417       vector<EBDetId> scXtals;
00418       scXtals.clear();
00419 
00420       if (nClus <= 1) return;
00421       for(Int_t i=0 ; i<nClus ; i++){
00422         for(Int_t j=i+1 ; j<nClus ; j++){
00423           //      cout<<" i "<<i<<"  etClus[i] "<<etClus[i]<<" j "<<j<<"  etClus[j] "<<etClus[j]<<endl;
00424           if( etClus[i]>selePtGammaOne_ && etClus[j]>selePtGammaTwo_ && s4s9Clus[i]>seleS4S9GammaOne_ && s4s9Clus[j]>seleS4S9GammaTwo_){
00425             float theta_0 = 2. * atan(exp(-etaClus[i]));
00426             float theta_1 = 2. * atan(exp(-etaClus[j]));
00427         
00428             float p0x = eClus[i] * sin(theta_0) * cos(phiClus[i]);
00429             float p1x = eClus[j] * sin(theta_1) * cos(phiClus[j]);
00430             float p0y = eClus[i] * sin(theta_0) * sin(phiClus[i]);
00431             float p1y = eClus[j] * sin(theta_1) * sin(phiClus[j]);
00432             float p0z = eClus[i] * cos(theta_0);
00433             float p1z = eClus[j] * cos(theta_1);
00434         
00435             float pt_pi0 = sqrt( (p0x+p1x)*(p0x+p1x) + (p0y+p1y)*(p0y+p1y));
00436             //      cout<<" pt_pi0 "<<pt_pi0<<endl;
00437             if (pt_pi0 < selePtPi0_)continue;
00438             float m_inv = sqrt ( (eClus[i] + eClus[j])*(eClus[i] + eClus[j]) - (p0x+p1x)*(p0x+p1x) - (p0y+p1y)*(p0y+p1y) - (p0z+p1z)*(p0z+p1z) );  
00439             if ( (m_inv<seleMinvMaxPi0_) && (m_inv>seleMinvMinPi0_) ){
00440 
00441               //New Loop on cluster to measure isolation:
00442               vector<int> IsoClus;
00443               IsoClus.clear();
00444               float Iso = 0;
00445               TVector3 pi0vect = TVector3((p0x+p1x), (p0y+p1y), (p0z+p1z));
00446               for(Int_t k=0 ; k<nClus ; k++){
00447                 if(k==i || k==j)continue;
00448                 TVector3 Clusvect = TVector3(eClus[k] * sin(2. * atan(exp(-etaClus[k]))) * cos(phiClus[k]), eClus[k] * sin(2. * atan(exp(-etaClus[k]))) * sin(phiClus[k]) , eClus[k] * cos(2. * atan(exp(-etaClus[k]))));
00449                 float dretaclpi0 = fabs(etaClus[k] - pi0vect.Eta());
00450                 float drclpi0 = Clusvect.DeltaR(pi0vect);
00451                 //      cout<< "   Iso: k, E, drclpi0, detaclpi0, dphiclpi0 "<<k<<" "<<eClus[k]<<" "<<drclpi0<<" "<<dretaclpi0<<endl;
00452                 if((drclpi0<selePi0BeltDR_) && (dretaclpi0<selePi0BeltDeta_) ){
00453                   //              cout<< "   ... good iso cluster #: "<<k<<" etClus[k] "<<etClus[k] <<endl;
00454                   Iso = Iso + etClus[k];
00455                   IsoClus.push_back(k);
00456                 }
00457               }
00458 
00459               //      cout<<"  Iso/pt_pi0 "<<Iso/pt_pi0<<endl;
00460               if(Iso/pt_pi0<selePi0Iso_){
00461                 //for(unsigned int Rec=0;Rec<RecHitsCluster[i].size();Rec++)pi0EBRecHitCollection->push_back(RecHitsCluster[i][Rec]);
00462                 //for(unsigned int Rec2=0;Rec2<RecHitsCluster[j].size();Rec2++)pi0EBRecHitCollection->push_back(RecHitsCluster[j][Rec2]);
00463                 
00464                 
00465                 hMinvPi0EB_->Fill(m_inv);
00466                 hPt1Pi0EB_->Fill(etClus[i]);
00467                 hPt2Pi0EB_->Fill(etClus[j]);
00468                 hPtPi0EB_->Fill(pt_pi0);
00469                 hIsoPi0EB_->Fill(Iso/pt_pi0);
00470                 hS4S91EB_->Fill(s4s9Clus[i]);
00471                 hS4S92EB_->Fill(s4s9Clus[j]);
00472                 
00473                 npi0_s++;
00474               }
00475               //                for(unsigned int iii=0 ; iii<IsoClus.size() ; iii++){   
00476                 //cout<< "    Iso cluster: # "<<iii<<" "<<IsoClus[iii]<<endl;  
00477               //                  for(unsigned int Rec3=0;Rec3<RecHitsCluster[IsoClus[iii]].size();Rec3++)pi0EBRecHitCollection->push_back(RecHitsCluster[IsoClus[iii]][Rec3]);
00478               //}   
00479             
00480                 //cout <<"  Simple Clustering: pi0 Candidate pt,m_inv,i,j :   "<<pt_pi0<<" "<<m_inv<<" "<<i<<" "<<j<<" "<<endl;  
00481 
00482           
00483               if(npi0_s == MAXPI0S) return;
00484             }
00485           }
00486         } // End of the "j" loop over Simple Clusters
00487       } // End of the "i" loop over Simple Clusters
00488 
00489       //cout<<"  (Simple Clustering) Pi0 candidates #: "<<npi0_s<<endl;
00490 
00491       delete recHitsEB_map;
00492 
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500 
00501       
00502     } // if valid
00503 
00504   } // if isMonEB
00505 
00506   // fill EE histos
00507 
00508   if(isMonEE_){  
00509     EcalRecHitCollection::const_iterator ite;
00510     
00511     if (rhEE.isValid()){
00512       
00513       float etot =0;
00514       for(ite=rhEE->begin(); ite!=rhEE->end(); ++ite){
00515         
00516         EEDetId id(ite->id());
00517         hRechitEnergyEE_->Fill(ite->energy());
00518         etot+= ite->energy();    
00519       } // EE rechits
00520       
00521       hNRecHitsEE_->Fill(rhEE->size());
00522       hMeanRecHitEnergyEE_->Fill(etot/rhEE->size());
00523       hEventEnergyEE_->Fill(etot);
00524     }
00525     
00526   }//isMonEE
00527 } //analyze
00528 
00529 
00530 
00531 
00532 //--------------------------------------------------------
00533 void DQMSourcePi0::endLuminosityBlock(const LuminosityBlock& lumiSeg, 
00534                                           const EventSetup& context) {
00535 }
00536 //--------------------------------------------------------
00537 void DQMSourcePi0::endRun(const Run& r, const EventSetup& context){
00538 
00539 }
00540 //--------------------------------------------------------
00541 void DQMSourcePi0::endJob(){
00542 
00543   if(dbe_) {  
00544     if (saveToFile_) {
00545       dbe_->save(fileName_);
00546     }
00547   }
00548 }
00549 
00550 

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