CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

LaserAlignment Class Reference

#include <LaserAlignment.h>

Inheritance diagram for LaserAlignment:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginJob (void)
virtual void endJob (void)
virtual void endRun (edm::Run &, const edm::EventSetup &)
 LaserAlignment (edm::ParameterSet const &theConf)
virtual void produce (edm::Event &, edm::EventSetup const &)
void testRoutine (void)
 for debugging & testing only, will disappear..
 ~LaserAlignment ()

Private Member Functions

void ApplyATMaskingCorrections (LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &, LASBarrelAlignmentParameterSet &)
 same for alignment tube modules
void ApplyEndcapMaskingCorrections (LASGlobalData< LASCoordinateSet > &, LASGlobalData< LASCoordinateSet > &, LASEndcapAlignmentParameterSet &)
 apply endcap correction to masked modules in TEC
void CalculateNominalCoordinates (void)
 fills a LASGlobalData<LASCoordinateSet> with nominal module positions
double ConvertAngle (double)
 convert an angle in the [-pi,pi] range to the [0,2*pi] range
void DumpHitmaps (LASGlobalData< int > &)
 for debugging only, will disappear
void DumpPosFileSet (LASGlobalData< LASCoordinateSet > &)
 for debugging only, will disappear
void DumpStripFileSet (LASGlobalData< std::pair< float, float > > &)
 for debugging only, will disappear
void fillDataProfiles (edm::Event const &, edm::EventSetup const &)
 fill profiles from SiStrip(Raw)Digi container
void fillDetectorId (void)
 fill hard coded detIds
void fillPedestalProfiles (edm::ESHandle< SiStripPedestals > &)
 fill pedestals from dbase
double getTEC2TECNominalBeamOffset (unsigned int, unsigned int, unsigned int)
 returns the nominal beam position (strips) in TEC (AT) for the profileJudge
double getTIBTOBNominalBeamOffset (unsigned int, unsigned int, unsigned int)
 returns the nominal beam position (strips) in TOB for the profileJudge
bool isATBeam (void)
bool isTECBeam (void)
 decide whether TEC or AT beams have fired

Private Attributes

LASGlobalData< LASModuleProfilecollectedDataProfiles
LASGlobalData< LASModuleProfilecurrentDataProfiles
 data profiles for the current event
LASGlobalData< unsigned int > detectorId
bool enableJudgeZeroFilter
 config switch
bool firstEvent_
edm::ESHandle< GeometricDetgD
 tracker geometry;
LASGlobalData< int > isAcceptedProfile
LASProfileJudge judge
unsigned int judgeOverdriveThreshold
 config parameters for the LASProfileJudge
bool misalignedByRefGeometry
 config switch
LASGlobalLoop moduleLoop
LASGlobalData< LASCoordinateSetnominalCoordinates
LASGlobalData< int > numberOfAcceptedProfiles
double peakFinderThreshold
 config parameter
LASGlobalData< LASModuleProfilepedestalProfiles
TDirectory * singleModulesDir
LASGlobalData< TH1D * > summedHistograms
std::vector< unsigned int > tecDoubleHitDetId
AlignableTrackertheAlignableTracker
std::string theAlignRecordName
bool theApplyBeamKinkCorrections
 config switch
int theCompression
 config parameter (histograms file compression level)
std::vector< edm::ParameterSettheDigiProducersList
bool theDoPedestalSubtraction
 config switch
std::string theErrorRecordName
int theEvents
 counter for the total number of events processed
TFile * theFile
 Tree stuff.
std::string theFileName
 config parameter (histograms file output name)
edm::ESHandle< AlignmentstheGlobalPositionRcd
LASConstants theLasConstants
std::vector< unsigned int > theMaskAtModules
std::vector< unsigned int > theMaskTecModules
 config parameters
const edm::ParameterSet theParameterSet
LASGlobalData< std::string > theProfileNames
bool theSaveHistograms
 config switch
bool theSetNominalStrips
 config switch
bool theStoreToDB
 config switch
edm::ESHandle< TrackerGeometrytheTrackerGeometry
bool theUseMinuitAlgorithm
 config switch
bool updateFromInputGeometry
 config switch

Detailed Description

Main reconstruction module for the Laser Alignment System

Date:
2012/06/13 16:23:31
Revision:
1.31
Author:
Maarten Thomas
Jan Olzem

Definition at line 84 of file LaserAlignment.h.


Constructor & Destructor Documentation

LaserAlignment::LaserAlignment ( edm::ParameterSet const &  theConf) [explicit]

Definition at line 19 of file LaserAlignment.cc.

References gather_cfg::cout, enableJudgeZeroFilter, LASProfileJudge::EnableZeroFilter(), edm::ParameterSet::getParameter(), judge, judgeOverdriveThreshold, misalignedByRefGeometry, peakFinderThreshold, LASProfileJudge::SetOverdriveThreshold(), AlCaHLTBitMon_QueryRunRegistry::string, theApplyBeamKinkCorrections, theCompression, theDoPedestalSubtraction, theFileName, theMaskAtModules, theMaskTecModules, theSaveHistograms, theSetNominalStrips, theStoreToDB, theUseMinuitAlgorithm, and updateFromInputGeometry.

                                                               :
  theEvents(0), 
  theDoPedestalSubtraction( theConf.getUntrackedParameter<bool>( "SubtractPedestals", true ) ),
  theUseMinuitAlgorithm( theConf.getUntrackedParameter<bool>( "RunMinuitAlignmentTubeAlgorithm", false ) ),
  theApplyBeamKinkCorrections( theConf.getUntrackedParameter<bool>( "ApplyBeamKinkCorrections", true ) ),
  peakFinderThreshold( theConf.getUntrackedParameter<double>( "PeakFinderThreshold", 10. ) ),
  enableJudgeZeroFilter( theConf.getUntrackedParameter<bool>( "EnableJudgeZeroFilter", true ) ),
  judgeOverdriveThreshold( theConf.getUntrackedParameter<unsigned int>( "JudgeOverdriveThreshold", 220 ) ),
  updateFromInputGeometry( theConf.getUntrackedParameter<bool>( "UpdateFromInputGeometry", false ) ),
  misalignedByRefGeometry( theConf.getUntrackedParameter<bool>( "MisalignedByRefGeometry", false ) ),
  theStoreToDB ( theConf.getUntrackedParameter<bool>( "SaveToDbase", false ) ),
  theDigiProducersList( theConf.getParameter<std::vector<edm::ParameterSet> >( "DigiProducersList" ) ),
  theSaveHistograms( theConf.getUntrackedParameter<bool>( "SaveHistograms", false ) ),
  theCompression( theConf.getUntrackedParameter<int>( "ROOTFileCompression", 1 ) ),
  theFileName( theConf.getUntrackedParameter<std::string>( "ROOTFileName", "test.root" ) ),
  theMaskTecModules( theConf.getUntrackedParameter<std::vector<unsigned int> >( "MaskTECModules" ) ),
  theMaskAtModules( theConf.getUntrackedParameter<std::vector<unsigned int> >( "MaskATModules" ) ),
  theSetNominalStrips( theConf.getUntrackedParameter<bool>( "ForceFitterToNominalStrips", false ) ),
  theLasConstants( theConf.getUntrackedParameter<std::vector<edm::ParameterSet> >( "LaserAlignmentConstants" ) ),
  theFile(),
  theAlignableTracker(),
  theAlignRecordName( "TrackerAlignmentRcd" ),
  theErrorRecordName( "TrackerAlignmentErrorRcd" ),
  firstEvent_(true),
  theParameterSet( theConf )
{


  std::cout << std::endl;
  std::cout <<   "=============================================================="
            << "\n===         LaserAlignment module configuration            ==="
            << "\n"
            << "\n    Write histograms to file       = " << (theSaveHistograms?"true":"false")
            << "\n    Histogram file name            = " << theFileName
            << "\n    Histogram file compression     = " << theCompression
            << "\n    Subtract pedestals             = " << (theDoPedestalSubtraction?"true":"false")
            << "\n    Run Minuit AT algorithm        = " << (theUseMinuitAlgorithm?"true":"false")
            << "\n    Apply beam kink corrections    = " << (theApplyBeamKinkCorrections?"true":"false")
            << "\n    Peak Finder Threshold          = " << peakFinderThreshold
            << "\n    EnableJudgeZeroFilter          = " << (enableJudgeZeroFilter?"true":"false")
            << "\n    JudgeOverdriveThreshold        = " << judgeOverdriveThreshold
            << "\n    Update from input geometry     = " << (updateFromInputGeometry?"true":"false")
            << "\n    Misalignment from ref geometry = " << (misalignedByRefGeometry?"true":"false")
            << "\n    Number of TEC modules masked   = " << theMaskTecModules.size() << " (s. below list if > 0)"
            << "\n    Number of AT modules masked    = " << theMaskAtModules.size()  << " (s. below list if > 0)"
            << "\n    Store to database              = " << (theStoreToDB?"true":"false")
            << "\n    ----------------------------------------------- ----------"
            << (theSetNominalStrips?"\n    Set strips to nominal       =  true":"\n")
            << "\n=============================================================" << std::endl;

  // tell about masked modules
  if( theMaskTecModules.size() ) {
    std::cout << " ===============================================================================================\n" << std::flush;
    std::cout << " The following " << theMaskTecModules.size() << " TEC modules have been masked out and will not be considered by the TEC algorithm:\n " << std::flush;
    for( std::vector<unsigned int>::iterator moduleIt = theMaskTecModules.begin(); moduleIt != theMaskTecModules.end(); ++moduleIt ) {
      std::cout << *moduleIt << (moduleIt!=--theMaskTecModules.end()?", ":"") << std::flush;
    }
    std::cout << std::endl << std::flush;
    std::cout << " ===============================================================================================\n\n" << std::flush;
  }
  if( theMaskAtModules.size() ) {
    std::cout << " ===============================================================================================\n" << std::flush;
    std::cout << " The following " << theMaskAtModules.size() << " AT modules have been masked out and will not be considered by the AT algorithm:\n " << std::flush;
    for( std::vector<unsigned int>::iterator moduleIt = theMaskAtModules.begin(); moduleIt != theMaskAtModules.end(); ++moduleIt ) {
      std::cout << *moduleIt << (moduleIt!=--theMaskAtModules.end()?", ":"") << std::flush;
    }
    std::cout << std::endl << std::flush;
    std::cout << " ===============================================================================================\n\n" << std::flush;
  }
  


  // alias for the Branches in the root files
  std::string alias ( theConf.getParameter<std::string>("@module_label") );  

  // declare the product to produce
  produces<TkLasBeamCollection, edm::InRun>( "tkLaserBeams" ).setBranchAlias( alias + "TkLasBeamCollection" );

  // switch judge's zero filter depending on cfg
  judge.EnableZeroFilter( enableJudgeZeroFilter );

  // set the upper threshold for zero suppressed data
  judge.SetOverdriveThreshold( judgeOverdriveThreshold );

}
LaserAlignment::~LaserAlignment ( )

Definition at line 112 of file LaserAlignment.cc.

References theAlignableTracker, theFile, and theSaveHistograms.

                                {

  if ( theSaveHistograms ) theFile->Write();
  if ( theFile ) { delete theFile; }
  if ( theAlignableTracker ) { delete theAlignableTracker; }

}

Member Function Documentation

void LaserAlignment::ApplyATMaskingCorrections ( LASGlobalData< LASCoordinateSet > &  measuredCoordinates,
LASGlobalData< LASCoordinateSet > &  nominalCoordinates,
LASBarrelAlignmentParameterSet atParameters 
) [private]

same for alignment tube modules

loop the list of alignment tube modules to be masked and apply the corrections from the "barrelParameters" to them

Definition at line 1638 of file LaserAlignment.cc.

References detectorId, LASCoordinateSet::GetPhi(), LASAlignmentTubeAlgorithm::GetTEC2TECAlignmentParameterCorrection(), LASGlobalData< T >::GetTEC2TECEntry(), LASAlignmentTubeAlgorithm::GetTIBTOBAlignmentParameterCorrection(), LASGlobalData< T >::GetTIBTOBEntry(), moduleLoop, pos, LASCoordinateSet::SetPhi(), LASGlobalLoop::TEC2TECLoop(), theMaskAtModules, and LASGlobalLoop::TIBTOBLoop().

Referenced by endRun().

                                                                                                                                                                                                        {

  // loop the list of modules to be masked
  for( std::vector<unsigned int>::iterator moduleIt = theMaskAtModules.begin(); moduleIt != theMaskAtModules.end(); ++moduleIt ) {

    // loop variables
    LASGlobalLoop moduleLoop;
    int det, beam, disk, pos;

    // this will calculate the corrections from the alignment parameters
    LASAlignmentTubeAlgorithm atAlgorithm;


    // find the location of the respective module in the container with these loops:

    // first TIB+TOB
    det = 2; beam = 0; pos = 0;
    do {

      // here we got it
      if( detectorId.GetTIBTOBEntry( det, beam, pos ) == *moduleIt ) {

        // the nominal phi value for this module
        const double nominalPhi = nominalCoordinates.GetTIBTOBEntry( det, beam, pos ).GetPhi();

        // the offset from the alignment parameters
        const double phiCorrection = atAlgorithm.GetTIBTOBAlignmentParameterCorrection( det, beam, pos, nominalCoordinates, atParameters );

        // apply the corrections
        measuredCoordinates.GetTIBTOBEntry( det, beam, pos ).SetPhi( nominalPhi - phiCorrection );

      }

    } while ( moduleLoop.TIBTOBLoop( det, beam, pos ) );
      
    
    
    // then TEC(AT)  
    det = 0; beam = 0; disk = 0;
    do {
          
      // here we got it
      if( detectorId.GetTEC2TECEntry( det, beam, disk ) == *moduleIt ) {

        // the nominal phi value for this module
        const double nominalPhi = nominalCoordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi();

        // the offset from the alignment parameters
        const double phiCorrection = atAlgorithm.GetTEC2TECAlignmentParameterCorrection( det, beam, disk, nominalCoordinates, atParameters );

        // apply the corrections
        measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhi( nominalPhi - phiCorrection );

      }
      
    } while ( moduleLoop.TEC2TECLoop( det, beam, disk ) );
    
  }

}
void LaserAlignment::ApplyEndcapMaskingCorrections ( LASGlobalData< LASCoordinateSet > &  measuredCoordinates,
LASGlobalData< LASCoordinateSet > &  nominalCoordinates,
LASEndcapAlignmentParameterSet endcapParameters 
) [private]

apply endcap correction to masked modules in TEC

loop the list of endcap modules to be masked and apply the corrections from the "endcapParameters" to them

Definition at line 1594 of file LaserAlignment.cc.

References detectorId, LASEndcapAlgorithm::GetAlignmentParameterCorrection(), LASCoordinateSet::GetPhi(), LASGlobalData< T >::GetTECEntry(), moduleLoop, relativeConstraints::ring, LASCoordinateSet::SetPhi(), LASGlobalLoop::TECLoop(), and theMaskTecModules.

Referenced by endRun().

                                                                                                                                                                                                                {

  // loop the list of modules to be masked
  for( std::vector<unsigned int>::iterator moduleIt = theMaskTecModules.begin(); moduleIt != theMaskTecModules.end(); ++moduleIt ) {

    // loop variables
    LASGlobalLoop moduleLoop;
    int det, ring, beam, disk;

    // this will calculate the corrections from the alignment parameters
    LASEndcapAlgorithm endcapAlgorithm;

    // find the location of the respective module in the container with this loop
    det = 0; ring = 0; beam = 0; disk = 0;
    do {
          
      // here we got it
      if( detectorId.GetTECEntry( det, ring, beam, disk ) == *moduleIt ) {
        
        // the nominal phi value for this module
        const double nominalPhi = nominalCoordinates.GetTECEntry( det, ring, beam, disk ).GetPhi();
        
        // the offset from the alignment parameters
        const double phiCorrection = endcapAlgorithm.GetAlignmentParameterCorrection( det, ring, beam, disk, nominalCoordinates, endcapParameters );
        
        // apply the corrections
        measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhi( nominalPhi - phiCorrection );
        
      }
      
    } while ( moduleLoop.TECLoop( det, ring, beam, disk ) );
    
  }

}
void LaserAlignment::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 127 of file LaserAlignment.cc.

