CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Calibration/HcalCalibAlgos/src/Analyzer_minbias.cc

Go to the documentation of this file.
00001 // system include files
00002 #include <memory>
00003 #include <string>
00004 #include <iostream>
00005 
00006 // user include files
00007 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00008 #include "Calibration/HcalCalibAlgos/interface/Analyzer_minbias.h"
00009 #include "DataFormats/Provenance/interface/Provenance.h"
00010 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00011 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00012 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00013 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00014 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00015 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeWord.h"
00016 #include "FWCore/Framework/interface/Run.h"
00017 
00018 #include "TFile.h"
00019 #include "TH1.h"
00020 #include "TH2.h"
00021 #include <fstream>
00022 #include <sstream>
00023 
00024 #include "CondFormats/HcalObjects/interface/HcalRespCorrs.h"
00025 #include "CondFormats/DataRecord/interface/HcalRespCorrsRcd.h"
00026 
00027 using namespace std;
00028 using namespace reco;
00029 //
00030 // constructors and destructor
00031 //
00032 namespace cms{
00033 Analyzer_minbias::Analyzer_minbias(const edm::ParameterSet& iConfig)
00034 {
00035   // get name of output file with histogramms
00036   fOutputFileName = iConfig.getUntrackedParameter<string>("HistOutFile"); 
00037   // get names of modules, producing object collections
00038   
00039   hbherecoMB = iConfig.getParameter<edm::InputTag>("hbheInputMB");
00040   horecoMB   = iConfig.getParameter<edm::InputTag>("hoInputMB");
00041   hfrecoMB   = iConfig.getParameter<edm::InputTag>("hfInputMB");
00042   
00043   hbherecoNoise = iConfig.getParameter<edm::InputTag>("hbheInputNoise");
00044   horecoNoise   = iConfig.getParameter<edm::InputTag>("hoInputNoise");
00045   hfrecoNoise   = iConfig.getParameter<edm::InputTag>("hfInputNoise");
00046   
00047   theRecalib = iConfig.getParameter<bool>("Recalib"); 
00048    
00049 //
00050 //
00051   for(int i=0; i<73; i++)
00052   {
00053      for(int j=0; j<43; j++)
00054      {
00055         noise_min[i][j] = 0.;
00056         noise_pl[i][j] = 0.;
00057      } 
00058   }
00059 //
00060 //
00061      
00062 }
00063 
00064 Analyzer_minbias::~Analyzer_minbias()
00065 {
00066  
00067    // do anything here that needs to be done at desctruction time
00068    // (e.g. close files, deallocate resources etc.)
00069 
00070 }
00071 
00072 void Analyzer_minbias::beginRun( const edm::Run& r, const edm::EventSetup& iSetup)
00073 {
00074   nevent_run = 0;
00075 }
00076 void Analyzer_minbias::endRun( const edm::Run& r, const edm::EventSetup& iSetup)
00077 {
00078  std::cout<<" Runnumber "<<r.run()<<" Nevents  "<<nevent_run<<std::endl;
00079 }
00080 
00081 void Analyzer_minbias::beginJob()
00082 {
00083    
00084    hOutputFile   = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
00085    
00086    myTree = new TTree("RecJet","RecJet Tree");
00087    myTree->Branch("mydet",  &mydet, "mydet/I");
00088    myTree->Branch("mysubd",  &mysubd, "mysubd/I");
00089    myTree->Branch("depth",  &depth, "depth/I");
00090    myTree->Branch("ieta",  &ieta, "ieta/I");
00091    myTree->Branch("iphi",  &iphi, "iphi/I");
00092    myTree->Branch("eta",  &eta, "eta/F");
00093    myTree->Branch("phi",  &phi, "phi/F");
00094    
00095    myTree->Branch("mom0_MB",  &mom0_MB, "mom0_MB/F");
00096    myTree->Branch("mom1_MB",  &mom1_MB, "mom1_MB/F");
00097    myTree->Branch("mom2_MB",  &mom2_MB, "mom2_MB/F");
00098    myTree->Branch("mom4_MB",  &mom4_MB, "mom4_MB/F");
00099    
00100    myTree->Branch("mom0_Noise",  &mom0_Noise, "mom0_Noise/F");
00101    myTree->Branch("mom1_Noise",  &mom1_Noise, "mom1_Noise/F");
00102    myTree->Branch("mom2_Noise",  &mom2_Noise, "mom2_Noise/F");
00103    myTree->Branch("mom4_Noise",  &mom4_Noise, "mom4_Noise/F");
00104    
00105    myTree->Branch("mom0_Diff",  &mom0_Diff, "mom0_Diff/F");
00106    myTree->Branch("mom1_Diff",  &mom1_Diff, "mom1_Diff/F");
00107    myTree->Branch("mom2_Diff",  &mom2_Diff, "mom2_Diff/F");
00108 
00109    myTree->Branch("occup",  &occup, "occup/F");
00110    
00111    std::cout<<" Before ordering Histos "<<std::endl;
00112   
00113    char str0[15];
00114    char str1[15];
00115 
00116    char str10[15];
00117    char str11[15];
00118 
00119    int k=0;
00120    nevent = 0;
00121 // Size of collections
00122 
00123    hHBHEsize_vs_run = new TH2F("hHBHEsize_vs_run","hHBHEsize_vs_run",500,111500.,112000.,6101,-100.5,6000.5);
00124    hHFsize_vs_run = new TH2F("hHFsize_vs_run","hHFsize_vs_run",500,111500.,112000.,6101,-100.5,6000.5); 
00125 
00126    for(int i=1;i<73;i++){
00127     for(int j=1;j<43;j++){
00128 
00129        meannoise_pl[i][j] = 0.;
00130        meannoise_min[i][j] = 0.;
00131 
00132 //     for(int l=1;l<5;l++){
00133         k = i*1000+j;
00134         sprintf(str0,"mpl%d",k);
00135         sprintf(str1,"mmin%d",k);
00136 
00137         sprintf(str10,"vpl%d",k);
00138         sprintf(str11,"vmin%d",k);
00139 //      cout<<" "<<i<<" "<<j<<endl;
00140     if( j < 30 )
00141     {
00142 // first order moment
00143     hCalo1[i][j] = new TH1F(str0, "h0", 320, -10., 10.);
00144     hCalo2[i][j] = new TH1F(str1, "h1", 320, -10., 10.);
00145 
00146 // second order moment
00147     hCalo1mom2[i][j] = new TH1F(str10, "h10", 320, 0., 20.);
00148     hCalo2mom2[i][j] = new TH1F(str11, "h11", 320, 0., 20.);
00149     }
00150       else
00151       {
00152 // HF
00153 // first order moment
00154 //   cout<<" "<<i<<" "<<j<<" "<<k<<endl;
00155    if(j < 40)
00156    {
00157     hCalo1[i][j] = new TH1F(str0, "h0", 320, -10., 10.);
00158     hCalo2[i][j] = new TH1F(str1, "h1", 320, -10., 10.);
00159 //
00160 // second order moment
00161     hCalo1mom2[i][j] = new TH1F(str10, "h10", 320, 0., 40.);
00162     hCalo2mom2[i][j] = new TH1F(str11, "h11", 320, 0., 40.);
00163    }
00164      else
00165      {
00166     hCalo1[i][j] = new TH1F(str0,"h0" , 320, -10., 10.);
00167     hCalo2[i][j] = new TH1F(str1, "h1", 320, -10., 10.);
00168 
00169 // second order moment
00170     hCalo1mom2[i][j] = new TH1F(str10, "h10", 320, 0., 120.);
00171     hCalo2mom2[i][j] = new TH1F(str11, "h11", 320, 0., 120.);
00172 
00173      }
00174     } // HE/HF boundary
00175 //     } // l
00176     } // j
00177    } // i
00178 
00179 
00180    std::cout<<" After ordering Histos "<<std::endl;
00181 
00182    std::string ccc = "noise_0.dat";
00183 
00184    myout_hcal = new ofstream(ccc.c_str());
00185    if(!myout_hcal) cout << " Output file not open!!! "<<endl;
00186 
00187 //
00188    for (int i=0; i<5;i++)
00189    {
00190     for (int j=0; j<5;j++)
00191     {
00192      for (int k=0; k<73;k++)
00193      {
00194        for (int l=0; l<43;l++)
00195        {
00196         theMBFillDetMapPl0[i][j][k][l] = 0.;
00197         theMBFillDetMapPl1[i][j][k][l] = 0.;
00198         theMBFillDetMapPl2[i][j][k][l] = 0.;
00199         theMBFillDetMapPl4[i][j][k][l] = 0.;
00200 
00201         theMBFillDetMapMin0[i][j][k][l] = 0.;
00202         theMBFillDetMapMin1[i][j][k][l] = 0.;
00203         theMBFillDetMapMin2[i][j][k][l] = 0.;
00204         theMBFillDetMapMin4[i][j][k][l] = 0.;
00205 
00206 
00207         theNSFillDetMapPl0[i][j][k][l] = 0.;
00208         theNSFillDetMapPl1[i][j][k][l] = 0.;
00209         theNSFillDetMapPl2[i][j][k][l] = 0.;
00210         theNSFillDetMapPl4[i][j][k][l] = 0.;
00211 
00212         theNSFillDetMapMin0[i][j][k][l] = 0.;
00213         theNSFillDetMapMin1[i][j][k][l] = 0.;
00214         theNSFillDetMapMin2[i][j][k][l] = 0.;
00215         theNSFillDetMapMin4[i][j][k][l] = 0.;
00216 
00217         theDFFillDetMapPl0[i][j][k][l] = 0.;
00218         theDFFillDetMapPl1[i][j][k][l] = 0.;
00219         theDFFillDetMapPl2[i][j][k][l] = 0.;
00220         theDFFillDetMapMin0[i][j][k][l] = 0.;
00221         theDFFillDetMapMin1[i][j][k][l] = 0.;
00222         theDFFillDetMapMin2[i][j][k][l] = 0.;
00223        }
00224      }  
00225     }
00226    }    
00227     
00228    return ;
00229 }
00230 //
00231 //  EndJob
00232 //
00233 void Analyzer_minbias::endJob()
00234 {
00235    int ii=0;
00236       
00237    for (int i=1; i<5;i++)
00238    {
00239     for (int j=1; j<5;j++)
00240     {
00241      for (int k=1; k<73;k++)
00242      {
00243        for (int l=1; l<43;l++)
00244        {
00245           if(theMBFillDetMapPl0[i][j][k][l] > 0)
00246           { 
00247             mom0_MB = theMBFillDetMapPl0[i][j][k][l];
00248             mom1_MB = theMBFillDetMapPl1[i][j][k][l];
00249             mom2_MB = theMBFillDetMapPl2[i][j][k][l];
00250             mom4_MB = theMBFillDetMapPl4[i][j][k][l];
00251             mom0_Noise = theNSFillDetMapPl0[i][j][k][l];
00252             mom1_Noise = theNSFillDetMapPl1[i][j][k][l];
00253             mom2_Noise = theNSFillDetMapPl2[i][j][k][l];
00254             mom4_Noise = theNSFillDetMapPl4[i][j][k][l];
00255             mom0_Diff = theDFFillDetMapPl0[i][j][k][l];
00256             mom1_Diff = theDFFillDetMapPl1[i][j][k][l];
00257             mom2_Diff = theDFFillDetMapPl2[i][j][k][l];
00258             
00259             mysubd = i;
00260             depth = j;
00261             ieta = l;
00262             iphi = k;
00263             cout<<" Result Plus= "<<mysubd<<" "<<ieta<<" "<<iphi<<" mom0  "<<mom0_MB<<" mom1 "<<mom1_MB<<" mom2 "<<mom2_MB<<endl;
00264             myTree->Fill();
00265             ii++;
00266            } // Pl > 0
00267         
00268          
00269           if(theMBFillDetMapMin0[i][j][k][l] > 0)
00270           { 
00271             mom0_MB = theMBFillDetMapMin0[i][j][k][l];
00272             mom1_MB = theMBFillDetMapMin1[i][j][k][l];
00273             mom2_MB = theMBFillDetMapMin2[i][j][k][l];
00274             mom4_MB = theMBFillDetMapMin4[i][j][k][l];
00275             mom0_Noise = theNSFillDetMapMin0[i][j][k][l];
00276             mom1_Noise = theNSFillDetMapMin1[i][j][k][l];
00277             mom2_Noise = theNSFillDetMapMin2[i][j][k][l];
00278             mom4_Noise = theNSFillDetMapMin4[i][j][k][l];
00279             mom0_Diff = theDFFillDetMapMin0[i][j][k][l];
00280             mom1_Diff = theDFFillDetMapMin1[i][j][k][l];
00281             mom2_Diff = theDFFillDetMapMin2[i][j][k][l];
00282             
00283             
00284             mysubd = i;
00285             depth = j;
00286             ieta = -1*l;
00287             iphi = k;
00288             cout<<" Result Minus= "<<mysubd<<" "<<ieta<<" "<<iphi<<" mom0  "<<mom0_MB<<" mom1 "<<mom1_MB<<" mom2 "<<mom2_MB<<endl;
00289             myTree->Fill();
00290             ii++;
00291             
00292           } // Min>0  
00293       } // ieta
00294      } // iphi  
00295     } // depth
00296    } //subd    
00297    
00298    
00299    
00300    cout<<" Number of cells "<<ii<<endl; 
00301       
00302    hOutputFile->Write() ;   
00303    hOutputFile->cd();
00304    hHBHEsize_vs_run->Write() ;
00305    hHFsize_vs_run->Write() ;
00306    for(int i=1;i<73;i++){
00307     for(int j=1;j<43;j++){
00308     hCalo1[i][j]->Write();
00309     hCalo2[i][j]->Write();
00310     hCalo1mom2[i][j]->Write();
00311     hCalo2mom2[i][j]->Write();
00312    }
00313   }
00314   
00315    
00316    myTree->Write();
00317    hOutputFile->Close() ;
00318    
00319    return ;
00320 }
00321 
00322 
00323 //
00324 // member functions
00325 //
00326 
00327 // ------------ method called to produce the data  ------------
00328 void
00329 Analyzer_minbias::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00330 {
00331 
00332   std::cout<<" Start Analyzer_minbias::analyze "<<nevent<<std::endl;
00333   nevent++; 
00334   nevent_run++;
00335   using namespace edm;
00336 
00337   float rnnum = (float)iEvent.run(); 
00338 /*
00339   std::vector<Provenance const*> theProvenance;
00340   iEvent.getAllProvenance(theProvenance);
00341 
00342   for( std::vector<Provenance const*>::const_iterator ip = theProvenance.begin();
00343                                                       ip != theProvenance.end(); ip++)
00344   {
00345      cout<<" Print all module/label names "<<(**ip).moduleName()<<" "<<(**ip).moduleLabel()<<
00346      " "<<(**ip).productInstanceName()<<endl;
00347   }
00348 */
00349 
00350    edm::Handle<L1GlobalTriggerReadoutRecord> gtRecord;
00351    iEvent.getByLabel("gtDigis", gtRecord);
00352    
00353    if (!gtRecord.isValid()) {
00354 
00355 //     LogDebug("L1GlobalTriggerRecordProducer")
00356 //       << "\n\n Error: no L1GlobalTriggerReadoutRecord found with input tag "
00357 //       << m_l1GtReadoutRecord
00358 //       << "\n Returning empty L1GlobalTriggerRecord.\n\n"
00359 //       << std::endl;
00360       cout<<" No L1 trigger record "<<endl;
00361 //     return;
00362    }
00363 
00364 
00365   const HcalRespCorrs* myRecalib=0;
00366   if( theRecalib ) {
00367 // Radek:   
00368   edm::ESHandle <HcalRespCorrs> recalibCorrs;
00369   iSetup.get<HcalRespCorrsRcd>().get("recalibrate",recalibCorrs);
00370   myRecalib = recalibCorrs.product();
00371 // end
00372   } // theRecalib
00373 
00374 // Noise part for HB HE
00375 
00376      double tmpNSFillDetMapPl1[5][5][73][43]; 
00377      double tmpNSFillDetMapPl2[5][5][73][43];
00378      double tmpNSFillDetMapMin1[5][5][73][43]; 
00379      double tmpNSFillDetMapMin2[5][5][73][43];
00380 
00381    for (int i=0; i<5;i++)
00382    {
00383     for (int j=0; j<5;j++)
00384     {
00385      for (int k=0; k<73;k++)
00386      {
00387        for (int l=0; l<43;l++)
00388        {
00389         tmpNSFillDetMapPl1[i][j][k][l] = 0.;
00390         tmpNSFillDetMapPl2[i][j][k][l] = 0.;
00391         tmpNSFillDetMapMin1[i][j][k][l] = 0.;
00392         tmpNSFillDetMapMin2[i][j][k][l] = 0.;
00393        }
00394      }  
00395     }
00396    }    
00397    edm::Handle<HBHERecHitCollection> hbheNormal;
00398    iEvent.getByLabel("hbhereco", hbheNormal);
00399    if(!hbheNormal.isValid()){  
00400      cout<<" hbheNormal failed "<<endl;
00401    } else {
00402        cout<<" The size of the normal collection "<<hbheNormal->size()<<endl;
00403    } 
00404 
00405 
00406    edm::Handle<HBHERecHitCollection> hbheNS;
00407    iEvent.getByLabel(hbherecoNoise, hbheNS);
00408 
00409 
00410    if(!hbheNS.isValid()){
00411      LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
00412      cout<<" No HBHE MS "<<endl;
00413      return ;
00414    }
00415 
00416   
00417    const HBHERecHitCollection HithbheNS = *(hbheNS.product());
00418    cout<<" HBHE NS size of collection "<<HithbheNS.size()<<endl;
00419    hHBHEsize_vs_run->Fill(rnnum,(float)HithbheNS.size());
00420 
00421    if(HithbheNS.size()!= 5184) {
00422           cout<<" HBHE problem "<<rnnum<<" "<<HithbheNS.size()<<endl;
00423           return;
00424    }
00425    edm::Handle<HBHERecHitCollection> hbheMB;
00426    iEvent.getByLabel(hbherecoMB, hbheMB);
00427 
00428    if(!hbheMB.isValid()){
00429      LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
00430      cout<<" No HBHE MB"<<endl;
00431      return ;
00432    }
00433 
00434   const HBHERecHitCollection HithbheMB = *(hbheMB.product());
00435   cout<<" HBHE MB size of collection "<<HithbheMB.size()<<endl;
00436   if(HithbheMB.size()!= 5184) {
00437      cout<<" HBHE problem "<<rnnum<<" "<<HithbheMB.size()<<endl;
00438      return;
00439   }
00440 
00441    edm::Handle<HFRecHitCollection> hfNS;
00442    iEvent.getByLabel(hfrecoNoise, hfNS);
00443 
00444    if(!hfNS.isValid()){
00445      LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
00446      cout<<" No HF NS "<<endl;
00447      return ;
00448    }
00449 
00450    const HFRecHitCollection HithfNS = *(hfNS.product());
00451    cout<<" HFE NS size of collection "<<HithfNS.size()<<endl;
00452    hHFsize_vs_run->Fill(rnnum,(float)HithfNS.size());
00453    if(HithfNS.size()!= 1728) {
00454           cout<<" HF problem "<<rnnum<<" "<<HithfNS.size()<<endl;
00455           return;
00456    }
00457 
00458    edm::Handle<HFRecHitCollection> hfMB;
00459    iEvent.getByLabel(hfrecoMB, hfMB);
00460 
00461    if(!hfMB.isValid()){
00462      LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
00463      cout<<" No HBHE MB"<<endl;
00464      return ;
00465    }
00466 
00467   const HFRecHitCollection HithfMB = *(hfMB.product());
00468   cout<<" HF MB size of collection "<<HithfMB.size()<<endl;
00469    if(HithfMB.size()!= 1728) {
00470           cout<<" HF problem "<<rnnum<<" "<<HithfMB.size()<<endl;
00471           return;
00472    }
00473 
00474 
00475 
00476   for(HBHERecHitCollection::const_iterator hbheItr=HithbheNS.begin(); hbheItr!=HithbheNS.end(); hbheItr++)
00477         {
00478 // Recalibration of energy
00479          float icalconst=1.;     
00480          DetId mydetid = hbheItr->id().rawId();
00481          if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue();
00482     
00483          HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
00484          
00485          double energyhit = aHit.energy();
00486          
00487          DetId id = (*hbheItr).detid(); 
00488          HcalDetId hid=HcalDetId(id);
00489  
00490          int mysu = ((hid).rawId()>>25)&0x7;
00491          if( hid.ieta() > 0 ) {
00492          theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.;
00493          theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit;
00494          theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2);
00495          theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4);
00496          
00497          tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
00498          tmpNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = pow(energyhit,2);
00499          
00500          
00501          } else {
00502          theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.;
00503          theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit;
00504          theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2);
00505          theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4);
00506 
00507 
00508          tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
00509          tmpNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = pow(energyhit,2);
00510          
00511          }  
00512          
00513          if(hid.depth() == 1) {
00514          if( hid.ieta() > 0 ) {
00515           hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]);
00516           hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2));
00517          } else {
00518           hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]);
00519           hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2));
00520          } // eta><0
00521          } // depth=1
00522         } // HBHE_NS
00523 
00524 
00525 // Signal part for HB HE
00526      
00527 
00528   for(HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); hbheItr!=HithbheMB.end(); hbheItr++)
00529         {
00530 // Recalibration of energy
00531          float icalconst=1.;     
00532          DetId mydetid = hbheItr->id().rawId();
00533          if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue();
00534     
00535          HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
00536          
00537          double energyhit = aHit.energy();
00538          
00539          DetId id = (*hbheItr).detid(); 
00540          HcalDetId hid=HcalDetId(id);
00541  
00542          int mysu = ((hid).rawId()>>25)&0x7;
00543          if( hid.ieta() > 0 ) {
00544          theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.;
00545          theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit;
00546          theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2);
00547          theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4);
00548          float mydiff = energyhit - tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
00549          
00550          
00551          theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+mydiff;
00552          theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(mydiff,2);
00553          } else {
00554          theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.;
00555          theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit;
00556          theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2);
00557          theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4);
00558 
00559 
00560          float mydiff = energyhit - tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
00561          theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+mydiff;
00562          theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(mydiff,2);
00563          }  
00564 
00565          
00566          if(hid.depth() == 1) {
00567          if( hid.ieta() > 0 ) {
00568           hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit);
00569           hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2));
00570          } else {
00571           hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit);
00572           hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2));
00573          } // eta><0
00574          } // depth=1
00575         } // HBHE_MB
00576         
00577 // HF
00578  
00579   for(HFRecHitCollection::const_iterator hbheItr=HithfNS.begin(); hbheItr!=HithfNS.end(); hbheItr++)
00580         {
00581 // Recalibration of energy
00582          float icalconst=1.;     
00583          DetId mydetid = hbheItr->id().rawId();
00584          if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue();
00585     
00586          HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
00587          
00588          double energyhit = aHit.energy();
00589          
00590          DetId id = (*hbheItr).detid(); 
00591          HcalDetId hid=HcalDetId(id);
00592  
00593          int mysu = ((hid).rawId()>>25)&0x7;
00594          if( hid.ieta() > 0 ) {
00595          theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.;
00596          theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit;
00597          theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2);
00598          theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theNSFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4);
00599          
00600          tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
00601          tmpNSFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = pow(energyhit,2);
00602          
00603          
00604          } else {
00605          theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.;
00606          theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit;
00607          theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2);
00608          theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theNSFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4);
00609 
00610  
00611          tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = energyhit;
00612          tmpNSFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = pow(energyhit,2);
00613          
00614          }  
00615          
00616          if(hid.depth() == 1) {
00617          if( hid.ieta() > 0 ) {
00618           hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit-noise_pl[hid.iphi()][hid.ieta()]);
00619           hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2));
00620          } else {
00621           hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit-noise_min[hid.iphi()][abs(hid.ieta())]);
00622           hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2));
00623          } // eta><0
00624          } // depth=1
00625         } // HBHE_NS
00626 
00627 
00628 // Signal part for HB HE
00629 
00630   for(HFRecHitCollection::const_iterator hbheItr=HithfMB.begin(); hbheItr!=HithfMB.end(); hbheItr++)
00631         {
00632 // Recalibration of energy
00633          float icalconst=1.;     
00634          DetId mydetid = hbheItr->id().rawId();
00635          if( theRecalib ) icalconst=myRecalib->getValues(mydetid)->getValue();
00636     
00637          HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
00638          
00639          double energyhit = aHit.energy();
00640          
00641          DetId id = (*hbheItr).detid(); 
00642          HcalDetId hid=HcalDetId(id);
00643  
00644          int mysu = ((hid).rawId()>>25)&0x7;
00645          if( hid.ieta() > 0 ) {
00646          theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl0[mysu][hid.depth()][hid.iphi()][hid.ieta()]+ 1.;
00647          theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit;
00648          theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,2);
00649          theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theMBFillDetMapPl4[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow(energyhit,4);
00650 
00651 
00652          theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit-tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
00653          theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
00654          theDFFillDetMapPl2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow((energyhit-tmpNSFillDetMapPl1[mysu][hid.depth()][hid.iphi()][hid.ieta()]),2);
00655          } else {
00656          theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin0[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+ 1.;
00657          theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin1[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+energyhit;
00658          theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin2[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,2);
00659          theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())] = theMBFillDetMapMin4[mysu][hid.depth()][hid.iphi()][abs(hid.ieta())]+pow(energyhit,4);
00660  
00661          theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()] = theDFFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]+energyhit-tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()];
00662          theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()] =
00663          theDFFillDetMapMin2[mysu][hid.depth()][hid.iphi()][hid.ieta()]+pow((energyhit-tmpNSFillDetMapMin1[mysu][hid.depth()][hid.iphi()][hid.ieta()]),2);
00664          }  
00665 
00666          
00667          if(hid.depth() == 1) {
00668          if( hid.ieta() > 0 ) {
00669           hCalo1[hid.iphi()][hid.ieta()]->Fill(energyhit);
00670           hCalo1mom2[hid.iphi()][hid.ieta()]->Fill(pow(energyhit,2));
00671          } else {
00672           hCalo2[hid.iphi()][abs(hid.ieta())]->Fill(energyhit);
00673           hCalo2mom2[hid.iphi()][abs(hid.ieta())]->Fill(pow(energyhit,2));
00674          } // eta><0
00675          } // depth=1
00676         } // HF_MB
00677 
00678    std::cout<<" Event is finished "<<std::endl;
00679 }
00680 }
00681 //define this as a plug-in
00682 //DEFINE_FWK_MODULE(Analyzer_minbias)
00683