CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/EventFilter/SiStripChannelChargeFilter/src/MTCCHLTrigger.cc

Go to the documentation of this file.
00001 #include "EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h"
00002 #include "DataFormats/Common/interface/Handle.h"
00003 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00004 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00005 #include "DataFormats/Common/interface/DetSetVector.h"
00006 
00007 namespace cms
00008 {
00009 MTCCHLTrigger::MTCCHLTrigger(const edm::ParameterSet& ps){
00010    selOnDigiCharge=ps.getParameter<bool>("SelOnDigiCharge");
00011    ChargeThreshold=ps.getParameter<int>("ChargeThreshold");
00012    clusterProducer = ps.getParameter<std::string>("ClusterProducer");
00013    produces <int>();
00014    produces <unsigned int>();
00015 }
00016 
00017 bool MTCCHLTrigger::filter(edm::Event & e, edm::EventSetup const& c) {
00018   //get data
00019   //StripCluster
00020   edm::Handle< edm::DetSetVector<SiStripCluster> > h;
00021   e.getByLabel(clusterProducer,h);
00022 
00023   //StripDigi from RawToDigi and ZeroSuppressor
00024   std::vector< edm::Handle< edm::DetSetVector<SiStripDigi> > > di;
00025   e.getManyByType(di);
00026 
00027   if (selOnDigiCharge) {
00028     unsigned int digiadc=0;
00029     for (std::vector< edm::Handle< edm::DetSetVector<SiStripDigi> > >::const_iterator mi = di.begin(); mi!=di.end(); mi++){
00030       for (edm::DetSetVector<SiStripDigi>::const_iterator it = (*mi)->begin(); it!= (*mi)->end();it++) {
00031         for(std::vector<SiStripDigi>::const_iterator vit=(it->data).begin(); vit!=(it->data).end(); vit++) digiadc += vit->adc();
00032       }
00033     }
00034     return (digiadc>ChargeThreshold) ? true : false;
00035   } else {
00036     unsigned int amplclus=0;
00037     for (edm::DetSetVector<SiStripCluster>::const_iterator it=h->begin();it!=h->end();it++) {
00038       for(std::vector<SiStripCluster>::const_iterator vit=(it->data).begin(); vit!=(it->data).end(); vit++){
00039         for(std::vector<uint8_t>::const_iterator ia=vit->amplitudes().begin(); ia!=vit->amplitudes().end(); ia++) 
00040         {
00041             if  ((*ia)>0){ amplclus+=(*ia); }
00042         }
00043       }
00044     }
00045     bool decision= (amplclus>ChargeThreshold) ? true : false;
00046     std::auto_ptr< unsigned int > output( new unsigned int(amplclus) );
00047     std::auto_ptr< int > output_dec( new int(decision) );
00048     e.put(output);
00049     e.put(output_dec);
00050     return decision;
00051   }
00052  }
00053 }