References collectedDataProfiles, currentDataProfiles, Exception, fillDetectorId(), firstEvent_, LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), isAcceptedProfile, moduleLoop, numberOfAcceptedProfiles, pedestalProfiles, pos, relativeConstraints::ring, LASModuleProfile::SetAllValuesTo(), LASGlobalData< T >::SetTEC2TECEntry(), LASGlobalData< T >::SetTECEntry(), LASGlobalData< T >::SetTIBTOBEntry(), singleModulesDir, summedHistograms, LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), theCompression, theFile, theFileName, theProfileNames, theSaveHistograms, and LASGlobalLoop::TIBTOBLoop().

                              {


  // write sumed histograms to file (if selected in cfg)
  if( theSaveHistograms ) {

    // creating a new file
    theFile = new TFile( theFileName.c_str(), "RECREATE", "CMS ROOT file" );
    
    // initialize the histograms
    if ( theFile ) {
      theFile->SetCompressionLevel(theCompression);
      singleModulesDir = theFile->mkdir( "single modules" );
    } else 
      throw cms::Exception( " [LaserAlignment::beginJob]") << " ** ERROR: could not open file:"
                                                           << theFileName.c_str() << " for writing." << std::endl;

  }

  // detector id maps (hard coded)
  fillDetectorId();

  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //   PROFILE, HISTOGRAM & FITFUNCTION INITIALIZATION
  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  // object used to build various strings for names and labels
  std::stringstream nameBuilder;

  // loop variables for use with LASGlobalLoop object
  int det, ring, beam, disk, pos;

  // loop TEC modules
  det = 0; ring = 0; beam = 0; disk = 0;
  do { // loop using LASGlobalLoop functionality
    // init the profiles
    pedestalProfiles.GetTECEntry( det, ring, beam, disk ).SetAllValuesTo( 0. );
    currentDataProfiles.GetTECEntry( det, ring, beam, disk ).SetAllValuesTo( 0. );
    collectedDataProfiles.GetTECEntry( det, ring, beam, disk ).SetAllValuesTo( 0. );

    // init the hit maps
    isAcceptedProfile.SetTECEntry( det, ring, beam, disk, 0 );
    numberOfAcceptedProfiles.SetTECEntry( det, ring, beam, disk, 0 );

    // create strings for histo names
    nameBuilder.clear();
    nameBuilder.str( "" );
    nameBuilder << "TEC";
    if( det == 0 ) nameBuilder << "+"; else nameBuilder << "-";
    nameBuilder << "_Ring";
    if( ring == 0 ) nameBuilder << "4"; else nameBuilder << "6";
    nameBuilder << "_Beam" << beam;
    nameBuilder << "_Disk" << disk;
    theProfileNames.SetTECEntry( det, ring, beam, disk, nameBuilder.str() );

    // init the histograms
    if( theSaveHistograms ) {
      nameBuilder << "_Histo";
      summedHistograms.SetTECEntry( det, ring, beam, disk, new TH1D( nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512 ) );
      summedHistograms.GetTECEntry( det, ring, beam, disk )->SetDirectory( singleModulesDir );
    }
    
  } while ( moduleLoop.TECLoop( det, ring, beam, disk ) );


  // TIB & TOB section
  det = 2; beam = 0; pos = 0;
  do { // loop using LASGlobalLoop functionality
    // init the profiles
    pedestalProfiles.GetTIBTOBEntry( det, beam, pos ).SetAllValuesTo( 0. );
    currentDataProfiles.GetTIBTOBEntry( det, beam, pos ).SetAllValuesTo( 0. );
    collectedDataProfiles.GetTIBTOBEntry( det, beam, pos ).SetAllValuesTo( 0. );

    // init the hit maps
    isAcceptedProfile.SetTIBTOBEntry( det, beam, pos, 0 );
    numberOfAcceptedProfiles.SetTIBTOBEntry( det, beam, pos, 0 );

    // create strings for histo names
    nameBuilder.clear();
    nameBuilder.str( "" );
    if( det == 2 ) nameBuilder << "TIB"; else nameBuilder << "TOB";
    nameBuilder << "_Beam" << beam;
    nameBuilder << "_Zpos" << pos;

    theProfileNames.SetTIBTOBEntry( det, beam, pos, nameBuilder.str() );

    // init the histograms
    if( theSaveHistograms ) {
      nameBuilder << "_Histo";
      summedHistograms.SetTIBTOBEntry( det, beam, pos, new TH1D( nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512 ) );
      summedHistograms.GetTIBTOBEntry( det, beam, pos )->SetDirectory( singleModulesDir );
    }
    
  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );


  // TEC2TEC AT section
  det = 0; beam = 0; disk = 0;
  do { // loop using LASGlobalLoop functionality
    // init the profiles
    pedestalProfiles.GetTEC2TECEntry( det, beam, disk ).SetAllValuesTo( 0. );
    currentDataProfiles.GetTEC2TECEntry( det, beam, disk ).SetAllValuesTo( 0. );
    collectedDataProfiles.GetTEC2TECEntry( det, beam, disk ).SetAllValuesTo( 0. );
    
    // init the hit maps
    isAcceptedProfile.SetTEC2TECEntry( det, beam, disk, 0 );
    numberOfAcceptedProfiles.SetTEC2TECEntry( det, beam, disk, 0 );

    // create strings for histo names
    nameBuilder.clear();
    nameBuilder.str( "" );
    nameBuilder << "TEC(AT)";
    if( det == 0 ) nameBuilder << "+"; else nameBuilder << "-";
    nameBuilder << "_Beam" << beam;
    nameBuilder << "_Disk" << disk;
    theProfileNames.SetTEC2TECEntry( det, beam, disk, nameBuilder.str() );

    // init the histograms
    if( theSaveHistograms ) {
      nameBuilder << "_Histo";
      summedHistograms.SetTEC2TECEntry( det, beam, disk, new TH1D( nameBuilder.str().c_str(), nameBuilder.str().c_str(), 512, 0, 512 ) );
      summedHistograms.GetTEC2TECEntry( det, beam, disk )->SetDirectory( singleModulesDir );
    }
    
  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );

  firstEvent_ = true;
}
void LaserAlignment::CalculateNominalCoordinates ( void  ) [private]

fills a LASGlobalData<LASCoordinateSet> with nominal module positions

Definition at line 1353 of file LaserAlignment.cc.

References moduleLoop, nominalCoordinates, pos, relativeConstraints::ring, LASGlobalData< T >::SetTEC2TECEntry(), LASGlobalData< T >::SetTECEntry(), LASGlobalData< T >::SetTIBTOBEntry(), LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), and LASGlobalLoop::TIBTOBLoop().

Referenced by endRun().

                                                       {

  //
  // hard coded data yet...
  //

  // nominal phi values of tec beam / alignment tube hits (parameter is beam 0-7)
  const double tecPhiPositions[8]   = { 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486 }; // new values calculated by maple
  const double atPhiPositions[8]    = { 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784 }; // new values calculated by maple

  // nominal r values (mm) of hits
  const double tobRPosition = 600.;
  const double tibRPosition = 514.;
  const double tecRPosition[2] = { 564., 840. }; // ring 4,6

  // nominal z values (mm) of hits in barrel (parameter is pos 0-6)
  const double tobZPosition[6] = { 1040., 580., 220., -140., -500., -860. };
  const double tibZPosition[6] = { 620., 380., 180., -100., -340., -540. };

  // nominal z values (mm) of hits in tec (parameter is disk 0-8); FOR TEC-: (* -1.)
  const double tecZPosition[9] = { 1322.5, 1462.5, 1602.5, 1742.5, 1882.5, 2057.5, 2247.5, 2452.5, 2667.5 };
  

  //
  // now we fill these into the nominalCoordinates container;
  // errors are zero for nominal values..
  //

  // loop object and its variables
  LASGlobalLoop moduleLoop;
  int det, ring, beam, disk, pos;

  
  // TEC+- section
  det = 0; ring = 0, beam = 0; disk = 0;
  do {
    
    if( det == 0 ) { // this is TEC+
      nominalCoordinates.SetTECEntry( det, ring, beam, disk, LASCoordinateSet( tecPhiPositions[beam], 0., tecRPosition[ring], 0., tecZPosition[disk], 0. ) );
    }
    else { // now TEC-
      nominalCoordinates.SetTECEntry( det, ring, beam, disk, LASCoordinateSet( tecPhiPositions[beam], 0., tecRPosition[ring], 0., -1. * tecZPosition[disk], 0. ) ); // just * -1.
    }
    
  } while( moduleLoop.TECLoop( det, ring, beam, disk ) );



  // TIB & TOB section
  det = 2; beam = 0; pos = 0;
  do {
    if( det == 2 ) { // this is TIB
      nominalCoordinates.SetTIBTOBEntry( det, beam, pos, LASCoordinateSet( atPhiPositions[beam], 0., tibRPosition, 0., tibZPosition[pos], 0. ) );
    }
    else { // now TOB
      nominalCoordinates.SetTIBTOBEntry( det, beam, pos, LASCoordinateSet( atPhiPositions[beam], 0., tobRPosition, 0., tobZPosition[pos], 0. ) );
    }

  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );




  // TEC2TEC AT section
  det = 0; beam = 0; disk = 0;
  do {
    
    if( det == 0 ) { // this is TEC+, ring4 only
      nominalCoordinates.SetTEC2TECEntry( det, beam, disk, LASCoordinateSet( atPhiPositions[beam], 0., tecRPosition[0], 0., tecZPosition[disk], 0. ) );
    }
    else { // now TEC-
      nominalCoordinates.SetTEC2TECEntry( det, beam, disk, LASCoordinateSet( atPhiPositions[beam], 0., tecRPosition[0], 0., -1. * tecZPosition[disk], 0. ) ); // just * -1.
    }
    
  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );


}
double LaserAlignment::ConvertAngle ( double  angle) [private]

convert an angle in the [-pi,pi] range to the [0,2*pi] range

Definition at line 1440 of file LaserAlignment.cc.

References angle(), Exception, and M_PI.

Referenced by endRun().

                                                  {

  if( angle < -1. * M_PI  || angle > M_PI ) {
    throw cms::Exception(" [LaserAlignment::ConvertAngle] ") << "** ERROR: Called with illegal input angle: " << angle << "." << std::endl;
  }

  if( angle >= 0. ) return angle;
  else return( angle + 2. * M_PI );

}
void LaserAlignment::DumpHitmaps ( LASGlobalData< int > &  numberOfAcceptedProfiles) [private]

for debugging only, will disappear

Definition at line 1534 of file LaserAlignment.cc.

References gather_cfg::cout, and LASGlobalData< T >::GetTECEntry().

Referenced by endRun().

                                                                               {

  std::cout << " [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC+:" << std::endl;
  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
  std::cout << "     disk0   disk1   disk2   disk3   disk4   disk5   disk6   disk7   disk8" << std::endl;

  for( int beam = 0; beam < 8; ++beam ) {
    std::cout << " beam" << beam << ":";
    for( int disk = 0; disk < 9; ++disk ) {
      std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry( 0, 0, beam, disk );
    }
    std::cout << std::endl;
  }

  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
  std::cout << "     disk0   disk1   disk2   disk3   disk4   disk5   disk6   disk7   disk8" << std::endl;

  for( int beam = 0; beam < 8; ++beam ) {
    std::cout << " beam" << beam << ":";
    for( int disk = 0; disk < 9; ++disk ) {
      std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry( 0, 1, beam, disk );
    }
    std::cout << std::endl;
  }

  std::cout << " [LaserAlignment::DumpHitmaps] -- Dumping hitmap for TEC-:" << std::endl;
  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring4:" << std::endl;
  std::cout << "     disk0   disk1   disk2   disk3   disk4   disk5   disk6   disk7   disk8" << std::endl;

  for( int beam = 0; beam < 8; ++beam ) {
    std::cout << " beam" << beam << ":";
    for( int disk = 0; disk < 9; ++disk ) {
      std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry( 1, 0, beam, disk );
    }
    std::cout << std::endl;
  }

  std::cout << " [LaserAlignment::DumpHitmaps] -- Ring6:" << std::endl;
  std::cout << "     disk0   disk1   disk2   disk3   disk4   disk5   disk6   disk7   disk8" << std::endl;

  for( int beam = 0; beam < 8; ++beam ) {
    std::cout << " beam" << beam << ":";
    for( int disk = 0; disk < 9; ++disk ) {
      std::cout << "\t" << numberOfAcceptedProfiles.GetTECEntry( 1, 1, beam, disk );
    }
    std::cout << std::endl;
  }

  std::cout << " [LaserAlignment::DumpHitmaps] -- End of dump." << std::endl << std::endl;

}
void LaserAlignment::DumpPosFileSet ( LASGlobalData< LASCoordinateSet > &  coordinates) [private]

for debugging only, will disappear

debug only, will disappear

Definition at line 1458 of file LaserAlignment.cc.

References gather_cfg::cout, LASCoordinateSet::GetPhi(), LASCoordinateSet::GetPhiError(), LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), python::cmstools::loop(), pos, relativeConstraints::ring, LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), and LASGlobalLoop::TIBTOBLoop().

                                                                                  {

  LASGlobalLoop loop;
  int det, ring, beam, disk, pos;

  std:: cout << std::endl << " [LaserAlignment::DumpPosFileSet] -- Dump: " << std::endl;

  // TEC INTERNAL
  det = 0; ring = 0; beam = 0; disk = 0;
  do {
    std::cout << "POS " << det << "\t" << beam << "\t" << disk << "\t" << ring << "\t" << coordinates.GetTECEntry( det, ring, beam, disk ).GetPhi() << "\t" << coordinates.GetTECEntry( det, ring, beam, disk ).GetPhiError() << std::endl;
  } while ( loop.TECLoop( det, ring, beam, disk ) );

  // TIBTOB
  det = 2; beam = 0; pos = 0;
  do {
    std::cout << "POS " << det << "\t" << beam << "\t" << pos << "\t" << "-1" << "\t" << coordinates.GetTIBTOBEntry( det, beam, pos ).GetPhi() << "\t" << coordinates.GetTIBTOBEntry( det, beam, pos ).GetPhiError() << std::endl;
  } while( loop.TIBTOBLoop( det, beam, pos ) );

  // TEC2TEC
  det = 0; beam = 0; disk = 0;
  do {
    std::cout << "POS " << det << "\t" << beam << "\t" << disk << "\t" << "-1" << "\t" << coordinates.GetTEC2TECEntry( det, beam, disk ).GetPhi() << "\t" << coordinates.GetTEC2TECEntry( det, beam, disk ).GetPhiError() << std::endl;
  } while( loop.TEC2TECLoop( det, beam, disk ) );

  std:: cout << std::endl << " [LaserAlignment::DumpPosFileSet] -- End dump: " << std::endl;

}
void LaserAlignment::DumpStripFileSet ( LASGlobalData< std::pair< float, float > > &  measuredStripPositions) [private]

for debugging only, will disappear

Definition at line 1494 of file LaserAlignment.cc.

