CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/SiStripMonitorHardware/plugins/SiStripSpyDisplayModule.cc

Go to the documentation of this file.
00001 /* \file SiStripSpyDisplayModule.cc
00002  * \brief File containing code for the SiStripMonitorFEDProcessing plugin module.
00003  */
00004 // -*- C++ -*-
00005 //
00006 // Package:    SiStripMonitorHardware
00007 // Class:      SiStripSpyDisplayModule
00008 // 
00009 // Standard
00010 #include <memory>
00011 #include <vector>
00012 #include <iostream>
00013 #include <string>
00014 #include <sstream>
00015 
00016 // Framework include files
00017 #include "FWCore/Framework/interface/Frameworkfwd.h"
00018 #include "FWCore/Framework/interface/EDAnalyzer.h"
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/Framework/interface/ESHandle.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 
00024 // Needed for the SST cabling
00025 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00026 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00027 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00028 
00029 // Needed for the pedestal values
00030 #include "CondFormats/SiStripObjects/interface/SiStripPedestals.h"
00031 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
00032 
00033 // Needed for the noise values
00034 #include "CondFormats/SiStripObjects/interface/SiStripNoises.h"
00035 #include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h"
00036 
00037 // For translating between FED key and det ID
00038 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
00039 
00040 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00041 #include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
00042 #include "DataFormats/SiStripDigi/interface/SiStripProcessedRawDigi.h"
00043 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00044 #include "DataFormats/Common/interface/DetSetVector.h"
00045 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00046 
00047 // Needed for the FED raw data processing
00048 #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBuffer.h"
00049 #include "EventFilter/SiStripRawToDigi/interface/SiStripFEDBufferGenerator.h"
00050 #include "EventFilter/SiStripRawToDigi/interface/SiStripDigiToRaw.h"
00051 
00052 //for cabling
00053 #include "DQM/SiStripMonitorHardware/interface/SiStripSpyUtilities.h"
00054 
00055 // For plotting
00056 #include "FWCore/ServiceRegistry/interface/Service.h"
00057 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00058 #include "TH1S.h"
00059 #include "TH1D.h"
00060 
00061 //
00062 // constants, enums and typedefs
00063 //
00064 enum FEDSpyHistogramType {SCOPE_MODE,
00065                           PAYLOAD_RAW,
00066                           REORDERED_PAYLOAD_RAW,
00067                           REORDERED_MODULE_RAW,
00068                           PEDESTAL_VALUES,
00069                           NOISE_VALUES,
00070                           POST_PEDESTAL,
00071                           POST_COMMON_MODE,
00072                           ZERO_SUPPRESSED_PADDED,
00073                           ZERO_SUPPRESSED,
00074                           VR_COMP,
00075                           ZERO_SUPPRESSED_COMP};
00076 
00077 //
00078 // class declaration
00079 //
00080 
00081 
00093 class SiStripSpyDisplayModule : public edm::EDAnalyzer {
00094   public:
00095     explicit SiStripSpyDisplayModule(const edm::ParameterSet&);
00096     ~SiStripSpyDisplayModule();
00097 
00098   private:
00099     virtual void beginRun(const edm::Run&, const edm::EventSetup&);
00100     virtual void beginJob() ;
00101     virtual void analyze(const edm::Event&, const edm::EventSetup&);
00102     virtual void endJob() ;
00103 
00104   Bool_t MakeRawDigiHist_(const edm::Handle< edm::DetSetVector<SiStripRawDigi> > & digi_handle,
00105                             uint32_t specifier,
00106                             const TFileDirectory & dir,
00107                             FEDSpyHistogramType type);  
00108                           
00109   Bool_t MakeProcessedRawDigiHist_(const edm::Handle< edm::DetSetVector<SiStripProcessedRawDigi> > & digi_handle,
00110                                    uint32_t specifier,
00111                                    const TFileDirectory & dir,
00112                                    FEDSpyHistogramType type);                            
00113 
00114     Bool_t MakeDigiHist_(   const edm::Handle< edm::DetSetVector<SiStripDigi> > & digi_handle,
00115                             uint32_t detID,
00116                             const TFileDirectory & dir,
00117                             FEDSpyHistogramType type);                            
00118 
00119     // ----------member data ---------------------------
00120     std::vector<uint32_t>            detIDs_;         
00121   //now from utility class
00122   //    edm::ESHandle<SiStripDetCabling> cabling_;        //!< The Strip Tracker cabling object.
00123   sistrip::SpyUtilities utility_;
00124   
00125     // Data input labels
00126     //===================
00127     edm::InputTag inputScopeModeRawDigiLabel_; 
00128     edm::InputTag inputPayloadRawDigiLabel_; 
00129     edm::InputTag inputReorderedPayloadRawDigiLabel_; 
00130     edm::InputTag inputReorderedModuleRawDigiLabel_; 
00131     edm::InputTag inputPedestalsLabel_;               
00132     edm::InputTag inputNoisesLabel_;               
00133     edm::InputTag inputPostPedestalRawDigiLabel_; 
00134     edm::InputTag inputPostCMRawDigiLabel_; 
00135     edm::InputTag inputZeroSuppressedRawDigiLabel_; 
00136     edm::InputTag inputZeroSuppressedDigiLabel_;    
00137     edm::InputTag inputCompVirginRawDigiLabel_;    
00138     edm::InputTag inputCompZeroSuppressedDigiLabel_;    
00139     //
00140     // Output information
00141     //====================
00142     std::string outputFolderName_; 
00143 
00144 
00145 }; // end of SiStripSpyDisplayModule class
00146 
00147                           
00148 //
00149 // static data member definitions
00150 //
00151 
00152 using namespace sistrip;
00153 using namespace std;
00154 
00155 //
00156 // constructors and destructor
00157 //
00158 SiStripSpyDisplayModule::SiStripSpyDisplayModule(const edm::ParameterSet& iConfig) :
00159     detIDs_(                             iConfig.getParameter< std::vector<uint32_t> >( "detIDs")),
00160     inputScopeModeRawDigiLabel_(         iConfig.getParameter<edm::InputTag>( "InputScopeModeRawDigiLabel" ) ),
00161     inputPayloadRawDigiLabel_(           iConfig.getParameter<edm::InputTag>( "InputPayloadRawDigiLabel" ) ),
00162     inputReorderedPayloadRawDigiLabel_(  iConfig.getParameter<edm::InputTag>( "InputReorderedPayloadRawDigiLabel" ) ),
00163     inputReorderedModuleRawDigiLabel_(   iConfig.getParameter<edm::InputTag>( "InputReorderedModuleRawDigiLabel" ) ),
00164     inputPedestalsLabel_(                iConfig.getParameter<edm::InputTag>( "InputPedestalsLabel" ) ),
00165     inputNoisesLabel_(                   iConfig.getParameter<edm::InputTag>( "InputNoisesLabel" ) ),
00166     inputPostPedestalRawDigiLabel_(      iConfig.getParameter<edm::InputTag>( "InputPostPedestalRawDigiLabel" ) ),
00167     inputPostCMRawDigiLabel_(            iConfig.getParameter<edm::InputTag>( "InputPostCMRawDigiLabel" ) ),
00168     inputZeroSuppressedRawDigiLabel_(    iConfig.getParameter<edm::InputTag>( "InputZeroSuppressedRawDigiLabel" ) ),
00169     inputZeroSuppressedDigiLabel_(       iConfig.getParameter<edm::InputTag>( "InputZeroSuppressedDigiLabel" ) ),
00170     inputCompVirginRawDigiLabel_(        iConfig.getParameter<edm::InputTag>( "InputCompVirginRawDigiLabel" ) ),
00171     inputCompZeroSuppressedDigiLabel_(   iConfig.getParameter<edm::InputTag>( "InputCompZeroSuppressedDigiLabel" ) ),
00172     outputFolderName_(                   iConfig.getParameter<std::string>(   "OutputFolderName"    ) )
00173 {
00174    //now do what ever initialization is needed
00175 }
00176 
00177 
00178 SiStripSpyDisplayModule::~SiStripSpyDisplayModule()
00179 {
00180    // do anything here that needs to be done at desctruction time
00181    // (e.g. close files, deallocate resources etc.)
00182 }
00183 
00184 //
00185 // member functions
00186 //
00187 
00188 void
00189 SiStripSpyDisplayModule::beginRun(const edm::Run & iRun, const edm::EventSetup & iSetup)
00190 {
00191     // Retrieve FED cabling object
00192     //iSetup.get<SiStripDetCablingRcd>().get( cabling_ );
00193     //std::stringstream ss;
00194     //cabling_->print(ss);
00195     //std::cout << ss.str() << std::endl;
00196 
00197 } // end of beginRun method.
00198 
00199 // ------------ method called once each job just before starting event loop  ------------
00200 void 
00201 SiStripSpyDisplayModule::beginJob()
00202 {
00203     // register to the TFileService
00204     edm::Service<TFileService> fs;
00205     // Check that the TFileService has been configured
00206     if ( !fs.isAvailable() ) {
00207         throw cms::Exception("Configuration") << "TFileService not available: did you configure it ?";
00208     }
00209 } // end of beginJob method.
00210 
00211 // ------------ method called once each job just after ending the event loop  ------------
00212 void SiStripSpyDisplayModule::endJob() {}
00213 
00214 // ------------ method called to for each event  ------------
00215 void
00216 SiStripSpyDisplayModule::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00217 {
00218     using namespace edm;
00219     using namespace std;
00220 
00221     //retrieve cabling
00222     const SiStripDetCabling* lCabling = utility_.getDetCabling( iSetup );
00223 
00224     // Set up the event-level histogram folder
00225     //-----------------------------------------
00226     // register to the TFileService
00227     edm::Service<TFileService> fs;
00228 
00229     // Make the EDAnalyzer instance name directory
00230     TFileDirectory an_dir = fs->mkdir( outputFolderName_ );
00231     
00232     // Make the event directory filename
00233     stringstream ev_dir_name; 
00234     ev_dir_name << "run" << iEvent.id().run() << "_event" << iEvent.id().event();
00235     TFileDirectory evdir = an_dir.mkdir( ev_dir_name.str() );
00236 
00237     //if there are no detIds, get them from the comparison digis...
00238     if (detIDs_.size()==0) {
00239         //get the detIds of the modules in the zero-suppressed comparison
00240         if (!((inputCompZeroSuppressedDigiLabel_.label()=="") && (inputCompZeroSuppressedDigiLabel_.instance()==""))) {
00241             edm::Handle< edm::DetSetVector< SiStripDigi > > czs_digis;
00242             iEvent.getByLabel( inputCompZeroSuppressedDigiLabel_, czs_digis );
00243             std::vector< edm::DetSet<SiStripDigi> >::const_iterator digis_it = czs_digis->begin();
00244             for (; digis_it!=czs_digis->end(); ++digis_it) {
00245                 detIDs_.push_back(digis_it->detId());
00246             }
00247         }
00248         else if (!((inputCompVirginRawDigiLabel_.label()=="") && (inputCompVirginRawDigiLabel_.instance()==""))) {
00249             edm::Handle< edm::DetSetVector< SiStripRawDigi > > cvr_digis;
00250             iEvent.getByLabel( inputCompVirginRawDigiLabel_, cvr_digis );
00251             std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis_it = cvr_digis->begin();
00252             for (; digis_it!=cvr_digis->end(); ++digis_it) {
00253                 detIDs_.push_back(digis_it->detId());
00254             }
00255         }
00256 
00257     }
00258 
00259     // Loop over detIDs as obtained from the SpyChannelMonitor config file.
00260     for (std::vector<uint32_t>::iterator d = detIDs_.begin(); d!=detIDs_.end(); ++d) {
00261         // TODO: Need some error checking here, probably...
00262         const std::vector<const FedChannelConnection *> & conns = lCabling->getConnections( *d );
00263         //cout << "________________________________________________" << endl;
00264         //cout << "FED channels found in detId " << *d << " is " << conns.size() << endl;
00265         if (!(conns.size())) {
00266             // TODO: Properly DEBUG/warning this...
00267             //cout << "Skipping detID " << uint32_t(*d) << endl;
00268             continue;
00269         }
00270 
00271         // Create a histogram directory for each specified and available detID
00272         stringstream sss;  
00273         sss << "detID_" << *d;
00274         TFileDirectory detID_dir = evdir.mkdir( sss.str() );
00275 
00276         // Loop over the channels found with the detID and add directories.
00277         for (uint32_t ch = 0; ch<conns.size(); ch++) {
00278             
00279             // Name of channel histogram directory
00280             stringstream ssss; ssss << sss.str() << "_APVpair_" << ch;
00281             TFileDirectory chan_dir = detID_dir.mkdir(ssss.str());
00282             
00283             // Get the fed key from the detID and the channel
00284             uint32_t fedkey = SiStripFedKey::fedIndex(conns[ch]->fedId(), conns[ch]->fedCh());
00285             
00286             // (Spy) Scope Mode (SM)
00287             //=======================
00288             // Get the fed key from the FED ID and the FED channel (from conns)
00289             // This is because scope mode always stores in the collection by FED ID
00290             if (!((inputScopeModeRawDigiLabel_.label()=="") && (inputScopeModeRawDigiLabel_.instance()==""))) {
00291                 // Use the SiStripFedKey object to return the FED key
00292                 //cout << "detID=" << *d << ", FED key looking for is " << fedkey << endl;
00293                 //cout << "Attempting to find scope mode raw digis" << endl;
00294                 //
00295                 edm::Handle< edm::DetSetVector< SiStripRawDigi > > sm_rawdigis;
00296                 iEvent.getByLabel( inputScopeModeRawDigiLabel_, sm_rawdigis );
00297                 //
00298                 // Note that the fed key (also a uint32_t) is passed in this case.
00299                 // The method itself doesn't actually care, but it assumes whatever collection
00300                 // is stored in sm_rawdigis is indexed by FED key ;-)
00301                 // TODO: Make this, um, better.
00302                 if (!(MakeRawDigiHist_(sm_rawdigis, fedkey, chan_dir, SCOPE_MODE))) { ; }
00303             }
00304 
00305             // Payload Unordered Raw (UR)
00306             //============================
00307             if (!((inputPayloadRawDigiLabel_.label()=="") && (inputPayloadRawDigiLabel_.instance()==""))) {
00308                 uint32_t fedindex = SiStripFedKey::fedIndex(conns[ch]->fedId(), conns[ch]->fedCh());
00309                 //cout << "Attempting to find payload mode raw digis" << endl;
00310                 edm::Handle< edm::DetSetVector< SiStripRawDigi > > ur_rawdigis;
00311                 iEvent.getByLabel( inputPayloadRawDigiLabel_, ur_rawdigis );
00312                 if (!(MakeRawDigiHist_(ur_rawdigis, fedindex, chan_dir, PAYLOAD_RAW))) { ; }
00313             }
00314             // Payload Reordered Raw
00315             //=======================
00316             if (!((inputReorderedPayloadRawDigiLabel_.label()=="") && (inputReorderedPayloadRawDigiLabel_.instance()==""))) {
00317                 uint32_t fedkey = SiStripFedKey::fedIndex(conns[ch]->fedId(), conns[ch]->fedCh());
00318                 edm::Handle< edm::DetSetVector< SiStripRawDigi > > rrp_rawdigis;
00319                 iEvent.getByLabel( inputReorderedPayloadRawDigiLabel_, rrp_rawdigis );
00320                 if (!(MakeRawDigiHist_(rrp_rawdigis, fedkey, chan_dir, REORDERED_PAYLOAD_RAW))) { ; }
00321             }
00322         } // end of loop over channels
00323         //
00324         // Module Reordered Raw (RR)
00325         //====================
00326         if (!((inputReorderedModuleRawDigiLabel_.label()=="") && (inputReorderedModuleRawDigiLabel_.instance()==""))) {
00327             edm::Handle< edm::DetSetVector< SiStripRawDigi > > rr_rawdigis;
00328             iEvent.getByLabel( inputReorderedModuleRawDigiLabel_, rr_rawdigis );
00329             //cout << "Making Reordered module histogram for detID " << *d << endl;
00330             if (!(MakeRawDigiHist_(rr_rawdigis, *d, detID_dir, REORDERED_MODULE_RAW))) { ; }
00331         } // end of ReorderedModuleRaw check
00332         
00333         //
00334         // Pedestal values 
00335         //========================
00336         if (!((inputPedestalsLabel_.label()=="") && (inputPedestalsLabel_.instance()==""))) {
00337             edm::Handle< edm::DetSetVector< SiStripRawDigi > > pd_rawdigis;
00338             iEvent.getByLabel( inputPedestalsLabel_, pd_rawdigis );
00339             //cout << "Making pedestal values module histogram for detID " << *d << endl;
00340             if (!(MakeRawDigiHist_(pd_rawdigis, *d, detID_dir, PEDESTAL_VALUES))) { ; }
00341         }
00342          //
00343         // Noise values 
00344         //========================
00345         if (!((inputNoisesLabel_.label()=="") && (inputNoisesLabel_.instance()==""))) {
00346             edm::Handle< edm::DetSetVector< SiStripProcessedRawDigi > > pd_rawdigis;
00347             iEvent.getByLabel( inputNoisesLabel_, pd_rawdigis );
00348             //cout << "Making noise values module histogram for detID " << *d << endl;
00349             if (!(MakeProcessedRawDigiHist_(pd_rawdigis, *d, detID_dir, NOISE_VALUES))) { ; }
00350         }
00351         //
00352         // Post-Pedestal Raw (PP)
00353         //========================
00354         if (!((inputPostPedestalRawDigiLabel_.label()=="") && (inputPostPedestalRawDigiLabel_.instance()==""))) {
00355             edm::Handle< edm::DetSetVector< SiStripRawDigi > > pp_rawdigis;
00356             iEvent.getByLabel( inputPostPedestalRawDigiLabel_, pp_rawdigis );
00357             //cout << "Making post-pedestal module histogram for detID " << *d << endl;
00358             if (!(MakeRawDigiHist_(pp_rawdigis, *d, detID_dir, POST_PEDESTAL))) { ; }
00359         }
00360         //
00361         // Post-Common Mode Subtraction Raw (PC)
00362         //=======================================
00363         if (!((inputPostCMRawDigiLabel_.label()=="") && (inputPostCMRawDigiLabel_.instance()==""))) {
00364             edm::Handle< edm::DetSetVector< SiStripRawDigi > > pc_rawdigis;
00365             iEvent.getByLabel( inputPostCMRawDigiLabel_, pc_rawdigis );
00366             //cout << "Making post-CM module histogram for detID " << *d << endl;
00367             if (!(MakeRawDigiHist_(pc_rawdigis, *d, detID_dir, POST_COMMON_MODE))) { ; }
00368         }
00369         
00370         //
00371         // Zero-Suppressed Digis
00372         //=======================
00373         //bool founddigispy = false, founddigimain = false;
00374         if (!((inputZeroSuppressedDigiLabel_.label()=="") && (inputZeroSuppressedDigiLabel_.instance()==""))) {
00375             //cout << "Making ZeroSuppressed histogram!" << endl;
00376             edm::Handle< edm::DetSetVector< SiStripDigi > > zs_digis;
00377             iEvent.getByLabel( inputZeroSuppressedDigiLabel_, zs_digis );
00378             //founddigispy = 
00379             MakeDigiHist_(zs_digis, *d, detID_dir, ZERO_SUPPRESSED);
00380         }
00381         //comparison to mainline data
00382         if (!((inputCompVirginRawDigiLabel_.label()=="") && (inputCompVirginRawDigiLabel_.instance()==""))) {
00383             //cout << "Making Mainline VirginRaw histogram!" << endl;
00384             edm::Handle< edm::DetSetVector< SiStripRawDigi > > cvr_digis;
00385             iEvent.getByLabel( inputCompVirginRawDigiLabel_, cvr_digis );
00386             //founddigimain = 
00387             MakeRawDigiHist_(cvr_digis, *d, detID_dir, VR_COMP);
00388         }
00389         if (!((inputCompZeroSuppressedDigiLabel_.label()=="") && (inputCompZeroSuppressedDigiLabel_.instance()==""))) {
00390             //cout << "Making ZeroSuppressed histogram!" << endl;
00391             edm::Handle< edm::DetSetVector< SiStripDigi > > czs_digis;
00392             iEvent.getByLabel( inputCompZeroSuppressedDigiLabel_, czs_digis );
00393             //founddigimain = 
00394             MakeDigiHist_(czs_digis, *d, detID_dir, ZERO_SUPPRESSED_COMP);
00395         }
00396         //if (founddigimain && founddigispy) cout << "Found digis for both in detid=" << *d << endl;
00397         
00398     } // end of loop over detIDs specified in the config.
00399 
00400 } // end of Analyze method.
00401 
00402 Bool_t SiStripSpyDisplayModule::MakeRawDigiHist_(
00403     const edm::Handle< edm::DetSetVector< SiStripRawDigi > > & digi_handle,
00404     uint32_t specifier,
00405     const TFileDirectory & dir,
00406     FEDSpyHistogramType type)
00407     //const std::string & name)
00408 {
00409     // TODO: Remove the hard-coded numbers(!).
00410     TH1S * hist;
00411     if      (type==SCOPE_MODE)             hist = dir.make<TH1S>("ScopeMode",           ";Sample number;ADC counts / strip", 298, 0, 298);
00412     else if (type==PAYLOAD_RAW)            hist = dir.make<TH1S>("PayloadRaw",          ";Sample number;ADC counts / strip", 256, 0, 256);
00413     else if (type==REORDERED_PAYLOAD_RAW)  hist = dir.make<TH1S>("ReorderedPayloadRaw", ";Sample number;ADC counts / strip", 256, 0, 256);
00414     else if (type==REORDERED_MODULE_RAW)   hist = dir.make<TH1S>("ReorderedModuleRaw",  ";Sample number;ADC counts / strip", 768, 0, 768);
00415     else if (type==PEDESTAL_VALUES)        hist = dir.make<TH1S>("PedestalValues",      ";Strip number;Pedestal / strip",    768, 0, 768);
00416     else if (type==POST_PEDESTAL)          hist = dir.make<TH1S>("PostPedestal",        ";Strip number;ADC counts / strip",  768, 0, 768);
00417     else if (type==POST_COMMON_MODE)       hist = dir.make<TH1S>("PostCommonMode",      ";Strip number;ADC counts / strip",  768, 0, 768);
00418     else if (type==ZERO_SUPPRESSED_PADDED) hist = dir.make<TH1S>("ZeroSuppressedRaw" ,  ";Strip number;ADC counts / strip",  768, 0, 768);
00419     else if (type==VR_COMP)                hist = dir.make<TH1S>("VirginRawCom" ,       ";Strip number;ADC counts / strip",  768, 0, 768);
00420     else                                  {hist = 0; return false;}
00421 
00422     // TODO: May need to make this error checking independent when refactoring...
00423     //std::cout << "| * digis for " << type << " and detID " << specifier;
00424     std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis_it = digi_handle->find( specifier );
00425     if (digis_it == digi_handle->end()) { 
00426         //std::cout << " not found :( ";
00427         return false;
00428     }
00429     //std::cout << std::endl;
00430 
00431     // Loop over the digis for the detID and APV pair.
00432     edm::DetSet<SiStripRawDigi>::const_iterator idigi = digis_it->data.begin();
00433     uint32_t count = 0;
00434     for ( ; idigi != digis_it->data.end(); ++idigi ) {
00435         count++;
00436         hist->SetBinContent(count,static_cast<int>((*idigi).adc()));
00437     } // end of loop over the digis
00438     return true; // Success! (Probably.)
00439 }
00440 
00441 Bool_t SiStripSpyDisplayModule::MakeProcessedRawDigiHist_(
00442     const edm::Handle< edm::DetSetVector< SiStripProcessedRawDigi > > & digi_handle,
00443     uint32_t specifier,
00444     const TFileDirectory & dir,
00445     FEDSpyHistogramType type)
00446     //const std::string & name)
00447 {
00448     // TODO: Remove the hard-coded numbers(!).
00449     TH1F * hist;
00450     if (type==NOISE_VALUES) hist = dir.make<TH1F>("NoiseValues",";Strip number;Noise / strip",768, 0, 768);
00451     else {
00452       hist = 0; 
00453       return false;
00454     }
00455 
00456     // TODO: May need to make this error checking independent when refactoring...
00457     //std::cout << "| * digis for " << type << " and detID " << specifier;
00458     std::vector< edm::DetSet<SiStripProcessedRawDigi> >::const_iterator digis_it = digi_handle->find( specifier );
00459     if (digis_it == digi_handle->end()) { 
00460         //std::cout << " not found :( ";
00461         return false;
00462     }
00463     //std::cout << std::endl;
00464 
00465     // Loop over the digis for the detID and APV pair.
00466     edm::DetSet<SiStripProcessedRawDigi>::const_iterator idigi = digis_it->data.begin();
00467     uint32_t count = 0;
00468     for ( ; idigi != digis_it->data.end(); ++idigi ) {
00469         count++;
00470         hist->SetBinContent(count,static_cast<float>((*idigi).adc()));
00471     } // end of loop over the digis
00472     return true; // Success! (Probably.)
00473 }
00474 
00475 Bool_t SiStripSpyDisplayModule::MakeDigiHist_(
00476     const edm::Handle< edm::DetSetVector< SiStripDigi > > & digi_handle,
00477     uint32_t detID,
00478     //uint32_t channel,
00479     const TFileDirectory & dir,
00480     FEDSpyHistogramType type)
00481     //const std::string & name)
00482 {
00483     // TODO: Remove the hard-coded numbers.
00484     TH1S * hist;
00485     if      (type==ZERO_SUPPRESSED)        hist = dir.make<TH1S>("ZeroSuppressedDigi",      ";Strip number;ADC counts / strip",  768, 0, 768);
00486     else if (type==ZERO_SUPPRESSED_COMP)   hist = dir.make<TH1S>("ZeroSuppressedDigiComp",  ";Strip number;ADC counts / strip",  768, 0, 768);
00487     else                                  {hist = 0; return false;}
00488     
00489     // TODO: May need to make this error checking independent when refactoring...
00490     std::vector< edm::DetSet<SiStripDigi> >::const_iterator digis_it = digi_handle->find( detID );
00491     if (digis_it == digi_handle->end()) {
00492         return false;
00493     }
00494     else {
00495         //cout << "--* ZS digis found for detID " << detID << endl;
00496     }
00497 
00498     // Loop over the digis for the detID and APV pair.
00499     edm::DetSet<SiStripDigi>::const_iterator idigi = digis_it->data.begin();
00500     bool founddigi = false;
00501     for ( ; idigi != digis_it->data.end(); ++idigi ) {
00502         // Check strip number is within the channel limits
00503         //if ( static_cast<uint16_t>( (*idigi).strip()/256. ) == channel ) {
00504         //    hist->SetBinContent( ((*idigi).strip())%256 + 1,(*idigi).adc());
00505         //}
00506         hist->SetBinContent( static_cast<int>(((*idigi).strip())) + 1, static_cast<int>((*idigi).adc()) );
00507         if ( (*idigi).adc() > 0 ) founddigi = true;
00508         //cout << "----* ZS digi found at " << static_cast<int>(((*idigi).strip()))
00509         //     << ", " << static_cast<int>((*idigi).adc()) << endl;
00510     } // end of loop over the digis
00511 
00512     return founddigi;
00513 }
00514 
00515 // Define this as a plug-in
00516 DEFINE_FWK_MODULE(SiStripSpyDisplayModule);