CMS 3D CMS Logo

Public Member Functions

CmsTrackerLevelBuilder::ExtractPhiModule Struct Reference

#include <CmsTrackerLevelBuilder.h>

List of all members.

Public Member Functions

double operator() (const GeometricDet *a) const

Detailed Description

Definition at line 50 of file CmsTrackerLevelBuilder.h.


Member Function Documentation

double CmsTrackerLevelBuilder::ExtractPhiModule::operator() ( const GeometricDet a) const [inline]

Definition at line 51 of file CmsTrackerLevelBuilder.h.

References GeometricDet::components(), i, phi, pi, and groupFilesInBlocks::temp.

                                                 {
      const double pi = 3.141592653592;
      std::vector<const GeometricDet*> const & comp = a->components().back()->components();
      float phi = 0.;
      bool sum = true;
      
      for(unsigned int i=0;i<comp.size();i++){
        if(fabs(comp[i]->phi())>pi/2.) { 
          sum = false;
          break;
        }
      }
      
      if(sum){
        for(unsigned int i=0;i<comp.size();i++){
          phi+= comp[i]->phi();
        }
        
        double temp = phi/float(comp.size()) < 0. ? 
          2*pi + phi/float(comp.size()):
          phi/float(comp.size());
        return temp;
        
      }else{
        for(unsigned int i=0;i<comp.size();i++){
          double phi1 = comp[i]->phi() >= 0 ? comp[i]->phi(): 
            comp[i]->phi()+2*pi; 
          phi+= phi1;
        }
        
        double com = comp.front()->phi() >= 0 ? comp.front()->phi():
          2*pi + comp.front()->phi();
        double temp = fabs(phi/float(comp.size()) - com) > 2. ? 
          pi - phi/float(comp.size()):
          phi/float(comp.size());
        temp = temp >= 0? temp:2*pi+temp;
        return temp;
      }
    }