References gather_cfg::cout, python::cmstools::loop(), pos, relativeConstraints::ring, LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), and LASGlobalLoop::TIBTOBLoop().

                                                                                                    {

  LASGlobalLoop loop;
  int det, ring, beam, disk, pos;

  std:: cout << std::endl << " [LaserAlignment::DumpStripFileSet] -- Dump: " << std::endl;

  // TEC INTERNAL
  det = 0; ring = 0; beam = 0; disk = 0;
  do {
    std::cout << "STRIP " << det << "\t" << beam << "\t" << disk << "\t" << ring << "\t" << measuredStripPositions.GetTECEntry( det, ring, beam, disk ).first
              << "\t" << measuredStripPositions.GetTECEntry( det, ring, beam, disk ).second << std::endl;
  } while ( loop.TECLoop( det, ring, beam, disk ) );

  // TIBTOB
  det = 2; beam = 0; pos = 0;
  do {
    std::cout << "STRIP " << det << "\t" << beam << "\t" << pos << "\t" << "-1" << "\t" << measuredStripPositions.GetTIBTOBEntry( det, beam, pos ).first
              << "\t" << measuredStripPositions.GetTIBTOBEntry( det, beam, pos ).second << std::endl;
  } while( loop.TIBTOBLoop( det, beam, pos ) );

  // TEC2TEC
  det = 0; beam = 0; disk = 0;
  do {
    std::cout << "STRIP " << det << "\t" << beam << "\t" << disk << "\t" << "-1" << "\t" << measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).first
              << "\t" << measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).second << std::endl;
  } while( loop.TEC2TECLoop( det, beam, disk ) );

  std:: cout << std::endl << " [LaserAlignment::DumpStripFileSet] -- End dump: " << std::endl;
  
  
}
void LaserAlignment::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 961 of file LaserAlignment.cc.

                            {
}
void LaserAlignment::endRun ( edm::Run theRun,
const edm::EventSetup theSetup 
) [virtual]

laser hit section for trackbased interface

due to the peculiar order of beams in TkLasBeamCollection, we cannot use the LASGlobalLoop object here

Reimplemented from edm::EDProducer.

Definition at line 463 of file LaserAlignment.cc.

References AlignableTracker::alignmentErrors(), AlignableTracker::alignments(), ApplyATMaskingCorrections(), LASGeometryUpdater::ApplyBeamKinkCorrections(), ApplyEndcapMaskingCorrections(), PV3DBase< T, PVType, FrameType >::barePhi(), CalculateNominalCoordinates(), LASBarrelAlgorithm::CalculateParameters(), LASEndcapAlgorithm::CalculateParameters(), LASAlignmentTubeAlgorithm::CalculateParameters(), collectedDataProfiles, ConvertAngle(), gather_cfg::cout, detectorId, DumpHitmaps(), LASGeometryUpdater::EndcapUpdate(), LASPeakFinder::FindPeakIn(), LASGlobalData< T >::GetTEC2TECEntry(), getTEC2TECNominalBeamOffset(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), getTIBTOBNominalBeamOffset(), TrackerGeometry::idToDet(), edm::Service< T >::isAvailable(), align_cfg::iteration, laserBeams, misalignedByRefGeometry, moduleLoop, nominalCoordinates, numberOfAcceptedProfiles, peakFinderThreshold, pos, LASBarrelAlignmentParameterSet::Print(), LASEndcapAlignmentParameterSet::Print(), TkLasBeam::push_back(), edm::Run::put(), relativeConstraints::ring, LASPeakFinder::SetAmplitudeThreshold(), LASGeometryUpdater::SetMisalignmentFromRefGeometry(), LASCoordinateSet::SetPhi(), LASCoordinateSet::SetPhiError(), LASGeometryUpdater::SetReverseDirection(), LASGlobalData< T >::SetTEC2TECEntry(), LASGlobalData< T >::SetTECEntry(), LASGlobalData< T >::SetTIBTOBEntry(), summedHistograms, LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), theAlignableTracker, theAlignRecordName, theApplyBeamKinkCorrections, theErrorRecordName, theEvents, theLasConstants, theMaskAtModules, theMaskTecModules, theSetNominalStrips, theStoreToDB, theTrackerGeometry, theUseMinuitAlgorithm, LASGlobalLoop::TIBTOBLoop(), LASGeometryUpdater::TrackerUpdate(), and updateFromInputGeometry.

                                                                           {


  std::cout << " [LaserAlignment::endRun] -- Total number of events processed: " << theEvents << std::endl;

  // for debugging only..
  DumpHitmaps( numberOfAcceptedProfiles );

  // index variables for the LASGlobalLoop objects
  int det, ring, beam, disk, pos;
    
  // measured positions container for the algorithms
  LASGlobalData<LASCoordinateSet> measuredCoordinates;
  
  // fitted peak positions in units of strips (pair for value,error)
  LASGlobalData<std::pair<float,float> > measuredStripPositions;
  
  // the peak finder, a pair (pos/posErr in units of strips) for its results, and the success confirmation
  LASPeakFinder peakFinder;
  peakFinder.SetAmplitudeThreshold( peakFinderThreshold );
  std::pair<double,double> peakFinderResults;
  bool isGoodFit;
  
  // tracker geom. object for calculating the global beam positions
  const TrackerGeometry& theTracker( *theTrackerGeometry );

  // fill LASGlobalData<LASCoordinateSet> nominalCoordinates
  CalculateNominalCoordinates();
  
  // for determining the phi errors
  //    ErrorFrameTransformer errorTransformer; // later...
  




  // do the fits for TEC+- internal
  det = 0; ring = 0; beam = 0; disk = 0;
  do {
    
    // do the fit
    isGoodFit = peakFinder.FindPeakIn( collectedDataProfiles.GetTECEntry( det, ring, beam, disk ), peakFinderResults,
                                       summedHistograms.GetTECEntry( det, ring, beam, disk ), 0 ); // offset is 0 for TEC

    // now we have the measured positions in units of strips. 
    if( !isGoodFit ) std::cout << " [LaserAlignment::endRun] ** WARNING: Fit failed for TEC det: "
                               << det << ", ring: " << ring << ", beam: " << beam << ", disk: " << disk
                               << " (id: " << detectorId.GetTECEntry( det, ring, beam, disk ) << ")." << std::endl;

    

    // <- here we will later implement the kink corrections
      
    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTECEntry( det, ring, beam, disk ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
      
    if (theStripDet) {
      // first, set the measured coordinates to their nominal values
      measuredCoordinates.SetTECEntry( det, ring, beam, disk, nominalCoordinates.GetTECEntry( det, ring, beam, disk ) );
      
      if( isGoodFit ) { // convert strip position to global phi and replace the nominal phi value/error
        
        measuredStripPositions.GetTECEntry( det, ring, beam, disk ) = peakFinderResults;
        const float positionInStrips =  theSetNominalStrips ? 256. : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( positionInStrips ) );
        measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        
        // const GlobalError& globalError = errorTransformer.transform( theStripDet->specificTopology().localError( peakFinderResults.first, pow( peakFinderResults.second, 2 ) ), theStripDet->surface() );
        // measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhiError( globalError.phierr( globalPoint ) );
        measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhiError( 0.00046  ); // PRELIMINARY ESTIMATE
        
      }
      else { // keep nominal position (middle-of-module) but set a giant phi error so that the module can be ignored by the alignment algorithm
        measuredStripPositions.GetTECEntry( det, ring, beam, disk ) = std::pair<float,float>( 256., 1000. );
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( 256. ) );
        measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        measuredCoordinates.GetTECEntry( det, ring, beam, disk ).SetPhiError( 1000. );
      }
    }
      
  } while( moduleLoop.TECLoop( det, ring, beam, disk ) );




  // do the fits for TIB/TOB
  det = 2; beam = 0; pos = 0;
  do {

    // do the fit
    isGoodFit = peakFinder.FindPeakIn( collectedDataProfiles.GetTIBTOBEntry( det, beam, pos ), peakFinderResults, 
                                       summedHistograms.GetTIBTOBEntry( det, beam, pos ), getTIBTOBNominalBeamOffset( det, beam, pos ) );

    // now we have the measured positions in units of strips.
    if( !isGoodFit ) std::cout << " [LaserAlignment::endJob] ** WARNING: Fit failed for TIB/TOB det: "
                               << det << ", beam: " << beam << ", pos: " << pos 
                               << " (id: " << detectorId.GetTIBTOBEntry( det, beam, pos ) << ")." << std::endl;

      
    // <- here we will later implement the kink corrections
      
    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTIBTOBEntry( det, beam, pos ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
      
    if (theStripDet) {
      // first, set the measured coordinates to their nominal values
      measuredCoordinates.SetTIBTOBEntry( det, beam, pos, nominalCoordinates.GetTIBTOBEntry( det, beam, pos ) );
      
      if( isGoodFit ) { // convert strip position to global phi and replace the nominal phi value/error
        measuredStripPositions.GetTIBTOBEntry( det, beam, pos ) = peakFinderResults;
        const float positionInStrips =  theSetNominalStrips ? 256. + getTIBTOBNominalBeamOffset( det, beam, pos ) : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( positionInStrips ) );
        measuredCoordinates.GetTIBTOBEntry( det, beam, pos ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        measuredCoordinates.GetTIBTOBEntry( det, beam, pos ).SetPhiError( 0.00028 ); // PRELIMINARY ESTIMATE
      }
      else { // keep nominal position but set a giant phi error so that the module can be ignored by the alignment algorithm
        measuredStripPositions.GetTIBTOBEntry( det, beam, pos ) = std::pair<float,float>( 256. + getTIBTOBNominalBeamOffset( det, beam, pos ), 1000. );
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( 256. + getTIBTOBNominalBeamOffset( det, beam, pos ) ) );
        measuredCoordinates.GetTIBTOBEntry( det, beam, pos ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        measuredCoordinates.GetTIBTOBEntry( det, beam, pos ).SetPhiError( 1000. );
      }
    }

  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );




  // do the fits for TEC AT
  det = 0; beam = 0; disk = 0;
  do {

    // do the fit
    isGoodFit = peakFinder.FindPeakIn( collectedDataProfiles.GetTEC2TECEntry( det, beam, disk ), peakFinderResults,
                                       summedHistograms.GetTEC2TECEntry( det, beam, disk ), getTEC2TECNominalBeamOffset( det, beam, disk ) );
    // now we have the positions in units of strips.
    if( !isGoodFit ) std::cout << " [LaserAlignment::endRun] ** WARNING: Fit failed for TEC2TEC det: "
                               << det << ", beam: " << beam << ", disk: " << disk
                               << " (id: " << detectorId.GetTEC2TECEntry( det, beam, disk ) << ")." << std::endl;


    // <- here we will later implement the kink corrections
    
    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTEC2TECEntry( det, beam, disk ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );

    if (theStripDet) {
      // first, set the measured coordinates to their nominal values
      measuredCoordinates.SetTEC2TECEntry( det, beam, disk, nominalCoordinates.GetTEC2TECEntry( det, beam, disk ) );
      
      if( isGoodFit ) { // convert strip position to global phi and replace the nominal phi value/error
        measuredStripPositions.GetTEC2TECEntry( det, beam, disk ) = peakFinderResults;
        const float positionInStrips =  theSetNominalStrips ? 256. + getTEC2TECNominalBeamOffset( det, beam, disk ) : peakFinderResults.first; // implementation of "ForceFitterToNominalStrips" config parameter
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( positionInStrips ) );
        measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhiError( 0.00047 ); // PRELIMINARY ESTIMATE
      }
      else { // keep nominal position but set a giant phi error so that the module can be ignored by the alignment algorithm
        measuredStripPositions.GetTEC2TECEntry( det, beam, disk ) = std::pair<float,float>( 256. + getTEC2TECNominalBeamOffset( det, beam, disk ), 1000. );
        const GlobalPoint& globalPoint = theStripDet->surface().toGlobal( theStripDet->specificTopology().localPosition( 256. + getTEC2TECNominalBeamOffset( det, beam, disk ) ) );
        measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhi( ConvertAngle( globalPoint.barePhi() ) );
        measuredCoordinates.GetTEC2TECEntry( det, beam, disk ).SetPhiError( 1000. );
      }
    }

  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );
  






  // see what we got (for debugging)
  //  DumpStripFileSet( measuredStripPositions );
  //  DumpPosFileSet( measuredCoordinates );


  



  // CALCULATE PARAMETERS AND UPDATE DB OBJECT
  // for beam kink corrections, reconstructing the geometry and updating the db object
  LASGeometryUpdater geometryUpdater( nominalCoordinates, theLasConstants );

  // apply all beam corrections
  if( theApplyBeamKinkCorrections ) geometryUpdater.ApplyBeamKinkCorrections( measuredCoordinates );

  // if we start with input geometry instead of IDEAL,
  // reverse the adjustments in the AlignableTracker object
  if( updateFromInputGeometry ) geometryUpdater.SetReverseDirection( true );

  // if we have "virtual" misalignment which is introduced via the reference geometry,
  // tell the LASGeometryUpdater to reverse x & y adjustments
  if( misalignedByRefGeometry ) geometryUpdater.SetMisalignmentFromRefGeometry( true );

  // run the endcap algorithm
  LASEndcapAlgorithm endcapAlgorithm;
  LASEndcapAlignmentParameterSet endcapParameters;


  // this basically sets all the endcap modules to be masked 
  // to their nominal positions (since endcapParameters is overall zero)
  if( theMaskTecModules.size() ) {
    ApplyEndcapMaskingCorrections( measuredCoordinates, nominalCoordinates, endcapParameters );
  }

  // run the algorithm
  endcapParameters = endcapAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );

  // 
  // loop to mask out events
  // DESCRIPTION:
  //

  // do this only if there are modules to be masked..
  if( theMaskTecModules.size() ) {
    
    const unsigned int nIterations = 30;
    for( unsigned int iteration = 0; iteration < nIterations; ++iteration ) {
      
      // set the endcap modules to be masked to their positions
      // according to the reconstructed parameters
      ApplyEndcapMaskingCorrections( measuredCoordinates, nominalCoordinates, endcapParameters );
      
      // modifications applied, so re-run the algorithm
      endcapParameters = endcapAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );
      
    }

  } 

  // these are now final, so:
  endcapParameters.Print();



  
  // do a pre-alignment of the endcaps (TEC2TEC only)
  // so that the alignment tube algorithms finds orderly disks
  geometryUpdater.EndcapUpdate( endcapParameters, measuredCoordinates );


  // the alignment tube algorithms, choose from config
  LASBarrelAlignmentParameterSet alignmentTubeParameters;
  // the MINUIT-BASED alignment tube algorithm
  LASBarrelAlgorithm barrelAlgorithm;
  // the ANALYTICAL alignment tube algorithm
  LASAlignmentTubeAlgorithm alignmentTubeAlgorithm;


  // this basically sets all the modules to be masked 
  // to their nominal positions (since alignmentTubeParameters is overall zero)
  if( theMaskAtModules.size() ) {
    ApplyATMaskingCorrections( measuredCoordinates, nominalCoordinates, alignmentTubeParameters );
  }

  if( theUseMinuitAlgorithm ) {
    // run the MINUIT-BASED alignment tube algorithm
    alignmentTubeParameters = barrelAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );
  }
  else {
    // the ANALYTICAL alignment tube algorithm
    alignmentTubeParameters = alignmentTubeAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );
  }



  // 
  // loop to mask out events
  // DESCRIPTION:
  //

  // do this only if there are modules to be masked..
  if( theMaskAtModules.size() ) {
    
    const unsigned int nIterations = 30;
    for( unsigned int iteration = 0; iteration < nIterations; ++iteration ) {
      
      // set the AT modules to be masked to their positions
      // according to the reconstructed parameters
      ApplyATMaskingCorrections( measuredCoordinates, nominalCoordinates, alignmentTubeParameters );
      
      // modifications applied, so re-run the algorithm
      if( theUseMinuitAlgorithm ) {
        alignmentTubeParameters = barrelAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );
      }
      else {
        alignmentTubeParameters = alignmentTubeAlgorithm.CalculateParameters( measuredCoordinates, nominalCoordinates );
      }
      
    }

  } 


  // these are now final, so:
  alignmentTubeParameters.Print();


  // combine the results and update the db object
  geometryUpdater.TrackerUpdate( endcapParameters, alignmentTubeParameters, *theAlignableTracker );
  




    

    
    
  // the collection container
  std::auto_ptr<TkLasBeamCollection> laserBeams( new TkLasBeamCollection );

  
  // first for the endcap internal beams
  for( det = 0; det < 2; ++det ) {
    for( ring = 0; ring < 2; ++ring ) {
      for( beam = 0; beam < 8; ++beam ) {
        
        // the beam and its identifier (see TkLasTrackBasedInterface TWiki)
        TkLasBeam currentBeam( 100 * det + 10 * beam + ring );
        
        // order the hits in the beam by increasing z
        const int firstDisk = det==0 ? 0 : 8;
        const int lastDisk  = det==0 ? 8 : 0;
          
        // count upwards or downwards
        for( disk = firstDisk; det==0 ? disk <= lastDisk : disk >= lastDisk; det==0 ? ++disk : --disk ) {
            
          // detId for the SiStripLaserRecHit2D
          const SiStripDetId theDetId( detectorId.GetTECEntry( det, ring, beam, disk ) );
            
          // need this to calculate the localPosition and its error
          const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
            
          // the hit container
          const SiStripLaserRecHit2D currentHit(
            theStripDet->specificTopology().localPosition( measuredStripPositions.GetTECEntry( det, ring, beam, disk ).first ),
            theStripDet->specificTopology().localError( measuredStripPositions.GetTECEntry( det, ring, beam, disk ).first, measuredStripPositions.GetTECEntry( det, ring, beam, disk ).second ),
            theDetId
          );

          currentBeam.push_back( currentHit );

        }         
          
        laserBeams->push_back( currentBeam );
          
      }
    }
  }
    
    

  // then, following the convention in TkLasTrackBasedInterface TWiki, the alignment tube beams;
  // they comprise hits in TIBTOB & TEC2TEC

  for( beam = 0; beam < 8; ++beam ) {

    // the beam and its identifier (see TkLasTrackBasedInterface TWiki)
    TkLasBeam currentBeam( 100 * 2 /*beamGroup=AT=2*/ + 10 * beam + 0 /*ring=0*/);


    // first: tec-
    det = 1;
    for( disk = 4; disk >= 0; --disk ) {
        
      // detId for the SiStripLaserRecHit2D
      const SiStripDetId theDetId( detectorId.GetTEC2TECEntry( det, beam, disk ) );
        
      // need this to calculate the localPosition and its error
      const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
        
      // the hit container
      const SiStripLaserRecHit2D currentHit(
        theStripDet->specificTopology().localPosition( measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).first ),
        theStripDet->specificTopology().localError( measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).first, measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).second ),
        theDetId
      );

      currentBeam.push_back( currentHit );
        
    }

      
    // now TIB and TOB in one go
    for( det = 2; det < 4; ++det ) {
      for( pos = 5; pos >= 0; --pos ) { // stupidly, pos is defined from +z to -z in LASGlobalLoop
          
        // detId for the SiStripLaserRecHit2D
        const SiStripDetId theDetId( detectorId.GetTIBTOBEntry( det, beam, pos ) );
          
        // need this to calculate the localPosition and its error
        const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
          
        // the hit container
        const SiStripLaserRecHit2D currentHit(
          theStripDet->specificTopology().localPosition( measuredStripPositions.GetTIBTOBEntry( det, beam, pos ).first ),
          theStripDet->specificTopology().localError( measuredStripPositions.GetTIBTOBEntry( det, beam, pos ).first, measuredStripPositions.GetTIBTOBEntry( det, beam, pos ).second ),
          theDetId
        );

        currentBeam.push_back( currentHit );
          
      }
    }
      

    // then: tec+
    det = 0;
    for( disk = 0; disk < 5; ++disk ) {
        
      // detId for the SiStripLaserRecHit2D
      const SiStripDetId theDetId( detectorId.GetTEC2TECEntry( det, beam, disk ) );
        
      // need this to calculate the localPosition and its error
      const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
        
      // the hit container
      const SiStripLaserRecHit2D currentHit(
        theStripDet->specificTopology().localPosition( measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).first ),
        theStripDet->specificTopology().localError( measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).first, measuredStripPositions.GetTEC2TECEntry( det, beam, disk ).second ),
        theDetId
      );

      currentBeam.push_back( currentHit );
        
    }



    // save this beam to the beamCollection
    laserBeams->push_back( currentBeam );
    
  } // (close beam loop)
  
  
  // now attach the collection to the run
  theRun.put( laserBeams, "tkLaserBeams" );
  


  

  // store the estimated alignment parameters into the DB
  // first get them
  Alignments* alignments =  theAlignableTracker->alignments();
  AlignmentErrors* alignmentErrors = theAlignableTracker->alignmentErrors();

  if ( theStoreToDB ) {

    std::cout << " [LaserAlignment::endRun] -- Storing the calculated alignment parameters to the DataBase:" << std::endl;

    // Call service
    edm::Service<cond::service::PoolDBOutputService> poolDbService;
    if( !poolDbService.isAvailable() ) // Die if not available
      throw cms::Exception( "NotAvailable" ) << "PoolDBOutputService not available";
    
    // Store

    //     if ( poolDbService->isNewTagRequest(theAlignRecordName) ) {
    //       poolDbService->createNewIOV<Alignments>( alignments, poolDbService->currentTime(), poolDbService->endOfTime(), theAlignRecordName );
    //     }
    //     else {
    //       poolDbService->appendSinceTime<Alignments>( alignments, poolDbService->currentTime(), theAlignRecordName );
    //     }
    poolDbService->writeOne<Alignments>( alignments, poolDbService->beginOfTime(), theAlignRecordName );

    //     if ( poolDbService->isNewTagRequest(theErrorRecordName) ) {
    //       poolDbService->createNewIOV<AlignmentErrors>( alignmentErrors, poolDbService->currentTime(), poolDbService->endOfTime(), theErrorRecordName );
    //     }
    //     else {
    //       poolDbService->appendSinceTime<AlignmentErrors>( alignmentErrors, poolDbService->currentTime(), theErrorRecordName );
    //     }
    poolDbService->writeOne<AlignmentErrors>( alignmentErrors, poolDbService->beginOfTime(), theErrorRecordName );

    std::cout << " [LaserAlignment::endRun] -- Storing done." << std::endl;
    
  }

}
void LaserAlignment::fillDataProfiles ( edm::Event const &  theEvent,
edm::EventSetup const &  theSetup 
) [private]

