diff --git a/.gitignore b/.gitignore index df7ca6d..b3c2ae8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,14 @@ +*.[oa] +*~ +*.dat +*.txt *.png *.root __init__.py +*.old +pippo* +*processDump.py *.pyc html/* +LSF* +*.list diff --git a/EcalTiming/BuildFile.xml b/EcalTiming/BuildFile.xml index 2734bc3..f6abf85 100644 --- a/EcalTiming/BuildFile.xml +++ b/EcalTiming/BuildFile.xml @@ -10,18 +10,20 @@ - - + + + + diff --git a/EcalTiming/doc/AlCaPhiSymStream_test.doc b/EcalTiming/doc/AlCaPhiSymStream_test.doc index e498989..81645e8 100644 --- a/EcalTiming/doc/AlCaPhiSymStream_test.doc +++ b/EcalTiming/doc/AlCaPhiSymStream_test.doc @@ -5,8 +5,24 @@ Testing file: \verbatim file=root://eoscms//eos/cms/store/data/Run2015A/AlCaPhiSym/RAW/v1/000/246/908/00000/C0DA4527-2F0A-E511-ADFD-02163E014349.root -cmsRun test/ecalTimeTreeMaker_FromRaw_CosmicOrBeamSplash_cfg.py files=root://eoscms/$file +cmsRun test/ecalTime_fromAlcaStream_cfg.py files=root://eoscms/$file \endverbatim -The code is in debug mode that have to be switched off +## Options for `cmsRun test/ecalTime_fromAlcaStream_cfg.py` +Options | Default | Description +------- | ------- | ------- +files | "" | input files (can be RAW if step contains "RECO") +output | "" | output files. If TIME in step, it contains the calibration trees, otherwise it will be the RECO files. +maxEvents | -1 | # of events to run over +jsonFile |"" | path to the json file which designates which lumisections to use +step |"RECOTIMEANALYSIS" | Do reco, time analysis or both, RECO or TIMEANALYSIS or RECOTIMEANALYSIS +offset |0.0 | add this to each crystal time, (this was used in splash analysis, should probably be removed) +minEnergyEB | 0.0 | add this to minimum energy threshold in EB (0.520 GeV) +minEnergyEE | 0.0 | add this to minimum energy threshold in EE (which is a function of iRing) +isSplash | 0 | 0=false, 1=true, performs RECO as splash data and shifts timing in analyzer by TOF difference +streamName | "AlCaPhiSym" | type of stream, changes RECO path: AlCaPhiSym or AlCaP0 + + +The script `scripts/testCAF.sh` automatically can run over RAW files for specific runs, setting the options above appropriately. +Probably should use it as a template rather than running it as is. */ diff --git a/EcalTiming/doc/instructions.doc b/EcalTiming/doc/instructions.doc index 26f3444..243df8b 100644 --- a/EcalTiming/doc/instructions.doc +++ b/EcalTiming/doc/instructions.doc @@ -5,8 +5,10 @@ Download the code: scram project CMSSW_7_4_2 cd CMSSW_7_4_2/src cmsenv -git clone git@github.com:ECALELFS/EcalTiming.git -git clone git@github.com:ECALELFS/PhiSym.git +git cms-merge-topic shervin86:iRingInSubdet +git clone git@github.com:previsualconsent/EcalTiming.git +cd EcalTiming +checkout energystability scram b -j16 \endverbatim @@ -32,4 +34,4 @@ cd - Go back to \ref index -*/ \ No newline at end of file +*/ diff --git a/EcalTiming/doc/splach.doc b/EcalTiming/doc/splach.doc new file mode 100644 index 0000000..1bcb14a --- /dev/null +++ b/EcalTiming/doc/splach.doc @@ -0,0 +1,14 @@ +/** +\page Splash +\section Splash_sec How to analyze Splash events + +The offset are set to make the ieta = 1 bin average to 0. +\verbatim +output=/path/to/output.root +beam1file=/store/caf/user/ccecal/TPG/splash_events_run_239895_26_events_beam_1.root +beam2file=/store/caf/user/ccecal/TPG/splash_events_run_239895_31_events_beam_2.root +cmsRun test/ ecalTime_fromAlcaStream_cfg.py files=$beam1file output=$output offset=1.75589609219 isSplash=1 +cmsRun test/ ecalTime_fromAlcaStream_cfg.py files=$beam2file output=$output offset=-0.709605624194 isSplash=1 +\endverbatim + +*/ diff --git a/EcalTiming/doc/timing.doc b/EcalTiming/doc/timing.doc index c743ad3..fccbf08 100644 --- a/EcalTiming/doc/timing.doc +++ b/EcalTiming/doc/timing.doc @@ -6,7 +6,7 @@ \section introduction_ Timing package This package can be used to analyze - - splash event data in RAW format + - splash event data in RAW format: \ref Splash_sec - data from AlCaPhiSymmetry stream: \ref AlCaPhiSymmetry_test_sec diff --git a/EcalTiming/fulldoc b/EcalTiming/fulldoc index 621cd6b..dba9734 100644 --- a/EcalTiming/fulldoc +++ b/EcalTiming/fulldoc @@ -402,7 +402,7 @@ EXTRACT_ALL = NO # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. diff --git a/EcalTiming/interface/EcalCrystalTimingCalibration.h b/EcalTiming/interface/EcalCrystalTimingCalibration.h index e806bc7..ec5d2cb 100644 --- a/EcalTiming/interface/EcalCrystalTimingCalibration.h +++ b/EcalTiming/interface/EcalCrystalTimingCalibration.h @@ -1,13 +1,22 @@ #include "EcalTiming/EcalTiming/interface/EcalTimingEvent.h" - #include +#include -/** \class EcalCrystalTimingCalibration EcalCrystalTimingCalibration.cc EcalCrystalTimingCalibration.cc +/** \class EcalCrystalTimingCalibration EcalCrystalTimingCalibration.h EcalTiming/EcalTiming/interface/EcalCrystalTimingCalibration.h * * Description: add a description here * This class contains all the timing information for a single crystal */ +//Defines for Dump Status (reason for dumping each crystal) +#define DS_NONE 0x00 +#define DS_HIGH_SKEW 0x01 +#define DS_UNSTABLE_EN 0x02 +#define DS_CCU_OOT 0x04 +#define DS_RING 0x08 +#define DS_CRYS 0x10 + +void dumpAllToTree(TTree * tree, int ix_, int iy_, int iz_, float time_, float energy_, float chiSquare_, float thrApplied_); class EcalCrystalTimingCalibration { @@ -21,7 +30,12 @@ class EcalCrystalTimingCalibration float _sum2; ///< scalar sum of the square of the time of each timingEvent unsigned long int _num; ///< number of timingEvents; - float _sumE; + float _sumE; ///< scalar sum of the energy of each timingEvent: needed for average energy + bool _storingEvents; + + mutable std::map _sumWithinNSigma, _sum2WithinNSigma, _sum3WithinNSigma, _sumEWithinNSigma; ///< variables for calculation of mean, stdDev within n-times the origina stdDev (to remove tails) + mutable std::map _numWithinNSigma; ///< variables for calculation of mean, stdDev within n-times the origina stdDev (to remove tails) + std::vector timingEvents; ///< vector containing all the events for this crystal std::vector::iterator maxChi2Itr; @@ -31,7 +45,7 @@ class EcalCrystalTimingCalibration /// default constructor EcalCrystalTimingCalibration(bool weightMean = true) : //_detId(), - _sum(0), _sum2(0), _num(0), _sumE(0) + _sum(0), _sum2(0), _num(0), _sumE(0), _storingEvents(true) //totalChi2(-1), //useWeightedMean(weightMean) { @@ -43,6 +57,7 @@ class EcalCrystalTimingCalibration }; inline float mean() const { + if(!_num) return -999.f; return _sum / _num; }; ///< average time (mean of the time distribution) inline float stdDev() const ///< standard deviation of the time distribution @@ -65,6 +80,11 @@ class EcalCrystalTimingCalibration /* } */ //float totalChi2; + float getMeanWithinNSigma(float sigma, float maxRange) const; ///< returns the mean time within abs(mean+ n * stdDev) to reject tails + float getStdDevWithinNSigma(float sigma, float maxRange) const; ///< returns the stdDev calculated within abs(mean+ n * stdDev) to reject tails + float getNumWithinNSigma(float sigma, float maxRange) const; ///< returns the num calculated within abs(mean+ n * stdDev) to reject tails + float getMeanErrorWithinNSigma(float sigma, float maxRange) const; ///< returns the error on the mean calculated within abs(mean+ n * stdDev) to reject tails + float getSkewnessWithinNSigma(float sigma, float maxRange) const; ///< returns the skewness calculated within abs(mean+ n * stdDev) to reject tails friend std::ostream& operator<< (std::ostream& os, const EcalCrystalTimingCalibration& s) { @@ -73,29 +93,46 @@ class EcalCrystalTimingCalibration } /// add new event for this crystal - inline bool add(EcalTimingEvent te_) + inline bool add(EcalTimingEvent te_, bool storeEvent = true) { - return insertEvent(te_); + return insertEvent(te_,storeEvent); } inline void clear() { - _sum = 0.0f; - _sum2 = 0.0f; - _num = 0; - _sumE = 0.0f; - - timingEvents.clear(); + _sum = 0.0f; + _sum2 = 0.0f; + _num = 0; + _sumE = 0.0f; + _sumWithinNSigma.clear(); + _sum2WithinNSigma.clear(); + _sum3WithinNSigma.clear(); + _numWithinNSigma.clear(); + + timingEvents.clear(); } + + void dumpToTree(TTree *tree, int ix_, int iy_, int iz_, unsigned int status_, unsigned int elecID_, int iRing_); ///< dump the full set of events in a TTree: need an empty tree + void dumpCalibToTree(TTree * tree, int rawid_, int ix_, int iy_, int iz_, unsigned int elecID_, int iRing_) const; ///< dump the callibratoin to the tree + //void dumpAllToTree(TTree * tree, int ix_, int iy_, int iz_, float time_, float energy_, float chiSquare_, float thrApplied_); + + /// checks if the time measurement is stable changing the min energy threshold + bool isStableInEnergy(float min, float max, float step, std::vector< std::pair > &ret); + private: + void calcAllWithinNSigma(float n_sigma, float maxRange = 10) const; ///< calculate sum, sum2, sum3, n for time if time within n x stdDev and store the result + // since the values are stored, the calculation is done only once with only one loop over the events + /// \todo weighted average by timeError - bool insertEvent(EcalTimingEvent te_) + bool insertEvent(EcalTimingEvent te_, bool storeEvent) { - if(true || te_.timeError() > 0) { + if(!storeEvent) _storingEvents = false; + if(te_.timeError() > 0 && te_.timeError() < 1000 && te_.timeError() < 3) { //exclude values with wrong timeError estimation _sum += te_.time(); _sum2 += te_.time() * te_.time(); _sumE += te_.energy(); _num++; - timingEvents.push_back(te_); + if(_storingEvents) + timingEvents.push_back(te_); //updateChi2(); return true; } else { diff --git a/EcalTiming/interface/EcalTimeCalibrationMapFwd.h b/EcalTiming/interface/EcalTimeCalibrationMapFwd.h new file mode 100644 index 0000000..3872910 --- /dev/null +++ b/EcalTiming/interface/EcalTimeCalibrationMapFwd.h @@ -0,0 +1,13 @@ +/** In this file the time Map is defined + */ + +class EcalTimingEvent; +class EcalCrystalTimingCalibration; + +// Map of detId and Crystal time +typedef std::map EcalTimeCalibrationMap; +typedef std::map EcalHWCalibrationMap; + + +typedef std::map EventTimeMap; + diff --git a/EcalTiming/plugins/BuildFile.xml b/EcalTiming/plugins/BuildFile.xml index c2b09bd..86def5e 100644 --- a/EcalTiming/plugins/BuildFile.xml +++ b/EcalTiming/plugins/BuildFile.xml @@ -5,7 +5,9 @@ + + diff --git a/EcalTiming/plugins/DummyRechitDigis.cc b/EcalTiming/plugins/DummyRechitDigis.cc new file mode 100644 index 0000000..f6033a5 --- /dev/null +++ b/EcalTiming/plugins/DummyRechitDigis.cc @@ -0,0 +1,234 @@ +// -*- C++ -*- +// +// Package: ECALlite/DummyRechitDigis +// Class: DummyRechitDigis +// +/**\class DummyRechitDigis DummyRechitDigis.cc ECALlite/DummyRechitDigis/plugins/DummyRechitDigis.cc + Description: [one line class summary] + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Joshua Robert Hardenbrook +// Created: Mon, 01 Jun 2015 06:58:24 GMT +// +// + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/EgammaReco/interface/BasicCluster.h" +#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHit.h" +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +#include "DataFormats/CaloRecHit/interface/CaloID.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" + +#include "CondFormats/EcalObjects/interface/EcalSampleMask.h" + +#include "EcalTiming/EcalTiming/plugins/EcalTimingCalibProducer.h" + +// +// class declaration +// + +class DummyRechitDigis : public edm::EDProducer { +public: + explicit DummyRechitDigis(const edm::ParameterSet&); + ~DummyRechitDigis(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + virtual void beginJob() override; + virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + // ----------member data --------------------------- + edm::InputTag tag_barrelHitProducer_; + edm::InputTag tag_endcapHitProducer_; + const std::string barrelRecHitCollection_; + const std::string endcapRecHitCollection_; + edm::InputTag tag_barrelDigiProducer_; + edm::InputTag tag_endcapDigiProducer_; + const std::string barrelDigiCollection_; + const std::string endcapDigiCollection_; + const bool doDigi_; +}; + +DummyRechitDigis::DummyRechitDigis(const edm::ParameterSet& iConfig): + tag_barrelHitProducer_ (iConfig.getParameter< edm::InputTag > ("barrelHitProducer")), + tag_endcapHitProducer_ (iConfig.getParameter< edm::InputTag > ("endcapHitProducer")), + barrelRecHitCollection_ (iConfig.getUntrackedParameter("barrelRecHitCollection")), + endcapRecHitCollection_ (iConfig.getUntrackedParameter("endcapRecHitCollection")), + tag_barrelDigiProducer_ (iConfig.getParameter< edm::InputTag > ("barrelDigis")), + tag_endcapDigiProducer_ (iConfig.getParameter< edm::InputTag > ("endcapDigis")), + barrelDigiCollection_ (iConfig.getUntrackedParameter("barrelDigiCollection")), + endcapDigiCollection_ (iConfig.getUntrackedParameter("endcapDigiCollection")), + doDigi_ (iConfig.getUntrackedParameter("doDigi")) +{ + if(doDigi_) { + produces< EBDigiCollection >(barrelDigiCollection_); + produces< EEDigiCollection >(endcapDigiCollection_); + } + else { + produces< EcalRecHitCollection >(barrelRecHitCollection_); + produces< EcalRecHitCollection >(endcapRecHitCollection_); + } +} + +DummyRechitDigis::~DummyRechitDigis(){ } + +void DummyRechitDigis::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){ + //std::cout << "\n-----------New Event ----------------\n " << std::endl; + using namespace edm; + // build an empty collection + // fake rechits + // handle to try to fill + edm::Handle barrelRecHitsHandle; + edm::Handle endcapRecHitsHandle; + // dummy collection to Put() + std::auto_ptr< EcalRecHitCollection > rechits_temp( new EcalRecHitCollection); + std::auto_ptr< EcalRecHitCollection > rechits_temp2( new EcalRecHitCollection); + + // EcalRecHit::EcalRecHit(const DetId& id, float energy, float time, uint32_t flags, uint32_t flagBits) + // add one rechit + EcalRecHit zero_rechit(0,0,0,0,0); + EcalRecHitCollection zero_collection; + zero_collection.push_back(zero_rechit); + *rechits_temp = zero_collection; + *rechits_temp2 = zero_collection; + + std::auto_ptr< EcalRecHitCollection > rechits_eb( new EcalRecHitCollection); + std::auto_ptr< EcalRecHitCollection > rechits_ee( new EcalRecHitCollection); + + // fake digis + // handle to try to fill + Handle digisEBHandle; + Handle digisEEHandle; + // dummy collection to Put() + std::auto_ptr outputEBDigiCollection( new EBDigiCollection ); + std::auto_ptr outputEEDigiCollection( new EEDigiCollection ); + + //Digi zero_digi; + EBDigiCollection ebfakecol; + EEDigiCollection eefakecol; + //ebfakecol.push_back(zerodigi); + //eefakecol.push_back(zerodigi); + + // fake empty collections + std::auto_ptr fakeEBDigiCollection( new EBDigiCollection ); + *fakeEBDigiCollection = ebfakecol; + std::auto_ptr fakeEEDigiCollection( new EEDigiCollection) ; + *fakeEEDigiCollection = eefakecol; + + if(!doDigi_) { + bool foundEBRechit = true; + bool foundEERechit = true; + std::cout<<"sono entrato nel !dodigi"<begin(); recHit_itr != barrelRecHitsHandle->end(); ++recHit_itr){ + std::cout<<"sono entrato nell'if eb"<size() > 0;} + // if you found the collection put it back into the event + iEvent.put( foundEBRechit ? rechits_eb : rechits_temp, barrelRecHitCollection_); + + // if you dont find the endcap rechits youre looking for, put in a fake one + try { + //std::cout<<"sono entrato nell'if ee dodigi"<size() > 0; + } + + iEvent.put( foundEERechit ? rechits_ee : rechits_temp2, endcapRecHitCollection_); + std::cout<<"Build fake digi!"<begin(); digiItr != digisEBHandle->end(); ++digiItr){ + //EBDetId id_crystal(digiItr->id()); + DetId id = digiItr->id(); + //std::cout<id()<size() > 0; + //std::cout<<"sono entrato nel catch eb"<begin(); digiItr != digisEEHandle->end(); ++digiItr){ + DetId id = digiItr->id(); + // std::cout<id()); + // std::cout<<"SUBDETID!! Endcap "<id()<id().subdetId() <<"\n"; + } + *outputEEDigiCollection = *(digisEEHandle.product()); + //std::cout<<"sono entrato nell'else ee"<size() > 0; + //std::cout<<"sono entrato nel catch ee"< -#include -#include - -// Make Histograms the way!! -#include "FWCore/ServiceRegistry/interface/Service.h" -#include "CommonTools/UtilAlgos/interface/TFileService.h" - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDConsumerBase.h" - -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -//#include "FWCore/Framework/interface/Handle.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/LooperFactory.h" -#include "FWCore/Framework/interface/ESProducerLooper.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/ESProducts.h" -#include "FWCore/Framework/interface/Event.h" -// input collections -#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" -//RingTools -#include "Calibration/Tools/interface/EcalRingCalibrationTools.h" -#include "Geometry/CaloGeometry/interface/CaloGeometry.h" -#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" -#include "Geometry/Records/interface/CaloGeometryRecord.h" - -// record to be produced: -#include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h" -#include "CondFormats/DataRecord/interface/EcalTimeCalibErrorsRcd.h" -#include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h" -#include "CondTools/Ecal/interface/EcalTimeCalibConstantsXMLTranslator.h" -#include "CondTools/Ecal/interface/EcalTimeCalibErrorsXMLTranslator.h" -#include "CondTools/Ecal/interface/EcalTimeOffsetXMLTranslator.h" -#include "CondTools/Ecal/interface/EcalCondHeader.h" - -#include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h" -#include "CondFormats/EcalObjects/interface/EcalTimeCalibErrors.h" -#include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h" - -#include "EcalTiming/EcalTiming/interface/EcalTimingEvent.h" -#include "EcalTiming/EcalTiming/interface/EcalCrystalTimingCalibration.h" - -#include "DataFormats/EcalDetId/interface/EBDetId.h" -#include "DataFormats/EcalDetId/interface/EEDetId.h" - -#include "TProfile.h" -#include "TGraphErrors.h" -#include "TGraph.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TFile.h" -#include "TProfile2D.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -//#include // @@ -110,176 +17,6 @@ using namespace std; using namespace edm; using namespace cms; -class EcalTimingCalibProducer : public edm::ESProducerLooper -{ - -public: - // Map of detId and Crystal time - typedef std::map EcalTimeCalibrationMap; - EcalTimeCalibrationMap _timeCalibMap; - - typedef std::map EventTimeMap; - EventTimeMap eventTimeMap_; - - // For finding averages for specific eta ring - EcalCrystalTimingCalibration timeEEP; // - EcalCrystalTimingCalibration timeEEM; - EcalCrystalTimingCalibration timeEB; - float nearEndcapTime; - float farEndcapTime; - - EcalTimingCalibProducer(const edm::ParameterSet&); - ~EcalTimingCalibProducer(); - - - virtual void beginOfJob(const edm::EventSetup&); - virtual void startingNewLoop(unsigned int ) ; - virtual Status duringLoop(const edm::Event&, const edm::EventSetup&) ; - virtual Status endOfLoop(const edm::EventSetup&, unsigned int); - virtual void endOfJob(); -private: - // ----------member data --------------------------- - // input parameters - unsigned int _maxLoop; ///< maximum number of loops for intercalibration - bool _isSplash; ///< flag to activate for splash analysis - bool _makeEventPlots; ///< flag for making plots for each event - edm::InputTag _ecalRecHitsEBTAG; ///< input collection - edm::InputTag _ecalRecHitsEETAG; - std::vector _recHitFlags; ///< vector containing list of valid rec hit flags for calibration - unsigned int _recHitMin; ///< require at least this many rec hits to count the event - double _minRecHitEnergy; ///< minimum energy for the recHit to be considered for timing studies - unsigned int _minEntries; ///< require a minimum number of entries in a ring to do averages - float _globalOffset; ///< time to subtract from every event - bool _produceNewCalib; ///< true if you don't want to use the values in DB and what to extract new absolute calibrations, if false iteration does not work - std::string _outputDumpFileName; ///< name of the output file for the calibration constants' dump - float _noiseRMSThreshold; - float _noiseTimeThreshold; - - void dumpCalibration(std::string filename); - void dumpCorrections(std::string filename); - -// plotting -///fill histograms with the measured shifts (that will become -corrections for the next step) - void FillCalibrationCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr); - void initHists(TFileDirectory dir); - void initEventHists(TFileDirectory dir); - - // Create calibration container objects -> to be used in beginOfJob - void createConstants(const edm::EventSetup& iSetup) - { - - // time calib constants - edm::ESHandle ecalTimeCalibConstantsHandle; - iSetup.get().get( ecalTimeCalibConstantsHandle); - _timeCalibConstants = *ecalTimeCalibConstantsHandle; -#ifdef DEBUG - // why they are 0 when setWhatProduced is uncommented? -> I've not found a way to read the default DB at iter 0 - for(auto t_itr = _timeCalibConstants.begin(); t_itr != _timeCalibConstants.end() && t_itr - _timeCalibConstants.begin() < 10; ++t_itr) { - std::cout << "t_itr = " << *t_itr << std::endl; - } -#endif - produceCalibConstants(iSetup.get()); - - // time calib errors - edm::ESHandle ecalTimeCalibErrorsHandle; - //iSetup.get().get( ecalTimeCalibErrorsHandle); - //_timeCalibErrors = *ecalTimeCalibErrorsHandle; - //produceCalibErrors(iSetup.get()); - - // time offset constant - edm::ESHandle ecalTimeOffsetConstantHandle; - iSetup.get().get( ecalTimeOffsetConstantHandle); - _timeOffsetConstant = *ecalTimeOffsetConstantHandle; - produceOffsetConstant(iSetup.get()); - - } - - EcalTimeCalibConstants _timeCalibConstants; ///< container of calibrations updated iter by iter - boost::shared_ptr _calibConstants; // corrections used during this iter - inline boost::shared_ptr produceCalibConstants(const EcalTimeCalibConstantsRcd& iRecord) - { - // new shared_ptr initialized with previous iter: _timeCalibConstants - _calibConstants = boost::shared_ptr( new EcalTimeCalibConstants(_timeCalibConstants) ); - return _calibConstants; - } - - EcalTimeCalibErrors _timeCalibErrors; - boost::shared_ptr _calibErrors; - inline boost::shared_ptr& produceCalibErrors(const EcalTimeCalibErrorsRcd& iRecord) - { - _calibErrors = boost::shared_ptr( new EcalTimeCalibErrors(_timeCalibErrors) ); - return _calibErrors; - } - - EcalTimeOffsetConstant _timeOffsetConstant; - boost::shared_ptr _offsetConstant; - inline boost::shared_ptr produceOffsetConstant(const EcalTimeOffsetConstantRcd& iRecord) - { - _offsetConstant = boost::shared_ptr( new EcalTimeOffsetConstant(_timeOffsetConstant) ); - return _offsetConstant; - } - - - /// Checks whether or not we care about this recHit and then adds it to the corresponding collecionts - bool addRecHit(const EcalRecHit& recHit); - /// Adds the recHit to the per Event histograms - void plotRecHit(const EcalTimingEvent& recHit); - /// - /// Returns an EcalTimingEvent with a new time, which has been adjusted - /// so that the upstream endcap is 0. - /// - EcalTimingEvent correctGlobalOffset(const EcalTimingEvent& ev, int splashDir, float bunchCorr); - - std::map _CrysEnergyMap; - - edm::Service fileService_; - TFileDirectory histDir_; - // Mean Histograms - TProfile2D* EneMapEEP_; /// Using TProfile2D so we don't paint empty bins. - TProfile2D* EneMapEEM_; - TProfile2D* TimeMapEEP_; - TProfile2D* TimeMapEEM_; - - TProfile2D* EneMapEB_; - TProfile2D* TimeMapEB_; - - // Error Histograms - TProfile2D* TimeErrorMapEEP_; - TProfile2D* TimeErrorMapEEM_; - - TProfile2D* TimeErrorMapEB_; - - // Event Based Plots - TProfile2D * Event_EneMapEEP_; - TProfile2D * Event_EneMapEEM_; - TProfile2D * Event_EneMapEB_; - - TProfile2D* Event_TimeMapEEP_; - TProfile2D* Event_TimeMapEEM_; - TProfile2D* Event_TimeMapEB_; - - TProfile2D* Event_TimeMapEEP_OOT; - TProfile2D* Event_TimeMapEEM_OOT; - TProfile2D* Event_TimeMapEB_OOT; - - TH1F* RechitEneEB_; - TH1F* RechitTimeEB_; - TH1F* RechitEneEEM_; - TH1F* RechitTimeEEM_; - TH1F* RechitEneEEP_; - TH1F* RechitTimeEEP_; - - TH2F* RechitEnergyTimeEB; - TH2F* RechitEnergyTimeEEM; - TH2F* RechitEnergyTimeEEP; - - EcalRingCalibrationTools _ringTools; - const CaloSubdetectorGeometry * endcapGeometry_; - const CaloSubdetectorGeometry * barrelGeometry_; - - std::vector _noisyXtals; - std::vector _noisyXtalsHists; -}; // @@ -301,23 +38,30 @@ EcalTimingCalibProducer::EcalTimingCalibProducer(const edm::ParameterSet& iConfi _ecalRecHitsEETAG(iConfig.getParameter("recHitEECollection")), _recHitFlags(iConfig.getParameter >("recHitFlags")), _recHitMin(iConfig.getParameter("recHitMinimumN")), - _minRecHitEnergy(iConfig.getParameter("minRecHitEnergy")), - _minEntries(iConfig.getParameter("minEntries")), + + ///\todo the min energy should be in ADC not in energy + _minRecHitEnergyStep(iConfig.getParameter("minRecHitEnergyStep")), + _minRecHitEnergyNStep(iConfig.getParameter("minRecHitEnergyNStep")), + _energyThresholdOffsetEB(iConfig.getParameter("energyThresholdOffsetEB")), + _energyThresholdOffsetEE(iConfig.getParameter("energyThresholdOffsetEE")), + _chi2ThresholdOffsetEB(iConfig.getParameter("chi2ThresholdOffsetEB")),//added + _chi2ThresholdOffsetEE(iConfig.getParameter("chi2ThresholdOffsetEE")),//added + _minEntries(iConfig.getParameter("minEntries")), _globalOffset(iConfig.getParameter("globalOffset")), + _storeEvents(iConfig.getParameter("storeEvents")), _produceNewCalib(iConfig.getParameter("produceNewCalib")), _outputDumpFileName(iConfig.getParameter("outputDumpFile")), - _noiseRMSThreshold(iConfig.getParameter("noiseRMSThreshold")), - _noiseTimeThreshold(iConfig.getParameter("noiseTimeThreshold")), + _maxSkewnessForDump(iConfig.getParameter("maxSkewnessForDump")), _ringTools(EcalRingCalibrationTools()) { //_ecalRecHitsEBToken = edm::consumes(iConfig.getParameter< edm::InputTag > ("ebRecHitsLabel")); //the following line is needed to tell the framework what // data is being produced - if(_produceNewCalib){ - setWhatProduced(this, &EcalTimingCalibProducer::produceCalibConstants); -// setWhatProduced(this, &EcalTimingCalibProducer::produceCalibErrors); - setWhatProduced(this, &EcalTimingCalibProducer::produceOffsetConstant); - } + //if(_produceNewCalib) { + // setWhatProduced(this, &EcalTimingCalibProducer::produceCalibConstants); +// //setWhatProduced(this, &EcalTimingCalibProducer::produceCalibErrors); + // setWhatProduced(this, &EcalTimingCalibProducer::produceOffsetConstant); + //} //now do what ever other initialization is needed } @@ -333,103 +77,89 @@ EcalTimingCalibProducer::~EcalTimingCalibProducer() // member functions // -// ------------ method called to produce the data ------------ -// std::shared_ptr EcalTimingCalibProducer::produce(const EcalTimeCalibConstantsRcd& iRecord) -// { -// using namespace edm::es; -// //std::auto_ptr pMyType; -// //return products(pMyType); -// return NULL; -// } - - // ------------ method called once per job just before starting to loop over events ------------ -void EcalTimingCalibProducer::beginOfJob(const edm::EventSetup& iSetup) +void EcalTimingCalibProducer::beginJob() { std::cout << "Begin job: createConstants" << std::endl; - createConstants(iSetup); - - //Get Geometry for Rings - edm::ESHandle pG; - iSetup.get().get(pG); - EcalRingCalibrationTools::setCaloGeometry(&(*pG)); - endcapGeometry_ = pG->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); - barrelGeometry_ = pG->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); - -} - -// ------------ method called at the beginning of a new loop over the event ------------ -// ------------ the argument starts at 0 and increments for each loop ------------ -void EcalTimingCalibProducer::startingNewLoop(unsigned int iIteration) -{ - std::cout << "Starting new loop: " << iIteration << std::endl; - ofstream inFile; - inFile.open("/afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_4_patch4/src/EcalTiming/EcalTiming/test/loop.txt"); - inFile<find(RAWIDCRY); //begin(); - std::cout << "index\tcalibConstants\ttimeCalibConstants\n" - << calib2_itr - _calibConstants->begin() << "\t" << *calib2_itr << "\t" << *(_timeCalibConstants.find(RAWIDCRY)) - << std::endl; -#endif + //createConstants(iSetup); + _event_tracker = 0; //Keep track of the event number // Initialize histograms at start of Loop char histDirName[100]; - sprintf(histDirName, "EcalSplashTiming_%d", iIteration); + sprintf(histDirName, "EcalSplashTiming"); // Make a new directory for Histograms for each loop histDir_ = fileService_->mkdir( histDirName); initHists(histDir_); - // reset the calibration + initTree(histDir_); + // reset the calibration _timeCalibMap.clear(); - //reset Rechitenergy map -// _CrysEnergyMap.clear(); - } -bool EcalTimingCalibProducer::addRecHit(const EcalRecHit& recHit) + +bool EcalTimingCalibProducer::addRecHit(const EcalRecHit& recHit, EventTimeMap& eventTimeMap_) { - ifstream inFile; - inFile.open("/afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_4_patch4/src/EcalTiming/EcalTiming/test/loop.txt"); - int iter; - inFile>>iter; - //std::cout<<"Threshold: "<<_minRecHitEnergy+(0.5*iter)< energyThreshold = getEnergyThreshold(recHit.detid()); // first->energy threshold, second->chi2 threshold + //std::cout<<"Min Energy "<energyThreshold.second)) return false; // minRecHitEnergy in ADC for EB - the minChi2 value has to be implemented separately like the minEnergy + //if(recHit.detid().subdetId() == EcalEndcap && recHit.energy() < 2 * (_minRecHitEnergy+_minRecHitEnergyStep*_iter)) return false; + + _event_tracker+=1; + if(_event_tracker%10000==0) std::cout<<"------> event passed: "<<_event_tracker<<" <------"<(recHit.detid(),recHit.energy() )); return true; } +/** + fills the energy map and timing maps for EB, EE+ and EE- + */ void EcalTimingCalibProducer::plotRecHit(const EcalTimingEvent& recHit) { + /*if(recHit.detid().subdetId() != EcalBarrel && recHit.detid().subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<Fill(recHit.energy(), recHit.time()); } } - // if it is a noisy crystal plot it - auto it = std::find(_noisyXtals.begin(), _noisyXtals.end(), recHit.detid().rawId()); - if(it != _noisyXtals.end()) - _noisyXtalsHists[std::distance(_noisyXtals.begin(), it)]->Fill(recHit.time()); + //} } /** @@ -466,6 +193,11 @@ EcalTimingEvent EcalTimingCalibProducer::correctGlobalOffset(const EcalTimingEve { DetId id = te.detid(); + /* if(id.subdetId() != EcalBarrel && id.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<getGeometry(id)->getPosition().z(); @@ -481,49 +213,86 @@ EcalTimingEvent EcalTimingCalibProducer::correctGlobalOffset(const EcalTimingEve } // ------------ called for each event in the loop. The present event loop can be stopped by return kStop ------------ -EcalTimingCalibProducer::Status EcalTimingCalibProducer::duringLoop(const edm::Event& iEvent, const edm::EventSetup& iSetup) +bool EcalTimingCalibProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) { + //Get Geometry for Rings + edm::ESHandle pG; + iSetup.get().get(pG); + EcalRingCalibrationTools::setCaloGeometry(&(*pG)); +// if(pG->getSubdetectorGeometry(DetId::Ecal, EcalEndcap) || pG->getSubdetectorGeometry(DetId::Ecal, EcalBarrel)){ + + endcapGeometry_ = pG->getSubdetectorGeometry(DetId::Ecal, EcalEndcap); + barrelGeometry_ = pG->getSubdetectorGeometry(DetId::Ecal, EcalBarrel); + /* }else{ + std::cout<<"problem"< hElecMap; + iSetup.get().get(hElecMap); + elecMap_ = hElecMap.product(); // here the getByToken of the rechits edm::Handle ebRecHitHandle; - //iEvent.getByLabel(_ecalRecHitsEBToken, ebRecHitHandle); iEvent.getByLabel(_ecalRecHitsEBTAG, ebRecHitHandle); edm::Handle eeRecHitHandle; iEvent.getByLabel(_ecalRecHitsEETAG, eeRecHitHandle); - eventTimeMap_.clear(); + _eventTimeMap.clear(); // reset the map of time from recHits for this event - timeEB.clear(); - timeEEM.clear(); - timeEEP.clear(); + // the following maps are used to: + // - distinguish between beam1 and beam2 in splash events looking at the relative time shift + // - adjust the global time offset if required (for splash events for example). + // The global time shift is set such that all the time measurements in the event are relative to one ring + timeEB.clear(); // reset the map for one ring in EB + timeEEM.clear(); // reset the map for one ring in EE- + timeEEP.clear(); // reset the map for one ring in EE+ - // loop over the recHits + // loop over the recHits and add those passing the selection to the list of recHits to be used for timing: eventTimeMap // recHit_itr is of type: edm::Handle::const_iterator - //std::cout<<"EB recHit handle: "<size()<size()<begin(); recHit_itr != ebRecHitHandle->end(); ++recHit_itr) { - addRecHit(*recHit_itr); // add the recHit to the list of recHits used for calibration (with the relative information) + // add the recHit to the list of recHits used for calibration (with the relative information) + + if(addRecHit(*recHit_itr, _eventTimeMap)) { + //EBDetId id(recHit.detid()); + // if(id.ieta() == -75 && id.iphi() == 119) { + // std::cout << "RawID\t" << id.rawId() << std::endl; + // return false; + // } + timeEB.add(EcalTimingEvent(*recHit_itr), false); + } } // same for EE for(auto recHit_itr = eeRecHitHandle->begin(); recHit_itr != eeRecHitHandle->end(); ++recHit_itr) { - addRecHit(*recHit_itr); // add the recHit to the list of recHits used for calibration (with the relative information) + // add the recHit to the list of recHits used for calibration (with the relative information) + if(addRecHit(*recHit_itr, _eventTimeMap)) { // true if the recHit passes the selection and then added to the timeCalibMap + // create EEDetId + EEDetId id(recHit_itr->detid()); + if(id.zside() < 0) { + timeEEM.add(EcalTimingEvent(*recHit_itr), false); + } else { + timeEEP.add(EcalTimingEvent(*recHit_itr), false); + } + } } #ifdef DEBUG - std::cout << "[DEBUG]" << "\t" << eventTimeMap_.size(); - std::cout << timeEB.num() << "\t"; - std::cout << timeEEM.num() << "\t"; - std::cout << timeEEP.num() << "\n"; + std::cout << "[DEBUG]" << "nRecHits passing selection" + << "\t" << _eventTimeMap.size() + << "\t" << timeEB.num() + << "\t" << timeEEM.num() + << "\t" << timeEEP.num() + << std::endl; #endif - // If we got less than the minimum recHits, continue - if(eventTimeMap_.size() < _recHitMin) return kContinue; - if(timeEB.num() + timeEEM.num() + timeEEP.num() < _minEntries) return kContinue; + // If we got less than the minimum recHits, continue -> this is to select events with enough activity + if(_eventTimeMap.size() < _recHitMin) return false; #ifdef DEBUG std::cout << "[DUMP]\t" << timeEB << "\t" << timeEEM << "\t" << timeEEP << std::endl; #endif - // Make a new directory for Histograms for each event + // Make a new directory for Histograms for each event if you want plots per event char eventDirName[100]; if(_makeEventPlots) { sprintf(eventDirName, "Event_%d", int(iEvent.id().event()) ); @@ -531,85 +300,121 @@ EcalTimingCalibProducer::Status EcalTimingCalibProducer::duringLoop(const edm::E initEventHists(eventDir); } + // for splashes you want to distinguish between beam 1 and beam 2 + // you can use the average time over one ring in EE- and one ring in EE+ for that int splashDir = (timeEEP.mean() > timeEEM.mean()) ? 1 : -1; // 1 for beam 1, -1 for beam 2 float bunchCorr = 0.0f; if( std::max(timeEEP.mean(), timeEEM.mean()) > 10.0) bunchCorr = -25.0f; // Add adjusted timeEvents to CorrectionsMap - for(auto const & it : eventTimeMap_) { + for(auto const & it : _eventTimeMap) { + // if it is a splash event, set a global offset shift such that the time is coherent between different events EcalTimingEvent event = _isSplash ? correctGlobalOffset(it.second, splashDir, bunchCorr) : it.second; - // if it is a noisy and hit is out of time, skip it - auto find_it = std::find(_noisyXtals.begin(), _noisyXtals.end(), event.detid().rawId()); - if(find_it != _noisyXtals.end() && abs(event.time()) > _noiseTimeThreshold) - { -#ifdef DEBUG - std::cout << "Noisy: " << event.detid().rawId() << ' ' << event.time() << std::endl; -#endif - continue; - } if(_makeEventPlots) plotRecHit(event); - _timeCalibMap[it.first].add(event); - } + _timeCalibMap[it.first].add(event,_storeEvents); -#ifdef DEBUG - std::cout << eventDirName << "\t" << timeEB; - std::cout << "\t" << timeEEM; - std::cout << "\t" << timeEEP << std::endl; -#endif + //Find the CCU(tower) that this crystal belongs to + unsigned int elecID = getElecID(it.first); + _HWCalibrationMap[elecID].add(event,false); + + } // any etaRing check? // any etaRing inter-calibration? - return kContinue; + return true; } // ------------ called at the end of each event loop. A new loop will occur if you return kContinue ------------ -EcalTimingCalibProducer::Status EcalTimingCalibProducer::endOfLoop(const edm::EventSetup&, unsigned int iLoop_) +void EcalTimingCalibProducer::endJob() { std::cout << "EndOfLoop " << std::endl; + + // calculate the calibration constants // set the values in _calibConstants, _calibErrors, _offsetConstant + #ifdef DEBUG - auto calib2_itr = _calibConstants->find(RAWIDCRY); //begin(); - std::cout << "index\tcalibConstants\ttimeCalibConstants: before setValue\n" - << calib2_itr - _calibConstants->begin() << "\t" << *calib2_itr << "\t" << *(_timeCalibConstants.find(RAWIDCRY)) << "\t" << _calibConstants->size() - << std::endl; - float debugCorrection; + for (auto it : _HWCalibrationMap) + { + if (abs(it.second.mean()) > HW_UNIT * 1.5) std::cout << "HW: " << it.first << ' ' << it.second.mean() << std::endl; + } #endif - + // remove the entries OOT (time > n_sigma) + float n_sigma = 2.; /// \todo remove hard coded number for(auto calibRecHit_itr = _timeCalibMap.begin(); calibRecHit_itr != _timeCalibMap.end(); ++calibRecHit_itr) { - //for(auto calibRecHit_itr : _timeCalibMap) { + /* if(calibRecHit_itr->first.subdetId() == EcalBarrel){ + EBDetId ID(calibRecHit_itr->first()); + calibRecHit_itr->second.dumpAllToTree(infoTree, ID.ieta(),ID.iphi(), 0, ID.time(), ID.energy(), ID.chi2(),13 * 0.04 + _energyThresholdOffsetEB); + }else{ + EEDetId ID(calibRecHit_itr->first()); + calibRecHit_itr->second.dumpAllToTree(infoTree, ID.ix(),ID.iy(), ID.iz(), ID.time(), ID.energy(), ID.chi2(),13 * 0.04 + _energyThresholdOffsetEB); + }*/ FillCalibrationCorrectionHists(calibRecHit_itr); // histograms with shifts to be corrected at each step - float correction = - calibRecHit_itr->second.mean(); -#ifdef DEBUG - if(calibRecHit_itr->first.rawId() == RAWIDCRY) debugCorrection = correction; -#endif - _timeCalibConstants.setValue(calibRecHit_itr->first.rawId(), (*_calibConstants)[calibRecHit_itr->first.rawId()] + correction); - //_calibConstants->setValue(calibRecHit_itr->first.rawId(), *(_calibConstants->find(calibRecHit_itr->first.rawId()))+1); - //_timeCalibConstants.setValue(calibRecHit_itr->first.rawId(), *(_timeCalibConstants.find(calibRecHit_itr->first.rawId()))+1); - - // add filing Energy hists here - } + FillHWCorrectionHists(calibRecHit_itr); + float correction = - calibRecHit_itr->second.getMeanWithinNSigma(n_sigma, 10); // to reject tails + _timeCalibConstants.setValue(calibRecHit_itr->first.rawId(), correction); + + unsigned int ds = DS_NONE; + //TODO: This probably shouldn't be commented out. Move the stat check into the individual functions? + if(calibRecHit_itr->second.num() > 50) { + // check the asymmetry of the distribution: if asymmetric, dump the full set of events for further offline studies + if(fabs(calibRecHit_itr->second.getSkewnessWithinNSigma(n_sigma, 10)) > _maxSkewnessForDump) { + ds |= DS_HIGH_SKEW; + + } + + // check if result is stable as function of energy + std::vector< std::pair > energyStability; + //float energyThreshold = getEnergyThreshold(calibRecHit_itr->first); //changed + std::pair energyThreshold = getEnergyThreshold(calibRecHit_itr->first); + if(! calibRecHit_itr->second.isStableInEnergy(energyThreshold.first, energyThreshold.first + _minRecHitEnergyStep * _minRecHitEnergyNStep, _minRecHitEnergyStep, energyStability)) { + ds |= DS_UNSTABLE_EN; + } + FillEnergyStabilityHists(calibRecHit_itr, energyStability); + } - //Find noisy xtals - _noisyXtals.clear(); - for(auto calibRecHit : _timeCalibMap) { - if(calibRecHit.second.stdDev() > _noiseTimeThreshold) + unsigned int elecID = getElecID(calibRecHit_itr->first); + if( abs(_HWCalibrationMap[elecID].mean()) > HW_UNIT * 1.5) { - DetId id_ = calibRecHit.first; - _noisyXtals.push_back(id_.rawId()); + ds |= DS_CCU_OOT; } + + if((calibRecHit_itr->first.rawId() == EBCRYex) || + (calibRecHit_itr->first.rawId() == EECRYex)) ds |= DS_CRYS; + + int iRing = _ringTools.getRingIndexInSubdet(calibRecHit_itr->first); + + //Adding exception problem + /* if(calibRecHit_itr->first.subdetId() != EcalBarrel && calibRecHit_itr->first.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<first.subdetId() <<"\n"; + }else{*/ + if(calibRecHit_itr->first.subdetId() == EcalBarrel && iRing == EBRING) ds |= DS_RING; + else if(calibRecHit_itr->first.subdetId() == EcalEndcap && (iRing == EEmRING || iRing == EEpRING )) ds |= DS_RING; + + if(ds != DS_NONE) + { + int ix, iy, iz; + if(calibRecHit_itr->first.subdetId() == EcalBarrel) { + EBDetId id(calibRecHit_itr->first); + ix = id.ieta(); + iy = id.iphi(); + iz = 0; + } else { + EEDetId id(calibRecHit_itr->first); + ix = id.ix(); + iy = id.iy(); + iz = id.zside(); + } + calibRecHit_itr->second.dumpToTree(dumpTree, ix, iy, iz, ds, elecID, iRing); //changed + } + //} + // add filing Energy hists here } -#ifdef DEBUG - calib2_itr = _calibConstants->find(RAWIDCRY); - std::cout << "index\tcalibConstants\ttimeCalibConstants: after setValue\n" - << calib2_itr - _calibConstants->begin() << "\t" << *calib2_itr << "\t" << *(_timeCalibConstants.find(RAWIDCRY)) << "\t" << debugCorrection - << std::endl; -#endif // save txt time_t now = time(0); @@ -619,21 +424,13 @@ EcalTimingCalibProducer::Status EcalTimingCalibProducer::endOfLoop(const edm::Ev strftime(current_time, sizeof(current_time), "%Y-%m-%d.%X", &tstruct); char filename[100]; - sprintf(filename, "%s-%d.dat", _outputDumpFileName.substr(0, _outputDumpFileName.find(".root")).c_str(), iLoop_); //text file holding constants + sprintf(filename, "%s.dat", _outputDumpFileName.substr(0, _outputDumpFileName.find(".root")).c_str()); //text file holding constants + std::cout<<"Output Root File"<= _maxLoop - 1) return kStop; - ++iLoop_; - return kContinue; -} - -// ------------ called once each job just before the job ends ------------ -void -EcalTimingCalibProducer::endOfJob() -{ } void EcalTimingCalibProducer::dumpCorrections(std::string filename) @@ -644,17 +441,21 @@ void EcalTimingCalibProducer::dumpCorrections(std::string filename) // to make more efficient for(auto calibRecHit_itr = _timeCalibMap.begin(); calibRecHit_itr != _timeCalibMap.end(); ++calibRecHit_itr) { DetId id_ = calibRecHit_itr->first; - if(id_.subdetId()==EcalBarrel){ - EBDetId id(id_); - fout << id.ieta() << "\t" << id.iphi() << "\t" << 0 - << "\t" << calibRecHit_itr->second.mean() << "\t" << calibRecHit_itr->second.stdDev() << "\t" << calibRecHit_itr->second.num() << "\t" << calibRecHit_itr->second.meanE() - << "\t" << id.rawId() << std::endl; - } else { - EEDetId id(id_); - fout << id.ix() << "\t" << id.iy() << "\t" << id.zside() - << "\t" << calibRecHit_itr->second.mean() << "\t" << calibRecHit_itr->second.stdDev() << "\t" << calibRecHit_itr->second.num() << "\t" << calibRecHit_itr->second.meanE() - << "\t" << id.rawId() << std::endl; - } + /*if(id_.subdetId() != EcalBarrel && id_.subdetId()!= EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<second.getMeanWithinNSigma(2,10) << "\t" << calibRecHit_itr->second.stdDev() << "\t" << calibRecHit_itr->second.num() << "\t" << calibRecHit_itr->second.meanE() + << "\t" << id.rawId() << std::endl; + } else { + EEDetId id(id_); + fout << id.ix() << "\t" << id.iy() << "\t" << id.zside() + << "\t" << calibRecHit_itr->second.getMeanWithinNSigma(2,10) << "\t" << calibRecHit_itr->second.stdDev() << "\t" << calibRecHit_itr->second.num() << "\t" << calibRecHit_itr->second.meanE() + << "\t" << id.rawId() << std::endl; + } + // } } fout.close(); } @@ -667,13 +468,17 @@ void EcalTimingCalibProducer::dumpCalibration(std::string filename) // to make more efficient #ifdef DEBUG DetId findId(RAWIDCRY); - if(findId.subdetId() == EcalBarrel) { - EBDetId id(RAWIDCRY); - fout << "EB: " << id.ieta() << "\t" << id.iphi() << "\t" << id.zside() << "\t" << _timeCalibConstants.barrelItems()[id.denseIndex()] << "\t" << *_timeCalibConstants.find(RAWIDCRY) << "\t" << id.rawId() << std::endl; - } else { - EEDetId id(findId); - fout << "EE: " << id.ix() << "\t" << id.iy() << "\t" << id.zside() << "\t" << _timeCalibConstants.endcapItems()[id.denseIndex()] << "\t" << *_timeCalibConstants.find(RAWIDCRY) << std::endl; - } + /*if (findId.subdetId() != EcalBarrel && findId.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<first.subdetId() == EcalBarrel) { - EBDetId id(cal_itr->first); - // Fill Rechit Energy - EneMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.meanE()); // 2D energy map - TimeMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.mean()); // 2D time map - TimeErrorMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.meanError()); + int ix,iy,iz; + int rawid = cal_itr->first.rawId(); + /*if(cal_itr->first.subdetId() != EcalBarrel && cal_itr->first.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<first.subdetId() <<"\n"; + }else{*/ + if(cal_itr->first.subdetId() == EcalBarrel) { + EBDetId id(cal_itr->first); + // Fill Rechit Energy + EneMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.meanE()); // 2D energy map + TimeMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.getMeanWithinNSigma(2,10)); // 2D time map + TimeErrorMapEB_->Fill(id.ieta(), id.iphi(), cal_itr->second.getMeanErrorWithinNSigma(2,10)); + + RechitEneEB_->Fill(cal_itr->second.meanE()); // 1D histogram + RechitTimeEB_->Fill(cal_itr->second.getMeanWithinNSigma(2,10)); // 1D histogram + + // Fill Occupancy histo + OccupancyEB_->Fill(id.ieta(),id.iphi(), OccupancyEB[id.ieta()+85][id.iphi()]); + + ix = id.ieta(); + iy = id.iphi(); + iz = 0; + + } else { + // create EEDetId + EEDetId id(cal_itr->first); + if(id.zside() < 0) { + EneMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.meanE()); + TimeMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.getMeanWithinNSigma(2,10)); + TimeErrorMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.getMeanErrorWithinNSigma(2,10)); + + RechitEneEEM_->Fill(cal_itr->second.meanE()); + RechitTimeEEM_->Fill(cal_itr->second.getMeanWithinNSigma(2,10)); + + OccupancyEEM_->Fill(id.ix(), id.iy(), OccupancyEEM[id.ix()][id.iy()]); + + } else { + EneMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.meanE()); + TimeMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.getMeanWithinNSigma(2,10)); + TimeErrorMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.getMeanErrorWithinNSigma(2,10)); + + RechitEneEEP_->Fill(cal_itr->second.meanE()); + RechitTimeEEP_->Fill(cal_itr->second.getMeanWithinNSigma(2,10)); + + OccupancyEEP_->Fill(id.ix(), id.iy(), OccupancyEEP[id.ix()][id.iy()]); + + } + + ix = id.ix(); + iy = id.iy(); + iz = id.zside(); + } + // } + int iRing = _ringTools.getRingIndexInSubdet(cal_itr->first); + cal_itr->second.dumpCalibToTree(timingTree, rawid, ix, iy, iz, getElecID(cal_itr->first), iRing); +} - RechitEneEB_->Fill(cal_itr->second.meanE()); // 1D histogram - RechitTimeEB_->Fill(cal_itr->second.mean()); // 1D histogram - } else { - // create EEDetId - EEDetId id(cal_itr->first); - if(id.zside() < 0) { - EneMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.meanE()); - TimeMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.mean()); - TimeErrorMapEEM_->Fill(id.ix(), id.iy(), cal_itr->second.meanError()); +void EcalTimingCalibProducer::FillHWCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr) +{ + unsigned int elecID = getElecID(cal_itr->first); + float time = _HWCalibrationMap[elecID].mean(); + /*if(cal_itr->first.subdetId() != EcalBarrel && cal_itr->first.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<first.subdetId() <<"\n"; + }else{*/ + + if(cal_itr->first.subdetId() == EcalBarrel) { + EBDetId id(cal_itr->first); + // Fill Rechit Energy + HWTimeMapEB_->Fill(id.ieta(), id.iphi(), time); // 2D time map + } else { + // create EEDetId + EEDetId id(cal_itr->first); + if(id.zside() < 0) { + HWTimeMapEEM_->Fill(id.ix(), id.iy(), time); + } else { + HWTimeMapEEP_->Fill(id.ix(), id.iy(), time); + } + } + // } - RechitEneEEM_->Fill(cal_itr->second.meanE()); - RechitTimeEEM_->Fill(cal_itr->second.mean()); - } else { - EneMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.meanE()); - TimeMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.mean()); - TimeErrorMapEEP_->Fill(id.ix(), id.iy(), cal_itr->second.meanError()); +} +void EcalTimingCalibProducer::FillEnergyStabilityHists(EcalTimeCalibrationMap::const_iterator cal_itr, std::vector< std::pair > energyStability) +{ - RechitEneEEP_->Fill(cal_itr->second.meanE()); - RechitTimeEEP_->Fill(cal_itr->second.mean()); - } + int ix,iy,iz; + int rawid = cal_itr->first.rawId(); + //choose which map to store in + /* if(cal_itr->first.subdetId() != EcalBarrel && cal_itr->first.subdetId() != EcalEndcap){ + throw cms::Exception("EcalProblem") << "No valid subdetId(): "<first.subdetId() <<"\n"; + }else{*/ + if(cal_itr->first.subdetId() == EcalBarrel) { + EBDetId id(cal_itr->first); + ix = id.ieta(); + iy = id.iphi(); + iz = 0; + } else { + EEDetId id(cal_itr->first); + ix = id.ix(); + iy = id.iy(); + iz = id.zside(); + } + // } + int iRing = _ringTools.getRingIndexInSubdet(cal_itr->first); + + // Add min_energy to the tree which gets filld inside the dump function + float min_energy = -1.0; + if(energyStabilityTree->GetBranch("min_energy") == NULL) energyStabilityTree->Branch("min_energy", &min_energy, "min_energy/F"); + energyStabilityTree->SetBranchAddress("min_energy", &min_energy); + + UChar_t index = 0; + if(energyStabilityTree->GetBranch("index") == NULL) energyStabilityTree->Branch("index", &index, "index/b"); + energyStabilityTree->SetBranchAddress("index", &index); + + for(auto it = energyStability.begin(); it!=energyStability.end(); it++) + { + min_energy = it->first; + it->second->dumpCalibToTree(energyStabilityTree,rawid,ix,iy,iz,getElecID(cal_itr->first),iRing); + index++; } } - void EcalTimingCalibProducer::initEventHists(TFileDirectory fdir) { Event_EneMapEB_ = fdir.make("EneMapEB", "RecHit Energy[GeV] EB map;i#eta; i#phi;E[GeV]", 171, -85, 86, 360, 1., 361.); @@ -744,6 +638,8 @@ void EcalTimingCalibProducer::initEventHists(TFileDirectory fdir) // void EcalTimingCalibProducer::initHists(TFileDirectory fdir) { + std::cout<<"Initializing histos"<("EneMapEB", "RecHit Energy[GeV] EB profile map;i#eta; i#phi;E[GeV]", 171, -85, 86, 360, 1., 361.); TimeMapEB_ = fdir.make("TimeMapEB", "Mean Time [ns] EB profile map; i#eta; i#phi;Time[ns]", 171, -85, 86, 360, 1., 361.); @@ -765,23 +661,33 @@ void EcalTimingCalibProducer::initHists(TFileDirectory fdir) RechitEneEEP_ = fdir.make("RechitEneEEP", "RecHit Energy[GeV] EE+;Rechit Energy[GeV]; Events", 200, 0.0, 100.0); RechitEneEB_ = fdir.make("RechitEneEB", "RecHit Energy[GeV] EB;Rechit Energy[GeV]; Events", 200, 0.0, 100.0); - RechitEnergyTimeEEM = fdir.make("RechitEnergyTimeEEM", "RecHit Energy vs Time EE-;Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 1000.0, 100, -15,30); - RechitEnergyTimeEEP = fdir.make("RechitEnergyTimeEEP", "RecHit Energy vs Time EE+;Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 1000.0, 100, -15,30); - RechitEnergyTimeEB = fdir.make("RechitEnergyTimeEB", "RecHit Energy vs Time EB; Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 100.0, 100, -15,30); + RechitEnergyTimeEEM = fdir.make("RechitEnergyTimeEEM", "RecHit Energy vs Time EE-;Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 1000.0, 100, -15, 30); + RechitEnergyTimeEEP = fdir.make("RechitEnergyTimeEEP", "RecHit Energy vs Time EE+;Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 1000.0, 100, -15, 30); + RechitEnergyTimeEB = fdir.make("RechitEnergyTimeEB", "RecHit Energy vs Time EB; Rechit Energy[GeV]; Time[ns]; Events", 200, 0.0, 100.0, 100, -15, 30); - if(_noisyXtals.size()) - { - _noisyXtalsHists.clear(); - char histDirName[] = "noisyXtals"; - TFileDirectory dir = fdir.mkdir( histDirName); - for(auto raw_id : _noisyXtals) - { - char name[100]; - sprintf(name, "xtal_%d", raw_id); - _noisyXtalsHists.push_back(dir.make(name,name,21,-10,11)); - } - } + // HW Histograms + + HWTimeMapEEP_ = fdir.make("HWTimeMapEEP", "Mean HW Time[ns] profile map EE+;ix;iy; Time[ns]", 100, 1, 101, 100, 1, 101); + HWTimeMapEEM_ = fdir.make("HWTimeMapEEM", "Mean HW Time[ns] profile map EE-;ix;iy; Time[ns]", 100, 1, 101, 100, 1, 101); + HWTimeMapEB_ = fdir.make("HWTimeMapEB", "Mean HW Time[ns] EB profile map; i#eta; i#phi;Time[ns]", 171, -85, 86, 360, 1., 361.); + + //Occupancy histograms + + OccupancyEB_ = fdir.make("OccupancyEB", "Occupancy EB; i#eta; i#phi; #Hits", 171, -85, 86, 361, 1., 361.); + OccupancyEEM_ = fdir.make("OccupancyEEM", "OccupancyEEM; iy; ix; #Hits", 100, 1, 101, 100, 1, 101); + OccupancyEEP_ = fdir.make("OccupancyEEP", "OccupancyEEP; iy; ix; #Hits", 100, 1, 101, 100, 1, 101); + +} + +// +void EcalTimingCalibProducer::initTree(TFileDirectory fdir) +{ + std::cout<<"Initializing trees"<("dumpTree", ""); + timingTree = fdir.make("timingTree", ""); + energyStabilityTree = fdir.make("energyStabilityTree", ""); + infoTree = fdir.make("infoTree", ""); } //define this as a plug-in -DEFINE_FWK_LOOPER(EcalTimingCalibProducer); +DEFINE_FWK_MODULE(EcalTimingCalibProducer); diff --git a/EcalTiming/plugins/EcalTimingCalibProducer.h b/EcalTiming/plugins/EcalTimingCalibProducer.h new file mode 100644 index 0000000..c4286cc --- /dev/null +++ b/EcalTiming/plugins/EcalTimingCalibProducer.h @@ -0,0 +1,317 @@ +#ifndef ecaltimingcalibproducer_h +#define ecaltimingcalibproducer_h +/** \class EcalTimingCalibProducer EcalTimingCalibProducer.h EcalTiming/EcalTiming/plugins/EcalTimingCalibProducer.h + \brief Plugin that derives the calibration constants + + This plugin runs over the events, selects the recHits according to the criteria defined in addRecHit + + \todo Exit condition based on convergence + +*/ + +/** + Module description: + - digi to calibrated recHit reconstruction + - selection of events with reasonable activity: minimum number of recHits + - select recHits based on: + - recoFlag -> only good recHits (exclude OOT pileup contribution with MultiFit) + - minimum energy, ring based threshold + - save all the time events (recHits) passing the selection + - discard those not within 2 sigma of the stdDev distribution for the single channel (then excluding OOT spurious events) + - exclude events with large time error (> 3ns) or null time error (==0 ns) + - verify that the distribution is symmetric + - check stability vs energy of the single channel within uncertainty + - save full dump of time events in TTree for further checks if: + - distribution not symmetric + - time calibration not stable vs energy + - calculate global time for EB, EE + + + */ +//#define DEBUG +#define RAWIDCRY 838904321 + +/// The entire set of events are saved for one channel in EB and one channel in EE in order to debug +#define EBCRYex 838861346 +#define EECRYex 872422180 + +/// For one ring in EB, one in EE+ and one in EE- the entire set of events are saved to debug +#define EBRING 1 +#define EEmRING 20 +#define EEpRING 20 + +#define SPEEDOFLIGHT 30.0 // (cm/ns) +#define HW_UNIT 1.1 //(ns) + +// system include files +#include +#include +#include + +// Inserting Exception part +#include "FWCore/Utilities/interface/Exception.h" +// Make Histograms the way!! +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDConsumerBase.h" + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +//#include "FWCore/Framework/interface/Handle.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/Common/interface/Handle.h" +//#include "FWCore/Framework/interface/LooperFactory.h" +//#include "FWCore/Framework/interface/ESProducerLooper.h" +#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ESProducts.h" +#include "FWCore/Framework/interface/Event.h" +// input collections +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" +//RingTools +#include "Calibration/Tools/interface/EcalRingCalibrationTools.h" +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" +#include "Geometry/EcalMapping/interface/EcalMappingRcd.h" + +// record to be produced: +#include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h" +#include "CondFormats/DataRecord/interface/EcalTimeCalibErrorsRcd.h" +#include "CondFormats/DataRecord/interface/EcalTimeOffsetConstantRcd.h" +#include "CondTools/Ecal/interface/EcalTimeCalibConstantsXMLTranslator.h" +#include "CondTools/Ecal/interface/EcalTimeCalibErrorsXMLTranslator.h" +#include "CondTools/Ecal/interface/EcalTimeOffsetXMLTranslator.h" +#include "CondTools/Ecal/interface/EcalCondHeader.h" + +#include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h" +#include "CondFormats/EcalObjects/interface/EcalTimeCalibErrors.h" +#include "CondFormats/EcalObjects/interface/EcalTimeOffsetConstant.h" + +#include "EcalTiming/EcalTiming/interface/EcalTimingEvent.h" +#include "EcalTiming/EcalTiming/interface/EcalCrystalTimingCalibration.h" + +#include "DataFormats/EcalDetId/interface/EBDetId.h" +#include "DataFormats/EcalDetId/interface/EEDetId.h" + +#include "TProfile.h" +#include "TGraphErrors.h" +#include "TGraph.h" +#include "TH1F.h" +#include "TH2F.h" +#include "TFile.h" +#include "TProfile2D.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +//#include + +#include "EcalTiming/EcalTiming/interface/EcalTimeCalibrationMapFwd.h" + +class EcalTimingCalibProducer : public edm::EDFilter +{ + +private: + EcalTimeCalibrationMap _timeCalibMap; ///< calibration map: contains the time shift for each crystal + EventTimeMap _eventTimeMap; ///< container of recHits passing selection in the event (reset at each event) + EcalHWCalibrationMap _HWCalibrationMap; //!< The keys for this map are EcalElectronicIds with xtalid = stripid = 1 + ///< calibration map for the CCU's (Hardware Constants). + + // For finding averages for specific eta ring + EcalCrystalTimingCalibration timeEEP; ///< global time calibration of EE+ + EcalCrystalTimingCalibration timeEEM; ///< global time calibration of EE- + EcalCrystalTimingCalibration timeEB; ///< global time calibration of EB + EcalCrystalTimingCalibration timeEBRing; ///< global time calibration of one EB ring + EcalCrystalTimingCalibration timeEEmRing; ///< global time calibration of one EE- ring + EcalCrystalTimingCalibration timeEEpRing; ///< global time calibration of one EE+ ring + EcalCrystalTimingCalibration timeEBCRYex; ///< global time calibration of one EB channel + EcalCrystalTimingCalibration timeEECRYex; ///< global time calibration of one EE channel + +public: + EcalTimingCalibProducer(const edm::ParameterSet&); // default constructor + ~EcalTimingCalibProducer(); // default destructor + + + virtual void beginJob() override; + virtual bool filter(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + int OccupancyEB[171][361] = {{0}}; //added occupancy plots + int OccupancyEEM[101][101] = {{0}}; + int OccupancyEEP[101][101] = {{0}}; + +private: + // ----------member data --------------------------- + /** @name Input Parameters + * Parameters defined in the config file _cfi,py + */ + ///@{ + + unsigned int _maxLoop; ///< maximum number of loops for intercalibration + bool _isSplash; ///< flag to activate for splash analysis + bool _makeEventPlots; ///< flag for making plots for each event (meant for splashes) + edm::InputTag _ecalRecHitsEBTAG; ///< input collection + edm::InputTag _ecalRecHitsEETAG;///< input collection + std::vector _recHitFlags; ///< vector containing list of valid rec hit flags for calibration + unsigned int _recHitMin; ///< require at least this many rec hits to count the event + double _minRecHitEnergyStep; ///< to check step size to check energy stability + double _minRecHitEnergyNStep; ///< number of steps to check energy stability + double _energyThresholdOffsetEB; ///< energy to add to the minimum energy thresholc + double _energyThresholdOffsetEE; ///< energy to add to the minimum energy thresholc + double _chi2ThresholdOffsetEB; //chi2 square thr for the Barrel --- Added + double _chi2ThresholdOffsetEE; //chi2 square thr for the Endcap --- Added + unsigned int _minEntries; ///< require a minimum number of entries in a ring to do averages + float _globalOffset; ///< time to subtract from every event + bool _storeEvents; + bool _produceNewCalib; ///< true if you don't want to use the values in DB and what to extract new absolute calibrations, if false iteration does not work + std::string _outputDumpFileName; ///< name of the output file for the calibration constants' dump + float _maxSkewnessForDump; +/// @} + + void dumpCalibration(std::string filename); + void dumpCorrections(std::string filename); + +// plotting +///fill histograms with the measured shifts (that will become -corrections for the next step) + void FillCalibrationCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr); + void FillHWCorrectionHists(EcalTimeCalibrationMap::const_iterator cal_itr); + void FillEnergyStabilityHists(EcalTimeCalibrationMap::const_iterator cal_itr, std::vector< std::pair > energyStability); + void initHists(TFileDirectory dir); + void initEventHists(TFileDirectory dir); + void initTree(TFileDirectory dir); + + EcalTimeCalibConstants _timeCalibConstants; ///< container of calibrations updated iter by iter + + + + /** + \brief If recHit passes the selection it is added to the list of recHits to be used for calibration + + The recHit is used (accepted) if: + - recHit flag in the list of _recHitFlags defined in the config file + - recHit energy in EB > _minRecHitEnergy defined in the config file + - recHit energy in EE is x2 the threshold of EB + - at each iteration the recHit threshold is raised by _minRecHitEnergyStep + If the recHit is used, the time information is added to _eventTimeMap + */ + bool addRecHit(const EcalRecHit& recHit, EventTimeMap& eventTimeMap_); + + + /// Adds the recHit to the per Event histograms + void plotRecHit(const EcalTimingEvent& recHit); + /// + /// Returns an EcalTimingEvent with a new time, which has been adjusted + /// so that the upstream endcap is 0. + /// + EcalTimingEvent correctGlobalOffset(const EcalTimingEvent& ev, int splashDir, float bunchCorr); + + unsigned int getElecID(DetId id) + { + return (elecMap_->getElectronicsId(id).rawId() >> 6) & 0x3FFF; + } + //float getEnergyThreshold(const DetId detid) + std::pair getEnergyThreshold(const DetId detid) + { + int iRing = _ringTools.getRingIndexInSubdet(detid); + //std::pair outputThr = detid.subdetId() == EcalBarrel ? {13 * 0.04 + _energyThresholdOffsetEB, _chi2ThresholdOffsetEB} : {20 * (79.29 - 4.148 * iRing + 0.2442 * iRing * iRing ) / 1000 + _energyThresholdOffsetEE, _chi2ThresholdOffsetEE} + std::pair outputThr; + if (detid.subdetId() == EcalBarrel){ + outputThr = {13 * 0.04 + _energyThresholdOffsetEB, _chi2ThresholdOffsetEB}; + }else{ + outputThr = {20 * (79.29 - 4.148 * iRing + 0.2442 * iRing * iRing ) / 1000 + _energyThresholdOffsetEE, _chi2ThresholdOffsetEE}; + } + //return detid.subdetId() == EcalBarrel ? 13 * 0.04 + _energyThresholdOffsetEB : + // 20 * (79.29 - 4.148 * iRing + 0.2442 * iRing * iRing ) / 1000 + _energyThresholdOffsetEE; + return outputThr; + } + + std::map _CrysEnergyMap; + + edm::Service fileService_; + TFileDirectory histDir_; + // Tree + TTree *dumpTree; + TTree * timingTree; + TTree * energyStabilityTree; + TTree * infoTree; + + // Mean Histograms + + TProfile2D* EneMapEEP_; /// Using TProfile2D so we don't paint empty bins. + TProfile2D* EneMapEEM_; + TProfile2D* TimeMapEEP_; + TProfile2D* TimeMapEEM_; + + TProfile2D* EneMapEB_; + TProfile2D* TimeMapEB_; + + // Error Histograms + TProfile2D* TimeErrorMapEEP_; + TProfile2D* TimeErrorMapEEM_; + + TProfile2D* TimeErrorMapEB_; + + // Event Based Plots + TProfile2D * Event_EneMapEEP_; + TProfile2D * Event_EneMapEEM_; + TProfile2D * Event_EneMapEB_; + + TProfile2D* Event_TimeMapEEP_; + TProfile2D* Event_TimeMapEEM_; + TProfile2D* Event_TimeMapEB_; + + TProfile2D* Event_TimeMapEEP_OOT; + TProfile2D* Event_TimeMapEEM_OOT; + TProfile2D* Event_TimeMapEB_OOT; + + TH1F* RechitEneEB_; + TH1F* RechitTimeEB_; + TH1F* RechitEneEEM_; + TH1F* RechitTimeEEM_; + TH1F* RechitEneEEP_; + TH1F* RechitTimeEEP_; + + // HW Histograms + TProfile2D* HWTimeMapEEP_; + TProfile2D* HWTimeMapEEM_; + TProfile2D* HWTimeMapEB_; + + TH2F* RechitEnergyTimeEB; + TH2F* RechitEnergyTimeEEM; + TH2F* RechitEnergyTimeEEP; + + //Occupancy plots + TH2D* OccupancyEB_; + TH2D* OccupancyEEM_; + TH2D* OccupancyEEP_; + + EcalRingCalibrationTools _ringTools; + const CaloSubdetectorGeometry * endcapGeometry_; + const CaloSubdetectorGeometry * barrelGeometry_; + + const EcalElectronicsMapping * elecMap_; + int _event_tracker; + + unsigned int _iter; +}; + +#endif diff --git a/EcalTiming/plugins/RecHitsSelector.cc b/EcalTiming/plugins/RecHitsSelector.cc new file mode 100644 index 0000000..2243266 --- /dev/null +++ b/EcalTiming/plugins/RecHitsSelector.cc @@ -0,0 +1,189 @@ +// -*- C++ -*- +// +// Package: EcalTiming/RecHitSelector +// Class: RecHitSelector +// +/**\class RecHitSelector RecHitSelector.cc EcalTiming/RecHitSelector/plugins/RecHitSelector.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Peter Hansen +// Created: Tue, 21 Jul 2015 09:35:32 GMT +// +// + + +// system include files +#include +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" + +// +// class declaration +// + +class RecHitSelector : public edm::EDProducer { + public: + explicit RecHitSelector(const edm::ParameterSet&); + ~RecHitSelector(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + virtual void beginJob() override; + virtual void produce(edm::Event&, const edm::EventSetup&) override; + virtual void endJob() override; + + //virtual void beginRun(edm::Run const&, edm::EventSetup const&) override; + //virtual void endRun(edm::Run const&, edm::EventSetup const&) override; + //virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + //virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + + // ----------member data --------------------------- + edm::InputTag _ecalRecHitsTAG; + std::vector _recHitFlags; + double _minRecHitEnergy; +}; + +// +// constants, enums and typedefs +// + + +// +// static data member definitions +// + +// +// constructors and destructor +// +RecHitSelector::RecHitSelector(const edm::ParameterSet& iConfig): + _ecalRecHitsTAG(iConfig.getParameter("recHitCollection")), + _recHitFlags(iConfig.getParameter >("recHitFlags")), + _minRecHitEnergy(iConfig.getParameter("minRecHitEnergy")) +{ + //register your products + produces(); + + //if do put with a label + //produces("filteredRecHitEBCollection"); + + //if you want to put into the Run + //produces(); + //now do what ever other initialization is needed + +} + + +RecHitSelector::~RecHitSelector() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called to produce the data ------------ +void +RecHitSelector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + // here the getByToken of the rechits + edm::Handle RecHitHandle; + iEvent.getByLabel(_ecalRecHitsTAG, RecHitHandle); + + std::unique_ptr rec_out(new EcalRecHitCollection()); + + for(auto recHit_itr : *RecHitHandle) { + if(!recHit_itr.checkFlags(_recHitFlags)) continue; + if(recHit_itr.energy() < _minRecHitEnergy) continue; + + rec_out->push_back(recHit_itr); + } + + iEvent.put(std::move(rec_out)); + +/* this is an EventSetup example + //Read SetupData from the SetupRecord in the EventSetup + ESHandle pSetup; + iSetup.get().get(pSetup); +*/ + +} + +// ------------ method called once each job just before starting event loop ------------ +void +RecHitSelector::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +RecHitSelector::endJob() { +} + +// ------------ method called when starting to processes a run ------------ +/* +void +RecHitSelector::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} +*/ + +// ------------ method called when ending the processing of a run ------------ +/* +void +RecHitSelector::endRun(edm::Run const&, edm::EventSetup const&) +{ +} +*/ + +// ------------ method called when starting to processes a luminosity block ------------ +/* +void +RecHitSelector::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} +*/ + +// ------------ method called when ending the processing of a luminosity block ------------ +/* +void +RecHitSelector::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} +*/ + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +RecHitSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.add("recHitCollection"); + desc.add >("recHitFlags"); + desc.add("minRecHitEnergy"); + descriptions.addDefault(desc); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(RecHitSelector); diff --git a/EcalTiming/python/ElectronicsPlots.py b/EcalTiming/python/ElectronicsPlots.py index 32f7c31..0892b04 100644 --- a/EcalTiming/python/ElectronicsPlots.py +++ b/EcalTiming/python/ElectronicsPlots.py @@ -1,6 +1,6 @@ import ROOT -import CalibCalorimetry.EcalTiming.TokenRing as TokenRing -from CalibCalorimetry.EcalTiming.PlotUtils import customROOTstyle, drawMultipleGrid +import EcalTiming.EcalTiming.TokenRing as TokenRing +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, drawMultipleGrid def makeMap(tree, attribute): EB = ROOT.TProfile2D(attribute + "EB",attribute + " EB",360,1,361,85*2,-84,86) diff --git a/EcalTiming/python/PlotUtils.py b/EcalTiming/python/PlotUtils.py index cdbfd7f..673960f 100644 --- a/EcalTiming/python/PlotUtils.py +++ b/EcalTiming/python/PlotUtils.py @@ -10,14 +10,14 @@ def customROOTstyle() : ROOT.gStyle.SetPadTopMargin(0.06); ROOT.gStyle.SetPadBottomMargin(0.13); ROOT.gStyle.SetPadLeftMargin(0.12); - ROOT.gStyle.SetPadRightMargin(0.12); + ROOT.gStyle.SetPadRightMargin(.15) ROOT.gStyle.SetLabelColor(1, "XYZ"); ROOT.gStyle.SetLabelFont(42, "XYZ"); ROOT.gStyle.SetLabelOffset(0.007, "XYZ"); ROOT.gStyle.SetLabelSize(0.05, "XYZ"); ROOT.gStyle.SetTitleSize(0.05, "XYZ"); ROOT.gStyle.SetTitleOffset(1.0, "X"); - ROOT.gStyle.SetTitleOffset(1.4, "Y"); + ROOT.gStyle.SetTitleOffset(1.1, "Y"); ROOT.gStyle.SetTitleOffset(1.0, "Z"); ROOT.gStyle.SetAxisColor(1, "XYZ"); ROOT.gStyle.SetStripDecimals(True); @@ -39,6 +39,16 @@ def customROOTstyle() : ROOT.gStyle.SetPalette(55); ROOT.gStyle.SetNumberContours(100); +import numpy as np +def customPalette(zeropoint = 0.5): + Number = 3; + Red = np.array([0 , 100, 110],dtype=float)/255. + Green = np.array([0 , 255, 0], dtype=float)/255. + Blue = np.array([99 , 100, 2], dtype=float)/255. + Length = np.array([0.0, zeropoint, 1.0], dtype=float) + nb=100; + ROOT.TColor.CreateGradientColorTable(Number,Length,Red,Green,Blue,nb) + def drawMultipleGrid(hists,outname,limits=[],setLogY=False,setLogZ=False, ncols = 3, width=1500,height=1100): c = ROOT.TCanvas("c", "c", width,height) nhists = len(hists) diff --git a/EcalTiming/python/RecHitsSelector_cfi.py b/EcalTiming/python/RecHitsSelector_cfi.py new file mode 100644 index 0000000..fa888fa --- /dev/null +++ b/EcalTiming/python/RecHitsSelector_cfi.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +ecalRecHitEBSelector= cms.EDProducer("RecHitSelector", + recHitCollection = cms.InputTag("ecalRecHit","EcalRecHitsEB"), + recHitFlags = cms.vint32([0]), # only recHits with these flags are accepted for calibration + minRecHitEnergy = cms.double(0.5), + ) + +ecalRecHitEESelector= cms.EDProducer("RecHitSelector", + recHitCollection = cms.InputTag("ecalRecHit","EcalRecHitsEE"), + recHitFlags = cms.vint32([0]), # only recHits with these flags are accepted for calibration + minRecHitEnergy = cms.double(0.5), + ) diff --git a/EcalTiming/python/TimingPlots.py b/EcalTiming/python/TimingPlots.py index 0e12e34..0bfd8ed 100644 --- a/EcalTiming/python/TimingPlots.py +++ b/EcalTiming/python/TimingPlots.py @@ -1,5 +1,5 @@ import ROOT -from CalibCalorimetry.EcalTiming.PlotUtils import customROOTstyle +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle def saveEventTimingPlots(eventdir): customROOTstyle() diff --git a/EcalTiming/python/cmsRunFileFormat.sh b/EcalTiming/python/cmsRunFileFormat.sh deleted file mode 100755 index 9081906..0000000 --- a/EcalTiming/python/cmsRunFileFormat.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# This Small tool almost gave me the hwole day to know how to use it. - -# It actually Puts the input root files in the way accepted by CMS Modules: - -# Author TEN - - sed -e s/"\/pnfs"/"'dcache:\/pnfs"/ -e s/"root"/"root',"/ < doubleEleRun2012C_22Jan.txt > DoubleEleRun2012C_22Jan.txt& -# sed -e s/"\/pnfs/"/"'dcache:\/pnfs/"/ -e s/"root"/"root',"/ < singleEleR12C.txt >SingleEleRun2012C.txt& diff --git a/EcalTiming/python/compare.py b/EcalTiming/python/compare.py new file mode 100644 index 0000000..5a99bab --- /dev/null +++ b/EcalTiming/python/compare.py @@ -0,0 +1,138 @@ +import ROOT +from EcalTiming.EcalTiming.loadOldCalib import getCalib,getCalibFromFile, getRawIDMap +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle + +customROOTstyle() + +oldCalib = getCalib() +rawidMap = getRawIDMap() +simone = getCalibFromFile("PhiSimmetry_run251252.dat") +peter = getCalibFromFile("/afs/cern.ch/work/p/phansen/public/EcalTiming/round1/AlCaPhiSym-251252/ecalTimeRelative-251252-0_numEvent5000000-corr.dat") + +outdir = "plots/simone252/" + +def initMap(name, title, iz): + if iz == 0: + h = ROOT.TProfile2D("EB_" + name, title, 360, 1, 361, 171, -85, 86) + xtitle = "i#phi" + ytitle = "i#eta" + elif iz == -1: + h = ROOT.TProfile2D("EEM_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + elif iz == 1: + h = ROOT.TProfile2D("EEP_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + else: + print "bad iz value", iz + return None + h.SetXTitle(xtitle) + h.SetYTitle(ytitle) + return h + +def inittime1d(name, title, iz): + if iz == 0: + det = "EB_" + elif iz == -1: + det = "EEM_" + elif iz == 1: + det = "EEP_" + else: + #print "bad iz value", iz + det = str(iz) + h = ROOT.TH1F(det + name, title, 50, -10,30) + h.SetXTitle("Time [ns]") + h.SetYTitle("Events") + return h + +hpeter = dict() +hsimone = dict() +hpeter1d = dict() +hsimone1d = dict() +holdCalib = dict() +hdiff = dict() +hdiff1d = dict() +for iz in [-1,0,1]: + hpeter[iz] = initMap("peter","peter",iz) + hsimone[iz] = initMap("simone","simone",iz) + holdCalib[iz] = initMap("oldCalib","oldCalib",iz) + hdiff[iz] = initMap("diff","diff",iz) + hpeter1d[iz] = inittime1d("peter1d", "peter1d",iz) + hsimone1d[iz] = inittime1d("simone1d", "simone1d",iz) + hdiff1d[iz] = inittime1d("diff1d", "diff1d",iz) + + +#means = {0:0.398 + 0.5, -1:-1.130, 1:-0.832} +#means = {0:0.398 + 0.5, -1:-1.130, 1:-0.832} +#simone_means = {0:.5, -1:12, 1:12} +means = {0:0, -1:0, 1:0} +simone_means = {0:0, -1:0, 1:0} +ids = set(simone) & set(peter) & set(rawidMap) +print len(ids) +for id in ids: + crystal= rawidMap[id] + iz = crystal.iz + if iz == 0: + x = crystal.iy + y = crystal.ix + else: + x = crystal.ix + y = crystal.iy + + + hsimone[iz].Fill(x,y,simone[id] - simone_means[iz]) + hpeter[iz].Fill(x,y,peter[id] + means[iz]) + holdCalib[iz].Fill(x,y,oldCalib[id]) + hdiff[iz].Fill(x,y,simone[id] - simone_means[iz] - (oldCalib[id] - peter[id] - means[iz])) + hpeter1d[iz].Fill(peter[id] + means[iz]) + hsimone1d[iz].Fill(simone[id]-simone_means[iz]) + hdiff1d[iz].Fill(simone[id]-simone_means[iz] - (oldCalib[id] - peter[id] - means[iz])) + + +c = ROOT.TCanvas("c","c") +for h in hsimone.values() + holdCalib.values(): + h.SetAxisRange(-10,10,"Z") + h.Draw("colz") + c.SaveAs(outdir + h.GetName() + ".png") + +for h in hpeter.values(): + h.SetAxisRange(-10,10,"Z") + h.Draw("colz") + c.SaveAs(outdir + h.GetName() + ".png") + +for iz in hdiff: + h = hdiff[iz] + h.SetAxisRange(-10,10,"Z") + h.Draw("colz") + c.SaveAs(outdir + h.GetName() + ".png") + +for h in hdiff1d.values() + hpeter1d.values() + hsimone1d.values(): + h.Draw() + c.SaveAs(outdir + h.GetName() + ".png") + +#if __name__ == "__main__": +# customROOTstyle() +# ROOT.gROOT.SetBatch(True) +# filename = sys.argv[1] +# +# #if len(sys.argv) > 1: +# # outdir = sys.argv[1] +# #elif filename.startswith("output"): +# # use same path as input file with output -> plots +# dir, basename = os.path.split(filename) +# dir = dir.split('/') +# print dir[-1:] +# outdir = '/'.join(dir[:-1]) + "/plots/" + dir[-1] +# outdir = os.path.normpath(outdir) +# +# def mkdir_p(path): +# try: +# os.makedirs(path) +# except OSError as exc: # Python >2.5 +# if exc.errno == errno.EEXIST and os.path.isdir(path): +# pass +# else: raise +# +# mkdir_p(outdir) +# shutil.copy("plots/index.php", outdir) diff --git a/EcalTiming/python/crab.cfg b/EcalTiming/python/crab.cfg deleted file mode 100644 index 329962b..0000000 --- a/EcalTiming/python/crab.cfg +++ /dev/null @@ -1,74 +0,0 @@ -[CMSSW] -total_number_of_events = -1 -number_of_jobs = 500 -#runselection = 172798-173000 -#runselection = 202233-203695 -#total_number_of_lumis = -1 -lumis_per_job = 5000 -#pset = Mydpanalysis_unclean.py -#pset = Cleaned_ecalTimeEleMakeTree_cfg.py -pset = tryUnCleaned_ecalTimeEleMakeTree_cfg.py -#datasetpath =/PhotonHad/Run2012C-PromptReco-v2/RECO -#datasetpath =/SinglePhotonParked/Run2012D-22Jan2013-v1/AOD -#datasetpath =/SinglePhoton/Run2012D-PromptReco-v1/RECO -#datasetpath =/SinglePhoton/Run2012C-PromptReco-v1/RECO -#datasetpath =/SinglePhoton/Run2012B-PromptReco-v1/RECO -#datasetpath =/SinglePhoton/Run2012C-22Jan2013-v1/RECO -#datasetpath =/SinglePhoton/Run2012B-EXODisplacedPhoton-22Jan2013-v1/RECO -#datasetpath =/SinglePhoton/Run2012D-EXODisplacedPhoton-PromptSkim-v1/RECO -#datasetpath =/SinglePhoton/Run2012D-EXODisplacedPhoton-19Dec2012-v1/RECO -#datasetpath =/SinglePhotonParked25ns/Run2012D-PromptReco-v1/RECO -#datasetpath =/SinglePhoton/Run2012B-22Jan2013-v1/RECO -#datasetpath =/SingleElectron/Run2012A-22Jan2013-v1/RECO -#datasetpath = /SingleElectron/Run2012C-22Jan2013-v1/RECO -#datasetpath =/DoubleElectron/Run2012A-22Jan2013-v1/AOD -#datasetpath =/DoubleElectron/Run2012B-22Jan2013-v1/AOD -#datasetpath =/DoubleElectron/Run2012C-22Jan2013-v1/AOD -#datasetpath =/DoubleElectron/Run2012D-22Jan2013-v1/AOD -datasetpath =/DoubleElectron/Run2012C-22Jan2013-v1/AOD -#datasetpath =/DoubleElectron/Run2012A-22Jan2013-v1/RECO -#datasetpath =/DoubleElectron/Run2012B-22Jan2013-v1/RECO -##datasetpath =/DoubleElectron/Run2012C-22Jan2013-v1/RECO -#datasetpath =/DoubleElectron/Run2012D-22Jan2013-v1/RECO -#datasetpath =/DoubleElectron/Run2012D-PromptReco-v1/RECO -#datasetpath =/DoubleElectron/Run2012D-16Jan2013-v1/RECO -#datasetpath =/ElectronHad/Run2012C-PromptReco-v2/RECO - - -output_file = EcalTimeTree_999999.root -#lumi_mask=/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions11/7TeV/Prompt/Cert_160404-163869_7TeV_PromptReco_Collisions11_JSON.txt -#lumi_mask=/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions11/7TeV/Prompt/Cert_160404-166502_7TeV_PromptReco_Collisions11_JSON.txt -#lumi_mask=/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions11/7TeV/Prompt/Cert_160404-167913_7TeV_PromptReco_Collisions11_JSON.txt -allow_NonProductionCMSSW = 1 - -[GRID] -#se_black_list=fnal.gov -#se_white_list=fnal.gov - -[USER] -return_data = 1 -copy_data = 0 -#publish_data = 0 - -#storage_element=T2_CH_CERN -#user_remote_dir=test -#user_remote_dir = Photon -#email = tambe@cern.ch -email = norbert@physics.umn.edu -#ui_working_dir =/uscms_data/d3/tnorbert/DataSets/SinglePhoton2012C-PR-V2/ -#user_remote_dir =/uscms_data/d3/tnorbert/DataSets/Photon2012C-PR-V2/ # Works -#user_remote_dir =/pnfs/cms/WAX/resilient/tnorbert/PhotonDataSet/ # Works - -#ui_working_dir = /uscms_data/d3/jaredt/ecalTiming/electronHadSep6 -#copy_data = 1 -storage_element = T2_US_Wisconsin -user_remote_dir = TutGridSchool4TEN - -[CRAB] -scheduler = condor -#scheduler = remoteGlidein -#scheduler = glidein -jobtype = cmssw -use_server = 0 -#[CAF] -#queue=cmscaf1nd diff --git a/EcalTiming/python/ecalLocalRecoSequenceAlCaP0Stream_cff.py b/EcalTiming/python/ecalLocalRecoSequenceAlCaP0Stream_cff.py new file mode 100644 index 0000000..9d82aa1 --- /dev/null +++ b/EcalTiming/python/ecalLocalRecoSequenceAlCaP0Stream_cff.py @@ -0,0 +1,17 @@ +from RecoLocalCalo.Configuration.ecalLocalRecoSequence_cff import * + +ecalLocalRecoSequenceAlCaP0Stream = cms.Sequence (ecalMultiFitUncalibRecHit * + ecalRecHit) + +ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("dummyHits","dummyBarrelDigis") +ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("dummyHits","dummyEndcapDigis") + + +#ecalDetIdToBeRecovered = RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi.ecalDetIdToBeRecovered.clone() +ecalRecHit.killDeadChannels = cms.bool( False ) +ecalRecHit.recoverEBVFE = cms.bool( False ) +ecalRecHit.recoverEEVFE = cms.bool( False ) +ecalRecHit.recoverEBFE = cms.bool( False ) +ecalRecHit.recoverEEFE = cms.bool( False ) +ecalRecHit.recoverEEIsolatedChannels = cms.bool( False ) +ecalRecHit.recoverEBIsolatedChannels = cms.bool( False ) diff --git a/EcalTiming/python/ecalTimingCalibProducer_cfi.py b/EcalTiming/python/ecalTimingCalibProducer_cfi.py new file mode 100644 index 0000000..966413c --- /dev/null +++ b/EcalTiming/python/ecalTimingCalibProducer_cfi.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +timing = cms.EDFilter("EcalTimingCalibProducer", + maxLoop = cms.uint32(1), + isSplash = cms.bool(False), + makeEventPlots = cms.bool(False), + recHitEBCollection = cms.InputTag("ecalRecHit","EcalRecHitsEB"), + recHitEECollection = cms.InputTag("ecalRecHit","EcalRecHitsEE"), + recHitFlags = cms.vint32([0]), # only recHits with these flags are accepted for calibration + #recHitMinimumN = cms.uint32(10), + recHitMinimumN = cms.uint32(2), + minRecHitEnergyStep = cms.double(0.5), + minRecHitEnergyNStep = cms.double(10), + energyThresholdOffsetEE = cms.double(0.0), + energyThresholdOffsetEB = cms.double(0.0), + minEntries = cms.uint32(1), + globalOffset = cms.double(0.), + storeEvents = cms.bool(False), + produceNewCalib = cms.bool(True), + outputDumpFile = cms.string('output.dat'), + maxSkewnessForDump = cms.double(2), + ) diff --git a/EcalTiming/python/energyDiff.py b/EcalTiming/python/energyDiff.py new file mode 100644 index 0000000..1d9fec6 --- /dev/null +++ b/EcalTiming/python/energyDiff.py @@ -0,0 +1,75 @@ +import ROOT +import EcalTiming.EcalTiming.loadOldCalib as cal +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle +import sys,os +import shutil +import errno + +def energyDiff(outdir, map1, map2, name1, name2): + + diffMap = cal.addCalib(map1, map2, -1, 1) + cal.plot1d(diffMap, outdir, "diff" + name2 + "_" + name1, -1, 1) + cal.plot2d(diffMap, outdir, "diffMap" + name2 + "_" + name1, -1, 1) + ringdiff = cal.plotiRing(diffMap, outdir, "iRing" + name2 + "_" + name1) + return ringdiff + +if __name__ == "__main__": + customROOTstyle() + ROOT.gROOT.SetBatch(True) + file_pattern = sys.argv[1] + dirname = sys.argv[2] + + dir, basename = os.path.split(file_pattern) + dir = dir.split('/') + print dir[-1:] + outdir = '/'.join(dir[:-1]) + "/plots/" + dir[-1] + "/" + dirname +"/" + outdir = os.path.normpath(outdir) + + def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + mkdir_p(outdir) + shutil.copy("plots/index.php", outdir) + + energies = ["0.0", "0.5", "1.0"] + energies = ["0.0", "0.5", "1.0", "1.5", "2.0", "2.5"] + + files = [ file_pattern % en for en in energies ] + + maps = [ cal.getCalibFromFile(file) for file in files ] + + mg = dict() + mg[0] = ("EB_iRing_err",ROOT.TMultiGraph()) + mg[-1] = ("EEM_iRing_err",ROOT.TMultiGraph()) + mg[1] = ("EEP_iRing_err",ROOT.TMultiGraph()) + + colors = [ROOT.kCyan, ROOT.kRed, ROOT.kBlue, ROOT.kGreen, + ROOT.kBlack] + + x1 = ROOT.gStyle.GetPadLeftMargin(); + x2 = 1 - ROOT.gStyle.GetPadRightMargin(); + y1 = ROOT.gStyle.GetPadBottomMargin(); + y2 = y1 + .1 + leg = ROOT.TLegend(x1,y1,x2,y2) + leg.SetNColumns(4) + for i in range(len(files) - 1): + ringDiff = energyDiff(outdir, maps[i], maps[i+1], energies[i], energies[i+1]) + for j in ringDiff: + g = ROOT.TGraphErrors(ringDiff[j]) + g.SetLineColor(colors[i]) + mg[j][1].Add(g) + leg.AddEntry(g,energies[i+1] + " - " + energies[i]) + + for name,g in mg.values(): + c = ROOT.TCanvas("c","c",1600,1200) + g.Draw("ALP") + g.GetXaxis().SetTitle("#eta Ring") + g.GetYaxis().SetTitle("Average Time[ns]") + leg.Draw() + c.SaveAs(outdir + "/" + name + ".png") + diff --git a/EcalTiming/python/fixCCU.py b/EcalTiming/python/fixCCU.py new file mode 100644 index 0000000..0605fc6 --- /dev/null +++ b/EcalTiming/python/fixCCU.py @@ -0,0 +1,42 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, customPalette +import EcalTiming.EcalTiming.loadOldCalib as cal +import os + + + +def fixCCU(input): + + #input = "/afs/cern.ch/user/p/phansen/public/ecal-timing/dump_EcalTimeCalibConstants_v07_offline__since_00204623_till_4294967295.dat" + customROOTstyle() + + rawidMap = cal.getRawIDMap() + + print_once = set() + ccu_adj = {(54, 19): 4.0, (54, 20): 4.0, (48, 1): 2.0, (48, 2): 2.0, (48, 7): 2.0, (48, 5): 2.0, (48, 6): 2.0, (48, 3): 2.0, (48, 8): 2.0, (48, 4): 2.0, (1, 31): 4.0} + output = input.replace("ecalTiming","ecalTiming-fixCCU-v2") + with open(input,'r') as f: + with open(output,'w') as of: + for line in f: + if "#" in line: continue + line = line.split() + start = line[:3] + end = line[4:] + time = float(line[3]) + rawid = int(line[-1]) + + key = (rawidMap[rawid].FED, rawidMap[rawid].CCU) + if key in ccu_adj: + adj = ccu_adj[key] * 25./24. + if key not in print_once: + print_once.add(key) + print key, line, adj + else: + adj = 0 + out = "\t".join(start + ["%.4f" %(time - adj)] + end) + '\n' + of.write(out) + +if __name__ == "__main__": + filename = "/afs/cern.ch/work/p/phansen/public/EcalTiming/Cuts_EB1.0_EE2.0/AlCaPhiSym-251562/ecalTiming_0_GeV_numEvent10000000-corr.dat" + calib = fixCCU(filename); + diff --git a/EcalTiming/python/loadOldCalib.py b/EcalTiming/python/loadOldCalib.py new file mode 100644 index 0000000..3541637 --- /dev/null +++ b/EcalTiming/python/loadOldCalib.py @@ -0,0 +1,210 @@ +import ROOT +from EcalTiming.EcalTiming.txt2tree import txt2tree +from collections import namedtuple + +Crystal = namedtuple('Crystal',("ix", "iy", "iz", "elecID", "FED", "CCU", "iRing")) +Calib = namedtuple('Calib',("time", "stddev", "num", "energy","rawid" )) + + +det_name = {0:"EB", -1:"EEM", 1:"EEP"} + +def getCalibFromTree(tree): + calibMap = dict() + for event in tree: + calibMap[event.rawid] = event.time + return calibMap + +def getCalib(): + input = "/afs/cern.ch/user/p/phansen/public/ecal-timing/dump_EcalTimeCalibConstants_v07_offline__since_00204623_till_4294967295.dat" + + return getCalibFromFile(input) + +def getRawIDMap(): + """ + returns rawidMap[rawid]= Crystal(ix, iy, iz, elecID, FED, CCU, iRing) + where Crystal is a named tuple + """ + + rawidMap = dict() + + input = "data/crystalmap.txt" + with open(input,'r') as f: + for line in f: + if line[0] == "#": continue + line = line.split() + line = [int(val) for val in line] + ix, iy, iz, elecID, FED, CCU, iRing, rawid = line + rawidMap[rawid] = Crystal(ix, iy, iz, elecID, FED, CCU, iRing) + return rawidMap + +rawidMap = getRawIDMap() + +def getColumnFromFile(input,col): + """ + value from column col and rawid from last column + """ + + calibMap = dict() + linenumber = 0 + with open(input,'r') as f: + for line in f: + linenumber += 1 + if line[0] == "#": continue + if "nan" in line: continue + line = line.split() + val = float(line[col]) + #print linenumber, line + rawid = int(line[-1]) + calibMap[(rawid)] = val + return calibMap + +def getCalibFromFile(input): + """ + Get map of Rawid to time (column 4 in input) + """ + return getColumnFromFile(input,3) + +def getErrorFromFile(input): + """ + Get map of Rawid to time (column 5 in input) + """ + return getColumnFromFile(input,4) + +def getFullCalibFromFile(input): + """ + Get map of Rawid to time (column 5 in input) + """ + calibMap = dict() + linenumber = 0 + with open(input,'r') as f: + for line in f: + linenumber += 1 + if line[0] == "#": continue + if "nan" in line: continue + ix, iy, iz, time, stddev, num, energy, rawid = line.split() + + calibMap[int(rawid)] = Calib(float(time), float(stddev), int(num), + float(energy), int(rawid)) + return calibMap + +def addCalib(map1, map2, c1, c2): + """ + returns ret[id] = map1[id]*c1 + map2[id]*c2 + only contains crystals in both sets + """ + ids = set(map1) & set(map2) + ret = dict() + for id in ids: + ret[id] = map1[id]*c1 + map2[id]*c2 + return ret + +def divideCalib(map1, map2): + """ + returns ret[id] = map1[id]map2[id]*c2 + only contains crystals in both sets + """ + ids = set(map1) & set(map2) + ret = dict() + for id in ids: + if map2[id]: + ret[id] = map1[id]/map2[id] + return ret + +def addOffset(map, offsets): + """ + adds different offsets to each Subdetector + offsets = {0: EB_off, -1:EEM_off, 1:EEp_off} + """ + global rawidMap + + ret = dict() + for id in map: + ret[id] = map[id] + offsets[rawidMap[id].iz] + return ret + +def subtractOffset(map,offsets): + os = dict( [ (iz,-offsets[iz]) for iz in offsets] ) + return addOffset(map,os) + +def calcMeanBySD(map): + sum = {0:0, -1:0, 1:0} + num = {0:0, -1:0, 1:0} + global rawidMap + for id in map: + sum[rawidMap[id].iz] += map[id] + num[rawidMap[id].iz] += 1 + + return dict( [ (iz, sum[iz]/num[iz]) for iz in [0,-1,1] ] ) + +def plot1d(map, dir, name, low, hi,xtitle="[ns]", ytitle="Events"): + global rawidMap + + c = ROOT.TCanvas("c","c",1600,1200) + hists = dict() + for iz in [-1, 0 ,1 ]: + hists[iz] = ROOT.TH1F(det_name[iz] + "_" + name, det_name[iz] + ' ' + name, 50, low, hi) + hists[iz].SetXTitle(xtitle) + hists[iz].SetYTitle(ytitle) + for id,time in map.iteritems(): + hists[rawidMap[id].iz].Fill(time) + + for h in hists.values(): + h.Draw() + c.SaveAs(dir + '/' + h.GetName() + ".png") + +def plotiRing(map, dir, name): + global rawidMap + + c = ROOT.TCanvas("c","c",1600,1200) + hists = dict() + hists[0] = ROOT.TProfile("EB_" + name, 'EB ' + name, 171, -85, 86) + hists[-1] = ROOT.TProfile("EEM_" + name, 'EEM ' + name, 39, 0, 39) + hists[1] = ROOT.TProfile("EEP_" + name, 'EEP ' + name, 39, 0, 39) + for id,time in map.iteritems(): + hists[rawidMap[id].iz].Fill(rawidMap[id].iRing, time) + hists[rawidMap[id].iz].SetXTitle("#eta ring") + hists[rawidMap[id].iz].SetYTitle("[ns]") + + for h in hists.values(): + h.Draw() + c.SaveAs(dir + '/' + h.GetName() + ".png") + + return hists + +def plot2d(map, dir, name, low, hi,setLogz=False): + global rawidMap + + c = ROOT.TCanvas("c","c",1600,1200) + if setLogz: + c.SetLogz() + hists = dict() + hists[0] = ROOT.TProfile2D("EB_" + name, 'EB ' + name, 360, 1, 361, 171, -85, 86) + hists[0].SetXTitle("i#phi") + hists[0].SetYTitle("i#eta") + hists[-1] = ROOT.TProfile2D("EEM_" + name, 'EEM ' + name, 100, 1, 101, 100, 1, 101) + hists[-1].SetXTitle("ix") + hists[-1].SetYTitle("iy") + hists[1] = ROOT.TProfile2D("EEP_" + name, 'EEP ' + name, 100, 1, 101, 100, 1, 101) + hists[1].SetXTitle("ix") + hists[1].SetYTitle("iy") + for id,time in map.iteritems(): + if id not in rawidMap: continue + crys = rawidMap[id] + if crys.iz == 0: + x = crys.iy + y = crys.ix + else: + x = crys.ix + y = crys.iy + hists[crys.iz].Fill(x,y,time) + + for h in hists.values(): + h.SetAxisRange(low,hi,"Z") + h.Draw("colz") + c.SaveAs(dir + '/' + h.GetName() + ".png") + +if __name__ == "__main__": + print "hi" + calib = getCalib(); + print len(calib) + diff --git a/EcalTiming/python/makeCrystalMap.py b/EcalTiming/python/makeCrystalMap.py new file mode 100644 index 0000000..4165e1c --- /dev/null +++ b/EcalTiming/python/makeCrystalMap.py @@ -0,0 +1,22 @@ +import ROOT +from EcalTiming.EcalTiming.tree2txt import tree2txt +import math + +import os +import sys +import errno +import shutil + +argc = len(sys.argv) +if argc < 3: + print "Usage: tree2txt.py input.root path/to/TTree" + sys.exit(-1) + +filename = sys.argv[1] +tree_path = sys.argv[2] + +file = ROOT.TFile.Open(filename) +tree = file.Get(tree_path) +tree2txt(tree, filter = ["ix","iy","iz","elecID","iRing","rawid"]) + + diff --git a/EcalTiming/python/makeCrystalSelection.py b/EcalTiming/python/makeCrystalSelection.py index fb74138..697b83d 100644 --- a/EcalTiming/python/makeCrystalSelection.py +++ b/EcalTiming/python/makeCrystalSelection.py @@ -72,7 +72,7 @@ def getCalibrations(filename, invert = -1): print len(beam1), len(beam2), len(oldcalib) -from CalibCalorimetry.EcalTiming.calibrationXML import CalibrationXML +from EcalTiming.EcalTiming.calibrationXML import CalibrationXML cal = CalibrationXML() @@ -89,7 +89,7 @@ def getCalibrations(filename, invert = -1): cal.writeErrors("error.xml") import ROOT -from CalibCalorimetry.EcalTiming.PlotUtils import drawMultipleGrid,customROOTstyle +from EcalTiming.EcalTiming.PlotUtils import drawMultipleGrid,customROOTstyle customROOTstyle() def plotCalibration(crystals,histoname): diff --git a/EcalTiming/python/methDiff.py b/EcalTiming/python/methDiff.py new file mode 100644 index 0000000..ff0b9bb --- /dev/null +++ b/EcalTiming/python/methDiff.py @@ -0,0 +1,88 @@ +import ROOT +import EcalTiming.EcalTiming.loadOldCalib as cal +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle +import sys,os +import shutil +import errno + +def mapDiff(outdir, map1, map2, name1, name2, errs=[]): + + diffMap = cal.addCalib(map1, map2, -1, 1) + + ROOT.gStyle.SetOptStat(1100) + if errs: + resMap = cal.divideCalib(map1, errs) + cal.plot1d(resMap,outdir, "resmap" + name2 + "_" + name1, -2, 2, xtitle="diff/timeError") + cal.plot1d(diffMap, outdir, "diff" + name2 + "_" + name1, -.4, .4) + ROOT.gStyle.SetOptStat(0) + cal.plot2d(diffMap, outdir, "diffMap" + name2 + "_" + name1, -.4, .4) + ringdiff = cal.plotiRing(diffMap, outdir, "iRing" + name2 + "_" + name1) + return ringdiff + +def listDiff(hist_name, maps1, maps2, names1, names2, errs=[]): + mg = dict() + mg[0] = ("EB_" + hist_name,ROOT.TMultiGraph()) + mg[-1] = ("EEM_" + hist_name,ROOT.TMultiGraph()) + mg[1] = ("EEP_" + hist_name,ROOT.TMultiGraph()) + + colors = [ROOT.kBlack, ROOT.kBlue, ROOT.kRed, ROOT.kGreen, ROOT.kCyan, ROOT.kMagenta] + + x1 = ROOT.gStyle.GetPadLeftMargin(); + x2 = 1 - ROOT.gStyle.GetPadRightMargin(); + y1 = ROOT.gStyle.GetPadBottomMargin(); + y2 = y1 + .1 + leg = ROOT.TLegend(x1,y1,x2,y2) + leg.SetNColumns(4) + nmaps = len(maps1) + if nmaps != len(maps2) or nmaps != len(names1) or nmaps!= len(names2): + print "LENGTH MISMATCH" + return + + for i in range(nmaps): + ringDiff = mapDiff(outdir, maps1[i], maps2[i], names1[i], names2[i], errs=errs[i] if errs else []) + for j in ringDiff: + g = ROOT.TGraphErrors(ringDiff[j]) + g.SetLineColor(colors[i % len(colors)] ) + mg[j][1].Add(g) + leg.AddEntry(g,names2[i] + " - " + names1[i]) + + for name,g in mg.values(): + c = ROOT.TCanvas("c","c",1600,1200) + g.Draw("ALP") + g.GetXaxis().SetTitle("#eta Ring") + g.GetYaxis().SetTitle("Average Time[ns]") + leg.Draw() + c.SaveAs(outdir + "/" + name + ".png") + +if __name__ == "__main__": + customROOTstyle() + ROOT.gROOT.SetBatch(True) + file_pattern = sys.argv[1] + + dir, basename = os.path.split(file_pattern) + dir = dir.split('/') + print dir[-2:] + outdir = '/'.join(dir[:-2]) + "/plots/" + "/" + sys.argv[2] + "/" + outdir = os.path.normpath(outdir) + + def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + mkdir_p(outdir) + shutil.copy("plots/index.php", outdir) + + subs = sys.argv[3:] + files = [ file_pattern % s for s in subs ] + maps = [ cal.getCalibFromFile(file) for file in files ] + maps_err = [ cal.getErrorFromFile(file) for file in files ] + + print files + print outdir + #listDiff( sys.argv[2], maps[:-1], maps[1:], subs[:-1], subs[1:], errs=maps_err[:-1]) + listDiff(sys.argv[2], maps[:1]*(len(maps)-1), maps[1:], subs[:1]*(len(maps) -1), subs[1:], errs=maps_err[:-1]) + diff --git a/EcalTiming/python/multicrab.cfg b/EcalTiming/python/multicrab.cfg deleted file mode 100644 index 50c7a01..0000000 --- a/EcalTiming/python/multicrab.cfg +++ /dev/null @@ -1,123 +0,0 @@ -# section for multicrab: now has just the template crab.cfg, but more -# keys might appear in the future -[MULTICRAB] -cfg=crab.cfg - -# Section in common for all dataset -# General idea: you define all the parameter in the template (crab.cfg), -# but you might want to change the template values for all dataset. -# The general syntax is that you first put the crab.cfg [SECTION] and -# the the crab.cfg [key], with a "." in between, exactly as you would do -# to pass to CRAB keys via command line. -# Any parameters can be set or changed -[COMMON] -#EDG.se_black_list= T2_US_Caltech , cit-se.ultralight.org -#EDG.ce_black_list= T2_US_Caltech , cit-se.ultralight.org -#desy added on Fri Mar 25 08:52:53 CET 2011 - -# Add a section for each dataset you want to access (or, more precisely, -# any task you want to create). -# The name of the section will be used as USER.ui_working_dir, so the -# stuff for this dataset will be found in Wmunu/ directory. -# Any name is allowed (but MULTICRAB and COMMON) and any number of -# sections can be added -# The syntax for the parameters is the one described before -# SECTION.key=value -# and any parameter can be changed. Otherwise, the template one will be -# used. -#USER.user_remote_dir=/user/s/sckao/DPAnalysis - - -#[GMSB_L180_CT500] -#CMSSW.datasetpath=/GMSB_Lambda-180_CTau-500_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/GEN-SIM-RECO -#CMSSW.events_per_job =3000 -#CMSSW.total_number_of_events=-1 -#CMSSW.pset=gmsb180_CT500.py -#CMSSW.output_file = gmsb180_500.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB - -#[GMSB_L180_CT1000] -#CMSSW.datasetpath=/GMSB_Lambda-180_CTau-1000_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v2/GEN-SIM-RECO -#CMSSW.events_per_job =3000 -#CMSSW.total_number_of_events=-1 -#CMSSW.pset=gmsb180_CT1000.py -#CMSSW.output_file = gmsb180_1000.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB - -#[GMSB_L180_CT2000] -#CMSSW.datasetpath=/GMSB_Lambda-180_CTau-2000_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v2/GEN-SIM-RECO -#CMSSW.events_per_job =3000 -#CMSSW.total_number_of_events=-1 -#CMSSW.pset=gmsb180_CT2000.py -#CMSSW.output_file =/pnfs/cms/WAX/resilient/tnorbert/GMSB -#USER.user_remote_dir= GMSB - -#[GMSB_L180_CT3000] -#CMSSW.datasetpath=/GMSB_Lambda-180_CTau-3000_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v2/GEN-SIM-RECO -#CMSSW.events_per_job =3000 -#CMSSW.total_number_of_events=-1 -#CMSSW.pset=gmsb180_CT3000.py -#CMSSW.output_file = gmsb180_3000.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB - - -[Double_Electron_Run2012D] -CMSSW.datasetpath =/DoubleElectron/Run2012D-22Jan2013-v1/RECO #/SinglePhoton/Run2012D-EXODisplacedPhoton-19Dec2012-v1/RECO -CMSSW.events_per_job =3000 -CMSSW.total_number_of_events=-1 -CMSSW.pset=tryUnCleaned_ecalTimeEleMakeTree_cfg.py -#CMSSW.pset=Mydpanalysis_unclean.py -CMSSW.output_file = EcalTimeTree_999999.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/SinglePhoton/ -USER.user_remote_dir=/uscms_data/d3/tnorbert/DataSets/DoubleElectron2012D # Works - - -[Double_Electron_Run2012C] -CMSSW.datasetpath =/DoubleElectron/Run2012C-22Jan2013-v1/RECO #/SinglePhoton/Run2012C-22Jan2013-v1/RECO -CMSSW.events_per_job =3000 -CMSSW.total_number_of_events=-1 -CMSSW.pset=tryUnCleaned_ecalTimeEleMakeTree_cfg.py -#CMSSW.pset=Mydpanalysis_unclean.py -CMSSW.output_file = EcalTimeTree_999999.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/SinglePhoton/ -USER.user_remote_dir= /uscms_data/d3/tnorbert/DataSets/DoubleElectron2012C # Works - -##[Single_Photon_Run2012B] -##CMSSW.datasetpath=/SinglePhoton/Run2012B-EXODisplacedPhoton-22Jan2013-v1/RECO -##CMSSW.events_per_job =3000 -##CMSSW.total_number_of_events=-1 -##CMSSW.pset=tryUnCleaned_ecalTimeEleMakeTree_cfg.py -##CMSSW.pset=Mydpanalysis_unclean.py -##CMSSW.output_file = run_2012B_Jan22_2013v1_reco.root -##USER.user_remote_dir=/uscms_data/d3/tnorbert/DataSets/Photon2012B # Works - - -##[GMSB_L180_CT4000] -##CMSSW.datasetpath=/GMSB_Lambda-180_CTau-4000_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/GEN-SIM-RECO -##CMSSW.events_per_job =3000 -##CMSSW.total_number_of_events=-1 -##CMSSW.pset=gmsb180_CT4000.py -##CMSSW.output_file = gmsb180_4000.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB -#USER.user_remote_dir=GMSB_4000 -##USER.user_remote_dir=/uscms_data/d3/tnorbert/DataSets/GMSB_4000 # Works - -##[GMSB_L180_CT6000] -##CMSSW.datasetpath=/GMSB_Lambda-180_CTau-6000_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v2/GEN-SIM-RECO -##CMSSW.events_per_job =3000 -##CMSSW.total_number_of_events=-1 -##CMSSW.pset=gmsb180_CT6000.py -##CMSSW.output_file = gmsb180_6000.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB -#USER.user_remote_dir=GMSB_6000 -##USER.user_remote_dir=/uscms_data/d3/tnorbert/DataSets/GMSB_6000 # Works - -##[GMSB_L180_CT250] -##CMSSW.datasetpath=/GMSB_Lambda-180_CTau-250_TuneZ2star_8TeV-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/GEN-SIM-RECO -##CMSSW.events_per_job =3000 -##CMSSW.total_number_of_events=-1 -##CMSSW.pset= gmsb180_CT250.py -##CMSSW.output_file = gmsb180_250.root -#USER.user_remote_dir=/pnfs/cms/WAX/resilient/tnorbert/GMSB -#USER.user_remote_dir=GMSB_250 -##USER.user_remote_dir=/uscms_data/d3/tnorbert/DataSets/GMSB_250 # Works diff --git a/EcalTiming/python/plotCCU.py b/EcalTiming/python/plotCCU.py new file mode 100644 index 0000000..fc30f3d --- /dev/null +++ b/EcalTiming/python/plotCCU.py @@ -0,0 +1,294 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, customPalette +import math + +import os +import sys +import errno +import shutil + + +detectors = {-1: "EEM", 0: "EB", 1: "EEP"} + + +def float2name(x): + return ("%.1f" % x).replace('.', '_') + + +def initMap(name, title, iz): + if iz == 0: + h = ROOT.TProfile2D("EB_" + name, title, 360, 1, 361, 171, -85, 86) + xtitle = "i#phi" + ytitle = "i#eta" + elif iz == -1: + h = ROOT.TProfile2D("EEM_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + elif iz == 1: + h = ROOT.TProfile2D("EEP_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + else: + print "bad iz value", iz + return None + h.SetXTitle(xtitle) + h.SetYTitle(ytitle) + return h + + +def inittime1d(name, title, iz): + if iz == 0: + det = "EB_" + elif iz == -1: + det = "EEM_" + elif iz == 1: + det = "EEP_" + else: + #print "bad iz value", iz + det = str(iz) + h = ROOT.TH1F(det + name, title, 50, -10, 10) + h.SetXTitle("Time [ns]") + h.SetYTitle("Events") + return h + + +def initiRing(name, title, iz): + if iz == 0: + h = ROOT.TProfile("EB_" + name, title, 171, -85, 86) + elif iz == -1: + h = ROOT.TProfile("EEM_" + name, title, 39, 0, 39) + elif iz == 1: + h = ROOT.TProfile("EEP_" + name, title, 39, 0, 39) + else: + print "bad iz value", iz + return None + h.SetXTitle("iRing") + h.SetYTitle("Mean Time [ns]") + return h + +def initEvsT(name, title, iz): + if iz == 0: + det = "EB" + elif iz == -1: + det = "EEM" + elif iz == 1: + det = "EEP" + else: + print "bad iz value", iz + return None + h = ROOT.TH2F(det + name, title, 50,0,20,100,-10,10) + h.SetXTitle("Energy [GeV]") + h.SetYTitle("Time [ns]") + return h + +def initHists(prefix,hist_dict, init_func, key, name, title): + if key in hist_dict: + return + iz = key + hist_dict[key] = init_func(prefix + name, title, iz) + +def addFitToPlot(h): + fit = ROOT.TF1("gaus","gaus") + h.Fit(fit, "Q") + mu = fit.GetParameter(1) + sigma = fit.GetParameter(2) + label = ROOT.TPaveText(.5, .7, .9, .9, "NDC") + label.AddText("#mu = %.3f" % mu) + label.AddText("#sigma = %.3f" % sigma) + label.Draw() + return mu,sigma + + +def plotCCUs(tree, outdir, prefix=""): + c = ROOT.TCanvas("c","c",1600,1200) + # dictionaries to store histograms + time = dict() + time_offset = dict() + time_offset_ccu = dict() + time_abs = dict() + + CCU = dict() + CCU1d = dict() + CCU_maps = dict() + CCU_maps_cut = dict() + CCU_err_maps = dict() + elec_map = dict() + counter = 0 + + print "Found", tree.GetEntries(), "entries" + if tree.GetEntries() == 0: sys.exit(-1) + + offset = dict() + for iz in detectors: + tree.Draw("time>>temp%d(50,-5,5)" % iz,"iz == %d && num != 0" % iz) + h = ROOT.gDirectory.FindObject("temp%d" % iz) + offset[iz],__ = addFitToPlot(h) + c.SaveAs(outdir + '/' + detectors[iz] + "_1d_noffset.png") + + print "Global offset" + for iz in offset: + print "%d\t%.3f"%(iz, offset[iz]) + + timing = dict() + from EcalTiming.EcalTiming.loadOldCalib import getCalib,getRawIDMap + oldCalib = getCalib() + rawidMap = getRawIDMap() + + for event in tree: + if not counter % (tree.GetEntries()/10): print counter, '/', tree.GetEntries() + counter += 1 + if event.num == 0: continue + + # make dictionary key + if type(event.iz) == type("s"): + iz = ord(event.iz) + if iz == 255: iz = -1 + else: + iz = event.iz + key = iz + if math.isnan(event.time): + print "Found nan", event.rawid, event.ix, event.iy, iz, event.num + continue + # initialize histograms (if they haven't been made yet + initHists(prefix,time, initMap, key, "time", "Time Shifts [ns]") + initHists(prefix,time_offset, initMap, key, "time_offset", "Time Shifts - Global [ns]") + initHists(prefix,time_offset_ccu, initMap, key, "time_offset_ccu", "Time Shifts - Global - HW [ns]") + initHists(prefix,time_abs, initMap, key, "time_abs", "Absolute Time [ns]") + + initHists(prefix,CCU, inittime1d, (event.elecID), "ccu_time", " CCU Time [ns]") + initHists(prefix,CCU1d, inittime1d, key, "ccu_time1d", " CCU Time [ns]") + initHists(prefix,CCU_maps, initMap, key, "time_ccu", "CCU Shifts Map [ns]") + initHists(prefix,CCU_maps_cut, initMap, key, "time_ccu_cut", "CCU Shifts Map [ns]") + initHists(prefix,CCU_err_maps, initMap, key, "timeError_ccu", "StdDev of Crystals in CCU [ns]") + + elec_map[( event.ix, event.iy, iz, event.rawid)] = event.elecID + + # fill histograms + if iz == 0: + x = event.iy + y = event.ix + else: + x = event.ix + y = event.iy + + + time[key].Fill(x, y, event.time) + time_offset[key].Fill(x, y, event.time - offset[iz]) + CCU[event.elecID].Fill(event.time - offset[iz]) + time_abs[iz].Fill(x,y, event.time - offset[iz] - oldCalib[event.rawid]) + + ccu_adj = {(54, 19): 4.0, (54, 20): 4.0, (48, 1): 2.0, (48, 2): 1.0, (48, 7): 2.0, (48, 5): 2.0, (48, 6): 1.0, (48, 3): 1.0, (48, 8): 1.0, (48, 4): 2.0, ( 1, 19): 4.0} + + print "CCU shifts" + unit = 25./24. + for id,crys in rawidMap.iteritems(): + if(crys.FED,crys.CCU) in ccu_adj: + if crys.iz == 0: + x = crys.iy + y = crys.ix + else: + x = crys.ix + y = crys.iy + CCU_maps_cut[crys.iz].Fill(x,y,ccu_adj[(crys.FED,crys.CCU)]) + + r = 3 + for key in CCU_maps: + CCU_maps[key].SetAxisRange(-r, r, "Z") + CCU_maps[key].SetZTitle("[ns]") + CCU_maps[key].Draw("colz") + c.SaveAs(outdir + "/" + CCU_maps[key].GetName() + ".png") + + for key in CCU_maps_cut: + CCU_maps_cut[key].SetAxisRange(-r, r, "Z") + CCU_maps_cut[key].SetZTitle("[ns]") + CCU_maps_cut[key].Draw("colz") + c.SaveAs(outdir + "/" + CCU_maps_cut[key].GetName() + ".png") + + for key in CCU_err_maps: + CCU_err_maps[key].SetAxisRange(0, 2, "Z") + CCU_err_maps[key].SetZTitle("[ns]") + CCU_err_maps[key].Draw("colz") + c.SaveAs(outdir + "/" + CCU_err_maps[key].GetName() + ".png") + + for key in time: + time[key].SetAxisRange(-r, r, "Z") + time[key].SetZTitle("[ns]") + time[key].Draw("colz") + c.SaveAs(outdir + "/" + time[key].GetName() + ".png") + + for key in time_offset: + time_offset[key].SetAxisRange(-r, r, "Z") + time_offset[key].SetZTitle("[ns]") + time_offset[key].Draw("colz") + c.SaveAs(outdir + "/" + time_offset[key].GetName() + ".png") + + for key in time_offset_ccu: + time_offset_ccu[key].Add(time_offset[key], CCU_maps_cut[key], 1, -1 ) + time_offset_ccu[key].SetAxisRange(-r, r, "Z") + time_offset_ccu[key].SetZTitle("[ns]") + time_offset_ccu[key].Draw("colz") + c.SaveAs(outdir + "/" + time_offset_ccu[key].GetName() + ".png") + + def plotOutOfRange(h,hcut,low,high): + ncells = h.GetNcells() + for i in range(ncells): + val = h.GetBinContent(i) + if val < low or val > high: + hcut.SetBinContent(i,val) + hcut.SetBinEntries(i,1) + x,y,z = ROOT.Long(),ROOT.Long(),ROOT.Long() + h.GetBinXYZ(i,x,y,z) + print h.GetName(), x,y,z, val + + for key in time_abs: + time_abs[key].Add(CCU_maps_cut[key], -1) + time_abs[key].SetAxisRange(-10, 10, "Z") + time_abs[key].SetZTitle("[ns]") + time_abs[key].Draw("colz") + c.SaveAs(outdir + "/" + time_abs[key].GetName() + ".png") + + time_abs_oot = initMap("time_abs_oot", "Absolute Time OOT [ns]",key) + plotOutOfRange(time_abs[key], time_abs_oot, -10,10) + time_abs_oot.SetZTitle("[ns]") + time_abs_oot.Draw("colz") + c.SaveAs(outdir + "/" + time_abs_oot.GetName() + ".png") + + + for key in CCU1d: + CCU1d[key].Draw() + c.SaveAs(outdir + "/" + CCU1d[key].GetName() + ".png") + + return time + +if __name__ == "__main__": + + customROOTstyle() + ROOT.gROOT.SetBatch(True) + filename = sys.argv[1] + + #if len(sys.argv) > 1: + # outdir = sys.argv[1] + #elif filename.startswith("output"): + # use same path as input file with output -> plots + dir, basename = os.path.split(filename) + dir = dir.split('/') + print dir[-1:] + outdir = '/'.join(dir[:-1]) + "/plots/" + dir[-1] + outdir = os.path.normpath(outdir) + + def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + mkdir_p(outdir) + shutil.copy("plots/index.php", outdir) + + file = ROOT.TFile.Open(filename) + tree = file.Get("filter/EcalSplashTiming/timingTree") + time = plotCCUs(tree, outdir, ) + + diff --git a/EcalTiming/python/plotMaps.py b/EcalTiming/python/plotMaps.py new file mode 100644 index 0000000..e9bb4a8 --- /dev/null +++ b/EcalTiming/python/plotMaps.py @@ -0,0 +1,348 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, customPalette +import math + +import os +import sys +import errno +import shutil + + +detectors = {-1: "EEM", 0: "EB", 1: "EEP"} + + +def float2name(x): + return ("%.1f" % x).replace('.', '_') + + +def initMap(name, title, iz): + if iz == 0: + h = ROOT.TProfile2D("EB_" + name, title, 360, 1, 361, 171, -85, 86) + xtitle = "i#phi" + ytitle = "i#eta" + elif iz == -1: + h = ROOT.TProfile2D("EEM_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + elif iz == 1: + h = ROOT.TProfile2D("EEP_" + name, title, 100, 1, 101, 100, 1, 101) + xtitle = "ix" + ytitle = "iy" + else: + print "bad iz value", iz + return None + h.SetXTitle(xtitle) + h.SetYTitle(ytitle) + return h + + +def inittime1d(name, title, iz, low=-10, hi=10): + if iz == 0: + det = "EB_" + elif iz == -1: + det = "EEM_" + elif iz == 1: + det = "EEP_" + else: + #print "bad iz value", iz + det = str(iz) + h = ROOT.TH1F(det + name, title, 50, low, hi) + h.SetXTitle("Time [ns]") + h.SetYTitle("Events") + return h + + +def initiRing(name, title, iz, xtitle="iRing", ytitle="Mean Time [ns]"): + if iz == 0: + h = ROOT.TProfile("EB_" + name, title, 171, -85, 86) + elif iz == -1: + h = ROOT.TProfile("EEM_" + name, title, 39, 0, 39) + elif iz == 1: + h = ROOT.TProfile("EEP_" + name, title, 39, 0, 39) + else: + print "bad iz value", iz + return None + h.SetXTitle(xtitle) + h.SetYTitle(ytitle) + return h + +def initEvsT(name, title, iz): + if iz == 0: + det = "EB" + elif iz == -1: + det = "EEM" + elif iz == 1: + det = "EEP" + else: + print "bad iz value", iz + return None + h = ROOT.TH2F(det + name, title, 50,0,20,100,-10,10) + h.SetXTitle("Energy [GeV]") + h.SetYTitle("Time [ns]") + return h + +def initHists(prefix,hist_dict, init_func, key, name, title,**kwargs): + if key in hist_dict: + return + iz = key + hist_dict[key] = init_func(prefix + '_' + name, title, iz, **kwargs) + +def addFitToPlot(h,outfilename): + c = ROOT.TCanvas("c","c",1600,1200) + fit = ROOT.TF1("gaus","gaus") + h.Fit(fit, "Q") + mu = fit.GetParameter(1) + sigma = fit.GetParameter(2) + label = ROOT.TPaveText(.5, .7, .9, .9, "NDC") + label.AddText("#mu = %.3f" % mu) + label.AddText("#sigma = %.3f" % sigma) + label.Draw() + c.SaveAs(outfilename) + return mu,sigma + + +def plotMaps(tree, outdir, prefix=""): + # dictionaries to store histograms + time = dict() + time_rel2012 = dict() + timeError = dict() + timeError1d = dict() + stdDev = dict() + occupancy = dict() + energy = dict() + iRing = dict() + iRingError = dict() + time1d = dict() + EvsT = dict() + + CCU = dict() + CCU_maps = dict() + CCU_err_maps = dict() + elec_map = dict() + counter = 0 + + print "Found", tree.GetEntries(), "entries" + if tree.GetEntries() == 0: sys.exit(-1) + + offset = dict() + for iz in detectors: + tree.Draw("time>>temp%d(50,-5,5)" % iz,"iz == %d && num != 0" % iz) + h = ROOT.gDirectory.FindObject("temp%d" % iz) + offset[iz],__ = addFitToPlot(h,outdir + '/' + detectors[iz] + '_' + prefix + "_1d_noffset.png") + + from EcalTiming.EcalTiming.loadOldCalib import getCalib + oldCalib = getCalib() + + for event in tree: + if not counter % (tree.GetEntries()/10): print counter, '/', tree.GetEntries() + counter += 1 + if event.num == 0: continue + + # make dictionary key + if type(event.iz) == type("s"): + iz = ord(event.iz) + if iz == 255: iz = -1 + else: + iz = event.iz + key = iz + if math.isnan(event.time): + print "Found nan", event.rawid, event.ix, event.iy, iz, event.num + continue + # initialize histograms (if they haven't been made yet + initHists(prefix,time, initMap, key, "time", "Time [ns]") + initHists(prefix,time_rel2012, initMap, key, "time_rel2012", "Time - old calib [ns]") + initHists(prefix,timeError, initMap, key, "timeError", "Time Error[ns]") + initHists(prefix,timeError1d, inittime1d, key, "timeError1d", "Time Error Test [ns]", low=0, hi=.2) + initHists(prefix,stdDev, initMap, key, "stdDev", "Std Dev [ns]") + initHists(prefix,time1d, inittime1d, key, "time1d", "time1d") + + initHists(prefix,occupancy, initMap, key, "occupancy", "Occupancy") + initHists(prefix,energy, initMap, key, "energy", "Energy [GeV]") + initHists(prefix,iRing, initiRing, key, "iRing", "iRing") + initHists(prefix,iRingError, initiRing, key, "iRingError", "iRingError", xtitle="iRing", ytitle="Mean Time Error [ns]") + initHists(prefix,EvsT, initEvsT, key, "EvsT", "EvsT") + + initHists(prefix,CCU, inittime1d, (event.elecID), "ccu_time", " CCU Time [ns]") + initHists(prefix,CCU_maps, initMap, key, "ccu_time_map", "CCU Map [ns]") + initHists(prefix,CCU_err_maps, initMap, key, "ccu_timeError_map", "CCU Error Map [ns]") + + elec_map[( event.ix, event.iy, iz)] = event.elecID + + # fill histograms + if iz == 0: + x = event.iy + y = event.ix + else: + x = event.ix + y = event.iy + + + t = event.time - offset[iz] + + time[key].Fill(x, y, t) + timeError[key].Fill(x, y, event.timeError) + timeError1d[key].Fill(event.timeError) + stdDev[key].Fill(x, y, event.timeError * math.sqrt(event.num)) + time1d[key].Fill(t) + + occupancy[key].Fill(x, y, event.num) + energy[key].Fill(x, y, event.energy) + EvsT[key].Fill(event.energy, t) + iRing[key].Fill(event.iRing, t) + iRingError[key].Fill(event.iRing, event.timeError) + + CCU[event.elecID].Fill(t) + + if event.rawid in oldCalib: + time_rel2012[key].Fill(x,y, t - oldCalib[event.rawid]) + else: + print "Rawid not found", event.rawid + + + for ix,iy,iz in elec_map: + if iz == 0: + x = iy + y = ix + else: + x = ix + y = iy + CCU_maps[iz].Fill(x,y,CCU[elec_map[(ix,iy,iz)]].GetMean()) + CCU_err_maps[iz].Fill(x,y,CCU[elec_map[(ix,iy,iz)]].GetStdDev()) + + c = ROOT.TCanvas("c","c",1600,1200) + for key in CCU_maps: + CCU_maps[key].SetAxisRange(-2, 2, "Z") + CCU_maps[key].SetZTitle("[ns]") + CCU_maps[key].Draw("colz") + c.SaveAs(outdir + "/" + CCU_maps[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in CCU_err_maps: + CCU_err_maps[key].SetAxisRange(0, 2, "Z") + CCU_err_maps[key].SetZTitle("[ns]") + CCU_err_maps[key].Draw("colz") + c.SaveAs(outdir + "/" + CCU_err_maps[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in time: + time[key].SetAxisRange(-10, 10, "Z") + time[key].SetZTitle("[ns]") + time[key].Draw("colz") + c.SaveAs(outdir + "/" + time[key].GetName() + ".10.png") + time[key].SetAxisRange(-5,5,"Z") + time[key].Draw("colz") + c.SaveAs(outdir + "/" + time[key].GetName() + ".5.png") + time[key].SetAxisRange(-2,2,"Z") + time[key].Draw("colz") + c.SaveAs(outdir + "/" + time[key].GetName() + ".2.png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in time_rel2012: + time_rel2012[key].SetAxisRange(-10, 10, "Z") + time_rel2012[key].SetZTitle("[ns]") + time_rel2012[key].Draw("colz") + c.SaveAs(outdir + "/" + time_rel2012[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in timeError: + timeError[key].SetAxisRange(0, .2, "Z") + timeError[key].SetZTitle("[ns]") + timeError[key].Draw("colz") + c.SaveAs(outdir + "/" + timeError[key].GetName() + ".png") + + ROOT.gStyle.SetOptStat(1100) + c = ROOT.TCanvas("c","c",1600,1200) + for key in timeError1d: + timeError1d[key].SetStats(True) + timeError1d[key].Draw() + print timeError1d[key].GetMean(), timeError1d[key].GetRMS() + c.SaveAs(outdir + "/" + timeError1d[key].GetName() + ".png") + + ROOT.gStyle.SetOptStat(0) + c = ROOT.TCanvas("c","c",1600,1200) + for key in stdDev: + stdDev[key].SetAxisRange(0, 3, "Z") + stdDev[key].SetZTitle("[ns]") + stdDev[key].Draw("colz") + c.SaveAs(outdir + "/" + stdDev[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + c.SetLogz(True) + if occupancy: + occu_max = max( [ occupancy[key].GetMaximum() for key in occupancy]) + for key in occupancy: + occupancy[key].SetAxisRange(0, occu_max, "Z") + occupancy[key].SetZTitle("Events") + occupancy[key].Draw("colz") + c.SaveAs(outdir + "/" + occupancy[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + if energy: + en_max = max( [ energy[key].GetMaximum() for key in energy]) + en_max = 5.0 + for key in energy: + energy[key].Draw("colz") + energy[key].SetAxisRange(0, en_max, "Z") + energy[key].SetZTitle("[GeV]") + c.SaveAs(outdir + "/" + energy[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in iRing: + graph = ROOT.TGraphErrors(iRing[key]) + graph.Draw("AP") + iRing[key].Draw() + c.SaveAs(outdir + "/" + iRing[key].GetName() + ".png") + + for key in iRingError: + graph = ROOT.TGraphErrors(iRingError[key]) + graph.Draw("AP") + iRingError[key].Draw() + c.SaveAs(outdir + "/" + iRingError[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + for key in EvsT: + EvsT[key].Draw("colz") + c.SaveAs(outdir + "/" + EvsT[key].GetName() + ".png") + + c = ROOT.TCanvas("c","c",1600,1200) + ROOT.gStyle.SetOptStat(1100) + for key in time1d: + time1d[key].SetStats(True) + time1d[key].Draw() + addFitToPlot(time1d[key],os.path.join(outdir, time1d[key].GetName() + ".png")) + + return time + +if __name__ == "__main__": + + customROOTstyle() + ROOT.gROOT.SetBatch(True) + print sys.argv + filename = sys.argv[1] + prefix = sys.argv[2] + + #if len(sys.argv) > 1: + # outdir = sys.argv[1] + #elif filename.startswith("output"): + # use same path as input file with output -> plots + dir, basename = os.path.split(filename) + dir = dir.split('/') + print dir[-1:] + outdir = '/'.join(dir[:-1]) + "/plots/" + dir[-1] + outdir = os.path.normpath(outdir) + + def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + mkdir_p(outdir) + shutil.copy("plots/index.php", outdir) + + file = ROOT.TFile.Open(filename) + tree = file.Get("filter/EcalSplashTiming/timingTree") + time = plotMaps(tree, outdir, prefix = prefix) + diff --git a/EcalTiming/python/presentation-plots.py b/EcalTiming/python/presentation-plots.py index 3ac5b42..b8cc7cb 100644 --- a/EcalTiming/python/presentation-plots.py +++ b/EcalTiming/python/presentation-plots.py @@ -1,6 +1,6 @@ import ROOT -from CalibCalorimetry.EcalTiming.PlotUtils import customROOTstyle, drawMultipleGrid -import CalibCalorimetry.EcalTiming.TokenRing as TokenRing +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, drawMultipleGrid +import EcalTiming.EcalTiming.TokenRing as TokenRing import math def drawMultipleGrid(hists,outname,limits=[],setLogY=False,setLogZ=False,ncols = 3): diff --git a/EcalTiming/python/readTimeConstants.C b/EcalTiming/python/readTimeConstants.C deleted file mode 100644 index 63db837..0000000 --- a/EcalTiming/python/readTimeConstants.C +++ /dev/null @@ -1,100 +0,0 @@ -#include "Riostream" -#include "TFile" -#include "TProfile2D" -#include "TH2F" - -void readTimeConstants() - { - - // read basic.dat file - // file has 5 coulumns of data - // but we want to read only first 4 collumns - - TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName()); - dir.ReplaceAll("readTimeConstants.C",""); - dir.ReplaceAll("/./","/"); - ifstream in; - //in.open(Form("%sbasic.dat",dir.Data())); - in.open(Form("dumpConstants-0.dat",dir.Data())); - - int x; - int y; - int z; - Float_t t, id; - Int_t nlines = 0; - - TFile *f = new TFile("TimeCalibs.root","RECREATE"); - TH2F* calibMapEB = new TH2F("calibMapEB","Mean Time map EB [ns];i#phi;i#eta",360,1.,361.,171,-85,86); - calibMapEB->Sumw2(); - TH2F* calibMapEEM = new TH2F("calibMapEEM","Mean Time map EE-; ix; iy",100,1,101,100,1,101); - calibMapEEM->Sumw2(); - TH2F* calibMapEEP = new TH2F("calibMapEEP","Mean Time map EE+ ;ix;iy",100,1,101,100,1,101); - calibMapEEP->Sumw2(); - - //while (!in.eof()) { - while (1) { - in >> x >> y >> z >> t >> id ; - if (!in.good()) break; - // if (nlines < 5) printf("x=%3i, y=%3i, z=%1i\n, t=%8f\n",x,y,z,t);continue; - if(z == 0) { - calibMapEB->Fill(y,x,t); - //printf("x=%3i, y=%3i, z=%1i\n, t=%8f\n",x,y,z,t); - } - else{ - if( z < 1) { calibMapEEM->Fill(x,y, t);} - else{ calibMapEEP->Fill(x,y,t);} - } - nlines++; - - } - - - printf(" found %d points\n",nlines); - in.close(); - - -//Move empty bins out of the way -- EB - int nxbins = calibMapEB->GetNbinsX(); - int nybins = calibMapEB->GetNbinsY(); - for (int p=1;p<=nxbins;++p) - { - for (int q=1;q<=nybins;++q) - { - double binentsM = calibMapEB->GetBinContent(p,q); - if(binentsM==0) - { - calibMapEB->SetBinContent(p,q,-1000); - } - } - } - - //Move empty bins out of the way -- EE - nxbins = calibMapEEM->GetNbinsX(); - nybins = calibMapEEM->GetNbinsY(); - for (int n=1;n<=nxbins;++n) - { - for (int m=1;m<=nybins;++m) - { - double binentsM = calibMapEEM->GetBinContent(n,m); - if(binentsM==0) - { - calibMapEEM->SetBinContent(n,m,-1000); - } - double binentsP = calibMapEEP->GetBinContent(n,m); - if(binentsP==0) - { - calibMapEEP->SetBinContent(n,m,-1000); - } - } - } - -int min = -10; - -int max = 10; - -calibMapEB->GetZaxis()->SetRangeUser(min, max); // ... set the range ... -calibMapEEM->GetZaxis()->SetRangeUser(min, max); // ... set the range ... -calibMapEEP->GetZaxis()->SetRangeUser(min, max); // ... set the range ... - f->Write(); - - } diff --git a/EcalTiming/python/shift_txt.py b/EcalTiming/python/shift_txt.py new file mode 100644 index 0000000..4ce5465 --- /dev/null +++ b/EcalTiming/python/shift_txt.py @@ -0,0 +1,66 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, customPalette +import os + + +def addFitToPlot(h): + c = ROOT.TCanvas("c","c",800,500) + c.SetLogy() + fit = ROOT.TF1("gaus","gaus") + h.Fit(fit, "Q") + mu = fit.GetParameter(1) + sigma = fit.GetParameter(2) + label = ROOT.TPaveText(.7, .7, .9, .9, "NDC") + label.AddText("#mu = %.3f" % mu) + label.AddText("#sigma = %.3f" % sigma) + label.Draw() + c.SaveAs(h.GetName() + ".png") + return mu,sigma + +def shiftCalib(input): + + #input = "/afs/cern.ch/user/p/phansen/public/ecal-timing/dump_EcalTimeCalibConstants_v07_offline__since_00204623_till_4294967295.dat" + customROOTstyle() + + hists = dict() + for iz in [0,-1,1]: + hists[iz] = ROOT.TH1F("time_{iz}".format(iz=iz),"time",100,-10,10) + + with open(input,'r') as f: + for line in f: + line = line.split() + time = float(line[3]) + iz = int(line[2]) + hists[iz].Fill(time) + + offset = dict() + for iz in hists: + offset[iz],__ = addFitToPlot(hists[iz]) + + print offset + + #output = os.path.splitext(input)[0] + "-GlobalOffset.txt" + output = input.replace("ecalTiming","ecalTimeRelative") + global_out = input.replace("ecalTiming","ecalTimeGlobal") + with open(input,'r') as f: + with open(output,'w') as of: + for line in f: + line = line.split() + start = line[:3] + end = line[4:] + time = float(line[3]) + iz = int(line[2]) + + out = "\t".join(start + ["%.3f" %(time - offset[iz])] + end) + '\n' + of.write(out) + with open(global_out, 'w') as f: + for iz in offset: + f.write("%d\t%.3f\n" % (iz, offset[iz])) + +if __name__ == "__main__": + filename = "/afs/cern.ch/work/p/phansen/public/EcalTiming/round1/AlCaPhiSym-251252/ecalTiming-251252-0_numEvent5000000-corr.dat" + calib = shiftCalib(filename); + filename = "/afs/cern.ch/work/p/phansen/public/EcalTiming/round1/AlCaPhiSym-251562/ecalTiming-251562-0_numEvent5000000-corr.dat" + calib = shiftCalib(filename); + + diff --git a/EcalTiming/python/singleCrystalPlot.py b/EcalTiming/python/singleCrystalPlot.py new file mode 100644 index 0000000..c5196c9 --- /dev/null +++ b/EcalTiming/python/singleCrystalPlot.py @@ -0,0 +1,108 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle, customPalette +import math + +import os +import sys +import errno +import shutil + +flag_dict = { + "high_skew" :"0x01", + "unstable_en":"0x02", + "ccu_oot" :"0x04", + "ring" :"0x08", + "crys" :"0x10", + } + +flag_dict_int = { + "high_skew" :0x01, + "unstable_en":0x02, + "ccu_oot" :0x04, + "ring" :0x08, + "crys" :0x10, + } + +def getStatus(flag): + flag_value = flag_dict[flag] + return "( (status & " + flag_value + ") == " + flag_value + ")" + +def char2int(x, signed = False): + if type(x) == type("s"): + xout = ord(x) + if signed and xout >= 255: + xout -= 256 + else: + xout = x + return xout + +def makeCrystalHists(flag,id): + name = flag + "_" + str(id) + "_" + title = flag + " " + str(id) + " " + return [ ROOT.TH1F(name + "time", title + "Time", 200,-20,20), + ROOT.TH2F(name + "en_time", title + "Energy vs Time", 40, 0, 20, 200,-20,20), + ROOT.TProfile(name + "en_time_prof", title + "Time Profile", 40, 0, 20), + ] +def fillCrystalHists(hists,event): + hists[0].Fill(event.time) + hists[1].Fill(event.energy, event.time) + hists[2].Fill(event.energy, event.time) + +def singleCrystalDump(tree, outdir): + flags = ['high_skew', 'unstable_en','crys'] + + hists = dict() + print "Start of Tree Loop" + for event in tree: + iz = char2int(event.iz, signed=True) + status = char2int(event.status) + for flag in flags: + if status & flag_dict_int[flag]: + key = (flag, event.rawid) + if key not in hists: + hists[key] = makeCrystalHists(*key) + fillCrystalHists(hists[key], event) + + c = ROOT.TCanvas("c","c",1600,1200) + for h in hists.values(): + ROOT.gStyle.SetOptStat(220112210) + h[0].Draw() + c.SaveAs(outdir + "/" + h[0].GetName() + ".png") + ROOT.gStyle.SetOptStat(1110000) + h[1].Draw("colz") + h[2].Draw("same") + c.SaveAs(outdir + "/" + h[1].GetName() + ".png") + + print "End of Tree Loop" + + +if __name__ == "__main__": + + customROOTstyle() + ROOT.gROOT.SetBatch(True) + ROOT.gStyle.SetOptStat(1) + print sys.argv + filename = sys.argv[1] + prefix = sys.argv[2] + + dir, basename = os.path.split(filename) + dir = dir.split('/') + print dir[-1:] + outdir = '/'.join(dir[:-1]) + "/plots/single-crystal/" + dir[-1] + outdir = os.path.normpath(outdir) + + def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + + mkdir_p(outdir) + shutil.copy("plots/index.php", outdir) + + file = ROOT.TFile.Open(filename) + tree = file.Get("filter/EcalSplashTiming/dumpTree") + singleCrystalDump(tree, outdir) + diff --git a/EcalTiming/python/splitElecID.py b/EcalTiming/python/splitElecID.py new file mode 100644 index 0000000..f512135 --- /dev/null +++ b/EcalTiming/python/splitElecID.py @@ -0,0 +1,20 @@ +import os +import sys +argc = len(sys.argv) +if argc < 3: + print "Usage: splitElecID.py input.txt output.txt" + sys.exit(-1) + +input = sys.argv[1] +output = sys.argv[2] + +with open(input, "r") as infile: + with open(output, "w") as outfile: + for line in infile: + if line[0] == "#": + outfile.write(line) + continue + line = line.split() + elecID = int(line[3]) + outfile.write("\t".join(line[:4] + [str(elecID >> 7), str(elecID & 0x7F)] + line[4:]) + "\n") + diff --git a/EcalTiming/python/stabilityPlots.py b/EcalTiming/python/stabilityPlots.py new file mode 100644 index 0000000..f8c0956 --- /dev/null +++ b/EcalTiming/python/stabilityPlots.py @@ -0,0 +1,137 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle + +import sys + +def float2name(x): + return ("%.1f" % x).replace('.','_') + +customROOTstyle() +ROOT.gROOT.SetBatch(True) +filename = sys.argv[1] +outdir = "plots" +if len(sys.argv) > 2: + outdir = sys.argv[2] + +file = ROOT.TFile.Open(filename) + + +tree = file.Get("TriggerResults/EcalSplashTiming_0/energyStabilityTree") +c = ROOT.TCanvas() + +#print "Finding list of cuts" +#cuts = list(set([event.min_energy for event in tree])) +#cuts.sort() + +cuts = [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0] +cuts = [0.5, 1.0, 1.5, ] +print "Cuts are",cuts + +print "Finding max occupancy/energy" +#max_num = max([event.num for event in tree]) +#max_energy = max([event.energy for event in tree]) +max_num = 38341 +max_energy = 68.5 +print max_num,max_energy + +def getBins(detector): + if detector == "EB": + iz = 0 + bins = "(360,1,361,171,-85,86)" + elif detector == "EEM": + iz = -1 + bins = "(100,1,101,100,1,101)" + elif detector == "EEP": + iz = 1 + bins = "(100,1,101,100,1,101)" + return bins,iz + +def makeTimePlots(detector,cut,tree,canvas): + cut_str = float2name(cut) + old_cut_str = float2name(cuts[i-1]) + + canvas.SetLogz(False) + name = detector + "_time_" + cut_str + old_name = detector + "_time_" + old_cut_str + h = ROOT.gDirectory.FindObject(old_name) + hold = None + if h: + hold = h.Clone(old_name) + + bins,iz = getBins(detector) + + tree.Draw("ix:iy>>" + name + bins,"(iz==%d && min_energy == %.1f)*time" %(iz,cut),"colz") + h = ROOT.gDirectory.FindObject(name) + #h.GetZaxis().SetRangeUser(-10,10) + h.SetTitle(detector + " Timing with E > %.1f" % cut) + c.SaveAs(outdir + "/" + name + ".png") + + if hold: + hold.Add(h,-1) + hold.Scale(-1) + hold.SetTitle(detector + " Diff (E > %.1f) - (E > %.1f) " % (cut,cuts[i-1])) + hold.GetZaxis().UnZoom() + hold.Draw("colz") + c.SaveAs(outdir + "/" + name + "_rel" + ".png") + +def makeNumPlots(detector,cut,max_num,tree,canvas): + cut_str = float2name(cut) + + canvas.SetLogz(True) + + name = detector + "_occupancy" + bins,iz = getBins(detector) + + tree.Draw("ix:iy>>" + name + bins,"(iz==%d && min_energy == %.1f)*num" %(iz,cut),"colz") + h = ROOT.gDirectory.FindObject(name) + h.GetZaxis().SetRangeUser(0,max_num) + h.SetTitle(detector + " Occupancy with E > %.1f" % cut) + c.SaveAs(outdir + "/" + name + "_" + cut_str + ".png") + + +c = ROOT.TCanvas() +for i,cut in enumerate(cuts): + print "Doing cut", cut + cut_str = float2name(cut) + + makeTimePlots("EB",cut,tree,c) + makeTimePlots("EEM",cut,tree,c) + makeTimePlots("EEP",cut,tree,c) + + c.SetLogz(True) + tree.Draw("ix:iy>>EB_num(360,1,361,171,-85,86)","(iz==0 && min_energy == %.1f)*num" %cut,"colz") + h = ROOT.gDirectory.FindObject("EB_num") + h.GetZaxis().SetRangeUser(0,max_num) + h.SetTitle("Occupancy with E > %.1f" % cut) + c.SaveAs(outdir + "/EB_occupancy_" + cut_str + ".png") + + tree.Draw("ix:iy>>EEM_num(100,1,101,100,1,101)","(iz==-1 && min_energy == %.1f)*num" %cut,"colz") + h = ROOT.gDirectory.FindObject("EEM_num") + h.GetZaxis().SetRangeUser(0,max_num) + h.SetTitle("Occupancy with E > %.1f" % cut) + c.SaveAs(outdir + "/EEM_occupancy_" + cut_str + ".png") + + tree.Draw("ix:iy>>EEP_num(100,1,101,100,1,101)","(iz==-1 && min_energy == %.1f)*num" %cut,"colz") + h = ROOT.gDirectory.FindObject("EEP_num") + h.GetZaxis().SetRangeUser(0,max_num) + h.SetTitle("Occupancy with E > %.1f" % cut) + c.SaveAs(outdir + "/EEP_occupancy_" + cut_str + ".png") + + tree.Draw("ix:iy>>EB_energy(360,1,361,171,-85,86)","(iz==0 && min_energy == %.1f)*energy" %cut,"colz") + h = ROOT.gDirectory.FindObject("EB_energy") + h.GetZaxis().SetRangeUser(0,max_energy) + h.SetTitle("Energy with E > %.1f" % cut) + c.SaveAs(outdir + "/EB_energy_" + cut_str + ".png") + + tree.Draw("ix:iy>>EEM_energy(100,1,101,100,1,101)","(iz==-1 && min_energy == %.1f)*energy" %cut,"colz") + h = ROOT.gDirectory.FindObject("EEM_energy") + h.GetZaxis().SetRangeUser(0,max_energy) + h.SetTitle("Energy with E > %.1f" % cut) + c.SaveAs(outdir + "/EEM_energy_" + cut_str + ".png") + + tree.Draw("ix:iy>>EEP_energy(100,1,101,100,1,101)","(iz==-1 && min_energy == %.1f)*energy" %cut,"colz") + h = ROOT.gDirectory.FindObject("EEP_energy") + h.GetZaxis().SetRangeUser(0,max_energy) + h.SetTitle("Energy with E > %.1f" % cut) + c.SaveAs(outdir + "/EEP_energy_" + cut_str + ".png") + diff --git a/EcalTiming/python/stabilityPlotsSlow.py b/EcalTiming/python/stabilityPlotsSlow.py new file mode 100644 index 0000000..c96b520 --- /dev/null +++ b/EcalTiming/python/stabilityPlotsSlow.py @@ -0,0 +1,244 @@ +import ROOT +from EcalTiming.EcalTiming.PlotUtils import customROOTstyle,customPalette + +import os,sys,errno,shutil + +customROOTstyle() +ROOT.gROOT.SetBatch(True) +filename = sys.argv[1] + +detectors = {-1:"EEM", 0:"EB", 1:"EEP"} + +dir, basename = os.path.split(filename) +dir = dir.split('/') +print dir[-1:] +outdir = '/'.join(dir[:-1]) + "/plots/" + dir[-1] +outdir = os.path.normpath(outdir) + +from EcalTiming.EcalTiming.loadOldCalib import getCalib +oldCalib = getCalib() + +outdir = os.path.join(outdir, 'stability') +outdir_backup = os.path.join(outdir, 'backup') + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: raise + +mkdir_p(outdir) +mkdir_p(outdir_backup) +shutil.copy("plots/index.php",outdir) +shutil.copy("plots/index.php",outdir_backup) + + + +file = ROOT.TFile.Open(filename) + +def float2name(x): + return ("%.1f" % x).replace('.','_') + +def initMap(name,title,iz): + if iz == 0: + return ROOT.TProfile2D("EB_" + name,title,360,1,361,171,-85,86) + elif iz == -1: + return ROOT.TProfile2D("EEM_" + name,title,100,1,101,100,1,101) + elif iz == 1: + return ROOT.TProfile2D("EEP_" + name,title,100,1,101,100,1,101) + else: + print "bad iz value",iz + return None + +def inittime1d(name,title,iz): + if iz == 0: + det = "EB_" + elif iz == -1: + det = "EEM_" + elif iz == 1: + det = "EEP_" + else: + print "bad iz value",iz + return None + return ROOT.TH1F(det + name,title,50,-10,10) + +def initiRing(name,title,iz): + if iz == 0: + return ROOT.TProfile("EB_" + name,title,171,-85,86) + elif iz == -1: + return ROOT.TProfile("EEM_" + name,title,39,0,39) + elif iz == 1: + return ROOT.TProfile("EEP_" + name,title,39,0,39) + else: + print "bad iz value",iz + return None + +def initHists(hist_dict,init_func,key, name, title): + if key in hist_dict: + return + cut,iz = key + hist_dict[key] = init_func(name,title,iz) + +tree = file.Get("filter/EcalSplashTiming/energyStabilityTree") +c = ROOT.TCanvas("c","c",1600,900) +# dictionaries to store histograms +time = dict() +occupancy = dict() +energy = dict() +iRing = dict() +time1d = dict() +counter = 0 + +def addFitToPlot(h): + fit = ROOT.TF1("gaus","gaus") + h.Fit(fit, "Q") + mu = fit.GetParameter(1) + sigma = fit.GetParameter(2) + label = ROOT.TPaveText(.5, .7, .9, .9, "NDC") + label.AddText("#mu = %.3f" % mu) + label.AddText("#sigma = %.3f" % sigma) + label.Draw() + return mu,sigma + +offset = dict() +for iz in detectors: + tree.Draw("time>>temp%d(50,-5,5)" % iz,"iz == %d && num != 0" % iz) + h = ROOT.gDirectory.FindObject("temp%d" % iz) + offset[iz],__ = addFitToPlot(h) + c.SaveAs(outdir + '/' + detectors[iz] + "_1d_nooffset.png") + +print "Found",tree.GetEntries(),"entries" +if tree.GetEntries() == 0: sys.exit(-1) +for event in tree: + if not counter % (tree.GetEntries()/10): print counter, '/', tree.GetEntries() + counter += 1 + if event.num == 0: continue + # make dictionary key + index = ord(event.index) + cut_str = str(index) + iz = ord(event.iz) + if iz == 255: iz = -1 + key = (index,iz) + # initialize histograms (if they haven't been made yet + initHists(time, initMap, key, "time_" + cut_str, "Timing: step" + cut_str) + initHists(occupancy, initMap, key, "occupancy_" + cut_str, "Occupancy: step" + cut_str) + initHists(energy, initMap, key, "energy_" + cut_str, "Energy: step" + cut_str) + + initHists(iRing, initiRing, key, "iRing_" + cut_str, "iRing: step" + cut_str) + initHists(time1d, inittime1d, key, "time1d_" + cut_str, "time1d: step" + cut_str) + + # fill histograms + if iz == 0: + x = event.iy + y = event.ix + else: + x = event.ix + y = event.iy + + t = event.time - offset[iz] + + time[key].Fill(x, y, t) + occupancy[key].Fill(x, y, event.num) + energy[key].Fill(x, y, event.energy) + + iRing[key].Fill(float(event.iRing), t) + time1d[key].Fill(t) + #if event.rawid in oldCalib: + # t += oldCalib[event.rawid] + #else: + # print "Rawid not found", event.rawid + +for key in time: + time[key].SetZTitle("[ns]") + time[key].SetAxisRange(-10,10,"Z") + time[key].Draw("colz") + c.SaveAs(outdir_backup + "/" + time[key].GetName() + ".10.png") + time[key].SetAxisRange(-5,5,"Z") + time[key].Draw("colz") + c.SaveAs(outdir_backup + "/" + time[key].GetName() + ".5.png") + time[key].SetAxisRange(-2,2,"Z") + time[key].Draw("colz") + c.SaveAs(outdir_backup + "/" + time[key].GetName() + ".2.png") + +c.SetLogz(True) +occu_max = max( [ occupancy[key].GetMaximum() for key in occupancy]) +for key in occupancy: + occupancy[key].SetAxisRange(0,occu_max,"Z") + occupancy[key].SetZTitle("Events") + occupancy[key].Draw("colz") + c.SaveAs(outdir_backup + "/" + occupancy[key].GetName() + ".png") + +c.SetLogz(False) +en_max = max( [ energy[key].GetMaximum() for key in energy]) +en_max = 5.0 +for key in energy: + energy[key].Draw("colz") + energy[key].SetAxisRange(0,en_max,"Z") + energy[key].SetZTitle("[GeV]") + c.SaveAs(outdir_backup + "/" + energy[key].GetName() + ".png") + +colors = [ROOT.kBlack,ROOT.kRed,ROOT.kGreen,ROOT.kBlue,ROOT.kMagenta,ROOT.kGray] +markers = [ROOT.kFullCircle, ROOT.kFullSquare] + +ROOT.gStyle.SetHistLineWidth(1); +for iz in [-1,0,1]: + keys = sorted([ (cut,iz) for cut,i in time if i == iz]) + if not keys: continue + ic = 0 + leg = ROOT.TLegend(0.15 ,0.15, 0.48, 0.35) + leg.SetNColumns(3) + leg.SetHeader("Mean time in iRing") + mg = ROOT.TMultiGraph() + for i in range(1,len(keys)): + iRing_rel = initiRing("iRing_rel_%d_%d" % (i, i-1), "iRing Diff Step%d - Step%d" % (i, i-1), keys[i][1]) + iRing_rel.Add(iRing[keys[i]],iRing[keys[i-1]], 1, -1) + + graph = ROOT.TGraphErrors(iRing_rel) + graph.SetLineColor(colors[ic % len(colors)]) + graph.SetMarkerColor(colors[ic % len(colors)]) + graph.SetMarkerSize(1) + graph.SetMarkerStyle(markers[(ic / len(colors)) % len(markers)]) + leg.AddEntry(graph,"Step %d - %d" % (i,i-1), "ple") + ic+=1 + mg.Add(graph) + + mg.Draw("ALP") + leg.Draw() + c.SaveAs(outdir + "/" + iRing[keys[0]].GetName() + ".png") + +for key in time1d: + time1d[key].Draw() + c.SaveAs(os.path.join(outdir, time1d[key].GetName() + ".png")) + +for iz in [-1,0,1]: + keys = sorted([ (cut,iz) for cut,i in time if i == iz]) + if not keys: continue + for i in range(1,len(keys)): + c.SetLogz(False) + customPalette() + hrel = initMap("time_rel_%d_%d" % (i, i-1), "Time Diff Step%d - Step%d" % (i, i-1), keys[i][1]) + h1 = time[keys[i]] + h0 = time[keys[i-1]] + hrel.Add(h1,h0,1,-1) + hrel.SetAxisRange(-.2,.2,"Z") + hrel.Draw("colz") + c.SaveAs(outdir + "/" + hrel.GetName() + ".png") + + if i != 1: + hrel0 = initMap("time_rel_%d_%d" % (i, 0), "Time Diff Step%d - Step%d" % (i, 0), keys[i][1]) + hrel0.SetAxisRange(-.2,.2,"Z") + hrel0.Add(time[keys[i]],time[keys[0]],1,-1) + hrel0.Draw("colz") + c.SaveAs(outdir + "/" + hrel0.GetName() + ".png") + + c.SetLogz(True) + ROOT.gStyle.SetPalette(55) + hnum = occupancy[keys[i]] + hnumold = occupancy[keys[i-1]] + hnumold.Add(hnum,-1) + hnumold.SetTitle(detectors[iz] + " Num Diff Step%d - Step%d" % (keys[i][0],keys[i-1][0])) + hnumold.SetAxisRange(0,hnumold.GetBinContent(hnumold.GetMaximumBin()),"Z") + hnumold.Draw("colz") + c.SaveAs(outdir_backup + "/" + hnum.GetName() + "_" + str(keys[i-1][0]) + "_rel.png") diff --git a/EcalTiming/python/tree2txt.py b/EcalTiming/python/tree2txt.py new file mode 100644 index 0000000..bb95234 --- /dev/null +++ b/EcalTiming/python/tree2txt.py @@ -0,0 +1,75 @@ +import ROOT +import numpy as np + +import sys + +#Mapping ROOT types to appropriate python types +int_types = [ "Char_t", "UChar_t","Short_t","UShort_t","Int_t","UInt_t","Long64_t","ULong64_t", "Bool_t"] +float_types = [ "Float_t","Double_t" ] + + +def tree2txt(tree,filter = []): + counter = 0 +#Get Tree Info + nevents = tree.GetEntries() + if filter: + branches = [ tree.GetBranch(name) for name in filter] + else: + branches = [ b for b in tree.GetListOfBranches()] + columns = dict() + branch_type = dict() + branch_format = dict() + for b in branches: + branch_type[b] = b.GetListOfLeaves().At(0).GetTypeName() + + if branch_type[b] in int_types: + b_type = int + format = "%d" + elif branch_type[b] in float_types: + b_type = float + format = "%.3f" + else: + b_type = type(None) + format = "" + + columns[b] = np.zeros(nevents, dtype=b_type) + branch_format[b] = format + +#Read tree + for event in tree: + for b in branches: + value = event.__getattr__(b.GetName()) + + #some code to deal with how root gives us chars + if(branch_type[b] == "UChar_t"): + value = ord(value) + elif(branch_type[b] == "Char_t"): + value = ord(value) + if value > 127: + value -= 256 + + columns[b][counter] = value + + counter += 1 + if counter >= nevents: break + +#dump tree + print '\t'.join( [b.GetName() for b in branches] ) + for i in range(nevents): + print '\t'.join([ branch_format[b] % columns[b][i] for b in branches]) + +if __name__ == "__main__": + #Parse Arguments + argc = len(sys.argv) + if argc < 3: + print "Usage: tree2txt.py input.root path/to/TTree" + sys.exit(-1) + + filename = sys.argv[1] + tree_path = sys.argv[2] + + file = ROOT.TFile.Open(filename) + tree = file.Get(tree_path) + tree2txt(tree) + + diff --git a/EcalTiming/python/txt2tree.py b/EcalTiming/python/txt2tree.py new file mode 100644 index 0000000..65429fe --- /dev/null +++ b/EcalTiming/python/txt2tree.py @@ -0,0 +1,67 @@ +import ROOT +import array + +import sys + +type_map = { + "B": "i", + "b": "i", + "S": "i", + "s": "i", + "I": "i", + "i": "i", + "F": "f", + "D": "f", + "L": "i", + "l": "i", + "O": "i", +} + +def txt2tree(input,tree,format): + types = [a.split(':') for a in format.split(',')] + ncolumns = len(types) + data = [[]]*ncolumns + for i in range(ncolumns): + name,t = types[i] + pytype = type_map[t] + data[i] = array.array(pytype,[0]) + tree.Branch(name,data[i],name + '/' + t) + + with open(input,'r') as f: + for line in f: + line = line.split() + for i in range(ncolumns): + name,t = types[i] + x = line[i] + if type_map[t] is 'i': + xtype = int + if type_map[t] is 'f': + xtype = float + data[i][0] = xtype(x) + tree.Fill() + print "Loaded tree with", tree.GetEntries() + print tree.Show(0) + print tree.Show(1) + print tree.Show(2) + + + +if __name__ == "__main__" : + #Parse Arguments + argc = len(sys.argv) + if argc < 4: + print "Usage: tree2txt.py " + print " = name1:type1,name2:type2" + print "ex: tree2txt.py input.txt output.root MyTree nevents:I,energy:F" + sys.exit(-1) + + input = sys.argv[1] + output = sys.argv[2] + tree_path = sys.argv[3] + format = sys.argv[4] + + tree = ROOT.TTree(tree_path,"Tree made from " + input) + txt2tree(input,tree,format) + file = ROOT.TFile.Open(output,"RECREATE") + tree.Write() + file.Write() diff --git a/EcalTiming/scripts/CheckDifference.csh b/EcalTiming/scripts/CheckDifference.csh deleted file mode 100755 index d8eb0da..0000000 --- a/EcalTiming/scripts/CheckDifference.csh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/tcsh -f -################################# - - -#Simple file to compare Seth's Numbers, with my own - -foreach dcc ( 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 ) - #CompareTimingFromFile ../EBavgOnly_ratios_3runsNormal_2chRemoved_FE_calibs/calibs_FE_dcc_$dcc.txt ../ForSeth/sm_6$dcc.txt myout_$dcc 0 1 - #CompareTimingFromFile ../calibs_ratioNormal_filteredFEAvg/calibs_FE_dcc_$dcc.txt ../ForSeth/sm_6$dcc.txt myout_$dcc 0 1 - #CompareTimingFromFile ../calibs_ratioNormal_filteredFEAvg/calibs_FE_dcc_$dcc.txt ../EBavgOnly_ratios_3runsNormal_2chRemoved_FE_calibs/calibs_FE_dcc_$dcc.txt myout_$dcc 1 1 - CompareTimingFromFile ../ForSeth/sm_6$dcc.txt ../EBcalibs_ratioNormal_filteredFEAvg_unweightedAvg/calibs_FE_dcc_$dcc.txt myout_$dcc 1 0 -end - -hadd -f FullOutJasonsToSethsAveraged.root myout*.root; -################################## -#end of file - diff --git a/EcalTiming/scripts/CheckEcalTiming.sh b/EcalTiming/scripts/CheckEcalTiming.sh deleted file mode 100755 index 93a7b45..0000000 --- a/EcalTiming/scripts/CheckEcalTiming.sh +++ /dev/null @@ -1,486 +0,0 @@ -#!/bin/bash - -#preferred_dir="/home/daq/" -preferred_dir=`pwd` -log_dir=$preferred_dir/log/ -conf_dir=$preferred_dir/conf/ -#cmssw_dir="/home/daq/DUMP/CMSSW_1_3_1/src" -cmssw_dir=`pwd` - -# in case you wanted to force execution inside the preferred_dir -#if [ "$PWD" != $preferred_dir ]; then -# -# echo "" -# echo "this script should be executed from $preferred_dir" -# echo "please do:" -# echo " cd $preferred_dir" -# echo "" -## exit -# -#fi - -mkdir -p $preferred_dir/log/ -mkdir -p $preferred_dir/conf/ -mkdir -p $preferred_dir/data/ - -if [ ! -n "$1" ] - -then - -echo "" -echo "This script produces timing plots for all SM's and all TT's and each crystal based on laser data." -echo "" -echo "Options:" -echo "" -echo " -p|--path_file file_path data file to be analyzed preceeded by path" -echo "" -echo " -f|--first_ev f_ev first (as written to file) event that will be analyzed; default is 1" -echo " -l|--last_ev l_ev last (as written to file) event that will be analyzed; default is 9999" -echo " -mfed|--mask_fed_id mask_fed_id list of FEDids to mask; default is no masking" -echo " -meb|--mask_ieb_id mask_ieb_id list of sm barrel ids to mask; default is no masking" -echo " -mcry|--mask_cry mask_cry list of channels (use hashedIndex) to mask; default is no masking" -echo " -t|--threshold threshold ADC count threshold for laser event to be considered good; default is 200.0" -echo " -n|--number number Minnimum number of events in crystal to be considered good" -echo " -files|--files_file files_file File with list of Runs" -echo " -st|--start_time start_time StartTime of run from Jan 1 1970 in s" -echo " -rl|--run_length run_length Length of Run in hours" -echo " -ff|--from_file from_file Read from an input file; default is false" -echo " -ffn|--from_file_name from_file_name Name of input file; default is empty" -echo " -dt|--data_type data_type Data Type of interest; default is Laser" -echo " -cet|--correct_ecal correct_ecal Correct For Ecal Readout Timing; default is false" -echo " -cbh|--correct_bh correct_bh Correct For BeamHalo Readout Timing; default is false" -echo " -bhp|--bh_plus bh_plus Is Direction of BeamHalo Plus; default is true" -echo " -ebr|--eb_radius eb_radius Correct EB radius in Readout Timing; default is 1.4(m)" -echo " -wf|--write_files write_files Write Output files (default is false)" -echo " -aa|--all_average all_average This is the input average number defaults to 5.7" -echo " -as|--all_shift all_shift This is the timing shift for all values default of 1.5" -echo " -dr|--do_ratios do_ratios Allows one to use the ratios for amplitude and time; default is False" -echo " -s09|--splash_09 splash_09 Allows one apply the Splash09 corrections; default is False" -echo " -tt|--timing_tree timing_tree Allows one to keep the timing tree; default is False" - -echo "" -echo "To specify multiple fed_id's/ieb_id's/cry's to mask use a comma-separated list in between double quotes, e.g., \"1,2,3\" " -exit - -fi - - -data_path="/data/ecalod-22/daq-data/" -data_file="none" - -cfg_path="$conf_dir" - - -mfed=-1 -mieb="-1" -mcry=-1 - -threshold=200.0 -number=5 - -start_time=1215192037 -run_length=2 - -first_event=1 -last_event=999999 - -from_file="False" -from_file_name="Emptyfile.root" - -correct_ecal="False" -correct_bh="False" -bh_plus="True" -write_files="False" -do_ratios="False" -splash_09="False" - -data_type="Laser" -eb_radius=1.4 -all_average=5.7 -all_shift=1.5 -timing_tree="False" - -manyfiles="0" - - while [ $# -gt 0 ]; do # while there are parameters available... - case "$1" in - - -p|--path_file) - data_path="$2" - ;; - - - -f|--first_ev) - first_event="$2" - ;; - - - -l|--last_ev) - last_event="$2" - ;; - - - -mfed|--mask_fed_id) - mfed=$2 - ;; - - -meb|--mask_ieb_id) - mieb=$2 - ;; - - -mcry|--mask_cry) - mcry=$2 - ;; - - -n|--number) - number=$2 - ;; - - -t|--threshold) - threshold=$2 - ;; - - -files|--files_file) - manyfiles="1" - files_file=$2 - ;; - - -st|--start_time) - start_time=$2 - ;; - - -rl|--run_length) - run_length=$2 - ;; - - -ff|--from_file) - from_file=$2 - ;; - - -ffn|--from_file_name) - from_file_name=$2 - ;; - - -dt|--data_type) - data_type=$2 - ;; - - -cet|--correct_ecal) - correct_ecal=$2 - ;; - - -cbh|--correct_bh) - correct_bh=$2 - ;; - - -ebr|--eb_radius) - eb_radius=$2 - ;; - - -bhp|--bh_plus) - bh_plus=$2 - ;; - - -dr|--do_ratios) - do_ratios=$2 - ;; - - -s09|--splash_09) - splash_09=$2 - ;; - - -wf|--write_files) - write_files=$2 - ;; - - -aa|--all_average) - all_average=$2 - ;; - - -as|--all_shift) - all_shift=$2 - ;; - -tt|--timing_tree) - timing_tree=$2 - ;; - - esac - shift # Verifica la serie successiva di parametri. - -done - -data_file=${data_path##*/} -extension=${data_file##*.} - -echo "" -echo "" -echo "data to be analyzed: $data_file" -echo "or data to be analyzed: $files_file" -echo "first event analyzed will be: $first_event" -first_event=$(($first_event-1)) - -echo "last event analyzed will be: $last_event" -echo "supermodules to mask: ${mieb} (-1 => no masking)" -echo "feds to mask: ${mfed} (-1 => no masking)" -echo "crys to mask: ${mcry} (-1 => no masking)" - -echo "amplitude threshold: $threshold" - -echo "number: $number" -echo "start time: $start_time" -echo "run length: $run_length (hours)" -echo "from_file: $from_file" -echo "from_file_name: $from_file_name" -echo "data_type: $data_type" -echo "correct for ecal readout: $correct_ecal" -echo "correct for beam halo: $correct_bh" -echo "Beam halo direction plus: $bh_plus" -echo "EB Radius: $eb_radius m" -echo "Writing txt files: $write_files" -echo "Overall Average Change: $all_average" -echo "All shift: $all_shift" -echo "Using Ratios: $do_ratios" -echo "Correction Splash09: $splash_09" -echo "Timing Tree: $timing_tree" -echo "" -echo "" - -if [[ $extension == "root" ]]; then - input_module=" -# if getting data from a .root pool file -process.source = cms.Source('PoolSource', - skipEvents = cms.untracked.uint32($first_event), - fileNames = cms.untracked.vstring('file:$data_path'), - debugFlag = cms.untracked.bool(True), - debugVebosity = cms.untracked.uint32(10) - )" -else - input_module=" - # if getting data from a .root pool file -process.source = cms.Source('NewEventStreamFileReader', - skipEvents = cms.untracked.uint32($first_event), - fileNames = cms.untracked.vstring('file:$data_path') - #debugFlag = cms.untracked.bool(True), - #debugVebosity = cms.untracked.uint32(10) - )" - -fi - -if [[ $manyfiles == "1" ]]; then - echo "doing many files" - input_module=" -process.source = cms.Source('PoolSource', - skipEvents = cms.untracked.uint32($first_event), - fileNames = cms.untracked.vstring(`/bin/cat $files_file`) - #debugFlag = cms.untracked.bool(True), - #debugVebosity = cms.untracked.uint32(10) - )" -fi - -path=" -process.p = cms.Path(process.gtDigis*process.ecalDigis*process.ecalDccDigis*process.uncalibHitMaker*process.ecalDetIdToBeRecovered*process.ecalRecHit*process.timing) -" - -if [[ $from_file == "True" ]]; then - echo "using an input file using the empty source" - input_module=" -process.source = cms.Source('EmptySource') - " - path=" -process.p = cms.Path(process.timing) - " -fi - -recomethod=" -process.uncalibHitMaker = cms.EDProducer('EcalUncalibRecHitProducer', - EEdigiCollection = cms.InputTag('ecalDccDigis','eeDigiSkim'), - betaEE = cms.double(1.37), - alphaEE = cms.double(1.63), - EBdigiCollection = cms.InputTag('ecalDccDigis','ebDigiSkim'), - EEhitCollection = cms.string('EcalUncalibRecHitsEE'), - AlphaBetaFilename = cms.untracked.string('NOFILE'), - betaEB = cms.double(1.7), - MinAmplEndcap = cms.double(14.0), - MinAmplBarrel = cms.double(8.0), - alphaEB = cms.double(1.2), - UseDynamicPedestal = cms.bool(True), - EBhitCollection = cms.string('EcalUncalibRecHitsEB'), - algo = cms.string('EcalUncalibRecHitWorkerFixedAlphaBetaFit') - ) - - -" -if [[ $do_ratios == "True" ]]; then - recomethod=" -process.uncalibHitMaker = cms.EDProducer('EcalUncalibRecHitProducer', - EBdigiCollection = cms.InputTag('ecalDccDigis','ebDigiSkim'), - EEdigiCollection = cms.InputTag('ecalDccDigis','eeDigiSkim'), - EBhitCollection = cms.string('EcalUncalibRecHitsEB'), - EEhitCollection = cms.string('EcalUncalibRecHitsEE'), - EBtimeFitParameters = cms.vdouble(-2.015452e+00, 3.130702e+00, -1.234730e+01, 4.188921e+01, -8.283944e+01, 9.101147e+01, -5.035761e+01, 1.105621e+01), - EEtimeFitParameters = cms.vdouble(-2.390548e+00, 3.553628e+00, -1.762341e+01, 6.767538e+01, -1.332130e+02, 1.407432e+02, -7.541106e+01, 1.620277e+01), - EBamplitudeFitParameters = cms.vdouble(1.138,1.652), - EEamplitudeFitParameters = cms.vdouble(1.890,1.400), - EBtimeFitLimits_Lower = cms.double(0.2), - EBtimeFitLimits_Upper = cms.double(1.4), - EEtimeFitLimits_Lower = cms.double(0.2), - EEtimeFitLimits_Upper = cms.double(1.4), - #outOfTimeThreshold = cms.double(0.25), - #amplitudeThresholdEB = cms.double(20 * 1), - #amplitudeThresholdEE = cms.double(20 * 1), - - #ebPulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - #eePulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - - algo = cms.string('EcalUncalibRecHitWorkerRatio') - ) -" -fi - -maxevnts=$(($last_event-$first_event)) - -cat > "$cfg_path$data_file".graph.$$.py <& "$log_dir$data_file".$$.graph - -echo "" -echo "" - -mv Timing*.root log/ -mv *Peak*txt data/ -echo "File root with graphs was created:" -ls -ltrFh $preferred_dir/log/Timing*.root | tail -1 | awk '{print $9}' - -echo "" -echo "" -echo "Now you can look at the plots..." -echo "" -echo "" - - - diff --git a/EcalTiming/scripts/CorrectManyXML.csh b/EcalTiming/scripts/CorrectManyXML.csh deleted file mode 100644 index f624151..0000000 --- a/EcalTiming/scripts/CorrectManyXML.csh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/tcsh -f - -set fed = 601 -set runnum = $1 -set proc = $2 -set type = $3 -echo "starting with fed" $fed -while ( $fed < 655 ) - echo "working on fed" $fed - #ProduceRelTimeOffsetFileCMSSWNew sm_${fed}.xml ../data/SM_${fed}_TTPeakPositionFile${type}_Run_${runnum}.${proc}.txt sm_${fed}_${runnum} - #ProduceRelTimeOffsetFileCMSSWNew sm_${fed}.xml ../data/SM_${fed}_TTPeakPositionFile${type}_Run${runnum}BeamShots.${proc}.txt sm_${fed}_${runnum} - ProduceRelTimeOffsetFileCMSSWNew sm_${fed}.xml ../data/SM_${fed}_TTPeakPositionFile${type}_BeamShots.${proc}.txt sm_${fed}_${runnum} - @ fed = $fed + 1 -end - - -#end of file diff --git a/EcalTiming/scripts/MakeEcalTimingCalibs.sh b/EcalTiming/scripts/MakeEcalTimingCalibs.sh deleted file mode 100755 index 0c3d6f4..0000000 --- a/EcalTiming/scripts/MakeEcalTimingCalibs.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Usage: Pass in your EcalTimingAnalysis-created root file (containing the TTree) -# and a name for the directory where the new calibrations will be created -# -# Example: ./makeCalibs.sh myTimingAnalysisRootFile.root newSplash2009TimingSettings - -# set up cmssw area -eval `scramv1 run -sh` - -# make and cd into the new directory -mkdir $2 -cd $2 - -# run binaries to make the raw crystal calibrations -echo "Creating raw crystal calibrations for EB..." -createTimingCalibsEB $1 -echo "Now creating raw crystal calibrations for EE..." -createTimingCalibsEE $1 - -# Make and run cfgs for creating HW settings and subtracting -# those from the raw crystal calibrations calculated above -# Must do subtractTowerAvgForOfflineCalibs = cms.untracked.bool(False) -# in the createAvgs module if we don't want to subtract the HW values -# Can do this for EB/EE at the same time now - -# Combine EB/EE calibs -cat timingCalibsEB.calibs.txt timingCalibsEE.calibs.txt > timingCalibsEcal.calibs.txt - -echo "Creating cfg and cmsRunning to make HW/SW settings..." - -cat > ecalcreateavgTTtimes_cfg.py < test/run-${RUN}.cfg < test/run-${RUN}.cfg < + +float EcalCrystalTimingCalibration::getNumWithinNSigma(float n_sigma, float maxRange) const +{ + + if(_numWithinNSigma.count(n_sigma) == 0) calcAllWithinNSigma(n_sigma, maxRange); + return _numWithinNSigma[n_sigma]; +} + +float EcalCrystalTimingCalibration::getMeanWithinNSigma(float n_sigma, float maxRange) const +{ + + if(_numWithinNSigma.count(n_sigma) == 0) calcAllWithinNSigma(n_sigma, maxRange); + return _sumWithinNSigma[n_sigma] / _numWithinNSigma[n_sigma]; +} + +float EcalCrystalTimingCalibration::getStdDevWithinNSigma(float n_sigma, float maxRange) const +{ + + float mean = getMeanWithinNSigma(n_sigma, maxRange); //variables are calculated by that + return sqrt(_sum2WithinNSigma[n_sigma] / _numWithinNSigma[n_sigma] - mean * mean); +} + +float EcalCrystalTimingCalibration::getMeanErrorWithinNSigma(float n_sigma, float maxRange) const +{ + + float stddev = getStdDevWithinNSigma(n_sigma, maxRange); //variables are calculated by that + return stddev / sqrt(_numWithinNSigma[n_sigma]); +} + +float EcalCrystalTimingCalibration::getSkewnessWithinNSigma(float n_sigma, float maxRange) const +{ + + float mean = getMeanWithinNSigma(n_sigma, maxRange); //variables are calculated by that + float stdDev = getStdDevWithinNSigma(n_sigma, maxRange); + return (_sum3WithinNSigma[n_sigma] / _numWithinNSigma[n_sigma] - 3 * mean * stdDev * stdDev - mean * mean * mean) / (stdDev * stdDev * stdDev); + +} + + +// store the results such that you do only one loop over the events +void EcalCrystalTimingCalibration::calcAllWithinNSigma(float n_sigma, float maxRange) const +{ + //std::cout << timingEvents.size() << ' ' << _storingEvents; + //std::cout << *this << std::endl; + //assert(timingEvents.size() != 0 || !_storingEvents); + assert(timingEvents.size() == num() || !_storingEvents); + + float range = std::min(maxRange, stdDev() * n_sigma); + + _sumWithinNSigma[n_sigma] = 0.; + _sum2WithinNSigma[n_sigma] = 0; + _sum3WithinNSigma[n_sigma] = 0.; + _numWithinNSigma[n_sigma] = 0.; + + if(!_storingEvents) + { + _sumWithinNSigma[n_sigma] = _sum; + _sum2WithinNSigma[n_sigma] = _sum2; + _sum3WithinNSigma[n_sigma] = 0; + _numWithinNSigma[n_sigma] = _num; + } + + for(auto te : timingEvents) { + if(fabs(te.time() - mean()) < range) { + _sumWithinNSigma[n_sigma] += te.time(); + _sum2WithinNSigma[n_sigma] += te.time() * te.time(); + _sum3WithinNSigma[n_sigma] += te.time() * te.time() * te.time(); + _numWithinNSigma[n_sigma]++; + } + } + return; +} + +bool EcalCrystalTimingCalibration::isStableInEnergy(float min, float max, float step, std::vector > &cutLevels) +{ + if(timingEvents.size() == 0) return true; + unsigned int nSteps = std::round((max - min) / step); + + assert(nSteps < 100); + assert(nSteps > 1); + + cutLevels.clear(); + float energy = min; + for(unsigned int index = 0; index < nSteps; ++index, energy += step) + cutLevels.push_back(std::pair(energy, new EcalCrystalTimingCalibration())); + + for(auto te : timingEvents) { + for(auto it : cutLevels) + { + if(te.energy() > it.first) { + it.second->add(te, false); + } + else break; + } + } + + for( auto it : cutLevels) { + float mean_ = it.second->mean(); + float meanError_ = it.second->meanError(); + + float orig_mean = mean(); + float orig_meanError = meanError(); + + if(it.second->num() < 30 ) break; // low statistics so move on. + if( meanError_ > 1.41 * orig_meanError) break; // does not make any sense to continue if the error is too high + + if(abs(orig_mean - mean_) > orig_meanError ) return false; /// \todo define a better criterium + // now requires only that the mean with higher energy threshold is within the calibration statistical uncertainty + } + return true; + +} + +void EcalCrystalTimingCalibration::dumpCalibToTree(TTree *tree, int rawid_, int ix_, int iy_, int iz_, unsigned int elecID_, int iRing_) const +{ + Float_t time; + Float_t timeError; + UInt_t n; + if(_storingEvents) + { + time = getMeanWithinNSigma(2,10); + timeError = getMeanErrorWithinNSigma(2,10); + n = getNumWithinNSigma(2,10); + } + else + { + time = mean(); + timeError = meanError(); + n = num(); + } + + Float_t energy(meanE()); + UInt_t rawid(rawid_); + Short_t ix(ix_); + UShort_t iy(iy_); + Char_t iz(iz_); + UShort_t elecID(elecID_); + Short_t iRing(iRing_); + + if(tree->GetBranch("rawid") == NULL) tree->Branch("rawid", &rawid, "rawid/i"); + else tree->SetBranchAddress("rawid", &rawid); + + if(tree->GetBranch("ix") == NULL) tree->Branch("ix", &ix, "ix/S"); + else tree->SetBranchAddress("ix", &ix); + + if(tree->GetBranch("iy") == NULL) tree->Branch("iy", &iy, "iy/s"); + else tree->SetBranchAddress("iy", &iy); + + if(tree->GetBranch("iz") == NULL) tree->Branch("iz", &iz, "iz/B"); + else tree->SetBranchAddress("iz", &iz); + + if(tree->GetBranch("time") == NULL) tree->Branch("time", &time, "time/F"); + else tree->SetBranchAddress("time", &time); + + if(tree->GetBranch("timeError") == NULL) tree->Branch("timeError", &timeError, "timeError/F"); + tree->SetBranchAddress("timeError", &timeError); + + if(tree->GetBranch("energy") == NULL) tree->Branch("energy", &energy, "energy/F"); + tree->SetBranchAddress("energy", &energy); + + if(tree->GetBranch("num") == NULL) tree->Branch("num", &n, "num/i"); + else tree->SetBranchAddress("num", &n); + + if(tree->GetBranch("elecID") == NULL) tree->Branch("elecID", &elecID, "elecID/s"); + else tree->SetBranchAddress("elecID", &elecID); + + if(tree->GetBranch("iRing") == NULL) tree->Branch("iRing", &iRing, "iRing/S"); + else tree->SetBranchAddress("iRing", &iRing); + + tree->Fill(); +} + +void EcalCrystalTimingCalibration::dumpToTree(TTree *tree, int ix_, int iy_, int iz_, unsigned int status_, unsigned int elecID_, int iRing_) +{ + //assert(tree->GetEntries() == 0); + Float_t time, timeError, energy; + UInt_t rawid; + + Short_t ix(ix_); + UShort_t iy(iy_); + Char_t iz(iz_); + UShort_t elecID(elecID_); + UChar_t status(status_); + Short_t iRing(iRing_); + + if(tree->GetBranch("rawid") == NULL) tree->Branch("rawid", &rawid, "rawid/i"); + else tree->SetBranchAddress("rawid", &rawid); + + if(tree->GetBranch("ix") == NULL) tree->Branch("ix", &ix, "ix/S"); + else tree->SetBranchAddress("ix", &ix); + + if(tree->GetBranch("iy") == NULL) tree->Branch("iy", &iy, "iy/s"); + else tree->SetBranchAddress("iy", &iy); + + if(tree->GetBranch("iz") == NULL) tree->Branch("iz", &iz, "iz/B"); + else tree->SetBranchAddress("iz", &iz); + + if(tree->GetBranch("time") == NULL) tree->Branch("time", &time, "time/F"); + else tree->SetBranchAddress("time", &time); + + if(tree->GetBranch("timeError") == NULL) tree->Branch("timeError", &timeError, "timeError/F"); + tree->SetBranchAddress("timeError", &timeError); + + if(tree->GetBranch("energy") == NULL) tree->Branch("energy", &energy, "energy/F"); + tree->SetBranchAddress("energy", &energy); + + if(tree->GetBranch("status") == NULL) tree->Branch("status", &status, "status/b"); + else tree->SetBranchAddress("status", &status); + + if(tree->GetBranch("elecID") == NULL) tree->Branch("elecID", &elecID, "elecID/s"); + else tree->SetBranchAddress("elecID", &elecID); + + if(tree->GetBranch("iRing") == NULL) tree->Branch("iRing", &iRing, "iRing/S"); + else tree->SetBranchAddress("iRing", &iRing); + + for(auto te : timingEvents) { + rawid = te.detid().rawId(); + time = te.time(); + energy = te.energy(); + timeError = te.timeError(); + tree->Fill(); + } +} + + +//added!!! +//void EcalCrystalTimingCalibration::dumpAllToTree(TTree *tree, int ix_, int iy_, int iz_, float time_, float energy_, float chiSquare_, float thrApplied_) +void dumpAllToTree(TTree *tree, int ix_, int iy_, int iz_, float time_, float energy_, float chiSquare_, float thrApplied_) +{ + //casting variables + Short_t ix(ix_); + UShort_t iy(iy_); + Short_t iz(iz_); + + if(tree->GetBranch("ix")==NULL) tree->Branch("ix", &ix, "ix/S"); + else tree->SetBranchAddress("ix", &ix); + + if(tree->GetBranch("iy")==NULL) tree->Branch("iy", &iy, "iy/s"); + else tree->SetBranchAddress("iy", &iy); + + if(tree->GetBranch("iz")==NULL) tree->Branch("iz", &iz, "iz/S"); + else tree->SetBranchAddress("iz", &iz); + + if(tree->GetBranch("time") == NULL) tree->Branch("time", &time_, "time/F"); + else tree->SetBranchAddress("time", &time_); + + if(tree->GetBranch("energy") == NULL) tree->Branch("energy", &energy_, "energy/F"); + tree->SetBranchAddress("energy", &energy_); + + if(tree->GetBranch("chi2") == NULL) tree->Branch("chi2", &chiSquare_, "chi2/F"); + tree->SetBranchAddress("chi2", &chiSquare_); + + if(tree->GetBranch("thr") == NULL) tree->Branch("thr", &thrApplied_, "thr/F"); + tree->SetBranchAddress("thr", &thrApplied_); + + + + tree->Fill(); + +} + + + + + + + + + + + diff --git a/EcalTiming/test/CRABTEMPLATE.cfg b/EcalTiming/test/CRABTEMPLATE.cfg deleted file mode 100644 index ef1e4a5..0000000 --- a/EcalTiming/test/CRABTEMPLATE.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[CRAB] - -jobtype = cmssw -scheduler = caf - -[CMSSW] - -datasetpath = DATASETPLACE -pset = ANALYTYPEConfig_RUNNUMBER.py - -### A single processed dataset can contain multiple runs (in the case of real data !!! ) -### following selection can narrow down the run selection within a single processed dataset -### selection can be a comma-separated list of run numbers and run number ranges: 1,2,3-4 -runselection=RUNNUMBER - -total_number_of_events = -1 -events_per_job = EVENTSPERJOB -output_file = ANALYTYPE_RUNNUMBER.root - -[USER] -return_data = 1 -use_central_bossDB = 0 -use_boss_rt = 0 - -[GRID] -rb = CERN -proxy_server = myproxy.cern.ch -virtual_organization = cms -retry_count = 0 -lcg_catalog_type = lfc -lfc_host = lfc-cms-test.cern.ch -lfc_home = /grid/cms - -[CAF] -queue=cmscaf1nd diff --git a/EcalTiming/test/CalibTEMPLATE.cfg b/EcalTiming/test/CalibTEMPLATE.cfg index 620ef52..f11e930 100644 --- a/EcalTiming/test/CalibTEMPLATE.cfg +++ b/EcalTiming/test/CalibTEMPLATE.cfg @@ -36,8 +36,8 @@ include "Geometry/CaloEventSetup/data/CaloGeometry.cff" include "Geometry/EcalMapping/data/EcalMapping.cfi" include "Geometry/EcalMapping/data/EcalMappingRecord.cfi" include "Geometry/CMSCommonData/data/cmsIdealGeometryXML.cfi" -include "CalibCalorimetry/EcalLaserCorrection/data/ecalLaserCorrectionService.cfi" -include "CalibCalorimetry/EcalTrivialCondModules/data/EcalTrivialCondRetriever.cfi" +include "EcalTiming/EcalLaserCorrection/data/ecalLaserCorrectionService.cfi" +include "EcalTiming/EcalTrivialCondModules/data/EcalTrivialCondRetriever.cfi" module ecalUncalibHit = ecalFixedAlphaBetaFitUncalibRecHit from "RecoLocalCalo/EcalRecProducers/data/ecalFixedAlphaBetaFitUncalibRecHit.cfi" replace ecalUncalibHit.EBdigiCollection = ecalEBunpacker:ebDigis diff --git a/EcalTiming/test/CalibTEMPLATE.py b/EcalTiming/test/CalibTEMPLATE.py index af79d9b..1408903 100644 --- a/EcalTiming/test/CalibTEMPLATE.py +++ b/EcalTiming/test/CalibTEMPLATE.py @@ -13,9 +13,9 @@ process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi") -process.load("CalibCalorimetry.EcalLaserCorrection.ecalLaserCorrectionService_cfi") +process.load("EcalTiming.EcalLaserCorrection.ecalLaserCorrectionService_cfi") -process.load("CalibCalorimetry.EcalTrivialCondModules.EcalTrivialCondRetriever_cfi") +process.load("EcalTiming.EcalTrivialCondModules.EcalTrivialCondRetriever_cfi") import RecoLocalCalo.EcalRecProducers.ecalFixedAlphaBetaFitUncalibRecHit_cfi process.ecalUncalibHit = RecoLocalCalo.EcalRecProducers.ecalFixedAlphaBetaFitUncalibRecHit_cfi.ecalFixedAlphaBetaFitUncalibRecHit.clone() diff --git a/EcalTiming/test/LaserTEMPLATE.cfg b/EcalTiming/test/LaserTEMPLATE.cfg deleted file mode 100644 index cf667c7..0000000 --- a/EcalTiming/test/LaserTEMPLATE.cfg +++ /dev/null @@ -1,136 +0,0 @@ - - -process ECALTIMING = { - -include "EventFilter/EcalRawToDigiDev/data/EcalUnpackerMapping.cfi" -include "EventFilter/EcalRawToDigiDev/data/EcalUnpackerData.cfi" - -#replace ecalEBunpacker.InputLabel="FEDCOLLECTION" - -include "Geometry/CaloEventSetup/data/CaloTopology.cfi" -include "Geometry/EcalCommonData/data/EcalOnly.cfi" -include "Geometry/CaloEventSetup/data/CaloGeometry.cff" - -untracked PSet maxEvents = {untracked int32 input = 999999 } - - - #source = NewEventStreamFileReader{ - source = PoolSource{ - untracked uint32 skipEvents = 0 - untracked vstring fileNames = { - '/store/data/Commissioning08/TestEnables/RAW/v1/000/064/735/8868E0F8-8594-DD11-9EC6-000423D98930.root', - '/store/data/Commissioning08/TestEnables/RAW/v1/000/064/735/9A01DEFD-8794-DD11-A1F5-001617E30F48.root', - '/store/data/Commissioning08/TestEnables/RAW/v1/000/064/735/C0427F8D-8694-DD11-8E98-001617DBCF1E.root' - } - untracked uint32 debugVebosity = 10 - untracked bool debugFlag = true - } - - -es_source src1 = EcalTrivialConditionRetriever{ - untracked vdouble amplWeights = { -0.333, -0.333, -0.333, - 0.000, 0.000, 1.000, - 0.000, 0.000, 0.000, 0.000 } - untracked vdouble pedWeights = { 0.333, 0.333, 0.333, - 0.000, 0.000, 0.000, - 0.000, 0.000, 0.000, 0.000 } - untracked vdouble jittWeights = { 0.040, 0.040, 0.040, - 0.000, 1.320, -0.050, - -0.500, -0.500, -0.400, 0.000 } - } - - -module uncalibHitMaker = EcalFixedAlphaBetaFitUncalibRecHitProducer{ - - InputTag EBdigiCollection = ecalDccDigis:ebDigiSkim - InputTag EEdigiCollection = ecalDccDigis:eeDigiSkim - #InputTag EBdigiCollection = ecalEBunpacker:ebDigis - #InputTag EEdigiCollection = ecalEBunpacker:eeDigis - string EBhitCollection = "EcalUncalibRecHitsEB" - string EEhitCollection = "EcalUncalibRecHitsEE" - double alphaEB = 1.2 - double betaEB = 1.7 - double alphaEE = 1.63 - double betaEE = 1.37 - double MinAmplBarrel = 8. - double MinAmplEndcap = 14. - bool UseDynamicPedestal = true - untracked string AlphaBetaFilename = "NOFILE" - - } - - module ecalDccDigis = EcalDccDigiSkimer { - InputTag DigiUnpacker = ecalEBunpacker - InputTag EBdigiCollection = ecalEBunpacker:ebDigis - InputTag EEdigiCollection = ecalEBunpacker:eeDigis - - string EBdigiCollectionOut = 'ebDigiSkim' - string EEdigiCollectionOut = 'eeDigiSkim' - - string DigiType = "Laser" -} - - module timing = EcalTimingAnalysis { - string digiProducer = "ecalEBunpacker" - string hitProducer = "uncalibHitMaker" - string hitProducerEE = "uncalibHitMaker" - string hitCollection = "EcalUncalibRecHitsEB" - string hitCollectionEE = "EcalUncalibRecHitsEE" - - untracked string rootfile = "Laser_RUNNUMBER.root" - untracked string TTPeakTime = "TTPeakPositionFileLaser.txt" - untracked string ChPeakTime = "ChPeakTimeLaser.txt" - untracked double amplThr = 25 - untracked double minNumEvt = 20 - untracked double RunStart = 1215192037 - untracked double RunLength = 2 - untracked bool FromFile = false - untracked string FromFileName = "Emptyfile.root" - untracked bool CorrectEcalReadout = false - untracked bool CorrectBH = false - untracked double EBRadius = 1.4 - untracked bool BeamHaloPlus = true - #untracked vdouble SMAverages = {5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.2177, 5.2282, 5.1461, 5.1395, 4.8314, 4.7773, 4.8276, 4.8607, 4.9925, 5.0648, 4.837, 4.7639, 5.2952, 5.2985, 4.8695, 4.8308, 4.9181, 4.8526, 4.7157, 4.7297, 5.1266, 5.1656, 4.8872, 4.8274, 5.3140, 5.3209, 5.0342, 5.0402, 5.0712, 4.9686, 5.4509, 5.3868, 5.3950, 5.2342, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00} - - # untracked vdouble SMAverages = {5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, - # 6.2177, 6.2282, 6.1271, 6.1205, 5.4004, 5.3463, 5.4356, 5.4687, 5.7965, -# 5.8688, 5.4250, 5.3519, 6.2762, 6.2795, 5.4385, 5.3998, 5.5411, 5.4756, -# 5.3387, 5.3527, 6.1076, 6.1466, 5.4364, 5.3764, 6.3260, 6.3329, 5.6572, -# 5.6632, 5.6202, 5.5176, 6.4509, 6.3868, 6.4070, 6.2462, 5.00, 5.00, -# 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00} - - -# Laser Averages - # untracked vdouble SMAverages = {5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, - # 5.3805, 5.4358, 5.377, 5.287, 4.96, 4.9758, 4.9893, 5.0638, 5.2273, -# 5.242, 4.9926, 4.9928, 5.5974, 5.4966, 5.1288, 5.127, 5.2627, 5.1177, -# 5.0262, 5.0702, 5.3998, 5.5244, 5.1255, 5.0881, 5.7494, 5.6323, 5.4287, -# 5.4655, 5.3829, 5.3226, 5.7801, 5.7548, 5.8181, 5.6015, 5.00, 5.00, -# 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00} -# - untracked vdouble SMAverages = {5.0703, 5.2278, 5.2355, 5.1548, 5.1586, 5.1912, 5.1576, 5.1625, 5.1269, - 5.643, 5.6891, 5.588, 5.5978, 5.6508, 5.6363, 5.5972, 5.6784, 5.6108, - 5.6866, 5.6523, 5.6666, 5.7454, 5.729, 5.7751, 5.7546, 5.7835, 5.7529, - 5.5691, 5.6677, 5.5662, 5.6308, 5.7097, 5.6773, 5.76, 5.8025, 5.9171, - 5.8771, 5.8926, 5.9011, 5.8447, 5.8142, 5.8475, 5.7123,5.6216, 5.6713, - 5.3747,5.3564, 5.39, 5.8081, 5.8081, 5.1818, 5.1125, 5.1334, 5.2581} - - untracked vdouble SMCorrections = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, - 0.2411, 0.2411, 0.2221, 0.2221, -0.1899, -0.1899, -0.1509, -0.1509, 0.0451, - 0.0451, -0.1709,-0.1709, 0.2221, 0.2221, -0.1899, -0.1899, -0.1359, -0.1359, - -0.1359, -0.1359, 0.2221, 0.2221, -0.2099, -0.2099, 0.2531, 0.2531, -0.1359, - -0.1359, -0.2099, -0.2099, 0.2411, 0.2411, 0.2531, 0.2531, -0.1709, -0.1709, - 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00} - - # -} - - - - -path p = {ecalEBunpacker, ecalDccDigis, uncalibHitMaker, timing} - - -} - - diff --git a/EcalTiming/test/LaserTEMPLATE.py b/EcalTiming/test/LaserTEMPLATE.py deleted file mode 100644 index 7a0cf01..0000000 --- a/EcalTiming/test/LaserTEMPLATE.py +++ /dev/null @@ -1,137 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("ECALTIMING") -process.load("EventFilter.EcalRawToDigiDev.EcalUnpackerMapping_cfi") - -process.load("EventFilter.EcalRawToDigiDev.EcalUnpackerData_cfi") - -process.load("Geometry.CaloEventSetup.CaloTopology_cfi") - -process.load("Geometry.EcalCommonData.EcalOnly_cfi") - -process.load("Geometry.CaloEventSetup.CaloGeometry_cff") - -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.load("Configuration.StandardSequences.MagneticField_cff") -process.load("Configuration.StandardSequences.Geometry_cff") -process.GlobalTag.globaltag = 'GR10_P_V4::All' - - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(999999) - ) -process.source = cms.Source("PoolSource", - #debugFlag = cms.untracked.bool(True), - #debugVebosity = cms.untracked.uint32(10), -# skipEvents = cms.untracked.uint32(1200000), - skipEvents = cms.untracked.uint32(0), - fileNames = cms.untracked.vstring('MYINPUTFILETYPE') - ) - -process.source.duplicateCheckMode = cms.untracked.string('noDuplicateCheck') - -#process.src1 = cms.ESSource("EcalTrivialConditionRetriever", -# jittWeights = cms.untracked.vdouble(0.04, 0.04, 0.04, 0.0, 1.32, -# -0.05, -0.5, -0.5, -0.4, 0.0), -# pedWeights = cms.untracked.vdouble(0.333, 0.333, 0.333, 0.0, 0.0, -# 0.0, 0.0, 0.0, 0.0, 0.0), -# amplWeights = cms.untracked.vdouble(-0.333, -0.333, -0.333, 0.0, 0.0, -# 1.0, 0.0, 0.0, 0.0, 0.0) -# ) - - -process.uncalibHitMaker = cms.EDProducer("EcalUncalibRecHitProducer", - EBdigiCollection = cms.InputTag("ecalDccDigis","ebDigiSkim"), - EEdigiCollection = cms.InputTag("ecalDccDigis","eeDigiSkim"), - EBhitCollection = cms.string("EcalUncalibRecHitsEB"), - EEhitCollection = cms.string('EcalUncalibRecHitsEE'), - EBtimeFitParameters = cms.vdouble(-2.015452e+00, 3.130702e+00, -1.234730e+01, 4.188921e+01, -8.283944e+01, 9.101147e+01, -5.035761e+01, 1.105621e+01), - EEtimeFitParameters = cms.vdouble(-2.390548e+00, 3.553628e+00, -1.762341e+01, 6.767538e+01, -1.332130e+02, 1.407432e+02, -7.541106e+01, 1.620277e+01), - EBamplitudeFitParameters = cms.vdouble(1.138,1.652), - EEamplitudeFitParameters = cms.vdouble(1.890,1.400), - EBtimeFitLimits_Lower = cms.double(0.2), - EBtimeFitLimits_Upper = cms.double(1.4), - EEtimeFitLimits_Lower = cms.double(0.2), - EEtimeFitLimits_Upper = cms.double(1.4), - - #outOfTimeThreshold = cms.double(0.25), - #amplitudeThresholdEB = cms.double(20 * 1), - #amplitudeThresholdEE = cms.double(20 * 1), - - #ebPulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - #eePulseShape = cms.vdouble( 5.2e-05,-5.26e-05 , 6.66e-05, 0.1168, 0.7575, 1., 0.8876, 0.6732, 0.4741, 0.3194 ), - algo = cms.string("EcalUncalibRecHitWorkerRatio") - ) - -# -#process.uncalibHitMaker = cms.EDProducer("EcalUncalibRecHitProducer", -# EEdigiCollection = cms.InputTag("ecalDccDigis","eeDigiSkim"), -# betaEE = cms.double(1.37), -# alphaEE = cms.double(1.63), -# EBdigiCollection = cms.InputTag("ecalDccDigis","ebDigiSkim"), -# EEhitCollection = cms.string('EcalUncalibRecHitsEE'), -# AlphaBetaFilename = cms.untracked.string('NOFILE'), -# betaEB = cms.double(1.7), -# MinAmplEndcap = cms.double(14.0), -# MinAmplBarrel = cms.double(8.0), -# alphaEB = cms.double(1.2), -# UseDynamicPedestal = cms.bool(True), -# EBhitCollection = cms.string('EcalUncalibRecHitsEB'), -# algo = cms.string("EcalUncalibRecHitWorkerFixedAlphaBetaFit") -# ) - -process.ecalDccDigis = cms.EDFilter("EcalDccDigiSkimer", - EEdigiCollectionOut = cms.string('eeDigiSkim'), - EEdigiCollection = cms.InputTag("ecalEBunpacker","eeDigis"), - EBdigiCollectionOut = cms.string('ebDigiSkim'), - EBdigiCollection = cms.InputTag("ecalEBunpacker","ebDigis"), - DigiUnpacker = cms.InputTag("ecalEBunpacker"), - DigiType = cms.string('Laser') - ) - -process.timing = cms.EDFilter("EcalTimingAnalysis", - rootfile = cms.untracked.string('Laser_RUNNUMBER.root'), - CorrectBH = cms.untracked.bool(False), - hitProducer = cms.string('uncalibHitMaker'), - minNumEvt = cms.untracked.double(20.0), - FromFileName = cms.untracked.string('Emptyfile.root'), - TTPeakTime = cms.untracked.string('TTPeakPositionFileLaser.txt'), - SMAverages = cms.untracked.vdouble(5.0703, 5.2278, 5.2355, 5.1548, 5.1586, - 5.1912, 5.1576, 5.1625, 5.1269, 5.643, - 5.6891, 5.588, 5.5978, 5.6508, 5.6363, - 5.5972, 5.6784, 5.6108, 5.6866, 5.6523, - 5.6666, 5.7454, 5.729, 5.7751, 5.7546, - 5.7835, 5.7529, 5.5691, 5.6677, 5.5662, - 5.6308, 5.7097, 5.6773, 5.76, 5.8025, - 5.9171, 5.8771, 5.8926, 5.9011, 5.8447, - 5.8142, 5.8475, 5.7123, 5.6216, 5.6713, - 5.3747, 5.3564, 5.39, 5.8081, 5.8081, - 5.1818, 5.1125, 5.1334, 5.2581), - hitProducerEE = cms.string('uncalibHitMaker'), - GTRecordCollection = cms.untracked.string('NO'), - amplThr = cms.untracked.double(25.0), - SMCorrections = cms.untracked.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.2411, - 0.2411, 0.2221, 0.2221, -0.1899, -0.1899, - -0.1509, -0.1509, 0.0451, 0.0451, -0.1709, - -0.1709, 0.2221, 0.2221, -0.1899, -0.1899, - -0.1359, -0.1359, -0.1359, -0.1359, 0.2221, - 0.2221, -0.2099, -0.2099, 0.2531, 0.2531, - -0.1359, -0.1359, -0.2099, -0.2099, 0.2411, - 0.2411, 0.2531, 0.2531, -0.1709, -0.1709, - 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0), - BeamHaloPlus = cms.untracked.bool(True), - hitCollectionEE = cms.string('EcalUncalibRecHitsEE'), - ChPeakTime = cms.untracked.string('ChPeakTimeLaser.txt'), - hitCollection = cms.string('EcalUncalibRecHitsEB'), - digiProducer = cms.string('ecalEBunpacker'), - CorrectEcalReadout = cms.untracked.bool(False), - FromFile = cms.untracked.bool(False), - RunStart = cms.untracked.double(1215192037.0), - RunLength = cms.untracked.double(2.0), - EBRadius = cms.untracked.double(1.4) - ) - -process.p = cms.Path(process.ecalEBunpacker*process.ecalDccDigis*process.uncalibHitMaker*process.timing) - diff --git a/EcalTiming/test/MergeAndMakePlots.csh b/EcalTiming/test/MergeAndMakePlots.csh deleted file mode 100755 index 85269a4..0000000 --- a/EcalTiming/test/MergeAndMakePlots.csh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/tcsh -f - -set runnum = $1 - -./mergeJason.sh -r $runnum -at Laser -./makeLaserPlots.sh -r $runnum -#./makeCalibPlots.sh -r $runnum - -echo "DONE" -#end of file diff --git a/EcalTiming/test/TimingTEMPLATE.py b/EcalTiming/test/TimingTEMPLATE.py deleted file mode 100644 index 642d6c5..0000000 --- a/EcalTiming/test/TimingTEMPLATE.py +++ /dev/null @@ -1,151 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -process = cms.Process("ECALTIMING") -process.load("EventFilter.EcalRawToDigiDev.EcalUnpackerMapping_cfi") - -process.load("EventFilter.EcalRawToDigiDev.EcalUnpackerData_cfi") - -process.load("Geometry.CaloEventSetup.CaloTopology_cfi") - -process.load("Geometry.EcalCommonData.EcalOnly_cfi") - -process.load("Geometry.CaloEventSetup.CaloGeometry_cff") - -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.load("Configuration.StandardSequences.MagneticField_cff") -process.load("Configuration.StandardSequences.Geometry_cff") -process.GlobalTag.globaltag = 'GR10_P_V4::All' - -process.load("L1TriggerConfig.L1GtConfigProducers.L1GtConfig_cff") -process.load("L1TriggerConfig.L1GtConfigProducers.Luminosity.startup.L1Menu_startup_v3_Unprescaled_cff") -process.load("L1TriggerConfig.L1GtConfigProducers.L1GtBoardMapsConfig_cff") -process.load("L1TriggerConfig.L1ScalesProducers.L1MuTriggerScalesConfig_cff") -process.load("L1TriggerConfig.L1ScalesProducers.L1MuTriggerPtScaleConfig_cff") -import FWCore.Modules.printContent_cfi -process.dumpEv = FWCore.Modules.printContent_cfi.printContent.clone() -import EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi -process.gtDigis = EventFilter.L1GlobalTriggerRawToDigi.l1GtUnpack_cfi.l1GtUnpack.clone() -process.gtDigis.DaqGtInputTag = 'source' - - - -# shaping our Message logger to suit our needs -process.MessageLogger = cms.Service("MessageLogger", - #suppressWarning = cms.untracked.vstring('ecalEBunpacker', 'ecalUncalibHit', 'ecalRecHit', 'ecalCosmicsHists'), - #suppressInfo = cms.untracked.vstring('ecalEBunpacker', 'ecalUncalibHit', 'ecalRecHit', 'ecalCosmicsHists'), - cout = cms.untracked.PSet(threshold = cms.untracked.string('ERROR')), - categories = cms.untracked.vstring('ecalDigis','ecalDccDigis','uncalibHitMaker','ecalDetIdToBeRecovered','ecalRecHit'), - destinations = cms.untracked.vstring('cout') -) - - - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(999999) - ) -process.source = cms.Source("PoolSource", - #debugFlag = cms.untracked.bool(True), - #debugVebosity = cms.untracked.uint32(10), - skipEvents = cms.untracked.uint32(0), - fileNames = cms.untracked.vstring('MYINPUTFILETYPE') - ) - -#process.src1 = cms.ESSource("EcalTrivialConditionRetriever", -# jittWeights = cms.untracked.vdouble(0.04, 0.04, 0.04, 0.0, 1.32, -# -0.05, -0.5, -0.5, -0.4, 0.0), -# pedWeights = cms.untracked.vdouble(0.333, 0.333, 0.333, 0.0, 0.0, -# 0.0, 0.0, 0.0, 0.0, 0.0), -# amplWeights = cms.untracked.vdouble(-0.333, -0.333, -0.333, 0.0, 0.0, -# 1.0, 0.0, 0.0, 0.0, 0.0) -# ) - -process.uncalibHitMaker = cms.EDProducer("EcalUncalibRecHitProducer", - EBdigiCollection = cms.InputTag("ecalDccDigis","ebDigiSkim"), - EEdigiCollection = cms.InputTag("ecalDccDigis","eeDigiSkim"), - EBhitCollection = cms.string("EcalUncalibRecHitsEB"), - EEhitCollection = cms.string('EcalUncalibRecHitsEE'), - EBtimeFitParameters = cms.vdouble(-2.015452e+00, 3.130702e+00, -1.234730e+01, 4.188921e+01, -8.283944e+01, 9.101147e+01, -5.035761e+01, 1.105621e+01), - EEtimeFitParameters = cms.vdouble(-2.390548e+00, 3.553628e+00, -1.762341e+01, 6.767538e+01, -1.332130e+02, 1.407432e+02, -7.541106e+01, 1.620277e+01), - EBamplitudeFitParameters = cms.vdouble(1.138,1.652), - EEamplitudeFitParameters = cms.vdouble(1.890,1.400), - EBtimeFitLimits_Lower = cms.double(0.2), - EBtimeFitLimits_Upper = cms.double(1.4), - EEtimeFitLimits_Lower = cms.double(0.2), - EEtimeFitLimits_Upper = cms.double(1.4), - algo = cms.string("EcalUncalibRecHitWorkerRatio") - ) - -process.ecalDccDigis = cms.EDFilter("EcalDccDigiSkimer", - EEdigiCollectionOut = cms.string('eeDigiSkim'), - EEdigiCollection = cms.InputTag("ecalDigis","eeDigis"), - EBdigiCollectionOut = cms.string('ebDigiSkim'), - EBdigiCollection = cms.InputTag("ecalDigis","ebDigis"), - DigiUnpacker = cms.InputTag("ecalDigis"), - DigiType = cms.string('Physics') - ) - -process.load("RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi") - -process.load("RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi") -# make sure our calibrated rec hits can find the new name for our uncalibrated rec hits -process.ecalRecHit.EBuncalibRecHitCollection = 'uncalibHitMaker:EcalUncalibRecHitsEB' -process.ecalRecHit.EEuncalibRecHitCollection = 'uncalibHitMaker:EcalUncalibRecHitsEE' - -process.timing = cms.EDFilter("EcalTimingAnalysis", - rootfile = cms.untracked.string('Timing_RUNNUMBER.root'), - CorrectBH = cms.untracked.bool(False), - hitProducer = cms.string('uncalibHitMaker'), - rhitProducer = cms.untracked.string('ecalRecHit'), - minNumEvt = cms.untracked.double(0), - FromFileName = cms.untracked.string('Emptyfile.root'), - TTPeakTime = cms.untracked.string('TTPeakPositionFileTiming.txt'), - SMAverages = cms.untracked.vdouble(5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5.), - hitProducerEE = cms.string('uncalibHitMaker'), - rhitProducerEE = cms.untracked.string('ecalRecHit'), - GTRecordCollection = cms.untracked.string('gtDigis'), - amplThr = cms.untracked.double(15.0), - amplThrEE = cms.untracked.double(15.0), - SMCorrections = cms.untracked.vdouble(5.0, 5.0, 5.0, 5.0, 5.0, - 5.0, 5.0, 5.0, 5.0, 5.0, - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5., 5., 5., 5., 5., - 5.0, 5.0, 5.0, 5.0, 5.0, - 5.0, 5.0, 5.0, 5.0), - BeamHaloPlus = cms.untracked.bool(True), - hitCollectionEE = cms.string('EcalUncalibRecHitsEE'), - rhitCollectionEE = cms.untracked.string('EcalRecHitsEE'), - ChPeakTime = cms.untracked.string('ChPeakTimeTiming.txt'), - hitCollection = cms.string('EcalUncalibRecHitsEB'), - rhitCollection = cms.untracked.string('EcalRecHitsEB'), - digiProducer = cms.string('ecalDigis'), - CorrectEcalReadout = cms.untracked.bool(False), - FromFile = cms.untracked.bool(False), - RunStart = cms.untracked.double(1215192037.0), - WriteTxtFiles = cms.untracked.bool(False), - TimingTree = cms.untracked.bool(True), - AllAverage = cms.untracked.double(5.0), - Splash09Cor = cms.untracked.bool(False), - AllShift = cms.untracked.double(0.0), - RunLength = cms.untracked.double(2.0), - MinEBXtals = cms.untracked.int32(-1), - EBRadius = cms.untracked.double(1.4) - ) -process.ecalDigis = process.ecalEBunpacker.clone() - -process.p = cms.Path(process.gtDigis*process.ecalDigis*process.ecalDccDigis*process.uncalibHitMaker*process.ecalDetIdToBeRecovered*process.ecalRecHit*process.timing) - diff --git a/EcalTiming/test/checkBoth.csh b/EcalTiming/test/checkBoth.csh deleted file mode 100755 index ba66354..0000000 --- a/EcalTiming/test/checkBoth.csh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/tcsh -f - -set runnum=$1 - -echo "Checking both laser and calibration analysis for run ${1}" - -./checkResultsCRAB.sh -r Laser_${runnum}; -./checkResultsCRAB.sh -r Calib_${runnum}; - -#end of file diff --git a/EcalTiming/test/checkResultsCRAB.sh b/EcalTiming/test/checkResultsCRAB.sh deleted file mode 100755 index 81b1363..0000000 --- a/EcalTiming/test/checkResultsCRAB.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -usage='Usage: -r ' - -args=`getopt r: -- "$@"` -if test $? != 0 - then - echo $usage - exit 1 -fi - -eval set -- "$args" -for i - do - case "$i" in - -r) shift; run_num=$2;shift;; - esac -done - -echo 'Checking CRAB status' ${run_num} - -if [ "X"${run_num} == "X" ] - then - echo "INVALID RUN NUMBER! Please give a valid run number!" - echo $usage - exit -fi - -# setup crab environment -source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh; -eval `scramv1 runtime -sh`; -source /afs/cern.ch/cms/ccs/wm/scripts/Crab/CRAB_2_7_1/crab.sh; -#source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh; - -cd ${run_num}; - -nrun=`crab -status | grep -c RUN`; -npend=`crab -status | grep -c PEND`; -ndone=`crab -status | grep -c DONE`; - -if [ "${nrun}" == "0" ] && [ "${npend}" == "0" ] -then - echo "Run "$run_num "is done..." "run:" $nrun "pend:" $npend "done:" $ndone - crab -get -else - echo "Run "$run_num "NOT yet done..." "run:" $nrun "pend:" $npend "done:" $ndone -fi - -#cd -; diff --git a/EcalTiming/test/ecalCreateTTAvgTimes_cfg.py b/EcalTiming/test/ecalCreateTTAvgTimes_cfg.py index cc3b3af..f9f5e14 100644 --- a/EcalTiming/test/ecalCreateTTAvgTimes_cfg.py +++ b/EcalTiming/test/ecalCreateTTAvgTimes_cfg.py @@ -19,7 +19,7 @@ process.load("Geometry.EcalMapping.EcalMappingRecord_cfi") process.load("Geometry.EcalCommonData.EcalOnly_cfi") process.load("Geometry.CaloEventSetup.CaloGeometry_cff") -process.load("CalibCalorimetry.EcalTrivialCondModules.EcalTrivialCondRetriever_cfi") +process.load("EcalTiming.EcalTrivialCondModules.EcalTrivialCondRetriever_cfi") process.createAvgs = cms.EDAnalyzer('EcalCreateTTAvgTimes', diff --git a/EcalTiming/test/ecalTime_fromAlcaStreamHighPU_cfg.py b/EcalTiming/test/ecalTime_fromAlcaStreamHighPU_cfg.py new file mode 100644 index 0000000..fca5db1 --- /dev/null +++ b/EcalTiming/test/ecalTime_fromAlcaStreamHighPU_cfg.py @@ -0,0 +1,330 @@ +import FWCore.ParameterSet.Config as cms +import os, sys, imp, re +import FWCore.ParameterSet.VarParsing as VarParsing + +#sys.path(".") + +#new options to make everything easier for batch + +############################################################ +### SETUP OPTIONS + +options = VarParsing.VarParsing('standard') +options.register('jsonFile', + "", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "path and name of the json file") +options.register('step', + "RECOTIMEANALYSIS", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "Do reco, time analysis or both, RECO|TIMEANALYSIS|RECOTIMEANALYSIS") +options.register('offset', + 0.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to each crystal time") +options.register('minEnergyEB', + 1.5, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum energy threshold") +options.register('minEnergyEE', + 3, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum energy threshold") +options.register('minChi2EB', + 50.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum chi2 threshold") +options.register('minChi2EE', + 50.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum chi2 threshold") +options.register('isSplash', + 0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "0=false, 1=true" + ) +options.register('streamName', + 'AlCaPhiSym', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "type of stream: AlCaPhiSym or AlCaP0") +options.register('loneBunch', + 1, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "0=No, 1=Yes" + ) + +#options.jsonFile="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-256869_13TeV_PromptReco_Collisions15_25ns_JSON.txt" +#options.jsonFile="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/DCSOnly/json_DCSONLY.txt" +#options.jsonFile; +### setup any defaults you want +options.output="output/ecalTiming.root" +options.secondaryOutput="ntuple.root" + +if(options.streamName=="AlCaP0"): print "stream ",options.streamName#options.files = "/store/data/Commissioning2015/AlCaP0/RAW/v1/000/246/342/00000/048ECF48-F906-E511-95AC-02163E011909.root" +elif(options.streamName=="AlCaPhiSym"): print "stream ",options.streamName#options.files = "/store/data/Commissioning2015/AlCaPhiSym/RAW/v1/000/244/768/00000/A8219906-44FD-E411-8DA9-02163E0121C5.root" +else: + print "stream ",options.streamName," not foreseen" + exit + +#options.files = cms.untracked.vstring +#options.streamName = cms.untracked.vstring +options.maxEvents = -1# -1 means all events +### get and parse the command line arguments +options.parseArguments() +print options + +processname = options.step + +doReco = True +doAnalysis = True +if "RECO" not in processname: + doReco = False +if "TIME" not in processname: + doAnalysis = False + +process = cms.Process(processname) + +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000) + +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_cff') + +if(options.isSplash==1): + ## Get Cosmic Reconstruction + process.load('Configuration/StandardSequences/ReconstructionCosmics_cff') + process.caloCosmics.remove(process.hbhereco) + process.caloCosmics.remove(process.hcalLocalRecoSequence) + process.caloCosmics.remove(process.hfreco) + process.caloCosmics.remove(process.horeco) + process.caloCosmics.remove(process.zdcreco) + process.caloCosmics.remove(process.ecalClusters) + process.caloCosmicOrSplashRECOSequence = cms.Sequence(process.caloCosmics )#+ process.egammaCosmics) +else: + process.load('Configuration/StandardSequences/Reconstruction_cff') + process.recoSequence = cms.Sequence(process.calolocalreco )#+ process.egammaCosmics) + +#process.load('PhiSym.EcalCalibAlgos.ecalPhiSymLocarecoWeights_cff') +#process.load('RecoLocalCalo.Configuration.ecalLocalRecoSequence_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff') +process.load('EcalTiming.EcalTiming.ecalLocalRecoSequenceAlCaStream_cff') +process.load('EcalTiming.EcalTiming.ecalLocalRecoSequenceAlCaP0Stream_cff') + +if(options.streamName=="AlCaP0"): + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltAlCaPi0EBRechitsToDigis","pi0EBDigis") + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltAlCaPi0EERechitsToDigis","pi0EEDigis") +else: + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEB") + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEE") + + +## Raw to Digi +process.load('Configuration/StandardSequences/RawToDigi_Data_cff') + +## HLT Filter Splash +import HLTrigger.HLTfilters.hltHighLevel_cfi +process.spashesHltFilter = HLTrigger.HLTfilters.hltHighLevel_cfi.hltHighLevel.clone( + throw = cms.bool(False), + HLTPaths = ['HLT_EG20*', 'HLT_SplashEcalSumET', 'HLT_Calibration','HLT_EcalCalibration','HLT_HcalCalibration','HLT_Random','HLT_Physics','HLT_HcalNZS','HLT_SplashEcalSumET','HLTriggerFinalPath' ] +) + + +## GlobalTag Conditions Related +from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '74X_dataRun2_Prompt_v2', '') #run2_data', '') + +## Process Digi To Raw Step +process.digiStep = cms.Sequence(process.ecalDigis + process.ecalPreshowerDigis) + +## Process Reco + + + +### Print Out Some Messages +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ), + categories = cms.untracked.vstring('ecalTimeTree'), + destinations = cms.untracked.vstring('cout') +) + +# enable the TrigReport and TimeReport +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +# SkipEvent = cms.untracked.vstring('ProductNotFound') +) + +SkipEvent = cms.untracked.vstring('ProductNotFound','EcalProblem') + +# dbs search --query "find file where dataset=/ExpressPhysics/BeamCommissioning09-Express-v2/FEVT and run=124020" | grep store | awk '{printf "\"%s\",\n", $1}' +# Input source +process.source = cms.Source("PoolSource", + secondaryFileNames = cms.untracked.vstring(), + fileNames = cms.untracked.vstring(options.files), +) + +if(len(options.jsonFile) > 0): + import FWCore.PythonUtilities.LumiList as LumiList + process.source.lumisToProcess = LumiList.LumiList(filename = options.jsonFile).getVLuminosityBlockRange() + + + +# Output definition +process.RECOoutput = cms.OutputModule("PoolOutputModule", +splitLevel = cms.untracked.int32(0), +eventAutoFlushCompressedSize = cms.untracked.int32(5242880), +outputCommands = cms.untracked.vstring('drop *',"keep *_ecalRecHitE*Selector_*_*"), +fileName = cms.untracked.string(options.output), +dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('RECO') +) +) + + +## Histogram files +process.TFileService = cms.Service("TFileService", + fileName = cms.string(options.output), + closeFileFast = cms.untracked.bool(True) + ) + +### NumBer of events +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents)) + +#DUMMY RECHIT +process.dummyHits = cms.EDProducer("DummyRechitDigis", + doDigi = cms.untracked.bool(True), + # rechits + barrelHitProducer = cms.InputTag('hltAlCaPi0EBUncalibrator','pi0EcalRecHitsEB' ,"HLT"), + endcapHitProducer = cms.InputTag('hltAlCaPi0EEUncalibrator','pi0EcalRecHitsEE' ,"HLT"), + barrelRecHitCollection = cms.untracked.string("dummyBarrelRechitsPi0"), + endcapRecHitCollection = cms.untracked.string("dummyEndcapRechitsPi0"), + # digis + barrelDigis = cms.InputTag('hltAlCaPi0EBRechitsToDigis','pi0EBDigis',"HLT"), + endcapDigis = cms.InputTag('hltAlCaPi0EERechitsToDigis','pi0EEDigis',"HLT"), #changed hltAlCaPi0EERechitsToDigis in LowPU....changed in the file -.- + barrelDigiCollection = cms.untracked.string("dummyBarrelDigisPi0"), + endcapDigiCollection = cms.untracked.string("dummyEndcapDigisPi0")) + +##ADDED +# TRIGGER RESULTS FILTER +process.triggerSelectionLoneBunch = cms.EDFilter( "TriggerResultsFilter", + triggerConditions = cms.vstring('L1_AlwaysTrue'), + hltResults = cms.InputTag( "TriggerResults", "", "HLT" ), + l1tResults = cms.InputTag( "hltGtDigis" ), + l1tIgnoreMask = cms.bool( False ), + l1techIgnorePrescales = cms.bool( False ), + daqPartitions = cms.uint32( 1 ), + throw = cms.bool( True ) + ) + +process.filter=cms.Sequence() +if(options.isSplash==1): + process.filter+=process.spashesHltFilter + process.reco_step = cms.Sequence(process.caloCosmicOrSplashRECOSequence) +else: + if(options.streamName=="AlCaP0"): + #from RecoLocalCalo.Configuration.ecalLocalRecoSequence_cff import * + ##process.reco_step = cms.Sequence(ecalMultiFitUncalibRecHit * + ## ecalRecHit) + #process.ecalMultiFitUncalibRecHit = RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi.ecalMultiFitUncalibRecHit.clone() + + #process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag('dummyHits','dummyBarrelDigis')#,'piZeroAnalysis') + #process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag('dummyHits','dummyEndcapDigis')#,'piZeroAnalysis') + #ecalRecHit.killDeadChannels = False + #ecalRecHit.recoverEBFE = False + if(options.loneBunch==1): + process.filter+=process.triggerSelectionLoneBunch + import RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi + process.ecalMultiFitUncalibRecHit = RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi.ecalMultiFitUncalibRecHit.clone() + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag('dummyHits','dummyBarrelDigisPi0')#,'piZeroAnalysis') + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag('dummyHits','dummyEndcapDigisPi0')#,'piZeroAnalysis') + + #UNCALIB to CALIB + from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import * + process.ecalDetIdToBeRecovered = RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi.ecalDetIdToBeRecovered.clone() + process.ecalRecHit.killDeadChannels = cms.bool( False ) + process.ecalRecHit.recoverEBVFE = cms.bool( False ) + process.ecalRecHit.recoverEEVFE = cms.bool( False ) + process.ecalRecHit.recoverEBFE = cms.bool( False ) + process.ecalRecHit.recoverEEFE = cms.bool( False ) + process.ecalRecHit.recoverEEIsolatedChannels = cms.bool( False ) + process.ecalRecHit.recoverEBIsolatedChannels = cms.bool( False ) + + process.reco_step = cms.Sequence(process.dummyHits + * process.ecalMultiFitUncalibRecHit + * process.ecalRecHit) + else: + #process.reco_step = cms.Sequence(process.reconstruction_step_multiFit) + if(options.loneBunch==1): + process.filter+=process.triggerSelectionLoneBunch + process.reco_step = cms.Sequence(process.ecalLocalRecoSequenceAlCaStream) + + +### Process Full Path +if(options.isSplash==0): + process.digiStep = cms.Sequence() + + + +evtPlots = True if options.isSplash else False + + +#import Electronics mapping +process.load("Geometry.EcalCommonData.EcalOnly_cfi") +process.load("Geometry.EcalMapping.EcalMapping_cfi") +process.load("Geometry.EcalMapping.EcalMappingRecord_cfi") +#process.load("Geometry.CaloEventSetup.CaloGeometry_cff") + +#ESLooperProducer looper is imported here: +process.load('EcalTiming.EcalTiming.ecalTimingCalibProducer_cfi') +process.load('EcalTiming.EcalTiming.RecHitsSelector_cfi') + +#process.timing.outputDumpFile = process.TFileService.fileName #spostato per vedere se l'errore cambia o rimane o addirittura sparisce! +process.timing.recHitEBCollection = cms.InputTag("ecalRecHitEBSelector") +process.timing.recHitEECollection = cms.InputTag("ecalRecHitEESelector") +process.timing.isSplash= cms.bool(True if options.isSplash else False) +process.timing.makeEventPlots=evtPlots +process.timing.globalOffset = cms.double(options.offset) +process.timing.outputDumpFile = process.TFileService.fileName +process.timing.energyThresholdOffsetEB = cms.double(options.minEnergyEB) +process.timing.energyThresholdOffsetEE = cms.double(options.minEnergyEE) +process.timing.chi2ThresholdOffsetEB = cms.double(options.minChi2EB) +process.timing.chi2ThresholdOffsetEE = cms.double(options.minChi2EE) +process.timing.storeEvents = cms.bool(True) + + +process.analysis = cms.Sequence( process.timing ) +process.reco = cms.Sequence( (process.filter + + process.digiStep + + process.reco_step) + * (process.ecalRecHitEBSelector + process.ecalRecHitEESelector) + ) + + +process.seq = cms.Sequence() +if doReco: + process.seq += process.reco +if doAnalysis: + process.seq += process.analysis +else: + process.endp = cms.EndPath(process.RECOoutput) + +process.p = cms.Path(process.seq) + +processDumpFile = open('processDump.py', 'w') +print >> processDumpFile, process.dumpPython() diff --git a/EcalTiming/test/ecalTime_fromAlcaStream_cfg.py b/EcalTiming/test/ecalTime_fromAlcaStream_cfg.py index 14833a7..d52ba30 100644 --- a/EcalTiming/test/ecalTime_fromAlcaStream_cfg.py +++ b/EcalTiming/test/ecalTime_fromAlcaStream_cfg.py @@ -5,12 +5,6 @@ #sys.path(".") #new options to make everything easier for batch -from optparse import OptionParser -parser=OptionParser() -parser.add_option("-i","--inputFile") -parser.add_option("-o","--outputFile") - -(opts,args)=parser.parse_args() ############################################################ ### SETUP OPTIONS @@ -21,45 +15,90 @@ VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "path and name of the json file") +options.register('step', + "RECOTIMEANALYSIS", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "Do reco, time analysis or both, RECO|TIMEANALYSIS|RECOTIMEANALYSIS") options.register('offset', 0.0, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.float, "add this to each crystal time") +options.register('minEnergyEB', + 1.5, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum energy threshold") +options.register('minEnergyEE', + 3.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum energy threshold") +options.register('minChi2EB', + 50.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum chi2 threshold") +options.register('minChi2EE', + 50.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to minimum chi2 threshold") options.register('isSplash', 0, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "0=false, 1=true" ) +options.register('streamName', + 'AlCaPhiSym', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "type of stream: AlCaPhiSym or AlCaP0") + +#options.jsonFile ="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_246908-256869_13TeV_PromptReco_Collisions15_25ns_JSON.txt" +#options.jsonFile ="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/Cert_254986-255031_13TeV_PromptReco_Collisions15_LOWPU_25ns_JSON_MuonPhys.txt" +#options.jsonFile + + ### setup any defaults you want -streamName = "AlCaPhiSym" options.output="output/ecalTiming.root" options.secondaryOutput="ntuple.root" -if(streamName=="AlCaP0"): options.files = "/store/data/Commissioning2015/AlCaP0/RAW/v1/000/246/342/00000/048ECF48-F906-E511-95AC-02163E011909.root" -elif(streamName=="AlCaPhiSym"): options.files = "/store/data/Commissioning2015/AlCaPhiSym/RAW/v1/000/244/768/00000/A8219906-44FD-E411-8DA9-02163E0121C5.root" +if(options.streamName=="AlCaP0"): print "stream ",options.streamName #options.files = "/store/data/Commissioning2015/AlCaP0/RAW/v1/000/246/342/00000/048ECF48-F906-E511-95AC-02163E011909.root" +elif(options.streamName=="AlCaPhiSym"): print "stream ",options.streamName #options.files = "/store/data/Commissioning2015/AlCaPhiSym/RAW/v1/000/244/768/00000/A8219906-44FD-E411-8DA9-02163E0121C5.root" else: - print "stream ",streamName," not foreseen" + print "stream ",options.streamName," not foreseen" exit + +#options.files = cms.untracked.vstring +#options.streamName = cms.untracked.vstring options.maxEvents = -1 # -1 means all events ### get and parse the command line arguments options.parseArguments() print options -process = cms.Process("TIMECALIBANALYSIS") +processname = options.step -#dataset=/MinimumBias/Commissioning2015-v1/RAW run=243506 +doReco = True +doAnalysis = True +if "RECO" not in processname: + doReco = False +if "TIME" not in processname: + doAnalysis = False +process = cms.Process(processname) process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000) + process.load('Configuration.EventContent.EventContent_cff') process.load('SimGeneral.MixingModule.mixNoPU_cfi') process.load('Configuration.StandardSequences.GeometryRecoDB_cff') process.load('Configuration.StandardSequences.MagneticField_38T_cff') - if(options.isSplash==1): ## Get Cosmic Reconstruction process.load('Configuration/StandardSequences/ReconstructionCosmics_cff') @@ -79,8 +118,9 @@ process.load('Configuration.StandardSequences.EndOfProcess_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff') process.load('EcalTiming.EcalTiming.ecalLocalRecoSequenceAlCaStream_cff') +process.load('EcalTiming.EcalTiming.ecalLocalRecoSequenceAlCaP0Stream_cff') -if(streamName=="AlCaP0"): +if(options.streamName=="AlCaP0"): process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltAlCaPi0EBRechitsToDigis","pi0EBDigis") process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltAlCaPi0EERechitsToDigis","pi0EEDigis") else: @@ -99,12 +139,9 @@ ) -## Do you want to Pre-Scale -process.load("FWCore.Modules.preScaler_cfi") -process.preScaler.prescaleFactor = 1 ## GlobalTag Conditions Related from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '') +process.GlobalTag = GlobalTag(process.GlobalTag, '74X_dataRun2_Prompt_v2', '') #run2_data', '') ## Process Digi To Raw Step process.digiStep = cms.Sequence(process.ecalDigis + process.ecalPreshowerDigis) @@ -113,13 +150,6 @@ - - - -# Dump Some event Content -import FWCore.Modules.printContent_cfi -process.dumpEv = FWCore.Modules.printContent_cfi.printContent.clone() - ### Print Out Some Messages process.MessageLogger = cms.Service("MessageLogger", cout = cms.untracked.PSet( @@ -128,8 +158,6 @@ categories = cms.untracked.vstring('ecalTimeTree'), destinations = cms.untracked.vstring('cout') ) -process.load("FWCore.MessageService.MessageLogger_cfi") -process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000) # enable the TrigReport and TimeReport process.options = cms.untracked.PSet( @@ -137,43 +165,31 @@ # SkipEvent = cms.untracked.vstring('ProductNotFound') ) +SkipEvent = cms.untracked.vstring('ProductNotFound','EcalProblem') + # dbs search --query "find file where dataset=/ExpressPhysics/BeamCommissioning09-Express-v2/FEVT and run=124020" | grep store | awk '{printf "\"%s\",\n", $1}' # Input source process.source = cms.Source("PoolSource", secondaryFileNames = cms.untracked.vstring(), - # fileNames = cms.untracked.vstring('file:test_DIGI.root') - fileNames = cms.untracked.vstring(options.files), + fileNames = cms.untracked.vstring(options.files), ) -# process.source = cms.Source( -# "PoolSource", -# skipEvents = cms.untracked.uint32(0), -# fileNames = cms.untracked.vstring( -# #'file:MyCrab/50988619-41DE-E211-9F98-003048FFD770.root' -# #'root://xrootd.unl.edu//store/data/Run2010B/Cosmics/RAW/v1/000/144/556/C8B5FCA9-F3B5-DF11-B28A-0030487CD16E.root' -# #'file:Cosmic-Commissioning2014-Cosmics-RAW-v1-AC4963B3-54BE-E311-97F5-02163E00E6E3.root' -# #'/store/data/Commissioning2015/Cosmics/RAW-RECO/CosmicSP-6Mar2015-v1/10000/248747E6-25CA-E411-B17C-02163E00BD75.root' -# #'/store/data/Run2010B/Cosmics/RAW/v1/000/144/559/306A4ABD-F3B5-DF11-9CAD-003048F118C6.root' -# '/store/data/Commissioning2015/Cosmics/RAW/v1/000/232/881/00000/26ADAFFB-3FAB-E411-A313-02163E011DDC.root' -# ), -# # drop native rechits and clusters, to be sure only those locally made will be picked up -# inputCommands = cms.untracked.vstring('keep *' -# ,'drop EcalRecHitsSorted_*_*_RECO' # drop hfRecoEcalCandidate as remade in this process -# , 'drop recoSuperClusters_*_*_RECO' # drop hfRecoEcalCandidate as remade in this process -# , 'drop recoCaloClusters_*_*_RECO' -# ) +if(len(options.jsonFile) > 0): + import FWCore.PythonUtilities.LumiList as LumiList + process.source.lumisToProcess = LumiList.LumiList(filename = options.jsonFile).getVLuminosityBlockRange() + # Output definition process.RECOoutput = cms.OutputModule("PoolOutputModule", - splitLevel = cms.untracked.int32(0), - eventAutoFlushCompressedSize = cms.untracked.int32(5242880), - outputCommands = process.RECOEventContent.outputCommands, - fileName = cms.untracked.string('test_RECO.root'), - dataset = cms.untracked.PSet( - filterName = cms.untracked.string(''), - dataTier = cms.untracked.string('RECO') - ) +splitLevel = cms.untracked.int32(0), +eventAutoFlushCompressedSize = cms.untracked.int32(5242880), +outputCommands = cms.untracked.vstring('drop *',"keep *_ecalRecHitE*Selector_*_*"), +fileName = cms.untracked.string(options.output), +dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('RECO') +) ) @@ -183,53 +199,112 @@ closeFileFast = cms.untracked.bool(True) ) -## Dumpevent Event Contents -process.dumpEvContent = cms.EDAnalyzer("EventContentAnalyzer") - ### NumBer of events process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents)) +#DUMMY RECHIT +process.dummyHits = cms.EDProducer("DummyRechitDigis", + doDigi = cms.untracked.bool(True), + # rechits + barrelHitProducer = cms.InputTag('hltAlCaPi0EBUncalibrator','pi0EcalRecHitsEB' ,"HLT"), + endcapHitProducer = cms.InputTag('hltAlCaPi0EEUncalibrator','pi0EcalRecHitsEE' ,"HLT"), + barrelRecHitCollection = cms.untracked.string("dummyBarrelRechitsPi0"), + endcapRecHitCollection = cms.untracked.string("dummyEndcapRechitsPi0"), + # digis + barrelDigis = cms.InputTag('hltAlCaPi0EBRechitsToDigis','pi0EBDigis',"HLT"), + endcapDigis = cms.InputTag('hltAlCaPi0EERechitsToDigisLowPU','pi0EEDigis',"HLT"), #changed hltAlCaPi0EERechitsToDigis in LowPU....changed in the file -.- + barrelDigiCollection = cms.untracked.string("dummyBarrelDigisPi0"), + endcapDigiCollection = cms.untracked.string("dummyEndcapDigisPi0")) process.filter=cms.Sequence() if(options.isSplash==1): process.filter+=process.spashesHltFilter process.reco_step = cms.Sequence(process.caloCosmicOrSplashRECOSequence) else: - #process.reco_step = cms.Sequence(process.reconstruction_step_multiFit) - process.reco_step = cms.Sequence(process.ecalLocalRecoSequenceAlCaStream) + if(options.streamName=="AlCaP0"): + #from RecoLocalCalo.Configuration.ecalLocalRecoSequence_cff import * + ##process.reco_step = cms.Sequence(ecalMultiFitUncalibRecHit * + ## ecalRecHit) + #process.ecalMultiFitUncalibRecHit = RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi.ecalMultiFitUncalibRecHit.clone() + + #process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag('dummyHits','dummyBarrelDigis')#,'piZeroAnalysis') + #process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag('dummyHits','dummyEndcapDigis')#,'piZeroAnalysis') + #ecalRecHit.killDeadChannels = False + #ecalRecHit.recoverEBFE = False + import RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi + process.ecalMultiFitUncalibRecHit = RecoLocalCalo.EcalRecProducers.ecalMultiFitUncalibRecHit_cfi.ecalMultiFitUncalibRecHit.clone() + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag('dummyHits','dummyBarrelDigisPi0')#,'piZeroAnalysis') + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag('dummyHits','dummyEndcapDigisPi0')#,'piZeroAnalysis') + + #UNCALIB to CALIB + from RecoLocalCalo.EcalRecProducers.ecalRecHit_cfi import * + process.ecalDetIdToBeRecovered = RecoLocalCalo.EcalRecProducers.ecalDetIdToBeRecovered_cfi.ecalDetIdToBeRecovered.clone() + process.ecalRecHit.killDeadChannels = cms.bool( False ) + process.ecalRecHit.recoverEBVFE = cms.bool( False ) + process.ecalRecHit.recoverEEVFE = cms.bool( False ) + process.ecalRecHit.recoverEBFE = cms.bool( False ) + process.ecalRecHit.recoverEEFE = cms.bool( False ) + process.ecalRecHit.recoverEEIsolatedChannels = cms.bool( False ) + process.ecalRecHit.recoverEBIsolatedChannels = cms.bool( False ) + + process.reco_step = cms.Sequence(process.dummyHits + * process.ecalMultiFitUncalibRecHit + * process.ecalRecHit) + else: + #process.reco_step = cms.Sequence(process.reconstruction_step_multiFit) + process.reco_step = cms.Sequence(process.ecalLocalRecoSequenceAlCaStream) + ### Process Full Path if(options.isSplash==0): process.digiStep = cms.Sequence() -process.p = cms.Path( process.filter #+ process.preScaler + + +evtPlots = True if options.isSplash else False + + +#import Electronics mapping +process.load("Geometry.EcalCommonData.EcalOnly_cfi") +process.load("Geometry.EcalMapping.EcalMapping_cfi") +process.load("Geometry.EcalMapping.EcalMappingRecord_cfi") +#process.load("Geometry.CaloEventSetup.CaloGeometry_cff") + +#ESLooperProducer looper is imported here: +process.load('EcalTiming.EcalTiming.ecalTimingCalibProducer_cfi') +process.load('EcalTiming.EcalTiming.RecHitsSelector_cfi') + +#process.timing.outputDumpFile = process.TFileService.fileName #spostato per vedere se l'errore cambia o rimane o addirittura sparisce! +process.timing.recHitEBCollection = cms.InputTag("ecalRecHitEBSelector") +process.timing.recHitEECollection = cms.InputTag("ecalRecHitEESelector") +process.timing.isSplash= cms.bool(True if options.isSplash else False) +process.timing.makeEventPlots=evtPlots +process.timing.globalOffset = cms.double(options.offset) +process.timing.outputDumpFile = process.TFileService.fileName +process.timing.energyThresholdOffsetEB = cms.double(options.minEnergyEB) +process.timing.energyThresholdOffsetEE = cms.double(options.minEnergyEE) +process.timing.chi2ThresholdOffsetEB = cms.double(options.minChi2EB) +process.timing.chi2ThresholdOffsetEE = cms.double(options.minChi2EE) +process.timing.storeEvents = cms.bool(True) + + +process.analysis = cms.Sequence( process.timing ) +process.reco = cms.Sequence( (process.filter + process.digiStep - + process.reco_step + + process.reco_step) + * (process.ecalRecHitEBSelector + process.ecalRecHitEESelector) ) -process.endp = cms.EndPath(process.RECOoutput) -### Schedule ### -process.schedule = cms.Schedule(process.p) # , process.endp) +process.seq = cms.Sequence() +if doReco: + process.seq += process.reco +if doAnalysis: + process.seq += process.analysis +else: + process.endp = cms.EndPath(process.RECOoutput) -evtPlots = True if options.isSplash else False -process.looper = cms.Looper("EcalTimingCalibProducer", - maxLoop = cms.uint32(2), - isSplash = cms.bool(True if options.isSplash == 1 else False), - makeEventPlots = cms.bool(evtPlots), - recHitEBCollection = cms.InputTag("ecalRecHit","EcalRecHitsEB"), - recHitEECollection = cms.InputTag("ecalRecHit","EcalRecHitsEE"), - recHitFlags = cms.vint32([0]), # only recHits with these flags are accepted for calibration - #recHitMinimumN = cms.uint32(10), - recHitMinimumN = cms.uint32(2), - minRecHitEnergy = cms.double(1), - minEntries = cms.uint32(1), - globalOffset = cms.double(options.offset), - produceNewCalib = cms.bool(True), - outputDumpFile = process.TFileService.fileName, - noiseRMSThreshold = cms.double(0.5), - noiseTimeThreshold = cms.double(2.0) - ) +process.p = cms.Path(process.seq) processDumpFile = open('processDump.py', 'w') print >> processDumpFile, process.dumpPython() diff --git a/EcalTiming/test/getRunTimeAbbrev.csh b/EcalTiming/test/getRunTimeAbbrev.csh deleted file mode 100755 index 47dd74c..0000000 --- a/EcalTiming/test/getRunTimeAbbrev.csh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/csh -############################################################################ -# Simple program, outputs the seconds since Jan 1 1970 for a provided run -# Also, output teh length of the run rounded up to 15 mins. -#--------------------------------------------------------------------------- -# This requires parse.pl to be present in the CWD -############################################################################ - -############################################################################ -# Checking Arguments -if ($#argv < 1) then - echo " scripts needs only 1 input variables GEESH give it the darn run number" - exit -endif -############################################################################ - - -set RUNNUM = $1 -#echo "http://cmsmon.cern.ch/cmsdb/servlet/ECALSummary?RUN=$RUNNUM&RIUNROUP=ECAL" -wget --quiet -nv "http://cmsmon.cern.ch/cmsdb/servlet/ECALSummary?RUN=$RUNNUM&RUNGROUP=ECAL" -O rundate.html - -#set rundates = ( `./parse.pl` ) -set rundates = `./parse.pl` -#echo $rundates - -set startdate = $rundates[1] -set enddate = $rundates[2] -#echo "------------------Event Timing for run $RUNNUM------------------" -#echo "Start in Seconds since Jan 1 1970 : " $rundates[1] -#echo "End in Seconds since Jan 1 1970 : " $rundates[2] - -#OK OK, I should be shot for writing this in c-shell... oh well. -set runlengths = 0 -set runlengthh = 0 -set runlengthhp1 = 0 -set runlengthhp900 = 0 -set runlengthhp1800 = 0 -set runlengthhp2700 = 0 - -set secondsinhour = 3600 -@ runlengths = $enddate - $startdate -@ runlengthh = $runlengths / $secondsinhour -@ runlengthhp1 = ${runlengths} + 3599 -@ runlengthhp1 = ${runlengthhp1} / ${secondsinhour} -@ runlengthhp900 = ${runlengths} + 2699 -@ runlengthhp900 = ${runlengthhp900} / ${secondsinhour} -@ runlengthhp1800 = ${runlengths} + 1799 -@ runlengthhp1800 = ${runlengthhp1800} / ${secondsinhour} -@ runlengthhp2700 = ${runlengths} + 899 -@ runlengthhp2700 = ${runlengthhp2700} / ${secondsinhour} - -set runlength = 0 -if ( $runlengthhp2700 > $runlengthh ) then - set runlength = $runlengthhp2700 -else if ( $runlengthhp1800 > $runlengthh ) then - set runlength = "${runlengthh}.75" -else if ( $runlengthhp900 > $runlengthh ) then - set runlength = "${runlengthh}.50" -else if ( $runlengthhp1 > $runlengthh ) then - set runlength = "${runlengthh}.25" -endif - -#echo "The run lasted " $runlengths " seconds" -#echo "The run lasted " $runlength " hours (rounded to 15 mins) " -#echo "--------------------If you use a cfg--------------------------" -#echo "replace ecalCosmicsHists.TimeStampStart = $startdate" -#echo "replace ecalCosmicsHists.TimeStampLength = $runlength" -#echo "--------------------If you use the script---------------------" -#echo " -rl ${runlength} -st $startdate " -#echo "--------------------------------------------------------------" - -echo "export startdate="$startdate -echo "export runlength="$runlength - -rm -f rundate.html - -#end of file - diff --git a/EcalTiming/test/launchBoth.csh b/EcalTiming/test/launchBoth.csh deleted file mode 100755 index 12197a4..0000000 --- a/EcalTiming/test/launchBoth.csh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/tcsh -f - -set runnum=$1 - -echo "Launching both laser and calibration analysis for run ${1}" - -./launchLaserCRAB.sh -r $runnum -s 50000 -d "/TestEnables/Commissioning09-v1/RAW" -at Laser; -./launchLaserCRAB.sh -r $runnum -s 20000 -d "/TestEnables/Commissioning09-v1/RAW" -at Calib; - -#end of file diff --git a/EcalTiming/test/launchLaserCRAB.sh b/EcalTiming/test/launchLaserCRAB.sh deleted file mode 100755 index e867b8e..0000000 --- a/EcalTiming/test/launchLaserCRAB.sh +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/bash - -#if [ "X$CMSSW_BASE" == "X" ] -# then -# echo "Setup CMSSW environment using eval \`scramv1 runtime -(c)sh\`" -# exit -#fi -#usage='Usage: -r -d -s -o ' -usage='Usage: -r -d -s -at ' -# -#args=`getopt rdso: -- "$@"` -args=`getopt rds: -- "$@"` -if test $? != 0 - then - echo $usage - exit 1 -fi - -eval set -- "$args" -for i - do - case "$i" in - -r) shift; run_num=$2;shift;; - -d) shift; data_set=$2;shift;; - -s) shift; nsplit=$2;shift;; - -at) shift; analy_type=$2;shift;; -# -o) shift; output_dir=$2;shift;; - esac -done - -if [ "X"${run_num} == "X" ] - then - echo "INVALID RUN NUMBER! Please give a valid run number!" - echo $usage - exit -fi - -if [ ${run_num} -lt 68094 ] - then - fedcollection="source" -else - fedcollection="hltCalibrationRaw" -fi - - -if [ "X"${data_set} == "X" ] - then -# echo "using default Dataset: /TestEnables/Commissioning09-v3/RAW" -# data_set="/TestEnables/Commissioning09-v3/RAW" - echo "using default Dataset: /TestEnables/BeamCommissioning09-v1/RAW" - data_set="/TestEnables/BeamCommissioning09-v1/RAW" -fi - -echo 'Submitting CRAB cosmics analysis jobs for' ${run_num} 'dataset' ${data_set} - -#if [ "X"${output_dir} == "X" ] -# then -# echo " no output dir" -# output_dir=/castor/cern.ch/user/c/ccecal/CRUZET3/CosmicsAnalysis -# echo " using default output dir" ${output_dir} -#else -# echo " using output dir "${output_dir} -# rfmkdir ${output_dir} -# rfchmod 775 ${output_dir} -#fi - - - -if [ "X"${analy_type} == "X" ] - then - echo " Must set analysis type: Laser or Calib !!!" - exit -fi - -if [ ${analy_type} != "Laser" ] - then - if [ ${analy_type} != "Calib" ] - then - echo " Must set analysis type: Laser or Calib !!! You entered: ${analy_type} !!!" - exit - fi -fi - -if [ ${analy_type} == "Laser" ] - then - if [ "X"${nsplit} == "X" ] - then - nsplit=50000 - echo " using default split of 50000 events per job" - else - echo " splitting into "${nsplit} "events per job" - fi -else - nsplit=10000000000 - echo " Calib run: all events in one job" -fi - -this_dir=`pwd`; - -# set up directory -mkdir -p ${analy_type}_${run_num}; - -# extract time info -#cd /afs/cern.ch/cms/CAF/CMSCOMM/COMM_ECAL/ccecal/usefulScripts/eventTiming; -#pwd -#./getRunTimeAbbrev.csh ${run_num} >& temp.sh -#source temp.sh -#echo " startdate and runlength: "$startdate $runlength -#cd -; - -#if [ "X"${startdate} == "X" ] -#then - startdate=1215107133 - echo "Warning: did not get startdate.. using default: " $startdate -#fi -# -#if [ "X"${runlength} == "X" ] -#then - runlength=3 - echo "Warning: did not get runlength.. using default: " $runlength -#fi - -# set up Laser.cfg - -cat ${analy_type}TEMPLATE.py | /bin/sed "s@RUNNUMBER@${run_num}@g; s@FEDCOLLECTION@${fedcollection}@g" > ${analy_type}_${run_num}/${analy_type}Config_${run_num}.py - -# set up crab.cfg file - -cat CRABTEMPLATE.cfg | /bin/sed "s@RUNNUMBER@${run_num}@g; s@EVENTSPERJOB@${nsplit}@g; s@DATASETPLACE@${data_set}@g; s@ANALYTYPE@${analy_type}@g ; s@FEDCOLLECTION@${fedcollection}@g " > ${analy_type}_${run_num}/crab.cfg - - - - -#cat ${run_num}/crab.cfg - -cd ${analy_type}_${run_num}; -#pwd - -echo " setting up crab env" -# setup crab environment -source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh; -eval `scramv1 runtime -sh`; -source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh; - -echo " launching crab jobs" -crab -create; -sleep 3; -crab -submit; -sleep 5; -crab -status; -cd -; - -#unset startdate -#unset runlength -#rm -f temp -#rm -f temp.sh - -exit - - - - - - - diff --git a/EcalTiming/test/launchTimingCRAB.sh b/EcalTiming/test/launchTimingCRAB.sh deleted file mode 100755 index 6ea8142..0000000 --- a/EcalTiming/test/launchTimingCRAB.sh +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash - -#if [ "X$CMSSW_BASE" == "X" ] -# then -# echo "Setup CMSSW environment using eval \`scramv1 runtime -(c)sh\`" -# exit -#fi -#usage='Usage: -r -d -s -o ' -usage='Usage: -r -d -s -at ' -# -#args=`getopt rdso: -- "$@"` -args=`getopt rds: -- "$@"` -if test $? != 0 - then - echo $usage - exit 1 -fi - -eval set -- "$args" -for i - do - case "$i" in - -r) shift; run_num=$2;shift;; - -d) shift; data_set=$2;shift;; - -s) shift; nsplit=$2;shift;; - -at) shift; analy_type=$2;shift;; - -fn) shift; file_name=$2;shift;; - -fnf) shift; fnamefiles=$2;shift;; -# -o) shift; output_dir=$2;shift;; - esac -done - -if [ "X"${run_num} == "X" ] - then - echo "INVALID RUN NUMBER! Please give a valid run number!" - echo $usage - exit -fi - -if [ "X"${file_name} == "X" ] - then - echo "You are using crab" -fi - -if [ "X"${fnamefiles} != "X" ] - then - echo "You are using a list of files" - echo - echo " file name is: " $file_name - file_name=`echo $(cat ${file_name})` - echo " file name is now: " $file_name - -fi - - - -#if [ ${run_num} -lt 68094 ] -# then -# fedcollection="source" -#else -fedcollection="hltCalibrationRaw" -#fi - - -if [ "X"${data_set} == "X" ] - then - echo "using default Dataset: /BeamHaloExpress/BeamCommissioning09-Express-v1/FEVT" - data_set="/BeamHaloExpress/BeamCommissioning09-Express-v1/FEVT" -fi - - -if [ "X"${file_name} == "X" ] - then - echo "You are using crab" - echo 'Submitting CRAB Timing analysis jobs for' ${run_num} 'dataset' ${data_set} -else - echo "You are NOT using crab. You are directly running on a skimmed file" -fi - -#if [ "X"${output_dir} == "X" ] -# then -# echo " no output dir" -# output_dir=/castor/cern.ch/user/c/ccecal/CRUZET3/CosmicsAnalysis -# echo " using default output dir" ${output_dir} -#else -# echo " using output dir "${output_dir} -# rfmkdir ${output_dir} -# rfchmod 775 ${output_dir} -#fi - - - -if [ "X"${analy_type} == "X" ] - then - echo " Must set analysis type: Laser or Calib or Timing !!!" - exit -fi - -if [ ${analy_type} != "Laser" ] - then - if [ ${analy_type} != "Calib" ] - then - if [ ${analy_type} != "Timing" ] - then - echo " Must set analysis type: Laser or Calib or Timing !!! You entered: ${analy_type} !!!" - exit - fi - fi -fi - -if [ ${analy_type} == "Laser" ] - then - if [ "X"${nsplit} == "X" ] - then - nsplit=50000 - echo " using default split of 50000 events per job" - else - echo " splitting into "${nsplit} "events per job" - fi -elif [ ${analy_type} == "Timing" ] - then - if [ "X"${nsplit} == "X" ] - then - nsplit=50000 - echo " using default split of 50000 events per job" - else - echo " splitting into "${nsplit} "events per job" - fi -else - nsplit=10000000000 - echo " Calib run: all events in one job" -fi - -this_dir=`pwd`; - -# set up directory -mkdir -p ${analy_type}_${run_num}; - -# extract time info -#cd /afs/cern.ch/cms/CAF/CMSCOMM/COMM_ECAL/ccecal/usefulScripts/eventTiming; -#pwd -#./getRunTimeAbbrev.csh ${run_num} >& temp.sh -#source temp.sh -#echo " startdate and runlength: "$startdate $runlength -#cd -; - -#if [ "X"${startdate} == "X" ] -#then - startdate=1215107133 - echo "Warning: did not get startdate.. using default: " $startdate -#fi -# -#if [ "X"${runlength} == "X" ] -#then - runlength=3 - echo "Warning: did not get runlength.. using default: " $runlength -#fi - -# set up Laser.cfg - -cat ${analy_type}TEMPLATE.py | /bin/sed "s@RUNNUMBER@${run_num}@g; s@FEDCOLLECTION@${fedcollection}@g; s@MYINPUTFILETYPE@${file_name}@g " > ${analy_type}_${run_num}/${analy_type}Config_${run_num}.py - -# set up crab.cfg file - -cat CRABTEMPLATE.cfg | /bin/sed "s@RUNNUMBER@${run_num}@g; s@EVENTSPERJOB@${nsplit}@g; s@DATASETPLACE@${data_set}@g; s@ANALYTYPE@${analy_type}@g ; s@FEDCOLLECTION@${fedcollection}@g " > ${analy_type}_${run_num}/crab.cfg - - - - -#cat ${run_num}/crab.cfg - -cd ${analy_type}_${run_num}; -#pwd - - -eval `scramv1 runtime -sh`; - -if [ "X"${file_name} == "X" ] - then - echo " setting up crab env" -# setup crab environment - source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh; - eval `scramv1 runtime -sh`; - source /afs/cern.ch/cms/ccs/wm/scripts/Crab/CRAB_2_7_2/crab.sh; -# source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh; - - echo "You are using crab" - echo " launching crab jobs" - crab -create; - sleep 3; - crab -submit; - sleep 5; - crab -status; -else - cmsRun ${analy_type}Config_${run_num}.py >& ${analy_type}_${run_num}.log ; - mkdir crab_0_0; - mkdir crab_0_0/res; - mv ${analy_type}_${run_num}.root crab_0_0/res/.; -fi - - -cd -; - -#unset startdate -#unset runlength -#rm -f temp -#rm -f temp.sh - -exit - - - - - - - diff --git a/EcalTiming/test/launcher.sh b/EcalTiming/test/launcher.sh new file mode 100755 index 0000000..133548c --- /dev/null +++ b/EcalTiming/test/launcher.sh @@ -0,0 +1,109 @@ +#! /bin/bash + +############################################################################## +# USAGE # +# # +# ./launcher.sh /store/data/Run2015B/AlCaP0/RAW/v1/000/ 251 562 "AlCaP0" # +############################################################################## + +cd /afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_12_patch4/src/ +export SCRAM_ARCH='slc6_amd64_gcc491' +eval `scramv1 runtime -sh` +source /afs/cern.ch/project/eos/installation/cms/etc/setup.sh +EOSCMD="/afs/cern.ch/project/eos/installation/cms/bin/eos.select" + +#FILES=$($EOSCMD ls /eos/cms/store/data/Run2015B/AlCaP0/RAW/v1/000/251/562/00000/) +#$EOSCMD ls /eos/cms/store/data/Run2015B/AlCaP0/RAW/v1/000/251/562/00000/ >test.txt + +#for files in $FILES +#do +# echo "Input " $files +#done + +#echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + +#while read line +#do +# echo "Input " $line +# +#done study only the run 251562 from PhiSym stream + + echo "++++++++++++++++++++++" + echo "+ Single Run Study +" + echo "++++++++++++++++++++++" + + runs=$($EOSCMD ls "/eos/cms/"$1"/"$2"/"$3"/00000/") + + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + + #echo $TEST1 + + + #fileListSingle="'" + for run in $runs + do + fileList+=$"$1/$2/$3/00000/$run, " + #echo "Input test1 " $test1 + + done + fileList=${fileList%??} + #fileListSingle+="'" + echo $fileList + + #cmsRun /afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_4_patch4/src/EcalTiming/EcalTiming/test/ecalTime_fromAlcaStream_cfg.py files="$fileList" + +fi + +echo $CMSSW_BASE +cd $CMSSW_BASE/src/EcalTiming/EcalTiming/test/ + + +if [ -z "$3" ]; then + cmsRun /afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_12_patch4/src/EcalTiming/EcalTiming/test/ecalTime_fromAlcaStreamHighPU_cfg.py files="$fileList" output="/afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_12_patch4/src/EcalTiming/EcalTiming/test/output/run"${firstFolder}${secondFolder}"_"${2}"_test_new.root" streamName=$2 jsonFile="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/DCSOnly/json_DCSONLY.txt" +else + + cmsRun /afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_12_patch4/src/EcalTiming/EcalTiming/test/ecalTime_fromAlcaStreamHighPU_cfg.py files="$fileList" output="/afs/cern.ch/work/s/sgelli/public/CMSSW_7_4_12_patch4/src/EcalTiming/EcalTiming/test/output/run"${2}${3}"_"${4}"_test_new.root" streamName=$4 jsonFile="/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/certification/Collisions15/13TeV/DCSOnly/json_DCSONLY.txt" + +fi + + +#cmsRun ecalTime_fromAlcaStream_cfg.py files='/store/data/Run2015A/AlCaP0/RAW/v1/000/246/908/00000/581F78FF-D909-E511-A356-02163E01231F.root, /store/data/Run2015A/AlCaP0/RAW/v1/000/246/908/00000/581F78FF-D909-E511-A356-02163E01231F.root' streamName=$4 diff --git a/EcalTiming/test/makeCalibPlots.sh b/EcalTiming/test/makeCalibPlots.sh index bde84e6..a8f570f 100755 --- a/EcalTiming/test/makeCalibPlots.sh +++ b/EcalTiming/test/makeCalibPlots.sh @@ -37,7 +37,7 @@ echo 'Making Calib Webpages for ' ${run_num} # specify directories here -work_dir=${CMSSW_BASE}'/src/CalibCalorimetry/EcalTiming/test/SCRIPTS' +work_dir=${CMSSW_BASE}'/src/EcalTiming/EcalTiming/test/SCRIPTS' plots_dir=plots/Calib/$run_num; mkdir $plots_dir @@ -51,7 +51,7 @@ cp ${work_dir}/Calib_${run_num}/${crab_dir}/res/${root_file} ${plots_dir} echo echo 'Now making plots, by running these command in ROOT:' echo -echo '.L '${CMSSW_BASE}'/src/CalibCalorimetry/EcalTiming/test/SCRIPTS/plotCalib.C' +echo '.L '${CMSSW_BASE}'/src/EcalTiming/EcalTiming/test/SCRIPTS/plotCalib.C' echo 'DrawCalibPlots("'${plots_dir}'/'${root_file}'",'${run_num}',kTRUE,"png","'${plots_dir}'",kFALSE)' echo @@ -62,7 +62,7 @@ cat > ${plots_dir}/plot.py < ${plots_dir}/plot.py < '${plots_dir}'/plotting.txt' -#echo '.L '${my_cmssw_base}'/CalibCalorimetry/EcalTiming/test/plotLaser.C' +#echo '.L '${my_cmssw_base}'/EcalTiming/EcalTiming/test/plotLaser.C' #echo 'DrawLaserPlots("'${plots_dir}'/'${Nroot_file}'","'${Nrun_num}'",kTRUE,"png","'${plots_dir}'",kFALSE,"${analy_type}","'${plot_file}'")' echo @@ -140,9 +140,9 @@ EcalTimingTTreePlotter ${plots_dir}/${Nroot_file} ${Nrun_num} 1 png ${plots_dir} #######AutoLibraryLoader.enable(); #######gSystem.Load('libDataFormatsFWLite.so') #######gSystem.Load('libDataFormatsPatCandidates.so') -#######gROOT.LoadMacro( '${my_cmssw_base}/CalibCalorimetry/EcalTiming/test/plotLaser.C++') +#######gROOT.LoadMacro( '${my_cmssw_base}/EcalTiming/EcalTiming/test/plotLaser.C++') #gSystem.Load('plotLaser_C.so') -#gROOT.ProcessLine( '.L ${my_cmssw_base}/CalibCalorimetry/EcalTiming/test/plotLaser.C++') +#gROOT.ProcessLine( '.L ${my_cmssw_base}/EcalTiming/EcalTiming/test/plotLaser.C++') #get my cute class #######from ROOT import DrawLaserPlots diff --git a/EcalTiming/test/mergeJason.sh b/EcalTiming/test/mergeJason.sh deleted file mode 100755 index a6a7a39..0000000 --- a/EcalTiming/test/mergeJason.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash - -usage='Usage: -r -d -o ' - -args=`getopt rd: -- "$@"` -if test $? != 0 - then - echo $usage - exit 1 -fi - -eval set -- "$args" -for i - do - case "$i" in - -r) shift; run_num=$2;shift;; - -d) shift; crab_dir=$2;shift;; - -o) shift; output_dir=$2;shift;; - -at) shift; analy_type=$2;shift;; - esac -done - - - -if [ "X"${analy_type} == "X" ] - then - analy_type="Laser" - echo " using default analysis type of Laser" -else - echo " doing analysis on ${analy_type} of events " -fi - -if [ "X"${run_num} == "X" ] - then - echo "INVALID RUN NUMBER! Please give a valid run number!" - echo $usage - exit -fi - - -if [ "X"${crab_dir} == "X" ] - then - crab_dir=`\ls -rt1 ${analy_type}_${run_num} | grep "crab_" | tail -1 | awk '{print $NF}'`; -# echo " using default output dir" ${crab_dir} -#else -# echo " using output dir "${crab_dir} -fi - -echo 'Merging CRAB output' ${run_num} 'crab_dir' ${crab_dir} - -cd ${analy_type}_${run_num}/${crab_dir}/res; -#pwd; - -# check root files -nroot=`\ls ${analy_type}_*root | grep -vc ${run_num}`; -nmergeroot=`\ls ${analy_type}_*root | grep -c ${run_num}`; -#echo $nmergeroot - -if [ "${nroot}" == "0" ] && [ "${nmergeroot}" == "0" ] -then - echo " NO root files" $nroot ".. exiting" - exit -else - echo " $nroot root files, $nmergeroot merged files" -fi - -#rm -f ${analy_type}_${run_num}.root -# now to hadd -hadd -f ${analy_type}_${run_num}.root ${analy_type}_*root - -if [ "${analy_type}" == "Laser" ] -then - echo "Running the laser combination analysis" - CheckEcalTiming.sh -p Run_${run_num} -ff True -ffn ${analy_type}_${run_num}.root -n 25 -t 25 -dt Laser -l 2 - ####rm -fr data - ####rm -fr conf - mv -f log/Timing${analy_type}_Run_${run_num}.*.root ${analy_type}_${run_num}.root - ####rm -fr log -fi - -if [ "${analy_type}" == "Timing" ] -then - echo "Running the Timing combination analysis" - #CheckEcalTiming.sh -p Run_${run_num} -ff True -ffn ${analy_type}_${run_num}.root -n 5 -t 25 -dt Physics -l 2 -aa 5.0 -as 0.0 -dr True - #######################CheckEcalTiming.sh -p Run_${run_num} -ff True -ffn ${analy_type}_${run_num}.root -n 0 -t 15 -dt Physics -l 2 -aa 5.0 -as 0.0 -dr True -tt True - ###rm -fr data - ###rm -fr conf - #######################mv -f log/TimingPhysics_Run_${run_num}.*.root ${analy_type}_${run_num}.root - echo "done" - ###rm -fr log -fi - - -# check log files -nstdout=`\ls -l CMSSW*stdout | wc | awk '{print $1}'`; -nmergeout=`\ls ${analy_type}_*log | grep -c ${run_num}`; -if [ "${nstdout}" == "0" ] #&& [ "${nmergeout}" == "0" ] -then - echo " NO stdout files" $nstdout - #exit -else - echo " $nstdout stdout files, $nmergeout merged files" - cat CMSSW*stdout > ${analy_type}_${run_num}.log -fi - -if [ "X"${output_dir} == "X" ] - then - output_dir=/castor/cern.ch/user/c/ccecal/${analy_type} - echo " use default output dir" $output_dir - rfmkdir ${output_dir} - rfchmod 775 ${output_dir} - rfcp ${analy_type}_${run_num}.log ${output_dir} - rfcp ${analy_type}_${run_num}.root ${output_dir} - rfchmod 775 ${output_dir}/${analy_type}_${run_num}.log - rfchmod 775 ${output_dir}/${analy_type}_${run_num}.root -else - echo " using output dir "${output_dir} - rfmkdir ${output_dir} - rfchmod 775 ${output_dir} - rfcp ${analy_type}_${run_num}.log ${output_dir} - rfcp ${analy_type}_${run_num}.root ${output_dir} - rfchmod 775 ${output_dir}/${analy_type}_${run_num}.log - rfchmod 775 ${output_dir}/${analy_type}_${run_num}.root - ####rm -f ${analy_type}_${run_num}.log -fi - -size=`\ls -l ${analy_type}_${run_num}.root | grep -c ${run_num}`; -echo $size - -if [ "${size}" == "0" ] -then - echo " Warning: your merged file has size ZERO.. will not delete root files." -else - echo -# echo " Warning: deleting root files" -# \ls ${analy_type}_*root | grep -v ${run_num} | awk '{print "rm -f "$NF}' |sh -fi - -#rm -rf CMSSW*stdout -#rm -rf CMSSW*stderr -#rm -rf crab*xml - -#\ls -l; - diff --git a/EcalTiming/test/moveifoncastor.csh b/EcalTiming/test/moveifoncastor.csh deleted file mode 100755 index 527fd30..0000000 --- a/EcalTiming/test/moveifoncastor.csh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/tcsh -f - - -foreach run ( `/bin/ls | grep "Laser_"`) -echo "Does $run exist on castor?" -if ( `rfdir /castor/cern.ch/user/c/ccecal/CRUZET4/CosmicsAnalysis/ | grep -c $run` > 0 ) then -echo "yes it is" -rm -rf $run -echo "now removed" -endif - -end - -#end of file diff --git a/EcalTiming/test/moveifoncastorCALIB.csh b/EcalTiming/test/moveifoncastorCALIB.csh deleted file mode 100755 index afa33ca..0000000 --- a/EcalTiming/test/moveifoncastorCALIB.csh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/tcsh -f - - -foreach run ( `/bin/ls | grep "Calib_"`) -echo "Does $run exist on castor?" - -if ( `rfdir /castor/cern.ch/user/c/ccecal/CRUZET4/Calibration | grep -c $run` < 1 ) then -echo "good it doesn't" -tar -cvf ${run}.tar $run -rfcp ${run}.tar run /castor/cern.ch/user/c/ccecal/CRUZET4/Calibration/. -rm -rf ${run}.tar $run -endif -end - -#end of file diff --git a/EcalTiming/test/moveifoncastorPLOTs.csh b/EcalTiming/test/moveifoncastorPLOTs.csh deleted file mode 100755 index c78ab3f..0000000 --- a/EcalTiming/test/moveifoncastorPLOTs.csh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/tcsh -f - -foreach typ ( Laser Timing ) - set typu=`echo $typ | tr "[:lower:]" "[:upper:]"` - echo $typu - foreach runf ( `/bin/ls plots/$typ/*/*.root`) - echo "File location is $runf" - echo "Does $runf:t exist on castor?" - echo "Looking in " - echo "/castor/cern.ch/user/c/ccecal/${typ} and /castor/cern.ch/user/c/ccecal/${typu}" - if ( `rfdir /castor/cern.ch/user/c/ccecal/$typ | grep -c $runf:t` > 0 ||`rfdir /castor/cern.ch/user/c/ccecal/$typu | grep -c $runf:t` > 0 ) then - echo "yes it is" - rm -rf $runf - echo "now removed" - else - echo "it needss to be moved: doing it now." - echo "..." - rfcp $runf /castor/cern.ch/user/c/ccecal/$typ/$runf:t - rm -rf $runf - endif - - end -end - -#end of file diff --git a/EcalTiming/test/plotCalib.C b/EcalTiming/test/plotCalib.C deleted file mode 100644 index 88584a5..0000000 --- a/EcalTiming/test/plotCalib.C +++ /dev/null @@ -1,373 +0,0 @@ - -int Wait() { - cout << " Continue [|q]? "; - char x; - x = getchar(); - if ((x == 'q') || (x == 'Q')) return 1; - return 0; -} - -void DrawCalibPlots(Char_t* infile = 0, Int_t runNum=0, Bool_t printPics = kTRUE, Char_t* fileType = "png", Char_t* dirName = ".", Bool_t doWait=kFALSE) -{ - - gROOT->SetStyle("Plain"); - //gStyle->SetPalette(1,0); - gStyle->SetOptStat(10); - - if (!infile) { - cout << " No input file specified !" << endl; - return; - } - - cout << "Producing Calib plots for: " << infile << endl; - - TFile* f = new TFile(infile); - f->cd(); //added by jason for completeness - f->cd("ecalCalibrationAnalyzer"); - f->ls(); - - int runNumber = 0; - runNumber = runNum; - - - char name[100]; - - const int nHists1=14; - const int nHists = nHists1; - // const int nHists = 9; - cout << nHists1 << " " << nHists << endl;; - - TCanvas* c[nHists]; - char cname[100]; - - for (int i=0; iSetNumberContours(5); - gStyle->SetPalette(5,colors); - //Simple Data Run Type - c[0]->cd(); - gStyle->SetOptStat(10); - TH2F *dataHeadRunType_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DdataHeadRunType_"); //NEEDED as I stupidly started the histo names with a number - if (dataHeadRunType_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dataHeadRunType_->GetTitle()); - dataHeadRunType_->SetFillColor(0); - dataHeadRunType_->SetTitle(mytitle); - dataHeadRunType_->SetMinimum(-1.5); - dataHeadRunType_->SetMaximum(3.5); - dataHeadRunType_->SetContour(5, levels); - dataHeadRunType_->Draw("colz"); - dataHeadRunType_->GetZaxis()->Set(5,-1.5,3.5); - dataHeadRunType_->GetZaxis()->SetBinLabel(1,"Unknown"); - dataHeadRunType_->GetZaxis()->SetBinLabel(2,"Empty"); - dataHeadRunType_->GetZaxis()->SetBinLabel(3,"Laser"); - dataHeadRunType_->GetZaxis()->SetBinLabel(4,"Testpulse"); - dataHeadRunType_->GetZaxis()->SetBinLabel(5,"Ped"); - dataHeadRunType_->GetZaxis()->SetLabelColor(kBlack); - dataHeadRunType_->GetZaxis()->SetLabelSize(0.06); - dataHeadRunType_->GetZaxis()->SetLabelOffset(-0.02); - dataHeadRunType_->GetZaxis()->SetTickLength(0); - - dataHeadRunType_->GetYaxis()->SetTitleOffset(1.37); - if (printPics) { sprintf(name,"%s/CalibAnalysis_simpleDataRunType_%i.%s",dirName,runNumber,fileType); c[0]->Print(name); } - } - - c[1]->cd(); - gStyle->SetOptStat(10); - TH2F *simpleHeadRunType_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DsimpleHeadRunType_"); //NEEDED as I stupidly started the histo names with a number - if (simpleHeadRunType_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,simpleHeadRunType_->GetTitle()); - simpleHeadRunType_->SetFillColor(0); - simpleHeadRunType_->SetTitle(mytitle); - simpleHeadRunType_->SetMinimum(-1.5); - simpleHeadRunType_->SetMaximum(3.5); - simpleHeadRunType_->SetContour(5, levels); - simpleHeadRunType_->Draw("colz"); - simpleHeadRunType_->GetZaxis()->Set(5,-1.5,3.5); - simpleHeadRunType_->GetZaxis()->SetBinLabel(1,"Unknown"); - simpleHeadRunType_->GetZaxis()->SetBinLabel(2,"Empty"); - simpleHeadRunType_->GetZaxis()->SetBinLabel(3,"Laser"); - simpleHeadRunType_->GetZaxis()->SetBinLabel(4,"Testpulse"); - simpleHeadRunType_->GetZaxis()->SetBinLabel(5,"Ped"); - simpleHeadRunType_->GetZaxis()->SetLabelColor(kBlack); - simpleHeadRunType_->GetZaxis()->SetLabelSize(0.06); - simpleHeadRunType_->GetZaxis()->SetLabelOffset(-0.02); - simpleHeadRunType_->GetZaxis()->SetTickLength(0); - - simpleHeadRunType_->GetYaxis()->SetTitleOffset(1.37); - if (printPics) { sprintf(name,"%s/CalibAnalysis_simpleHeadRunType_%i.%s",dirName,runNumber,fileType); c[1]->Print(name); } - } - - gStyle->SetNumberContours(20); - gStyle->SetPalette(0,0); - - c[2]->cd(); - gStyle->SetOptStat(10); - TH2F *dccHeadRunType_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DdccHeadRunType_"); //NEEDED as I stupidly started the histo names with a number - if (dccHeadRunType_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dccHeadRunType_->GetTitle()); - dccHeadRunType_->SetFillColor(0); - dccHeadRunType_->SetTitle(mytitle); - dccHeadRunType_->Draw("colz"); - dccHeadRunType_->GetZaxis()->SetTickLength(0.03); - - dccHeadRunType_->GetYaxis()->SetTitleOffset(1.37); - if (printPics) { sprintf(name,"%s/CalibAnalysis_dccHeadRunType_%i.%s",dirName,runNumber,fileType); c[2]->Print(name); } - } - gStyle->SetNumberContours(99); - gStyle->SetPalette(1,0); - - c[3]->cd(); - gStyle->SetOptStat(10); - TH2F *RunTypeByCycle_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DRunTypeByCycle_"); //NEEDED as I stupidly started the histo names with a number - if (RunTypeByCycle_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,RunTypeByCycle_->GetTitle()); - RunTypeByCycle_->SetFillColor(0); - RunTypeByCycle_->SetTitle(mytitle); - RunTypeByCycle_->Draw("colztext"); - RunTypeByCycle_->GetXaxis()->SetTickLength(0.03); - RunTypeByCycle_->GetXaxis()->SetBinLabel(1,"Unknown"); - RunTypeByCycle_->GetXaxis()->SetBinLabel(2,"Empty"); - RunTypeByCycle_->GetXaxis()->SetBinLabel(3,"Laser"); - RunTypeByCycle_->GetXaxis()->SetBinLabel(4,"Testpulse"); - RunTypeByCycle_->GetXaxis()->SetBinLabel(5,"Ped"); - RunTypeByCycle_->GetXaxis()->SetLabelSize(0.06); - RunTypeByCycle_->SetMinimum(1.0); - if (printPics) { sprintf(name,"%s/CalibAnalysis_RunTypeByCycle_%i.%s",dirName,runNumber,fileType); c[3]->Print(name); } - } - - c[4]->cd(); - gStyle->SetOptStat(10); - TH2F *LaserFEDCycle_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DLaserFEDCycle_"); //NEEDED as I stupidly started the histo names with a number - if (LaserFEDCycle_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,LaserFEDCycle_->GetTitle()); - LaserFEDCycle_->SetFillColor(0); - LaserFEDCycle_->SetTitle(mytitle); - LaserFEDCycle_->Draw("colztext"); - LaserFEDCycle_->GetZaxis()->SetTickLength(0.03); - LaserFEDCycle_->SetMinimum(1.0); - if (printPics) { sprintf(name,"%s/CalibAnalysis_LaserFEDCycle_%i.%s",dirName,runNumber,fileType); c[4]->Print(name); } - } - - c[5]->cd(); - gStyle->SetOptStat(10); - TH2F *PedFEDCycle_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DPedFEDCycle_"); //NEEDED as I stupidly started the histo names with a number - if (PedFEDCycle_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,PedFEDCycle_->GetTitle()); - PedFEDCycle_->SetFillColor(0); - PedFEDCycle_->SetTitle(mytitle); - PedFEDCycle_->Draw("colztext"); - PedFEDCycle_->GetZaxis()->SetTickLength(0.03); - PedFEDCycle_->SetMinimum(1.0); - if (printPics) { sprintf(name,"%s/CalibAnalysis_PedFEDCycle_%i.%s",dirName,runNumber,fileType); c[5]->Print(name); } - } - - c[6]->cd(); - gStyle->SetOptStat(10); - TH2F *TestPulseFEDCycle_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DTestPulseFEDCycle_"); //NEEDED as I stupidly started the histo names with a number - if (TestPulseFEDCycle_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,TestPulseFEDCycle_->GetTitle()); - TestPulseFEDCycle_->SetFillColor(0); - TestPulseFEDCycle_->SetTitle(mytitle); - TestPulseFEDCycle_->Draw("colztext"); - TestPulseFEDCycle_->GetZaxis()->SetTickLength(0.03); - TestPulseFEDCycle_->SetMinimum(1.0); - if (printPics) { sprintf(name,"%s/CalibAnalysis_TestPulseFEDCycle_%i.%s",dirName,runNumber,fileType); c[6]->Print(name); } - } - - c[7]->cd(); - gStyle->SetOptStat(10); - TH2F *UnknownFEDCycle_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/2DUnknownFEDCycle_"); //NEEDED as I stupidly started the histo names with a number - if (UnknownFEDCycle_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,UnknownFEDCycle_->GetTitle()); - UnknownFEDCycle_->SetFillColor(0); - UnknownFEDCycle_->SetTitle(mytitle); - UnknownFEDCycle_->Draw("colztext"); - UnknownFEDCycle_->GetZaxis()->SetTickLength(0.03); - UnknownFEDCycle_->SetMinimum(1.0); - if (printPics) { sprintf(name,"%s/CalibAnalysis_UnknownFEDCycle_%i.%s",dirName,runNumber,fileType); c[7]->Print(name); } - } - -//Average Amplitudes & DCC comparisons - const int mnHists=54; - TCanvas* ap[mnHists]; - char apname[100]; - for (int i=0; i -10) && ((!inEE) && SM < 10)) {inEE = true; sprintf(SMstr,"EE%s",SMstr); SM--;} else {inEE = false;sprintf(SMstr,"EB%s",SMstr) ;} - gStyle->SetOptStat(10); - TH1F *aveampHist = (TH1F*) f->Get(Form("ecalCalibrationAnalyzer/avgAmp_%s",SMstr)) ; //NEEDED as I stupidly started the histo names with a number - if (aveampHist){ - ap[ampdccanvas]->cd(); - char mytitle[100]; sprintf(mytitle,"%s %s; Event Number; Average Amplitude (ADC)",runChar,aveampHist->GetTitle()); - aveampHist->SetFillColor(0); - aveampHist->SetTitle(mytitle); - aveampHist->Draw(""); - ap[ampdccanvas]->SetLogy(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_aveampHist_%s_%i.%s", dirName,SMstr,runNumber,fileType); ap[ampdccanvas]->Print(name); } - } - - TCanvas *dccCan = (TCanvas*) f->Get(Form("ecalCalibrationAnalyzer/dccAndDataRunTypes_%s",SMstr)) ; //NEEDED as I stupidly started the histo names with a number - if (dccCan){ - dccCan->cd(); - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dccCan->GetTitle()); - dccCan->SetFillColor(0); - dccCan->SetTitle(mytitle); - dccCan->Draw(""); - - - if (printPics) { sprintf(name,"%s/CalibAnalysis_DccandDataHist_%s_%i.%s", dirName,SMstr,runNumber,fileType); dccCan->Print(name); } - } - - ampdccanvas++; - - } - - -// DCC Header Errors - c[8]->cd(); - gStyle->SetOptStat(10); - TH1F *dccHeaderErrors = (TH1F*) f->Get("ecalCalibrationAnalyzer/dccHeaderErrors"); //NEEDED as I stupidly started the histo names with a number - if (dccHeaderErrors){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dccHeaderErrors->GetTitle()); - dccHeaderErrors->SetFillColor(0); - dccHeaderErrors->SetMaximum(1.); - dccHeaderErrors->SetTitle(mytitle); - dccHeaderErrors->Draw(""); - dccHeaderErrors->GetXaxis()->SetBinLabel(1,"Data-to-DCC RunType Conflicts"); - dccHeaderErrors->GetXaxis()->SetBinLabel(2,"DCC RunType Conflicts"); - dccHeaderErrors->GetXaxis()->SetBinLabel(3,"RTHalf Conflict"); - c[8]->SetLogy(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_dccHeaderErrors%i.%s",dirName,runNumber,fileType); c[8]->Print(name); } - } - - c[9]->cd(); - gStyle->SetOptStat(10); - TH2F *dataRunTypeVsBX_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/TwoDdataRunTypeVsBX_"); - if (dataRunTypeVsBX_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dataRunTypeVsBX_->GetTitle()); - dataRunTypeVsBX_->SetFillColor(0); - dataRunTypeVsBX_->SetTitle(mytitle); - dataRunTypeVsBX_->Draw("colztext"); - dataRunTypeVsBX_->GetZaxis()->SetTickLength(0.03); - dataRunTypeVsBX_->SetMinimum(1.0); - dataRunTypeVsBX_->GetYaxis()->SetLabelOffset(-0.01); - c[9]->SetLogz(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_dataRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[9]->Print(name); } - dataRunTypeVsBX_->GetXaxis()->SetRangeUser(3490.,3490.); - dataRunTypeVsBX_->GetXaxis()->SetNdivisions(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_zoomdataRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[9]->Print(name); } - } - - c[10]->cd(); - gStyle->SetOptStat(10); - TH2F *dccRunTypeVsBX_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/TwoDdccRunTypeVsBX_"); - if (dccRunTypeVsBX_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dccRunTypeVsBX_->GetTitle()); - dccRunTypeVsBX_->SetFillColor(0); - dccRunTypeVsBX_->SetTitle(mytitle); - dccRunTypeVsBX_->Draw("colztext"); - dccRunTypeVsBX_->GetZaxis()->SetTickLength(0.03); - dccRunTypeVsBX_->SetMinimum(1.0); - dccRunTypeVsBX_->GetYaxis()->SetLabelOffset(-0.045); - c[10]->SetLogz(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_dccRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[10]->Print(name); } - dccRunTypeVsBX_->GetXaxis()->SetRangeUser(3490.,3490.); - dccRunTypeVsBX_->GetXaxis()->SetNdivisions(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_zoomdccRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[10]->Print(name); } - } - - c[11]->cd(); - gStyle->SetOptStat(10); - TH2F *simpledccRunTypeVsBX_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/TwoDsimpledccRunTypeVsBX_"); - if (simpledccRunTypeVsBX_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,simpledccRunTypeVsBX_->GetTitle()); - simpledccRunTypeVsBX_->SetFillColor(0); - simpledccRunTypeVsBX_->SetTitle(mytitle); - simpledccRunTypeVsBX_->Draw("colztext"); - simpledccRunTypeVsBX_->GetZaxis()->SetTickLength(0.03); - simpledccRunTypeVsBX_->SetMinimum(1.0); - simpledccRunTypeVsBX_->GetYaxis()->SetLabelOffset(-0.01); - c[11]->SetLogz(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_simpledccRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[11]->Print(name); } - simpledccRunTypeVsBX_->GetXaxis()->SetRangeUser(3490.,3490.); - simpledccRunTypeVsBX_->GetXaxis()->SetNdivisions(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_zoomsimpledccRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[11]->Print(name); } - } - - c[12]->cd(); - gStyle->SetOptStat(10); - TH2F *dccInTCCRunTypeVsBX_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/TwoDdccInTCCRunTypeVsBX_"); - if (dccInTCCRunTypeVsBX_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,dccInTCCRunTypeVsBX_->GetTitle()); - dccInTCCRunTypeVsBX_->SetFillColor(0); - dccInTCCRunTypeVsBX_->SetTitle(mytitle); - dccInTCCRunTypeVsBX_->Draw("colztext"); - dccInTCCRunTypeVsBX_->GetZaxis()->SetTickLength(0.03); - dccInTCCRunTypeVsBX_->SetMinimum(1.0); - dccInTCCRunTypeVsBX_->GetYaxis()->SetLabelOffset(-0.045); - c[12]->SetLogz(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_dccInTCCRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[12]->Print(name); } - dccInTCCRunTypeVsBX_->GetXaxis()->SetRangeUser(3490.,3490.); - dccInTCCRunTypeVsBX_->GetXaxis()->SetNdivisions(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_zoomdccInTCCRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[12]->Print(name); } - } - - c[13]->cd(); - gStyle->SetOptStat(10); - TH2F *simpledccInTCCRunTypeVsBX_ = (TH2F*) f->Get("ecalCalibrationAnalyzer/TwoDsimpledccInTCCRunTypeVsBX_"); - if (simpledccInTCCRunTypeVsBX_){ - char mytitle[100]; sprintf(mytitle,"%s %s",runChar,simpledccInTCCRunTypeVsBX_->GetTitle()); - simpledccInTCCRunTypeVsBX_->SetFillColor(0); - simpledccInTCCRunTypeVsBX_->SetTitle(mytitle); - simpledccInTCCRunTypeVsBX_->Draw("colztext"); - simpledccInTCCRunTypeVsBX_->GetZaxis()->SetTickLength(0.03); - simpledccInTCCRunTypeVsBX_->SetMinimum(1.0); - simpledccInTCCRunTypeVsBX_->GetYaxis()->SetLabelOffset(-0.01); - c[13]->SetLogz(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_simpledccInTCCRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[13]->Print(name); } - simpledccInTCCRunTypeVsBX_->GetXaxis()->SetRangeUser(3490.,3490.); - simpledccInTCCRunTypeVsBX_->GetXaxis()->SetNdivisions(1); - if (printPics) { sprintf(name,"%s/CalibAnalysis_zoomsimpledccInTCCRunTypeVsBX_%i.%s",dirName,runNumber,fileType); c[13]->Print(name); } - } - - - -cout << name << endl; - - - - return; - -} - - - - - diff --git a/EcalTiming/test/plotLaser.C b/EcalTiming/test/plotLaser.C deleted file mode 100644 index a9e931a..0000000 --- a/EcalTiming/test/plotLaser.C +++ /dev/null @@ -1,1188 +0,0 @@ -int Wait() { - cout << " Continue [|q]? "; - char x; - x = getchar(); - if ((x == 'q') || (x == 'Q')) return 1; - return 0; -} - -void DrawLaserPlots(Char_t* infile = 0, Int_t runNum=0, Bool_t printPics = kTRUE, Char_t* fileType = "png", Char_t* dirName = ".", Bool_t doWait=kFALSE, Char_t* mType = "Laser") -{ - - gROOT->SetStyle("Plain"); - gStyle->SetNumberContours(99); - gStyle->SetPalette(1,0); gStyle->SetOptStat(10); - - if (!infile) { - cout << " No input file specified !" << endl; - return; - } - - cout << "Producing Laser plots for: " << infile << endl; - - TFile* f = new TFile(infile); - f->cd(); //added by jason for completeness - - int runNumber = 0; - runNumber = runNum; - - - char name[100]; - char mytitle[200]; - - const int nHists1=80; - const int nHists = nHists1; - // const int nHists = 9; - cout << nHists1 << " " << nHists << endl;; - - TCanvas* c[nHists]; - char cname[100]; - - for (int i=0; icd(); - gStyle->SetOptStat(10); - TProfile *SM_timing = (TProfile*) f->Get("SM_timing"); - customizeTProfile(SM_timing); - SM_timing->Draw(); - sprintf(mytitle,"%s %s",runChar,SM_timing->GetTitle()); - SM_timing->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_SM_timing_%i.%s",dirName,mType,runNumber,fileType); c[0]->Print(name); } - - c[1]->cd(); - gStyle->SetOptStat(10); - TH1F *SM_timingh = CorrectProfToHist(SM_timing,"SM_timingh",-5,25.0); - customizeTHist(SM_timingh); - SM_timingh->Draw("p"); - sprintf(mytitle,"%s %s to optimal;FED;Time (ns)",runChar,SM_timing->GetTitle()); - SM_timingh->SetMinimum(-30.); - SM_timingh->SetMaximum(50.); - SM_timingh->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_SM_timingCorrected_%i.%s",dirName,mType,runNumber,fileType); c[1]->Print(name); } - - //Timing by LM - c[2]->cd(); - gStyle->SetOptStat(10); - TProfile *LM_timing = (TProfile*) f->Get("LM_timing"); - customizeTProfile(LM_timing); - LM_timing->Draw(); - sprintf(mytitle,"%s %s",runChar,LM_timing->GetTitle()); - LM_timing->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_LM_timing_%i.%s",dirName,mType,runNumber,fileType); c[2]->Print(name); } - - c[3]->cd(); - gStyle->SetOptStat(10); - TH1F *LM_timingh = CorrectProfToHist(LM_timing,"LM_timingh",-5,25.0); - customizeTHist(LM_timingh); - LM_timingh->Draw("p"); - sprintf(mytitle,"%s %s to optimal;FED;Time (ns)",runChar,LM_timing->GetTitle()); - LM_timingh->SetMinimum(-30.); - LM_timingh->SetMaximum(50.); - LM_timingh->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_LM_timingCorrected_%i.%s",dirName,mType,runNumber,fileType); c[3]->Print(name); } - - - //Timing within the towers - c[4]->cd(); - gStyle->SetOptStat(1111); - TProfile *Inside_TT_timing = (TProfile*) f->Get("Inside_TT_timing"); - Inside_TT_timing->Draw(); - sprintf(mytitle,"%s %s",runChar,Inside_TT_timing->GetTitle()); - Inside_TT_timing->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_Inside_TT_timing_%i.%s",dirName,mType,runNumber,fileType); c[4]->Print(name); } - - //Eta Profiles by TT - c[5]->cd(); - gStyle->SetOptStat(1111); - TProfile *timeTTAllFEDsEta = (TProfile*) f->Get("timeTTAllFEDsEta"); - timeTTAllFEDsEta->Draw(); - //timeTTAllFEDsEta->SetMinimum(4.95); - //timeTTAllFEDsEta->SetMaximum(5.05); - sprintf(mytitle,"%s %s",runChar,timeTTAllFEDsEta->GetTitle()); - timeTTAllFEDsEta->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEta_%i.%s",dirName,mType,runNumber,fileType); c[5]->Print(name); } - - c[6]->cd(); - gStyle->SetOptStat(1111); - TProfile *timeTTAllFEDsEtaEEP = (TProfile*) f->Get("timeTTAllFEDsEtaEEP"); - timeTTAllFEDsEtaEEP->Draw(); - //timeTTAllFEDsEtaEEP->SetMinimum(4.5); - //timeTTAllFEDsEtaEEP->SetMaximum(5.5); - sprintf(mytitle,"%s %s",runChar,timeTTAllFEDsEtaEEP->GetTitle()); - timeTTAllFEDsEtaEEP->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEtaEEP_%i.%s",dirName,mType,runNumber,fileType); c[6]->Print(name); } - - c[7]->cd(); - gStyle->SetOptStat(1111); - TProfile *timeTTAllFEDsEtaEEM = (TProfile*) f->Get("timeTTAllFEDsEtaEEM"); - timeTTAllFEDsEtaEEM->Draw(); - //timeTTAllFEDsEtaEEM->SetMinimum(4.5); - //timeTTAllFEDsEtaEEM->SetMaximum(5.5); - sprintf(mytitle,"%s %s",runChar,timeTTAllFEDsEtaEEM->GetTitle()); - timeTTAllFEDsEtaEEM->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEtaEEM_%i.%s",dirName,mType,runNumber,fileType); c[7]->Print(name); } - - //Eta profile by Ch - c[8]->cd(); - gStyle->SetOptStat(1111); - TProfile *timeCHAllFEDsEta = (TProfile*) f->Get("timeCHAllFEDsEta"); - timeCHAllFEDsEta->Draw(); - //timeCHAllFEDsEta->SetMinimum(4.8); - //timeCHAllFEDsEta->SetMaximum(5.2); - sprintf(mytitle,"%s %s",runChar,timeCHAllFEDsEta->GetTitle()); - timeCHAllFEDsEta->SetTitle(mytitle); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeCHAllFEDsEta_%i.%s",dirName,mType,runNumber,fileType); c[8]->Print(name); } - -//1-D Histograms - c[9]->cd(); - gStyle->SetOptStat(111110); - TH1F *Rel_TimingSigma = (TH1F*) f->Get("Rel_TimingSigma"); - Rel_TimingSigma->Draw(); - sprintf(mytitle,"%s %s",runChar,Rel_TimingSigma->GetTitle()); - Rel_TimingSigma->SetTitle(mytitle); - c[9]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_Rel_TimingSigma_%i.%s",dirName,mType,runNumber,fileType); c[9]->Print(name); } - - c[10]->cd(); - gStyle->SetOptStat(111110); - TH1F *XtalsPerEvt = (TH1F*) f->Get("XtalsPerEvt"); - XtalsPerEvt->Draw(); - //XtalsPerEvt->GetXaxis()->SetRangeUser(0,100); - sprintf(mytitle,"%s %s",runChar,XtalsPerEvt->GetTitle()); - XtalsPerEvt->SetTitle(mytitle); - //c[10]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_XtalsPerEvt_%i.%s",dirName,mType,runNumber,fileType); c[10]->Print(name); } - - c[11]->cd(); - gStyle->SetOptStat(111110); - TH1F *laserShift = (TH1F*) f->Get("laserShift"); - laserShift->Draw(); - sprintf(mytitle,"%s %s",runChar,laserShift->GetTitle()); - laserShift->SetTitle(mytitle); - c[11]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_laserShift_%i.%s",dirName,mType,runNumber,fileType); c[11]->Print(name); } - -//2-D Histogram - c[12]->cd(); - gStyle->SetOptStat(111110); - TH2F *RelRMS_vs_AbsTime = (TH2F*) f->Get("RelRMS_vs_AbsTime"); - RelRMS_vs_AbsTime->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,RelRMS_vs_AbsTime->GetTitle()); - RelRMS_vs_AbsTime->SetTitle(mytitle); - c[12]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_RelRMS_vs_AbsTime_%i.%s",dirName,mType,runNumber,fileType); c[12]->Print(name); } - -//1-D TGraphs - c[13]->cd(); - gStyle->SetOptStat(111110); - TGraph *TTMeanWithRMS_All_FEDS = (TGraph*) f->Get("TTMeanWithRMS_All_FEDS"); - sprintf(mytitle,"%s %s",runChar,TTMeanWithRMS_All_FEDS->GetTitle()); - TTMeanWithRMS_All_FEDS->SetTitle(mytitle); - TTMeanWithRMS_All_FEDS->GetYaxis()->SetLimits(5.,6.); - //TTMeanWithRMS_All_FEDS->GetYaxis()->SetLimits(4.,6.); - TTMeanWithRMS_All_FEDS->GetYaxis()->UnZoom(); - TTMeanWithRMS_All_FEDS->Draw("AP*"); - //c[13]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_TTMeanWithRMS_All_FEDS_%i.%s",dirName,mType,runNumber,fileType); c[13]->Print(name); } - - c[14]->cd(); - gStyle->SetOptStat(111110); - TGraph *TTMeanWithRMS_All_FEDS_CHANGED = (TGraph*) f->Get("TTMeanWithRMS_All_FEDS_CHANGED"); - sprintf(mytitle,"%s %s",runChar,TTMeanWithRMS_All_FEDS_CHANGED->GetTitle()); - TTMeanWithRMS_All_FEDS_CHANGED->SetTitle(mytitle); - TTMeanWithRMS_All_FEDS_CHANGED->GetYaxis()->SetLimits(-5.,5.); - //TTMeanWithRMS_All_FEDS_CHANGED->GetYaxis()->SetLimits(4.,6.); - TTMeanWithRMS_All_FEDS_CHANGED->GetYaxis()->UnZoom(); - TTMeanWithRMS_All_FEDS_CHANGED->Draw("AP*"); - //c[13]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_TTMeanWithRMS_All_FEDS_Corrected_%i.%s",dirName,mType,runNumber,fileType); c[14]->Print(name); } - -//2-D TGraphs/Profiles - //Ch by Ch timing profile - c[15]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeCHProfile = (TProfile2D*) f->Get("timeCHProfile"); - timeCHProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,timeCHProfile->GetTitle()); - timeCHProfile->SetTitle(mytitle); - timeCHProfile->SetMinimum(4.0); - //timeCHProfile->SetMinimum(4.5); - //timeCHProfile->SetMaximum(5.5); - timeCHProfile->GetXaxis()->SetNdivisions(-18); - timeCHProfile->GetYaxis()->SetNdivisions(2); - c[15]->SetLogy(0); - c[15]->SetLogz(0); - c[15]->SetGridx(1); - c[15]->SetGridy(1); - //c[15]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[15]->Print(name); } - - c[15]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeCHProfilep = TProfToRelProf2D(timeCHProfile,"timeCHProfilep", -5., 25.); - timeCHProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",timeCHProfile->GetTitle()); - timeCHProfilep->SetTitle(mytitle); - timeCHProfilep->SetMinimum(-10.); - timeCHProfilep->SetMaximum(30.); - //timeTTProfile->SetMinimum(5.85); - //timeTTProfile->SetMinimum(4.8); - //timeTTProfile->SetMaximum(6.45); - timeCHProfilep->GetXaxis()->SetNdivisions(-18); - timeCHProfilep->GetYaxis()->SetNdivisions(2); - c[15]->SetLogy(0); - c[15]->SetLogz(0); - c[15]->SetGridx(1); - c[15]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeCHProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[15]->Print(name); } - //TT by TT timing profile - - c[39]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeCHProfileO = TProfile2DOccupancyFromProf2D(timeCHProfile,"timeCHProfileO"); - timeCHProfileO->Draw("colz"); - sprintf(mytitle,"CH occupancy"); - timeCHProfileO->SetTitle(mytitle); - timeCHProfileO->SetMinimum(1.); - timeCHProfileO->GetXaxis()->SetNdivisions(-18); - timeCHProfileO->GetYaxis()->SetNdivisions(2); - c[39]->SetLogy(0); - c[39]->SetLogz(1); - c[39]->SetGridx(1); - c[39]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_OccuCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[39]->Print(name); } - - c[16]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeTTProfile = (TProfile2D*) f->Get("timeTTProfile"); - timeTTProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,timeTTProfile->GetTitle()); - timeTTProfile->SetTitle(mytitle); - timeTTProfile->SetMinimum(4.0); - //timeTTProfile->SetMinimum(5.85); - //timeTTProfile->SetMinimum(4.8); - //timeTTProfile->SetMaximum(6.45); - timeTTProfile->GetXaxis()->SetNdivisions(-18); - timeTTProfile->GetYaxis()->SetNdivisions(2); - c[16]->SetLogy(0); - c[16]->SetLogz(1); - c[16]->SetGridx(1); - c[16]->SetGridy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[16]->Print(name); } - - c[16]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeTTProfilep = TProfToRelProf2D(timeTTProfile,"timeTTProfilep", -5., 25.); - timeTTProfilep->SetContour(10); - timeTTProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",timeTTProfile->GetTitle()); - timeTTProfilep->SetTitle(mytitle); - timeTTProfilep->SetMinimum(6.); - timeTTProfilep->SetMaximum(16.); - - - //timeTTProfile->SetMinimum(5.85); - //timeTTProfile->SetMinimum(4.8); - //timeTTProfile->SetMaximum(6.45); - timeTTProfilep->GetXaxis()->SetNdivisions(-18); - timeTTProfilep->GetYaxis()->SetNdivisions(2); - c[16]->SetLogy(0); - c[16]->SetLogz(0); - c[16]->SetGridx(1); - c[16]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[16]->Print(name); } - - c[40]->cd(); - gStyle->SetOptStat(10); - TProfile2D *timeTTProfileO = TProfile2DOccupancyFromProf2D(timeTTProfile,"timeTTProfileO"); - timeTTProfileO->Draw("colz"); - sprintf(mytitle,"TT occupancy"); - timeTTProfileO->SetTitle(mytitle); - timeTTProfileO->SetMinimum(1.); - timeTTProfileO->GetXaxis()->SetNdivisions(-18); - timeTTProfileO->GetYaxis()->SetNdivisions(2); - c[40]->SetLogy(0); - c[40]->SetLogz(1); - c[40]->SetGridx(1); - c[40]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_OccuTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[40]->Print(name); } - //Ch by Ch timing profile EE+ - c[17]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeCHProfile = (TProfile2D*) f->Get("EEPtimeCHProfile"); - EEPtimeCHProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,EEPtimeCHProfile->GetTitle()); - EEPtimeCHProfile->SetTitle(mytitle); - EEPtimeCHProfile->SetMinimum(4.0); - //EEPtimeCHProfile->SetMinimum(4.5); - //EEPtimeCHProfile->SetMaximum(5.5); - EEPtimeCHProfile->GetXaxis()->SetNdivisions(18); - c[17]->SetLogy(0); - c[17]->SetLogz(0); - drawEELines(); - //c[15]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPtimeCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[17]->Print(name); } - - c[17]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeCHProfilep = TProfToRelProf2D(EEPtimeCHProfile,"EEPtimeCHProfilep", -5., 25.); - EEPtimeCHProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",EEPtimeCHProfilep->GetTitle()); - EEPtimeCHProfilep->SetTitle(mytitle); - EEPtimeCHProfilep->SetMinimum(-30.); - EEPtimeCHProfilep->SetMaximum(50.); - //EEPtimeCHProfile->SetMinimum(4.5); - //EEPtimeCHProfile->SetMaximum(5.5); - EEPtimeCHProfilep->GetXaxis()->SetNdivisions(18); - c[17]->SetLogy(0); - c[17]->SetLogz(0); - drawEELines(); - //c[15]->SetLogz(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPtimeCHProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[17]->Print(name); } - - c[41]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeCHProfileO = TProfile2DOccupancyFromProf2D(EEPtimeCHProfile,"EEPtimeCHProfileO"); - EEPtimeCHProfileO->Draw("colz"); - sprintf(mytitle,"CH occupancy"); - EEPtimeCHProfileO->SetTitle(mytitle); - EEPtimeCHProfileO->SetMinimum(1.); - c[41]->SetLogy(0); - c[41]->SetLogz(1); - drawEELines(); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPOccuCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[41]->Print(name); } - //Ch by Ch timing profile EE+ - c[18]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeCHProfile = (TProfile2D*) f->Get("EEMtimeCHProfile"); - EEMtimeCHProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,EEMtimeCHProfile->GetTitle()); - EEMtimeCHProfile->SetTitle(mytitle); - EEMtimeCHProfile->SetMinimum(4.); - //EEMtimeCHProfile->SetMinimum(4.5); - //EEMtimeCHProfile->SetMaximum(5.5); - EEMtimeCHProfile->GetXaxis()->SetNdivisions(18); - c[18]->SetLogy(0); - c[18]->SetLogz(1); - drawEELines(); - //c[15]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMtimeCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[18]->Print(name); } - - c[18]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeCHProfilep = TProfToRelProf2D(EEMtimeCHProfile,"EEMtimeCHProfilep", -5., 25.); - EEMtimeCHProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",EEMtimeCHProfilep->GetTitle()); - EEMtimeCHProfilep->SetTitle(mytitle); - EEMtimeCHProfilep->SetMinimum(-30.); - EEMtimeCHProfilep->SetMaximum(50.); - //EEPtimeCHProfile->SetMinimum(4.5); - //EEPtimeCHProfile->SetMaximum(5.5); - EEMtimeCHProfilep->GetXaxis()->SetNdivisions(18); - c[18]->SetLogy(0); - c[18]->SetLogz(0); - drawEELines(); - //c[15]->SetLogz(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMtimeCHProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[18]->Print(name); } - - c[42]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeCHProfileO = TProfile2DOccupancyFromProf2D(EEMtimeCHProfile,"EEMtimeCHProfileO"); - EEMtimeCHProfileO->Draw("colz"); - sprintf(mytitle,"CH occupancy"); - EEMtimeCHProfileO->SetTitle(mytitle); - EEMtimeCHProfileO->SetMinimum(1.); - c[42]->SetLogy(0); - c[42]->SetLogz(1); - drawEELines(); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMOccuCHProfile_%i.%s",dirName,mType,runNumber,fileType); c[42]->Print(name); } - //TT by TT timing profile EE+ - c[19]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeTTProfile = (TProfile2D*) f->Get("EEPtimeTTProfile"); - EEPtimeTTProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,EEPtimeTTProfile->GetTitle()); - EEPtimeTTProfile->SetTitle(mytitle); - EEPtimeTTProfile->SetMinimum(4.); - //EEPtimeTTProfile->SetMinimum(4.5); - //EEPtimeTTProfile->SetMaximum(5.5); - EEPtimeTTProfile->GetXaxis()->SetNdivisions(18); - c[19]->SetLogy(0); - c[19]->SetLogz(1); - drawEELines(); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPtimeTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[19]->Print(name); } - - - c[19]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeTTProfilep = TProfToRelProf2D(EEPtimeTTProfile,"EEPtimeTTProfilep", -5., 25.); - EEPtimeTTProfilep->SetContour(10); - EEPtimeTTProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",EEPtimeTTProfile->GetTitle()); - EEPtimeTTProfilep->SetTitle(mytitle); - EEPtimeTTProfilep->SetMinimum(6.); - EEPtimeTTProfilep->SetMaximum(16.); - - //timeTTProfile->SetMinimum(5.85); - //timeTTProfile->SetMinimum(4.8); - //timeTTProfile->SetMaximum(6.45); - EEPtimeTTProfilep->GetXaxis()->SetNdivisions(18); - //EEPtimeTTProfilep->GetYaxis()->SetNdivisions(2); - drawEELines(); - c[19]->SetLogy(0); - c[19]->SetLogz(0); - // c[19]->SetGridx(1); - //c[19]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPtimeTTProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[19]->Print(name); } - c[44]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEPtimeTTProfileO = TProfile2DOccupancyFromProf2D(EEPtimeTTProfile,"EEPtimeTTProfileO"); - EEPtimeTTProfileO->Draw("colz"); - sprintf(mytitle,"TT occupancy"); - EEPtimeTTProfileO->SetTitle(mytitle); - EEPtimeTTProfileO->SetMinimum(1.); - c[44]->SetLogy(0); - c[44]->SetLogz(1); - drawEELines(); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPOccuTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[44]->Print(name); } - - //TT by TT timing profile EE- - c[20]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeTTProfile = (TProfile2D*) f->Get("EEMtimeTTProfile"); - EEMtimeTTProfile->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,EEMtimeTTProfile->GetTitle()); - EEMtimeTTProfile->SetTitle(mytitle); - EEMtimeTTProfile->SetMinimum(4.); - //EEMtimeTTProfile->SetMinimum(4.5); - //EEMtimeTTProfile->SetMaximum(5.5); - EEMtimeTTProfile->GetXaxis()->SetNdivisions(18); - c[20]->SetLogy(0); - c[20]->SetLogz(1); - drawEELines(); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMtimeTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[20]->Print(name); } - - c[20]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeTTProfilep = TProfToRelProf2D(EEMtimeTTProfile,"EEMtimeTTProfilep", -5., 25.); - - EEMtimeTTProfilep->Draw("colz"); - sprintf(mytitle,"%s in ns",EEMtimeTTProfile->GetTitle()); - EEMtimeTTProfilep->SetTitle(mytitle); - EEMtimeTTProfilep->SetContour(10); - EEMtimeTTProfilep->SetMinimum(6.); - EEMtimeTTProfilep->SetMaximum(16.); - - //timeTTProfile->SetMinimum(5.85); - //timeTTProfile->SetMinimum(4.8); - //timeTTProfile->SetMaximum(6.45); - EEMtimeTTProfilep->GetXaxis()->SetNdivisions(18); - //EEMtimeTTProfilep->GetYaxis()->SetNdivisions(2); - c[20]->SetLogy(0); - c[20]->SetLogz(0); - drawEELines(); - //c[20]->SetGridx(1); - //c[20]->SetGridy(1); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMtimeTTProfileRel_%i.%s",dirName,mType,runNumber,fileType); c[20]->Print(name); } - c[43]->cd(); - gStyle->SetOptStat(10); - TProfile2D *EEMtimeTTProfileO = TProfile2DOccupancyFromProf2D(EEMtimeTTProfile,"EEMtimeTTProfileO"); - EEMtimeTTProfileO->Draw("colz"); - sprintf(mytitle,"TT occupancy"); - EEMtimeTTProfileO->SetTitle(mytitle); - EEMtimeTTProfileO->SetMinimum(1.); - c[43]->SetLogy(0); - c[43]->SetLogz(1); - drawEELines(); - gStyle->SetOptStat(0); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMOccuTTProfile_%i.%s",dirName,mType,runNumber,fileType); c[43]->Print(name); } - - //Amplitude Profiles - c[21]->cd(); - gStyle->SetOptStat(10); - TProfile2D *fullAmpProfileEB = (TProfile2D*) f->Get("fullAmpProfileEB"); - fullAmpProfileEB->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,fullAmpProfileEB->GetTitle()); - fullAmpProfileEB->SetTitle(mytitle); - if (fullAmpProfileEB->GetMaximum() > 0 ) { - fullAmpProfileEB->SetMinimum(0.1); - c[21]->SetLogy(0); - c[21]->SetLogz(1); - } - if (printPics) { sprintf(name,"%s/%sAnalysis_fullAmpProfileEB_%i.%s",dirName,mType,runNumber,fileType); c[21]->Print(name); } - - c[22]->cd(); - gStyle->SetOptStat(10); - TProfile2D *fullAmpProfileEEP = (TProfile2D*) f->Get("fullAmpProfileEEP"); - fullAmpProfileEEP->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,fullAmpProfileEEP->GetTitle()); - fullAmpProfileEEP->SetTitle(mytitle); - if (fullAmpProfileEEP->GetMaximum() > 0 ) { - fullAmpProfileEEP->SetMinimum(0.1); - c[22]->SetLogy(0); - c[22]->SetLogz(1); - } - drawEELines(); - if (printPics) { sprintf(name,"%s/%sAnalysis_fullAmpProfileEEP_%i.%s",dirName,mType,runNumber,fileType); c[22]->Print(name); } - - c[23]->cd(); - gStyle->SetOptStat(10); - TProfile2D *fullAmpProfileEEM = (TProfile2D*) f->Get("fullAmpProfileEEM"); - fullAmpProfileEEM->Draw("colz"); - sprintf(mytitle,"%s %s",runChar,fullAmpProfileEEM->GetTitle()); - fullAmpProfileEEM->SetTitle(mytitle); - if (fullAmpProfileEEM->GetMaximum() > 0 ) { - fullAmpProfileEEM->SetMinimum(0.1); - c[23]->SetLogy(0); - c[23]->SetLogz(1); - } - drawEELines(); - if (printPics) { sprintf(name,"%s/%sAnalysis_fullAmpProfileEEM_%i.%s",dirName,mType,runNumber,fileType); c[23]->Print(name); } - - - //Eta Profiles by TT Normalized - c[24]->cd(); - TProfile *timeTTAllFEDsEtap = TProfToRelProf(timeTTAllFEDsEta,"timeTTAllFEDsEtap",-5,25.); - customizeTProfile(timeTTAllFEDsEtap); - timeTTAllFEDsEtap->Draw("p"); - timeTTAllFEDsEtap->SetMinimum(-30.); - timeTTAllFEDsEtap->SetMaximum(50.); - sprintf(mytitle,"%s to optimal;i#eta;Time (ns)",timeTTAllFEDsEta->GetTitle()); - timeTTAllFEDsEtap->SetTitle(mytitle); - gStyle->SetOptStat(100); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEtaRel_%i.%s",dirName,mType,runNumber,fileType); c[24]->Print(name); } - - c[25]->cd(); - TProfile *timeTTAllFEDsEtaEEPp = TProfToRelProf(timeTTAllFEDsEtaEEP,"timeTTAllFEDsEtaEEPp",-5,25.); - customizeTProfile(timeTTAllFEDsEtaEEPp); - timeTTAllFEDsEtaEEPp->Draw("p"); - timeTTAllFEDsEtaEEPp->SetMinimum(-30.); - timeTTAllFEDsEtaEEPp->SetMaximum(50.); - sprintf(mytitle,"%s to optimal;i#eta;Time (ns)",timeTTAllFEDsEtaEEP->GetTitle()); - timeTTAllFEDsEtaEEPp->SetTitle(mytitle); - gStyle->SetOptStat(100); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEtaEEPRel_%i.%s",dirName,mType,runNumber,fileType); c[25]->Print(name); } - - c[26]->cd(); - TProfile *timeTTAllFEDsEtaEEMp = TProfToRelProf(timeTTAllFEDsEtaEEM,"timeTTAllFEDsEtaEEMp",-5,25.); - customizeTProfile(timeTTAllFEDsEtaEEMp); - timeTTAllFEDsEtaEEMp->Draw("p"); - timeTTAllFEDsEtaEEMp->SetMinimum(-30.); - timeTTAllFEDsEtaEEMp->SetMaximum(50.); - sprintf(mytitle,"%s to optimal;i#eta;Time (ns)",timeTTAllFEDsEtaEEM->GetTitle()); - timeTTAllFEDsEtaEEMp->SetTitle(mytitle); - gStyle->SetOptStat(100); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeTTAllFEDsEtaEEMRel_%i.%s",dirName,mType,runNumber,fileType); c[26]->Print(name); } - - //Eta profile by Ch - c[27]->cd(); - gStyle->SetOptStat(1111); - TProfile *timeCHAllFEDsEta = (TProfile*) f->Get("timeCHAllFEDsEta"); - timeCHAllFEDsEta->Draw(); - TProfile *timeCHAllFEDsEtap = TProfToRelProf(timeCHAllFEDsEta,"timeCHAllFEDsEtap",-5,25.); - customizeTProfile(timeCHAllFEDsEtap); - timeCHAllFEDsEtap->Draw("p"); - timeCHAllFEDsEtap->SetMinimum(-30.); - timeCHAllFEDsEtap->SetMaximum(50.); - sprintf(mytitle,"%s to optimal;i#eta;Time (ns)",timeCHAllFEDsEta->GetTitle()); - timeCHAllFEDsEtap->SetTitle(mytitle); - gStyle->SetOptStat(100); - if (printPics) { sprintf(name,"%s/%sAnalysis_timeCHAllFEDsEtaRel_%i.%s",dirName,mType,runNumber,fileType); c[27]->Print(name); } - - //+_+_+_+_+_+_+_+_+__-----------------------------+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_ - //Now it is time to see if the timing tree is there and use the individual ntuple information - - char ebhashfilter[500]; - char eehashfilter[3000]; - sprintf(ebhashfilter,"crystalHashedIndicesEB != 25822 && crystalHashedIndicesEB != 32705 && crystalHashedIndicesEB != 56473"); - sprintf(eehashfilter,"crystalHashedIndicesEE != 11658 && crystalHashedIndicesEE != 11742 && crystalHashedIndicesEE != 10224 && crystalHashedIndicesEE != 10225 && crystalHashedIndicesEE != 10226 && crystalHashedIndicesEE != 10310 && crystalHashedIndicesEE != 10311 && crystalHashedIndicesEE != 10394 && crystalHashedIndicesEE != 10395 && crystalHashedIndicesEE != 10875 && crystalHashedIndicesEE != 11316 && crystalHashedIndicesEE != 11659 && crystalHashedIndicesEE != 11660 && crystalHashedIndicesEE != 11661 && crystalHashedIndicesEE != 11743 && crystalHashedIndicesEE != 11744 && crystalHashedIndicesEE != 11744 && crystalHashedIndicesEE != 11745 && crystalHashedIndicesEE != 11932 && crystalHashedIndicesEE != 11746 && crystalHashedIndicesEE != 12702 && crystalHashedIndicesEE != 4252 && crystalHashedIndicesEE != 4335 && crystalHashedIndicesEE != 4337 && crystalHashedIndicesEE != 4419 && crystalHashedIndicesEE != 4423 && crystalHashedIndicesEE != 4785 && crystalHashedIndicesEE != 6181 && crystalHashedIndicesEE != 14613 && crystalHashedIndicesEE != 13726 && crystalHashedIndicesEE != 13727 && crystalHashedIndicesEE != 7717 && crystalHashedIndicesEE != 7778 && crystalHashedIndicesEE != 4420 && crystalHashedIndicesEE != 4421 && crystalHashedIndicesEE != 4423 && crystalHashedIndicesEE != 2946 && crystalHashedIndicesEE != 2900 && crystalHashedIndicesEE != 2902 && crystalHashedIndicesEE != 2901 && crystalHashedIndicesEE != 2903 && crystalHashedIndicesEE != 2904 && crystalHashedIndicesEE != 2905 && crystalHashedIndicesEE != 2986 && crystalHashedIndicesEE != 2987 && crystalHashedIndicesEE != 2988 && crystalHashedIndicesEE != 2989 && crystalHashedIndicesEE != 3070 && crystalHashedIndicesEE != 3071 && crystalHashedIndicesEE != 4252 && crystalHashedIndicesEE != 4253 && crystalHashedIndicesEE != 4254 && crystalHashedIndicesEE != 4255 && crystalHashedIndicesEE != 4256"); - - char ebtimefilter[100]; - char eetimefilter[100]; - sprintf(ebtimefilter,"(crystalTimeErrorsEB)*25. < 5.0"); - sprintf(eetimefilter,"(crystalTimeErrorsEE)*25. < 5.0"); - - char ebfilter[500]; - char eefilter[3100]; - sprintf(ebfilter,"(%s) && (%s)",ebtimefilter,ebhashfilter); - sprintf(eefilter,"(%s) && (%s)",eetimefilter,eehashfilter); - - char eepfilter[3200]; - char eemfilter[3200]; - sprintf(eepfilter,"(%s) && (crystalHashedIndicesEE > 7341)",eefilter); - sprintf(eemfilter,"(%s) && (crystalHashedIndicesEE < 7342)",eefilter); - - TTree* eventTimingInfoTree = ((TTree*) f->Get("eventTimingInfoTree")); - if (!eventTimingInfoTree) { std::cout << " No TTree in the event, probalby expected" << std::endl; cout << name << endl; return;} - //Now, we will only do the below if there is a TTree in the event. - c[28]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEB-5.)*25. >> hctEB(tbins,tbinsL,tbinsH)",ebhashfilter); - sprintf(mytitle,"%s EB Crystal Times;Time (ns);Number of Crystals",runChar); - hctEB->SetTitle(mytitle); - hctEB->GetXaxis()->SetNdivisions(512); - hctEB->Fit("gaus"); - gStyle->SetOptFit(111); - c[28]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMES_%i.%s",dirName,mType,runNumber,fileType); c[28]->Print(name); } - - eventTimingInfoTree->Draw("(crystalTimesEB-5.)*25. >> hctEBf(tbins,tbinsL,tbinsH)",ebfilter); - sprintf(mytitle,"%s EB Crystal Times (Error Filtered);Time (ns);Number of Crystals",runChar); - hctEBf->SetTitle(mytitle); - hctEBf->GetXaxis()->SetNdivisions(512); - hctEBf->Fit("gaus"); - gStyle->SetOptFit(111); - c[28]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMESFILT_%i.%s",dirName,mType,runNumber,fileType); c[28]->Print(name); } - - c[29]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEE-5.)*25. >> hctEE(tbins,tbinsL,tbinsH)",eehashfilter); - sprintf(mytitle,"%s EE Crystal Times;Time (ns);Number of Crystals",runChar); - hctEE->SetTitle(mytitle); - c[29]->SetLogy(1); - hctEE->GetXaxis()->SetNdivisions(512); - hctEE->Fit("gaus"); - gStyle->SetOptFit(111); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMES_%i.%s",dirName,mType,runNumber,fileType); c[29]->Print(name); } - eventTimingInfoTree->Draw("(crystalTimesEE-5.)*25. >> hctEEf(tbins,tbinsL,tbinsH)",eefilter); - sprintf(mytitle,"%s EE Crystal Times (Error Filtered);Time (ns);Number of Crystals",runChar); - hctEEf->SetTitle(mytitle); - c[29]->SetLogy(1); - hctEEf->GetXaxis()->SetNdivisions(512); - hctEEf->Fit("gaus"); - gStyle->SetOptFit(111); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMESFILT_%i.%s",dirName,mType,runNumber,fileType); c[29]->Print(name); } - - c[54]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEE-5.)*25. >> hctEEp(tbins,tbinsL,tbinsH)",eepfilter); - sprintf(mytitle,"%s EE+ Crystal Times;Time (ns);Number of Crystals",runChar); - hctEEp->SetTitle(mytitle); - c[54]->SetLogy(1); - hctEEp->GetXaxis()->SetNdivisions(512); - hctEEp->Fit("gaus"); - gStyle->SetOptFit(111); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPTIMES_%i.%s",dirName,mType,runNumber,fileType); c[54]->Print(name); } - - c[55]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEE-5.)*25. >> hctEEm(tbins,tbinsL,tbinsH)",eemfilter); - sprintf(mytitle,"%s EE- Crystal Times;Time (ns);Number of Crystals",runChar); - hctEEm->SetTitle(mytitle); - c[55]->SetLogy(1); - hctEEm->GetXaxis()->SetNdivisions(512); - hctEEm->Fit("gaus"); - gStyle->SetOptFit(111); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMTIMES_%i.%s",dirName,mType,runNumber,fileType); c[55]->Print(name); } - - - //Time to average event time - c[30]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(correctionToSampleEB-5.)*25.:(crystalTimesEE-5.)*25. >> hctEEtoAve(tbins,tbinsL,tbinsH,tbins,tbinsL,tbinsH)", eehashfilter, "COLZ"); - sprintf(mytitle,"%s EE Crystal Times to Average Time;Crystal Time (ns);Average EB Event Time (ns)",runChar); - //hctEEtoAve->Draw; - hctEEtoAve->SetTitle(mytitle); - hctEEtoAve->GetXaxis()->SetNdivisions(512); - hctEEtoAve->GetYaxis()->SetNdivisions(512); - c[30]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMEStoAverage_%i.%s",dirName,mType,runNumber,fileType); c[30]->Print(name); } - c[31]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(correctionToSampleEB-5.)*25.:(crystalTimesEB-5.)*25. >> hctEBtoAve(tbins,tbinsL,tbinsH,tbins,tbinsL,tbinsH)", ebhashfilter, "COLZ"); - sprintf(mytitle,"%s EB Crystal Times to Average Time;Crystal Time (ns);Average EB Event Time (ns)",runChar); - //hctEEtoAve->Draw; - hctEBtoAve->SetTitle(mytitle); - hctEBtoAve->GetXaxis()->SetNdivisions(512); - hctEBtoAve->GetYaxis()->SetNdivisions(512); - c[31]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMEStoAverage_%i.%s",dirName,mType,runNumber,fileType); c[31]->Print(name); } - - //Time to Time error - c[32]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimeErrorsEB)*25.:(crystalTimesEB-5.)*25. >> hctEBtoTerr(tbins,tbinsL,tbinsH,26,0.,tbinsH)",ebhashfilter,"COLZ"); - sprintf(mytitle,"%s EB Crystal Times to Time Error;Crystal Time (ns);Crystal Time Error (ns)",runChar); - hctEBtoTerr->SetTitle(mytitle); - hctEBtoTerr->GetXaxis()->SetNdivisions(512); - hctEBtoTerr->GetYaxis()->SetNdivisions(507); - c[32]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMEStoTERR_%i.%s",dirName,mType,runNumber,fileType); c[32]->Print(name); } - c[33]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimeErrorsEE)*25.:(crystalTimesEE-5.)*25. >> hctEEtoTerr(tbins,tbinsL,tbinsH,26,0.,tbinsH)",eehashfilter,"COLZ"); - sprintf(mytitle,"%s EE Crystal Times to Time Error;Crystal Time (ns);Crystal Time Error (ns)",runChar); - hctEEtoTerr->SetTitle(mytitle); - hctEEtoTerr->GetXaxis()->SetNdivisions(512); - hctEEtoTerr->GetYaxis()->SetNdivisions(507); - c[33]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMEStoTERR_%i.%s",dirName,mType,runNumber,fileType); c[33]->Print(name); } - - //Amplitude to time - c[34]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalAmplitudesEE:(crystalTimesEE-5.)*25. >> hctEEtoAmp(tbins,tbinsL,tbinsH,30,0.,30.)",eehashfilter,"COLZ"); - sprintf(mytitle,"%s EE Crystal Times to Amplitdue;Crystal Time (ns);Crystal Amplitude (GeV)",runChar); - hctEEtoAmp->SetTitle(mytitle); - hctEEtoAmp->GetXaxis()->SetNdivisions(512); - hctEEtoAmp->GetYaxis()->SetNdivisions(507); - c[34]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMEStoAMP_%i.%s",dirName,mType,runNumber,fileType); c[34]->Print(name); } - c[35]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalAmplitudesEB:(crystalTimesEB-5.)*25. >> hctEBtoAmp(tbins,tbinsL,tbinsH,30,0.,30.)",ebhashfilter,"COLZ"); - sprintf(mytitle,"%s EB Crystal Times to Amplitdue;Crystal Time (ns);Crystal Amplitude (GeV)",runChar); - hctEBtoAmp->SetTitle(mytitle); - hctEBtoAmp->GetXaxis()->SetNdivisions(512); - hctEBtoAmp->GetYaxis()->SetNdivisions(507); - c[35]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMEStoAMP_%i.%s",dirName,mType,runNumber,fileType); c[35]->Print(name); } - - //Amplitdue to ave event time - c[36]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalAmplitudesEB:(correctionToSampleEB-5.0)*25. >> hctEBtoAmpEvt(tbins,tbinsL,tbinsH,30,0.,30.)",ebhashfilter,"COLZ"); - sprintf(mytitle,"%s EB Event Time to Crystal Amplitudes;Average EB Event Time (ns);Crystal Amplitude (GeV)",runChar); - hctEBtoAmpEvt->SetTitle(mytitle); - hctEBtoAmpEvt->GetXaxis()->SetNdivisions(512); - hctEBtoAmpEvt->GetYaxis()->SetNdivisions(507); - c[36]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBEvtTIMEStoAMP_%i.%s",dirName,mType,runNumber,fileType); c[36]->Print(name); } - c[37]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalAmplitudesEE:(correctionToSampleEB-5.0)*25. >> hctEEtoAmpEvt(tbins,tbinsL,tbinsH,30,0.,30.)",eehashfilter,"COLZ"); - sprintf(mytitle,"%s EE Event Time to Crystal Amplitudes;Average EB Event Time (ns);Crystal Amplitude (GeV)",runChar); - hctEEtoAmpEvt->SetTitle(mytitle); - hctEEtoAmpEvt->GetXaxis()->SetNdivisions(512); - hctEEtoAmpEvt->GetYaxis()->SetNdivisions(507); - c[37]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEEvtTIMEStoAMP_%i.%s",dirName,mType,runNumber,fileType); c[37]->Print(name); } - - //Amplitude to time error. - c[38]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimeErrorsEE)*25.:crystalAmplitudesEE >> hctEEtoAmpErr(30,0.,30.,26,0.,26.)",eehashfilter,"COLZ"); - sprintf(mytitle,"%s EE Time Error to Crystal Amplitudes;Crystal Amplitude (GeV);Time Error (ns)",runChar); - hctEEtoAmpErr->SetTitle(mytitle); - hctEEtoAmpErr->GetXaxis()->SetNdivisions(512); - hctEEtoAmpErr->GetYaxis()->SetNdivisions(507); - c[38]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EETIMESErrtoAMP_%i.%s",dirName,mType,runNumber,fileType); c[38]->Print(name); } - c[39]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimeErrorsEB)*25.:crystalAmplitudesEB >> hctEBtoAmpErr(30,0.,30.,26,0.,26.)",ebhashfilter,"COLZ"); - sprintf(mytitle,"%s EB Time Error to Crystal Amplitudes;Crystal Amplitude (GeV);Time Error (ns)",runChar); - hctEBtoAmpErr->SetTitle(mytitle); - hctEBtoAmpErr->GetXaxis()->SetNdivisions(512); - hctEBtoAmpErr->GetYaxis()->SetNdivisions(507); - c[39]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTIMESErrtoAMP_%i.%s",dirName,mType,runNumber,fileType); c[39]->Print(name); } - - //Hashed Index's - c[50]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalHashedIndicesEB >> hctEBHashed(62000,0.,62000.)",ebhashfilter); - sprintf(mytitle,"%s EB Hashed Index Occupancy;Hashed Index",runChar); - hctEBHashed->SetTitle(mytitle); - hctEBHashed->GetXaxis()->SetNdivisions(512); - c[50]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBHashed_%i.%s",dirName,mType,runNumber,fileType); c[50]->Print(name); } - - c[51]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("crystalHashedIndicesEE >> hctEEHashed(15000,0.,15000.)",eehashfilter); - sprintf(mytitle,"%s EE Hashed Index Occupancy;Hashed Index",runChar); - hctEEHashed->SetTitle(mytitle); - c[51]->SetLogy(1); - hctEEHashed->GetXaxis()->SetNdivisions(512); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEHashed_%i.%s",dirName,mType,runNumber,fileType); c[51]->Print(name); } - - - //Time to Hashed Index - c[52]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEB-5.)*25.:crystalHashedIndicesEB >> hctEBtoHashed(2000,0.,62000.,52,-40.,100.)",ebhashfilter,"COLZ"); - sprintf(mytitle,"%s EB Hashed Index to Time;Hashed Index;Time(ns)",runChar); - hctEBtoHashed->SetTitle(mytitle); - hctEBtoHashed->GetXaxis()->SetNdivisions(512); - hctEBtoHashed->GetYaxis()->SetNdivisions(507); - hctEBtoHashed->SetMinimum(1); - c[52]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBHashedToTime_%i.%s",dirName,mType,runNumber,fileType); c[52]->Print(name); } - - c[53]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("(crystalTimesEE-5.)*25.:crystalHashedIndicesEE >> hctEEtoHashed(500,0.,15000.,52,-40.,100.)",eehashfilter,"COLZ"); - sprintf(mytitle,"%s EE Hashed Index to Time;Hashed Index;Time(ns)",runChar); - hctEEtoHashed->SetTitle(mytitle); - hctEEtoHashed->GetXaxis()->SetNdivisions(512); - hctEEtoHashed->GetYaxis()->SetNdivisions(507); - hctEEtoHashed->SetMinimum(1); - c[53]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEHashedToTime_%i.%s",dirName,mType,runNumber,fileType); c[53]->Print(name); } - - //1-D Number of crystal distributions - c[56]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("numberOfEBcrys >> hctEBCry(25,0.,25.)",""); - sprintf(mytitle,"%s EB Number of Crystals;Number of EB crystals",runChar); - hctEBCry->SetTitle(mytitle); - hctEBCry->GetXaxis()->SetNdivisions(512); - c[56]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBCrys_%i.%s",dirName,mType,runNumber,fileType); c[56]->Print(name); } - - c[57]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("numberOfEEcrys >> hctEECry(25,0.,25.)",""); - sprintf(mytitle,"%s EB Number of Crystals;Number of EE crystals",runChar); - hctEECry->SetTitle(mytitle); - hctEECry->GetXaxis()->SetNdivisions(512); - c[57]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EECrys_%i.%s",dirName,mType,runNumber,fileType); c[57]->Print(name); } - - - //2-D crystal plots - c[58]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("numberOfEBcrys:(correctionToSampleEB-5.0)*25. >> hctEBCryT(tbins,tbinsL,tbinsH,25,0.,25.)","numberOfEBcrys>0","colz"); - sprintf(mytitle,"%s EB Number of Crystals to EB average time;EB average time (ns);Number of EB crystals",runChar); - hctEBCryT->SetTitle(mytitle); - hctEBCryT->GetXaxis()->SetNdivisions(512); - hctEBCryT->GetYaxis()->SetNdivisions(507); - hctEBCryT->SetMinimum(1); - c[58]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBCrysToTime_%i.%s",dirName,mType,runNumber,fileType); c[58]->Print(name); } - - c[59]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("numberOfEEcrys:(correctionToSampleEEP-5.0)*25. >> hctEEPCryT(tbins,tbinsL,tbinsH,25,0.,25.)","numberOfEEcrys>0 && correctionToSampleEEP>0","colz"); - sprintf(mytitle,"%s EE Number of Crystals to EE+ average time;EE+ average time (ns);Number of EE crystals",runChar); - hctEEPCryT->SetTitle(mytitle); - hctEEPCryT->GetXaxis()->SetNdivisions(512); - hctEEPCryT->GetYaxis()->SetNdivisions(507); - hctEEPCryT->SetMinimum(1); - c[59]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPCrysToTime_%i.%s",dirName,mType,runNumber,fileType); c[59]->Print(name); } - - c[60]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("numberOfEEcrys:(correctionToSampleEEM-5.0)*25. >> hctEEMCryT(tbins,tbinsL,tbinsH,25,0.,25.)","numberOfEEcrys>0 && correctionToSampleEEM>0","colz"); - sprintf(mytitle,"%s EE Number of Crystals to EE- average time;EE- average time (ns);Number of EE crystals",runChar); - hctEEMCryT->SetTitle(mytitle); - hctEEMCryT->GetXaxis()->SetNdivisions(512); - hctEEMCryT->GetYaxis()->SetNdivisions(507); - hctEEMCryT->SetMinimum(1); - c[60]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMCrysToTime_%i.%s",dirName,mType,runNumber,fileType); c[60]->Print(name); } - - c[61]->cd(); - gStyle->SetOptStat(111110); - eventTimingInfoTree->Draw("(correctionToSampleEEM-5.0)*25.:(correctionToSampleEEP-5.0)*25. >> hctEEMEEP(tbins,tbinsL,tbinsH,tbins,tbinsL,tbinsH)","correctionToSampleEEP>0 && correctionToSampleEEM>0","colz"); - sprintf(mytitle,"%s EE+ average time to EE- average time;EE- average time (ns);EE+ average time (ns)",runChar); - hctEEMEEP->SetTitle(mytitle); - hctEEMEEP->GetXaxis()->SetNdivisions(512); - hctEEMEEP->GetYaxis()->SetNdivisions(507); - hctEEMEEP->SetMinimum(1); - c[61]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPTimeToEEMTime_%i.%s",dirName,mType,runNumber,fileType); c[61]->Print(name); } - - c[63]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("numberOfEEcrys:(correctionToSampleEEM-5.0)*25.-(correctionToSampleEEP-5.0)*25. >> hctEEMDEEPcry(25,-40,100,25,0,25)","correctionToSampleEEP>0 && correctionToSampleEEM>0","colz"); - sprintf(mytitle,"%s EE- minus EE+ average time vs EE crystals;(EEM - EEP) average time (ns);Number EE crystals",runChar); - hctEEMDEEPcry->SetTitle(mytitle); - hctEEMDEEPcry->GetXaxis()->SetNdivisions(512); - hctEEMDEEPcry->SetMinimum(1); - c[63]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPDiffEEMTimeCrys_%i.%s",dirName,mType,runNumber,fileType); c[63]->Print(name); } - - c[62]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - eventTimingInfoTree->Draw("(correctionToSampleEEM-5.0)*25.-(correctionToSampleEEP-5.0)*25. >> hctEEMDEEP(tbins,tbinsL,tbinsH)","correctionToSampleEEP>0 && correctionToSampleEEM>0"); - sprintf(mytitle,"%s EE- minus EE+ average time;(EEM - EEP) average time (ns)",runChar); - hctEEMDEEP->SetTitle(mytitle); - hctEEMDEEP->GetXaxis()->SetNdivisions(512); - cout << "mean is " << hctEEMDEEP->GetMean() << endl; - if (hctEEMDEEP->GetMean() != 0) hctEEMDEEP->Fit("gaus"); - //hctEEMEEP->SetMinimum(.5); - c[62]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPDiffEEMTime_%i.%s",dirName,mType,runNumber,fileType); c[62]->Print(name); } - - //Number of crystals vs amplitude - c[64]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("numberOfEEcrys:crystalAmplitudesEE >> hctEEcryamp(30,0,30,25,0,25)","numberOfEEcrys>0","colz"); - sprintf(mytitle,"%s EE amplitudes vs number of crystals;Crystal Amp (GeV);Number EE crystals",runChar); - hctEEcryamp->SetTitle(mytitle); - hctEEcryamp->GetXaxis()->SetNdivisions(512); - hctEEcryamp->SetMinimum(1); - c[64]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EECrysAmp_%i.%s",dirName,mType,runNumber,fileType); c[64]->Print(name); } - - c[65]->cd(); - gStyle->SetOptStat(1110); - eventTimingInfoTree->Draw("numberOfEBcrys:crystalAmplitudesEB >> hctEBcryamp(30,0,30,25,0,25)","numberOfEBcrys>0","colz"); - sprintf(mytitle,"%s EB amplitudes vs number of crystals;Crystal Amp (GeV);Number EB crystals",runChar); - hctEBcryamp->SetTitle(mytitle); - hctEBcryamp->GetXaxis()->SetNdivisions(512); - hctEBcryamp->SetMinimum(1); - c[65]->SetLogz(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBCrysAmp_%i.%s",dirName,mType,runNumber,fileType); c[65]->Print(name); } - - //FINAL 1D timing number, by crystal by TT - c[66]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *tthistEB = HistFromTProfile2D(timeTTProfile,"tthistEB",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EB TT Timing;TT time average (ns)",runChar); - tthistEB->SetTitle(mytitle); - tthistEB->GetXaxis()->SetNdivisions(512); - if (tthistEB->GetMean() != 0) tthistEB->Fit("gaus"); - c[66]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBTTTIME_%i.%s",dirName,mType,runNumber,fileType); c[66]->Print(name); } - - c[67]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *chhistEB = HistFromTProfile2D(timeCHProfile,"chhistEB",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EB CH Timing;CH time average (ns)",runChar); - chhistEB->SetTitle(mytitle); - chhistEB->GetXaxis()->SetNdivisions(512); - if (chhistEB->GetMean() != 0) chhistEB->Fit("gaus"); - c[67]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EBCHTIME_%i.%s",dirName,mType,runNumber,fileType); c[67]->Print(name); } - - c[68]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *tthistEEP = HistFromTProfile2D(EEPtimeTTProfile,"tthistEEP",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EE+ TT Timing;TT time average (ns)",runChar); - tthistEEP->SetTitle(mytitle); - tthistEEP->GetXaxis()->SetNdivisions(512); - if (tthistEEP->GetMean() != 0) tthistEEP->Fit("gaus"); - c[68]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPTTTIME_%i.%s",dirName,mType,runNumber,fileType); c[68]->Print(name); } - - c[69]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *chhistEEP = HistFromTProfile2D(EEPtimeCHProfile,"chhistEEP",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EE+ CH Timing;CH time average (ns)",runChar); - chhistEEP->SetTitle(mytitle); - chhistEEP->GetXaxis()->SetNdivisions(512); - if (chhistEEP->GetMean() != 0) chhistEEP->Fit("gaus"); - c[69]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEPCHTIME_%i.%s",dirName,mType,runNumber,fileType); c[69]->Print(name); } - - c[70]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *tthistEEM = HistFromTProfile2D(EEMtimeTTProfile,"tthistEEM",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EE- TT Timing;TT time average (ns)",runChar); - tthistEEM->SetTitle(mytitle); - tthistEEM->GetXaxis()->SetNdivisions(512); - if (tthistEEM->GetMean() != 0) tthistEEM->Fit("gaus"); - c[70]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMTTTIME_%i.%s",dirName,mType,runNumber,fileType); c[70]->Print(name); } - - c[71]->cd(); - gStyle->SetOptStat(111110); - gStyle->SetOptFit(111); - TH1F *chhistEEM = HistFromTProfile2D(EEMtimeCHProfile,"chhistEEM",200, -30., 40.,-5.,25.); - sprintf(mytitle,"%s EE- CH Timing;CH time average (ns)",runChar); - chhistEEM->SetTitle(mytitle); - chhistEEM->GetXaxis()->SetNdivisions(512); - if (chhistEEM->GetMean() != 0) chhistEEM->Fit("gaus"); - c[71]->SetLogy(1); - if (printPics) { sprintf(name,"%s/%sAnalysis_EEMCHTIME_%i.%s",dirName,mType,runNumber,fileType); c[71]->Print(name); } - - cout << name << endl; - - return; - -} - -void drawEELines() { - - int ixSectorsEE[202] = {61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 0,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100, 0, 61, 65, 65, 70, 70, 80, 80, 90, 90, 92, 0, 61, 65, 65, 90, 90, 97, 0, 57, 60, 60, 65, 65, 70, 70, 75, 75, 80, 80, 0, 50, 50, 0, 43, 40, 40, 35, 35, 30, 30, 25, 25, 20, 20, 0, 39, 35, 35, 10, 10, 3, 0, 39, 35, 35, 30, 30, 20, 20, 10, 10, 8, 0, 45, 45, 40, 40, 35, 35, 0, 55, 55, 60, 60, 65, 65}; - - int iySectorsEE[202] = {50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 50, 0, 50, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97,100,100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 50, 0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25, 0, 50, 50, 55, 55, 60, 60, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 61,100, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 50, 50, 55, 55, 60, 60, 0, 45, 45, 40, 40, 35, 35, 30, 30, 25, 25, 0, 39, 30, 30, 15, 15, 5, 0, 39, 30, 30, 15, 15, 5}; - - - for ( int i=0; i<202; i++) { - ixSectorsEE[i] += 1; - iySectorsEE[i] += 1; -// std::cout << i << " " << ixSectorsEE[i] << " " << iySectorsEE[i] << std::endl; - } - - TLine l; - l.SetLineWidth(1); - for ( int i=0; i<201; i=i+1) { - if ( (ixSectorsEE[i]!=1 || iySectorsEE[i]!=1) && - (ixSectorsEE[i+1]!=1 || iySectorsEE[i+1]!=1) ) { - l.DrawLine(ixSectorsEE[i], iySectorsEE[i], - ixSectorsEE[i+1], iySectorsEE[i+1]); - } - } - -} - -void customizeTProfile (TProfile* myTProfile) { - if (myTProfile) { - myTProfile->SetLineWidth(2); - myTProfile->SetMarkerStyle(kFullCircle); - myTProfile->SetMarkerSize(0.7); - } -} - -void customizeTHist (TH1F* myTHist) { - if (myTHist) { - myTHist->SetLineWidth(2); - myTHist->SetMarkerStyle(kFullCircle); - myTHist->SetMarkerSize(0.7); - } -} - - -TH1F* CorrectProfToHist(TProfile *prof, const char * histname, double numb=0, double myScale = 1.0 ) -{ - TH1F *temphist = new TH1F(histname,histname,prof->GetNbinsX(),prof->GetXaxis()->GetXmin(),prof->GetXaxis()->GetXmax()); - for (int i = 1; i < prof->GetNbinsX()+1; ++i) - { - //std::cout << " bin " << i << " is " << temphist->GetBinContent(i) << std::endl; - if (prof->GetBinEntries(i) > 0 ) - { - temphist->SetBinContent(i,prof->GetBinContent(i)+numb); - temphist->SetBinError(i,prof->GetBinError(i)); - } - else {temphist->SetBinContent(i,-100.);} - //std::cout << " bin " << i << " bin content before " << prof->GetBinContent(i) << " bin entries " << prof->GetBinEntries(i) << " new bi\ncontent " << temphist->GetBinContent(i) << std::endl; - } - temphist->Sumw2(); - temphist->Scale(myScale); - return temphist; -} - -void ScaleTProfile2D(TProfile2D* myprof, Double_t myfac, Double_t myscale) -{ -int nxbins = myprof->GetNbinsX(); -int nybins = myprof->GetNbinsY(); - -for (int i=0; i<=(nxbins+2)*(nybins+2); i++ ) { - Double_t oldcont = myprof->GetBinContent(i); - Double_t binents = myprof->GetBinEntries(i); - if (binents == 0 ) {binents =1.;myprof->SetBinEntries(i,1); } - myprof->SetBinContent(i,myscale*(oldcont+myfac)*binents); -} -} - - - - -TProfile2D* TProfToRelProf2D(TProfile2D *prof, const char * histname, double numb=0, double myScale = 1.0) -{ -TProfile2D *myprof = prof->Clone(histname); -ScaleTProfile2D(myprof,numb,myScale); - -return myprof; -} - -TProfile* TProfToRelProf(TProfile *prof, const char * histname, double numb=0, double myScale = 1.0) -{ -TProfile *myprof = prof->Clone(histname); -ScaleTProfile(myprof,numb,myScale); - -return myprof; -} - -void ScaleTProfile(TProfile* myprof, Double_t myfac, Double_t myscale) -{ -int nxbins = myprof->GetNbinsX(); - -for (int i=1; i<(nxbins+1); i++ ) { - Double_t oldcont = myprof->GetBinContent(i); - Double_t binents = myprof->GetBinEntries(i); - Double_t binerrr = myprof->GetBinError(i); - - if (binents == 0 ) { continue; /*binents =1.;myprof->SetBinEntries(i,1);*/ } - myprof->SetBinContent(i,myscale*(oldcont+myfac)*binents); - Double_t newentries = myprof->GetBinEntries(i); - Double_t newcont = myprof->GetBinContent(i); - //cout << " cont " << oldcont << " ent " << binents << " err " << binerrr << " new err " << myprof->GetBinError(i); - if ( newentries == 1) { myprof->SetBinError(i,5+fabs(myprof->GetBinContent(i)-myprof->GetBinContent(i)/2.5));} - //else {myprof->SetBinError(i,binerrr*myscale+1.0);} - //cout << " newnew " << myprof->GetBinError(i) << std::endl; - if (newentries != binents) {std::cout << "NONONO" << std::endl;} -} -} - -void EntryProfileFromTProfile2D(TProfile2D* myprof) -{ -int nxbins = myprof->GetNbinsX(); -int nybins = myprof->GetNbinsY(); - -for (int i=0; i<=(nxbins+2)*(nybins+2); i++ ) { - Double_t oldcont = myprof->GetBinContent(i); - Double_t binents = myprof->GetBinEntries(i); - if (binents == 0 ) { continue; } - myprof->SetBinContent(i,binents*binents); -} -} - - -TProfile2D* TProfile2DOccupancyFromProf2D(TProfile2D *prof, const char * histname) -{ -TProfile2D *myprof = prof->Clone(histname); -EntryProfileFromTProfile2D(myprof); -return myprof; -} - -TH1F* HistFromTProfile2D(TProfile2D *prof, const char * histname, Int_t xbins, Double_t xmin, Double_t xmax, Double_t myfac, Double_t myscale) -{ -int nxbins = prof->GetNbinsX(); -int nybins = prof->GetNbinsY(); - -TH1F *temphist = new TH1F(histname,histname,xbins,xmin,xmax); - -for (int i=0; i<=(nxbins+2)*(nybins+2); i++ ) { - Double_t oldcont = prof->GetBinContent(i); - Double_t binents = prof->GetBinEntries(i); - if (binents == 0 ) { continue; } - temphist->Fill((oldcont+myfac)*myscale); -} -return temphist; -} - - - - diff --git a/EcalTiming/test/recoAlcaStream_cfg.py b/EcalTiming/test/recoAlcaStream_cfg.py new file mode 100644 index 0000000..4e1353d --- /dev/null +++ b/EcalTiming/test/recoAlcaStream_cfg.py @@ -0,0 +1,235 @@ +import FWCore.ParameterSet.Config as cms +import os, sys, imp, re +import FWCore.ParameterSet.VarParsing as VarParsing + +#sys.path(".") + +#new options to make everything easier for batch + +############################################################ +### SETUP OPTIONS + +options = VarParsing.VarParsing('standard') +options.register('jsonFile', + "", + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "path and name of the json file") +options.register('offset', + 0.0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.float, + "add this to each crystal time") +options.register('isSplash', + 0, + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.int, + "0=false, 1=true" + ) +options.register('streamName', + 'AlCaPhiSym', + VarParsing.VarParsing.multiplicity.singleton, + VarParsing.VarParsing.varType.string, + "type of stream: AlCaPhiSym or AlCaP0") + +### setup any defaults you want +options.output="output/ecalTiming.root" +options.secondaryOutput="ntuple.root" + +if(options.streamName=="AlCaP0"): options.files = "/store/data/Commissioning2015/AlCaP0/RAW/v1/000/246/342/00000/048ECF48-F906-E511-95AC-02163E011909.root" +elif(options.streamName=="AlCaPhiSym"): options.files = "/store/data/Commissioning2015/AlCaPhiSym/RAW/v1/000/244/768/00000/A8219906-44FD-E411-8DA9-02163E0121C5.root" +else: + print "stream ",options.streamName," not foreseen" + exit +options.maxEvents = -1 # -1 means all events +### get and parse the command line arguments +options.parseArguments() +print options + +process = cms.Process("RECO") + +#dataset=/MinimumBias/Commissioning2015-v1/RAW run=243506 + + +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_38T_cff') + +if(options.isSplash==1): + ## Get Cosmic Reconstruction + process.load('Configuration/StandardSequences/ReconstructionCosmics_cff') + process.caloCosmics.remove(process.hbhereco) + process.caloCosmics.remove(process.hcalLocalRecoSequence) + process.caloCosmics.remove(process.hfreco) + process.caloCosmics.remove(process.horeco) + process.caloCosmics.remove(process.zdcreco) + process.caloCosmics.remove(process.ecalClusters) + process.caloCosmicOrSplashRECOSequence = cms.Sequence(process.caloCosmics )#+ process.egammaCosmics) +else: + process.load('Configuration/StandardSequences/Reconstruction_cff') + process.recoSequence = cms.Sequence(process.calolocalreco )#+ process.egammaCosmics) + +#process.load('PhiSym.EcalCalibAlgos.ecalPhiSymLocarecoWeights_cff') +#process.load('RecoLocalCalo.Configuration.ecalLocalRecoSequence_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff') +process.load('EcalTiming.EcalTiming.ecalLocalRecoSequenceAlCaStream_cff') + +if(options.streamName=="AlCaP0"): + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltAlCaPi0EBRechitsToDigis","pi0EBDigis") + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltAlCaPi0EERechitsToDigis","pi0EEDigis") +else: + process.ecalMultiFitUncalibRecHit.EBdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEB") + process.ecalMultiFitUncalibRecHit.EEdigiCollection = cms.InputTag("hltEcalPhiSymFilter","phiSymEcalDigisEE") + + +## Raw to Digi +process.load('Configuration/StandardSequences/RawToDigi_Data_cff') + +## HLT Filter Splash +import HLTrigger.HLTfilters.hltHighLevel_cfi +process.spashesHltFilter = HLTrigger.HLTfilters.hltHighLevel_cfi.hltHighLevel.clone( + throw = cms.bool(False), + HLTPaths = ['HLT_EG20*', 'HLT_SplashEcalSumET', 'HLT_Calibration','HLT_EcalCalibration','HLT_HcalCalibration','HLT_Random','HLT_Physics','HLT_HcalNZS','HLT_SplashEcalSumET','HLTriggerFinalPath' ] +) + + +## Do you want to Pre-Scale +process.load("FWCore.Modules.preScaler_cfi") +process.preScaler.prescaleFactor = 1 +## GlobalTag Conditions Related +from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'GR_P_V56', '') #run2_data', '') + +## Process Digi To Raw Step +process.digiStep = cms.Sequence(process.ecalDigis + process.ecalPreshowerDigis) + +## Process Reco + + + + + + +# Dump Some event Content +import FWCore.Modules.printContent_cfi +process.dumpEv = FWCore.Modules.printContent_cfi.printContent.clone() + +### Print Out Some Messages +process.MessageLogger = cms.Service("MessageLogger", + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING') + ), + categories = cms.untracked.vstring('ecalTimeTree'), + destinations = cms.untracked.vstring('cout') +) +process.load("FWCore.MessageService.MessageLogger_cfi") +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(1000) + +# enable the TrigReport and TimeReport +process.options = cms.untracked.PSet( + wantSummary = cms.untracked.bool(True) +# SkipEvent = cms.untracked.vstring('ProductNotFound') +) + +# dbs search --query "find file where dataset=/ExpressPhysics/BeamCommissioning09-Express-v2/FEVT and run=124020" | grep store | awk '{printf "\"%s\",\n", $1}' +# Input source +process.source = cms.Source("PoolSource", + secondaryFileNames = cms.untracked.vstring(), + # fileNames = cms.untracked.vstring('file:test_DIGI.root') + fileNames = cms.untracked.vstring(options.files), +) + +if(len(options.jsonFile) > 0): + import FWCore.PythonUtilities.LumiList as LumiList + process.source.lumisToProcess = LumiList.LumiList(filename = options.jsonFile).getVLuminosityBlockRange() + +# process.source = cms.Source( +# "PoolSource", +# skipEvents = cms.untracked.uint32(0), +# fileNames = cms.untracked.vstring( +# #'file:MyCrab/50988619-41DE-E211-9F98-003048FFD770.root' +# #'root://xrootd.unl.edu//store/data/Run2010B/Cosmics/RAW/v1/000/144/556/C8B5FCA9-F3B5-DF11-B28A-0030487CD16E.root' +# #'file:Cosmic-Commissioning2014-Cosmics-RAW-v1-AC4963B3-54BE-E311-97F5-02163E00E6E3.root' +# #'/store/data/Commissioning2015/Cosmics/RAW-RECO/CosmicSP-6Mar2015-v1/10000/248747E6-25CA-E411-B17C-02163E00BD75.root' +# #'/store/data/Run2010B/Cosmics/RAW/v1/000/144/559/306A4ABD-F3B5-DF11-9CAD-003048F118C6.root' +# '/store/data/Commissioning2015/Cosmics/RAW/v1/000/232/881/00000/26ADAFFB-3FAB-E411-A313-02163E011DDC.root' +# ), +# # drop native rechits and clusters, to be sure only those locally made will be picked up +# inputCommands = cms.untracked.vstring('keep *' +# ,'drop EcalRecHitsSorted_*_*_RECO' # drop hfRecoEcalCandidate as remade in this process +# , 'drop recoSuperClusters_*_*_RECO' # drop hfRecoEcalCandidate as remade in this process +# , 'drop recoCaloClusters_*_*_RECO' +# ) + + +# Output definition +process.RECOoutput = cms.OutputModule("PoolOutputModule", + splitLevel = cms.untracked.int32(0), + eventAutoFlushCompressedSize = cms.untracked.int32(5242880), + outputCommands = cms.untracked.vstring('drop *',"keep *_ecalRecHit_EcalRecHits*_*"), + fileName = cms.untracked.string(options.output), + dataset = cms.untracked.PSet( + filterName = cms.untracked.string(''), + dataTier = cms.untracked.string('RECO') + ) +) + + +## Histogram files +#process.TFileService = cms.Service("TFileService", +# fileName = cms.string(options.output), +# closeFileFast = cms.untracked.bool(True) +# ) + +## Dumpevent Event Contents +process.dumpEvContent = cms.EDAnalyzer("EventContentAnalyzer") + +### NumBer of events +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents)) + + +process.filter=cms.Sequence() +if(options.isSplash==1): + process.filter+=process.spashesHltFilter + process.reco_step = cms.Sequence(process.caloCosmicOrSplashRECOSequence) +else: + #process.reco_step = cms.Sequence(process.reconstruction_step_multiFit) + process.reco_step = cms.Sequence(process.ecalLocalRecoSequenceAlCaStream) + +### Process Full Path +if(options.isSplash==0): + process.digiStep = cms.Sequence() + +process.p = cms.Path( process.filter #+ process.preScaler + + process.digiStep + + process.reco_step + ) + +process.endp = cms.EndPath(process.RECOoutput) + +### Schedule ### +process.schedule = cms.Schedule(process.p, process.endp) + +evtPlots = True if options.isSplash else False + + +#import Electronics mapping +process.load("Geometry.EcalCommonData.EcalOnly_cfi") +process.load("Geometry.EcalMapping.EcalMapping_cfi") +process.load("Geometry.EcalMapping.EcalMappingRecord_cfi") +#process.load("Geometry.CaloEventSetup.CaloGeometry_cff") + +#ESLooperProducer looper is imported here: +#process.load('EcalTiming.EcalTiming.ecalTimingCalibProducer_cfi') +#process.looper.isSplash= cms.bool(True if options.isSplash else False) +#process.looper.makeEventPlots=evtPlots +#process.looper.globalOffset = cms.double(options.offset) +#process.looper.outputDumpFile = process.TFileService.fileName +#process.looper.minRecHitEnergy = cms.double(0.5) + +processDumpFile = open('processDump.py', 'w') +print >> processDumpFile, process.dumpPython() diff --git a/EcalTiming/test/setupCRAB.csh b/EcalTiming/test/setupCRAB.csh deleted file mode 100755 index bd90c23..0000000 --- a/EcalTiming/test/setupCRAB.csh +++ /dev/null @@ -1,3 +0,0 @@ -source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.csh -cmsenv -source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.csh diff --git a/EcalTiming/test/setupCRAB.sh b/EcalTiming/test/setupCRAB.sh deleted file mode 100755 index 16e4839..0000000 --- a/EcalTiming/test/setupCRAB.sh +++ /dev/null @@ -1,3 +0,0 @@ -source /afs/cern.ch/cms/LCG/LCG-2/UI/cms_ui_env.sh -cmsenv -source /afs/cern.ch/cms/ccs/wm/scripts/Crab/crab.sh