CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterMTCCFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripChannelChargeFilter
4 // Class : ClusterMTCCFilter
5 //
6 //
7 // Original Author: dkcira
8 
9 
18 
19 using namespace std;
20 
21 namespace cms
22 {
23 
24 ClusterMTCCFilter::ClusterMTCCFilter(const edm::ParameterSet& ps){
25  //
26  ModulesToBeExcluded.clear();
27  ModulesToBeExcluded = ps.getParameter< std::vector<unsigned> >("ModulesToBeExcluded");
28  edm::LogInfo("ClusterMTCCFilter")<<"Clusters from "<<ModulesToBeExcluded.size()<<" modules will be ignored in the filter:";
29  for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++){
30  edm::LogInfo("ClusterMTCCFilter")<< *imod;
31  }
32  //
33  ChargeThresholdTIB=ps.getParameter<int>("ChargeThresholdTIB");
34  ChargeThresholdTOB=ps.getParameter<int>("ChargeThresholdTOB");
35  ChargeThresholdTEC=ps.getParameter<int>("ChargeThresholdTEC");
36  MinClustersDiffComponents=ps.getParameter<int>("MinClustersDiffComponents");
37  clusterProducer = ps.getParameter<string>("ClusterProducer");
38  //
39  produces <int>();
40  produces <unsigned int >();
41  produces < map<unsigned int,vector<SiStripCluster> > >();
42 }
43 
45 
46  //Retrieve tracker topology from geometry
48  c.get<IdealGeometryRecord>().get(tTopoHandle);
49  const TrackerTopology* const tTopo = tTopoHandle.product();
50 
51  //get SiStripCluster
53  e.getByLabel(clusterProducer,h);
54 
55 
56  //
57  unsigned int sum_of_cluster_charges=0;
58  clusters_in_subcomponents.clear();
59  // first find all clusters that are over the threshold
60  for (edm::DetSetVector<SiStripCluster>::const_iterator it=h->begin();it!=h->end();it++) {
61  for(vector<SiStripCluster>::const_iterator vit=(it->data).begin(); vit!=(it->data).end(); vit++){
62  // calculate sum of amplitudes
63  unsigned int amplclus=0;
64  for(auto ia=vit->amplitudes().begin(); ia!=vit->amplitudes().end(); ia++) {
65  if ((*ia)>0) amplclus+=(*ia); // why should this be negative?
66  }
67  sum_of_cluster_charges += amplclus;
68  DetId thedetId = DetId(it->detId());
69  unsigned int generalized_layer = 0;
70  bool exclude_this_detid = false;
71  for( std::vector<uint32_t>::const_iterator imod = ModulesToBeExcluded.begin(); imod != ModulesToBeExcluded.end(); imod++ ){
72  if(*imod == thedetId.rawId()) exclude_this_detid = true; // found in exclusion list
73  }
74  // apply different thresholds for TIB/TOB/TEC
75  if( ! exclude_this_detid ){ // only consider if not in exclusion list
76  if ( ( thedetId.subdetId()==StripSubdetector::TIB && amplclus>ChargeThresholdTIB )
77  || ( thedetId.subdetId()==StripSubdetector::TOB && amplclus>ChargeThresholdTOB )
78  || ( thedetId.subdetId()==StripSubdetector::TEC && amplclus>ChargeThresholdTEC )
79  ){
80  // calculate generalized_layer: 31 = TIB1, 32 = TIB2, 33 = TIB3, 50 = TOB, 60 = TEC
81  if(thedetId.subdetId()==StripSubdetector::TIB){
82 
83  generalized_layer = 10*thedetId.subdetId() + tTopo->tibLayer(thedetId.rawId()) + tTopo->tibStereo(thedetId.rawId());
84  if (tTopo->tibLayer(thedetId.rawId())==2){
85  generalized_layer++;
86  if (tTopo->tibGlued(thedetId.rawId())) edm::LogError("ClusterMTCCFilter")<<"WRONGGGG"<<endl;
87  }
88  }else{
89  generalized_layer = 10*thedetId.subdetId();
90  if(thedetId.subdetId()==StripSubdetector::TOB){
91 
92  generalized_layer += tTopo->tobLayer(thedetId.rawId());
93  }
94  }
95  // fill clusters_in_subcomponents
96  map<unsigned int,vector<SiStripCluster> >::iterator layer_it = clusters_in_subcomponents.find(generalized_layer);
97  if(layer_it==clusters_in_subcomponents.end()){ // if layer not found yet, create DATA vector and generate map KEY + DATA
98  vector<SiStripCluster> local_vector;
99  local_vector.push_back(*vit);
100  clusters_in_subcomponents.insert( std::make_pair( generalized_layer, local_vector) );
101  }else{ // push into already existing vector
102  (layer_it->second).push_back(*vit);
103  }
104  }
105  }
106  }
107  }
108 
109  bool decision=false; // default value, only accept if set true in this loop
110  unsigned int nr_of_subcomps_with_clusters=0;
111 // dk: 2006.08.24 - change filter decision as proposed by V. Ciulli. || TIB1 TIB2 counted as 1, TEC excluded
112 // if( clusters_in_subcomponents[31].size()>0 ) nr_of_subcomps_with_clusters++; // TIB1
113 // if( clusters_in_subcomponents[32].size()>0 ) nr_of_subcomps_with_clusters++; // TIB2
114 // if( clusters_in_subcomponents[60].size()>0 ) nr_of_subcomps_with_clusters++; // TEC
115  if( clusters_in_subcomponents[31].size()>0 || clusters_in_subcomponents[32].size()>0 ) nr_of_subcomps_with_clusters++; // TIB1 || TIB2
116  if( clusters_in_subcomponents[33].size()>0 ) nr_of_subcomps_with_clusters++; // TIB3
117  if( clusters_in_subcomponents[51].size()>0 ) nr_of_subcomps_with_clusters++; // TOB1
118  if( clusters_in_subcomponents[52].size()>0 ) nr_of_subcomps_with_clusters++; // TOB2
119  if(
120  nr_of_subcomps_with_clusters >= MinClustersDiffComponents // more than 'MinClustersDiffComponents' components have at least 1 cluster
121  ) {
122  decision = true; // accept event
123  }
124 
125  std::auto_ptr< int > output_decision( new int(decision) );
126  e.put(output_decision);
127 
128  std::auto_ptr< unsigned int > output_sumofcharges( new unsigned int(sum_of_cluster_charges) );
129  e.put(output_sumofcharges);
130 
131  std::auto_ptr< map<unsigned int,vector<SiStripCluster> > > output_clusters(new map<unsigned int,vector<SiStripCluster> > (clusters_in_subcomponents));
132  e.put(output_clusters);
133 
134  return decision;
135 }
136 }
T getParameter(std::string const &) const
unsigned int tibLayer(const DetId &id) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define end
Definition: vmac.h:37
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
Definition: DetId.h:18
uint32_t tibGlued(const DetId &id) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
uint32_t tibStereo(const DetId &id) const
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
tuple size
Write out results.
unsigned int tobLayer(const DetId &id) const