CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterSummaryProducer.cc
Go to the documentation of this file.
2 
4  : stripModules(iConfig.getParameter<std::string>("stripModule")),
5  pixelModules(iConfig.getParameter<std::string>("pixelModule")),
6  stripVariables(iConfig.getParameter<std::string>("stripVariables")),
7  pixelVariables(iConfig.getParameter<std::string>("pixelVariables")),
8  doStrips(iConfig.getParameter<bool>("doStrips")),
9  doPixels(iConfig.getParameter<bool>("doPixels")),
10  verbose(iConfig.getParameter<bool>("verbose"))
11 {
12 
13  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<edm::InputTag>("pixelClusters"));
14  stripClusters_ = consumes<edmNew::DetSetVector<SiStripCluster> >(iConfig.getParameter<edm::InputTag>("stripClusters"));
15 
16  //register your products
17  produces<ClusterSummary>().setBranchAlias("SummaryCollection");
18 
19  firstpass = true;
20  firstpass_mod = true;
21  firstpassPixel = true;
22  firstpassPixel_mod = true;
23 
24 }
25 
26 
27 void
29 {
30  using namespace edm;
31 
33 
34  //===================++++++++++++========================
35  //
36  // For SiStrips
37  //
38  //===================++++++++++++========================
39  if (doStrips){
41  iEvent.getByToken(stripClusters_, stripClusters);
42 
43  ModuleSelectionVect.clear();
44  for ( std::vector<std::string>::iterator it=v_stripModuleTypes.begin() ; it < v_stripModuleTypes.end(); it++ ){
46  }
47 
48  firstpass_mod = true;
49 
50  int CurrMod = -1;
51  //Loop over all the ModuleSelectors
52  for ( unsigned int i = 0; i < ModuleSelectionVect.size(); i++){
53 
54  // Loop over the strip clusters
55  edmNew::DetSetVector<SiStripCluster>::const_iterator itClusters=stripClusters->begin();
56  for(;itClusters!=stripClusters->end();++itClusters){
57  uint32_t id = itClusters->id();
58  for(edmNew::DetSet<SiStripCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
59 
60  const ClusterVariables Summaryinfo(*cluster);
61 
62  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
63 
64  std::pair<int, int> ModSelect = ModuleSelectionVect.at(i) -> IsStripSelected( id );
65  int mod_pair = ModSelect.first;
66  int mod_pair2 = ModSelect.second;
67 
68  if ( mod_pair ){
69  if ( firstpass_mod ) {
70  CurrMod = mod_pair2;
71  cCluster.SetUserModules( mod_pair2 ) ;
72  }
73 
74  firstpass_mod = false;
75  int CurrModTmp = mod_pair2;
76 
77  if ( CurrMod != CurrModTmp ) {
78  cCluster.SetUserModules( mod_pair2 ) ;
79  CurrMod = CurrModTmp;
80  }
81 
82  cCluster.SetGenericVariable( "cHits", mod_pair2, 1 );
83  cCluster.SetGenericVariable( "cSize", mod_pair2, Summaryinfo.clusterSize() );
84  cCluster.SetGenericVariable( "cCharge", mod_pair2, Summaryinfo.charge() );
85 
86  }
87  }
88  }
89  }
90 
91  }
92 
93  //===================++++++++++++========================
94  //
95  // For SiPixels
96  //
97  //===================++++++++++++========================
98  if (doPixels){
100  iEvent.getByToken(pixelClusters_, pixelClusters);
101 
103  for ( std::vector<std::string>::iterator it=v_pixelModuleTypes.begin() ; it < v_pixelModuleTypes.end(); it++ ){
105  }
106 
107  firstpassPixel_mod = true;
108 
109  int CurrModPixel = -1;
110  //Loop over all the ModuleSelectors
111  for ( unsigned int i = 0; i < ModuleSelectionVectPixels.size(); i++){
112 
113  // Loop over the pixel clusters
114  edmNew::DetSetVector<SiPixelCluster>::const_iterator itClusters=pixelClusters->begin();
115  for(;itClusters!=pixelClusters->end();++itClusters){
116  uint32_t detid = itClusters->detId();
117  for(edmNew::DetSet<SiPixelCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
118 
119  // For each ModuleSelector, check if the detID belongs to a desired module. If so, update the summary information for that module
120 
121  std::pair<int, int> ModSelectPixel = ModuleSelectionVectPixels.at(i) -> IsPixelSelected( detid );
122  int mod_pair = ModSelectPixel.first;
123  int mod_pair2 = ModSelectPixel.second;
124  if ( mod_pair ){
125  if ( firstpassPixel_mod ) {
126  CurrModPixel = mod_pair2;
127  cCluster.SetUserModules( mod_pair2 ) ;
128  }
129  firstpassPixel_mod = false;
130  int CurrModTmp = mod_pair2;
131  if ( CurrModPixel != CurrModTmp ) {
132  cCluster.SetUserModules( mod_pair2 ) ;
133  CurrModPixel = CurrModTmp;
134  }
135 
136  cCluster.SetGenericVariable( "pHits", mod_pair2, 1 );
137  cCluster.SetGenericVariable( "pSize", mod_pair2, cluster->size() );
138  cCluster.SetGenericVariable( "pCharge", mod_pair2, float(cluster->charge())/1000. );
139 
140  }
141  }
142  }
143  }
144 
145  }
146 
147 
148  //===================+++++++++++++========================
149  //
150  // Fill Producer
151  //
152  //===================+++++++++++++========================
153 
154 
155  unsigned int n = 0;
156  int n_pixel = 0;
157 
159 
160  std::vector<int> _mod = cCluster.GetUserModules( );
161  for(std::vector<int>::iterator it = _mod.begin(); it != _mod.end(); ++it) {
162 
163  if ( n < v_stripModuleTypes.size() && doStrips ){
164  if (verbose) std::cout << "n" << v_stripModuleTypes.at(n) <<", avg size, avg charge = "<< cCluster.GetGenericVariable( "cHits",*it ) << ", " << cCluster.GetGenericVariable( "cSize",*it )/cCluster.GetGenericVariable( "cHits",*it ) << ", "<< cCluster.GetGenericVariable( "cCharge",*it )/cCluster.GetGenericVariable( "cHits",*it ) << std::endl;
165  delete ModuleSelectionVect[n];
166  }
167  else if (doPixels) {
168  if (verbose) {
169  std::cout << "n" << v_pixelModuleTypes.at(n_pixel) << ", avg size, avg charge = "<< cCluster.GetGenericVariable( "pHits",*it ) << ", " << cCluster.GetGenericVariable( "pSize",*it )/cCluster.GetGenericVariable( "pHits",*it ) << ", "<< cCluster.GetGenericVariable( "pCharge",*it )/cCluster.GetGenericVariable( "pHits",*it ) << std::endl;
170  }
171  delete ModuleSelectionVectPixels[n_pixel];
172  ++n_pixel;
173  }
174  ++n;
175  }
176 
177  if (verbose) std::cout << "-------------------------------------------------------" << std::endl;
178 
179  firstpass = false;
180  firstpassPixel = false;
181 
182  //Put the filled class into the producer
183  std::auto_ptr<ClusterSummary> result(new ClusterSummary (cCluster) );
184  iEvent.put( result );
185 
187 
188 }
189 
190 
191 void
193 {
194 
199 
200  if (doStrips){
201  if (verbose){
202  std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
203  std::cout << "FOR STRIPS: " << std::endl;
204  std::cout << "Getting info on " ;
205  for (unsigned int ii = 0; ii < v_stripModuleTypes.size( ); ++ii) {
206  std::cout << v_stripModuleTypes[ii] << " " ;
207  }
208  std::cout << std::endl;
209  }
210 
211  if (verbose) std::cout << "Getting info on strip variables " ;
212  for (unsigned int ii = 0; ii < v_stripVariables.size( ); ++ii) {
213  if (verbose) std::cout << v_stripVariables[ii] << " " ;
214  v_userContent.push_back(v_stripVariables[ii]);
215  }
216  if (verbose) std::cout << std::endl;
217  }
218 
219  if (doPixels){
220  if (verbose){
221  std::cout << "FOR PIXELS: " << std::endl;
222  std::cout << "Getting info on " ;
223  for (unsigned int ii = 0; ii < v_pixelModuleTypes.size( ); ++ii) {
224  std::cout << v_pixelModuleTypes[ii] << " " ;
225  }
226  std::cout << std::endl;
227  }
228 
229  if (verbose) std::cout << "Getting info on pixel variables " ;
230  for (unsigned int ii = 0; ii < v_pixelVariables.size( ); ++ii) {
231  if (verbose) std::cout << v_pixelVariables[ii] << " " ;
232  v_userContent.push_back(v_pixelVariables[ii]);
233  }
234  if (verbose) std::cout << std::endl;
235  if (verbose) std::cout << "+++++++++++++++++++++++++++++++ " << std::endl;
236  }
237 
238  //Create the summary info for output
241 }
242 
243 
244 
245 
246 void
247 ClusterSummaryProducer::decodeInput(std::vector<std::string> & vec, std::string mod)
248 {
249 
250  // Define the Modules to get the summary info out of
252  std::string::size_type j = mod.find(',');
253 
254  if ( j == std::string::npos ){
255  vec.push_back(mod);
256  }
257  else{
258  while (j != std::string::npos) {
259  vec.push_back(mod.substr(i, j-i));
260  i = ++j;
261  j = mod.find(',', j);
262  if (j == std::string::npos)
263  vec.push_back(mod.substr(i, mod.length( )));
264  }
265  }
266 
267 
268 }
269 
270 
271 
275 
276 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVect
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > stripClusters_
void SetGenericVariable(int variableLocation, int module, double value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< std::string > v_userContent
virtual void produce(edm::Event &, const edm::EventSetup &) override
void decodeInput(std::vector< std::string > &, std::string)
data_type const * const_iterator
Definition: DetSetNew.h:30
int ii
Definition: cuy.py:588
id_type id(size_t cell) const
uint16_t size_type
void SetUserContent(const std::vector< std::string > &Content) const
ClusterSummaryProducer(const edm::ParameterSet &)
std::vector< std::string > v_pixelVariables
int iEvent
Definition: GenABIO.cc:230
void SetUserIterator()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< std::string > v_pixelModuleTypes
uint16_t charge() const
tuple result
Definition: query.py:137
std::vector< int > GetUserModules() const
int j
Definition: DBlmapReader.cc:9
double GetGenericVariable(int variableLocation, int module) const
std::vector< std::string > v_stripModuleTypes
virtual void beginStream(edm::StreamID) override
void PrepairGenericVariable()
void SetUserModules(int value)
tuple cout
Definition: gather_cfg.py:121
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
std::vector< std::string > v_stripVariables
const unsigned clusterSize() const
std::vector< ClusterSummary::ModuleSelection * > ModuleSelectionVectPixels
void ClearGenericVariable()
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void ClearUserModules()
const_iterator begin(bool update=false) const