Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
# **CMS Object-oriented Code for Optical Alignment**


## General COCOA documentation

General documentation is at [1].   
COCOA website is at [2].   
Notably, a user guide can be found at [3].   

[1] https://cds.cern.ch/record/1047121/files/p193.pdf   
[2] http://cmsdoc.cern.ch/cms/MUON/alignment/software/COCOA/doc/cocoa.html   
[3] http://cmsdoc.cern.ch/cms/MUON/alignment/software/COCOA/doc/tex/users_guide.ps



## Run COCOA
This shows how to:
- Run the COCOA simulation of an optical alignment system (described in .txt or XML format, with adjustments from DB description);
- Run the least-squared fit on the alignment system;
- Store results back into DB.

### Input XML file
An XML file describing the optical alignment system of interest needs to be provided as input to COCOA.      
   
Such an XML file can be generated from a .txt description, by an independent cocoa application in `Alignment/CocoaApplication/bin`.    
For example, one can generate an XML optical alignment system description, by simply doing the following:

    cd Alignment/CocoaApplication/bin
    cocoa simple2D.txt

### Input DB OpticalAlignmentsRcd
For testing purposes, an example input DB `OpticalAlignmentsRcd` can now be found at `Alignment/CocoaApplication/test/OpticalAlignments.db`.    
It was generated by adding the following, in `CocoaAnalyzer::analyze`, after `readXMLFile` returns:

    Model& model = Model::getInstance();
    model.BuildSystemDescriptionFromOA(oaList_);
    CocoaDBMgr::getInstance()->DumpCocoaResults();
Of course, in practice, one would actually just need to call the OpticalAlignmentsRcd of interest to the desired alignment study.

### Run COCOA
One can now just do:    

    cd Alignment/CocoaApplication/test
    cmsRun cocoaAnalyzer_cfg.py
This will perform the least-squared fit, and store all results in `Alignment/CocoaApplication/test/OpticalAlignments.db`.      
The `OpticalAlignmentsRcd` obtained after fit, is stored with `OpticalAlignmentsRcdOutput` tag.      
It should also be possible to use the feature of dumping the results into ROOT format.