CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CaloOnlineTools/EcalTools/plugins/EcalCosmicsHists.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:   EcalCosmicsHists 
00004 // Class:     EcalCosmicsHists  
00005 // 
00015 #include "CaloOnlineTools/EcalTools/plugins/EcalCosmicsHists.h"
00016 #include "DataFormats/DetId/interface/DetId.h"
00017 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00018 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00019 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00020 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00021 
00022 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00023 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00024 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00025 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00026 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00027 
00028 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00029 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00030 
00031 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
00032 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00033 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00034 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00035 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00036 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00037 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
00038 
00039 
00040 #include <vector>
00041 #include "TLine.h"
00042 
00043  
00044 using namespace cms;
00045 using namespace edm;
00046 using namespace std;
00047 
00048 //
00049 // constants, enums and typedefs
00050 //
00051 
00052 //
00053 // static data member definitions
00054 //
00055 
00056 //
00057 // constructors and destructor
00058 //
00059 EcalCosmicsHists::EcalCosmicsHists(const edm::ParameterSet& iConfig) :
00060   ecalRawDataColl_(iConfig.getParameter<edm::InputTag>("ecalRawDataColl")),
00061   ecalRecHitCollectionEB_ (iConfig.getParameter<edm::InputTag>("ecalRecHitCollectionEB")),
00062   ecalRecHitCollectionEE_ (iConfig.getParameter<edm::InputTag>("ecalRecHitCollectionEE")),
00063   barrelClusterCollection_ (iConfig.getParameter<edm::InputTag>("barrelClusterCollection")),
00064   endcapClusterCollection_ (iConfig.getParameter<edm::InputTag>("endcapClusterCollection")),
00065   l1GTReadoutRecTag_ (iConfig.getUntrackedParameter<std::string>("L1GlobalReadoutRecord","gtDigis")),
00066   l1GMTReadoutRecTag_ (iConfig.getUntrackedParameter<std::string>("L1GlobalMuonReadoutRecord","gtDigis")),
00067   runNum_(-1),
00068   histRangeMax_ (iConfig.getUntrackedParameter<double>("histogramMaxRange",1.8)),
00069   histRangeMin_ (iConfig.getUntrackedParameter<double>("histogramMinRange",0.0)),
00070   minTimingAmpEB_ (iConfig.getUntrackedParameter<double>("MinTimingAmpEB",0.100)),
00071   minTimingAmpEE_ (iConfig.getUntrackedParameter<double>("MinTimingAmpEE",0.100)),
00072   minRecHitAmpEB_(iConfig.getUntrackedParameter<double>("MinRecHitAmpEB",0.027)),
00073   minRecHitAmpEE_(iConfig.getUntrackedParameter<double>("MinRecHitAmpEE",0.18)),
00074   minHighEnergy_(iConfig.getUntrackedParameter<double>("MinHighEnergy",2.0)),
00075   fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalCosmicHists"))),
00076   runInFileName_(iConfig.getUntrackedParameter<bool>("runInFileName",true)),
00077   startTime_ (iConfig.getUntrackedParameter<double>("TimeStampStart",1215107133.)),
00078   runTimeLength_ (iConfig.getUntrackedParameter<double>("TimeStampLength",3.)),
00079   numTimingBins_(iConfig.getUntrackedParameter<int>("TimeStampBins",1800))
00080 {
00081   naiveEvtNum_ = 0;
00082   cosmicCounter_ = 0;
00083   cosmicCounterEB_ = 0;
00084   cosmicCounterEEM_ = 0;
00085   cosmicCounterEEP_ = 0;
00086   cosmicCounterTopBottom_ = 0;
00087 
00088   // TrackAssociator parameters
00089   edm::ParameterSet trkParameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00090   trackParameters_.loadParameters( trkParameters );
00091   trackAssociator_.useDefaultPropagator();
00092   
00093   string title1 = "Seed Energy for All Feds; Seed Energy (GeV)";
00094   string name1 = "SeedEnergyAllFEDs";
00095   int numBins = 200;//(int)round(histRangeMax_-histRangeMin_)+1;
00096   allFedsHist_ = new TH1F(name1.c_str(),title1.c_str(),numBins,histRangeMin_,histRangeMax_);
00097   
00098   fedMap_ = new EcalFedMap();
00099 }
00100 
00101 
00102 EcalCosmicsHists::~EcalCosmicsHists()
00103 {
00104 }
00105 
00106 
00107 //
00108 // member functions
00109 //
00110 
00111 // ------------ method called to for each event  ------------
00112 void
00113 EcalCosmicsHists::analyze(edm::Event const & iEvent, edm::EventSetup const & iSetup)
00114 {
00115   bool hasEndcapClusters = true;
00116   int ievt = iEvent.id().event();
00117   
00118   edm::Handle<reco::SuperClusterCollection> bscHandle;  
00119   edm::Handle<reco::SuperClusterCollection> escHandle;  
00120   
00121   naiveEvtNum_++;
00122   
00123   //LogDebug("EcalCosmicsHists")<< "  My Event: " << naiveEvtNum_ << " " << iEvent.id().run() << " " << iEvent.id().event() << " " << iEvent.time().value();
00124   //LogDebug("EcalCosmicsHists")<< "Timestamp: " << iEvent.id().run() << " " << iEvent.id().event() << " " << iEvent.time().value();
00125   
00126 
00127   // check DB payload
00128   edm::ESHandle<EcalADCToGeVConstant> pAgc;
00129   iSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
00130   const EcalADCToGeVConstant* agc = pAgc.product();
00131   if (naiveEvtNum_<=1) {
00132     LogWarning("EcalCosmicsHists") << "Global EB ADC->GeV scale: " << agc->getEBValue() << " GeV/ADC count" ;
00133     LogWarning("EcalCosmicsHists") << "Global EE ADC->GeV scale: " << agc->getEEValue() << " GeV/ADC count" ;
00134   }
00135     //float adcEBconst = agc->getEBValue();
00136     //float adcEEconst = agc->getEEValue();
00137 
00138 
00139   //
00140 
00141   //===================TIMESTAMP INFORMTION=================================
00142   // Code added to get the time in seconds
00143   unsigned int  timeStampLow = ( 0xFFFFFFFF & iEvent.time().value() );
00144   unsigned int  timeStampHigh = ( iEvent.time().value() >> 32 );
00145   double rawEventTime = ( double)(timeStampHigh)+((double )(timeStampLow)/1000000.);
00146   double eventTime = rawEventTime - startTime_; //Notice the subtraction of the "starttime"
00147   //std::cout << "Event Time " << eventTime << " High " <<timeStampHigh<< " low"<<timeStampLow <<" value " <<iEvent.time().value() << std::endl;  
00148   //========================================================================
00149 
00150   iEvent.getByLabel(barrelClusterCollection_, bscHandle);
00151   if (!(bscHandle.isValid())) 
00152     {
00153       LogWarning("EcalCosmicsHists") << barrelClusterCollection_ << " not available";
00154       return;
00155     }
00156   LogDebug("EcalCosmicsHists") << "event " << ievt;
00157   
00158   iEvent.getByLabel(endcapClusterCollection_, escHandle);
00159   if (!(escHandle.isValid())) 
00160     {
00161       LogWarning("EcalCosmicsHists") << endcapClusterCollection_ << " not available";
00162       hasEndcapClusters = false;
00163       //return;
00164     }
00165   
00166   Handle<EcalRecHitCollection> hits;
00167   iEvent.getByLabel(ecalRecHitCollectionEB_, hits);
00168   if (!(hits.isValid())) 
00169     {
00170       LogWarning("EcalCosmicsHists") << ecalRecHitCollectionEB_ << " not available";
00171       return;
00172     }
00173   Handle<EcalRecHitCollection> hitsEE;
00174   iEvent.getByLabel(ecalRecHitCollectionEE_, hitsEE);
00175   if (!(hitsEE.isValid())) 
00176     {
00177       LogWarning("EcalCosmicsHists") << ecalRecHitCollectionEE_ << " not available";
00178       return;
00179     }
00180   
00181   Handle<EcalRawDataCollection> DCCHeaders;
00182   iEvent.getByLabel(ecalRawDataColl_, DCCHeaders);
00183   if(!DCCHeaders.isValid())
00184     LogWarning("EcalCosmicsHists") << "DCC headers not available";
00185 
00186   //make the bx histos right here
00187   //TODO: Right now we are filling histos for errors...
00188   int orbit = -100;
00189   int bx = -100;
00190   int runType = -100;
00191 
00192   for(EcalRawDataCollection::const_iterator headerItr= DCCHeaders->begin();headerItr != DCCHeaders->end(); 
00193       ++headerItr) {
00194     EcalDCCHeaderBlock::EcalDCCEventSettings settings = headerItr->getEventSettings();
00195     int myorbit = headerItr->getOrbit();
00196     int mybx = headerItr->getBX();
00197     int myRunType = headerItr->getRunType();
00198     int FEDid = headerItr->fedId();
00199     TH2F* dccRuntypeHist = FEDsAndDCCRuntypeVsBxHists_[FEDid];
00200     if(dccRuntypeHist==0)
00201     {
00202       initHists(FEDid);
00203       dccRuntypeHist = FEDsAndDCCRuntypeVsBxHists_[FEDid];
00204     }
00205     dccRuntypeHist->Fill(mybx,myRunType);
00206     
00207     if (bx == -100)
00208     {
00209       bx = mybx;
00210     }
00211     else if (bx != mybx)
00212     {
00213       LogWarning("EcalCosmicsHists") << "This header has a conflicting bx OTHERS were " << bx << " here " << mybx;
00214       dccBXErrorByFEDHist_->Fill(headerItr->fedId());
00215       if(bx != -100)
00216       {
00217         dccErrorVsBxHist_->Fill(bx,0);
00218       }
00219     }
00220 
00221     if (runType == -100)
00222     {
00223       runType = myRunType;
00224     }
00225     else if (runType != myRunType)
00226     {
00227       LogWarning("EcalCosmicsHists") << "This header has a conflicting runType OTHERS were " << bx << " here " << mybx;
00228       dccRuntypeErrorByFEDHist_->Fill(headerItr->fedId());
00229       if(bx != -100)
00230         dccErrorVsBxHist_->Fill(bx,2);
00231     }
00232     
00233     
00234     if (orbit == -100)
00235     {
00236       orbit = myorbit;
00237     }
00238     else if (orbit != myorbit)
00239     {
00240       LogWarning("EcalCosmicsHists") << "This header has a conflicting orbit; OTHERS were " << orbit << " here " << myorbit;
00241       dccOrbitErrorByFEDHist_->Fill(headerItr->fedId());
00242       if(bx != -100)
00243         dccErrorVsBxHist_->Fill(bx,1);
00244     }
00245   }
00246   dccEventVsBxHist_->Fill(bx,runType);
00247   dccRuntypeHist_->Fill(runType);
00248 
00249 
00250   
00251   std::vector<bool> l1Triggers = determineTriggers(iEvent, iSetup);      
00252   bool isEcalL1 = l1Triggers[4];
00253   bool isHCALL1 = l1Triggers[3];
00254   bool isRPCL1 = l1Triggers[2];
00255   bool isCSCL1 = l1Triggers[1];
00256   bool isDTL1 = l1Triggers[0];
00257   
00258   if(runNum_==-1)
00259     {
00260       runNum_ = iEvent.id().run();
00261     }      
00262   
00263   int  numberOfCosmics = 0;
00264   int  numberOfCosmicsEB = 0;
00265   int  numberOfCosmicsEEP = 0;
00266   int  numberOfCosmicsEEM = 0;
00267   int  numberOfCosmicsTop = 0;
00268   int  numberOfCosmicsBottom = 0;
00269   int  numberOfHighEClusters = 0;
00270   //int eventnum = iEvent.id().event();
00271   std::vector<EBDetId> seeds;
00272   
00273   //++++++++++++++++++BEGIN LOOP OVER EB SUPERCLUSTERS+++++++++++++++++++++++++//
00274 
00275   const reco::SuperClusterCollection *clusterCollection_p = bscHandle.product();
00276   for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin(); clus != clusterCollection_p->end(); ++clus) 
00277    {
00278      double energy = clus->energy();
00279      double phi    = clus->phi();
00280      double eta    = clus->eta();
00281      double time = -1000.0;
00282      double ampli = 0.;
00283      double secondMin = 0.;
00284      double secondTime = -1000.;
00285      int numXtalsinCluster = 0;
00286      
00287      EBDetId maxDet;
00288      EBDetId secDet;
00289      
00290      numberofBCinSC_->Fill(clus->clustersSize());
00291      numberofBCinSCphi_->Fill(phi,clus->clustersSize());     
00292      
00293      for (reco::CaloCluster_iterator bclus = (clus->clustersBegin()); bclus != (clus->clustersEnd()); ++bclus) 
00294        {
00295          double cphi = (*bclus)->phi();
00296          double ceta = (*bclus)->eta();     
00297          TrueBCOccupancy_->Fill(cphi,ceta);
00298          TrueBCOccupancyCoarse_->Fill(cphi,ceta);
00299        }
00300      
00301      std::vector< std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();//get these from the cluster
00302      for(std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin(); detitr != clusterDetIds.end(); ++detitr) 
00303        {
00304          //Here I use the "find" on a digi collection... I have been warned...
00305          if ((*detitr).first.det() != DetId::Ecal) { std::cout << " det is " <<(*detitr).first.det() << std::endl;continue;}
00306          if ((*detitr).first.subdetId() != EcalBarrel) {std::cout << " subdet is " <<(*detitr).first.subdetId() << std::endl; continue; }
00307          EcalRecHitCollection::const_iterator thishit = hits->find((*detitr).first);
00308          if (thishit == hits->end()) continue;
00309          //The checking above should no longer be needed...... as only those in the cluster would already have rechits..
00310          
00311          EcalRecHit myhit = (*thishit);
00312          
00313          double thisamp = myhit.energy();
00314          if (thisamp > minRecHitAmpEB_) {numXtalsinCluster++; }
00315          if (thisamp > secondMin) {secondMin = thisamp; secondTime = myhit.time(); secDet = (EBDetId)(*detitr).first;}
00316          if (secondMin > ampli) {std::swap(ampli,secondMin); std::swap(time,secondTime); std::swap(maxDet,secDet);}
00317        }
00318      
00319      double fullnumXtalsinCluster = clusterDetIds.size();     
00320      
00321      float E2 = ampli + secondMin;
00322      EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId((EBDetId) maxDet);
00323      int FEDid = 600+elecId.dccId();
00324      
00325      numberOfCosmics++;
00326      numberOfCosmicsEB++;
00327      
00328      //Set some more values
00329      seeds.push_back(maxDet);
00330      int ieta = maxDet.ieta();
00331      int iphi = maxDet.iphi();
00332      int ietaSM = maxDet.ietaSM();
00333      int iphiSM = maxDet.iphiSM();
00334      
00335      int LM = ecalElectronicsMap_->getLMNumber(maxDet) ;//FIX ME
00336      
00337      // top and bottom clusters
00338      if (iphi>0&&iphi<180) { 
00339        numberOfCosmicsTop++;
00340      } else {
00341        numberOfCosmicsBottom++;
00342      }      
00343      
00344      // fill the proper hist
00345      TH1F* uRecHist = FEDsAndHists_[FEDid];
00346      TH1F* E2uRecHist = FEDsAndE2Hists_[FEDid];
00347      TH1F* energyuRecHist = FEDsAndenergyHists_[FEDid];
00348      TH1F* timingHist = FEDsAndTimingHists_[FEDid];
00349      TH1F* freqHist = FEDsAndFrequencyHists_[FEDid];
00350      TH1F* iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
00351      TH1F* ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
00352      TH2F* timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
00353      TH2F* timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
00354      TH2F* E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
00355      TH2F* energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
00356      TH1F* numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];    
00357      TH2F* occupHist = FEDsAndOccupancyHists_[FEDid];
00358      TH2F* timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
00359      TH2F* timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
00360      
00361      if(uRecHist==0)
00362        {
00363          initHists(FEDid);
00364          uRecHist = FEDsAndHists_[FEDid];
00365          E2uRecHist = FEDsAndE2Hists_[FEDid];
00366          energyuRecHist = FEDsAndenergyHists_[FEDid];
00367          timingHist = FEDsAndTimingHists_[FEDid];
00368          freqHist = FEDsAndFrequencyHists_[FEDid];
00369          timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
00370          timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
00371          iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
00372          ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
00373          E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
00374          energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
00375          numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];
00376          occupHist = FEDsAndOccupancyHists_[FEDid];
00377          timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
00378          timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
00379        }
00380      
00381      uRecHist->Fill(ampli);
00382      E2uRecHist->Fill(E2);
00383      E2vsE1uRecHist->Fill(ampli,E2);
00384      energyuRecHist->Fill(energy);
00385      energyvsE1uRecHist->Fill(ampli,energy);
00386      allFedsHist_->Fill(ampli);
00387      allFedsE2Hist_->Fill(E2); 
00388      allFedsenergyHist_->Fill(energy);
00389      allFedsenergyHighHist_->Fill(energy);
00390      allFedsE2vsE1Hist_->Fill(ampli,E2);
00391      allFedsenergyvsE1Hist_->Fill(ampli,energy);
00392      freqHist->Fill(naiveEvtNum_);
00393      iphiProfileHist->Fill(iphi);
00394      ietaProfileHist->Fill(ieta);
00395      
00396      allFedsFrequencyHist_->Fill(naiveEvtNum_);
00397      allFedsiPhiProfileHist_->Fill(iphi);
00398      allFedsiEtaProfileHist_->Fill(ieta);
00399      allOccupancy_->Fill(iphi, ieta);
00400      TrueOccupancy_->Fill(phi, eta);
00401      allOccupancyCoarse_->Fill(iphi, ieta);
00402      TrueOccupancyCoarse_->Fill(phi, eta);
00403      allFedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
00404      NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
00405      numxtalsVsEnergy_->Fill(energy,numXtalsinCluster);
00406      numxtalsVsHighEnergy_->Fill(energy,numXtalsinCluster);
00407      
00408      //Fill the hists for the time stamp information
00409      allFedsFreqTimeVsPhiHist_->Fill(iphi,eventTime);
00410      allFedsFreqTimeVsPhiTTHist_->Fill(iphi,eventTime);
00411      allFedsFreqTimeVsEtaHist_->Fill(eventTime,ieta);
00412      allFedsFreqTimeVsEtaTTHist_->Fill(eventTime,ieta);
00413      //end time stamp hists
00414      
00415      occupHist->Fill(ietaSM,iphiSM);
00416      if (fullnumXtalsinCluster==1) {
00417        allOccupancySingleXtal_->Fill(iphi, ieta);
00418        energySingleXtalHist_->Fill(energy);
00419      }
00420      
00421      // Exclusive trigger plots
00422      
00423      if(isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00424        allOccupancyExclusiveECAL_->Fill(iphi, ieta);
00425        allOccupancyCoarseExclusiveECAL_->Fill(iphi, ieta);
00426        if (ampli > minTimingAmpEB_) {
00427          allFedsTimingHistECAL_->Fill(time);
00428          allFedsTimingPhiEtaHistECAL_->Fill(iphi,ieta,time);
00429          allFedsTimingTTHistECAL_->Fill(iphi,ieta,time);
00430          allFedsTimingLMHistECAL_->Fill(LM,time);
00431        }      
00432        triggerExclusiveHist_->Fill(0);
00433      } 
00434      
00435      if(!isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&isHCALL1) {   
00436        allOccupancyExclusiveHCAL_->Fill(iphi, ieta);
00437        allOccupancyCoarseExclusiveHCAL_->Fill(iphi, ieta);
00438        if (ampli > minTimingAmpEB_) {
00439          allFedsTimingHistHCAL_->Fill(time);
00440          allFedsTimingPhiEtaHistHCAL_->Fill(iphi,ieta,time);
00441          allFedsTimingTTHistHCAL_->Fill(iphi,ieta,time);
00442          allFedsTimingLMHistHCAL_->Fill(LM,time);
00443        }      
00444        triggerExclusiveHist_->Fill(1);
00445      }
00446      
00447      if(!isEcalL1&&isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00448        allOccupancyExclusiveDT_->Fill(iphi, ieta);
00449        allOccupancyCoarseExclusiveDT_->Fill(iphi, ieta);
00450        if (ampli > minTimingAmpEB_) {
00451          allFedsTimingHistDT_->Fill(time);
00452          allFedsTimingPhiEtaHistDT_->Fill(iphi,ieta,time);
00453          allFedsTimingTTHistDT_->Fill(iphi,ieta,time);
00454          allFedsTimingLMHistDT_->Fill(LM,time);
00455        }      
00456        triggerExclusiveHist_->Fill(2);
00457      }
00458      
00459      if(!isEcalL1&&!isDTL1&&isRPCL1&&!isCSCL1&&!isHCALL1) {
00460        allOccupancyExclusiveRPC_->Fill(iphi, ieta);
00461        allOccupancyCoarseExclusiveRPC_->Fill(iphi, ieta);
00462        if (ampli > minTimingAmpEB_) {
00463          allFedsTimingHistRPC_->Fill(time);
00464          allFedsTimingPhiEtaHistRPC_->Fill(iphi,ieta,time);
00465          allFedsTimingTTHistRPC_->Fill(iphi,ieta,time);
00466          allFedsTimingLMHistRPC_->Fill(LM,time);
00467        }      
00468        triggerExclusiveHist_->Fill(3);
00469      }
00470      
00471      if(!isEcalL1&&!isDTL1&&!isRPCL1&&isCSCL1&&!isHCALL1) {   
00472        allOccupancyExclusiveCSC_->Fill(iphi, ieta);
00473        allOccupancyCoarseExclusiveCSC_->Fill(iphi, ieta);
00474        if (ampli > minTimingAmpEB_) {
00475          allFedsTimingHistCSC_->Fill(time);
00476          allFedsTimingPhiEtaHistCSC_->Fill(iphi,ieta,time);
00477          allFedsTimingTTHistCSC_->Fill(iphi,ieta,time);
00478          allFedsTimingLMHistCSC_->Fill(LM,time);
00479        }      
00480        triggerExclusiveHist_->Fill(4);
00481      }
00482      
00483      // Inclusive trigger plots
00484      
00485      if (isEcalL1) { 
00486        triggerHist_->Fill(0);
00487        allOccupancyECAL_->Fill(iphi, ieta);
00488        allOccupancyCoarseECAL_->Fill(iphi, ieta);
00489      }
00490      if (isHCALL1) {
00491        triggerHist_->Fill(1);
00492        allOccupancyHCAL_->Fill(iphi, ieta);
00493        allOccupancyCoarseHCAL_->Fill(iphi, ieta);
00494      }
00495      if (isDTL1)   {
00496        triggerHist_->Fill(2);
00497        allOccupancyDT_->Fill(iphi, ieta);
00498        allOccupancyCoarseDT_->Fill(iphi, ieta);
00499      }
00500      if (isRPCL1)  {
00501        triggerHist_->Fill(3);
00502        allOccupancyRPC_->Fill(iphi, ieta);
00503        allOccupancyCoarseRPC_->Fill(iphi, ieta);
00504      }
00505      if (isCSCL1)  {
00506        triggerHist_->Fill(4);
00507        allOccupancyCSC_->Fill(iphi, ieta);
00508        allOccupancyCoarseCSC_->Fill(iphi, ieta);
00509      }
00510      
00511      // Fill histo for Ecal+muon coincidence
00512      if(isEcalL1&&(isCSCL1||isRPCL1||isDTL1)&&!isHCALL1)
00513        allFedsTimingHistEcalMuon_->Fill(time);
00514      
00515      if (ampli > minTimingAmpEB_) {
00516        timingHist->Fill(time);
00517        timingHistVsFreq->Fill(time, naiveEvtNum_);
00518        timingHistVsAmp->Fill(time, ampli);
00519        allFedsTimingHist_->Fill(time);
00520        allFedsTimingVsAmpHist_->Fill(time, ampli);
00521        allFedsTimingVsFreqHist_->Fill(time, naiveEvtNum_);
00522        timingHistVsPhi->Fill(time, iphiSM);
00523        timingHistVsModule->Fill(time, ietaSM);
00524        allFedsTimingPhiHist_->Fill(iphi,time);
00525        allFedsTimingPhiEtaHist_->Fill(iphi,ieta,time);
00526        allFedsTimingTTHist_->Fill(iphi,ieta,time);
00527        allFedsTimingLMHist_->Fill(LM,time);
00528        if (FEDid>=610&&FEDid<=627)  allFedsTimingPhiEbmHist_->Fill(iphi,time);
00529        if (FEDid>=628&&FEDid<=645)  allFedsTimingPhiEbpHist_->Fill(iphi,time);
00530        
00531        if (FEDid>=610&&FEDid<=627)  allFedsTimingEbmHist_->Fill(time);
00532        if (FEDid>=628&&FEDid<=645)  allFedsTimingEbpHist_->Fill(time);
00533        if (FEDid>=613&&FEDid<=616)  allFedsTimingEbmTopHist_->Fill(time);
00534        if (FEDid>=631&&FEDid<=634)  allFedsTimingEbpTopHist_->Fill(time);
00535        if (FEDid>=622&&FEDid<=625)  allFedsTimingEbmBottomHist_->Fill(time);
00536        if (FEDid>=640&&FEDid<=643)  allFedsTimingEbpBottomHist_->Fill(time);
00537      }         
00538      
00539      // *** High Energy Clusters Analysis ** //
00540      
00541      if (energy>minHighEnergy_) {
00542        
00543        LogInfo("EcalCosmicsHists") << "High energy event " << iEvent.id().run() << " : " 
00544                                    << iEvent.id().event() << " " << naiveEvtNum_  
00545                                    << " : " << energy << " " << numXtalsinCluster
00546                                    << " : " << iphi << " " << ieta 
00547                                    << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1 ;
00548        
00549        numberOfHighEClusters++;
00550        allOccupancyHighEnergy_->Fill(iphi, ieta);
00551        allOccupancyHighEnergyCoarse_->Fill(iphi, ieta);    
00552        allFedsOccupancyHighEnergyHist_->Fill(iphi,ieta,energy);
00553        allFedsenergyOnlyHighHist_->Fill(energy);
00554        
00555        HighEnergy_2GeV_occuCoarse->Fill(iphi,ieta);    
00556        HighEnergy_2GeV_occu3D->Fill(iphi,ieta,energy);
00557        
00558        HighEnergy_NumXtal->Fill(fullnumXtalsinCluster);
00559        HighEnergy_NumXtalFedId->Fill(FEDid,fullnumXtalsinCluster);
00560        HighEnergy_NumXtaliphi->Fill(iphi,fullnumXtalsinCluster);
00561        HighEnergy_energy3D->Fill(iphi,ieta,energy);
00562        HighEnergy_energyNumXtal->Fill(fullnumXtalsinCluster,energy);
00563        
00564        if (energy>100.0) {
00565          LogInfo("EcalCosmicsHists") << "Very high energy event " << iEvent.id().run() << " : " 
00566                                      << iEvent.id().event() << " " << naiveEvtNum_  
00567                                      << " : " << energy << " " << numXtalsinCluster 
00568                                      << " : " << iphi << " " << ieta 
00569                                      << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1 ;
00570          
00571          HighEnergy_100GeV_occuCoarse->Fill(iphi,ieta);    
00572          HighEnergy_100GeV_occu3D->Fill(iphi,ieta,energy);
00573          
00574        }
00575        
00576      }  
00577      
00578      // *** end of High Energy Clusters analysis *** //
00579      
00580    }//++++++++++++++++++END LOOP OVER EB SUPERCLUSTERS+++++++++++++++++++++++//
00581   
00582   //+++++++++++++++++++LOOP OVER ENDCAP EE CLUSTERS++++++++++++++++++++//
00583   
00584   if(hasEndcapClusters) {
00585     clusterCollection_p = escHandle.product();
00586     for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin(); clus != clusterCollection_p->end(); ++clus) {
00587       double energy = clus->energy();
00588       //double phi    = clus->phi();
00589       //double eta    = clus->eta();
00590       double time = -1000.0;
00591       double ampli = 0.;
00592       double secondMin = 0.;
00593       double secondTime = -1000.;
00594       int clusSize = clus->clustersSize();
00595       int numXtalsinCluster = 0;
00596       
00597       EEDetId maxDet;
00598       EEDetId secDet;
00599       //LogInfo("EcalCosmicsHists") << "Here is what we initialized the maxDet to: " << maxDet;
00600       
00601  //      for (reco::basicCluster_iterator bclus = (clus->clustersBegin()); bclus != (clus->clustersEnd()); ++bclus) {
00602 //      //double cphi = (*bclus)->phi();
00603 //      //double ceta = (*bclus)->eta();        
00604 //         //TODO: extend histos to EE
00605 //         //TrueBCOccupancy_->Fill(cphi,ceta);
00606 //         //TrueBCOccupancyCoarse_->Fill(cphi,ceta);
00607 //       }
00608       
00609       std::vector<std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();//get these from the cluster
00610       for(std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin(); detitr != clusterDetIds.end(); ++detitr) {
00611         
00612         //LogInfo("EcalCosmicsHists") << " Here is the DetId inside the cluster: " << (EEDetId)(*detitr);
00613         //Here I use the "find" on a digi collection... I have been warned...
00614         
00615         if ((*detitr).first.det() != DetId::Ecal) {
00616           LogError("EcalCosmicsHists") << " det is " <<(*detitr).first.det(); continue;
00617         }
00618         if ((*detitr).first.subdetId() != EcalEndcap) {
00619           LogError("EcalCosmicsHists") << " subdet is " <<(*detitr).first.subdetId(); continue; 
00620         }
00621 
00622         EcalRecHitCollection::const_iterator thishit = hitsEE->find((*detitr).first);
00623         
00624         if (thishit == hitsEE->end()) {
00625           LogInfo("EcalCosmicsHists") << " WARNING: EEDetId not found in the RecHit collection!";
00626           continue;
00627         }
00628         // The checking above should no longer be needed...... 
00629         // as only those in the cluster would already have rechits..
00630         
00631         EcalRecHit myhit = (*thishit);
00632         
00633         //LogInfo("EcalCosmicsHists") << " Found hit for DetId: " << (EEDetId)(*detitr);
00634         double thisamp = myhit.energy();
00635         if (thisamp > minRecHitAmpEE_) {numXtalsinCluster++; }
00636         if (thisamp > secondMin) {secondMin = thisamp; secondTime = myhit.time(); secDet = (EEDetId)(*detitr).first;}
00637         if (secondMin > ampli) {std::swap(ampli,secondMin); std::swap(time,secondTime); std::swap(maxDet,secDet);}
00638         
00639         //LogInfo("EcalCosmicsHists") << "maxDetId is now: " << (EEDetId)(maxDet);
00640       }
00641       
00642       double fullnumXtalsinCluster = clusterDetIds.size();     
00643       
00644       float E2 = ampli + secondMin;
00645       
00646       EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId((EEDetId) maxDet);      
00647       //int FEDid = 600+elecId.dccId();           
00648 
00649       //Set some more values
00650       //TODO: need to fix the seeds vector to be DetId or have another one for EE
00651       //seeds.push_back(maxDet);
00652       
00653       int ix = maxDet.ix();
00654       int iy = maxDet.iy();
00655       int iz = maxDet.zside();
00656      
00657       //      LogWarning("EcalCosmicsHists") << "EE cluster (x,y,z) : ( " 
00658       //                                     << ix << " , " << iy << " , " << iz 
00659       //                                     << " ) " << std::endl;
00660 
00661       if (!EEDetId::validDetId(ix,iy,iz)) {
00662         LogWarning("EcalCosmicsHists") << "INVALID EE DetId !!!" << endl;
00663         return;
00664       }
00665 
00666 
00667       numberOfCosmics++;
00668       if (iz<0) { numberOfCosmicsEEM++; }
00669       else { numberOfCosmicsEEP++; }
00670 
00671       //int LM = ecalElectronicsMap_->getLMNumber(maxDet) ;//FIX ME
00672       
00673       //TODO: extend histos to EE
00674       //TH1F* uRecHist = FEDsAndHists_[FEDid];
00675       //TH1F* E2uRecHist = FEDsAndE2Hists_[FEDid];
00676       //TH1F* energyuRecHist = FEDsAndenergyHists_[FEDid];
00677       //TH1F* timingHist = FEDsAndTimingHists_[FEDid];
00678       //TH1F* freqHist = FEDsAndFrequencyHists_[FEDid];
00679       //TH1F* iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
00680       //TH1F* ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
00681       //TH2F* timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
00682       //TH2F* timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
00683       //TH2F* E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
00684       //TH2F* energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
00685       //TH1F* numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];    
00686       //TH2F* occupHist = FEDsAndOccupancyHists_[FEDid];
00687       //TH2F* timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
00688       //TH2F* timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
00689       //if(uRecHist==0)
00690       //{
00691       //  initHists(FEDid);
00692       //  uRecHist = FEDsAndHists_[FEDid];
00693       //  E2uRecHist = FEDsAndE2Hists_[FEDid];
00694       //  energyuRecHist = FEDsAndenergyHists_[FEDid];
00695       //  timingHist = FEDsAndTimingHists_[FEDid];
00696       //  freqHist = FEDsAndFrequencyHists_[FEDid];
00697       //  timingHistVsFreq = FEDsAndTimingVsFreqHists_[FEDid];
00698       //  timingHistVsAmp = FEDsAndTimingVsAmpHists_[FEDid];
00699       //  iphiProfileHist = FEDsAndiPhiProfileHists_[FEDid];
00700       //  ietaProfileHist = FEDsAndiEtaProfileHists_[FEDid];
00701       //  E2vsE1uRecHist = FEDsAndE2vsE1Hists_[FEDid];
00702       //  energyvsE1uRecHist = FEDsAndenergyvsE1Hists_[FEDid];
00703       //  numXtalInClusterHist = FEDsAndNumXtalsInClusterHists_[FEDid];
00704       //  occupHist = FEDsAndOccupancyHists_[FEDid];
00705       //  timingHistVsPhi = FEDsAndTimingVsPhiHists_[FEDid];
00706       //  timingHistVsModule = FEDsAndTimingVsModuleHists_[FEDid];
00707       //}
00708       //uRecHist->Fill(ampli);
00709       //E2uRecHist->Fill(E2);
00710       //E2vsE1uRecHist->Fill(ampli,E2);
00711       //energyuRecHist->Fill(energy);
00712       //energyvsE1uRecHist->Fill(ampli,energy);
00713       //allFedsHist_->Fill(ampli);
00714 
00715       if (iz<0) {
00716         EEM_FedsSeedEnergyHist_->Fill(ampli);
00717         EEM_FedsenergyHist_->Fill(energy);
00718         EEM_FedsenergyHighHist_->Fill(energy);
00719         EEM_FedsE2Hist_->Fill(E2); 
00720         EEM_FedsE2vsE1Hist_->Fill(ampli,E2);
00721         EEM_FedsenergyvsE1Hist_->Fill(ampli,energy);
00722         EEM_AllOccupancyCoarse_->Fill(ix-0.5,iy-0.5);
00723         EEM_AllOccupancy_->Fill(ix-0.5,iy-0.5);
00724 
00725         EEM_FedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
00726         EEM_NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
00727         EEM_numxtalsVsEnergy_->Fill(energy,numXtalsinCluster);
00728         EEM_numxtalsVsHighEnergy_->Fill(energy,numXtalsinCluster);
00729         EEM_numberofBCinSC_->Fill(clusSize);
00730 
00731         if (fullnumXtalsinCluster==1) {
00732           EEM_OccupancySingleXtal_->Fill(ix-0.5,iy-0.5);
00733           EEM_energySingleXtalHist_->Fill(energy);
00734         }
00735 
00736         if (ampli > minTimingAmpEE_) {
00737           EEM_FedsTimingHist_->Fill(time);
00738           EEM_FedsTimingVsAmpHist_->Fill(time, ampli);
00739           EEM_FedsTimingTTHist_->Fill(ix-0.5,iy-0.5,time);
00740         }
00741 
00742         // Exclusive trigger plots
00743         
00744         if(isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00745           EEM_OccupancyExclusiveECAL_->Fill(ix-0.5,iy-0.5);
00746           EEM_OccupancyCoarseExclusiveECAL_->Fill(ix-0.5,iy-0.5);
00747           if (ampli > minTimingAmpEE_) {
00748             EEM_FedsTimingHistECAL_->Fill(time);
00749             EEM_FedsTimingTTHistECAL_->Fill(ix-0.5,iy-0.5,time);
00750           }      
00751           EEM_triggerExclusiveHist_->Fill(0);
00752         } 
00753         
00754         if(!isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&isHCALL1) {   
00755           EEM_OccupancyExclusiveHCAL_->Fill(ix-0.5,iy-0.5);
00756           EEM_OccupancyCoarseExclusiveHCAL_->Fill(ix-0.5,iy-0.5);
00757           if (ampli > minTimingAmpEE_) {
00758             EEM_FedsTimingHistHCAL_->Fill(time);
00759             EEM_FedsTimingTTHistHCAL_->Fill(ix-0.5,iy-0.5,time);
00760           }      
00761           EEM_triggerExclusiveHist_->Fill(1);
00762         }
00763         
00764         if(!isEcalL1&&isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00765           EEM_OccupancyExclusiveDT_->Fill(ix-0.5,iy-0.5);
00766           EEM_OccupancyCoarseExclusiveDT_->Fill(ix-0.5,iy-0.5);
00767           if (ampli > minTimingAmpEE_) {
00768             EEM_FedsTimingHistDT_->Fill(time);
00769             EEM_FedsTimingTTHistDT_->Fill(ix-0.5,iy-0.5,time);
00770           }      
00771           EEM_triggerExclusiveHist_->Fill(2);
00772         }
00773         
00774         if(!isEcalL1&&!isDTL1&&isRPCL1&&!isCSCL1&&!isHCALL1) {
00775           EEM_OccupancyExclusiveRPC_->Fill(ix-0.5,iy-0.5);
00776           EEM_OccupancyCoarseExclusiveRPC_->Fill(ix-0.5,iy-0.5);
00777           if (ampli > minTimingAmpEE_) {
00778             EEM_FedsTimingHistRPC_->Fill(time);
00779             EEM_FedsTimingTTHistRPC_->Fill(ix-0.5,iy-0.5,time);
00780           }      
00781           EEM_triggerExclusiveHist_->Fill(3);
00782         }
00783         
00784         if(!isEcalL1&&!isDTL1&&!isRPCL1&&isCSCL1&&!isHCALL1) {   
00785           EEM_OccupancyExclusiveCSC_->Fill(ix-0.5,iy-0.5);
00786           EEM_OccupancyCoarseExclusiveCSC_->Fill(ix-0.5,iy-0.5);
00787           if (ampli > minTimingAmpEE_) {
00788             EEM_FedsTimingHistCSC_->Fill(time);
00789             EEM_FedsTimingTTHistCSC_->Fill(ix-0.5,iy-0.5,time);
00790           }      
00791           EEM_triggerExclusiveHist_->Fill(4);
00792         }
00793         
00794         // Inclusive trigger plots
00795         
00796         if (isEcalL1) { 
00797           EEM_triggerHist_->Fill(0);
00798           EEM_OccupancyECAL_->Fill(ix-0.5,iy-0.5);
00799           EEM_OccupancyCoarseECAL_->Fill(ix-0.5,iy-0.5);
00800         }
00801         if (isHCALL1) {
00802           EEM_triggerHist_->Fill(1);
00803           EEM_OccupancyHCAL_->Fill(ix-0.5,iy-0.5);
00804           EEM_OccupancyCoarseHCAL_->Fill(ix-0.5,iy-0.5);
00805         }
00806         if (isDTL1)   {
00807           EEM_triggerHist_->Fill(2);
00808           EEM_OccupancyDT_->Fill(ix-0.5,iy-0.5);
00809           EEM_OccupancyCoarseDT_->Fill(ix-0.5,iy-0.5);
00810         }
00811         if (isRPCL1)  {
00812           EEM_triggerHist_->Fill(3);
00813           EEM_OccupancyRPC_->Fill(ix-0.5,iy-0.5);
00814           EEM_OccupancyCoarseRPC_->Fill(ix-0.5,iy-0.5);
00815         }
00816         if (isCSCL1)  {
00817           EEM_triggerHist_->Fill(4);
00818           EEM_OccupancyCSC_->Fill(ix-0.5,iy-0.5);
00819           EEM_OccupancyCoarseCSC_->Fill(ix-0.5,iy-0.5);
00820         }               
00821 
00822       } else {
00823 
00824         EEP_FedsSeedEnergyHist_->Fill(ampli);
00825         EEP_FedsenergyHist_->Fill(energy);
00826         EEP_FedsenergyHighHist_->Fill(energy);
00827         EEP_FedsE2Hist_->Fill(E2); 
00828         EEP_FedsE2vsE1Hist_->Fill(ampli,E2);
00829         EEP_FedsenergyvsE1Hist_->Fill(ampli,energy);
00830         EEP_AllOccupancyCoarse_->Fill(ix-0.5,iy-0.5);
00831         EEP_AllOccupancy_->Fill(ix-0.5,iy-0.5);
00832 
00833         EEP_FedsNumXtalsInClusterHist_->Fill(numXtalsinCluster);
00834         EEP_NumXtalsInClusterHist_->Fill(fullnumXtalsinCluster);
00835         EEP_numxtalsVsEnergy_->Fill(energy,numXtalsinCluster);
00836         EEP_numxtalsVsHighEnergy_->Fill(energy,numXtalsinCluster);
00837         EEP_numberofBCinSC_->Fill(clusSize);
00838 
00839         if (fullnumXtalsinCluster==1) {
00840           EEP_OccupancySingleXtal_->Fill(ix-0.5,iy-0.5);
00841           EEP_energySingleXtalHist_->Fill(energy);
00842         }
00843 
00844         if (ampli > minTimingAmpEE_) {
00845           EEP_FedsTimingHist_->Fill(time);
00846           EEP_FedsTimingVsAmpHist_->Fill(time, ampli);
00847           EEP_FedsTimingTTHist_->Fill(ix-0.5,iy-0.5,time);
00848         }
00849 
00850         // Exclusive trigger plots
00851         
00852         if(isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00853           EEP_OccupancyExclusiveECAL_->Fill(ix-0.5,iy-0.5);
00854           EEP_OccupancyCoarseExclusiveECAL_->Fill(ix-0.5,iy-0.5);
00855           if (ampli > minTimingAmpEE_) {
00856             EEP_FedsTimingHistECAL_->Fill(time);
00857             EEP_FedsTimingTTHistECAL_->Fill(ix-0.5,iy-0.5,time);
00858           }      
00859           EEP_triggerExclusiveHist_->Fill(0);
00860         } 
00861         
00862         if(!isEcalL1&&!isDTL1&&!isRPCL1&&!isCSCL1&&isHCALL1) {   
00863           EEP_OccupancyExclusiveHCAL_->Fill(ix-0.5,iy-0.5);
00864           EEP_OccupancyCoarseExclusiveHCAL_->Fill(ix-0.5,iy-0.5);
00865           if (ampli > minTimingAmpEE_) {
00866             EEP_FedsTimingHistHCAL_->Fill(time);
00867             EEP_FedsTimingTTHistHCAL_->Fill(ix-0.5,iy-0.5,time);
00868           }      
00869           EEP_triggerExclusiveHist_->Fill(1);
00870         }
00871         
00872         if(!isEcalL1&&isDTL1&&!isRPCL1&&!isCSCL1&&!isHCALL1) {
00873           EEP_OccupancyExclusiveDT_->Fill(ix-0.5,iy-0.5);
00874           EEP_OccupancyCoarseExclusiveDT_->Fill(ix-0.5,iy-0.5);
00875           if (ampli > minTimingAmpEE_) {
00876             EEP_FedsTimingHistDT_->Fill(time);
00877             EEP_FedsTimingTTHistDT_->Fill(ix-0.5,iy-0.5,time);
00878           }      
00879           EEP_triggerExclusiveHist_->Fill(2);
00880         }
00881         
00882         if(!isEcalL1&&!isDTL1&&isRPCL1&&!isCSCL1&&!isHCALL1) {
00883           EEP_OccupancyExclusiveRPC_->Fill(ix-0.5,iy-0.5);
00884           EEP_OccupancyCoarseExclusiveRPC_->Fill(ix-0.5,iy-0.5);
00885           if (ampli > minTimingAmpEE_) {
00886             EEP_FedsTimingHistRPC_->Fill(time);
00887             EEP_FedsTimingTTHistRPC_->Fill(ix-0.5,iy-0.5,time);
00888           }      
00889           EEP_triggerExclusiveHist_->Fill(3);
00890         }
00891         
00892         if(!isEcalL1&&!isDTL1&&!isRPCL1&&isCSCL1&&!isHCALL1) {   
00893           EEP_OccupancyExclusiveCSC_->Fill(ix-0.5,iy-0.5);
00894           EEP_OccupancyCoarseExclusiveCSC_->Fill(ix-0.5,iy-0.5);
00895           if (ampli > minTimingAmpEE_) {
00896             EEP_FedsTimingHistCSC_->Fill(time);
00897             EEP_FedsTimingTTHistCSC_->Fill(ix-0.5,iy-0.5,time);
00898           }      
00899           EEP_triggerExclusiveHist_->Fill(4);
00900         }
00901         
00902         // Inclusive trigger plots
00903         
00904         if (isEcalL1) { 
00905           EEP_triggerHist_->Fill(0);
00906           EEP_OccupancyECAL_->Fill(ix-0.5,iy-0.5);
00907           EEP_OccupancyCoarseECAL_->Fill(ix-0.5,iy-0.5);
00908         }
00909         if (isHCALL1) {
00910           EEP_triggerHist_->Fill(1);
00911           EEP_OccupancyHCAL_->Fill(ix-0.5,iy-0.5);
00912           EEP_OccupancyCoarseHCAL_->Fill(ix-0.5,iy-0.5);
00913         }
00914         if (isDTL1)   {
00915           EEP_triggerHist_->Fill(2);
00916           EEP_OccupancyDT_->Fill(ix-0.5,iy-0.5);
00917           EEP_OccupancyCoarseDT_->Fill(ix-0.5,iy-0.5);
00918         }
00919         if (isRPCL1)  {
00920           EEP_triggerHist_->Fill(3);
00921           EEP_OccupancyRPC_->Fill(ix-0.5,iy-0.5);
00922           EEP_OccupancyCoarseRPC_->Fill(ix-0.5,iy-0.5);
00923         }
00924         if (isCSCL1)  {
00925           EEP_triggerHist_->Fill(4);
00926           EEP_OccupancyCSC_->Fill(ix-0.5,iy-0.5);
00927           EEP_OccupancyCoarseCSC_->Fill(ix-0.5,iy-0.5);
00928         }       
00929 
00930       }
00931       
00932 
00933       // *** High Energy Clusters Analysis ** //
00934       
00935       if (energy>minHighEnergy_) {
00936         
00937         LogInfo("EcalCosmicsHists") << "High energy event in EE " << iEvent.id().run() << " : " 
00938                                     << iEvent.id().event() << " " << naiveEvtNum_  
00939                                     << " : " << energy << " " << numXtalsinCluster
00940                                     << " : " << ix << " " << iy 
00941                                     << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1 ;
00942         
00943         //  numberOfHighEClusters++;
00944         //  allOccupancyHighEnergy_->Fill(iphi, ieta);
00945         //  allOccupancyHighEnergyCoarse_->Fill(iphi, ieta);    
00946         //  allFedsOccupancyHighEnergyHist_->Fill(iphi,ieta,energy);
00947         if (iz<0) {
00948           EEM_FedsenergyOnlyHighHist_->Fill(energy);
00949           EEM_OccupancyHighEnergy_->Fill(ix-0.5,iy-0.5);
00950           EEM_OccupancyHighEnergyCoarse_->Fill(ix-0.5,iy-0.5);    
00951         } else {
00952           EEP_FedsenergyOnlyHighHist_->Fill(energy);
00953         }
00954         //  HighEnergy_2GeV_occuCoarse->Fill(iphi,ieta);    
00955         //  HighEnergy_2GeV_occu3D->Fill(iphi,ieta,energy);
00956         
00957         //  HighEnergy_NumXtal->Fill(fullnumXtalsinCluster);
00958         //  HighEnergy_NumXtalFedId->Fill(FEDid,fullnumXtalsinCluster);
00959         //  HighEnergy_NumXtaliphi->Fill(iphi,fullnumXtalsinCluster);
00960         //  HighEnergy_energy3D->Fill(iphi,ieta,energy);
00961         //  HighEnergy_energyNumXtal->Fill(fullnumXtalsinCluster,energy);
00962         
00963         if (energy>100.0) {
00964           LogInfo("EcalCosmicsHists") << "Very high energy event in EE " << iEvent.id().run() << " : " 
00965                                       << iEvent.id().event() << " " << naiveEvtNum_  
00966                                       << " : " << energy << " " << numXtalsinCluster
00967                                       << " : " << ix << " " << iy 
00968                                       << " : " << isEcalL1 << isHCALL1 << isDTL1 << isRPCL1 << isCSCL1 ;
00969           //    HighEnergy_100GeV_occuCoarse->Fill(iphi,ieta);    
00970           //    HighEnergy_100GeV_occu3D->Fill(iphi,ieta,energy);
00971         }
00972         
00973       }  
00974       
00975       // *** end of High Energy Clusters analysis *** //
00976       
00977     }//++++++++++++++++++END LOOP OVER EE SUPERCLUSTERS+++++++++++++++++++++++++++++++++++
00978   }
00979   
00980   HighEnergy_numClusHighEn->Fill(numberOfHighEClusters);
00981   HighEnergy_ratioClusters->Fill((double(numberOfHighEClusters))/(double(numberOfCosmics)));
00982   
00983   numberofCosmicsHist_->Fill(numberOfCosmics);
00984   EEP_numberofCosmicsHist_->Fill(numberOfCosmicsEEP);
00985   EEM_numberofCosmicsHist_->Fill(numberOfCosmicsEEM);
00986   numberofCosmicsHistEB_->Fill(numberOfCosmicsEB);
00987   
00988   if ( numberOfCosmics > 0 ) {
00989     cosmicCounter_++;
00990     numberofGoodEvtFreq_->Fill(naiveEvtNum_);
00991     allFedsFreqTimeHist_->Fill(eventTime);
00992     //This line will work in 21X!!
00993     //std::cout << " Orbit " <<   iEvent.orbitNumber() << " BX " << iEvent.bunchCrossing()<< std::endl;
00994     //std::cout << " BX " << iEvent.experimentType() << std::endl;
00995   }
00996 
00997   if ( numberOfCosmicsEB > 0 ) cosmicCounterEB_++;
00998   if ( numberOfCosmicsEEP > 0 ) cosmicCounterEEP_++;
00999   if ( numberOfCosmicsEEM > 0 ) cosmicCounterEEM_++;
01000 
01001   if (numberOfCosmicsTop&&numberOfCosmicsBottom) {
01002     cosmicCounterTopBottom_++;
01003     numberofCosmicsTopBottomHist_->Fill(numberOfCosmicsTop+numberOfCosmicsBottom);
01004   }
01005   
01006   // *** TrackAssociator *** //
01007   
01008   // get reco tracks 
01009   edm::Handle<reco::TrackCollection> recoTracks;
01010   iEvent.getByLabel("cosmicMuons", recoTracks);  
01011   
01012   if ( recoTracks.isValid() ) {
01013     //    LogWarning("EcalCosmicsHists") << "... Valid TrackAssociator recoTracks !!! " << recoTracks.product()->size();
01014     std::map<int,std::vector<DetId> > trackDetIdMap;
01015     int tracks = 0;
01016     for(reco::TrackCollection::const_iterator recoTrack = recoTracks->begin(); recoTrack != recoTracks->end(); ++recoTrack){
01017       
01018       if(fabs(recoTrack->d0())>70 || fabs(recoTrack->dz())>70)
01019         continue;
01020       if(recoTrack->numberOfValidHits()<20)
01021         continue;
01022       
01023       //if (recoTrack->pt() < 2) continue; // skip low Pt tracks       
01024       
01025       TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *recoTrack, trackParameters_);      
01026       
01027       //       edm::LogVerbatim("TrackAssociator") << "\n-------------------------------------------------------\n Track (pt,eta,phi): " <<
01028       //    recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() ;
01029       //       edm::LogVerbatim("TrackAssociator") << "Ecal energy in crossed crystals based on RecHits: " <<
01030       //    info.crossedEnergy(TrackDetMatchInfo::EcalRecHits);
01031       //       edm::LogVerbatim("TrackAssociator") << "Ecal energy in 3x3 crystals based on RecHits: " <<
01032       //    info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1);
01033       //       edm::LogVerbatim("TrackAssociator") << "Hcal energy in crossed towers based on RecHits: " <<
01034       //    info.crossedEnergy(TrackDetMatchInfo::HcalRecHits);
01035       //       edm::LogVerbatim("TrackAssociator") << "Hcal energy in 3x3 towers based on RecHits: " <<
01036       //    info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1);
01037       //       edm::LogVerbatim("TrackAssociator") << "Number of muon segment matches: " << info.numberOfSegments();
01038       
01039       //       std::cout << "\n-------------------------------------------------------\n Track (pt,eta,phi): " <<
01040       //    recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() << std::endl;
01041       //       std::cout << "Ecal energy in crossed crystals based on RecHits: " <<
01042       //    info.crossedEnergy(TrackDetMatchInfo::EcalRecHits) << std::endl;
01043       //       std::cout << "Ecal energy in 3x3 crystals based on RecHits: " <<
01044       //    info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1) << std::endl;
01045       //       std::cout << "Hcal energy in crossed towers based on RecHits: " <<
01046       //    info.crossedEnergy(TrackDetMatchInfo::HcalRecHits) << std::endl;
01047       //       std::cout << "Hcal energy in 3x3 towers based on RecHits: " <<
01048       //    info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1) << std::endl;
01049       
01050       for (unsigned int i=0; i<info.crossedEcalIds.size(); i++) {        
01051         // only checks for barrel
01052         if (info.crossedEcalIds[i].det() == DetId::Ecal && info.crossedEcalIds[i].subdetId() == 1) {         
01053           EBDetId ebDetId (info.crossedEcalIds[i]);        
01054           trackAssoc_muonsEcal_->Fill(ebDetId.iphi(), ebDetId.ieta());
01055           //std::cout << "Crossed iphi: " << ebDetId.iphi() 
01056           //    << " ieta: " << ebDetId.ieta() << " : nCross " << info.crossedEcalIds.size() << std::endl;
01057 
01058           EcalRecHitCollection::const_iterator thishit = hits->find(ebDetId);
01059           if (thishit == hits->end()) continue;
01060           
01061           EcalRecHit myhit = (*thishit);         
01062           //double thisamp = myhit.energy();
01063           //std::cout << " Crossed energy: " << thisamp << " : nCross " << info.crossedEcalIds.size() << std::endl;       
01064         }
01065       }
01066       
01067       //edm::LogVerbatim("TrackAssociator") << " crossedEcalIds size: " << info.crossedEcalIds.size()
01068       //                                  << " crossedEcalRecHits size: " << info.crossedEcalRecHits.size();
01069       numberofCrossedEcalIdsHist_->Fill(info.crossedEcalIds.size());
01070       tracks++;
01071       if(info.crossedEcalIds.size()>0)
01072         trackDetIdMap.insert(std::pair<int,std::vector<DetId> > (tracks,info.crossedEcalIds));
01073     }      
01074     
01075     // Now to match recoTracks with cosmic clusters
01076     
01077     int numAssocTracks = 0;
01078     int numAssocClusters = 0;
01079     edm::LogVerbatim("TrackAssociator") << "Matching cosmic clusters to tracks...";
01080     int numSeeds = seeds.size();
01081     int numTracks = trackDetIdMap.size();
01082     while(seeds.size() > 0 && trackDetIdMap.size() > 0)
01083     {
01084       double bestDr = 1000;
01085       double bestDPhi = 1000;
01086       double bestDEta = 1000;
01087       double bestEtaTrack = 1000;
01088       double bestEtaSeed = 1000;
01089       double bestPhiTrack = 1000;
01090       double bestPhiSeed = 1000;
01091       EBDetId bestTrackDet;
01092       EBDetId bestSeed;
01093       int bestTrack = -1;
01094       std::map<EBDetId,EBDetId> trackDetIdToSeedMap;
01095 
01096       //edm::LogVerbatim("TrackAssociator") << "NumTracks:" << trackDetIdMap.size() << " numClusters:" << seeds.size();
01097 
01098       for(std::vector<EBDetId>::const_iterator seedItr = seeds.begin(); seedItr != seeds.end(); ++seedItr) {
01099         for(std::map<int,std::vector<DetId> >::const_iterator mapItr = trackDetIdMap.begin();
01100             mapItr != trackDetIdMap.end(); ++mapItr) {
01101           for(unsigned int i=0; i<mapItr->second.size(); i++) {
01102             // only checks for barrel
01103             if(mapItr->second[i].det() == DetId::Ecal && mapItr->second[i].subdetId() == 1) {
01104               EBDetId ebDet = (mapItr->second[i]);
01105               double seedEta = seedItr->ieta();
01106               double deta = ebDet.ieta()-seedEta;
01107               if(seedEta * ebDet.ieta() < 0 )
01108                 deta > 0 ? (deta=deta-1.) : (deta=deta+1.); 
01109               double dR;
01110               double dphi = ebDet.iphi()-seedItr->iphi();
01111               if (abs(dphi) > 180)
01112                 dphi > 0 ?  (dphi=360-dphi) : (dphi=-360-dphi);
01113               dR = sqrt(deta*deta + dphi*dphi);
01114               if(dR < bestDr)
01115               {
01116                 bestDr = dR;
01117                 bestDPhi = dphi;
01118                 bestDEta = deta;
01119                 bestTrackDet = mapItr->second[i];
01120                 bestTrack = mapItr->first;
01121                 bestSeed = (*seedItr);
01122                 bestEtaTrack = ebDet.ieta();
01123                 bestEtaSeed = seedEta;
01124                 bestPhiTrack = ebDet.iphi();
01125                 bestPhiSeed = seedItr->iphi();
01126               }
01127             }
01128           }
01129         }
01130       }
01131       if(bestDr < 1000) {
01132         //edm::LogVerbatim("TrackAssociator") << "Best deltaR from matched DetId's to cluster:" << bestDr;
01133         deltaRHist_->Fill(bestDr);
01134         deltaPhiHist_->Fill(bestDPhi);
01135         deltaEtaHist_->Fill(bestDEta);
01136         deltaEtaDeltaPhiHist_->Fill(bestDEta,bestDPhi);
01137         seedTrackEtaHist_->Fill(bestEtaSeed,bestEtaTrack);
01138         seedTrackPhiHist_->Fill(bestPhiSeed,bestPhiTrack);
01139         seeds.erase(find(seeds.begin(),seeds.end(), bestSeed));
01140         trackDetIdMap.erase(trackDetIdMap.find(bestTrack));
01141         trackDetIdToSeedMap[bestTrackDet] = bestSeed;
01142         numAssocTracks++;
01143         numAssocClusters++;
01144 
01145         // for high energy analysis
01146         if(bestDPhi < 1.5 && bestDEta < 1.8 ) {
01147           //edm::LogVerbatim("TrackAssociator") << "Best seed ieta and iphi: (" 
01148           //                                    << bestSeed.ieta() << ", " << bestSeed.iphi() << ") ";
01149           //check if the bestSeed is a High Energy one
01150           EcalRecHitCollection::const_iterator Ecalhit = hits->find(bestSeed);
01151           if (Ecalhit == hits->end()) {
01152             continue;
01153           }
01154           double EcalhitEnergy = Ecalhit->energy();
01155           //edm::LogVerbatim("TrackAssociator") << "Best seed energy: " << EcalhitEnergy ;
01156           HighEnergy_bestSeed->Fill(EcalhitEnergy);
01157           HighEnergy_bestSeedOccupancy->Fill(bestSeed.iphi(), bestSeed.ieta());
01158         }
01159       }
01160       else {
01161         edm::LogVerbatim("TrackAssociator") << "could not match cluster seed to track." << bestDr;
01162         break; // no match found
01163       }
01164     }
01165     if(numSeeds>0 && numTracks>0) {
01166       ratioAssocClustersHist_->AddBinContent(1,numAssocClusters);
01167       ratioAssocClustersHist_->AddBinContent(2,numSeeds);
01168     }
01169     if(numTracks>0) {
01170       ratioAssocTracksHist_->AddBinContent(1,numAssocTracks);
01171       ratioAssocTracksHist_->AddBinContent(2,numTracks);
01172       numberofCosmicsWTrackHist_->Fill(numSeeds);
01173     }
01174   } else {
01175     //    LogWarning("EcalCosmicsHists") << "!!! No TrackAssociator recoTracks !!!";    
01176   }
01177   
01178   
01179   // Study on Tracks for High Energy events
01180   edm::Handle<reco::TrackCollection> recoTracksBarrel;
01181   iEvent.getByLabel("cosmicMuonsBarrelOnly", recoTracksBarrel);
01182   if ( !recoTracksBarrel.isValid() ) {
01183     //edm::LogWarning("EcalCosmicsHists") << "RecoTracksBarrel not valid!! " ;
01184   }
01185   else {
01186     //edm::LogWarning("EcalCosmicsHists") << "Number of barrel reco tracks found in the event: " << recoTracksBarrel->size() ;
01187     HighEnergy_numRecoTrackBarrel->Fill(recoTracksBarrel->size());
01188     for(reco::TrackCollection::const_iterator recoTrack = recoTracksBarrel->begin(); recoTrack != recoTracksBarrel->end(); ++recoTrack) {
01189       //edm::LogWarning("EcalCosmicsHists") << "Track (pt,eta,phi): " << recoTrack->pt() << " , " << recoTrack->eta() << " , " << recoTrack->phi() ;
01190       //edm::LogWarning("EcalCosmicsHists") << "Track innermost hit: " << recoTrack->innerPosition().phi() ;
01191     }
01192     
01193     for (reco::SuperClusterCollection::const_iterator clus = clusterCollection_p->begin(); clus != clusterCollection_p->end(); ++clus) {
01194       double energy = clus->energy();
01195       double phi    = clus->phi();
01196       double eta    = clus->eta();
01197       
01198       if (recoTracksBarrel->size()==0) HighEnergy_0tracks_occu3D->Fill(phi,eta,energy);
01199       if (recoTracksBarrel->size()==1) HighEnergy_1tracks_occu3D->Fill(phi,eta,energy);
01200       if (recoTracksBarrel->size()==2) HighEnergy_2tracks_occu3D->Fill(phi,eta,energy);
01201       
01202       std::vector<std::pair<DetId, float> > clusterDetIds = clus->hitsAndFractions();//get these from the cluster
01203       for(std::vector< std::pair<DetId, float> >::const_iterator detitr = clusterDetIds.begin(); detitr != clusterDetIds.end(); ++detitr)
01204         {
01205           if ((*detitr).first.det() != DetId::Ecal) {continue;}
01206           if ((*detitr).first.subdetId() != EcalBarrel) {continue; }
01207           EcalRecHitCollection::const_iterator thishit = hits->find((*detitr).first);
01208           if (thishit == hits->end()) {continue;}
01209           
01210           double rechitenergy = thishit->energy();
01211           int ieta = ((EBDetId)(*detitr).first).ieta();
01212           int iphi = ((EBDetId)(*detitr).first).iphi();
01213           if (rechitenergy > minRecHitAmpEB_) {
01214             if (recoTracksBarrel->size()==0) HighEnergy_0tracks_occu3DXtal->Fill(iphi,ieta,rechitenergy);
01215             if (recoTracksBarrel->size()==1) HighEnergy_1tracks_occu3DXtal->Fill(iphi,ieta,rechitenergy);
01216             if (recoTracksBarrel->size()==2) HighEnergy_2tracks_occu3DXtal->Fill(iphi,ieta,rechitenergy);
01217             
01218             if (rechitenergy > 10 ) edm::LogWarning("EcalCosmicsHists") << "!!!!! Crystal with energy " << rechitenergy << " at (ieta,iphi) (" << ieta << " ," << iphi << "); Id: " << (*detitr).first.det();
01219           }
01220         }
01221     }
01222     
01223     // look at angle between 2 recoTracks
01224     if ( recoTracksBarrel->size() == 2 ) {
01225       reco::TrackCollection::const_iterator Track1 = recoTracksBarrel->begin();
01226       reco::TrackCollection::const_iterator Track2 = (recoTracksBarrel->begin())+1;
01227       float angle = (acos(sin(Track1->theta()) * cos(Track1->phi()) * sin(Track2->theta()) * cos(Track2->phi()) + sin(Track1->theta()) * sin(Track1->phi()) * sin(Track2->theta()) * sin(Track2->phi()) + cos(Track1->theta()) * cos(Track2->theta())))/0.017453292519943;
01228       //edm::LogWarning("EcalCosmicsHists") << "Tracks angle: " << angle;
01229       HighEnergy_TracksAngle->Fill(angle);
01230       if ( (Track1->innerPosition().phi()) > 0  && (Track2->innerPosition().phi()) < 0 ) {
01231         //edm::LogWarning("EcalCosmicsHists") << "Top-bottom tracks";
01232         HighEnergy_TracksAngleTopBottom->Fill(angle);
01233       }
01234       
01235       
01236     }
01237   }
01238   
01239   // *** end of TrackAssociator code *** //
01240   
01241   
01242   // *** HCAL RecHits code *** //
01243   
01244   //hcal rechits
01245   edm::Handle<HBHERecHitCollection> hbhe;
01246   iEvent.getByLabel("hbhereco", hbhe);
01247   
01248   edm::Handle<HFRecHitCollection> hfrh;
01249   iEvent.getByLabel("hfreco",hfrh);
01250   
01251   edm::Handle<HORecHitCollection> horh; 
01252   iEvent.getByLabel("horeco", horh);
01253   
01254   if ( hbhe.isValid() ) {
01255     //    LogInfo("EcalCosmicHists") << "event " << ievt << " HBHE RecHits collection size " << hbhe->size();    
01256     const HBHERecHitCollection hbheHit = *(hbhe.product());
01257     for (HBHERecHitCollection::const_iterator hhit=hbheHit.begin(); hhit!=hbheHit.end(); hhit++) {
01258       //      if (hhit->energy() > 0.6){
01259       hcalEnergy_HBHE_->Fill(hhit->energy());
01260       //      }
01261     }
01262   } else {
01263     //    LogWarning("EcalCosmicHists") << " HBHE RecHits **NOT** VALID!! " << endl;
01264   }
01265   
01266   if ( hfrh.isValid() ) {
01267     //    LogInfo("EcalCosmicHists") << "event " << ievt << " HF RecHits collection size " << hfrh->size();
01268     const HFRecHitCollection hfHit = *(hfrh.product());
01269     for (HFRecHitCollection::const_iterator hhit=hfHit.begin(); hhit!=hfHit.end(); hhit++) {
01270       hcalEnergy_HF_->Fill(hhit->energy());
01271     }
01272   } else {
01273     //    LogWarning("EcalCosmicHists") << " HF RecHits **NOT** VALID!! " << endl;
01274   } 
01275   
01276   if ( horh.isValid() ) {
01277     //    LogInfo("EcalCosmicHists") << "event " << ievt << " HO RecHits collection size " << horh->size();
01278     const HORecHitCollection hoHit = *(horh.product());
01279     for (HORecHitCollection::const_iterator hhit=hoHit.begin(); hhit!=hoHit.end(); hhit++) {
01280       //     if (hhit->energy() > 0.6){
01281       hcalEnergy_HO_->Fill(hhit->energy());
01282       //     }
01283     }
01284   } else {
01285     //    LogWarning("EcalCosmicHists") << " HO RecHits **NOT** VALID!! " << endl;
01286   }
01287   
01288   // *** end of HCAL code *** //
01289 }
01290 
01291 
01292 
01293 std::vector<bool> EcalCosmicsHists::determineTriggers(const edm::Event& iEvent, const edm::EventSetup& eventSetup)
01294 {
01295   std::vector<bool> l1Triggers; //DT,CSC,RPC,HCAL,ECAL
01296                                 //0 , 1 , 2 , 3  , 4
01297   for(int i=0;i<5;i++)
01298     l1Triggers.push_back(false);
01299   
01300   // get the GMTReadoutCollection
01301   Handle<L1MuGMTReadoutCollection> gmtrc_handle; 
01302   iEvent.getByLabel(l1GMTReadoutRecTag_,gmtrc_handle);
01303   L1MuGMTReadoutCollection const* gmtrc = gmtrc_handle.product();
01304   if (!(gmtrc_handle.isValid())) 
01305     {
01306       LogWarning("EcalCosmicsHists") << "l1MuGMTReadoutCollection" << " not available";
01307       return l1Triggers;
01308     }
01309   // get hold of L1GlobalReadoutRecord
01310   Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
01311   iEvent.getByLabel(l1GTReadoutRecTag_,L1GTRR);
01312   
01313   //Ecal
01314   edm::ESHandle<L1GtTriggerMenu> menuRcd;
01315   eventSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
01316   const L1GtTriggerMenu* menu = menuRcd.product();
01317   edm::Handle< L1GlobalTriggerReadoutRecord > gtRecord;
01318   iEvent.getByLabel( edm::InputTag("gtDigis"), gtRecord);
01319   // Get dWord after masking disabled bits
01320   const DecisionWord dWord = gtRecord->decisionWord();
01321   
01322   bool l1SingleEG1 = menu->gtAlgorithmResult("L1_SingleEG1", dWord);
01323   bool l1SingleEG5 = menu->gtAlgorithmResult("L1_SingleEG5", dWord);
01324   bool l1SingleEG8 = menu->gtAlgorithmResult("L1_SingleEG8", dWord);
01325   bool l1SingleEG10 = menu->gtAlgorithmResult("L1_SingleEG10", dWord);
01326   bool l1SingleEG12 = menu->gtAlgorithmResult("L1_SingleEG12", dWord);
01327   bool l1SingleEG15 = menu->gtAlgorithmResult("L1_SingleEG15", dWord);
01328   bool l1SingleEG20 = menu->gtAlgorithmResult("L1_SingleEG20", dWord);
01329   bool l1SingleEG25 = menu->gtAlgorithmResult("L1_SingleEG25", dWord);
01330   bool l1DoubleNoIsoEGBTBtight = menu->gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_tight", dWord);
01331   bool l1DoubleNoIsoEGBTBloose = menu->gtAlgorithmResult("L1_DoubleNoIsoEG_BTB_loose ", dWord);
01332   bool l1DoubleNoIsoEGTopBottom = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottom", dWord);
01333   bool l1DoubleNoIsoEGTopBottomCen  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen", dWord);
01334   bool l1DoubleNoIsoEGTopBottomCen2  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCen2", dWord);
01335   bool l1DoubleNoIsoEGTopBottomCenVert  = menu->gtAlgorithmResult("L1_DoubleNoIsoEGTopBottomCenVert", dWord);
01336   
01337   l1Triggers[4] = l1SingleEG1 || l1SingleEG5 || l1SingleEG8 || l1SingleEG10 || l1SingleEG12 || l1SingleEG15
01338     || l1SingleEG20 || l1SingleEG25 || l1DoubleNoIsoEGBTBtight || l1DoubleNoIsoEGBTBloose
01339     || l1DoubleNoIsoEGTopBottom || l1DoubleNoIsoEGTopBottomCen || l1DoubleNoIsoEGTopBottomCen2
01340     || l1DoubleNoIsoEGTopBottomCenVert;
01341   
01342   std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
01343   std::vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
01344   for(igmtrr=gmt_records.begin(); igmtrr!=gmt_records.end(); igmtrr++) {
01345     std::vector<L1MuRegionalCand>::const_iterator iter1;
01346     std::vector<L1MuRegionalCand> rmc;
01347     
01348     //DT triggers
01349     int idt = 0;
01350     rmc = igmtrr->getDTBXCands();
01351     for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
01352       if ( !(*iter1).empty() ) {
01353         idt++;
01354       }
01355     }
01356     //if(idt>0) std::cout << "Found " << idt << " valid DT candidates in bx wrt. L1A = " 
01357     //  << igmtrr->getBxInEvent() << std::endl;
01358     if(igmtrr->getBxInEvent()==0 && idt>0) l1Triggers[0] = true;
01359     
01360     //RPC triggers
01361     int irpcb = 0;
01362     rmc = igmtrr->getBrlRPCCands();
01363     for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
01364       if ( !(*iter1).empty() ) {
01365         irpcb++;
01366       }
01367     }
01368     //if(irpcb>0) std::cout << "Found " << irpcb << " valid RPC candidates in bx wrt. L1A = " 
01369     //  << igmtrr->getBxInEvent() << std::endl;
01370     if(igmtrr->getBxInEvent()==0 && irpcb>0) l1Triggers[2] = true;
01371     
01372     //CSC Triggers
01373     int icsc = 0;
01374     rmc = igmtrr->getCSCCands();
01375     for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
01376       if ( !(*iter1).empty() ) {
01377         icsc++;
01378       }
01379     }
01380     //if(icsc>0) std::cout << "Found " << icsc << " valid CSC candidates in bx wrt. L1A = " 
01381     //  << igmtrr->getBxInEvent() << std::endl;
01382     if(igmtrr->getBxInEvent()==0 && icsc>0) l1Triggers[1] = true;
01383   }
01384   
01385   L1GlobalTriggerReadoutRecord const* gtrr = L1GTRR.product();
01386   
01387   for(int ibx=-1; ibx<=1; ibx++) {
01388     bool hcal_top = false;
01389     bool hcal_bot = false;
01390     const L1GtPsbWord psb = gtrr->gtPsbWord(0xbb0d,ibx);
01391     std::vector<int> valid_phi;
01392     if((psb.aData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(4)>>10)&0x1f ); }
01393     if((psb.bData(4)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(4)>>10)&0x1f ); }
01394     if((psb.aData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.aData(5)>>10)&0x1f ); }
01395     if((psb.bData(5)&0x3f) >= 1) {valid_phi.push_back( (psb.bData(5)>>10)&0x1f ); }
01396     std::vector<int>::const_iterator iphi;
01397     for(iphi=valid_phi.begin(); iphi!=valid_phi.end(); iphi++) {
01398       //std::cout << "Found HCAL mip with phi=" << *iphi << " in bx wrt. L1A = " << ibx << std::endl;
01399       if(*iphi<9) hcal_top=true;
01400       if(*iphi>8) hcal_bot=true;
01401     }
01402     if(ibx==0 && hcal_top && hcal_bot) l1Triggers[3]=true;
01403   }
01404   
01405   edm::LogInfo("EcalCosmicsHists") << "**** Trigger SourceSource ****";
01406   if(l1Triggers[0]) edm::LogInfo("EcalCosmicsHists") << "DT";
01407   if(l1Triggers[2]) edm::LogInfo("EcalCosmicsHists") << "RPC";
01408   if(l1Triggers[1]) edm::LogInfo("EcalCosmicsHists") << "CSC";
01409   if(l1Triggers[3]) edm::LogInfo("EcalCosmicsHists") << "HCAL";
01410   if(l1Triggers[4]) edm::LogInfo("EcalCosmicsHists") << "ECAL";
01411   edm::LogInfo("EcalCosmicsHists") << "************************";
01412   
01413   return l1Triggers;
01414 }
01415 
01416 // insert the hist map into the map keyed by FED number
01417 void EcalCosmicsHists::initHists(int FED)
01418 {
01419   using namespace std;
01420   
01421   string FEDid = intToString(FED);
01422   string title1 = "Energy of Seed Crystal ";
01423   title1.append(fedMap_->getSliceFromFed(FED));
01424   title1.append(";Seed Energy (GeV);Number of Cosmics");
01425   string name1 = "SeedEnergyFED";
01426   name1.append(intToString(FED));
01427   int numBins = 200;//(int)round(histRangeMax_-histRangeMin_)+1;
01428   TH1F* hist = new TH1F(name1.c_str(),title1.c_str(), numBins, histRangeMin_, histRangeMax_);
01429   FEDsAndHists_[FED] = hist;
01430   FEDsAndHists_[FED]->SetDirectory(0);
01431   
01432   TH1F* E2hist = new TH1F(Form("E2_FED_%d",FED),Form("E2_FED_%d",FED), numBins, histRangeMin_, histRangeMax_);
01433   FEDsAndE2Hists_[FED] = E2hist;
01434   FEDsAndE2Hists_[FED]->SetDirectory(0);
01435   
01436   TH1F* energyhist = new TH1F(Form("Energy_FED_%d",FED),Form("Energy_FED_%d",FED), numBins, histRangeMin_, histRangeMax_);
01437   FEDsAndenergyHists_[FED] = energyhist;
01438   FEDsAndenergyHists_[FED]->SetDirectory(0);
01439   
01440   TH2F* E2vsE1hist = new TH2F(Form("E2vsE1_FED_%d",FED),Form("E2vsE1_FED_%d",FED), numBins, histRangeMin_, histRangeMax_, numBins, histRangeMin_, histRangeMax_);
01441   FEDsAndE2vsE1Hists_[FED] = E2vsE1hist;
01442   FEDsAndE2vsE1Hists_[FED]->SetDirectory(0);
01443   
01444   TH2F* energyvsE1hist = new TH2F(Form("EnergyvsE1_FED_%d",FED),Form("EnergyvsE1_FED_%d",FED), numBins, histRangeMin_, histRangeMax_, numBins, histRangeMin_, histRangeMax_);
01445   FEDsAndenergyvsE1Hists_[FED] = energyvsE1hist;
01446   FEDsAndenergyvsE1Hists_[FED]->SetDirectory(0);
01447   
01448   title1 = "Time for ";
01449   title1.append(fedMap_->getSliceFromFed(FED));
01450   title1.append(";Relative Time (1 clock = 25ns);Events");
01451   name1 = "TimeFED";
01452   name1.append(intToString(FED));
01453   TH1F* timingHist = new TH1F(name1.c_str(),title1.c_str(),78,-7,7);
01454   FEDsAndTimingHists_[FED] = timingHist;
01455   FEDsAndTimingHists_[FED]->SetDirectory(0);
01456   
01457   TH1F* freqHist = new TH1F(Form("Frequency_FED_%d",FED),Form("Frequency for FED %d;Event Number",FED),100,0.,100000);
01458   FEDsAndFrequencyHists_[FED] = freqHist;
01459   FEDsAndFrequencyHists_[FED]->SetDirectory(0);
01460   
01461   TH1F* iphiProfileHist = new TH1F(Form("iPhi_Profile_FED_%d",FED),Form("iPhi Profile for FED %d",FED),360,1.,361);
01462   FEDsAndiPhiProfileHists_[FED] = iphiProfileHist;
01463   FEDsAndiPhiProfileHists_[FED]->SetDirectory(0);
01464   
01465   TH1F* ietaProfileHist = new TH1F(Form("iEta_Profile_FED_%d",FED),Form("iEta Profile for FED %d",FED),172,-86,86);
01466   FEDsAndiEtaProfileHists_[FED] = ietaProfileHist;
01467   FEDsAndiEtaProfileHists_[FED]->SetDirectory(0);
01468   
01469   TH2F* timingHistVsFreq = new TH2F(Form("timeVsFreqFED_%d",FED),Form("time Vs Freq FED %d",FED),78,-7,7,100,0.,100000);
01470   FEDsAndTimingVsFreqHists_[FED] = timingHistVsFreq;
01471   FEDsAndTimingVsFreqHists_[FED]->SetDirectory(0);
01472   
01473   TH2F* timingHistVsAmp = new TH2F(Form("timeVsAmpFED_%d",FED),Form("time Vs Amp FED %d",FED),78,-7,7,numBins,histRangeMin_,histRangeMax_);
01474   FEDsAndTimingVsAmpHists_[FED] = timingHistVsAmp;
01475   FEDsAndTimingVsAmpHists_[FED]->SetDirectory(0);
01476   
01477   TH1F* numXtalInClusterHist = new TH1F(Form("NumXtalsInCluster_FED_%d",FED),Form("Num active Xtals In Cluster for FED %d;Num Active Xtals",FED),25,0,25);
01478   FEDsAndNumXtalsInClusterHists_[FED] = numXtalInClusterHist;
01479   FEDsAndNumXtalsInClusterHists_[FED]->SetDirectory(0);
01480   
01481   TH2F* OccupHist = new TH2F(Form("occupFED_%d",FED),Form("Occupancy FED %d;i#eta;i#phi",FED),85,1,86,20,1,21);
01482   FEDsAndOccupancyHists_[FED] = OccupHist;
01483   FEDsAndOccupancyHists_[FED]->SetDirectory(0);
01484   
01485   TH2F* timingHistVsPhi = new TH2F(Form("timeVsPhiFED_%d",FED),Form("time Vs Phi FED %d;Relative Time (1 clock = 25ns);i#phi",FED),78,-7,7,20,1,21);
01486   FEDsAndTimingVsPhiHists_[FED] = timingHistVsPhi;
01487   FEDsAndTimingVsPhiHists_[FED]->SetDirectory(0);
01488   
01489   TH2F* timingHistVsModule = new TH2F(Form("timeVsModuleFED_%d",FED),Form("time Vs Module FED %d;Relative Time (1 clock = 25ns);i#eta",FED),78,-7,7,4,1,86);
01490   FEDsAndTimingVsModuleHists_[FED] = timingHistVsModule;
01491   FEDsAndTimingVsModuleHists_[FED]->SetDirectory(0);
01492 
01493   TH2F* dccRuntypeVsBxFED = new TH2F(Form("DCCRuntypeVsBxFED_%d",FED),Form("DCC Runtype vs. BX FED %d",FED),3600,0,3600,24,0,24);
01494   FEDsAndDCCRuntypeVsBxHists_[FED] = dccRuntypeVsBxFED;
01495   FEDsAndDCCRuntypeVsBxHists_[FED]->SetDirectory(0); 
01496   
01497 }
01498 
01499 // ------------ method called once each job just before starting event loop  ------------
01500 void 
01501 EcalCosmicsHists::beginRun(edm::Run const &, edm::EventSetup const & eventSetup)
01502 {
01503   edm::ESHandle< EcalElectronicsMapping > handle;
01504   eventSetup.get< EcalMappingRcd >().get(handle);
01505   ecalElectronicsMap_ = handle.product();
01506   
01507   //Here I will init some of the specific histograms
01508   int numBins = 200;//(int)round(histRangeMax_-histRangeMin_)+1;
01509   
01510   //=============Special Bins for TT and Modules borders=============================
01511   double ttEtaBins[36] = {-85, -80, -75, -70, -65, -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86 };
01512   double modEtaBins[10]={-85, -65, -45, -25, 0, 1, 26, 46, 66, 86};
01513   double ttPhiBins[73];
01514   double modPhiBins[19];
01515   double timingBins[79];
01516   double highEBins[11];
01517   for (int i = 0; i < 79; ++i)
01518     {
01519       timingBins[i]=-7.+double(i)*14./78.;
01520       if (i<73) 
01521         {
01522           ttPhiBins[i]=1+5*i;
01523           if ( i < 19) 
01524             {
01525               modPhiBins[i]=1+20*i;
01526               if (i < 11)
01527                 {
01528                   highEBins[i]=10.+double(i)*20.;
01529                 }
01530             }
01531         }
01532       
01533     }
01534   //=============END Special Bins for TT and Modules borders===========================
01535   
01536   //====================Frequency for Event timing information=========================
01537   double timingEndInSeconds = runTimeLength_*3600.;  
01538   double timingBinWidth     = timingEndInSeconds/double(numTimingBins_);
01539   //====================END Frequency for Event timing information=====================
01540   
01541 
01542   allFedsenergyHist_           = new TH1F("energy_AllClusters","energy_AllClusters;Cluster Energy (GeV)",numBins,histRangeMin_,histRangeMax_);
01543   allFedsenergyHighHist_       = new TH1F("energyHigh_AllClusters","energyHigh_AllClusters;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01544   allFedsenergyOnlyHighHist_       = new TH1F("energyHigh_HighEnergyClusters","energy of High Energy Clusters;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01545   allFedsE2Hist_           = new TH1F("E2_AllClusters","E2_AllClusters;Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,histRangeMax_);
01546   allFedsE2vsE1Hist_       = new TH2F("E2vsE1_AllClusters","E2vsE1_AllClusters;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,histRangeMax_,numBins,histRangeMin_,histRangeMax_);
01547   allFedsenergyvsE1Hist_       = new TH2F("energyvsE1_AllClusters","energyvsE1_AllClusters;Seed Energy (GeV);Energy(GeV)",numBins,histRangeMin_,histRangeMax_,numBins,histRangeMin_,histRangeMax_);
01548   allFedsTimingHist_       = new TH1F("timeForAllFeds","timeForAllFeds;Relative Time (1 clock = 25ns)",78,-7,7);
01549   allFedsTimingVsFreqHist_ = new TH2F("timeVsFreqAllEvent","time Vs Freq All events;Relative Time (1 clock = 25ns);Event Number",78,-7,7,2000,0.,200000);
01550   allFedsTimingVsAmpHist_  = new TH2F("timeVsAmpAllEvents","time Vs Amp All Events;Relative Time (1 clock = 25ns);Amplitude (GeV)",78,-7,7,numBins,histRangeMin_,histRangeMax_);
01551   allFedsFrequencyHist_    = new TH1F("FrequencyAllEvent","Frequency for All events;Event Number",2000,0.,200000);
01552   
01553   //--------Special Hists for times stamp info----------------------------------------------
01554   allFedsFreqTimeHist_     = new TH1F("FrequencyAllEventsInTime",Form("Time of Cosmic Events; Time (s);Passing Event rate/%5g s",timingBinWidth),numTimingBins_,0.,timingEndInSeconds);
01555   allFedsFreqTimeVsPhiHist_= new TH2F("FrequencyAllEventsInTimeVsPhi",Form("Time of Cosmic Events vs iPhi; iPhi;Time (s)/%5g s",timingBinWidth*360.),360,1.,361.,numTimingBins_/360,0.,timingEndInSeconds);
01556   allFedsFreqTimeVsPhiTTHist_= new TH2F("FrequencyAllEventsInTimeVsTTPhi",Form("Time of Cosmic Events vs iPhi (TT bins); iPhi;Time (s)/%5g s",timingBinWidth*72.),72,1.,361.,numTimingBins_/72,0.,timingEndInSeconds);
01557   allFedsFreqTimeVsEtaHist_= new TH2F("FrequencyAllEventsInTimeVsEta",Form("Time of Cosmic Events vs iEta; Time (s)/%5g s; iEta" ,timingBinWidth*172.),numTimingBins_/172,0.,timingEndInSeconds,172,-86.,86.);
01558   allFedsFreqTimeVsEtaTTHist_= new TH2F("FrequencyAllEventsInTimeVsTTEta",Form("Time of Cosmic Events vs Eta (TT bins);Time (s)/%5g s; iEta" ,timingBinWidth*35.),numTimingBins_/35,0.,timingEndInSeconds,35,ttEtaBins);
01559   //--------END Special Hists for times stamp info------------------------------------------
01560   
01561   allFedsiPhiProfileHist_  = new TH1F("iPhiProfileAllEvents","iPhi Profile all events;i#phi",360,1.,361.);
01562   allFedsiEtaProfileHist_  = new TH1F("iEtaProfileAllEvents","iEta Profile all events;i#eta",172,-86,86);
01563   
01564   allOccupancy_            = new TH2F("OccupancyAllEvents","Occupancy all events;i#phi;i#eta",360,1.,361.,172,-86,86);  
01565   TrueOccupancy_            = new TH2F("TrueOccupancyAllEvents","True Occupancy all events;#phi;#eta",360,-3.14159,3.14159,172,-1.5,1.5);
01566   allOccupancyCoarse_      = new TH2F("OccupancyAllEventsCoarse","Occupancy all events Coarse;i#phi;i#eta",360/5,1,361.,35,ttEtaBins);  
01567   TrueOccupancyCoarse_      = new TH2F("TrueOccupancyAllEventsCoarse","True Occupancy all events Coarse;#phi;#eta",360/5,-3.14159,3.14159,34,-1.5,1.5);
01568   
01569   
01570   // single xtal cluster occupancy
01571   allOccupancySingleXtal_  = new TH2F("OccupancySingleXtal","Occupancy single xtal clusters;i#phi;i#eta",360,1.,361.,172,-86,86);
01572   energySingleXtalHist_    = new TH1F("energy_SingleXtalClusters","Energy single xtal clusters;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01573   
01574   allFedsTimingPhiHist_          = new TH2F("timePhiAllFEDs","time vs Phi for all FEDs (TT binning);i#phi;Relative Time (1 clock = 25ns)",72,1,361,78,-7,7);
01575   allFedsTimingPhiEbpHist_       = new TH2F("timePhiEBP","time vs Phi for FEDs in EB+ (TT binning) ;i#phi;Relative Time (1 clock = 25ns)",72,1,361,78,-7,7);
01576   allFedsTimingPhiEbmHist_       = new TH2F("timePhiEBM","time vs Phi for FEDs in EB- (TT binning);i#phi;Relative Time (1 clock = 25ns)",72,1,361,78,-7,7);
01577   allFedsTimingPhiEtaHist_       = new TH3F("timePhiEtaAllFEDs","(Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9,modEtaBins,78,timingBins);  
01578   allFedsTimingTTHist_           = new TH3F("timeTTAllFEDs","(Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01579   allFedsTimingLMHist_           = new TH2F("timeLMAllFEDs","(LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 92,78,-7,7);
01580   
01581   allFedsTimingEbpHist_       = new TH1F("timeEBP","time for FEDs in EB+;Relative Time (1 clock = 25ns)",78,-7,7);
01582   allFedsTimingEbmHist_       = new TH1F("timeEBM","time for FEDs in EB-;Relative Time (1 clock = 25ns)",78,-7,7);
01583   allFedsTimingEbpTopHist_    = new TH1F("timeEBPTop","time for FEDs in EB+ Top;Relative Time (1 clock = 25ns)",78,-7,7);
01584   allFedsTimingEbmTopHist_    = new TH1F("timeEBMTop","time for FEDs in EB- Top;Relative Time (1 clock = 25ns)",78,-7,7);
01585   allFedsTimingEbpBottomHist_ = new TH1F("timeEBPBottom","time for FEDs in EB+ Bottom;Relative Time (1 clock = 25ns)",78,-7,7);
01586   allFedsTimingEbmBottomHist_ = new TH1F("timeEBMBottom","time for FEDs in EB- Bottom;Relative Time (1 clock = 25ns)",78,-7,7);
01587   
01588   numberofCosmicsHist_ = new TH1F("numberofCosmicsPerEvent","Number of cosmics per event;Number of Cosmics",30,0,30);
01589   numberofCosmicsHistEB_ = new TH1F("numberofCosmicsPerEvent_EB","Number of cosmics per event EB;Number of Cosmics",30,0,30);
01590 
01591   numberofCosmicsWTrackHist_ = new TH1F("numberofCosmicsWTrackPerEvent","Number of cosmics with track per event",30,0,30);
01592   numberofCosmicsTopBottomHist_ = new TH1F("numberofCosmicsTopBottomPerEvent","Number of top bottom cosmics per event;Number of Cosmics",30,0,30);
01593   numberofGoodEvtFreq_  = new TH1F("frequencyOfGoodEvents","Number of events with cosmic vs Event;Event Number;Number of Good Events/100 Events",2000,0,200000);
01594   
01595   numberofCrossedEcalIdsHist_ = new TH1F("numberofCrossedEcalCosmicsPerEvent","Number of crossed ECAL cosmics per event;Number of Crossed Cosmics",10,0,10);
01596   
01597   allOccupancyExclusiveECAL_            = new TH2F("OccupancyAllEvents_ExclusiveECAL","Occupancy all events Exclusive ECAL ;i#phi;i#eta",360,1.,361.,172,-86,86);
01598   allOccupancyCoarseExclusiveECAL_      = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL","Occupancy all events Coarse Exclusive ECAL;i#phi;i#eta",360/5,ttPhiBins,35, ttEtaBins);
01599   allOccupancyECAL_            = new TH2F("OccupancyAllEvents_ECAL","Occupancy all events ECAL;i#phi;i#eta",360,1.,361.,172,-86,86);
01600   allOccupancyCoarseECAL_      = new TH2F("OccupancyAllEventsCoarse_ECAL","Occupancy all events Coarse ECAL;i#phi;i#eta",360/5,ttPhiBins,35, ttEtaBins);
01601   allFedsTimingHistECAL_       = new TH1F("timeForAllFeds_ECAL","timeForAllFeds ECAL;Relative Time (1 clock = 25ns)",78,-7,7);
01602   allFedsTimingPhiEtaHistECAL_ = new TH3F("timePhiEtaAllFEDs_ECAL","ECAL (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9, modEtaBins,78,timingBins); 
01603   allFedsTimingTTHistECAL_     = new TH3F("timeTTAllFEDs_ECAL","ECAL (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01604   allFedsTimingLMHistECAL_     = new TH2F("timeLMAllFEDs_ECAL","ECAL (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 92,78,-7,7); 
01605   
01606   allOccupancyExclusiveDT_            = new TH2F("OccupancyAllEvents_ExclusiveDT","Occupancy all events Exclusive DT;i#phi;i#eta",360,1.,361.,172,-86,86);
01607   allOccupancyCoarseExclusiveDT_      = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT","Occupancy all events Coarse Exclusive DT;i#phi;i#eta",360/5,1,361.,35,ttEtaBins);
01608   allOccupancyDT_            = new TH2F("OccupancyAllEvents_DT","Occupancy all events DT;i#phi;i#eta",360,1.,361.,172,-86,86);
01609   allOccupancyCoarseDT_      = new TH2F("OccupancyAllEventsCoarse_DT","Occupancy all events Coarse DT;i#phi;i#eta",360/5,1,361.,35,ttEtaBins);
01610   allFedsTimingHistDT_       = new TH1F("timeForAllFeds_DT","timeForAllFeds DT;Relative Time (1 clock = 25ns)",78,-7,7);
01611   allFedsTimingPhiEtaHistDT_ = new TH3F("timePhiEtaAllFEDs_DT","DT (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9, modEtaBins,78,timingBins);  
01612   allFedsTimingTTHistDT_   = new TH3F("timeTTAllFEDs_DT","DT (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01613   allFedsTimingLMHistDT_   = new TH2F("timeLMAllFEDs_DT","DT (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 92,78,-7,7); 
01614   
01615   allOccupancyExclusiveRPC_            = new TH2F("OccupancyAllEvents_ExclusiveRPC","Occupancy all events Exclusive RPC;i#phi;i#eta",360,1.,361.,172,-86,86);
01616   allOccupancyCoarseExclusiveRPC_      = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC","Occupancy all events Coarse Exclusive RPC;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01617   allOccupancyRPC_            = new TH2F("OccupancyAllEvents_RPC","Occupancy all events RPC;i#phi;i#eta",360,1.,361.,172,-86,86);
01618   allOccupancyCoarseRPC_      = new TH2F("OccupancyAllEventsCoarse_RPC","Occupancy all events Coarse RPC;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01619   allFedsTimingHistRPC_       = new TH1F("timeForAllFeds_RPC","timeForAllFeds RPC;Relative Time (1 clock = 25ns)",78,-7,7);
01620   allFedsTimingPhiEtaHistRPC_ = new TH3F("timePhiEtaAllFEDs_RPC","RPC (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9, modEtaBins,78,timingBins);  
01621   allFedsTimingTTHistRPC_     = new TH3F("timeTTAllFEDs_RPC","RPC (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01622   allFedsTimingLMHistRPC_     = new TH2F("timeLMAllFEDs_RPC","RPC (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 92,78,-7,7); 
01623   
01624   allOccupancyExclusiveCSC_            = new TH2F("OccupancyAllEvents_ExclusiveCSC","Occupancy all events Exclusive CSC;i#phi;i#eta",360,1.,361.,172,-86,86);
01625   allOccupancyCoarseExclusiveCSC_      = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC","Occupancy all events Coarse Exclusive CSC;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01626   allOccupancyCSC_            = new TH2F("OccupancyAllEvents_CSC","Occupancy all events CSC;i#phi;i#eta",360,1.,361.,172,-86,86);
01627   allOccupancyCoarseCSC_      = new TH2F("OccupancyAllEventsCoarse_CSC","Occupancy all events Coarse CSC;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01628   allFedsTimingHistCSC_       = new TH1F("timeForAllFeds_CSC","timeForAllFeds CSC;Relative Time (1 clock = 25ns)",78,-7,7);
01629   allFedsTimingPhiEtaHistCSC_ = new TH3F("timePhiEtaAllFEDs_CSC","CSC (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9, modEtaBins,78,timingBins);  
01630   allFedsTimingTTHistCSC_    = new TH3F("timeTTAllFEDs_CSC","CSC (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01631   allFedsTimingLMHistCSC_    = new TH2F("timeLMAllFEDs_CSC","CSC (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 62,78,-7,7); 
01632   
01633   allOccupancyExclusiveHCAL_            = new TH2F("OccupancyAllEvents_ExclusiveHCAL","Occupancy all events Exclusive HCAL;i#phi;i#eta",360,1.,361.,172,-86,86);
01634   allOccupancyCoarseExclusiveHCAL_      = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL","Occupancy all events Coarse Exclusive HCAL;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01635   allOccupancyHCAL_            = new TH2F("OccupancyAllEvents_HCAL","Occupancy all events HCAL;i#phi;i#eta",360,1.,361.,172,-86,86);
01636   allOccupancyCoarseHCAL_      = new TH2F("OccupancyAllEventsCoarse_HCAL","Occupancy all events Coarse HCAL;i#phi;i#eta",360/5,1,361.,35, ttEtaBins);
01637   allFedsTimingHistHCAL_       = new TH1F("timeForAllFeds_HCAL","timeForAllFeds HCAL;Relative Time (1 clock = 25ns)",78,-7,7);
01638   allFedsTimingPhiEtaHistHCAL_ = new TH3F("timePhiEtaAllFEDs_HCAL","HCAL (Phi,Eta,time) for all FEDs (SM,M binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",18,modPhiBins,9, modEtaBins,78,timingBins);  
01639   allFedsTimingTTHistHCAL_     = new TH3F("timeTTAllFEDs_HCAL","HCAL (Phi,Eta,time) for all FEDs (SM,TT binning);i#phi;i#eta;Relative Time (1 clock = 25ns)",72,ttPhiBins,35,ttEtaBins,78,timingBins); 
01640   allFedsTimingLMHistHCAL_     = new TH2F("timeLMAllFEDs_HCAL","HCAL (LM,time) for all FEDs (SM,LM binning);LM;Relative Time (1 clock = 25ns)",92, 1, 92,78,-7,7); 
01641   
01642   TrueBCOccupancy_            = new TH2F("BCTrueOccupancyAllEvents","True SB Occupancy all events;#phi;#eta",360,-3.14159,3.14159,172,-1.5,1.5);
01643   TrueBCOccupancyCoarse_      = new TH2F("BCTrueOccupancyAllEventsCoarse","True BC Occupancy all events Coarse;#phi;#eta",360/5,-3.14159,3.14159,34,-1.5 ,1.5);
01644   
01645   numberofBCinSC_ = new TH1F("numberofBCinSC","Number of Basic Clusters in Super Cluster;Num Basic Clusters",20,0,20);//SC
01646   numberofBCinSCphi_ = new TH2F("numberofBCinSCphi","Number of Basic Clusters in Super Cluster;phi;Num Basic Clusters",360/5,-3.14159,3.14159,20,0,20);//SC
01647   
01648   allFedsTimingHistEcalMuon_   = new TH1F("timeForAllFeds_EcalMuon","timeForAllFeds Ecal+Muon;Relative Time (1 clock = 25ns)",78,-7,7);
01649   
01650   triggerHist_ = new TH1F("triggerHist","Trigger Number",5,0,5);
01651   triggerHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01652   triggerHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01653   triggerHist_->GetXaxis()->SetBinLabel(3,"DT");
01654   triggerHist_->GetXaxis()->SetBinLabel(4,"RPC");
01655   triggerHist_->GetXaxis()->SetBinLabel(5,"CSC");
01656   
01657   triggerExclusiveHist_ = new TH1F("triggerExclusiveHist","Trigger Number (Mutually Exclusive)",5,0,5);  triggerExclusiveHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01658   triggerExclusiveHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01659   triggerExclusiveHist_->GetXaxis()->SetBinLabel(3,"DT");
01660   triggerExclusiveHist_->GetXaxis()->SetBinLabel(4,"RPC");
01661   triggerExclusiveHist_->GetXaxis()->SetBinLabel(5,"CSC");
01662   
01663   runNumberHist_ = new TH1F("runNumberHist","Run Number",1,0,1);
01664   
01665   deltaRHist_ = new TH1F("deltaRHist","deltaR",500,-0.5,499.5); 
01666   deltaEtaHist_ = new TH1F("deltaIEtaHist","deltaIEta",170,-85.5,84.5);
01667   deltaPhiHist_ = new TH1F("deltaIPhiHist","deltaIPhi",720,-360.5,359.5);
01668   ratioAssocTracksHist_ = new TH1F("ratioAssocTracks","num assoc. tracks/tracks through Ecal",11,0,1.1);
01669   ratioAssocClustersHist_ = new TH1F("ratioAssocClusters","num assoc. clusters/total clusters",11,0,1.1);
01670   trackAssoc_muonsEcal_= new TH2F("trackAssoc_muonsEcal","Map of muon hits in Ecal", 360,1.,361.,172,-86,86);//360, 0 , 360, 170,-85 ,85);
01671   deltaEtaDeltaPhiHist_ = new TH2F("deltaEtaDeltaPhi","Delta ieta vs. delta iphi",170,-85.5,84.5,720,-360.5,359.5); 
01672   seedTrackEtaHist_ = new TH2F("seedTrackEta","track ieta vs. seed ieta",170,-85.5,84.5,170,-85.5,84.5); 
01673   seedTrackPhiHist_ = new TH2F("seedTrackPhi","track iphi vs. seed iphi",720,-360.5,359.5,720,-360.5,359.5); 
01674 
01675   dccEventVsBxHist_ = new TH2F("dccEventVsBx","DCC Runtype vs. bunch crossing",3600,0,3600,24,0,24);
01676   dccBXErrorByFEDHist_ = new TH1F("dccBXErrorByFED","Incorrect BX number by FED",54,601,655);
01677   dccOrbitErrorByFEDHist_ = new TH1F("dccOrbitErrorByFED","Incorrect orbit number by FED",54,601,655);
01678   dccRuntypeErrorByFEDHist_ = new TH1F("dccRuntypeErrorByFED","Incorrect DCC Runtype by FED",54,601,655);
01679   dccRuntypeHist_ = new TH1F("dccRuntype","DCC Runtype frequency",24,0,24);
01680   dccErrorVsBxHist_ = new TH2F("dccErrorVsBX","DCC Errors vs. BX",3600,0,3600,3,0,3);
01681   
01682   hcalEnergy_HBHE_ = new TH1F("hcalEnergy_HBHE","RecHit Energy HBHE",440,-10,100);
01683   hcalEnergy_HF_   = new TH1F("hcalEnergy_HF","RecHit Energy HF",440,-10,100);
01684   hcalEnergy_HO_   = new TH1F("hcalEnergy_HO","RecHit Energy HO",440,-10,100);
01685   hcalHEHBecalEB_  = new TH2F("hcalHEHBecalEB","HCAL HBHE RecHit energy vs ECAL EB energy",numBins,histRangeMin_,300.0,40,-5,5);
01686   
01687   NumXtalsInClusterHist_              = new TH1F("NumXtalsInClusterAllHist","Number of Xtals in Cluster;NumXtals",150,0,150);
01688   numxtalsVsEnergy_                   = new TH2F("NumXtalsVsEnergy","Number of Xtals in Cluster vs Energy;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,histRangeMax_, 150,0,150);
01689   numxtalsVsHighEnergy_               = new TH2F("NumXtalsVsHighEnergy","Number of Xtals in Cluster vs Energy;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,200., 150,0,150);
01690   
01691   // high energy analysis
01692   allOccupancyHighEnergy_             = new TH2F("OccupancyHighEnergyEvents","Occupancy high energy events;i#phi;i#eta",360,1.,361.,172,-86,86);
01693   allOccupancyHighEnergyCoarse_       = new TH2F("OccupancyHighEnergyEventsCoarse","Occupancy high energy events Coarse;i#phi;i#eta",72,ttPhiBins,35,ttEtaBins); 
01694   allFedsOccupancyHighEnergyHist_     = new TH3F("OccupancyHighEnergyEvents3D","(Phi,Eta,energy) for all high energy events;i#phi;i#eta;energy (GeV)",18,modPhiBins,9,modEtaBins,10,highEBins);
01695   allFedsNumXtalsInClusterHist_       = new TH1F("NumActiveXtalsInClusterAllHist","Number of active Xtals in Cluster;NumXtals",100,0,100);
01696   
01697   HighEnergy_NumXtal                  = new TH1F("HighEnergy_NumXtal","Num crystals in high E clusters;num crystals",150,0,150);
01698   HighEnergy_NumXtalFedId             = new TH2F("HighEnergy_NumXtalFedId","Num crystals in cluster vs FedId;FedId;num crystals",36,610.,645.,150,0,150);
01699   HighEnergy_NumXtaliphi              = new TH2F("HighEnergy_NumXtaliphi","Num crystals in cluster vs iphi;i#phi;num crystals",360,1.,361.,150,0,150);
01700   HighEnergy_energy3D                 = new TH3F("HighEnergy_energy3D","(Phi,Eta,energy) for all high energy events;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01701   
01702   HighEnergy_energyNumXtal            = new TH2F("HighEnergy_energyNumXtal","Energy in cluster vs Num crystals in cluster;num crystals;energy",150,0,150,200,0.,200.);
01703   
01704   HighEnergy_bestSeed                 = new TH1F("HighEnergy_bestSeedEnergy","BestSeed Energy from TrackAss",200,0.,200.);
01705   HighEnergy_bestSeedOccupancy        = new TH2F("HighEnergy_bestSeedOccupancy","Occupancy HighEn events from TrackAss;i#phi;i#eta",360,1.,361.,172,-86,86);
01706   
01707   HighEnergy_numClusHighEn            = new TH1F("HighEnergy_numClusHighEn","Num High Energy Clusters",7,0,7);
01708   HighEnergy_ratioClusters            = new TH1F("HighEnergy_ratioClusters","Num High Energy Clusters/Num tot Clusters",100,0.,1.1);
01709   
01710   HighEnergy_numRecoTrackBarrel       = new TH1F("HighEnergy_numRecoTracksBarrel","Num BarrelRecoTracks",10,0,10);
01711   HighEnergy_TracksAngle              = new TH1F("HighEnergy_TracksAngle","Angle between tracks",720,0.,180.);
01712   HighEnergy_TracksAngleTopBottom     = new TH1F("HighEnergy_TopBottomTracksAngle","Angle between top-bottom tracks",720,0.,180.);
01713   
01714   HighEnergy_2GeV_occuCoarse          = new TH2F("HighEnergy_occu2GeV_Coarse","Occupancy high energy events with more than 2 GeV;i#phi;i#eta",72,ttPhiBins,35,ttEtaBins); 
01715   HighEnergy_2GeV_occu3D              = new TH3F("HighEnergy_2GeV_energy3D","(iphi,ieta,energy) for all high energy events w > 10 GeV;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01716   HighEnergy_100GeV_occuCoarse        = new TH2F("HighEnergy_occu100GeV_Coarse","Occupancy high energy events with more than 100 GeV;i#phi;i#eta",72,ttPhiBins,35,ttEtaBins); 
01717   HighEnergy_100GeV_occu3D            = new TH3F("HighEnergy_100GeV_energy3D","(iphi,ieta,energy) for all high energy events more than 100 GeV;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01718   HighEnergy_0tracks_occu3D           = new TH3F("HighEnergy_0Tracks_energy3D","(iphi,ieta,energy) for all events with 0 tracks;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01719   HighEnergy_1tracks_occu3D           = new TH3F("HighEnergy_1Tracks_energy3D","(iphi,ieta,energy) for all events with 1 tracks;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01720   HighEnergy_2tracks_occu3D           = new TH3F("HighEnergy_2Tracks_energy3D","(iphi,ieta,energy) for all events with 2 tracks;i#phi;i#eta;energy (GeV)",72,ttPhiBins,35,ttEtaBins,10,highEBins);
01721   HighEnergy_0tracks_occu3DXtal       = new TH3F("HighEnergy_0Tracks_energy3DXtal","(iphi,ieta,energy) for all events with 0 tracks;i#phi;i#eta;energy (GeV)",360,1.,361.,172,-86,86,200,0.,200.);
01722   HighEnergy_1tracks_occu3DXtal       = new TH3F("HighEnergy_1Tracks_energy3DXtal","(iphi,ieta,energy) for all events with 1 tracks;i#phi;i#eta;energy (GeV)",360,1.,361.,172,-86,86,200,0.,200.);
01723   HighEnergy_2tracks_occu3DXtal       = new TH3F("HighEnergy_2Tracks_energy3DXtal","(iphi,ieta,energy) for all events with 2 tracks;i#phi;i#eta;energy (GeV)",360,1.,361.,172,-86,86,200,0.,200.);
01724 
01725   //EE histograms
01726 
01727   // EE-
01728   EEM_FedsSeedEnergyHist_           = new TH1F("SeedEnergyAllFEDs","Seed Energy for EEM Feds; Seed Energy (GeV)",200,histRangeMin_,10.0);
01729 
01730   EEM_AllOccupancyCoarse_           = new TH2F("OccupancyAllEventsCoarse","Occupancy all events Coarse EEM;ix;iy",20,0,100,20,0,100);
01731   EEM_AllOccupancy_                 = new TH2F("OccupancyAllEvents","Occupancy all events EEM;ix;iy",100,0,100,100,0,100);
01732   EEM_FedsenergyHist_               = new TH1F("energy_AllClusters","energy_AllClusters_EEM;Cluster Energy (GeV)",numBins,histRangeMin_,10.0);
01733   EEM_FedsenergyHighHist_           = new TH1F("energyHigh_AllClusters","energyHigh_AllClusters in EEM;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01734   EEM_FedsenergyOnlyHighHist_       = new TH1F("energyHigh_HighEnergyClusters","energy of High Energy Clusters in EEM;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01735   EEM_FedsE2Hist_                   = new TH1F("E2_AllClusters","E2_AllClusters_EEM;Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,10.0);
01736   EEM_FedsE2vsE1Hist_               = new TH2F("E2vsE1_AllClusters","E2vsE1_AllClusters_EEM;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,10.0,numBins,histRangeMin_,10.0);
01737   EEM_FedsenergyvsE1Hist_           = new TH2F("energyvsE1_AllClusters","energyvsE1_AllClusters_EEM;Seed Energy (GeV);Energy(GeV)",numBins,histRangeMin_,10.0,numBins,histRangeMin_,10.0);
01738   EEM_FedsTimingHist_               = new TH1F("timeForAllFeds","timeForAllFeds_EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01739   EEM_numberofCosmicsHist_ = new TH1F("numberofCosmicsPerEvent","Number of cosmics per event EEM;Number of Cosmics",30,0,30);
01740   
01741   EEM_FedsTimingVsAmpHist_          = new TH2F("timeVsAmpAllEvents","time Vs Amp All Events EEM;Relative Time (1 clock = 25ns);Amplitude (GeV)",78,-7,7,numBins,histRangeMin_,10.0);
01742   EEM_FedsTimingTTHist_             = new TH3F("timeTTAllFEDs","(ix,iy,time) for all FEDs (SM,TT binning) EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01743   
01744   EEM_OccupancySingleXtal_          = new TH2F("OccupancySingleXtal","Occupancy single xtal clusters EEM;ix;iy",100,0,100,100,0,100);
01745   EEM_energySingleXtalHist_         = new TH1F("energy_SingleXtalClusters","Energy single xtal clusters EEM;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01746   
01747   EEM_OccupancyExclusiveECAL_       = new TH2F("OccupancyAllEvents_ExclusiveECAL","Occupancy all events Exclusive ECAL  EEM;ix;iy",100,0,100,100,0,100);
01748   EEM_OccupancyCoarseExclusiveECAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL","Occupancy all events Coarse Exclusive ECAL EEM;ix;iy",20,0,100,20,0,100);
01749   EEM_OccupancyECAL_                = new TH2F("OccupancyAllEvents_ECAL","Occupancy all events ECAL EEM;ix;iy",100,0,100,100,0,100);
01750   EEM_OccupancyCoarseECAL_          = new TH2F("OccupancyAllEventsCoarse_ECAL","Occupancy all events Coarse ECAL EEM;ix;iy",20,0,100,20,0,100);
01751   EEM_FedsTimingHistECAL_           = new TH1F("timeForAllFeds_ECAL","timeForAllFeds ECAL EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01752   EEM_FedsTimingTTHistECAL_         = new TH3F("timeTTAllFEDs_ECAL","(ix,iy,time) for all FEDs (SM,TT binning) ECAL EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01753   
01754   EEM_OccupancyExclusiveDT_         = new TH2F("OccupancyAllEvents_ExclusiveDT","Occupancy all events Exclusive DT EEM;ix;iy",100,0,100,100,0,100);
01755   EEM_OccupancyCoarseExclusiveDT_   = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT","Occupancy all events Coarse Exclusive DT EEM;ix;iy",20,0,100,20,0,100);
01756   EEM_OccupancyDT_                  = new TH2F("OccupancyAllEvents_DT","Occupancy all events DT EEM;ix;iy",100,0,100,100,0,100);
01757   EEM_OccupancyCoarseDT_            = new TH2F("OccupancyAllEventsCoarse_DT","Occupancy all events Coarse DT EEM;ix;iy",20,0,100,20,0,100);
01758   EEM_FedsTimingHistDT_             = new TH1F("timeForAllFeds_DT","timeForAllFeds DT EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01759   EEM_FedsTimingTTHistDT_         = new TH3F("timeTTAllFEDs_DT","(ix,iy,time) for all FEDs (SM,TT binning) DT EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01760   
01761   EEM_OccupancyExclusiveRPC_        = new TH2F("OccupancyAllEvents_ExclusiveRPC","Occupancy all events Exclusive RPC EEM;ix;iy",100,0,100,100,0,100);
01762   EEM_OccupancyCoarseExclusiveRPC_  = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC","Occupancy all events Coarse Exclusive RPC EEM;ix;iy",20,0,100,20,0,100);
01763   EEM_OccupancyRPC_                 = new TH2F("OccupancyAllEvents_RPC","Occupancy all events RPC EEM;ix;iy",100,0,100,100,0,100);
01764   EEM_OccupancyCoarseRPC_           = new TH2F("OccupancyAllEventsCoarse_RPC","Occupancy all events Coarse RPC EEM;ix;iy",20,0,100,20,0,100);
01765   EEM_FedsTimingHistRPC_            = new TH1F("timeForAllFeds_RPC","timeForAllFeds RPC EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01766   EEM_FedsTimingTTHistRPC_          = new TH3F("timeTTAllFEDs_RPC","(ix,iy,time) for all FEDs (SM,TT binning) RPC EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01767   
01768   EEM_OccupancyExclusiveCSC_        = new TH2F("OccupancyAllEvents_ExclusiveCSC","Occupancy all events Exclusive CSC EEM;ix;iy",100,0,100,100,0,100);
01769   EEM_OccupancyCoarseExclusiveCSC_  = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC","Occupancy all events Coarse Exclusive CSC EEM;ix;iy",20,0,100,20,0,100);
01770   EEM_OccupancyCSC_                 = new TH2F("OccupancyAllEvents_CSC","Occupancy all events CSC EEM;ix;iy",100,0,100,100,0,100);
01771   EEM_OccupancyCoarseCSC_           = new TH2F("OccupancyAllEventsCoarse_CSC","Occupancy all events Coarse CSC EEM;ix;iy",20,0,100,20,0,100);
01772   EEM_FedsTimingHistCSC_            = new TH1F("timeForAllFeds_CSC","timeForAllFeds CSC EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01773   EEM_FedsTimingTTHistCSC_          = new TH3F("timeTTAllFEDs_CSC","(ix,iy,time) for all FEDs (SM,TT binning) CSC EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01774   
01775   EEM_OccupancyExclusiveHCAL_       = new TH2F("OccupancyAllEvents_ExclusiveHCAL","Occupancy all events Exclusive HCAL EEM;ix;iy",100,0,100,100,0,100);
01776   EEM_OccupancyCoarseExclusiveHCAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL","Occupancy all events Coarse Exclusive HCAL EEM;ix;iy",20,0,100,20,0,100);
01777   EEM_OccupancyHCAL_                = new TH2F("OccupancyAllEvents_HCAL","Occupancy all events HCAL EEM;ix;iy",100,0,100,100,0,100);
01778   EEM_OccupancyCoarseHCAL_          = new TH2F("OccupancyAllEventsCoarse_HCAL","Occupancy all events Coarse HCAL EEM;ix;iy",20,0,100,20,0,100);
01779   EEM_FedsTimingHistHCAL_           = new TH1F("timeForAllFeds_HCAL","timeForAllFeds HCAL EEM;Relative Time (1 clock = 25ns)",78,-7,7);
01780   EEM_FedsTimingTTHistHCAL_         = new TH3F("timeTTAllFEDs_HCAL","(ix,iy,time) for all FEDs (SM,TT binning) HCAL EEM;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01781   
01782   EEM_numberofBCinSC_               = new TH1F("numberofBCinSC","Number of Basic Clusters in Super Cluster EEM;Num Basic Clusters",20,0,20);
01783   
01784   EEM_triggerHist_                  = new TH1F("triggerHist","Trigger Number EEM",5,0,5);
01785   EEM_triggerHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01786   EEM_triggerHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01787   EEM_triggerHist_->GetXaxis()->SetBinLabel(3,"DT");
01788   EEM_triggerHist_->GetXaxis()->SetBinLabel(4,"RPC");
01789   EEM_triggerHist_->GetXaxis()->SetBinLabel(5,"CSC");
01790   
01791   EEM_triggerExclusiveHist_         = new TH1F("triggerExclusiveHist","Trigger Number (Mutually Exclusive) EEM",5,0,5);  triggerExclusiveHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01792   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01793   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(3,"DT");
01794   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(4,"RPC");
01795   EEM_triggerExclusiveHist_->GetXaxis()->SetBinLabel(5,"CSC");
01796   
01797   EEM_NumXtalsInClusterHist_        = new TH1F("NumXtalsInClusterAllHist","Number of Xtals in Cluster EEM;NumXtals",150,0,150);
01798   EEM_numxtalsVsEnergy_             = new TH2F("NumXtalsVsEnergy","Number of Xtals in Cluster vs Energy EEM;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,10.0, 150,0,150);
01799   EEM_numxtalsVsHighEnergy_         = new TH2F("NumXtalsVsHighEnergy","Number of Xtals in Cluster vs Energy EEM;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,200., 150,0,150);
01800   
01801   EEM_OccupancyHighEnergy_          = new TH2F("OccupancyHighEnergyEvents","Occupancy high energy events EEM;ix;iy",100,0,100,100,0,100);
01802   EEM_OccupancyHighEnergyCoarse_    = new TH2F("OccupancyHighEnergyEventsCoarse","Occupancy high energy events Coarse EEM;ix;iy",20,0,100,20,0,100);
01803   
01804   EEM_FedsNumXtalsInClusterHist_    = new TH1F("NumActiveXtalsInClusterAllHist","Number of active Xtals in Cluster EEM;NumXtals",100,0,100);
01805 
01806   
01807   // EE+
01808   EEP_FedsSeedEnergyHist_           = new TH1F("SeedEnergyAllFEDs","Seed Energy for EEP Feds; Seed Energy (GeV)",200,histRangeMin_,10.0);
01809 
01810   EEP_AllOccupancyCoarse_           = new TH2F("OccupancyAllEventsCoarse","Occupancy all events Coarse EEP;ix;iy",20,0,100,20,0,100);
01811   EEP_AllOccupancy_                 = new TH2F("OccupancyAllEvents","Occupancy all events EEP;ix;iy",100,0,100,100,0,100);
01812   EEP_FedsenergyHist_               = new TH1F("energy_AllClusters","energy_AllClusters_EEP;Cluster Energy (GeV)",numBins,histRangeMin_,10.0);
01813   EEP_FedsenergyHighHist_           = new TH1F("energyHigh_AllClusters","energyHigh_AllClusters in EEP;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01814   EEP_FedsenergyOnlyHighHist_       = new TH1F("energyHigh_HighEnergyClusters","energy of High Energy Clusters in EEP;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01815   EEP_FedsE2Hist_                   = new TH1F("E2_AllClusters","E2_AllClusters_EEP;Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,10.0);
01816   EEP_FedsE2vsE1Hist_               = new TH2F("E2vsE1_AllClusters","E2vsE1_AllClusters_EEP;Seed Energy (GeV);Seed+highest neighbor energy (GeV)",numBins,histRangeMin_,10.0,numBins,histRangeMin_,10.0);
01817   EEP_FedsenergyvsE1Hist_           = new TH2F("energyvsE1_AllClusters","energyvsE1_AllClusters_EEP;Seed Energy (GeV);Energy(GeV)",numBins,histRangeMin_,10.0,numBins,histRangeMin_,10.0);
01818   EEP_FedsTimingHist_               = new TH1F("timeForAllFeds","timeForAllFeds_EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01819   EEP_numberofCosmicsHist_ = new TH1F("numberofCosmicsPerEvent","Number of cosmics per event EEP;Number of Cosmics",30,0,30);
01820 
01821   EEP_FedsTimingVsAmpHist_          = new TH2F("timeVsAmpAllEvents","time Vs Amp All Events EEP;Relative Time (1 clock = 25ns);Amplitude (GeV)",78,-7,7,numBins,histRangeMin_,10.0);
01822   EEP_FedsTimingTTHist_             = new TH3F("timeTTAllFEDs","(ix,iy,time) for all FEDs (SM,TT binning) EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01823   
01824   EEP_OccupancySingleXtal_          = new TH2F("OccupancySingleXtal","Occupancy single xtal clusters EEP;ix;iy",100,0,100,100,0,100);
01825   EEP_energySingleXtalHist_         = new TH1F("energy_SingleXtalClusters","Energy single xtal clusters EEP;Cluster Energy (GeV)",numBins,histRangeMin_,200.0);
01826   
01827   EEP_OccupancyExclusiveECAL_       = new TH2F("OccupancyAllEvents_ExclusiveECAL","Occupancy all events Exclusive ECAL  EEP;ix;iy",100,0,100,100,0,100);
01828   EEP_OccupancyCoarseExclusiveECAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveECAL","Occupancy all events Coarse Exclusive ECAL EEP;ix;iy",20,0,100,20,0,100);
01829   EEP_OccupancyECAL_                = new TH2F("OccupancyAllEvents_ECAL","Occupancy all events ECAL EEP;ix;iy",100,0,100,100,0,100);
01830   EEP_OccupancyCoarseECAL_          = new TH2F("OccupancyAllEventsCoarse_ECAL","Occupancy all events Coarse ECAL EEP;ix;iy",20,0,100,20,0,100);
01831   EEP_FedsTimingHistECAL_           = new TH1F("timeForAllFeds_ECAL","timeForAllFeds ECAL EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01832   EEP_FedsTimingTTHistECAL_         = new TH3F("timeTTAllFEDs_ECAL","(ix,iy,time) for all FEDs (SM,TT binning) ECAL EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01833   
01834   EEP_OccupancyExclusiveDT_         = new TH2F("OccupancyAllEvents_ExclusiveDT","Occupancy all events Exclusive DT EEP;ix;iy",100,0,100,100,0,100);
01835   EEP_OccupancyCoarseExclusiveDT_   = new TH2F("OccupancyAllEventsCoarse_ExclusiveDT","Occupancy all events Coarse Exclusive DT EEP;ix;iy",20,0,100,20,0,100);
01836   EEP_OccupancyDT_                  = new TH2F("OccupancyAllEvents_DT","Occupancy all events DT EEP;ix;iy",100,0,100,100,0,100);
01837   EEP_OccupancyCoarseDT_            = new TH2F("OccupancyAllEventsCoarse_DT","Occupancy all events Coarse DT EEP;ix;iy",20,0,100,20,0,100);
01838   EEP_FedsTimingHistDT_             = new TH1F("timeForAllFeds_DT","timeForAllFeds DT EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01839   EEP_FedsTimingTTHistDT_         = new TH3F("timeTTAllFEDs_DT","(ix,iy,time) for all FEDs (SM,TT binning) DT EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01840   
01841   EEP_OccupancyExclusiveRPC_        = new TH2F("OccupancyAllEvents_ExclusiveRPC","Occupancy all events Exclusive RPC EEP;ix;iy",100,0,100,100,0,100);
01842   EEP_OccupancyCoarseExclusiveRPC_  = new TH2F("OccupancyAllEventsCoarse_ExclusiveRPC","Occupancy all events Coarse Exclusive RPC EEP;ix;iy",20,0,100,20,0,100);
01843   EEP_OccupancyRPC_                 = new TH2F("OccupancyAllEvents_RPC","Occupancy all events RPC EEP;ix;iy",100,0,100,100,0,100);
01844   EEP_OccupancyCoarseRPC_           = new TH2F("OccupancyAllEventsCoarse_RPC","Occupancy all events Coarse RPC EEP;ix;iy",20,0,100,20,0,100);
01845   EEP_FedsTimingHistRPC_            = new TH1F("timeForAllFeds_RPC","timeForAllFeds RPC EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01846   EEP_FedsTimingTTHistRPC_          = new TH3F("timeTTAllFEDs_RPC","(ix,iy,time) for all FEDs (SM,TT binning) RPC EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01847   
01848   EEP_OccupancyExclusiveCSC_        = new TH2F("OccupancyAllEvents_ExclusiveCSC","Occupancy all events Exclusive CSC EEP;ix;iy",100,0,100,100,0,100);
01849   EEP_OccupancyCoarseExclusiveCSC_  = new TH2F("OccupancyAllEventsCoarse_ExclusiveCSC","Occupancy all events Coarse Exclusive CSC EEP;ix;iy",20,0,100,20,0,100);
01850   EEP_OccupancyCSC_                 = new TH2F("OccupancyAllEvents_CSC","Occupancy all events CSC EEP;ix;iy",100,0,100,100,0,100);
01851   EEP_OccupancyCoarseCSC_           = new TH2F("OccupancyAllEventsCoarse_CSC","Occupancy all events Coarse CSC EEP;ix;iy",20,0,100,20,0,100);
01852   EEP_FedsTimingHistCSC_            = new TH1F("timeForAllFeds_CSC","timeForAllFeds CSC EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01853   EEP_FedsTimingTTHistCSC_          = new TH3F("timeTTAllFEDs_CSC","(ix,iy,time) for all FEDs (SM,TT binning) CSC EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01854   
01855   EEP_OccupancyExclusiveHCAL_       = new TH2F("OccupancyAllEvents_ExclusiveHCAL","Occupancy all events Exclusive HCAL EEP;ix;iy",100,0,100,100,0,100);
01856   EEP_OccupancyCoarseExclusiveHCAL_ = new TH2F("OccupancyAllEventsCoarse_ExclusiveHCAL","Occupancy all events Coarse Exclusive HCAL EEP;ix;iy",20,0,100,20,0,100);
01857   EEP_OccupancyHCAL_                = new TH2F("OccupancyAllEvents_HCAL","Occupancy all events HCAL EEP;ix;iy",100,0,100,100,0,100);
01858   EEP_OccupancyCoarseHCAL_          = new TH2F("OccupancyAllEventsCoarse_HCAL","Occupancy all events Coarse HCAL EEP;ix;iy",20,0,100,20,0,100);
01859   EEP_FedsTimingHistHCAL_           = new TH1F("timeForAllFeds_HCAL","timeForAllFeds HCAL EEP;Relative Time (1 clock = 25ns)",78,-7,7);
01860   EEP_FedsTimingTTHistHCAL_         = new TH3F("timeTTAllFEDs_HCAL","(ix,iy,time) for all FEDs (SM,TT binning) HCAL EEP;ix;iy;Relative Time (1 clock = 25ns)",20,0,100,20,0,100,78,-7,7); 
01861   
01862   EEP_numberofBCinSC_               = new TH1F("numberofBCinSC","Number of Basic Clusters in Super Cluster EEP;Num Basic Clusters",20,0,20);
01863   
01864   EEP_triggerHist_                  = new TH1F("triggerHist","Trigger Number EEP",5,0,5);
01865   EEP_triggerHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01866   EEP_triggerHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01867   EEP_triggerHist_->GetXaxis()->SetBinLabel(3,"DT");
01868   EEP_triggerHist_->GetXaxis()->SetBinLabel(4,"RPC");
01869   EEP_triggerHist_->GetXaxis()->SetBinLabel(5,"CSC");
01870   
01871   EEP_triggerExclusiveHist_         = new TH1F("triggerExclusiveHist","Trigger Number (Mutually Exclusive) EEP",5,0,5);  
01872   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(1,"ECAL");
01873   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(2,"HCAL");
01874   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(3,"DT");
01875   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(4,"RPC");
01876   EEP_triggerExclusiveHist_->GetXaxis()->SetBinLabel(5,"CSC");
01877   
01878   EEP_NumXtalsInClusterHist_        = new TH1F("NumXtalsInClusterAllHist","Number of Xtals in Cluster EEP;NumXtals",150,0,150);
01879   EEP_numxtalsVsEnergy_             = new TH2F("NumXtalsVsEnergy","Number of Xtals in Cluster vs Energy EEP;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,10.0, 150,0,150);
01880   EEP_numxtalsVsHighEnergy_         = new TH2F("NumXtalsVsHighEnergy","Number of Xtals in Cluster vs Energy EEP;Energy (GeV);Number of Xtals in Cluster",numBins,histRangeMin_,200., 150,0,150);
01881   
01882   EEP_OccupancyHighEnergy_          = new TH2F("OccupancyHighEnergyEvents","Occupancy high energy events EEP;ix;iy",100,0,100,100,0,100);
01883   EEP_OccupancyHighEnergyCoarse_    = new TH2F("OccupancyHighEnergyEventsCoarse","Occupancy high energy events Coarse EEP;ix;iy",20,0,100,20,0,100);
01884   
01885   EEP_FedsNumXtalsInClusterHist_    = new TH1F("NumActiveXtalsInClusterAllHist","Number of active Xtals in Cluster EEP;NumXtals",100,0,100);
01886   
01887 
01888 }
01889 
01890 // ------------ method called once each job just after ending the event loop  ------------
01891 void 
01892 EcalCosmicsHists::endJob()
01893 {
01894   using namespace std;
01895   if (runInFileName_) {
01896     fileName_ += "-"+intToString(runNum_)+".graph.root";
01897   } else {
01898     fileName_ += ".root";
01899   }
01900   
01901   TFile root_file_(fileName_.c_str() , "RECREATE");
01902   
01903   for(map<int,TH1F*>::const_iterator itr = FEDsAndHists_.begin();
01904       itr != FEDsAndHists_.end(); ++itr) {
01905     string dir = fedMap_->getSliceFromFed(itr->first);
01906     TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
01907     FEDdir->cd();
01908     
01909     TH1F* hist = itr->second;
01910     if(hist!=0)
01911       hist->Write();
01912     else {
01913       cerr << "EcalCosmicsHists: Error: This shouldn't happen!" << endl;
01914     }
01915     // Write out timing hist
01916     hist = FEDsAndTimingHists_[itr->first];
01917     if(hist!=0)
01918       hist->Write();
01919     else {
01920       cerr << "EcalCosmicsHists: Error: This shouldn't happen!" << endl;
01921     }
01922     
01923     hist = FEDsAndFrequencyHists_[itr->first];
01924     hist->Write();
01925     
01926     hist = FEDsAndiPhiProfileHists_[itr->first];
01927     hist->Write();
01928     
01929     hist = FEDsAndiEtaProfileHists_[itr->first];
01930     hist->Write();
01931     
01932     hist = FEDsAndE2Hists_[itr->first];
01933     hist->Write();
01934     
01935     hist = FEDsAndenergyHists_[itr->first];
01936     hist->Write();
01937     
01938     hist = FEDsAndNumXtalsInClusterHists_[itr->first];
01939     hist->Write();
01940     
01941     TH2F* hist2 = FEDsAndTimingVsAmpHists_[itr->first];
01942     hist2->Write();
01943     
01944     hist2 = FEDsAndTimingVsFreqHists_[itr->first];
01945     hist2->Write();
01946     
01947     hist2 = FEDsAndE2vsE1Hists_[itr->first];
01948     hist2->Write();
01949     
01950     hist2 = FEDsAndenergyvsE1Hists_[itr->first];
01951     hist2->Write();
01952     
01953     hist2 = FEDsAndOccupancyHists_[itr->first];
01954     hist2->Write();
01955     
01956     hist2 = FEDsAndTimingVsPhiHists_[itr->first];
01957     hist2->Write();
01958     
01959     hist2 = FEDsAndTimingVsModuleHists_[itr->first];
01960     hist2->Write();
01961 
01962     //2d hist
01963     map<int,TH2F*>::const_iterator itr2d;
01964     itr2d = FEDsAndDCCRuntypeVsBxHists_.find(itr->first);
01965     if(itr2d != FEDsAndDCCRuntypeVsBxHists_.end())
01966     {
01967       TH2F* hist2 = itr2d->second;
01968       hist2->GetYaxis()->SetBinLabel(1,"COSMIC");
01969       hist2->GetYaxis()->SetBinLabel(2,"BEAMH4");
01970       hist2->GetYaxis()->SetBinLabel(3,"BEAMH2");
01971       hist2->GetYaxis()->SetBinLabel(4,"MTCC");
01972       hist2->GetYaxis()->SetBinLabel(5,"LASER_STD");
01973       hist2->GetYaxis()->SetBinLabel(6,"LASER_POWER_SCAN");
01974       hist2->GetYaxis()->SetBinLabel(7,"LASER_DELAY_SCAN");
01975       hist2->GetYaxis()->SetBinLabel(8,"TESTPULSE_SCAN_MEM");
01976       hist2->GetYaxis()->SetBinLabel(9,"TESTPULSE_MGPA");
01977       hist2->GetYaxis()->SetBinLabel(10,"PEDESTAL_STD");
01978       hist2->GetYaxis()->SetBinLabel(11,"PEDESTAL_OFFSET_SCAN");
01979       hist2->GetYaxis()->SetBinLabel(12,"PEDESTAL_25NS_SCAN");
01980       hist2->GetYaxis()->SetBinLabel(13,"LED_STD");
01981       hist2->GetYaxis()->SetBinLabel(14,"PHYSICS_GLOBAL");
01982       hist2->GetYaxis()->SetBinLabel(15,"COSMICS_GLOBAL");
01983       hist2->GetYaxis()->SetBinLabel(16,"HALO_GLOBAL");
01984       hist2->GetYaxis()->SetBinLabel(17,"LASER_GAP");
01985       hist2->GetYaxis()->SetBinLabel(18,"TESTPULSE_GAP");
01986       hist2->GetYaxis()->SetBinLabel(19,"PEDESTAL_GAP");
01987       hist2->GetYaxis()->SetBinLabel(20,"LED_GAP");
01988       hist2->GetYaxis()->SetBinLabel(21,"PHYSICS_LOCAL");
01989       hist2->GetYaxis()->SetBinLabel(22,"COSMICS_LOCAL");
01990       hist2->GetYaxis()->SetBinLabel(23,"HALO_LOCAL");
01991       hist2->GetYaxis()->SetBinLabel(24,"CALIB_LOCAL");
01992       hist2->Write();
01993     }
01994     
01995     root_file_.cd();
01996   }
01997   allFedsHist_->Write();
01998   allFedsE2Hist_->Write();
01999   allFedsenergyHist_->Write();
02000   allFedsenergyHighHist_->Write();
02001   allFedsenergyOnlyHighHist_->Write();
02002   allFedsE2vsE1Hist_->Write();
02003   allFedsenergyvsE1Hist_->Write();
02004   allFedsTimingHist_->Write();
02005   allFedsTimingVsAmpHist_->Write();
02006   allFedsFrequencyHist_->Write();
02007   allFedsTimingVsFreqHist_->Write();
02008   allFedsiEtaProfileHist_->Write();
02009   allFedsiPhiProfileHist_->Write();
02010   allOccupancy_->Write();
02011   TrueOccupancy_->Write();
02012   allOccupancyCoarse_->Write();
02013   TrueOccupancyCoarse_->Write();
02014   allOccupancyHighEnergy_->Write();
02015   allOccupancyHighEnergyCoarse_->Write();
02016   allOccupancySingleXtal_->Write();
02017   energySingleXtalHist_->Write();
02018   allFedsNumXtalsInClusterHist_->Write();
02019   allFedsTimingPhiHist_->Write();
02020   allFedsTimingPhiEbpHist_->Write();
02021   allFedsTimingPhiEbmHist_->Write();
02022   allFedsTimingEbpHist_->Write();
02023   allFedsTimingEbmHist_->Write();
02024   allFedsTimingEbpTopHist_->Write();
02025   allFedsTimingEbmTopHist_->Write();
02026   allFedsTimingEbpBottomHist_->Write();
02027   allFedsTimingEbmBottomHist_->Write();
02028   allFedsTimingPhiEtaHist_->Write();
02029   allFedsTimingTTHist_->Write();
02030   allFedsTimingLMHist_->Write();
02031   allFedsOccupancyHighEnergyHist_->Write();
02032 
02033   numberofBCinSC_->Write();//SC
02034   numberofBCinSCphi_->Write();//SC
02035   TrueBCOccupancyCoarse_->Write();//BC
02036   TrueBCOccupancy_->Write(); //BC
02037 
02038   numxtalsVsEnergy_->Write();
02039   numxtalsVsHighEnergy_->Write();
02040   
02041   allOccupancyExclusiveECAL_->Write();
02042   allOccupancyCoarseExclusiveECAL_->Write();
02043   allOccupancyECAL_->Write();
02044   allOccupancyCoarseECAL_->Write();
02045   allFedsTimingPhiEtaHistECAL_->Write();
02046   allFedsTimingHistECAL_->Write();
02047   allFedsTimingTTHistECAL_->Write();
02048   allFedsTimingLMHistECAL_->Write();
02049 
02050   allOccupancyExclusiveHCAL_->Write();
02051   allOccupancyCoarseExclusiveHCAL_->Write();
02052   allOccupancyHCAL_->Write();
02053   allOccupancyCoarseHCAL_->Write();
02054   allFedsTimingPhiEtaHistHCAL_->Write();
02055   allFedsTimingHistHCAL_->Write();
02056   allFedsTimingTTHistHCAL_->Write();
02057   allFedsTimingLMHistHCAL_->Write();
02058 
02059   allOccupancyExclusiveDT_->Write();
02060   allOccupancyCoarseExclusiveDT_->Write();
02061   allOccupancyDT_->Write();
02062   allOccupancyCoarseDT_->Write();
02063   allFedsTimingPhiEtaHistDT_->Write();
02064   allFedsTimingHistDT_->Write();
02065   allFedsTimingTTHistDT_->Write();
02066   allFedsTimingLMHistDT_->Write();
02067 
02068   allOccupancyExclusiveRPC_->Write();
02069   allOccupancyCoarseExclusiveRPC_->Write();
02070   allOccupancyRPC_->Write();
02071   allOccupancyCoarseRPC_->Write();
02072   allFedsTimingPhiEtaHistRPC_->Write();
02073   allFedsTimingHistRPC_->Write();
02074   allFedsTimingTTHistRPC_->Write();
02075   allFedsTimingLMHistRPC_->Write();
02076 
02077   allOccupancyExclusiveCSC_->Write();
02078   allOccupancyCoarseExclusiveCSC_->Write();
02079   allOccupancyCSC_->Write();
02080   allOccupancyCoarseCSC_->Write();
02081   allFedsTimingPhiEtaHistCSC_->Write();
02082   allFedsTimingHistCSC_->Write();
02083   allFedsTimingTTHistCSC_->Write();
02084   allFedsTimingLMHistCSC_->Write();
02085 
02086   allFedsTimingHistEcalMuon_->Write();
02087 
02088   //EE
02089   TDirectory* EEMinusDir = gDirectory->mkdir("EEMinus");
02090   EEMinusDir->cd();
02091   EEM_FedsSeedEnergyHist_->Write();
02092   EEM_AllOccupancyCoarse_->Write(); 
02093   EEM_AllOccupancy_->Write(); 
02094   EEM_FedsenergyHist_->Write();
02095   EEM_FedsenergyHighHist_->Write();
02096   EEM_FedsenergyOnlyHighHist_->Write();
02097   EEM_FedsE2Hist_->Write();
02098   EEM_FedsE2vsE1Hist_->Write();
02099   EEM_FedsenergyvsE1Hist_->Write();
02100   EEM_FedsTimingHist_->Write();        
02101   EEM_numberofCosmicsHist_->Write();
02102   EEM_FedsTimingVsAmpHist_->Write();
02103   EEM_FedsTimingTTHist_->Write();
02104   EEM_OccupancySingleXtal_->Write();
02105   EEM_energySingleXtalHist_->Write();
02106   EEM_OccupancyExclusiveECAL_->Write();
02107   EEM_OccupancyCoarseExclusiveECAL_->Write();
02108   EEM_OccupancyECAL_->Write();
02109   EEM_OccupancyCoarseECAL_->Write();
02110   EEM_FedsTimingHistECAL_->Write();
02111   EEM_FedsTimingTTHistECAL_->Write();
02112   EEM_OccupancyExclusiveDT_->Write();
02113   EEM_OccupancyCoarseExclusiveDT_->Write();
02114   EEM_OccupancyDT_->Write();
02115   EEM_OccupancyCoarseDT_->Write();
02116   EEM_FedsTimingHistDT_->Write();
02117   EEM_FedsTimingTTHistDT_->Write();
02118   EEM_OccupancyExclusiveRPC_->Write();
02119   EEM_OccupancyCoarseExclusiveRPC_->Write();
02120   EEM_OccupancyRPC_->Write();
02121   EEM_OccupancyCoarseRPC_->Write();
02122   EEM_FedsTimingHistRPC_->Write();
02123   EEM_FedsTimingTTHistRPC_->Write();
02124   EEM_OccupancyExclusiveCSC_->Write();
02125   EEM_OccupancyCoarseExclusiveCSC_->Write();
02126   EEM_OccupancyCSC_->Write();
02127   EEM_OccupancyCoarseCSC_->Write();
02128   EEM_FedsTimingHistCSC_->Write();
02129   EEM_FedsTimingTTHistCSC_->Write();
02130   EEM_OccupancyExclusiveHCAL_->Write();
02131   EEM_OccupancyCoarseExclusiveHCAL_->Write();
02132   EEM_OccupancyHCAL_->Write();
02133   EEM_OccupancyCoarseHCAL_->Write();
02134   EEM_FedsTimingHistHCAL_->Write();
02135   EEM_FedsTimingTTHistHCAL_->Write();
02136   EEM_numberofBCinSC_->Write();
02137   EEM_triggerHist_->Write();
02138   EEM_triggerExclusiveHist_->Write();
02139   EEM_NumXtalsInClusterHist_->Write();
02140   EEM_numxtalsVsEnergy_->Write();
02141   EEM_numxtalsVsHighEnergy_->Write();
02142   EEM_OccupancyHighEnergy_->Write();
02143   EEM_OccupancyHighEnergyCoarse_->Write();
02144   EEM_FedsNumXtalsInClusterHist_->Write();
02145   root_file_.cd();
02146 
02147   TDirectory* EEPlusDir = gDirectory->mkdir("EEPlus");
02148   EEPlusDir->cd();
02149   EEP_FedsSeedEnergyHist_->Write();
02150   EEP_AllOccupancyCoarse_->Write(); 
02151   EEP_AllOccupancy_->Write(); 
02152   EEP_FedsenergyHist_->Write();
02153   EEP_FedsenergyHighHist_->Write();
02154   EEP_FedsenergyOnlyHighHist_->Write();
02155   EEP_FedsE2Hist_->Write();
02156   EEP_FedsE2vsE1Hist_->Write();
02157   EEP_FedsenergyvsE1Hist_->Write();
02158   EEP_FedsTimingHist_->Write();        
02159   EEP_numberofCosmicsHist_->Write();
02160   EEP_FedsTimingVsAmpHist_->Write();
02161   EEP_FedsTimingTTHist_->Write();
02162   EEP_OccupancySingleXtal_->Write();
02163   EEP_energySingleXtalHist_->Write();
02164   EEP_OccupancyExclusiveECAL_->Write();
02165   EEP_OccupancyCoarseExclusiveECAL_->Write();
02166   EEP_OccupancyECAL_->Write();
02167   EEP_OccupancyCoarseECAL_->Write();
02168   EEP_FedsTimingHistECAL_->Write();
02169   EEP_FedsTimingTTHistECAL_->Write();
02170   EEP_OccupancyExclusiveDT_->Write();
02171   EEP_OccupancyCoarseExclusiveDT_->Write();
02172   EEP_OccupancyDT_->Write();
02173   EEP_OccupancyCoarseDT_->Write();
02174   EEP_FedsTimingHistDT_->Write();
02175   EEP_FedsTimingTTHistDT_->Write();
02176   EEP_OccupancyExclusiveRPC_->Write();
02177   EEP_OccupancyCoarseExclusiveRPC_->Write();
02178   EEP_OccupancyRPC_->Write();
02179   EEP_OccupancyCoarseRPC_->Write();
02180   EEP_FedsTimingHistRPC_->Write();
02181   EEP_FedsTimingTTHistRPC_->Write();
02182   EEP_OccupancyExclusiveCSC_->Write();
02183   EEP_OccupancyCoarseExclusiveCSC_->Write();
02184   EEP_OccupancyCSC_->Write();
02185   EEP_OccupancyCoarseCSC_->Write();
02186   EEP_FedsTimingHistCSC_->Write();
02187   EEP_FedsTimingTTHistCSC_->Write();
02188   EEP_OccupancyExclusiveHCAL_->Write();
02189   EEP_OccupancyCoarseExclusiveHCAL_->Write();
02190   EEP_OccupancyHCAL_->Write();
02191   EEP_OccupancyCoarseHCAL_->Write();
02192   EEP_FedsTimingHistHCAL_->Write();
02193   EEP_FedsTimingTTHistHCAL_->Write();
02194   EEP_numberofBCinSC_->Write();
02195   EEP_triggerHist_->Write();
02196   EEP_triggerExclusiveHist_->Write();
02197   EEP_NumXtalsInClusterHist_->Write();
02198   EEP_numxtalsVsEnergy_->Write();
02199   EEP_numxtalsVsHighEnergy_->Write();
02200   EEP_OccupancyHighEnergy_->Write();
02201   EEP_OccupancyHighEnergyCoarse_->Write();
02202   EEP_FedsNumXtalsInClusterHist_->Write();
02203   root_file_.cd();
02204 
02205   triggerHist_->Write();
02206   triggerExclusiveHist_->Write();
02207 
02208   NumXtalsInClusterHist_->Write();
02209   
02210   numberofCosmicsHist_->Write();
02211   numberofCosmicsHistEB_->Write();
02212 
02213   numberofCosmicsWTrackHist_->Write();
02214   numberofCosmicsTopBottomHist_->Write();
02215   numberofGoodEvtFreq_->Write();
02216   numberofCrossedEcalIdsHist_->Write();
02217 
02218   runNumberHist_->SetBinContent(1,runNum_);
02219   runNumberHist_->Write();
02220 
02221   deltaRHist_->Write();
02222   deltaEtaHist_->Write();
02223   deltaPhiHist_->Write();
02224   ratioAssocClustersHist_->Write();
02225   ratioAssocTracksHist_->Write();
02226   deltaEtaDeltaPhiHist_->Write();
02227   seedTrackPhiHist_->Write();
02228   seedTrackEtaHist_->Write();
02229   dccEventVsBxHist_->Write();
02230   dccOrbitErrorByFEDHist_->Write();
02231   dccBXErrorByFEDHist_->Write();
02232   dccRuntypeErrorByFEDHist_->Write();
02233   dccErrorVsBxHist_->Write();
02234   dccRuntypeHist_->Write();
02235   
02236   trackAssoc_muonsEcal_->Write();
02237 
02238   hcalEnergy_HBHE_->Write();
02239   hcalEnergy_HF_->Write();
02240   hcalEnergy_HO_->Write();
02241   hcalHEHBecalEB_->Write();
02242 
02243   TDirectory* highEnergyDir = gDirectory->mkdir("HighEnergy");
02244   highEnergyDir->cd();
02245   HighEnergy_NumXtal->Write();
02246   HighEnergy_NumXtalFedId->Write();
02247   HighEnergy_NumXtaliphi->Write();  
02248   HighEnergy_energy3D->Write();
02249   HighEnergy_energyNumXtal->Write();
02250   HighEnergy_bestSeed->Write();
02251   HighEnergy_bestSeedOccupancy->Write();
02252   HighEnergy_numClusHighEn->Write();
02253   HighEnergy_ratioClusters->Write();
02254   HighEnergy_numRecoTrackBarrel->Write();
02255   HighEnergy_TracksAngle->Write();
02256   HighEnergy_TracksAngleTopBottom->Write();
02257   HighEnergy_2GeV_occuCoarse->Write();
02258   HighEnergy_2GeV_occu3D->Write();
02259   HighEnergy_100GeV_occuCoarse->Write();
02260   HighEnergy_100GeV_occu3D->Write();
02261   HighEnergy_0tracks_occu3D->Write();
02262   HighEnergy_1tracks_occu3D->Write();
02263   HighEnergy_2tracks_occu3D->Write();
02264   HighEnergy_0tracks_occu3DXtal->Write();
02265   HighEnergy_1tracks_occu3DXtal->Write();
02266   HighEnergy_2tracks_occu3DXtal->Write();
02267 
02268   root_file_.cd();
02269 
02270   TDirectory* TimeStampdir = gDirectory->mkdir("EventTiming");
02271   TimeStampdir->cd();
02272   allFedsFreqTimeHist_->Write();
02273   allFedsFreqTimeVsPhiHist_->Write();
02274   allFedsFreqTimeVsPhiTTHist_->Write();
02275   allFedsFreqTimeVsEtaHist_->Write();
02276   allFedsFreqTimeVsEtaTTHist_->Write(); 
02277 
02278   root_file_.cd();
02279 
02280   root_file_.Close();
02281 
02282   LogWarning("EcalCosmicsHists") << "---> Number of cosmic events: " << cosmicCounter_ << " in " << naiveEvtNum_ << " events.";
02283   LogWarning("EcalCosmicsHists") << "---> Number of EB cosmic events: " << cosmicCounterEB_ << " in " << naiveEvtNum_ << " events.";
02284   LogWarning("EcalCosmicsHists") << "---> Number of EE- cosmic events: " << cosmicCounterEEM_ << " in " << naiveEvtNum_ << " events.";
02285   LogWarning("EcalCosmicsHists") << "---> Number of EE+ cosmic events: " << cosmicCounterEEP_ << " in " << naiveEvtNum_ << " events.";
02286 
02287   //  LogWarning("EcalCosmicsHists") << "---> Number of top+bottom cosmic events: " << cosmicCounterTopBottom_ << " in " << cosmicCounter_ << " cosmics in " << naiveEvtNum_ << " events.";
02288 
02289 }
02290 
02291 
02292 std::string EcalCosmicsHists::intToString(int num)
02293 {
02294     using namespace std;
02295     ostringstream myStream;
02296     myStream << num << flush;
02297     return(myStream.str()); //returns the string form of the stringstream object
02298 }
02299