CMS 3D CMS Logo

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