CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/SimCalorimetry/EcalElectronicsEmulation/interface/EcalSimRawData.h

Go to the documentation of this file.
00001 /*  
00002  * $Id: EcalSimRawData.h,v 1.8 2007/05/15 20:57:01 nuno Exp $
00003  */
00004 
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/Framework/interface/EDAnalyzer.h"
00008 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00009 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00010 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00011 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00012 #include "SimCalorimetry/EcalSelectiveReadoutAlgos/src/EcalSelectiveReadout.h"
00013 #include <string>
00014 #include <fstream>
00015 
00042 class EcalSimRawData: public edm::EDAnalyzer{
00043   public:
00047   explicit EcalSimRawData(const edm::ParameterSet& pset);
00048 
00051   virtual ~EcalSimRawData(){};
00052 
00056   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00057 
00058 private:
00061   static const int nEbEta = 170;
00062 
00065   static const int nEbPhi = 360;
00066 
00069   static const int nEeX = 100;
00070 
00073   static const int nEeY = 100;
00074 
00077   static const int nEndcaps = 2;
00078 
00081   static const int scEdge = 5;
00082 
00085   static const int nScX = 20;
00086 
00089   static const int nScY = 20;
00090 
00091   /* Edge size of a barrel TT in num. of crystals
00092   */
00093   static const int ttEdge = 5;
00094 
00097   static const int nTtSmPhi = 4;
00098 
00101   static const int nTtSmEta = 17;
00102 
00105   static const int nTtPhi = nEbPhi/ttEdge;//72
00106 
00109   static const int nEbTtEta = nEbEta/ttEdge;//34
00110 
00113   static const int nEeTtEta = 11;
00114 
00117   static const int nTtEta = nEbTtEta+2*nEeTtEta;//56
00118 
00121   static const int nDccInPhi = 18;
00122 
00125   static const int nDccEndcap = 9;
00126 
00129   static const int ebTccPhiEdge = 20;
00130 
00133   static const int nTccInPhi = 18;
00134 
00137   static const int nTccEndcap = 36;
00138 
00141   static const int ebDccPhiEdge = 20;
00142 
00145   static const int nTtPhisPerEbDcc = 4;
00146 
00149   static const int nTtPhisPerEbTcc = 4;
00150 
00153   static const int nTtTypes = 2;
00154 
00159   static const int ttType[nEbTtEta];
00160 
00167   static const int stripCh2Phi[nTtTypes][ttEdge][ttEdge];
00168 
00174   static const int strip2Eta[nTtTypes][ttEdge];
00175 
00183   enum writeMode_t {littleEndian, bigEndian, ascii};
00184   
00185 private:
00186   /*
00187   const EBDigiCollection*
00188   getEBDigis(const edm::Event& event) const;
00189   
00190   const EEDigiCollection*
00191   getEEDigis(const edm::Event& event) const;
00192 
00193   const EcalTrigPrimDigiCollection*
00194   getTrigPrims(const edm::Event& event) const;
00195   */
00196   
00199   void
00200   checkGeometry(const edm::EventSetup& eventSetup);
00201   void
00202   checkTriggerMap(const edm::EventSetup& eventSetup);
00203 
00209   int iEta2cIndex(int iEta) const{
00210     return (iEta<0)?iEta+85:iEta+84;
00211   }
00212 
00218   int iPhi2cIndex(int iPhi) const{
00219     int iPhi0 = iPhi -11;
00220     if(iPhi0<0) iPhi0+=nEbPhi;
00221     return iPhi0;
00222   }
00223 
00230   int iTtEta2cIndex(int iTtEta) const{
00231     return (iTtEta<0)?(iTtEta+28):(iTtEta+27);
00232   }
00233 
00238   int cIndex2iTtEta(int iTtEta0) const{
00239     return (iTtEta0<28)?(iTtEta0-28):(iTtEta0-27);
00240   }
00241 
00246   int cIndex2TtPhi(int iTtPhi0) const{
00247     return iTtPhi0+1;
00248   }
00249   
00255   int iTtPhi2cIndex(int iTtPhi) const{
00256     return iTtPhi-1;
00257   }
00258 
00259   /*
00260     int iXY2cIndex(int iX) const{
00261     return iX-1;
00262   }
00263   */
00264 
00274   void elec2GeomNum(int ittEta0, int ittPhi0, int strip1,
00275                     int ch1, int& iEta0, int& iPhi0) const;
00276 
00277   /* Set horizontal parity of a 16-bit word of FE data
00278    * @param a the word whose parity must be set.
00279    */
00280   void setHParity(uint16_t& a) const;
00281 
00288   void genFeData(std::string basename, int iEvent,
00289                  const std::vector<uint16_t> adcCount[nEbEta][nEbPhi]) const;
00290 
00291 
00298   void genTccIn(std::string basename, int iEvent,
00299                 const int tps[nTtEta][nTtPhi]) const;
00300 
00307   void genTccOut(std::string basename, int iEvent,
00308                  const int tps[nTtEta][nTtPhi]) const;
00309 
00310 
00311   
00316   void getEbDigi(const edm::Event& event,
00317                  std::vector<uint16_t> adc[nEbEta][nEbPhi]) const;
00318 
00319 
00328   void getTp(const edm::Event& event, const std::string& collName,
00329              int tp[nTtEta][nTtPhi]) const;
00330 
00331   
00335   std::string getExt() const;
00336 
00346   void fwrite(std::ofstream& f, uint16_t data, int& iword,
00347               bool hpar = true) const;
00348 
00349 
00355   void getSrfs(const edm::Event& event, int ebSrf[nTtEta][nTtPhi],
00356                int eeSrf[nEndcaps][nScX][nScY]) const;
00357 
00364   void genSrData(std::string basename, int iEvent,
00365                  int ttf[nEbTtEta][nTtPhi]) const;
00366   
00367 private:
00370   std::string digiProducer_;
00371 
00374   std::string ebDigiCollection_;
00375 
00378   std::string eeDigiCollection_;
00379 
00380 
00383   std::string srDigiProducer_;
00384   
00387   std::string ebSrFlagCollection_;
00388 
00391   std::string eeSrFlagCollection_;
00392 
00395   std::string tpDigiCollection_; 
00396 
00399   std::string tcpDigiCollection_; 
00400   
00403   const CaloGeometry * theGeometry;
00404 
00407   std::string tpProducer_;
00408 
00411   writeMode_t writeMode_;
00412 
00415   bool xtalVerbose_;
00416 
00419   bool tpVerbose_;
00420 
00423   bool srp2dcc_;
00424 
00427   bool tcc2dcc_;
00428 
00431   bool fe2dcc_;
00432 
00435   bool fe2tcc_;
00436 
00439   const EcalTrigTowerConstituentsMap * theTriggerTowerMap;
00440 
00443   std::auto_ptr<EcalSelectiveReadout> esr_;
00444 
00447   std::ofstream ttfFile;
00448 
00451   std::ofstream srfFile;
00452 
00455   int tccNum_;
00456   
00459   int dccNum_;
00460   
00463   int tccInDefaultVal_;
00464   
00467   std::string basename_;
00468 };
00469