Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:18

0001 // -*- C++ -*-
0002 //
0003 // Package:    ClusterSummary
0004 // Class:      ClusterSummary
0005 //
0006 /**\class ClusterSummary ClusterSummary.cc msegala/ClusterSummary/src/ClusterSummary.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Michael Segala
0015 //         Created:  Wed Feb 23 17:36:23 CST 2011
0016 //
0017 //
0018 
0019 #ifndef CLUSTERSUMMARY
0020 #define CLUSTERSUMMARY
0021 
0022 // system include files
0023 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0024 #include <atomic>
0025 #endif
0026 #include <memory>
0027 #include <string>
0028 #include <map>
0029 #include <vector>
0030 #include <iostream>
0031 #include <cstring>
0032 #include <sstream>
0033 #include "FWCore/Utilities/interface/Exception.h"
0034 
0035 // user include files
0036 
0037 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0038 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0039 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0040 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0041 
0042 #include "DataFormats/SiStripDigi/interface/SiStripProcessedRawDigi.h"
0043 #include "DataFormats/Common/interface/DetSetVector.h"
0044 
0045 #include "DataFormats/DetId/interface/DetId.h"
0046 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0047 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0048 
0049 /*****************************************************************************************
0050 
0051 How to use ClusterSummary class:
0052 
0053 ClusterSummary provides summary information for a number of cluster dependent variables.
0054 All the variables are stored within variables_
0055 The modules selected are stored within modules_
0056 The number of variables for each module is stored within iterator_
0057 
0058 ********************************************************************************************/
0059 
0060 class ClusterSummary {
0061 public:
0062   ClusterSummary();
0063   //nSelections is the number of selections that you want to have
0064   //It should be highest enum + 1
0065   ClusterSummary(const int nSelections);
0066   ~ClusterSummary() {}
0067   // copy ctor
0068   ClusterSummary(const ClusterSummary& src);
0069   // copy assingment operator
0070   ClusterSummary& operator=(const ClusterSummary& rhs);
0071 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
0072   ClusterSummary(ClusterSummary&& other);
0073 #endif
0074 
0075   // Enum for each partition within Tracker
0076   enum CMSTracker {
0077     STRIP = 0,
0078     TIB = 1,
0079     TOB = 2,
0080     TID = 3,
0081     TEC = 4,
0082     PIXEL = 5,
0083     FPIX = 6,
0084     BPIX = 7,
0085     NVALIDENUMS = 8,
0086     NTRACKERENUMS = 100
0087   };
0088   static const std::vector<std::string> subDetNames;
0089   static const std::vector<std::vector<std::string> > subDetSelections;
0090 
0091   // Enum which describes the ordering of the summary variables inside vector variables_
0092   enum VariablePlacement { NCLUSTERS, CLUSTERSIZE, CLUSTERCHARGE, NVARIABLES };
0093   static const std::vector<std::string> variableNames;
0094 
0095   //===================+++++++++++++========================
0096   //
0097   //                 Main methods to fill
0098   //                      Variables
0099   //
0100   //===================+++++++++++++========================
0101 
0102   //These functions are broken into two categories. The standard versions take the enums as input and find the locations in the vector.
0103   //The ones labeled "byIndex" take the vector location as input
0104 public:
0105   int getNClusByIndex(const int mod) const { return nClus.at(mod); }
0106   int getClusSizeByIndex(const int mod) const { return clusSize.at(mod); }
0107   float getClusChargeByIndex(const int mod) const { return clusCharge.at(mod); }
0108 
0109   int getNClus(const CMSTracker mod) const {
0110     int pos = getModuleLocation(mod);
0111     return pos < 0 ? 0. : nClus[pos];
0112   }
0113   int getClusSize(const CMSTracker mod) const {
0114     int pos = getModuleLocation(mod);
0115     return pos < 0 ? 0. : clusSize[pos];
0116   }
0117   float getClusCharge(const CMSTracker mod) const {
0118     int pos = getModuleLocation(mod);
0119     return pos < 0 ? 0. : clusCharge[pos];
0120   }
0121 
0122   const std::vector<int>& getNClusVector() const { return nClus; }
0123   const std::vector<int>& getClusSizeVector() const { return clusSize; }
0124   const std::vector<float>& getClusChargeVector() const { return clusCharge; }
0125 
0126   void addNClusByIndex(const int mod, const int val) { nClus.at(mod) += val; }
0127   void addClusSizeByIndex(const int mod, const int val) { clusSize.at(mod) += val; }
0128   void addClusChargeByIndex(const int mod, const float val) { clusCharge.at(mod) += val; }
0129 
0130   void addNClus(const CMSTracker mod, const int val) { nClus.at(getModuleLocation(mod)) += val; }
0131   void addClusSize(const CMSTracker mod, const int val) { clusSize.at(getModuleLocation(mod)) += val; }
0132   void addClusCharge(const CMSTracker mod, const float val) { clusCharge.at(getModuleLocation(mod)) += val; }
0133 
0134   const std::vector<int>& getModules() const { return modules; }
0135   // Return the location of desired module within modules_. If warn is set to true, a warnign will be outputed in case no module was found
0136   int getModuleLocation(int mod, bool warn = true) const;
0137   unsigned int getNumberOfModules() const { return modules.size(); }
0138   int getModule(const int index) const { return modules[index]; }
0139 
0140   //copies over only non-zero entries into the current one
0141   void copyNonEmpty(const ClusterSummary& src);
0142   //Set values to 0
0143   void reset();
0144 
0145 private:
0146   std::vector<int> modules;  // <Module1, Module2 ...>
0147   std::vector<int> nClus;
0148   std::vector<int> clusSize;
0149   std::vector<float> clusCharge;
0150 };
0151 
0152 #endif