CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/SiStripChannelChargeFilter/src/TECClusterFilter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     SiStripChannelChargeFilter
00004 // Class  :     TECClusterFilter
00005 // 
00006 //
00007 // Original Author: sfricke 
00008 
00009 
00010 #include "EventFilter/SiStripChannelChargeFilter/interface/TECClusterFilter.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 #include "DataFormats/Common/interface/DetSetVector.h"
00013 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00014 //#include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00015 //#include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00016 //#include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 
00019 using namespace std;
00020 
00021 namespace cms
00022 {
00023 
00024   TECClusterFilter::TECClusterFilter(const edm::ParameterSet& ps){
00025     //
00026     ModulesToBeExcluded.clear();
00027     ModulesToBeExcluded = ps.getParameter< std::vector<unsigned> >("ModulesToBeExcluded");
00028     edm::LogInfo("TECClusterFilter")<<"Clusters from "<<ModulesToBeExcluded.size()<<" modules will be ignored in the filter:";
00029     for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++){
00030       edm::LogInfo("TECClusterFilter")<< *imod;
00031     }
00032     //
00033     ChargeThresholdTEC=ps.getParameter<int>("ChargeThresholdTEC");
00034     edm::LogInfo("TECClusterFilter")<<"ChargeThresholdTEC"<<ChargeThresholdTEC;
00035     minNrOfTECClusters=ps.getParameter<int>("MinNrOfTECClusters");
00036     edm::LogInfo("TECClusterFilter")<<"MinNrOfTECClusters"<<minNrOfTECClusters;
00037     clusterProducer = ps.getParameter<string>("ClusterProducer");
00038     edm::LogInfo("TECClusterFilter")<<"ClusterProducer"<<clusterProducer;
00039 
00040     // also put decision in the event
00041     produces <int>();
00042   }
00043 
00044   bool TECClusterFilter::filter(edm::Event & e, edm::EventSetup const& c) 
00045   {
00046     edm::Handle< edm::DetSetVector<SiStripCluster> > h; //get SiStripCluster
00047     e.getByLabel(clusterProducer,h);
00048     bool decision=false;               // default value, only accept if set true in this loop
00049     unsigned int nr_clusters_above_threshold = 0;
00050     for (edm::DetSetVector<SiStripCluster>::const_iterator it=h->begin();it!=h->end();it++) 
00051       {
00052         DetId thedetId = DetId(it->detId());
00053         bool exclude_this_detid = false;
00054         for(vector<SiStripCluster>::const_iterator vit=(it->data).begin(); vit!=(it->data).end(); vit++) 
00055           {
00056             for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++ )
00057               { if(*imod == thedetId.rawId()) exclude_this_detid = true;  } // found in exclusion list
00058             if(  (! exclude_this_detid ) && (thedetId.subdetId()==StripSubdetector::TEC) ) // if not excluded and if TEC module
00059               { // calculate sum of amplitudes
00060                 unsigned int amplclus=0;
00061                 // int amplclus=0;
00062                 for(vector<uint8_t>::const_iterator ia=vit->amplitudes().begin(); ia!=vit->amplitudes().end(); ia++) 
00063                 // for(vector<short>::const_iterator ia=vit->amplitudes().begin(); ia!=vit->amplitudes().end(); ia++) 
00064                   { if ((*ia)>0) amplclus+=(*ia); } // why should this be negative?
00065                 if(amplclus>ChargeThresholdTEC) nr_clusters_above_threshold++;
00066               }
00067           }
00068       }
00069     if(nr_clusters_above_threshold>=minNrOfTECClusters) decision=true;
00070     std::auto_ptr< int > output_decision( new int(decision) );
00071     e.put(output_decision);
00072     return decision;
00073   }
00074 }