fill profiles from SiStrip(Raw)Digi container

fills the module profiles (LASGlobalLoop<LASModuleProfile> currentDataProfiles) from the event digi containers, distinguishing between SiStripDigi or SiStripRawDigi.

Definition at line 972 of file LaserAlignment.cc.

References SiStripRawDigi::adc(), SiStripDigi::adc(), edm::DetSetVector< T >::begin(), currentDataProfiles, detectorId, dtTPAnalyzer_cfg::digiLabel, EcnaSystemPythonModuleInsert_2::digiProducer, edm::DetSetVector< T >::end(), Exception, edm::Event::getByLabel(), LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), moduleLoop, pos, relativeConstraints::ring, LASModuleProfile::SetAllValuesTo(), LASModuleProfile::SetValue(), AlCaHLTBitMon_QueryRunRegistry::string, SiStripDigi::strip(), LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), theDigiProducersList, and LASGlobalLoop::TIBTOBLoop().

Referenced by produce().

                                                                                               {

  // two handles for the two different kinds of digis
  edm::Handle< edm::DetSetVector<SiStripRawDigi> > theStripRawDigis;
  edm::Handle< edm::DetSetVector<SiStripDigi> > theStripDigis;

  bool isRawDigi = false;

  // indices for the LASGlobalLoop object
  int det = 0, ring = 0, beam = 0, disk = 0, pos = 0;

  // query config set and loop over all PSets in the VPSet
  for ( std::vector<edm::ParameterSet>::iterator itDigiProducersList = theDigiProducersList.begin(); itDigiProducersList != theDigiProducersList.end(); ++itDigiProducersList ) {

    std::string digiProducer = itDigiProducersList->getParameter<std::string>( "DigiProducer" );
    std::string digiLabel = itDigiProducersList->getParameter<std::string>( "DigiLabel" );
    std::string digiType = itDigiProducersList->getParameter<std::string>( "DigiType" );

    // now branch according to digi type (raw or processed);    
    // first we go for raw digis => SiStripRawDigi
    if( digiType == "Raw" ) {
      theEvent.getByLabel( digiProducer, digiLabel, theStripRawDigis );
      isRawDigi = true;
    }
    else if( digiType == "Processed" ) {
      theEvent.getByLabel( digiProducer, digiLabel, theStripDigis );
      isRawDigi = false;
    }
    else {
      throw cms::Exception( " [LaserAlignment::fillDataProfiles]") << " ** ERROR: Invalid digi type: \"" << digiType << "\" specified in configuration." << std::endl;
    }    



    // loop TEC internal modules
    det = 0; ring = 0; beam = 0; disk = 0;
    do {
      
      // first clear the profile
      currentDataProfiles.GetTECEntry( det, ring, beam, disk ).SetAllValuesTo( 0. );

      // retrieve the raw id of that module
      const int detRawId = detectorId.GetTECEntry( det, ring, beam, disk );
      
      if( isRawDigi ) { // we have raw SiStripRawDigis
        
        // search the digis for the raw id
        edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find( detRawId );
        if( detSetIter == theStripRawDigis->end() ) {
          throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
        }
      
        // fill the digis to the profiles
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
        
        // loop all digis
        for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripRawDigi& digi = *digiRangeIterator;
          const int channel = distance( digiRangeStart, digiRangeIterator );
          if ( channel >= 0 && channel < 512 ) currentDataProfiles.GetTECEntry( det, ring, beam, disk ).SetValue( channel, digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "." << std::endl;
        }

      }

      else { // we have zero suppressed SiStripDigis

        // search the digis for the raw id
        edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find( detRawId );
        
        // processed DetSets may be missing, just skip
        if( detSetIter == theStripDigis->end() ) continue;

        // fill the digis to the profiles
        edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
        
        for(; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripDigi& digi = *digiRangeIterator;
          if ( digi.strip() < 512 ) currentDataProfiles.GetTECEntry( det, ring, beam, disk ).SetValue( digi.strip(), digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "." << std::endl;
        }

      }

      
    } while( moduleLoop.TECLoop( det, ring, beam, disk ) );
    



    
    // loop TIBTOB modules
    det = 2; beam = 0; pos = 0;
    do {

      // first clear the profile
      currentDataProfiles.GetTIBTOBEntry( det, beam, pos ).SetAllValuesTo( 0. );

      // retrieve the raw id of that module
      const int detRawId = detectorId.GetTIBTOBEntry( det, beam, pos );
      
      if( isRawDigi ) { // we have raw SiStripRawDigis
        
        // search the digis for the raw id
        edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find( detRawId );
        if( detSetIter == theStripRawDigis->end() ) {
          throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
        }
      
        // fill the digis to the profiles
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
        
        // loop all digis
        for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripRawDigi& digi = *digiRangeIterator;
          const int channel = distance( digiRangeStart, digiRangeIterator );
          if ( channel >= 0 && channel < 512 ) currentDataProfiles.GetTIBTOBEntry( det, beam, pos ).SetValue( channel, digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "." << std::endl;
        }

      }

      else { // we have zero suppressed SiStripDigis

        // search the digis for the raw id
        edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find( detRawId );

        // processed DetSets may be missing, just skip
        if( detSetIter == theStripDigis->end() ) continue;

        // fill the digis to the profiles
        edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
        
        for(; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripDigi& digi = *digiRangeIterator;
          if ( digi.strip() < 512 ) currentDataProfiles.GetTIBTOBEntry( det, beam, pos ).SetValue( digi.strip(), digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "." << std::endl;
        }

      }

    } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );



    // loop TEC AT modules
    det = 0; beam = 0; disk = 0;
    do {

      // first clear the profile
      currentDataProfiles.GetTEC2TECEntry( det, beam, disk ).SetAllValuesTo( 0. );

      // retrieve the raw id of that module
      const int detRawId = detectorId.GetTEC2TECEntry( det, beam, disk );
    
      if( isRawDigi ) { // we have raw SiStripRawDigis
      
        // search the digis for the raw id
        edm::DetSetVector<SiStripRawDigi>::const_iterator detSetIter = theStripRawDigis->find( detRawId );
        if( detSetIter == theStripRawDigis->end() ) {
          throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: No raw DetSet found for det: " << detRawId << "." << std::endl;
        }
      
        // fill the digis to the profiles
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
        edm::DetSet<SiStripRawDigi>::const_iterator digiRangeStart = digiRangeIterator; // save starting positions
      
        // loop all digis
        for (; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripRawDigi& digi = *digiRangeIterator;
          const int channel = distance( digiRangeStart, digiRangeIterator );
          if ( channel >= 0 && channel < 512 ) currentDataProfiles.GetTEC2TECEntry( det, beam, disk ).SetValue( channel, digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: raw digi channel: " << channel << " out of range for det: " << detRawId << "." << std::endl;
        }
      
      }
    
      else { // we have zero suppressed SiStripDigis
      
        // search the digis for the raw id
        edm::DetSetVector<SiStripDigi>::const_iterator detSetIter = theStripDigis->find( detRawId );
        
        // processed DetSets may be missing, just skip
        if( detSetIter == theStripDigis->end() ) continue;
      
        // fill the digis to the profiles
        edm::DetSet<SiStripDigi>::const_iterator digiRangeIterator = detSetIter->data.begin(); // for the loop
      
        for(; digiRangeIterator != detSetIter->data.end(); ++digiRangeIterator ) {
          const SiStripDigi& digi = *digiRangeIterator;
          if ( digi.strip() < 512 ) currentDataProfiles.GetTEC2TECEntry( det, beam, disk ).SetValue( digi.strip(), digi.adc() );
          else throw cms::Exception( "[Laser Alignment::fillDataProfiles]" ) << " ** ERROR: digi strip: " << digi.strip() << " out of range for det: " << detRawId << "." << std::endl;
        }
      
      }
    
    } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );

  } // theDigiProducersList loop

}
void LaserAlignment::fillDetectorId ( void  ) [private]

fill hard coded detIds

all the detector ids for the LAS modules hard-coded

Definition at line 8 of file LaserAlignmentFillDetId.cc.

References detectorId, LASGlobalData< T >::SetTEC2TECEntry(), LASGlobalData< T >::SetTECEntry(), LASGlobalData< T >::SetTIBTOBEntry(), and tecDoubleHitDetId.

Referenced by beginJob().

                                          {
  
  // these are the detids of the TEC modules hit
  // by the AT as well as the TEC beams
  tecDoubleHitDetId.push_back( 470307208 );
  tecDoubleHitDetId.push_back( 470323592 );
  tecDoubleHitDetId.push_back( 470339976 );
  tecDoubleHitDetId.push_back( 470356360 );
  tecDoubleHitDetId.push_back( 470372744 );
  tecDoubleHitDetId.push_back( 470307976 );
  tecDoubleHitDetId.push_back( 470324360 );
  tecDoubleHitDetId.push_back( 470340744 );
  tecDoubleHitDetId.push_back( 470357128 );
  tecDoubleHitDetId.push_back( 470373512 );
  tecDoubleHitDetId.push_back( 470308488 );
  tecDoubleHitDetId.push_back( 470324872 );
  tecDoubleHitDetId.push_back( 470341256 );
  tecDoubleHitDetId.push_back( 470357640 );
  tecDoubleHitDetId.push_back( 470374024 );
  tecDoubleHitDetId.push_back( 470045064 );
  tecDoubleHitDetId.push_back( 470061448 );
  tecDoubleHitDetId.push_back( 470077832 );
  tecDoubleHitDetId.push_back( 470094216 );
  tecDoubleHitDetId.push_back( 470110600 );
  tecDoubleHitDetId.push_back( 470045832 );
  tecDoubleHitDetId.push_back( 470062216 );
  tecDoubleHitDetId.push_back( 470078600 );
  tecDoubleHitDetId.push_back( 470094984 );
  tecDoubleHitDetId.push_back( 470111368 );
  tecDoubleHitDetId.push_back( 470046344 );
  tecDoubleHitDetId.push_back( 470062728 );
  tecDoubleHitDetId.push_back( 470079112 );
  tecDoubleHitDetId.push_back( 470095496 );
  tecDoubleHitDetId.push_back( 470111880 );

  // now all the modules (above included)

  // TEC+
  detectorId.SetTECEntry( 0, 0, 0, 0, 470307208 );
  detectorId.SetTECEntry( 0, 0, 0, 1, 470323592 );
  detectorId.SetTECEntry( 0, 0, 0, 2, 470339976 );
  detectorId.SetTECEntry( 0, 0, 0, 3, 470356360 );
  detectorId.SetTECEntry( 0, 0, 0, 4, 470372744 );
  detectorId.SetTECEntry( 0, 0, 0, 5, 470389128 );
  detectorId.SetTECEntry( 0, 0, 0, 6, 470405512 );
  detectorId.SetTECEntry( 0, 0, 0, 7, 470421896 );
  detectorId.SetTECEntry( 0, 0, 0, 8, 470438280 );
  detectorId.SetTECEntry( 0, 0, 1, 0, 470307464 );
  detectorId.SetTECEntry( 0, 0, 1, 1, 470323848 );
  detectorId.SetTECEntry( 0, 0, 1, 2, 470340232 );
  detectorId.SetTECEntry( 0, 0, 1, 3, 470356616 );
  detectorId.SetTECEntry( 0, 0, 1, 4, 470373000 );
  detectorId.SetTECEntry( 0, 0, 1, 5, 470389384 );
  detectorId.SetTECEntry( 0, 0, 1, 6, 470405768 );
  detectorId.SetTECEntry( 0, 0, 1, 7, 470422152 );
  detectorId.SetTECEntry( 0, 0, 1, 8, 470438536 );
  detectorId.SetTECEntry( 0, 0, 2, 0, 470307720 );
  detectorId.SetTECEntry( 0, 0, 2, 1, 470324104 );
  detectorId.SetTECEntry( 0, 0, 2, 2, 470340488 );
  detectorId.SetTECEntry( 0, 0, 2, 3, 470356872 );
  detectorId.SetTECEntry( 0, 0, 2, 4, 470373256 );
  detectorId.SetTECEntry( 0, 0, 2, 5, 470389640 );
  detectorId.SetTECEntry( 0, 0, 2, 6, 470406024 );
  detectorId.SetTECEntry( 0, 0, 2, 7, 470422408 );
  detectorId.SetTECEntry( 0, 0, 2, 8, 470438792 );
  detectorId.SetTECEntry( 0, 0, 3, 0, 470307976 );
  detectorId.SetTECEntry( 0, 0, 3, 1, 470324360 );
  detectorId.SetTECEntry( 0, 0, 3, 2, 470340744 );
  detectorId.SetTECEntry( 0, 0, 3, 3, 470357128 );
  detectorId.SetTECEntry( 0, 0, 3, 4, 470373512 );
  detectorId.SetTECEntry( 0, 0, 3, 5, 470389896 );
  detectorId.SetTECEntry( 0, 0, 3, 6, 470406280 );
  detectorId.SetTECEntry( 0, 0, 3, 7, 470422664 );
  detectorId.SetTECEntry( 0, 0, 3, 8, 470439048 );
  detectorId.SetTECEntry( 0, 0, 4, 0, 470308232 );
  detectorId.SetTECEntry( 0, 0, 4, 1, 470324616 );
  detectorId.SetTECEntry( 0, 0, 4, 2, 470341000 );
  detectorId.SetTECEntry( 0, 0, 4, 3, 470357384 );
  detectorId.SetTECEntry( 0, 0, 4, 4, 470373768 );
  detectorId.SetTECEntry( 0, 0, 4, 5, 470390152 );
  detectorId.SetTECEntry( 0, 0, 4, 6, 470406536 );
  detectorId.SetTECEntry( 0, 0, 4, 7, 470422920 );
  detectorId.SetTECEntry( 0, 0, 4, 8, 470439304 );
  detectorId.SetTECEntry( 0, 0, 5, 0, 470308488 );
  detectorId.SetTECEntry( 0, 0, 5, 1, 470324872 );
  detectorId.SetTECEntry( 0, 0, 5, 2, 470341256 );
  detectorId.SetTECEntry( 0, 0, 5, 3, 470357640 );
  detectorId.SetTECEntry( 0, 0, 5, 4, 470374024 );
  detectorId.SetTECEntry( 0, 0, 5, 5, 470390408 );
  detectorId.SetTECEntry( 0, 0, 5, 6, 470406792 );
  detectorId.SetTECEntry( 0, 0, 5, 7, 470423176 );
  detectorId.SetTECEntry( 0, 0, 5, 8, 470439560 );
  detectorId.SetTECEntry( 0, 0, 6, 0, 470308744 );
  detectorId.SetTECEntry( 0, 0, 6, 1, 470325128 );
  detectorId.SetTECEntry( 0, 0, 6, 2, 470341512 );
  detectorId.SetTECEntry( 0, 0, 6, 3, 470357896 );
  detectorId.SetTECEntry( 0, 0, 6, 4, 470374280 );
  detectorId.SetTECEntry( 0, 0, 6, 5, 470390664 );
  detectorId.SetTECEntry( 0, 0, 6, 6, 470407048 );
  detectorId.SetTECEntry( 0, 0, 6, 7, 470423432 );
  detectorId.SetTECEntry( 0, 0, 6, 8, 470439816 );
  detectorId.SetTECEntry( 0, 0, 7, 0, 470309000 );
  detectorId.SetTECEntry( 0, 0, 7, 1, 470325384 );
  detectorId.SetTECEntry( 0, 0, 7, 2, 470341768 );
  detectorId.SetTECEntry( 0, 0, 7, 3, 470358152 );
  detectorId.SetTECEntry( 0, 0, 7, 4, 470374536 );
  detectorId.SetTECEntry( 0, 0, 7, 5, 470390920 );
  detectorId.SetTECEntry( 0, 0, 7, 6, 470407304 );
  detectorId.SetTECEntry( 0, 0, 7, 7, 470423688 );
  detectorId.SetTECEntry( 0, 0, 7, 8, 470440072 );
  detectorId.SetTECEntry( 0, 1, 0, 0, 470307272 );
  detectorId.SetTECEntry( 0, 1, 0, 1, 470323656 );
  detectorId.SetTECEntry( 0, 1, 0, 2, 470340040 );
  detectorId.SetTECEntry( 0, 1, 0, 3, 470356424 );
  detectorId.SetTECEntry( 0, 1, 0, 4, 470372808 );
  detectorId.SetTECEntry( 0, 1, 0, 5, 470389192 );
  detectorId.SetTECEntry( 0, 1, 0, 6, 470405576 );
  detectorId.SetTECEntry( 0, 1, 0, 7, 470421960 );
  detectorId.SetTECEntry( 0, 1, 0, 8, 470438344 );
  detectorId.SetTECEntry( 0, 1, 1, 0, 470307528 );
  detectorId.SetTECEntry( 0, 1, 1, 1, 470323912 );
  detectorId.SetTECEntry( 0, 1, 1, 2, 470340296 );
  detectorId.SetTECEntry( 0, 1, 1, 3, 470356680 );
  detectorId.SetTECEntry( 0, 1, 1, 4, 470373064 );
  detectorId.SetTECEntry( 0, 1, 1, 5, 470389448 );
  detectorId.SetTECEntry( 0, 1, 1, 6, 470405832 );
  detectorId.SetTECEntry( 0, 1, 1, 7, 470422216 );
  detectorId.SetTECEntry( 0, 1, 1, 8, 470438600 );
  detectorId.SetTECEntry( 0, 1, 2, 0, 470307784 );
  detectorId.SetTECEntry( 0, 1, 2, 1, 470324168 );
  detectorId.SetTECEntry( 0, 1, 2, 2, 470340552 );
  detectorId.SetTECEntry( 0, 1, 2, 3, 470356936 );
  detectorId.SetTECEntry( 0, 1, 2, 4, 470373320 );
  detectorId.SetTECEntry( 0, 1, 2, 5, 470389704 );
  detectorId.SetTECEntry( 0, 1, 2, 6, 470406088 );
  detectorId.SetTECEntry( 0, 1, 2, 7, 470422472 );
  detectorId.SetTECEntry( 0, 1, 2, 8, 470438856 );
  detectorId.SetTECEntry( 0, 1, 3, 0, 470308040 );
  detectorId.SetTECEntry( 0, 1, 3, 1, 470324424 );
  detectorId.SetTECEntry( 0, 1, 3, 2, 470340808 );
  detectorId.SetTECEntry( 0, 1, 3, 3, 470357192 );
  detectorId.SetTECEntry( 0, 1, 3, 4, 470373576 );
  detectorId.SetTECEntry( 0, 1, 3, 5, 470389960 );
  detectorId.SetTECEntry( 0, 1, 3, 6, 470406344 );
  detectorId.SetTECEntry( 0, 1, 3, 7, 470422728 );
  detectorId.SetTECEntry( 0, 1, 3, 8, 470439112 );
  detectorId.SetTECEntry( 0, 1, 4, 0, 470308296 );
  detectorId.SetTECEntry( 0, 1, 4, 1, 470324680 );
  detectorId.SetTECEntry( 0, 1, 4, 2, 470341064 );
  detectorId.SetTECEntry( 0, 1, 4, 3, 470357448 );
  detectorId.SetTECEntry( 0, 1, 4, 4, 470373832 );
  detectorId.SetTECEntry( 0, 1, 4, 5, 470390216 );
  detectorId.SetTECEntry( 0, 1, 4, 6, 470406600 );
  detectorId.SetTECEntry( 0, 1, 4, 7, 470422984 );
  detectorId.SetTECEntry( 0, 1, 4, 8, 470439368 );
  detectorId.SetTECEntry( 0, 1, 5, 0, 470308552 );
  detectorId.SetTECEntry( 0, 1, 5, 1, 470324936 );
  detectorId.SetTECEntry( 0, 1, 5, 2, 470341320 );
  detectorId.SetTECEntry( 0, 1, 5, 3, 470357704 );
  detectorId.SetTECEntry( 0, 1, 5, 4, 470374088 );
  detectorId.SetTECEntry( 0, 1, 5, 5, 470390472 );
  detectorId.SetTECEntry( 0, 1, 5, 6, 470406856 );
  detectorId.SetTECEntry( 0, 1, 5, 7, 470423240 );
  detectorId.SetTECEntry( 0, 1, 5, 8, 470439624 );
  detectorId.SetTECEntry( 0, 1, 6, 0, 470308808 );
  detectorId.SetTECEntry( 0, 1, 6, 1, 470325192 );
  detectorId.SetTECEntry( 0, 1, 6, 2, 470341576 );
  detectorId.SetTECEntry( 0, 1, 6, 3, 470357960 );
  detectorId.SetTECEntry( 0, 1, 6, 4, 470374344 );
  detectorId.SetTECEntry( 0, 1, 6, 5, 470390728 );
  detectorId.SetTECEntry( 0, 1, 6, 6, 470407112 );
  detectorId.SetTECEntry( 0, 1, 6, 7, 470423496 );
  detectorId.SetTECEntry( 0, 1, 6, 8, 470439880 );
  detectorId.SetTECEntry( 0, 1, 7, 0, 470309064 );
  detectorId.SetTECEntry( 0, 1, 7, 1, 470325448 );
  detectorId.SetTECEntry( 0, 1, 7, 2, 470341832 );
  detectorId.SetTECEntry( 0, 1, 7, 3, 470358216 );
  detectorId.SetTECEntry( 0, 1, 7, 4, 470374600 );
  detectorId.SetTECEntry( 0, 1, 7, 5, 470390984 );
  detectorId.SetTECEntry( 0, 1, 7, 6, 470407368 );
  detectorId.SetTECEntry( 0, 1, 7, 7, 470423752 );
  detectorId.SetTECEntry( 0, 1, 7, 8, 470440136 );

  // TEC-
  detectorId.SetTECEntry( 1, 0, 0, 0, 470045064 );
  detectorId.SetTECEntry( 1, 0, 0, 1, 470061448 );
  detectorId.SetTECEntry( 1, 0, 0, 2, 470077832 );
  detectorId.SetTECEntry( 1, 0, 0, 3, 470094216 );
  detectorId.SetTECEntry( 1, 0, 0, 4, 470110600 );
  detectorId.SetTECEntry( 1, 0, 0, 5, 470126984 );
  detectorId.SetTECEntry( 1, 0, 0, 6, 470143368 );
  detectorId.SetTECEntry( 1, 0, 0, 7, 470159752 );
  detectorId.SetTECEntry( 1, 0, 0, 8, 470176136 );
  detectorId.SetTECEntry( 1, 0, 1, 0, 470045320 );
  detectorId.SetTECEntry( 1, 0, 1, 1, 470061704 );
  detectorId.SetTECEntry( 1, 0, 1, 2, 470078088 );
  detectorId.SetTECEntry( 1, 0, 1, 3, 470094472 );
  detectorId.SetTECEntry( 1, 0, 1, 4, 470110856 );
  detectorId.SetTECEntry( 1, 0, 1, 5, 470127240 );
  detectorId.SetTECEntry( 1, 0, 1, 6, 470143624 );
  detectorId.SetTECEntry( 1, 0, 1, 7, 470160008 );
  detectorId.SetTECEntry( 1, 0, 1, 8, 470176392 );
  detectorId.SetTECEntry( 1, 0, 2, 0, 470045576 );
  detectorId.SetTECEntry( 1, 0, 2, 1, 470061960 );
  detectorId.SetTECEntry( 1, 0, 2, 2, 470078344 );
  detectorId.SetTECEntry( 1, 0, 2, 3, 470094728 );
  detectorId.SetTECEntry( 1, 0, 2, 4, 470111112 );
  detectorId.SetTECEntry( 1, 0, 2, 5, 470127496 );
  detectorId.SetTECEntry( 1, 0, 2, 6, 470143880 );
  detectorId.SetTECEntry( 1, 0, 2, 7, 470160264 );
  detectorId.SetTECEntry( 1, 0, 2, 8, 470176648 );
  detectorId.SetTECEntry( 1, 0, 3, 0, 470045832 );
  detectorId.SetTECEntry( 1, 0, 3, 1, 470062216 );
  detectorId.SetTECEntry( 1, 0, 3, 2, 470078600 );
  detectorId.SetTECEntry( 1, 0, 3, 3, 470094984 );
  detectorId.SetTECEntry( 1, 0, 3, 4, 470111368 );
  detectorId.SetTECEntry( 1, 0, 3, 5, 470127752 );
  detectorId.SetTECEntry( 1, 0, 3, 6, 470144136 );
  detectorId.SetTECEntry( 1, 0, 3, 7, 470160520 );
  detectorId.SetTECEntry( 1, 0, 3, 8, 470176904 );
  detectorId.SetTECEntry( 1, 0, 4, 0, 470046088 );
  detectorId.SetTECEntry( 1, 0, 4, 1, 470062472 );
  detectorId.SetTECEntry( 1, 0, 4, 2, 470078856 );
  detectorId.SetTECEntry( 1, 0, 4, 3, 470095240 );
  detectorId.SetTECEntry( 1, 0, 4, 4, 470111624 );
  detectorId.SetTECEntry( 1, 0, 4, 5, 470128008 );
  detectorId.SetTECEntry( 1, 0, 4, 6, 470144392 );
  detectorId.SetTECEntry( 1, 0, 4, 7, 470160776 );
  detectorId.SetTECEntry( 1, 0, 4, 8, 470177160 );
  detectorId.SetTECEntry( 1, 0, 5, 0, 470046344 );
  detectorId.SetTECEntry( 1, 0, 5, 1, 470062728 );
  detectorId.SetTECEntry( 1, 0, 5, 2, 470079112 );
  detectorId.SetTECEntry( 1, 0, 5, 3, 470095496 );
  detectorId.SetTECEntry( 1, 0, 5, 4, 470111880 );
  detectorId.SetTECEntry( 1, 0, 5, 5, 470128264 );
  detectorId.SetTECEntry( 1, 0, 5, 6, 470144648 );
  detectorId.SetTECEntry( 1, 0, 5, 7, 470161032 );
  detectorId.SetTECEntry( 1, 0, 5, 8, 470177416 );
  detectorId.SetTECEntry( 1, 0, 6, 0, 470046600 );
  detectorId.SetTECEntry( 1, 0, 6, 1, 470062984 );
  detectorId.SetTECEntry( 1, 0, 6, 2, 470079368 );
  detectorId.SetTECEntry( 1, 0, 6, 3, 470095752 );
  detectorId.SetTECEntry( 1, 0, 6, 4, 470112136 );
  detectorId.SetTECEntry( 1, 0, 6, 5, 470128520 );
  detectorId.SetTECEntry( 1, 0, 6, 6, 470144904 );
  detectorId.SetTECEntry( 1, 0, 6, 7, 470161288 );
  detectorId.SetTECEntry( 1, 0, 6, 8, 470177672 );
  detectorId.SetTECEntry( 1, 0, 7, 0, 470046856 );
  detectorId.SetTECEntry( 1, 0, 7, 1, 470063240 );
  detectorId.SetTECEntry( 1, 0, 7, 2, 470079624 );
  detectorId.SetTECEntry( 1, 0, 7, 3, 470096008 );
  detectorId.SetTECEntry( 1, 0, 7, 4, 470112392 );
  detectorId.SetTECEntry( 1, 0, 7, 5, 470128776 );
  detectorId.SetTECEntry( 1, 0, 7, 6, 470145160 );
  detectorId.SetTECEntry( 1, 0, 7, 7, 470161544 );
  detectorId.SetTECEntry( 1, 0, 7, 8, 470177928 );
  detectorId.SetTECEntry( 1, 1, 0, 0, 470045128 );
  detectorId.SetTECEntry( 1, 1, 0, 1, 470061512 );
  detectorId.SetTECEntry( 1, 1, 0, 2, 470077896 );
  detectorId.SetTECEntry( 1, 1, 0, 3, 470094280 );
  detectorId.SetTECEntry( 1, 1, 0, 4, 470110664 );
  detectorId.SetTECEntry( 1, 1, 0, 5, 470127048 );
  detectorId.SetTECEntry( 1, 1, 0, 6, 470143432 );
  detectorId.SetTECEntry( 1, 1, 0, 7, 470159816 );
  detectorId.SetTECEntry( 1, 1, 0, 8, 470176200 );
  detectorId.SetTECEntry( 1, 1, 1, 0, 470045384 );
  detectorId.SetTECEntry( 1, 1, 1, 1, 470061768 );
  detectorId.SetTECEntry( 1, 1, 1, 2, 470078152 );
  detectorId.SetTECEntry( 1, 1, 1, 3, 470094536 );
  detectorId.SetTECEntry( 1, 1, 1, 4, 470110920 );
  detectorId.SetTECEntry( 1, 1, 1, 5, 470127304 );
  detectorId.SetTECEntry( 1, 1, 1, 6, 470143688 );
  detectorId.SetTECEntry( 1, 1, 1, 7, 470160072 );
  detectorId.SetTECEntry( 1, 1, 1, 8, 470176456 );
  detectorId.SetTECEntry( 1, 1, 2, 0, 470045640 );
  detectorId.SetTECEntry( 1, 1, 2, 1, 470062024 );
  detectorId.SetTECEntry( 1, 1, 2, 2, 470078408 );
  detectorId.SetTECEntry( 1, 1, 2, 3, 470094792 );
  detectorId.SetTECEntry( 1, 1, 2, 4, 470111176 );
  detectorId.SetTECEntry( 1, 1, 2, 5, 470127560 );
  detectorId.SetTECEntry( 1, 1, 2, 6, 470143944 );
  detectorId.SetTECEntry( 1, 1, 2, 7, 470160328 );
  detectorId.SetTECEntry( 1, 1, 2, 8, 470176712 );
  detectorId.SetTECEntry( 1, 1, 3, 0, 470045896 );
  detectorId.SetTECEntry( 1, 1, 3, 1, 470062280 );
  detectorId.SetTECEntry( 1, 1, 3, 2, 470078664 );
  detectorId.SetTECEntry( 1, 1, 3, 3, 470095048 );
  detectorId.SetTECEntry( 1, 1, 3, 4, 470111432 );
  detectorId.SetTECEntry( 1, 1, 3, 5, 470127816 );
  detectorId.SetTECEntry( 1, 1, 3, 6, 470144200 );
  detectorId.SetTECEntry( 1, 1, 3, 7, 470160584 );
  detectorId.SetTECEntry( 1, 1, 3, 8, 470176968 );
  detectorId.SetTECEntry( 1, 1, 4, 0, 470046152 );
  detectorId.SetTECEntry( 1, 1, 4, 1, 470062536 );
  detectorId.SetTECEntry( 1, 1, 4, 2, 470078920 );
  detectorId.SetTECEntry( 1, 1, 4, 3, 470095304 );
  detectorId.SetTECEntry( 1, 1, 4, 4, 470111688 );
  detectorId.SetTECEntry( 1, 1, 4, 5, 470128072 );
  detectorId.SetTECEntry( 1, 1, 4, 6, 470144456 );
  detectorId.SetTECEntry( 1, 1, 4, 7, 470160840 );
  detectorId.SetTECEntry( 1, 1, 4, 8, 470177224 );
  detectorId.SetTECEntry( 1, 1, 5, 0, 470046408 );
  detectorId.SetTECEntry( 1, 1, 5, 1, 470062792 );
  detectorId.SetTECEntry( 1, 1, 5, 2, 470079176 );
  detectorId.SetTECEntry( 1, 1, 5, 3, 470095560 );
  detectorId.SetTECEntry( 1, 1, 5, 4, 470111944 );
  detectorId.SetTECEntry( 1, 1, 5, 5, 470128328 );
  detectorId.SetTECEntry( 1, 1, 5, 6, 470144712 );
  detectorId.SetTECEntry( 1, 1, 5, 7, 470161096 );
  detectorId.SetTECEntry( 1, 1, 5, 8, 470177480 );
  detectorId.SetTECEntry( 1, 1, 6, 0, 470046664 );
  detectorId.SetTECEntry( 1, 1, 6, 1, 470063048 );
  detectorId.SetTECEntry( 1, 1, 6, 2, 470079432 );
  detectorId.SetTECEntry( 1, 1, 6, 3, 470095816 );
  detectorId.SetTECEntry( 1, 1, 6, 4, 470112200 );
  detectorId.SetTECEntry( 1, 1, 6, 5, 470128584 );
  detectorId.SetTECEntry( 1, 1, 6, 6, 470144968 );
  detectorId.SetTECEntry( 1, 1, 6, 7, 470161352 );
  detectorId.SetTECEntry( 1, 1, 6, 8, 470177736 );
  detectorId.SetTECEntry( 1, 1, 7, 0, 470046920 );
  detectorId.SetTECEntry( 1, 1, 7, 1, 470063304 );
  detectorId.SetTECEntry( 1, 1, 7, 2, 470079688 );
  detectorId.SetTECEntry( 1, 1, 7, 3, 470096072 );
  detectorId.SetTECEntry( 1, 1, 7, 4, 470112456 );
  detectorId.SetTECEntry( 1, 1, 7, 5, 470128840 );
  detectorId.SetTECEntry( 1, 1, 7, 6, 470145224 );
  detectorId.SetTECEntry( 1, 1, 7, 7, 470161608 );
  detectorId.SetTECEntry( 1, 1, 7, 8, 470177992 );

  // TIB
  detectorId.SetTIBTOBEntry( 2, 0, 0, 369174604 );
  detectorId.SetTIBTOBEntry( 2, 0, 1, 369174600 );
  detectorId.SetTIBTOBEntry( 2, 0, 2, 369174596 );
  detectorId.SetTIBTOBEntry( 2, 0, 3, 369170500 );
  detectorId.SetTIBTOBEntry( 2, 0, 4, 369170504 );
  detectorId.SetTIBTOBEntry( 2, 0, 5, 369170508 );
  detectorId.SetTIBTOBEntry( 2, 1, 0, 369174732 );
  detectorId.SetTIBTOBEntry( 2, 1, 1, 369174728 );
  detectorId.SetTIBTOBEntry( 2, 1, 2, 369174724 );
  detectorId.SetTIBTOBEntry( 2, 1, 3, 369170628 );
  detectorId.SetTIBTOBEntry( 2, 1, 4, 369170632 );
  detectorId.SetTIBTOBEntry( 2, 1, 5, 369170636 );
  detectorId.SetTIBTOBEntry( 2, 2, 0, 369174812 );
  detectorId.SetTIBTOBEntry( 2, 2, 1, 369174808 );
  detectorId.SetTIBTOBEntry( 2, 2, 2, 369174804 );
  detectorId.SetTIBTOBEntry( 2, 2, 3, 369170708 );
  detectorId.SetTIBTOBEntry( 2, 2, 4, 369170712 );
  detectorId.SetTIBTOBEntry( 2, 2, 5, 369170716 );
  detectorId.SetTIBTOBEntry( 2, 3, 0, 369174940 );
  detectorId.SetTIBTOBEntry( 2, 3, 1, 369174936 );
  detectorId.SetTIBTOBEntry( 2, 3, 2, 369174932 );
  detectorId.SetTIBTOBEntry( 2, 3, 3, 369170836 );
  detectorId.SetTIBTOBEntry( 2, 3, 4, 369170840 );
  detectorId.SetTIBTOBEntry( 2, 3, 5, 369170844 );
  detectorId.SetTIBTOBEntry( 2, 4, 0, 369175068 );
  detectorId.SetTIBTOBEntry( 2, 4, 1, 369175064 );
  detectorId.SetTIBTOBEntry( 2, 4, 2, 369175060 );
  detectorId.SetTIBTOBEntry( 2, 4, 3, 369170964 );
  detectorId.SetTIBTOBEntry( 2, 4, 4, 369170968 );
  detectorId.SetTIBTOBEntry( 2, 4, 5, 369170972 );
  detectorId.SetTIBTOBEntry( 2, 5, 0, 369175164 );
  detectorId.SetTIBTOBEntry( 2, 5, 1, 369175160 );
  detectorId.SetTIBTOBEntry( 2, 5, 2, 369175156 );
  detectorId.SetTIBTOBEntry( 2, 5, 3, 369171060 );
  detectorId.SetTIBTOBEntry( 2, 5, 4, 369171064 );
  detectorId.SetTIBTOBEntry( 2, 5, 5, 369171068 );
  detectorId.SetTIBTOBEntry( 2, 6, 0, 369175292 );
  detectorId.SetTIBTOBEntry( 2, 6, 1, 369175288 );
  detectorId.SetTIBTOBEntry( 2, 6, 2, 369175284 );
  detectorId.SetTIBTOBEntry( 2, 6, 3, 369171188 );
  detectorId.SetTIBTOBEntry( 2, 6, 4, 369171192 );
  detectorId.SetTIBTOBEntry( 2, 6, 5, 369171196 );
  detectorId.SetTIBTOBEntry( 2, 7, 0, 369175372 );
  detectorId.SetTIBTOBEntry( 2, 7, 1, 369175368 );
  detectorId.SetTIBTOBEntry( 2, 7, 2, 369175364 );
  detectorId.SetTIBTOBEntry( 2, 7, 3, 369171268 );
  detectorId.SetTIBTOBEntry( 2, 7, 4, 369171272 );
  detectorId.SetTIBTOBEntry( 2, 7, 5, 369171276 );

  // TOB
  detectorId.SetTIBTOBEntry( 3, 0, 0, 436232314 );
  detectorId.SetTIBTOBEntry( 3, 0, 1, 436232306 );
  detectorId.SetTIBTOBEntry( 3, 0, 2, 436232298 );
  detectorId.SetTIBTOBEntry( 3, 0, 3, 436228198 );
  detectorId.SetTIBTOBEntry( 3, 0, 4, 436228206 );
  detectorId.SetTIBTOBEntry( 3, 0, 5, 436228214 );
  detectorId.SetTIBTOBEntry( 3, 1, 0, 436232506 );
  detectorId.SetTIBTOBEntry( 3, 1, 1, 436232498 );
  detectorId.SetTIBTOBEntry( 3, 1, 2, 436232490 );
  detectorId.SetTIBTOBEntry( 3, 1, 3, 436228390 );
  detectorId.SetTIBTOBEntry( 3, 1, 4, 436228398 );
  detectorId.SetTIBTOBEntry( 3, 1, 5, 436228406 );
  detectorId.SetTIBTOBEntry( 3, 2, 0, 436232634 );
  detectorId.SetTIBTOBEntry( 3, 2, 1, 436232626 );
  detectorId.SetTIBTOBEntry( 3, 2, 2, 436232618 );
  detectorId.SetTIBTOBEntry( 3, 2, 3, 436228518 );
  detectorId.SetTIBTOBEntry( 3, 2, 4, 436228526 );
  detectorId.SetTIBTOBEntry( 3, 2, 5, 436228534 );
  detectorId.SetTIBTOBEntry( 3, 3, 0, 436232826 );
  detectorId.SetTIBTOBEntry( 3, 3, 1, 436232818 );
  detectorId.SetTIBTOBEntry( 3, 3, 2, 436232810 );
  detectorId.SetTIBTOBEntry( 3, 3, 3, 436228710 );
  detectorId.SetTIBTOBEntry( 3, 3, 4, 436228718 );
  detectorId.SetTIBTOBEntry( 3, 3, 5, 436228726 );
  detectorId.SetTIBTOBEntry( 3, 4, 0, 436233018 );
  detectorId.SetTIBTOBEntry( 3, 4, 1, 436233010 );
  detectorId.SetTIBTOBEntry( 3, 4, 2, 436233002 );
  detectorId.SetTIBTOBEntry( 3, 4, 3, 436228902 );
  detectorId.SetTIBTOBEntry( 3, 4, 4, 436228910 );
  detectorId.SetTIBTOBEntry( 3, 4, 5, 436228918 );
  detectorId.SetTIBTOBEntry( 3, 5, 0, 436233146 );
  detectorId.SetTIBTOBEntry( 3, 5, 1, 436233138 );
  detectorId.SetTIBTOBEntry( 3, 5, 2, 436233130 );
  detectorId.SetTIBTOBEntry( 3, 5, 3, 436229030 );
  detectorId.SetTIBTOBEntry( 3, 5, 4, 436229038 );
  detectorId.SetTIBTOBEntry( 3, 5, 5, 436229046 );
  detectorId.SetTIBTOBEntry( 3, 6, 0, 436233338 );
  detectorId.SetTIBTOBEntry( 3, 6, 1, 436233330 );
  detectorId.SetTIBTOBEntry( 3, 6, 2, 436233322 );
  detectorId.SetTIBTOBEntry( 3, 6, 3, 436229222 );
  detectorId.SetTIBTOBEntry( 3, 6, 4, 436229230 );
  detectorId.SetTIBTOBEntry( 3, 6, 5, 436229238 );
  detectorId.SetTIBTOBEntry( 3, 7, 0, 436233466 );
  detectorId.SetTIBTOBEntry( 3, 7, 1, 436233458 );
  detectorId.SetTIBTOBEntry( 3, 7, 2, 436233450 );
  detectorId.SetTIBTOBEntry( 3, 7, 3, 436229350 );
  detectorId.SetTIBTOBEntry( 3, 7, 4, 436229358 );
  detectorId.SetTIBTOBEntry( 3, 7, 5, 436229366 );

  // TEC+ AT
  detectorId.SetTEC2TECEntry( 0, 0, 0, 470307208 );
  detectorId.SetTEC2TECEntry( 0, 0, 1, 470323592 );
  detectorId.SetTEC2TECEntry( 0, 0, 2, 470339976 );
  detectorId.SetTEC2TECEntry( 0, 0, 3, 470356360 );
  detectorId.SetTEC2TECEntry( 0, 0, 4, 470372744 );
  detectorId.SetTEC2TECEntry( 0, 1, 0, 470307468 );
  detectorId.SetTEC2TECEntry( 0, 1, 1, 470323852 );
  detectorId.SetTEC2TECEntry( 0, 1, 2, 470340236 );
  detectorId.SetTEC2TECEntry( 0, 1, 3, 470356620 );
  detectorId.SetTEC2TECEntry( 0, 1, 4, 470373004 );
  detectorId.SetTEC2TECEntry( 0, 2, 0, 470307716 );
  detectorId.SetTEC2TECEntry( 0, 2, 1, 470324100 );
  detectorId.SetTEC2TECEntry( 0, 2, 2, 470340484 );
  detectorId.SetTEC2TECEntry( 0, 2, 3, 470356868 );
  detectorId.SetTEC2TECEntry( 0, 2, 4, 470373252 );
  detectorId.SetTEC2TECEntry( 0, 3, 0, 470307976 );
  detectorId.SetTEC2TECEntry( 0, 3, 1, 470324360 );
  detectorId.SetTEC2TECEntry( 0, 3, 2, 470340744 );
  detectorId.SetTEC2TECEntry( 0, 3, 3, 470357128 );
  detectorId.SetTEC2TECEntry( 0, 3, 4, 470373512 );
  detectorId.SetTEC2TECEntry( 0, 4, 0, 470308236 );
  detectorId.SetTEC2TECEntry( 0, 4, 1, 470324620 );
  detectorId.SetTEC2TECEntry( 0, 4, 2, 470341004 );
  detectorId.SetTEC2TECEntry( 0, 4, 3, 470357388 );
  detectorId.SetTEC2TECEntry( 0, 4, 4, 470373772 );
  detectorId.SetTEC2TECEntry( 0, 5, 0, 470308488 );
  detectorId.SetTEC2TECEntry( 0, 5, 1, 470324872 );
  detectorId.SetTEC2TECEntry( 0, 5, 2, 470341256 );
  detectorId.SetTEC2TECEntry( 0, 5, 3, 470357640 );
  detectorId.SetTEC2TECEntry( 0, 5, 4, 470374024 );
  detectorId.SetTEC2TECEntry( 0, 6, 0, 470308748 );
  detectorId.SetTEC2TECEntry( 0, 6, 1, 470325132 );
  detectorId.SetTEC2TECEntry( 0, 6, 2, 470341516 );
  detectorId.SetTEC2TECEntry( 0, 6, 3, 470357900 );
  detectorId.SetTEC2TECEntry( 0, 6, 4, 470374284 );
  detectorId.SetTEC2TECEntry( 0, 7, 0, 470308996 );
  detectorId.SetTEC2TECEntry( 0, 7, 1, 470325380 );
  detectorId.SetTEC2TECEntry( 0, 7, 2, 470341764 );
  detectorId.SetTEC2TECEntry( 0, 7, 3, 470358148 );
  detectorId.SetTEC2TECEntry( 0, 7, 4, 470374532 );

  // TEC- AT
  detectorId.SetTEC2TECEntry( 1, 0, 0, 470045064 );
  detectorId.SetTEC2TECEntry( 1, 0, 1, 470061448 );
  detectorId.SetTEC2TECEntry( 1, 0, 2, 470077832 );
  detectorId.SetTEC2TECEntry( 1, 0, 3, 470094216 );
  detectorId.SetTEC2TECEntry( 1, 0, 4, 470110600 );
  detectorId.SetTEC2TECEntry( 1, 1, 0, 470045316 );
  detectorId.SetTEC2TECEntry( 1, 1, 1, 470061700 );
  detectorId.SetTEC2TECEntry( 1, 1, 2, 470078084 );
  detectorId.SetTEC2TECEntry( 1, 1, 3, 470094468 );
  detectorId.SetTEC2TECEntry( 1, 1, 4, 470110852 );
  detectorId.SetTEC2TECEntry( 1, 2, 0, 470045580 );
  detectorId.SetTEC2TECEntry( 1, 2, 1, 470061964 );
  detectorId.SetTEC2TECEntry( 1, 2, 2, 470078348 );
  detectorId.SetTEC2TECEntry( 1, 2, 3, 470094732 );
  detectorId.SetTEC2TECEntry( 1, 2, 4, 470111116 );
  detectorId.SetTEC2TECEntry( 1, 3, 0, 470045832 );
  detectorId.SetTEC2TECEntry( 1, 3, 1, 470062216 );
  detectorId.SetTEC2TECEntry( 1, 3, 2, 470078600 );
  detectorId.SetTEC2TECEntry( 1, 3, 3, 470094984 );
  detectorId.SetTEC2TECEntry( 1, 3, 4, 470111368 );
  detectorId.SetTEC2TECEntry( 1, 4, 0, 470046084 );
  detectorId.SetTEC2TECEntry( 1, 4, 1, 470062468 );
  detectorId.SetTEC2TECEntry( 1, 4, 2, 470078852 );
  detectorId.SetTEC2TECEntry( 1, 4, 3, 470095236 );
  detectorId.SetTEC2TECEntry( 1, 4, 4, 470111620 );
  detectorId.SetTEC2TECEntry( 1, 5, 0, 470046344 );
  detectorId.SetTEC2TECEntry( 1, 5, 1, 470062728 );
  detectorId.SetTEC2TECEntry( 1, 5, 2, 470079112 );
  detectorId.SetTEC2TECEntry( 1, 5, 3, 470095496 );
  detectorId.SetTEC2TECEntry( 1, 5, 4, 470111880 );
  detectorId.SetTEC2TECEntry( 1, 6, 0, 470046596 );
  detectorId.SetTEC2TECEntry( 1, 6, 1, 470062980 );
  detectorId.SetTEC2TECEntry( 1, 6, 2, 470079364 );
  detectorId.SetTEC2TECEntry( 1, 6, 3, 470095748 );
  detectorId.SetTEC2TECEntry( 1, 6, 4, 470112132 );
  detectorId.SetTEC2TECEntry( 1, 7, 0, 470046860 );
  detectorId.SetTEC2TECEntry( 1, 7, 1, 470063244 );
  detectorId.SetTEC2TECEntry( 1, 7, 2, 470079628 );
  detectorId.SetTEC2TECEntry( 1, 7, 3, 470096012 );
  detectorId.SetTEC2TECEntry( 1, 7, 4, 470112396 );

}
void LaserAlignment::fillPedestalProfiles ( edm::ESHandle< SiStripPedestals > &  pedestalsHandle) [private]

fill pedestals from dbase

This function fills the pedestal profiles (LASGlobalData<LASModuleProfiles> pedestalProfiles) from the ESHandle (from file or DB)

Argument: readily connected SiStripPedestals object (get() alredy called) The functionality inside the loops is basically taken from: CommonTools/SiStripZeroSuppression/src/SiStripPedestalsSubtractor.cc

Definition at line 1188 of file LaserAlignment.cc.

References detectorId, LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), moduleLoop, pedestalProfiles, pos, relativeConstraints::ring, LASModuleProfile::SetValue(), strip(), LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), and LASGlobalLoop::TIBTOBLoop().

