CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h

Go to the documentation of this file.
00001 #ifndef DCCDATAUNPACKER_HH
00002 #define DCCDATAUNPACKER_HH
00003 
00004 
00005 /*
00006  *\ Class DCCDataUnpacker
00007  *
00008  * This class takes care of unpacking ECAL's raw data info.
00009  * A gateway for all blocks unpackers and committing collections to the Event
00010  * DCCEBEventBlock and DCCEEEventBlock are used here
00011  *
00012  * \file DCCDataUnpacker.h
00013  *
00014  * $Date: 2010/10/04 07:44:38 $
00015  * $Revision: 1.5 $
00016  * \author N. Almeida
00017  * \author G. Franzoni
00018  *
00019 */
00020 //C++
00021 #include <fstream>                   
00022 #include <iostream>
00023 #include <string>
00024 #include <vector>
00025 #include <map>
00026 #include <stdio.h>                     
00027 #include <stdint.h>
00028 
00029 //DATA DECODER
00030 
00031 #include "DCCEventBlock.h"
00032 
00033 #include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
00034 #include <DataFormats/EcalDigi/interface/EcalPnDiodeDigi.h>
00035 
00036 #include <DataFormats/EcalDetId/interface/EcalDetIdCollections.h>
00037 #include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
00038 
00039 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00040 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00041 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
00042 
00043 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00044 
00045 class EcalElectronicsMapper;
00046 class DCCEventBlock;
00047 class DCCEBEventBlock;
00048 class DCCEEEventBlock;
00049 class EcalRawToDigi;
00050 
00051 class DCCDataUnpacker{
00052 
00053 public : 
00054   
00055   DCCDataUnpacker(EcalElectronicsMapper *, bool hU,bool srpU, bool tccU, bool feU, bool memU, bool syncCheck, bool feIdCheck, bool forceToKeepFRdata);
00056   ~DCCDataUnpacker();
00060   void unpack( uint64_t * buffer, unsigned int bufferSize, unsigned int smId, unsigned int fedId);
00061 
00062 
00067   void setEBDigisCollection( std::auto_ptr<EBDigiCollection>                         * x )
00068   { ebDigis_                = x; } 
00069  
00070   void setEEDigisCollection( std::auto_ptr<EEDigiCollection>                         * x )
00071   { eeDigis_                = x; } 
00072  
00073   void setDccHeadersCollection( std::auto_ptr<EcalRawDataCollection>                 * x )
00074   { dccHeaders_             = x; }
00075  
00076   void setEBSrFlagsCollection( std::auto_ptr<EBSrFlagCollection>                     * x )
00077   { ebSrFlags_              = x; } 
00078   
00079   void setEESrFlagsCollection( std::auto_ptr<EESrFlagCollection>                     * x )
00080   { eeSrFlags_              = x; }
00081 
00082   void setEcalTpsCollection( std::auto_ptr<EcalTrigPrimDigiCollection>                  * x )
00083   { ecalTps_                  = x; }
00084 
00085   void  setEcalPSsCollection( std::auto_ptr<EcalPSInputDigiCollection>                  * x )
00086   { ecalPSs_                  = x; }
00087 
00088   void setInvalidGainsCollection( std::auto_ptr<EBDetIdCollection>                    * x )
00089   { invalidGains_           = x; }
00090  
00091   void setInvalidGainsSwitchCollection( std::auto_ptr<EBDetIdCollection>              * x )
00092   { invalidGainsSwitch_     = x; }
00093  
00094   void setInvalidChIdsCollection( std::auto_ptr<EBDetIdCollection>                    * x )
00095   { invalidChIds_           = x; }
00096 
00097   // EE 
00098   void setInvalidEEGainsCollection( std::auto_ptr<EEDetIdCollection>                    * x )
00099   { invalidEEGains_           = x; }
00100   
00101   void setInvalidEEGainsSwitchCollection( std::auto_ptr<EEDetIdCollection>              * x )
00102   { invalidEEGainsSwitch_     = x; }
00103  
00104   void setInvalidEEChIdsCollection( std::auto_ptr<EEDetIdCollection>                    * x )
00105   { invalidEEChIds_           = x; }
00106   // EE 
00107  
00108   void setInvalidTTIdsCollection( std::auto_ptr<EcalElectronicsIdCollection>         * x )
00109   { invalidTTIds_           = x; }
00110 
00111   void setInvalidZSXtalIdsCollection( std::auto_ptr<EcalElectronicsIdCollection>     * x )
00112   { invalidZSXtalIds_           = x; }
00113 
00114   void setInvalidBlockLengthsCollection( std::auto_ptr<EcalElectronicsIdCollection>  * x )
00115   { invalidBlockLengths_    = x; }
00116  
00117   void setPnDiodeDigisCollection( std::auto_ptr<EcalPnDiodeDigiCollection>            * x )
00118   { pnDiodeDigis_           = x; }
00119  
00120   void setInvalidMemTtIdsCollection( std::auto_ptr<EcalElectronicsIdCollection>      * x )
00121   { invalidMemTtIds_        = x; }
00122  
00123   void setInvalidMemBlockSizesCollection( std::auto_ptr<EcalElectronicsIdCollection> * x )
00124   { invalidMemBlockSizes_   = x; }
00125  
00126   void setInvalidMemChIdsCollection( std::auto_ptr<EcalElectronicsIdCollection>      * x )
00127   { invalidMemChIds_        = x; }
00128  
00129   void setInvalidMemGainsCollection( std::auto_ptr<EcalElectronicsIdCollection>      * x )
00130   { invalidMemGains_        = x; }
00131   
00132  
00137   std::auto_ptr<EBDigiCollection>             * ebDigisCollection()
00138   { return ebDigis_;               }
00139   
00140   std::auto_ptr<EEDigiCollection>             * eeDigisCollection()
00141   { return eeDigis_;               }
00142   
00143   std::auto_ptr<EcalTrigPrimDigiCollection>   * ecalTpsCollection()
00144   { return ecalTps_;                 } 
00145   
00146   std::auto_ptr<EcalPSInputDigiCollection>    * ecalPSsCollection()
00147   { return ecalPSs_;                 } 
00148 
00149   std::auto_ptr<EBSrFlagCollection>           * ebSrFlagsCollection()
00150   { return ebSrFlags_;             }  
00151   
00152   std::auto_ptr<EESrFlagCollection>           * eeSrFlagsCollection()
00153   { return eeSrFlags_;             } 
00154   
00155   std::auto_ptr<EcalRawDataCollection>        * dccHeadersCollection()
00156   { return dccHeaders_;            }
00157   
00158   std::auto_ptr<EBDetIdCollection>            * invalidGainsCollection()
00159   { return invalidGains_;          }
00160   
00161   std::auto_ptr<EBDetIdCollection>            * invalidGainsSwitchCollection()
00162   { return invalidGainsSwitch_;    }
00163   
00164   std::auto_ptr<EBDetIdCollection>            * invalidChIdsCollection()
00165   { return invalidChIds_;          }
00166 
00167   //EE
00168   std::auto_ptr<EEDetIdCollection>            * invalidEEGainsCollection()
00169   { return invalidEEGains_;          }
00170   
00171   std::auto_ptr<EEDetIdCollection>            * invalidEEGainsSwitchCollection()
00172   { return invalidEEGainsSwitch_;    }
00173   
00174   std::auto_ptr<EEDetIdCollection>            * invalidEEChIdsCollection()
00175   { return invalidEEChIds_;          }
00176   //EE
00177 
00178   std::auto_ptr<EcalElectronicsIdCollection> * invalidTTIdsCollection()
00179   { return invalidTTIds_;          }
00180 
00181   std::auto_ptr<EcalElectronicsIdCollection> * invalidZSXtalIdsCollection()
00182   { return invalidZSXtalIds_;          }  
00183   
00184   std::auto_ptr< EcalElectronicsIdCollection> * invalidBlockLengthsCollection()
00185   { return invalidBlockLengths_;   }
00186      
00187   std::auto_ptr<EcalElectronicsIdCollection>  * invalidMemTtIdsCollection()
00188   { return invalidMemTtIds_;       }
00189  
00190   std::auto_ptr<EcalElectronicsIdCollection>  * invalidMemBlockSizesCollection()
00191   { return invalidMemBlockSizes_;  }
00192   
00193   std::auto_ptr<EcalElectronicsIdCollection>  * invalidMemChIdsCollection()
00194   { return invalidMemChIds_;       }
00195   
00196   std::auto_ptr<EcalElectronicsIdCollection>  * invalidMemGainsCollection()
00197   { return invalidMemGains_;       }
00198 
00199   std::auto_ptr<EcalPnDiodeDigiCollection>    * pnDiodeDigisCollection()
00200   { return pnDiodeDigis_;          }
00201   
00202 
00206   const EcalElectronicsMapper * electronicsMapper() const { return electronicsMapper_; }
00207   
00208   
00212   void setChannelStatusDB(const EcalChannelStatusMap* chdb) { chdb_ = chdb; }
00213   // return status of given crystal
00214   // https://twiki.cern.ch/twiki/bin/view/CMS/EcalChannelStatus#Assigning_Channel_status
00215   uint16_t getChannelStatus(const DetId& id) const;
00216   // return low 5 bits of status word
00217   uint16_t getChannelValue(const DetId& id) const;
00218   uint16_t getChannelValue(const int fed, const int ccu, const int strip, const int xtal) const;
00219   // return status of given CCU
00220   uint16_t getCCUValue(const int fed, const int ccu) const;
00221   
00222   
00226   DCCEventBlock * currentEvent(){ return currentEvent_;}
00227 
00228   static bool silentMode_; 
00229  
00230 protected :
00231 
00232   // Data collections pointers
00233   std::auto_ptr<EBDigiCollection>            * ebDigis_;
00234   std::auto_ptr<EEDigiCollection>            * eeDigis_;
00235   std::auto_ptr<EcalTrigPrimDigiCollection>  * ecalTps_;
00236   std::auto_ptr<EcalPSInputDigiCollection>   * ecalPSs_;
00237   std::auto_ptr<EcalRawDataCollection>       * dccHeaders_;
00238   std::auto_ptr<EBDetIdCollection>           * invalidGains_;
00239   std::auto_ptr<EBDetIdCollection>           * invalidGainsSwitch_;
00240   std::auto_ptr<EBDetIdCollection>           * invalidChIds_;
00241   //EE
00242   std::auto_ptr<EEDetIdCollection>           * invalidEEGains_;
00243   std::auto_ptr<EEDetIdCollection>           * invalidEEGainsSwitch_;
00244   std::auto_ptr<EEDetIdCollection>           * invalidEEChIds_;
00245   //EE
00246   std::auto_ptr<EBSrFlagCollection>          * ebSrFlags_;
00247   std::auto_ptr<EESrFlagCollection>          * eeSrFlags_;
00248   std::auto_ptr<EcalElectronicsIdCollection> * invalidTTIds_;
00249   std::auto_ptr<EcalElectronicsIdCollection> * invalidZSXtalIds_;
00250   std::auto_ptr<EcalElectronicsIdCollection> * invalidBlockLengths_; 
00251   
00252   std::auto_ptr<EcalElectronicsIdCollection> * invalidMemTtIds_ ;
00253   std::auto_ptr<EcalElectronicsIdCollection> * invalidMemBlockSizes_ ;
00254   std::auto_ptr<EcalElectronicsIdCollection> * invalidMemChIds_ ;
00255   std::auto_ptr<EcalElectronicsIdCollection> * invalidMemGains_ ;
00256   std::auto_ptr<EcalPnDiodeDigiCollection>   * pnDiodeDigis_;
00257 
00258   EcalElectronicsMapper  * electronicsMapper_;
00259   const EcalChannelStatusMap* chdb_;
00260   DCCEventBlock          * currentEvent_;
00261   DCCEBEventBlock        * ebEventBlock_;
00262   DCCEEEventBlock        * eeEventBlock_;
00263                 
00264 };
00265 
00266 #endif