Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "EventFilter/SiStripChannelChargeFilter/interface/ClusterMTCCFilter.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/TOBDetId.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017
00018 using namespace std;
00019
00020 namespace cms
00021 {
00022
00023 ClusterMTCCFilter::ClusterMTCCFilter(const edm::ParameterSet& ps){
00024
00025 ModulesToBeExcluded.clear();
00026 ModulesToBeExcluded = ps.getParameter< std::vector<unsigned> >("ModulesToBeExcluded");
00027 edm::LogInfo("ClusterMTCCFilter")<<"Clusters from "<<ModulesToBeExcluded.size()<<" modules will be ignored in the filter:";
00028 for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++){
00029 edm::LogInfo("ClusterMTCCFilter")<< *imod;
00030 }
00031
00032 ChargeThresholdTIB=ps.getParameter<int>("ChargeThresholdTIB");
00033 ChargeThresholdTOB=ps.getParameter<int>("ChargeThresholdTOB");
00034 ChargeThresholdTEC=ps.getParameter<int>("ChargeThresholdTEC");
00035 MinClustersDiffComponents=ps.getParameter<int>("MinClustersDiffComponents");
00036 clusterProducer = ps.getParameter<string>("ClusterProducer");
00037
00038 produces <int>();
00039 produces <unsigned int >();
00040 produces < map<unsigned int,vector<SiStripCluster> > >();
00041 }
00042
00043 bool ClusterMTCCFilter::filter(edm::Event & e, edm::EventSetup const& c) {
00044
00045 edm::Handle< edm::DetSetVector<SiStripCluster> > h;
00046 e.getByLabel(clusterProducer,h);
00047
00048
00049
00050 unsigned int sum_of_cluster_charges=0;
00051 clusters_in_subcomponents.clear();
00052
00053 for (edm::DetSetVector<SiStripCluster>::const_iterator it=h->begin();it!=h->end();it++) {
00054 for(vector<SiStripCluster>::const_iterator vit=(it->data).begin(); vit!=(it->data).end(); vit++){
00055
00056 unsigned int amplclus=0;
00057 for(vector<uint8_t>::const_iterator ia=vit->amplitudes().begin(); ia!=vit->amplitudes().end(); ia++) {
00058 if ((*ia)>0) amplclus+=(*ia);
00059 }
00060 sum_of_cluster_charges += amplclus;
00061 DetId thedetId = DetId(it->detId());
00062 unsigned int generalized_layer = 0;
00063 bool exclude_this_detid = false;
00064 for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++ ){
00065 if(*imod == thedetId.rawId()) exclude_this_detid = true;
00066 }
00067
00068 if( ! exclude_this_detid ){
00069 if ( ( thedetId.subdetId()==StripSubdetector::TIB && amplclus>ChargeThresholdTIB )
00070 || ( thedetId.subdetId()==StripSubdetector::TOB && amplclus>ChargeThresholdTOB )
00071 || ( thedetId.subdetId()==StripSubdetector::TEC && amplclus>ChargeThresholdTEC )
00072 ){
00073
00074 if(thedetId.subdetId()==StripSubdetector::TIB){
00075 TIBDetId ptib = TIBDetId(thedetId.rawId());
00076 generalized_layer = 10*thedetId.subdetId() + ptib.layer() + ptib.stereo();
00077 if (ptib.layer()==2){
00078 generalized_layer++;
00079 if (ptib.glued()) edm::LogError("ClusterMTCCFilter")<<"WRONGGGG"<<endl;
00080 }
00081 }else{
00082 generalized_layer = 10*thedetId.subdetId();
00083 if(thedetId.subdetId()==StripSubdetector::TOB){
00084 TOBDetId ptob = TOBDetId(thedetId.rawId());
00085 generalized_layer += ptob.layer();
00086 }
00087 }
00088
00089 map<unsigned int,vector<SiStripCluster> >::iterator layer_it = clusters_in_subcomponents.find(generalized_layer);
00090 if(layer_it==clusters_in_subcomponents.end()){
00091 vector<SiStripCluster> local_vector;
00092 local_vector.push_back(*vit);
00093 clusters_in_subcomponents.insert( std::make_pair( generalized_layer, local_vector) );
00094 }else{
00095 (layer_it->second).push_back(*vit);
00096 }
00097 }
00098 }
00099 }
00100 }
00101
00102 bool decision=false;
00103 unsigned int nr_of_subcomps_with_clusters=0;
00104
00105
00106
00107
00108 if( clusters_in_subcomponents[31].size()>0 || clusters_in_subcomponents[32].size()>0 ) nr_of_subcomps_with_clusters++;
00109 if( clusters_in_subcomponents[33].size()>0 ) nr_of_subcomps_with_clusters++;
00110 if( clusters_in_subcomponents[51].size()>0 ) nr_of_subcomps_with_clusters++;
00111 if( clusters_in_subcomponents[52].size()>0 ) nr_of_subcomps_with_clusters++;
00112 if(
00113 nr_of_subcomps_with_clusters >= MinClustersDiffComponents
00114 ) {
00115 decision = true;
00116 }
00117
00118 std::auto_ptr< int > output_decision( new int(decision) );
00119 e.put(output_decision);
00120
00121 std::auto_ptr< unsigned int > output_sumofcharges( new unsigned int(sum_of_cluster_charges) );
00122 e.put(output_sumofcharges);
00123
00124 std::auto_ptr< map<unsigned int,vector<SiStripCluster> > > output_clusters(new map<unsigned int,vector<SiStripCluster> > (clusters_in_subcomponents));
00125 e.put(output_clusters);
00126
00127 return decision;
00128 }
00129 }