CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DataFormats/TrackerCommon/src/ClusterSummary.cc

Go to the documentation of this file.
00001 #include "DataFormats/TrackerCommon/interface/ClusterSummary.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 
00004 int ClusterSummary::GetModuleLocation ( int mod ) const {
00005 
00006   int placeInModsVector = -1;
00007     
00008   int cnt = 0;
00009   int pixelcnt = 0; 
00010   for(std::vector<int>::const_iterator it = modules_.begin(); it != modules_.end(); ++it) {
00011     /*
00012     if ( mod == (*it) ) { 
00013       placeInModsVector = cnt; 
00014       break;
00015     }
00016     else ++cnt;
00017     */
00018     
00019     int mod_tmp = *it;
00020     while (mod_tmp > 9 ){
00021       mod_tmp /= 10;
00022     }
00023      
00024     if ( mod_tmp < 5 ){
00025 
00026       if ( mod == (*it) ) { 
00027         placeInModsVector = cnt; 
00028         break;
00029       }
00030       else ++cnt;
00031     }
00032     else{      
00033       if ( mod == (*it) ) { 
00034         placeInModsVector = pixelcnt; 
00035         break;
00036       }
00037       else ++pixelcnt;
00038     }   
00039   }
00040 
00041   if (placeInModsVector == -1){
00042 
00043     edm::LogWarning("NoModule") << "No information for requested module "<<mod<<". Please check in the Provinence Infomation for proper modules.";
00044       
00045     return -1;
00046 
00047   }
00048 
00049   return placeInModsVector;
00050 
00051 }
00052 
00053 
00054 
00055 int ClusterSummary::GetVariableLocation ( std::string var ) const {
00056 
00057   int placeInUserVector = -1;
00058     
00059 
00060   int cnt = 0;
00061   for(std::vector<std::string>::const_iterator it = userContent.begin(); it != userContent.end(); ++it) {
00062 
00063     if ( var == (*it) ) { 
00064       placeInUserVector = cnt; 
00065       break;
00066     }
00067     else ++cnt;
00068       
00069   }
00070 
00071 
00072   /*
00073   if ( var == "cHits" )
00074     placeInUserVector = NMODULES;
00075   else if (var == "cSize" )
00076     placeInUserVector = CLUSTERSIZE;
00077   else if (var == "cCharge" )
00078     placeInUserVector = CLUSTERCHARGE;
00079   else if (var == "pHits" )
00080     placeInUserVector = NMODULESPIXELS;
00081   else if (var == "pSize" )
00082     placeInUserVector = CLUSTERSIZEPIXELS;
00083   else if (var == "pCharge" )
00084     placeInUserVector = CLUSTERCHARGEPIXELS;
00085   else
00086     placeInUserVector = -1;
00087   */
00088   if (placeInUserVector == -1){
00089     std::ostringstream err;
00090     err<<"No information for requested var "<<var<<". Please check if you have chosen a proper variable.";
00091       
00092     throw cms::Exception( "Missing Variable", err.str());
00093   }
00094 
00095   return placeInUserVector;
00096 
00097 }
00098 
00099 
00100 
00101 std::vector<std::string> ClusterSummary::DecodeProvInfo(std::string ProvInfo) const {
00102 
00103   std::vector<std::string> v_moduleTypes;
00104 
00105   std::string mod = ProvInfo;
00106   std::string::size_type i = 0;
00107   std::string::size_type j = mod.find(',');
00108 
00109   if ( j == std::string::npos ){
00110     v_moduleTypes.push_back(mod);
00111   }
00112   else{
00113 
00114     while (j != std::string::npos) {
00115       v_moduleTypes.push_back(mod.substr(i, j-i));
00116       i = ++j;
00117       j = mod.find(',', j);
00118       if (j == std::string::npos)
00119         v_moduleTypes.push_back(mod.substr(i, mod.length( )));
00120     }
00121 
00122   }
00123 
00124   return v_moduleTypes;
00125 
00126 }
00127 
00128 
00129 
00130 std::pair<int,int> ClusterSummary::ModuleSelection::IsStripSelected(int DetId){
00131 
00132   // true if the module mod is among the selected modules.  
00133   int isselected = 0;
00134   int enumVal = 99999;
00135   
00136   SiStripDetId subdet(DetId);
00137   int subdetid = subdet.subDetector();
00138   
00139   std::string::size_type result = geosearch.find("_");
00140 
00141   if(result != std::string::npos) { 
00142 
00143     /****
00144          Check to the layers in the modules
00145     ****/
00146   
00147     std::string modStr = geosearch; //Convert to string to use needed methods    
00148     size_t pos = modStr.find("_", 0); //find the '_'
00149     std::string Mod = modStr.substr(0, pos); //find the module
00150     std::string Layer = modStr.substr(pos+1, modStr.length()); //find the Layer
00151 
00152     std::stringstream ss(Layer);
00153     int layer_id = 0;
00154          
00155     ss >> layer_id;
00156          
00157     if (SiStripDetId::TIB == subdetid && Mod == "TIB"){
00158            
00159       TIBDetId tib(DetId);
00160       int layer    = tib.layer(); 
00161       if (layer_id == layer){
00162 
00163         if (layer_id == 1) enumVal = ClusterSummary::TIB_1;
00164         else if (layer_id == 2) enumVal = ClusterSummary::TIB_2;
00165         else if (layer_id == 3) enumVal = ClusterSummary::TIB_3;
00166         else if (layer_id == 4) enumVal = ClusterSummary::TIB_4;
00167 
00168         isselected = 1;
00169       }
00170     } 
00171          
00172     else if (SiStripDetId::TOB == subdetid && Mod == "TOB"){
00173 
00174       TOBDetId tob(DetId);
00175       int layer    = tob.layer(); 
00176       if (layer_id == layer){
00177 
00178         if (layer_id == 1) enumVal = ClusterSummary::TOB_1;
00179         else if (layer_id == 2) enumVal = ClusterSummary::TOB_2;
00180         else if (layer_id == 3) enumVal = ClusterSummary::TOB_3;
00181         else if (layer_id == 4) enumVal = ClusterSummary::TOB_4;
00182         else if (layer_id == 5) enumVal = ClusterSummary::TOB_5;
00183         else if (layer_id == 6) enumVal = ClusterSummary::TOB_6;
00184           
00185         isselected = 1;
00186       }
00187     } 
00188 
00189     else if (SiStripDetId::TEC == subdetid && Mod == "TECM"){
00190 
00191       TECDetId tec(DetId);
00192       int side          = (tec.isZMinusSide())?-1:1; 
00193       int layerwheel    = tec.wheel(); 
00194 
00195       if (layer_id == layerwheel && side == -1){
00196           
00197         if (layer_id == 1) enumVal = ClusterSummary::TECM_1;
00198         else if (layer_id == 2) enumVal = ClusterSummary::TECM_2;
00199         else if (layer_id == 3) enumVal = ClusterSummary::TECM_3;
00200         else if (layer_id == 4) enumVal = ClusterSummary::TECM_4;
00201         else if (layer_id == 5) enumVal = ClusterSummary::TECM_5;
00202         else if (layer_id == 6) enumVal = ClusterSummary::TECM_6;
00203         else if (layer_id == 7) enumVal = ClusterSummary::TECM_7;
00204         else if (layer_id == 8) enumVal = ClusterSummary::TECM_8;
00205         else if (layer_id == 9) enumVal = ClusterSummary::TECM_9;
00206 
00207         isselected = 1;
00208       }
00209     } 
00210 
00211     else if (SiStripDetId::TEC == subdetid && Mod == "TECP"){
00212 
00213       TECDetId tec(DetId);
00214       int side          = (tec.isZMinusSide())?-1:1; 
00215       int layerwheel    = tec.wheel(); 
00216 
00217       if (layer_id == layerwheel && side == 1){
00218 
00219         if (layer_id == 1) enumVal = ClusterSummary::TECP_1;
00220         else if (layer_id == 2) enumVal = ClusterSummary::TECP_2;
00221         else if (layer_id == 3) enumVal = ClusterSummary::TECP_3;
00222         else if (layer_id == 4) enumVal = ClusterSummary::TECP_4;
00223         else if (layer_id == 5) enumVal = ClusterSummary::TECP_5;
00224         else if (layer_id == 6) enumVal = ClusterSummary::TECP_6;
00225         else if (layer_id == 7) enumVal = ClusterSummary::TECP_7;
00226         else if (layer_id == 8) enumVal = ClusterSummary::TECP_8;
00227         else if (layer_id == 9) enumVal = ClusterSummary::TECP_9;
00228 
00229         isselected = 1;
00230       }
00231     } 
00232 
00233     // TEC minus ring
00234     else if (SiStripDetId::TEC == subdetid && Mod == "TECMR"){
00235 
00236       TECDetId tec(DetId);
00237       int side          = (tec.isZMinusSide())?-1:1; 
00238       int ring    = tec.ringNumber();  
00239 
00240       if (layer_id == ring && side == -1){
00241 
00242         if (layer_id == 1) enumVal = ClusterSummary::TECMR_1;
00243         else if (layer_id == 2) enumVal = ClusterSummary::TECMR_2;
00244         else if (layer_id == 3) enumVal = ClusterSummary::TECMR_3;
00245         else if (layer_id == 4) enumVal = ClusterSummary::TECMR_4;
00246         else if (layer_id == 5) enumVal = ClusterSummary::TECMR_5;
00247         else if (layer_id == 6) enumVal = ClusterSummary::TECMR_6;
00248         else if (layer_id == 7) enumVal = ClusterSummary::TECMR_7;
00249 
00250         isselected = 1;
00251       }
00252     } 
00253 
00254     // TEC plus ring
00255     else if (SiStripDetId::TEC == subdetid && Mod == "TECPR"){
00256 
00257       TECDetId tec(DetId);
00258       int side          = (tec.isZMinusSide())?-1:1; 
00259       int ring    = tec.ringNumber();  
00260       if (layer_id == ring && side == 1){
00261 
00262         if (layer_id == 1) enumVal = ClusterSummary::TECPR_1;
00263         else if (layer_id == 2) enumVal = ClusterSummary::TECPR_2;
00264         else if (layer_id == 3) enumVal = ClusterSummary::TECPR_3;
00265         else if (layer_id == 4) enumVal = ClusterSummary::TECPR_4;
00266         else if (layer_id == 5) enumVal = ClusterSummary::TECPR_5;
00267         else if (layer_id == 6) enumVal = ClusterSummary::TECPR_6;
00268         else if (layer_id == 7) enumVal = ClusterSummary::TECPR_7;
00269 
00270         isselected = 1;
00271       }
00272     } 
00273 
00274     else if (SiStripDetId::TID == subdetid && Mod == "TIDM"){
00275 
00276       TIDDetId tid(DetId);
00277       int side          = (tid.isZMinusSide())?-1:1; 
00278       int layerwheel    = tid.wheel(); 
00279 
00280       if (layer_id == layerwheel && side == -1){
00281 
00282         if (layer_id == 1) enumVal = ClusterSummary::TIDM_1;
00283         else if (layer_id == 2) enumVal = ClusterSummary::TIDM_2;
00284         else if (layer_id == 3) enumVal = ClusterSummary::TIDM_3;
00285 
00286         isselected = 1;
00287       }
00288     } 
00289 
00290     else if (SiStripDetId::TID == subdetid && Mod == "TIDP"){
00291 
00292       TIDDetId tid(DetId);
00293       int side          = (tid.isZMinusSide())?-1:1; 
00294       int layerwheel    = tid.wheel(); 
00295 
00296       if (layer_id == layerwheel && side == 1){
00297 
00298         if (layer_id == 1) enumVal = ClusterSummary::TIDP_1;
00299         else if (layer_id == 2) enumVal = ClusterSummary::TIDP_2;
00300         else if (layer_id == 3) enumVal = ClusterSummary::TIDP_3;
00301 
00302         isselected = 1;
00303       }
00304     } 
00305          
00306     // TID minus ring
00307     else if (SiStripDetId::TID == subdetid && Mod == "TIDMR"){
00308       TIDDetId tid(DetId);
00309       int side          = (tid.isZMinusSide())?-1:1; 
00310       int ring    = tid.ringNumber(); 
00311       if (layer_id == ring && side == -1){
00312           
00313         if (layer_id == 1) enumVal = ClusterSummary::TIDMR_1;
00314         else if (layer_id == 2) enumVal = ClusterSummary::TIDMR_2;
00315         else if (layer_id == 3) enumVal = ClusterSummary::TIDMR_3;
00316 
00317         isselected = 1;
00318       }
00319     } 
00320 
00321     // TID plus ring
00322     else if (SiStripDetId::TID == subdetid && Mod == "TIDPR"){
00323       TIDDetId tid(DetId);
00324       int side          = (tid.isZMinusSide())?-1:1; 
00325       int ring    = tid.ringNumber(); 
00326         
00327       if (layer_id == ring && side == 1){
00328 
00329         if (layer_id == 1) enumVal = ClusterSummary::TIDPR_1;
00330         else if (layer_id == 2) enumVal = ClusterSummary::TIDPR_2;
00331         else if (layer_id == 3) enumVal = ClusterSummary::TIDPR_3;
00332 
00333         isselected = 1;
00334       }
00335     } 
00336   }
00337     
00338   /****
00339        Check the top and bottom for the TEC and TID
00340   ****/
00341 
00342   else if( SiStripDetId::TEC == subdetid && geosearch.compare("TECM")==0 ) {
00343        
00344     TECDetId tec(DetId);
00345     int side          = (tec.isZMinusSide())?-1:1;  
00346 
00347     if (side == -1){
00348       isselected = 1;
00349       enumVal = ClusterSummary::TECM;
00350     }
00351   }
00352 
00353   else if( SiStripDetId::TEC == subdetid && geosearch.compare("TECP")==0 ) {
00354       
00355     TECDetId tec(DetId);
00356     int side          = (tec.isZMinusSide())?-1:1;  
00357 
00358     if (side == 1){
00359       isselected = 1;
00360       enumVal = ClusterSummary::TECP;
00361     }    
00362   }
00363 
00364 
00365   else if( SiStripDetId::TID == subdetid && geosearch.compare("TIDM")==0 ) {
00366        
00367     TIDDetId tid(DetId);
00368     int side          = (tid.isZMinusSide())?-1:1;  
00369 
00370     if (side == -1){
00371       isselected = 1;
00372       enumVal = ClusterSummary::TIDM;
00373     }
00374   }
00375 
00376 
00377   else if( SiStripDetId::TID == subdetid && geosearch.compare("TIDP")==0 ) {
00378        
00379     TIDDetId tid(DetId);
00380     int side          = (tid.isZMinusSide())?-1:1;  
00381 
00382     if (side == 1){
00383       isselected = 1;
00384       enumVal = ClusterSummary::TIDP;
00385     }
00386   }
00387 
00388   /****
00389        Check the full TOB, TIB, TID, TEC modules
00390   ****/
00391 
00392   else if( SiStripDetId::TIB == subdetid && geosearch.compare("TIB")==0 ) {
00393     isselected = 1;
00394     enumVal = ClusterSummary::TIB;
00395   }
00396   else if( SiStripDetId::TID == subdetid && geosearch.compare("TID")==0 ) {
00397     isselected = 1;
00398     enumVal = ClusterSummary::TID;
00399   } 
00400   else if( SiStripDetId::TOB == subdetid && geosearch.compare("TOB")==0) {
00401     isselected = 1;
00402     enumVal = ClusterSummary::TOB;
00403   } 
00404   else if( SiStripDetId::TEC == subdetid && geosearch.compare("TEC")==0) {
00405     isselected = 1;
00406     enumVal = ClusterSummary::TEC;
00407   }
00408   else if( geosearch.compare("TRACKER")==0) {
00409     isselected = 1;
00410     enumVal = ClusterSummary::TRACKER;
00411   }
00412   
00413 
00414   return  std::make_pair(isselected, enumVal);
00415 }
00416 
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 std::pair<int,int> ClusterSummary::ModuleSelection::IsPixelSelected(int detid){
00425 
00426   // true if the module mod is among the selected modules.  
00427   int isselected = 0;
00428   int enumVal = 99999;
00429   
00430   DetId detId = DetId(detid);       // Get the Detid object
00431   unsigned int detType=detId.det(); // det type, pixel=1
00432   unsigned int subdetid=detId.subdetId(); //subdetector type, barrel=1, foward=2
00433 
00434   if(detType!=1) return std::make_pair(0,99999); // look only at pixels
00435 
00436   std::string::size_type result = geosearch.find("_");
00437 
00438   if(result != std::string::npos) { 
00439   
00440     std::string modStr = geosearch; //Convert to string to use needed methods    
00441     size_t pos = modStr.find("_", 0); //find the '_'
00442     std::string Mod = modStr.substr(0, pos); //find the module
00443     std::string Layer = modStr.substr(pos+1, modStr.length()); //find the Layer
00444 
00445     std::stringstream ss(Layer);
00446     int layer_id = 0;
00447          
00448     ss >> layer_id;
00449 
00450     /****
00451          Check the Layers of the Barrel
00452     ****/
00453 
00454     if (subdetid == 1 && Mod == "BPIX"){
00455            
00456       PXBDetId pdetId = PXBDetId(detid);
00457       // Barell layer = 1,2,3
00458       int layer=pdetId.layer();
00459 
00460       if (layer_id == layer){
00461 
00462         if (layer_id == 1) enumVal = ClusterSummary::BPIX_1;
00463         else if (layer_id == 2) enumVal = ClusterSummary::BPIX_2;
00464         else if (layer_id == 3) enumVal = ClusterSummary::BPIX_3;
00465 
00466         isselected = 1;
00467       }
00468     } 
00469 
00470     /****
00471          Check the Disk of the endcaps
00472     ****/
00473     else if (subdetid == 2 && Mod == "FPIX"){
00474       
00475       PXFDetId pdetId = PXFDetId(detid);
00476       int disk=pdetId.disk(); //1,2,3
00477 
00478       if (layer_id == disk){
00479 
00480         if (disk == 1) enumVal = ClusterSummary::FPIX_1;
00481         else if (disk == 2) enumVal = ClusterSummary::FPIX_2;
00482         else if (disk == 3) enumVal = ClusterSummary::FPIX_3;
00483 
00484         isselected = 1;
00485         
00486       }
00487     }
00488 
00489     /****
00490          Check the sides of each Disk of the endcaps
00491     ****/
00492 
00493     else if (subdetid == 2 && Mod == "FPIXM"){
00494       
00495       PXFDetId pdetId = PXFDetId(detid);
00496       int side=pdetId.side(); //size=1 for -z, 2 for +z
00497       int disk=pdetId.disk(); //1,2,3
00498 
00499       if (layer_id == disk && side == 1 ){
00500 
00501         if (disk == 1) enumVal = ClusterSummary::FPIXM_1;
00502         else if (disk == 2) enumVal = ClusterSummary::FPIXM_2;
00503         else if (disk == 3) enumVal = ClusterSummary::FPIXM_3;
00504 
00505         isselected = 1;
00506         
00507       }
00508     }
00509 
00510     else if (subdetid == 2 && Mod == "FPIXP"){
00511       
00512       PXFDetId pdetId = PXFDetId(detid);
00513       int side=pdetId.side(); //size=1 for -z, 2 for +z
00514       int disk=pdetId.disk(); //1,2,3
00515 
00516       if (layer_id == disk && side == 2){
00517 
00518         if (disk == 1) enumVal = ClusterSummary::FPIXP_1;
00519         else if (disk == 2) enumVal = ClusterSummary::FPIXP_2;
00520         else if (disk == 3) enumVal = ClusterSummary::FPIXP_3;
00521 
00522         isselected = 1;
00523         
00524       }
00525     }
00526   }
00527    
00528   /****
00529        Check the top and bottom of the endcaps
00530   ****/
00531 
00532   else if( subdetid == 2 && geosearch.compare("FPIXM")==0 ) {
00533        
00534     PXFDetId pdetId = PXFDetId(detid);
00535     int side=pdetId.side(); //size=1 for -z, 2 for +z
00536 
00537     if (side == 1){
00538       isselected = 1;
00539       enumVal = ClusterSummary::FPIXM;
00540     }
00541   }
00542 
00543   else if( subdetid == 2 && geosearch.compare("FPIXP")==0 ) {
00544       
00545     PXFDetId pdetId = PXFDetId(detid);
00546     int side=pdetId.side(); //size=1 for -z, 2 for +z
00547 
00548     if (side == 2){
00549       isselected = 1;
00550       enumVal = ClusterSummary::FPIXP;
00551     }    
00552   }
00553 
00554 
00555   /****
00556        Check the full Barrel and Endcaps
00557   ****/
00558     
00559   else if(subdetid == 1 && geosearch.compare("BPIX")==0 ) {
00560     isselected = 1;
00561     enumVal = ClusterSummary::BPIX;
00562   }
00563   else if(subdetid == 2 && geosearch.compare("FPIX")==0 ) {
00564     isselected = 1;
00565     enumVal = ClusterSummary::FPIX;
00566   }
00567   else if( geosearch.compare("PIXEL")==0) {
00568     isselected = 1;
00569     enumVal = ClusterSummary::PIXEL;
00570   }
00571 
00572 
00573   return  std::make_pair(isselected, enumVal);
00574 }
00575 
00576 ClusterSummary::ModuleSelection::ModuleSelection(std::string gs){
00577   geosearch = gs;
00578 }
00579 
00580 ClusterSummary::ModuleSelection::~ModuleSelection() {}