Referenced by produce().

                                                                                          {

  int det, ring, beam, disk, pos;

  // loop TEC modules (yet without AT)
  det = 0; ring = 0; beam = 0; disk = 0;
  do { // loop using LASGlobalLoop functionality
    SiStripPedestals::Range pedRange = pedestalsHandle->getRange( detectorId.GetTECEntry( det, ring, beam, disk ) );
    for( int strip = 0; strip < 512; ++strip ) {
      int thePedestal = int( pedestalsHandle->getPed( strip, pedRange ) );
      if( thePedestal > 895 ) thePedestal -= 1024;
      pedestalProfiles.GetTECEntry( det, ring, beam, disk ).SetValue( strip, thePedestal );
    }
  } while ( moduleLoop.TECLoop( det, ring, beam, disk ) );


  // TIB & TOB section
  det = 2; beam = 0; pos = 0;
  do { // loop using LASGlobalLoop functionality
    SiStripPedestals::Range pedRange = pedestalsHandle->getRange( detectorId.GetTIBTOBEntry( det, beam, pos ) );
    for( int strip = 0; strip < 512; ++strip ) {
      int thePedestal = int( pedestalsHandle->getPed( strip, pedRange ) );
      if( thePedestal > 895 ) thePedestal -= 1024;
      pedestalProfiles.GetTIBTOBEntry( det, beam, pos ).SetValue( strip, thePedestal );
    }
  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );


  // TEC2TEC AT section
  det = 0; beam = 0; disk = 0;
  do { // loop using LASGlobalLoop functionality
    SiStripPedestals::Range pedRange = pedestalsHandle->getRange( detectorId.GetTEC2TECEntry( det, beam, disk ) );
    for( int strip = 0; strip < 512; ++strip ) {
      int thePedestal = int( pedestalsHandle->getPed( strip, pedRange ) );
      if( thePedestal > 895 ) thePedestal -= 1024;
      pedestalProfiles.GetTEC2TECEntry( det, beam, disk ).SetValue( strip, thePedestal );
    }
  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );

}
double LaserAlignment::getTEC2TECNominalBeamOffset ( unsigned int  det,
unsigned int  beam,
unsigned int  disk 
) [private]

