Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:19

0001 #include "EventFilter/SiStripChannelChargeFilter/interface/MTCCHLTrigger.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0004 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0005 #include "DataFormats/Common/interface/DetSetVector.h"
0006 
0007 namespace cms {
0008   MTCCHLTrigger::MTCCHLTrigger(const edm::ParameterSet& ps) {
0009     selOnDigiCharge = ps.getParameter<bool>("SelOnDigiCharge");
0010     ChargeThreshold = ps.getParameter<int>("ChargeThreshold");
0011     clusterProducer = ps.getParameter<std::string>("ClusterProducer");
0012     produces<int>();
0013     produces<unsigned int>();
0014   }
0015 
0016   bool MTCCHLTrigger::filter(edm::Event& e, edm::EventSetup const& c) {
0017     //get data
0018     //StripCluster
0019     edm::Handle<edm::DetSetVector<SiStripCluster> > h;
0020     e.getByLabel(clusterProducer, h);
0021 
0022     //StripDigi from RawToDigi and ZeroSuppressor
0023     std::vector<edm::Handle<edm::DetSetVector<SiStripDigi> > > di;
0024     e.getManyByType(di);
0025 
0026     if (selOnDigiCharge) {
0027       unsigned int digiadc = 0;
0028       for (std::vector<edm::Handle<edm::DetSetVector<SiStripDigi> > >::const_iterator mi = di.begin(); mi != di.end();
0029            mi++) {
0030         for (edm::DetSetVector<SiStripDigi>::const_iterator it = (*mi)->begin(); it != (*mi)->end(); it++) {
0031           for (std::vector<SiStripDigi>::const_iterator vit = (it->data).begin(); vit != (it->data).end(); vit++)
0032             digiadc += vit->adc();
0033         }
0034       }
0035       return (digiadc > ChargeThreshold) ? true : false;
0036     } else {
0037       unsigned int amplclus = 0;
0038       for (edm::DetSetVector<SiStripCluster>::const_iterator it = h->begin(); it != h->end(); it++) {
0039         for (std::vector<SiStripCluster>::const_iterator vit = (it->data).begin(); vit != (it->data).end(); vit++) {
0040           for (auto ia = vit->amplitudes().begin(); ia != vit->amplitudes().end(); ia++) {
0041             if ((*ia) > 0) {
0042               amplclus += (*ia);
0043             }
0044           }
0045         }
0046       }
0047       bool decision = (amplclus > ChargeThreshold) ? true : false;
0048       e.put(std::make_unique<unsigned int>(amplclus));
0049       e.put(std::make_unique<int>(decision));
0050       return decision;
0051     }
0052   }
0053 }  // namespace cms