Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-22 04:03:20

0001 #ifndef PCCNTupler_h
0002 #define PCCNTupler_h
0003 
0004 /** \class PCCNTupler
0005  * ----------------------------------------------------------------------
0006  * PCCNTupler
0007  * ---------
0008  * Summary: The pixel clusters are summed per pixel module per lumi
0009  *          lumi section.
0010  *
0011  * ----------------------------------------------------------------------
0012  * Author:  Chris Palmer
0013  * ----------------------------------------------------------------------
0014  *
0015  *
0016  ************************************************************/
0017 
0018 #include <map>
0019 
0020 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/ServiceRegistry/interface/Service.h"
0023 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0024 #include "TrackingTools/TrackAssociator/interface/TrackDetectorAssociator.h"
0025 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0026 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
0027 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0028 #include "DataFormats/VertexReco/interface/Vertex.h"
0029 
0030 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0031 
0032 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0033 #include "FWCore/Utilities/interface/EDGetToken.h"
0034 
0035 #include "TObject.h"
0036 #include "TH1F.h"
0037 
0038 class TObject;
0039 class TTree;
0040 class TH1D;
0041 class TFile;
0042 class DetId;
0043 
0044 class PCCNTupler : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchLuminosityBlocks> {
0045 public:
0046   PCCNTupler(const edm::ParameterSet&);
0047   virtual ~PCCNTupler();
0048   virtual void beginJob() override;
0049   virtual void endJob() override;
0050   virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0051   void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
0052   void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
0053 
0054 protected:
0055   void Reset();
0056   void SaveAndReset();
0057   void ComputeMeanAndMeanError();
0058 
0059 private:
0060   edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > pixelToken;
0061   edm::EDGetTokenT<reco::VertexCollection> recoVtxToken;
0062   edm::EDGetTokenT<std::vector<PileupSummaryInfo> > pileUpToken;
0063   edm::EDGetTokenT<reco::CaloJetCollection> hltjetsToken_;
0064   float *jhcalpt, *jhcalphi, *jhcaleta, *jhcale, *jhcalemf, *jhcaln90, *jhcaln90hits;
0065   int nhjetcal;
0066 
0067   edm::InputTag fPrimaryVertexCollectionLabel;
0068   edm::InputTag fPixelClusterLabel;
0069   edm::InputTag fPileUpInfoLabel;
0070 
0071   static const int MAX_VERTICES = 300;
0072 
0073   // saving events per LS, LN or event
0074   std::string saveType = "LumiSect";  // LumiSect or LumiNib or Event
0075   std::string sampleType = "MC";      // MC or DATA
0076   bool saveAndReset;
0077   bool sameEvent;
0078   bool sameLumiNib;
0079   bool sameLumiSect;
0080   bool firstEvent;
0081 
0082   // Lumi stuff
0083   TTree* tree;
0084   int run;
0085   int LS = -99;             // set to indicate first pass of analyze method
0086   int LN = -99;             // set to indicate first pass of analyze method
0087   int event = -99;          // set to indicate first pass of analyze method
0088   int bunchCrossing = -99;  // local variable only
0089   int orbit = -99;
0090 
0091   std::pair<int, int> bxModKey;  // local variable only
0092 
0093   int eventCounter = 0;
0094   int totalEvents;
0095 
0096   bool includeVertexInformation;
0097   bool includePixels;
0098   bool includeJets;
0099   bool splitByBX;
0100   bool pixelPhase2Geometry;
0101 
0102   int nPU;
0103   int nVtx;
0104   int vtx_nTrk[MAX_VERTICES];
0105   int vtx_ndof[MAX_VERTICES];
0106   float vtx_x[MAX_VERTICES];
0107   float vtx_y[MAX_VERTICES];
0108   float vtx_z[MAX_VERTICES];
0109   float vtx_xError[MAX_VERTICES];
0110   float vtx_yError[MAX_VERTICES];
0111   float vtx_zError[MAX_VERTICES];
0112   float vtx_chi2[MAX_VERTICES];
0113   float vtx_normchi2[MAX_VERTICES];
0114   bool vtx_isValid[MAX_VERTICES];
0115   bool vtx_isFake[MAX_VERTICES];
0116   bool vtx_isGood[MAX_VERTICES];
0117 
0118   std::map<int, int> nGoodVtx;
0119   std::map<int, int> nValidVtx;
0120   std::map<std::pair<int, int>, int> nPixelClusters;
0121   std::map<std::pair<int, int>, int> nClusters;
0122   std::map<int, int> layers;
0123 
0124   std::map<std::pair<int, int>, float> meanPixelClusters;
0125   std::map<std::pair<int, int>, float> meanPixelClustersError;
0126 
0127   TH1F* pileup;
0128 
0129   UInt_t timeStamp_begin;
0130   UInt_t timeStamp_local;
0131   UInt_t timeStamp_end;
0132   std::map<int, int> BXNo;
0133 };
0134 
0135 #endif