returns the nominal beam position (strips) in TEC (AT) for the profileJudge

not all TEC-AT modules are hit in the center; this func returns the nominal beam offset locally on a module (in strips) for the ProfileJudge and the LASPeakFinder in strips. (offset = middle of module - nominal position)

the hard coded numbers will later be supplied by a special geometry class..

Definition at line 1333 of file LaserAlignment.cc.

References Exception.

Referenced by endRun().

                                                                                                           {

  if( det > 1 || beam > 7 || disk > 5 ) {
    throw cms::Exception( "[LaserAlignment::getTEC2TECNominalBeamOffset]" ) << " ERROR ** Called with nonexisting parameter set: det " << det << " beam " << beam << " disk " << disk << "." << std::endl;
  }

  const double nominalOffsets[8] = { 0., 2.220, -2.221, 0., 2.214, 0., 2.214, -2.217 };
  
  if( det == 0 ) return -1. * nominalOffsets[beam];
  else return nominalOffsets[beam];

}
double LaserAlignment::getTIBTOBNominalBeamOffset ( unsigned int  det,
unsigned int  beam,
unsigned int  pos 
) [private]

returns the nominal beam position (strips) in TOB for the profileJudge

not all TIB & TOB modules are hit in the center; this func returns the nominal beam offset locally on a module (in strips) for the ProfileJudge and the LASPeakFinder in strips. (offset = middle of module - nominal position)

the hard coded numbers will later be supplied by a special geometry class..

Definition at line 1298 of file LaserAlignment.cc.

References Exception.

Referenced by endRun(), and produce().

                                                                                                         {

  if( det < 2 || det > 3 || beam > 7 || pos > 5 ) {
    throw cms::Exception( "[LaserAlignment::getTIBTOBNominalBeamOffset]" ) << " ERROR ** Called with nonexisting parameter set: det " << det << " beam " << beam << " pos " << pos << "." << std::endl;
  }

  const double nominalOffsetsTIB[8] = { 0.00035, 2.10687, -2.10827, -0.00173446, 2.10072, -0.00135114, 2.10105, -2.10401 };

  // in tob, modules have alternating orientations along the rods.
  // this is described by the following pattern.
  // (even more confusing, this pattern is inversed for beams 0, 5, 6, 7)
  const int orientationPattern[6] = { -1, 1, 1, -1, -1, 1 };
  const double nominalOffsetsTOB[8] = { 0.00217408, 1.58678, 117.733, 119.321, 120.906, 119.328, 117.743, 1.58947 };


  if( det == 2 ) return( -1. * nominalOffsetsTIB[beam] );

  else {
    if( beam == 0 or beam > 4 ) return( nominalOffsetsTOB[beam] * orientationPattern[pos] );
    else return( -1. * nominalOffsetsTOB[beam] * orientationPattern[pos] );
  }

}
bool LaserAlignment::isATBeam ( void  ) [private]

count useable profiles in TIBTOB, operates on LASGlobalData<bool> LaserAlignment::isAcceptedProfile to allow for more elaborate patterns in the future

Definition at line 1269 of file LaserAlignment.cc.

References gather_cfg::cout, LASGlobalData< T >::GetTIBTOBEntry(), isAcceptedProfile, LogDebug, moduleLoop, pos, and LASGlobalLoop::TIBTOBLoop().

Referenced by produce().

                                    {

  int numberOfProfiles = 0;

  int det = 2; int beam = 0; int pos = 0; // search all TIB/TOB for signals
  do {
    if( isAcceptedProfile.GetTIBTOBEntry( det, beam, pos ) == 1 ) numberOfProfiles++;
  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );

  LogDebug( "[LaserAlignment::isATBeam]" ) << " Found: " << numberOfProfiles << "hits." << std::endl;
  std::cout << " [LaserAlignment::isATBeam] -- Found: " << numberOfProfiles << " hits." << std::endl; 

  if( numberOfProfiles > 10 ) return( true );
  return( false );
    
}
bool LaserAlignment::isTECBeam ( void  ) [private]

decide whether TEC or AT beams have fired

count useable profiles in TEC, operates on LASGlobalData<int> LaserAlignment::isAcceptedProfile to allow for more elaborate patterns in the future

Definition at line 1238 of file LaserAlignment.cc.

References gather_cfg::cout, LASGlobalData< T >::GetTECEntry(), isAcceptedProfile, LogDebug, and relativeConstraints::ring.

Referenced by produce().

                                     {
  
  int numberOfProfiles = 0;

  int ring = 1; // search all ring6 modules for signals
  for( int det = 0; det < 2; ++det ) {
    for( int beam = 0; beam < 8; ++ beam ) {
      for( int disk = 0; disk < 9; ++disk ) {
        if( isAcceptedProfile.GetTECEntry( det, ring, beam, disk ) == 1 ) numberOfProfiles++;
      }
    }
  }

  LogDebug( "[LaserAlignment::isTECBeam]" ) << " Found: " << numberOfProfiles << "hits." << std::endl;
  std::cout << " [LaserAlignment::isTECBeam] -- Found: " << numberOfProfiles << " hits." << std::endl; 

  if( numberOfProfiles > 10 ) return( true );
  return( false );
 
}
void LaserAlignment::produce ( edm::Event theEvent,
edm::EventSetup const &  theSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 264 of file LaserAlignment.cc.

References TrackerGeomBuilderFromGeometricDet::build(), collectedDataProfiles, gather_cfg::cout, currentDataProfiles, detectorId, edm::EventID::event(), fillDataProfiles(), fillPedestalProfiles(), spr::find(), firstEvent_, gD, edm::EventSetup::get(), edm::eventsetup::EventSetupRecord::get(), LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), getTIBTOBNominalBeamOffset(), edm::EventBase::id(), isAcceptedProfile, isATBeam(), LASProfileJudge::IsSignalIn(), isTECBeam(), judge, LASProfileJudge::JudgeProfile(), LogDebug, moduleLoop, numberOfAcceptedProfiles, pedestalProfiles, pos, relativeConstraints::ring, edm::EventID::run(), LASGlobalData< T >::SetTECEntry(), LASGlobalData< T >::SetTIBTOBEntry(), LASGlobalLoop::TEC2TECLoop(), tecDoubleHitDetId, LASGlobalLoop::TECLoop(), theAlignableTracker, theDoPedestalSubtraction, theEvents, theGlobalPositionRcd, theParameterSet, theProfileNames, theTrackerGeometry, LASGlobalLoop::TIBTOBLoop(), and updateFromInputGeometry.

                                                                               {

  if (firstEvent_) {

    // access the tracker
    theSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
    theSetup.get<IdealGeometryRecord>().get( gD );
    
    // access pedestals (from db..) if desired
    edm::ESHandle<SiStripPedestals> pedestalsHandle;
    if( theDoPedestalSubtraction ) {
      theSetup.get<SiStripPedestalsRcd>().get( pedestalsHandle );
      fillPedestalProfiles( pedestalsHandle );
    }
    
    // global positions
    //  edm::ESHandle<Alignments> theGlobalPositionRcd;
    theSetup.get<TrackerDigiGeometryRecord>().getRecord<GlobalPositionRcd>().get( theGlobalPositionRcd );

    // select the reference geometry
    if( !updateFromInputGeometry ) {
      // the AlignableTracker object is initialized with the ideal geometry
      edm::ESHandle<GeometricDet> theGeometricDet;
      theSetup.get<IdealGeometryRecord>().get(theGeometricDet);
      TrackerGeomBuilderFromGeometricDet trackerBuilder;
      TrackerGeometry* theRefTracker = trackerBuilder.build(&*theGeometricDet, theParameterSet);
      
      theAlignableTracker = new AlignableTracker(&(*theRefTracker));
    }
    else {
      // the AlignableTracker object is initialized with the input geometry from DB
      theAlignableTracker = new AlignableTracker( &(*theTrackerGeometry) );
    }
    
    firstEvent_ = false;
  }

  LogDebug("LaserAlignment") << "==========================================================="
                              << "\n   Private analysis of event #"<< theEvent.id().event() 
                              << " in run #" << theEvent.id().run();


  // do the Tracker Statistics to retrieve the current profiles
  fillDataProfiles( theEvent, theSetup );

  // index variables for the LASGlobalLoop object
  int det, ring, beam, disk, pos;

  //
  // first pre-loop on selected entries to find out
  // whether the TEC or the AT beams have fired
  // (pedestal profiles are left empty if false in cfg)
  // 


  // TEC+- (only ring 6)
  ring = 1;
  for( det = 0; det < 2; ++det ) {
    for( beam = 0; beam < 8; ++ beam ) {
      for( disk = 0; disk < 9; ++disk ) {
        if( judge.IsSignalIn( currentDataProfiles.GetTECEntry( det, ring, beam, disk ) - pedestalProfiles.GetTECEntry( det, ring, beam, disk ), 0 ) ) {
          isAcceptedProfile.SetTECEntry( det, ring, beam, disk, 1 );
        }
        else { // assume no initialization
          isAcceptedProfile.SetTECEntry( det, ring, beam, disk, 0 );
        }
      }
    }
  }

  // TIBTOB
  det = 2; beam = 0; pos = 0;
  do {
    // add current event's data and subtract pedestals
    if( judge.IsSignalIn( currentDataProfiles.GetTIBTOBEntry( det, beam, pos ) - pedestalProfiles.GetTIBTOBEntry( det, beam, pos ), getTIBTOBNominalBeamOffset( det, beam, pos ) ) ) {
      isAcceptedProfile.SetTIBTOBEntry( det, beam, pos, 1 );
    }
    else { // dto.
      isAcceptedProfile.SetTIBTOBEntry( det, beam, pos, 0 );
    }

  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );




  // now come the beam finders
  bool isTECMode = isTECBeam();
  //  LogDebug( " [LaserAlignment::produce]" ) << "LaserAlignment::isTECBeam declares this event " << ( isTECMode ? "" : "NOT " ) << "a TEC event." << std::endl;
  std::cout << " [LaserAlignment::produce] -- LaserAlignment::isTECBeam declares this event " << ( isTECMode ? "" : "NOT " ) << "a TEC event." << std::endl;

  bool isATMode  = isATBeam();
  //  LogDebug( " [LaserAlignment::produce]" ) << "LaserAlignment::isATBeam declares this event "  << ( isATMode ? "" : "NOT " )  << "an AT event." << std::endl;
  std::cout << " [LaserAlignment::produce] -- LaserAlignment::isATBeam declares this event "  << ( isATMode ? "" : "NOT " )  << "an AT event." << std::endl;




  //
  // now pass the pedestal subtracted profiles to the judge
  // if they're accepted, add them on the collectedDataProfiles
  // (pedestal profiles are left empty if false in cfg)
  //


  // loop TEC+- modules
  det = 0; ring = 0; beam = 0; disk = 0;
  do {
    
    LogDebug( "[LaserAlignment::produce]" ) << "Profile is: " << theProfileNames.GetTECEntry( det, ring, beam, disk ) << "." << std::endl;

    // this now depends on the AT/TEC mode, is this a doubly hit module? -> look for it in vector<int> tecDoubleHitDetId
    // (ring == 0 not necessary but makes it a little faster)
    if( ring == 0 && find( tecDoubleHitDetId.begin(), tecDoubleHitDetId.end(), detectorId.GetTECEntry( det, ring, beam, disk ) ) != tecDoubleHitDetId.end() ) {

      if( isTECMode ) { // add profile to TEC collection
        // add current event's data and subtract pedestals
        if( judge.JudgeProfile( currentDataProfiles.GetTECEntry( det, ring, beam, disk ) - pedestalProfiles.GetTECEntry( det, ring, beam, disk ), 0 ) ) {
          collectedDataProfiles.GetTECEntry( det, ring, beam, disk ) += currentDataProfiles.GetTECEntry( det, ring, beam, disk ) - pedestalProfiles.GetTECEntry( det, ring, beam, disk );
          numberOfAcceptedProfiles.GetTECEntry( det, ring, beam, disk )++;
        }
      }
    }

    else { // not a doubly hit module, don't care about the mode
      // add current event's data and subtract pedestals
      if( judge.JudgeProfile( currentDataProfiles.GetTECEntry( det, ring, beam, disk ) - pedestalProfiles.GetTECEntry( det, ring, beam, disk ), 0 ) ) {
        collectedDataProfiles.GetTECEntry( det, ring, beam, disk ) += currentDataProfiles.GetTECEntry( det, ring, beam, disk ) - pedestalProfiles.GetTECEntry( det, ring, beam, disk );
        numberOfAcceptedProfiles.GetTECEntry( det, ring, beam, disk )++;
      }
    }
    
  } while( moduleLoop.TECLoop( det, ring, beam, disk ) );


  


  // loop TIB/TOB modules
  det = 2; beam = 0; pos = 0;
  do {
    
    LogDebug( "[LaserAlignment::produce]" ) << "Profile is: " << theProfileNames.GetTIBTOBEntry( det, beam, pos ) << "." << std::endl;
    
    // add current event's data and subtract pedestals
    if( judge.JudgeProfile( currentDataProfiles.GetTIBTOBEntry( det, beam, pos ) - pedestalProfiles.GetTIBTOBEntry( det, beam, pos ), getTIBTOBNominalBeamOffset( det, beam, pos ) ) ) {
      collectedDataProfiles.GetTIBTOBEntry( det, beam, pos ) += currentDataProfiles.GetTIBTOBEntry( det, beam, pos ) - pedestalProfiles.GetTIBTOBEntry( det, beam, pos );
      numberOfAcceptedProfiles.GetTIBTOBEntry( det, beam, pos )++;
    }

  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );
  


  // loop TEC2TEC modules
  det = 0; beam = 0; disk = 0;
  do {
    
    LogDebug( "[LaserAlignment::produce]" ) << "Profile is: " << theProfileNames.GetTEC2TECEntry( det, beam, disk ) << "." << std::endl;

    // this again depends on the AT/TEC mode, is this a doubly hit module?
    // (ring == 0 not necessary but makes it a little faster)
    if( ring == 0 && find( tecDoubleHitDetId.begin(), tecDoubleHitDetId.end(), detectorId.GetTECEntry( det, ring, beam, disk ) ) != tecDoubleHitDetId.end() ) {

      if( isATMode ) { // add profile to TEC2TEC collection
        // add current event's data and subtract pedestals
        if( judge.JudgeProfile( currentDataProfiles.GetTEC2TECEntry( det, beam, disk ) - pedestalProfiles.GetTEC2TECEntry( det, beam, disk ), 0 ) ) {
          collectedDataProfiles.GetTEC2TECEntry( det, beam, disk ) += currentDataProfiles.GetTEC2TECEntry( det, beam, disk ) - pedestalProfiles.GetTEC2TECEntry( det, beam, disk );
          numberOfAcceptedProfiles.GetTEC2TECEntry( det, beam, disk )++;
        }
      }

    }     
    
    else { // not a doubly hit module, don't care about the mode
      // add current event's data and subtract pedestals
      if( judge.JudgeProfile( currentDataProfiles.GetTEC2TECEntry( det, beam, disk ) - pedestalProfiles.GetTEC2TECEntry( det, beam, disk ), 0 ) ) {
        collectedDataProfiles.GetTEC2TECEntry( det, beam, disk ) += currentDataProfiles.GetTEC2TECEntry( det, beam, disk ) - pedestalProfiles.GetTEC2TECEntry( det, beam, disk );
        numberOfAcceptedProfiles.GetTEC2TECEntry( det, beam, disk )++;
      }
    }
      

  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );



  // total event number counter
  theEvents++;

}
void LaserAlignment::testRoutine ( void  )

for debugging & testing only, will disappear..

this function is for debugging and testing only and will disappear..

Definition at line 1707 of file LaserAlignment.cc.

References gather_cfg::cout, detectorId, LASGlobalData< T >::GetTEC2TECEntry(), LASGlobalData< T >::GetTECEntry(), LASGlobalData< T >::GetTIBTOBEntry(), TrackerGeometry::idToDet(), moduleLoop, pos, CosmicsPD_Skims::radius, relativeConstraints::ring, LASGlobalLoop::TEC2TECLoop(), LASGlobalLoop::TECLoop(), theTrackerGeometry, theZ, and LASGlobalLoop::TIBTOBLoop().

                                       {


  // tracker geom. object for calculating the global beam positions
  const TrackerGeometry& theTracker( *theTrackerGeometry );

  const double atPhiPositions[8] = { 0.392699, 1.289799, 1.851794, 2.748894, 3.645995, 4.319690, 5.216791, 5.778784 };
  const double tecPhiPositions[8] = { 0.392699, 1.178097, 1.963495, 2.748894, 3.534292, 4.319690, 5.105088, 5.890486 };
  const double zPositions[9] = { 125.0, 139.0, 153.0, 167.0, 181.0, 198.5, 217.5, 238.0, 259.5 };
  const double zPositionsTIB[6] = { 62.0, 38.0, 18.0, -10.0, -34.0, -54.0 };
  const double zPositionsTOB[6] = { 104.0, 58.0, 22.0, -14.0, -50.0, -86.0 };

  int det, beam, disk, pos, ring;
  
  // loop TEC+- internal
  det = 0; ring = 0; beam = 0; disk = 0;
  do {

    const double radius = ring?84.0:56.4;

    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTECEntry( det, ring, beam, disk ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
    
    if (theStripDet) {
      const GlobalPoint gp( GlobalPoint::Cylindrical( radius, tecPhiPositions[beam], zPositions[disk] ) );
      
      const LocalPoint lp( theStripDet->surface().toLocal( gp ) );
      std::cout << "__TEC: " << 256. - theStripDet->specificTopology().strip( lp ) << std::endl; 
    }

  } while( moduleLoop.TECLoop( det, ring, beam, disk ) );


  // loop TIBTOB
  det = 2; beam = 0; pos = 0;
  do {

    const double radius = (det==2?51.4:58.4); 
    const double theZ = (det==2?zPositionsTIB[pos]:zPositionsTOB[pos]);

    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTIBTOBEntry( det, beam, pos ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
    
    if (theStripDet) {
      const GlobalPoint gp( GlobalPoint::Cylindrical( radius, atPhiPositions[beam], theZ ) );
      
      const LocalPoint lp( theStripDet->surface().toLocal( gp ) );
      std::cout << "__TIBTOB det " << det << " beam " << beam << " pos " << pos << "  " << 256. - theStripDet->specificTopology().strip( lp );
      std::cout << "           " << theStripDet->position().perp()<< std::endl; 
    }

  } while( moduleLoop.TIBTOBLoop( det, beam, pos ) );

  
  // loop TEC2TEC
  det = 0; beam = 0; disk = 0;
  do {

    const double radius = 56.4;

    // access the tracker geometry for this module
    const DetId theDetId( detectorId.GetTEC2TECEntry( det, beam, disk ) );
    const StripGeomDetUnit* const theStripDet = dynamic_cast<const StripGeomDetUnit*>( theTracker.idToDet( theDetId ) );
    
    if (theStripDet) {
      const GlobalPoint gp( GlobalPoint::Cylindrical( radius, atPhiPositions[beam], zPositions[disk] ) );
      
      const LocalPoint lp( theStripDet->surface().toLocal( gp ) );
      std::cout << "__TEC2TEC det " << det << " beam " << beam << " disk " << disk << "  " << 256. - theStripDet->specificTopology().strip( lp ) << std::endl; 
    }

  } while( moduleLoop.TEC2TECLoop( det, beam, disk ) );


}

Member Data Documentation

Definition at line 210 of file LaserAlignment.h.

Referenced by beginJob(), endRun(), and produce().

data profiles for the current event

Definition at line 207 of file LaserAlignment.h.

Referenced by beginJob(), fillDataProfiles(), and produce().

LASGlobalData<unsigned int> LaserAlignment::detectorId [private]

config switch

Definition at line 157 of file LaserAlignment.h.

Referenced by LaserAlignment().

Definition at line 247 of file LaserAlignment.h.

Referenced by beginJob(), and produce().

tracker geometry;

Definition at line 238 of file LaserAlignment.h.

Referenced by produce().

Definition at line 220 of file LaserAlignment.h.

Referenced by beginJob(), isATBeam(), isTECBeam(), and produce().

Definition at line 192 of file LaserAlignment.h.

Referenced by LaserAlignment(), and produce().

config parameters for the LASProfileJudge

Definition at line 160 of file LaserAlignment.h.

Referenced by LaserAlignment().

config switch

Definition at line 166 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

Definition at line 227 of file LaserAlignment.h.

Referenced by CalculateNominalCoordinates(), and endRun().

Definition at line 216 of file LaserAlignment.h.

Referenced by beginJob(), endRun(), and produce().

config parameter

Definition at line 154 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

Definition at line 204 of file LaserAlignment.h.

Referenced by beginJob(), fillPedestalProfiles(), and produce().

TDirectory* LaserAlignment::singleModulesDir [private]

Definition at line 235 of file LaserAlignment.h.

Referenced by beginJob().

Definition at line 224 of file LaserAlignment.h.

Referenced by beginJob(), and endRun().

std::vector<unsigned int> LaserAlignment::tecDoubleHitDetId [private]

Definition at line 201 of file LaserAlignment.h.

Referenced by fillDetectorId(), and produce().

Definition at line 243 of file LaserAlignment.h.

Referenced by endRun(), produce(), and ~LaserAlignment().

std::string LaserAlignment::theAlignRecordName [private]

Definition at line 245 of file LaserAlignment.h.

Referenced by endRun().

config switch

Definition at line 151 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

config parameter (histograms file compression level)

Definition at line 178 of file LaserAlignment.h.

Referenced by beginJob(), and LaserAlignment().

Definition at line 172 of file LaserAlignment.h.

Referenced by fillDataProfiles().

config switch

Definition at line 145 of file LaserAlignment.h.

Referenced by LaserAlignment(), and produce().

std::string LaserAlignment::theErrorRecordName [private]

Definition at line 245 of file LaserAlignment.h.

Referenced by endRun().

counter for the total number of events processed

Definition at line 142 of file LaserAlignment.h.

Referenced by endRun(), and produce().

TFile* LaserAlignment::theFile [private]

Tree stuff.

Definition at line 234 of file LaserAlignment.h.

Referenced by beginJob(), and ~LaserAlignment().

std::string LaserAlignment::theFileName [private]

config parameter (histograms file output name)

Definition at line 181 of file LaserAlignment.h.

Referenced by beginJob(), and LaserAlignment().

Definition at line 240 of file LaserAlignment.h.

Referenced by produce().

Definition at line 195 of file LaserAlignment.h.

Referenced by endRun().

std::vector<unsigned int> LaserAlignment::theMaskAtModules [private]

Definition at line 185 of file LaserAlignment.h.

Referenced by ApplyATMaskingCorrections(), endRun(), and LaserAlignment().

std::vector<unsigned int> LaserAlignment::theMaskTecModules [private]

config parameters

Definition at line 184 of file LaserAlignment.h.

Referenced by ApplyEndcapMaskingCorrections(), endRun(), and LaserAlignment().

Definition at line 249 of file LaserAlignment.h.

Referenced by produce().

Definition at line 213 of file LaserAlignment.h.

Referenced by beginJob(), and produce().

config switch

Definition at line 175 of file LaserAlignment.h.

Referenced by beginJob(), LaserAlignment(), and ~LaserAlignment().

config switch

Definition at line 188 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

config switch

Definition at line 169 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

Definition at line 239 of file LaserAlignment.h.

Referenced by endRun(), produce(), and testRoutine().

config switch

Definition at line 148 of file LaserAlignment.h.

Referenced by endRun(), and LaserAlignment().

config switch

Definition at line 163 of file LaserAlignment.h.

Referenced by endRun(), LaserAlignment(), and produce().