CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

L1GtVhdlWriterCore Class Reference

#include <L1GtVhdlWriterCore.h>

Inheritance diagram for L1GtVhdlWriterCore:
L1GtVhdlDefinitions

List of all members.

Public Member Functions

void addJetCountsToCond2IntMap (const int chip, const std::vector< ConditionMap > &conditionMap, std::map< std::string, int > &conditionToIntegerMap)
void buildCommonHeader (std::map< std::string, std::string > &headerParameters, const std::vector< std::string > &connectedChannels)
 builds the common header for all files
std::string buildDefValString (const int &conditionIndex, const std::vector< int > &values)
bool buildDefValuesBuffer (L1GtVhdlTemplateFile &buffer, const std::map< L1GtConditionType, std::string > &typeList, const std::vector< std::string > &defValuesList, const L1GtObject &object)
std::string chip2OutputSubDir (const int &chip)
void countCondsAndAdd2NumberVec (const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap, const int &condChip)
bool findObjectType (const L1GtObject &object, ConditionMap &map)
bool getCaloSetupContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, std::string > &caloParameters, const L1GtObject &caloObject)
L1GtConditionCategory getCategoryFromObject (const L1GtObject &object)
 gets condition category from object
std::map< std::string, int > getCond2IntMap ()
bool getCondChipVhdContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, L1GtVhdlTemplateFile > &templates, std::map< std::string, std::string > &commonParams)
std::string getDefValsFromTriggerMenu (const L1GtConditionType &type, const L1GtObject &object, const VmeRegister &reg)
bool getEsumsSetupContentFromTriggerMenu (const unsigned short int &condChip, const L1GtObject &object, std::string &energySumParameter)
 contains only one subsitution parameter which is stored in reference energySumParameter
bool getIntVal (const std::map< std::string, int > &map, const std::string &searchValue, int &intVal)
 checks weather value searchValue exists in a <string,int> map, saves it in &intVal if it exists and returns false if not
std::vector< std::string > getMsgBuf ()
 returns intern message buffer
void getMuonSetupContentFromTriggerMenu (const unsigned short int &condChip, std::map< std::string, std::string > &muonParameters)
bool getSubstParamCommonFromTriggerMenu (const unsigned short int &condChip, L1GtVhdlTemplateFile &particle, const L1GtObject &object, const L1GtConditionCategory &category, std::string &parameterStr)
 builds the parameters particle_common for the cond_chip.vhd's
std::string gtTemplatesPath ()
 returns the templates path
std::string index4CondChipVhd (int intval)
void initializeDeltaConditions ()
 L1GtVhdlWriterCore (const std::string &templatesDirectory, const std::string &outputDirectory, const bool &debug)
 constructor
bool makeFirmware (const std::vector< ConditionMap > &conditionMap, const AlgorithmMap &algorithmMap)
 produces the firmware code
void msg (const std::string &message)
 adds a string to intern message buffer
L1GtVhdlTemplateFile openVhdlFileWithCommonHeader (const std::string &filename, const std::string &outputFilename)
 opens a new template file and inserts the common header
void printCommonHeader ()
 prints the common header
void printConditionsOfCategory (const L1GtConditionCategory &category, const ConditionMap &map)
 for debuggin
bool processAlgorithmMap (std::vector< std::map< int, std::string > > &algoStrings)
std::string retNumberOfConditionsString (const std::string &typeStr, const int &number)
L1GtVhdlTemplateFile retrunCommonHeader ()
 returns the common header
bool returnConditionsOfOneClass (const L1GtConditionType &type, const L1GtConditionCategory &category, const L1GtObject &object, const ConditionMap &map, ConditionMap &outputMap)
std::string sp (const std::string &name)
 converts string name to substiution parameter synthax; name -->
void writeAlgoSetup (std::vector< std::map< int, std::string > > &algoStrings)
 builds the prealgo_and_or setup
void writeCond2intMap2File ()
 produces a control output file for condition to integer conversion
void writeCondChipPkg (const int &chip)
void writeConditionChipSetup (std::map< std::string, L1GtVhdlTemplateFile > templates, const std::map< std::string, std::string > &common, const unsigned short int &chip)
 builds cond_chip.vhds
void writeDefValPkg (const std::vector< ConditionMap > &conditionMap, const int &chip)
 writes def_val_pkg.vhd
void writeEtmSetup (std::string &etmString, const int &condChip)
 builds etm setup files
void writeMuonSetupVhdl (std::map< std::string, std::string > &muonParameters, const std::string &particle, unsigned short int &condChip)
 builds muon setup files
void writeQsfSetupFiles (const std::string &version)
 builds the two quartus setup files. This routine is called in buildCommonHeader!
 ~L1GtVhdlWriterCore ()
 destructor

Static Public Member Functions

static std::string int2str (const int &integerValue)
 converts a integer into a string

Private Attributes

const AlgorithmMapalgorithmMap_
 algorithm map
L1GtVhdlWriterBitManager bm_
 bit manager for bit operations
std::vector< L1GtObjectcaloObjects_
 list of all possible calo objects
std::map< L1GtObject, std::string > caloType2Int_
 converts L1GtObject to calo_nr
L1GtVhdlTemplateFile commonHeader_
 common header for all files
const std::vector< ConditionMap > * conditionMap_
 condition map
std::map< std::string, int > conditionToIntegerMap_
 stores to condition name to integer conversion table
std::map< L1GtConditionType,
std::string > 
condType2Str_
 converts L1GtConditionType to firmware string
bool debugMode_
 class will produce some additional debugging output if set
std::vector< L1GtObjectesumObjects_
 list of all possible esums objects
std::vector< std::string > internMessageBuf_
std::vector< std::vector
< std::string > > 
numberOfConditions_
 vector containing the initialization of all conditions
std::map< L1GtObject, std::string > objType2Str_
 converts L1GtObject to string
std::string outputDir_
 output directory
std::string version_
std::string vhdlDir_
 templates directory

Detailed Description

writes the actual VHDL code and stores global information like the common header. This class is using parameter maps containing the substitution parameters and their content.

Implementation: <TODO: enter implementation details>

Author:
Philipp Wagner

$Date$ $Revision$

Description: a class to deal with VHDL template files

Implementation: <TODO: enter implementation details>

Author:
: Philipp Wagner

$Date$ $Revision$

Definition at line 44 of file L1GtVhdlWriterCore.h.


Constructor & Destructor Documentation

L1GtVhdlWriterCore::L1GtVhdlWriterCore ( const std::string &  templatesDirectory,
const std::string &  outputDirectory,
const bool &  debug 
)

constructor

Definition at line 51 of file L1GtVhdlWriterCore.cc.

References caloObjects_, caloType2Int_, CenJet, condType2Str_, debug, debugMode_, esumObjects_, ETM, ETT, ForJet, L1GtVhdlDefinitions::getCalo2IntMap(), L1GtVhdlDefinitions::getCond2StrMap(), L1GtVhdlDefinitions::getObj2StrMap(), HTT, IsoEG, NoIsoEG, numberOfConditions_, objType2Str_, outputDir_, TauJet, groupFilesInBlocks::temp, and vhdlDir_.

{

    // set templates directory
    vhdlDir_=templatesDirectory;

    // set output directory
    outputDir_=outputDirectory;

    // Get maps
    L1GtVhdlDefinitions maps;

    objType2Str_=maps.getObj2StrMap();
    caloType2Int_=maps.getCalo2IntMap();
    condType2Str_=maps.getCond2StrMap();

    // fill calo object vector
    caloObjects_.push_back(IsoEG);
    caloObjects_.push_back(NoIsoEG);
    caloObjects_.push_back(CenJet);
    caloObjects_.push_back(ForJet);
    caloObjects_.push_back(TauJet);

    esumObjects_.push_back(HTT);
    esumObjects_.push_back(ETT);
    esumObjects_.push_back(ETM);

    // prepare number of condition vector with two empty string vectors for the two condition chips
    std::vector<std::string> temp;
    numberOfConditions_.push_back(temp);
    numberOfConditions_.push_back(temp);

    // set debug mode
    debugMode_= debug;

}
L1GtVhdlWriterCore::~L1GtVhdlWriterCore ( )

destructor

Definition at line 90 of file L1GtVhdlWriterCore.cc.

{
    // empty
}

Member Function Documentation

void L1GtVhdlWriterCore::addJetCountsToCond2IntMap ( const int  chip,
const std::vector< ConditionMap > &  conditionMap,
std::map< std::string, int > &  conditionToIntegerMap 
)

calculates the integer value for jet counts conditions and furthermore counts how many jet counts of one type are in trigger menu

Definition at line 1383 of file L1GtVhdlWriterCore.cc.

References CondJetCounts, i, int2str(), JetCounts, numberOfConditions_, L1GtJetCountsTemplate::objectParameter(), retNumberOfConditionsString(), returnConditionsOfOneClass(), and TypeJetCounts.

Referenced by makeFirmware().

{
    ConditionMap jetConditions;

    returnConditionsOfOneClass(TypeJetCounts, CondJetCounts, JetCounts,
            conditionMap.at(chip-1), jetConditions);
    /*
     int counter = 0;

     for (ConditionMap::const_iterator iterCond =  jetConditions.begin(); iterCond !=  jetConditions.end(); iterCond++)
     {
     conditionToIntegerMap_[iterCond->first]=counter;
     counter++;
     msg(iterCond->first);
     }

     */
    
    unsigned int maxJetsCountsIndex = 11;
    
    for (unsigned int i= 0; i<=maxJetsCountsIndex; i++)
    {
        int counter = 0;

        for (ConditionMap::const_iterator iterCond = jetConditions.begin(); iterCond
                != jetConditions.end(); iterCond++)
        {

            L1GtJetCountsTemplate* jetsTemplate =
                    static_cast<L1GtJetCountsTemplate*>(iterCond->second);
            const std::vector<L1GtJetCountsTemplate::ObjectParameter>* op =
                    jetsTemplate->objectParameter();

            conditionToIntegerMap_[iterCond->first]=counter;
            if ((*op)[0].countIndex==i)
                counter++;

            //msg(int2str((*op)[0].countIndex));

        }

        numberOfConditions_.at(chip-1).push_back(retNumberOfConditionsString("jet_cnts_"
                +int2str(i)+"_cond", counter));

    }

}
void L1GtVhdlWriterCore::buildCommonHeader ( std::map< std::string, std::string > &  headerParameters,
const std::vector< std::string > &  connectedChannels 
)

builds the common header for all files

Definition at line 1045 of file L1GtVhdlWriterCore.cc.

References commonHeader_, L1GtVhdlTemplateFile::insert(), msg(), L1GtVhdlTemplateFile::open(), L1GtVhdlTemplateFile::substitute(), version_, and vhdlDir_.

Referenced by L1GtVhdlWriter::analyze().

{
    commonHeader_.open(vhdlDir_+"InternalTemplates/header");

    std::map<std::string,std::string>::iterator iter = headerParameters.begin();

    // loop over the header parameter map and replace all subsitution
    // parameters with their values
    while (iter != headerParameters.end() )
    {
        commonHeader_.substitute((*iter).first, (*iter).second);
        iter++;
    }

    commonHeader_.insert("$(connected_channels_1)", connectedChannels);
    commonHeader_.insert("$(connected_channels_2)", connectedChannels);

    //---------------------build the Quartus configuration files----------------------------------------

    //writeQsfSetupFiles(headerParameters["version"]);
    
    version_=headerParameters["version"];

    msg("Build Common header and Quartus setup files sucessuflly!");

}
std::string L1GtVhdlWriterCore::buildDefValString ( const int &  conditionIndex,
const std::vector< int > &  values 
)

builds the string representing a condition in def_val_pkg.vhd. Parameters are condition index and a vector containig default values.

Definition at line 1480 of file L1GtVhdlWriterCore.cc.

{
    // has to produce something like 1 =>  ("00000000", "00000000")

    return "1 =>  (\"00000000\", \"00000000\")";
}
bool L1GtVhdlWriterCore::buildDefValuesBuffer ( L1GtVhdlTemplateFile buffer,
const std::map< L1GtConditionType, std::string > &  typeList,
const std::vector< std::string > &  defValuesList,
const L1GtObject object 
)

helper, used by writeDefValPkg. Builds default values buffer for each object type. this buffer finally is inserte in the def_val_pkg.vhd template file

Definition at line 1667 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), condType2Str_, ws_sso_content_reader::content, ETM, ETT, L1GtVhdlTemplateFile::findAndReplaceString(), getDefValsFromTriggerMenu(), L1GtVhdlTemplateFile::getInternalParameter(), HTT, i, JetCounts, Mu, objType2Str_, L1GtVhdlTemplateFile::open(), L1GtVhdlDefinitions::RegEtThreshold, sp(), L1GtVhdlDefinitions::stringConstantCalo_, L1GtVhdlDefinitions::stringConstantDefValId_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamCaloOrMuon_, L1GtVhdlDefinitions::substParamContent_, L1GtVhdlDefinitions::substParamDefValId_, L1GtVhdlDefinitions::substParamDefValType_, L1GtVhdlDefinitions::substParamMaxNr_, L1GtVhdlDefinitions::substParamOthers_, L1GtVhdlDefinitions::substParamParticle_, L1GtVhdlDefinitions::substParamType_, and vhdlDir_.

Referenced by writeDefValPkg().

{
    // type iterator
    std::map<L1GtConditionType,std::string>::const_iterator typeIter;

    for (typeIter=typeList.begin(); typeIter!=typeList.end(); typeIter++)
    {

        for (unsigned int i = 0; i<defValuesList.size(); i++)
        {

            // open a new internale template
            L1GtVhdlTemplateFile internalTemplate;
            internalTemplate.open(vhdlDir_+"InternalTemplates/defvalpkg", true);

            std::string
                    idString =
                            internalTemplate.getInternalParameter(stringConstantDefValId_);

            // The following three steps convert "$(particle)_$(type)_$(defvaltype)_def_val"
            // to e.g. "muon_1s_et_def_val"

            // replace the substiution parameter particle with muon - thereby parameterString is a
            // reference and therefore changed.
            L1GtVhdlTemplateFile::findAndReplaceString(idString,
                    sp(substParamParticle_), objType2Str_[object]);

            // replace the substiution parameter particle with muon
            L1GtVhdlTemplateFile::findAndReplaceString(idString,
                    sp(substParamType_), typeIter->second);

            // replace the substiution parameter defvaltype with muon
            L1GtVhdlTemplateFile::findAndReplaceString(idString,
                    sp(substParamDefValType_), defValuesList.at(i));

            // usage of the subsitute routine:
            // first the substitution parameter, then the content
            internalTemplate.substitute(substParamDefValId_, idString);

            // !here the body of the internale template is build - almost done!

            // The body looks as follows $(def_val), $(max_nr), $(content) and
            // $(others) have to be subsituted 

            /*
             * CONSTANT $(def_val) : $(calo_or_muon)_maxnr$(max_nr)vector8_arr := 
             * (
             * $(content)
             * $(others)
             * );
             */

            // substitute the particle
            internalTemplate.substitute(substParamParticle_,
                    objType2Str_[object]);

            // go on with max number - get the correct expression for max number from the internal template
            internalTemplate.substitute(substParamMaxNr_,
                    internalTemplate.getInternalParameter(substParamMaxNr_+"_"
                            +condType2Str_[typeIter->first]));

            // now we have to choose the correct OTHERS string for the
            // internal template. The identifier for the OTHERS string
            // is the condition type (as firmware string) therefore:

            // we get it as follows
            std::string othersString;

            // jet_cnts are a special case
            if (object==JetCounts || object==HTT || object==ETM || object==ETT )
                othersString
                        = internalTemplate.getInternalParameter(objType2Str_[JetCounts]);
            else
                othersString
                        = internalTemplate.getInternalParameter(typeIter->second);

            internalTemplate.substitute(substParamOthers_, othersString);

            // the actual content, taken from the trigger menu

            std::string content = getDefValsFromTriggerMenu(typeIter->first,
                    object, RegEtThreshold);

            internalTemplate.substitute(substParamContent_, content);

            // Finally the parameter $(calo_or_muon) is left open
            std::string caloOrMuonStr = stringConstantCalo_;
           
            if (object == Mu)
                caloOrMuonStr = objType2Str_[Mu];
            
            internalTemplate.substitute(substParamCaloOrMuon_, caloOrMuonStr);
            
            // The internal template has been processed and now can be added to the buffer..
            buffer.append(internalTemplate);

        }

    }

    return true;
}
std::string L1GtVhdlWriterCore::chip2OutputSubDir ( const int &  chip)
void L1GtVhdlWriterCore::countCondsAndAdd2NumberVec ( const L1GtConditionType type,
const L1GtConditionCategory category,
const L1GtObject object,
const ConditionMap map,
ConditionMap outputMap,
const int &  condChip 
)

returns conditions of a class in output map and counts the occurance of all conditions of a certain type at the same time with the result being stored in numberOfConditions_ in the following format: CONSTANT nr_muon_3 : integer := 0; Tis is the format for the cond_chip_pkg files.

Definition at line 1772 of file L1GtVhdlWriterCore.cc.

References condType2Str_, numberOfConditions_, objType2Str_, retNumberOfConditionsString(), and returnConditionsOfOneClass().

Referenced by getCaloSetupContentFromTriggerMenu(), getEsumsSetupContentFromTriggerMenu(), and getMuonSetupContentFromTriggerMenu().

{

    // Get the absoloute amount of conditions

    int number;

    if (returnConditionsOfOneClass(type, category, object, map, outputMap))
        number=outputMap.size();
    else
        number=0;

    std::string initstr = retNumberOfConditionsString(objType2Str_[object]+"_"
            +condType2Str_[type], number);

    numberOfConditions_.at(condChip-1).push_back(initstr);

}
bool L1GtVhdlWriterCore::findObjectType ( const L1GtObject object,
ConditionMap map 
)

Definition at line 118 of file L1GtVhdlWriterCore.cc.

References i, dbtoconf::object, findQualityFiles::size, and ntuplemaker::status.

{
    bool status = false;

    ConditionMap::iterator condIter = map.begin();
    while (condIter!=map.end())
    {
        for (unsigned int i=0; i<(condIter->second->objectType()).size(); i++)
        {
            if (condIter->second->objectType()[i]==object)
            {
                status = true;
                break;
            }
        }

        if (status)
            break;
        condIter++;
    }

    return status;
}
bool L1GtVhdlWriterCore::getCaloSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, std::string > &  caloParameters,
const L1GtObject caloObject 
)

Definition at line 318 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildDeltaEtaCalo(), L1GtVhdlWriterBitManager::buildDeltaPhiCalo(), L1GtVhdlWriterBitManager::buildEtaCalo(), L1GtVhdlWriterBitManager::buildPhiCalo(), CondCalo, conditionToIntegerMap_, L1GtCaloTemplate::correlationParameter(), countCondsAndAdd2NumberVec(), CommonMethods::cp(), debugMode_, i, L1GtCaloTemplate::objectParameter(), Type1s, Type2s, Type2wsc, and Type4s.

Referenced by makeFirmware().

{
    // vector containing all relevant types for calo conditions
    std::vector<L1GtConditionType> caloConditionTypes;

    caloConditionTypes.push_back(Type1s);
    caloConditionTypes.push_back(Type2s);
    caloConditionTypes.push_back(Type2wsc);
    caloConditionTypes.push_back(Type4s);

    for (unsigned int i = 0; i<caloConditionTypes.size(); i++)
    {
        unsigned int counter=0;

        ConditionMap caloConditions;

        // stores all conditions of type given in the first three parameters
        countCondsAndAdd2NumberVec(caloConditionTypes.at(i), CondCalo,
                caloObject, (*conditionMap_).at(condChip-1), caloConditions,
                condChip);

        for (ConditionMap::const_iterator iterCond = caloConditions.begin(); iterCond
                != caloConditions.end(); iterCond++)
        {

            // add this condition to name -> integer conversion map
            conditionToIntegerMap_[iterCond->first]=counter;

            L1GtCaloTemplate* m_gtCaloTemplate =
                    static_cast<L1GtCaloTemplate*>(iterCond->second);
            const std::vector<L1GtCaloTemplate::ObjectParameter>* op =
                    m_gtCaloTemplate->objectParameter();

            if (caloConditionTypes.at(i)==Type1s)
            {

                //= static_cast<std::vector<L1GtCaloTemplate::ObjectPaenergySumParameter+=rameter*> >(op);

                // build eta
                caloParameters["eta_1_s"] += (bm_.buildEtaCalo(op, 1, counter));

                caloParameters["phi_1_s"]+= bm_.buildPhiCalo(op, 1, counter);

                if (debugMode_)
                {
                    caloParameters["eta_1_s"]+=("--"+iterCond->first+"\n");
                    caloParameters["phi_1_s"]+=("--"+iterCond->first+"\n");
                }

            } else if (caloConditionTypes.at(i)==Type2s)
            {

                // build eta
                caloParameters["eta_2_s"] += (bm_.buildEtaCalo(op, 2, counter));

                // add the parameters to parameter map
                caloParameters["phi_2_s"]+= bm_.buildPhiCalo(op, 2, counter);

                if (debugMode_)
                {
                    caloParameters["eta_2_s"]+=("--"+iterCond->first+"\n");
                    caloParameters["phi_2_s"]+=("--"+iterCond->first+"\n");
                }

            } else if (caloConditionTypes.at(i)==Type4s)
            {
                // build eta
                caloParameters["eta_4"] += (bm_.buildEtaCalo(op, 4, counter));

                // add the parameters to parameter map
                caloParameters["phi_4"]+= bm_.buildPhiCalo(op, 4, counter);

                if (debugMode_)
                {
                    caloParameters["eta_4"]+=("--"+iterCond->first+"\n");
                    caloParameters["phi_4"]+=("--"+iterCond->first+"\n");
                }

            } else if (caloConditionTypes.at(i)==Type2wsc)
            {
                const L1GtCaloTemplate::CorrelationParameter* cp =
                        m_gtCaloTemplate->correlationParameter();

                // build eta
                caloParameters["eta_2_wsc"]
                        += (bm_.buildEtaCalo(op, 2, counter));

                // build phi
                caloParameters["phi_2_wsc"]+= bm_.buildPhiCalo(op, 2, counter);

                // build delta_eta
                caloParameters["delta_eta"] += bm_.buildDeltaEtaCalo(cp,
                        counter);

                // build delta_phi
                caloParameters["delta_phi"] += bm_.buildDeltaPhiCalo(cp,
                        counter);

                if (debugMode_)
                {
                    caloParameters["eta_2_wsc"]+=("--"+iterCond->first+"\n");
                    caloParameters["phi_2_wsc"]+=("--"+iterCond->first+"\n");
                    caloParameters["delta_eta"]+=("--"+iterCond->first+"\n");
                    caloParameters["delta_phi"]+=("--"+iterCond->first+"\n");
                }

            }

            counter++;

        }

    }

    return true;
}
L1GtConditionCategory L1GtVhdlWriterCore::getCategoryFromObject ( const L1GtObject object)

gets condition category from object

Definition at line 1839 of file L1GtVhdlWriterCore.cc.

References python::rootplot::argparse::category, CenJet, CondCalo, CondEnergySum, CondJetCounts, CondMuon, CondNull, ETM, ETT, ForJet, HTT, IsoEG, JetCounts, Mu, NoIsoEG, and TauJet.

Referenced by getDefValsFromTriggerMenu().

{

    L1GtConditionCategory category;

    if (object==Mu)
        category = CondMuon;
    else if (object==ETM || object==HTT || object==ETT)
        category = CondEnergySum;
    else if (object==IsoEG|| object==NoIsoEG || object==CenJet || object
            ==ForJet || object==TauJet)
        category = CondCalo;
    else if (object==IsoEG|| object==NoIsoEG || object==CenJet || object
            ==ForJet || object==TauJet)
        category = CondCalo;
    else if (object==JetCounts)
        category = CondJetCounts;
    else 
        category=CondNull;

    return category;

}
std::map< std::string, int > L1GtVhdlWriterCore::getCond2IntMap ( )

Definition at line 1915 of file L1GtVhdlWriterCore.cc.

References conditionToIntegerMap_.

Referenced by L1GtVhdlWriter::analyze().

bool L1GtVhdlWriterCore::getCondChipVhdContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, L1GtVhdlTemplateFile > &  templates,
std::map< std::string, std::string > &  commonParams 
)

builds the substitution parameters for the cond_chip.vhd the condition chip that will be processed

Parameters:
conditionToIntegerMapthis has to be a already FILLED conversion map. therefore this routine has to be called after all those which are adding information to the conditionToIntegerMap map (getMuonSetupContentFromTriggerMenu, buildCaloParameterMap...)
templatesin this map the final content for the subsitution parameters is stored in VHDL template file format

Definition at line 530 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), asciidump::at, caloObjects_, caloType2Int_, CondCalo, CondCorrelation, CondEnergySum, conditionToIntegerMap_, CondJetCounts, CondMuon, CondNull, condType2Str_, esumObjects_, ETM, spr::find(), L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getInternalParameter(), getIntVal(), getSubstParamCommonFromTriggerMenu(), i, index4CondChipVhd(), int2str(), metsig::jet, JetCounts, msg(), Mu, metsig::muon, L1GtCondition::nrObjects(), L1GtJetCountsTemplate::objectParameter(), objType2Str_, L1GtVhdlTemplateFile::open(), AlCaHLTBitMon_ParallelJobs::p, L1GtVhdlTemplateFile::removeEmptyLines(), L1GtVhdlTemplateFile::returnParameterMap(), sp(), L1GtVhdlDefinitions::stringConstantCharge1s_, L1GtVhdlDefinitions::stringConstantCharge2s_, L1GtVhdlDefinitions::stringConstantCharge2wsc_, L1GtVhdlDefinitions::stringConstantCharge3s_, L1GtVhdlDefinitions::stringConstantCharge4s_, L1GtVhdlDefinitions::stringConstantCommon_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamCharge_, L1GtVhdlDefinitions::substParamJetCntsCommon_, L1GtVhdlDefinitions::substParamParticle_, L1GtVhdlDefinitions::substParamType_, Type1s, Type2s, Type2wsc, Type3s, Type4s, and vhdlDir_.

Referenced by makeFirmware().

{

    // open the necessary internal templates
    L1GtVhdlTemplateFile muon, calo, esums, jet;

    muon.open(vhdlDir_+"InternalTemplates/muon", true);
    muon.substitute("particle", "muon");

    calo.open(vhdlDir_+"InternalTemplates/calo", true);
    esums.open(vhdlDir_+"InternalTemplates/esums", true);
    jet.open(vhdlDir_+"InternalTemplates/jet_cnts", true);

    /*
     charge1s.open(vhdlDir_+"InternalTemplates/charge_1s",false);
     charge2s.open(vhdlDir_+"InternalTemplates/charge_2s",false);
     charge2wsc.open(vhdlDir_+"InternalTemplates/charge_2_wsc",false);
     charge3s.open(vhdlDir_+"InternalTemplates/charge_3",false);
     charge4s.open(vhdlDir_+"InternalTemplates/charge_4",false);
     */

    // only for jet_cnts common parameter relevant since common parameter is build in this routine
    std::vector<unsigned int> processedTypes;

    //-------------------------------------build the common parameters-------------------------------------------

    // build $(muon_common)
    getSubstParamCommonFromTriggerMenu(condChip,muon, Mu, CondMuon, commonParams["muon_common"]);

    // build $(calo_common) - loop over all calo objects
    std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();

    while (caloObjIter != caloObjects_.end())
    {

        getSubstParamCommonFromTriggerMenu(condChip, muon, (*caloObjIter), CondCalo,
                commonParams["calo_common"]);
        caloObjIter++;

    }

    // build $(esums_common) - loop over all esums objects
    std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();

    while (esumObjIter != esumObjects_.end())
    {

        getSubstParamCommonFromTriggerMenu(condChip, esums, (*esumObjIter), CondEnergySum,
                commonParams["esums_common"]);
        esumObjIter++;

    }

    //--------------------------------------build the parameter maps----------------------------------------------

    // loop over condition map
    for (ConditionMap::const_iterator iterCond = (*conditionMap_).at(condChip-1).begin(); iterCond != (*conditionMap_).at(condChip-1).end(); iterCond++)
    {

        switch ((iterCond->second)->condCategory())
        {

        case CondMuon:
        {

            int cond2int;
            if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
            {
                msg("Panik! Condition "+(iterCond->first)
                        +" does not have a integer equivalent!");
                break;
            }

            std::string intVal = index4CondChipVhd(cond2int);

            L1GtVhdlTemplateFile muoncopy = muon;

            muoncopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);

            muoncopy.substitute("ser_no", intVal);

            muoncopy.substitute("name", iterCond->first);

            if ((iterCond->second)->condType() == Type1s)
            {
                muoncopy.substitute(substParamCharge_,
                        muon.getInternalParameter(stringConstantCharge1s_));
            } else if ((iterCond->second)->condType() == Type2s)
            {
                muoncopy.substitute(substParamCharge_,
                        muon.getInternalParameter(stringConstantCharge2s_));
            } else if ((iterCond->second)->condType() == Type2wsc)
            {
                muoncopy.substitute(substParamCharge_,
                        muon.getInternalParameter(stringConstantCharge2wsc_));
            } else if ((iterCond->second)->condType() == Type3s)
            {
                muoncopy.substitute(substParamCharge_,
                        muon.getInternalParameter(stringConstantCharge3s_));
            } else if ((iterCond->second)->condType() == Type4s)
            {
                muoncopy.substitute(substParamCharge_,
                        muon.getInternalParameter(stringConstantCharge4s_));
            }

            std::string tempStr = muoncopy.returnParameterMap()["PREALGO"];

            muoncopy.findAndReplaceString(tempStr, "$(particle)", "muon");
            muoncopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
            muoncopy.findAndReplaceString(tempStr, "$(type)", condType2Str_[(iterCond->second)->condType()]);

            muoncopy.append(tempStr);

            muoncopy.removeEmptyLines();

            // add the processed internal template to parameter map
            templates["muon"].append(muoncopy);

        }
            break;

        case CondCalo:
        {
            int cond2int;

            if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
            {
                msg("Panik! Condition "+(iterCond->first)
                        +" does not have a integer equivalent!");
                break;
            }

            std::string intVal = index4CondChipVhd(cond2int);

            L1GtVhdlTemplateFile calocopy = calo;

            calocopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
            calocopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
            calocopy.substitute("name", iterCond->first);
            calocopy.substitute("ser_no", intVal);
            calocopy.substitute("calo_nr", caloType2Int_[((iterCond->second)->objectType()).at(0)]);

            // builds something like tau_1_s(20));
            calocopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] +"_"+condType2Str_[(iterCond->second)->condType()]+"("+intVal+"));");

            templates["calo"].append(calocopy);

        }
            break;

        case CondEnergySum:
        {

            int cond2int;

            if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
            {
                msg("Panik! Condition "+(iterCond->first)
                        +" does not have a integer equivalent!");
                break;
            }

            std::string intVal = index4CondChipVhd(cond2int);

            L1GtVhdlTemplateFile esumscopy = esums;

            esumscopy.substitute("type", condType2Str_[(iterCond->second)->condType()]);
            esumscopy.substitute("particle", objType2Str_[((iterCond->second)->objectType()).at(0)]);
            esumscopy.substitute("name", iterCond->first);
            esumscopy.substitute("ser_no", intVal);

            if (((iterCond->second)->objectType()).at(0)==ETM)
                esumscopy.substitute("if_etm_then_1_else_0", "1");
            else
                esumscopy.substitute("if_etm_then_1_else_0", "0");

            // builds something like htt_cond(4));
            esumscopy.append(objType2Str_[((iterCond->second)->objectType()).at(0)] +"_"+condType2Str_[(iterCond->second)->condType()]+"("+ intVal+"));");

            templates["esums"].append(esumscopy);
        }

            break;

        case CondJetCounts:
        {

            // build the common parameter for the jet counts

            L1GtJetCountsTemplate* jetsTemplate =
                    static_cast<L1GtJetCountsTemplate*>(iterCond->second);

            int nObjects = iterCond->second->nrObjects();

            const std::vector<L1GtJetCountsTemplate::ObjectParameter>* op =
                    jetsTemplate->objectParameter();

            for (int i = 0; i < nObjects; i++)
            {

                std::vector<unsigned int>::iterator p = find(
                        processedTypes.begin(), processedTypes.end(), (*op)[i].countIndex);

                // check, weather this count index was already processed
                // and process it if not
                if (p==processedTypes.end())
                {
                    std::ostringstream indStr;
                    indStr<<(*op)[i].countIndex;

                    std::string tempStr2 = jet.returnParameterMap()[stringConstantCommon_];
                    while (jet.findAndReplaceString(tempStr2,
                            sp(substParamParticle_), objType2Str_[JetCounts]))
                        ;
                    while (jet.findAndReplaceString(tempStr2,
                            sp(substParamType_), indStr.str()))
                        ;
                    commonParams[substParamJetCntsCommon_]+=tempStr2+"\n"; // +"<= '0';\n");
                    processedTypes.push_back((*op)[i].countIndex);
                }

            }

            int cond2int;

            if (!getIntVal(conditionToIntegerMap_, (iterCond->first), cond2int))
            {
                msg("Panik! Condition "+(iterCond->first)
                        +" does not have a integer equivalent!");
                break;
            }

            std::string intVal = index4CondChipVhd(cond2int);

            L1GtVhdlTemplateFile jetcopy = jet;

            jetcopy.substitute("particle", condType2Str_[(iterCond->second)->condType()]);
            jetcopy.substitute("type", int2str((*op)[0].countIndex));
            jetcopy.substitute("name", iterCond->first);

            jetcopy.substitute("ser_no", intVal);

            // builds the final string
            std::string tempStr = jetcopy.returnParameterMap()["PREALGO"];

            jetcopy.findAndReplaceString(tempStr, "$(particle)", "jet_cnt");
            jetcopy.findAndReplaceString(tempStr, "$(ser_no)", intVal);
            jetcopy.findAndReplaceString(tempStr, "$(type)", int2str((*op)[0].countIndex));

            jetcopy.append(tempStr);
            jetcopy.removeEmptyLines();

            templates["jet_cnts"].append(jetcopy);
        }

            break;

        case CondCorrelation:
        {
            //empty
        }
            break;

        case CondNull:
        {
            //empty
        }
            break;

        default:
        {
            //empty
        }
            break;
        }
    }

    // delete superfluous newlines at the end of common parameters
    std::map<std::string,std::string>::iterator pIt = commonParams.begin();

    while (pIt!=commonParams.end())
    {
        if ((pIt->second)[((pIt->second).length()-1)] == '\n')
            (pIt->second) = (pIt->second).substr(0, (pIt->second).length()-1);
        pIt++;
    }

    return true;

}
std::string L1GtVhdlWriterCore::getDefValsFromTriggerMenu ( const L1GtConditionType type,
const L1GtObject object,
const VmeRegister reg 
)

this routine extracts default values for def_val_pkg.vhd from trigger menu. it is used from buildDefValuesBuffer.

Definition at line 1488 of file L1GtVhdlWriterCore.cc.

References python::rootplot::argparse::category, CondCalo, getCategoryFromObject(), i, int2str(), L1GtCaloTemplate::objectParameter(), query::result, and returnConditionsOfOneClass().

Referenced by buildDefValuesBuffer().

{
    L1GtConditionCategory category;

    // get condition category from object

    category = getCategoryFromObject(object);

    ConditionMap conditions;
    returnConditionsOfOneClass(type, category, object, (*conditionMap_).at(0),
            conditions);

    std::string result;

    if (category==CondCalo)
    {
        for (ConditionMap::const_iterator iterCond =conditions.begin(); iterCond
                != conditions.end(); iterCond++)
        {
            L1GtCaloTemplate* caloTemplate =
                    static_cast<L1GtCaloTemplate*>(iterCond->second);
            const std::vector<L1GtCaloTemplate::ObjectParameter>* op =
                    caloTemplate->objectParameter();

            unsigned int nObjects = iterCond->second->nrObjects();

            for (unsigned int i =0; i<nObjects; i++)
            {
                if (i==0)
                    result+="(";
                result +="\"";
                result += int2str((*op).at(i).etThreshold);
                result +="\"";
                if (i!=nObjects-1)
                    result +=",";
                else
                    result+=")\n";

            }
        }
    }

    return "-- 0 => (\"00000000\", \"00000000\" ... )";
    return result;
}
bool L1GtVhdlWriterCore::getEsumsSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
const L1GtObject object,
std::string &  energySumParameter 
)

contains only one subsitution parameter which is stored in reference energySumParameter

Definition at line 438 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildPhiEnergySum(), CondEnergySum, conditionToIntegerMap_, countCondsAndAdd2NumberVec(), debugMode_, ETM, ETT, HTT, L1GtEnergySumTemplate::objectParameter(), TypeETM, TypeETT, and TypeHTT.

Referenced by makeFirmware().

{

    L1GtConditionType type;

    unsigned int counter=0;

    if (object==HTT)
        type= TypeHTT;
    else if (object==ETM)
        type= TypeETM;
    else if (object==ETT)
        type= TypeETT;

    ConditionMap esumsConditions;
    // stores all conditions of type given in the first three parameters
    countCondsAndAdd2NumberVec(type, CondEnergySum, object,
            (*conditionMap_).at(condChip-1), esumsConditions, condChip);

    for (ConditionMap::const_iterator iterCond = esumsConditions.begin(); iterCond
            != esumsConditions.end(); iterCond++)
    {
        L1GtEnergySumTemplate* energySumTempl =
                static_cast<L1GtEnergySumTemplate*>(iterCond->second);
        const std::vector<L1GtEnergySumTemplate::ObjectParameter>* op =
                energySumTempl->objectParameter();

        if (bm_.buildPhiEnergySum(op, 1, counter)!="")
            energySumParameter+=bm_.buildPhiEnergySum(op, 1, counter);

        if (debugMode_)
        {
            energySumParameter+=("--"+iterCond->first+"\n");
        }

        conditionToIntegerMap_[(iterCond->first)]=counter;

        counter++;
    }

    return true;

}
bool L1GtVhdlWriterCore::getIntVal ( const std::map< std::string, int > &  map,
const std::string &  searchValue,
int &  intVal 
)

checks weather value searchValue exists in a <string,int> map, saves it in &intVal if it exists and returns false if not

Definition at line 1367 of file L1GtVhdlWriterCore.cc.

Referenced by getCondChipVhdContentFromTriggerMenu().

{
    std::map<std::string,int>::const_iterator iter = map.find(searchValue);
    if (iter == map.end() )
        return false;
    intVal = (*iter).second;
    return true;
}
std::vector< std::string > L1GtVhdlWriterCore::getMsgBuf ( )

returns intern message buffer

Definition at line 1362 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

{
    return internMessageBuf_;
}
void L1GtVhdlWriterCore::getMuonSetupContentFromTriggerMenu ( const unsigned short int &  condChip,
std::map< std::string, std::string > &  muonParameters 
)

builds a parameter map that can be used by the L1GtVhdlWriterCore class the output is written into the parameter

Parameters:
conditionToIntegerMapis the condition is added to this conversion map
muonParametershere the routine stores the content of the subsitution parameters
conditionMapcontaining the input

Definition at line 143 of file L1GtVhdlWriterCore.cc.

References bm_, L1GtVhdlWriterBitManager::buildDeltaEtaMuon(), L1GtVhdlWriterBitManager::buildDeltaPhiMuon(), L1GtVhdlWriterBitManager::buildEtaMuon(), L1GtVhdlWriterBitManager::buildPhiMuon(), conditionToIntegerMap_, CondMuon, L1GtMuonTemplate::correlationParameter(), countCondsAndAdd2NumberVec(), CommonMethods::cp(), debugMode_, i, Mu, L1GtMuonTemplate::objectParameter(), Type1s, Type2s, Type2wsc, Type3s, and Type4s.

Referenced by makeFirmware().

{
    // vector containing all relevant types for muon conditions
    std::vector<L1GtConditionType> muonConditionTypes;

    muonConditionTypes.push_back(Type1s);
    muonConditionTypes.push_back(Type2s);
    muonConditionTypes.push_back(Type2wsc);
    muonConditionTypes.push_back(Type3s);
    muonConditionTypes.push_back(Type4s);

    for (unsigned int i = 0; i<muonConditionTypes.size(); i++)
    {
        //std::cout<<i<<std::endl;

        ConditionMap MuonConditions1s;

        countCondsAndAdd2NumberVec(muonConditionTypes.at(i), CondMuon, Mu,
                (*conditionMap_).at(condChip-1), MuonConditions1s, condChip);

        /*
         // Get the absoloute amount of conditions
         std::string initstr="CONSTANT nr_"+objType2Str_[Mu]+"_"+condType2Str_[muonConditionTypes.at(i)]+" : integer := ";

         if (returnConditionsOfOneClass(muonConditionTypes.at(i),CondMuon,Mu,conditionMap_.at(condChip-1), MuonConditions1s))
         initstr+=(int2str(MuonConditions1s.size())+";");
         else
         initstr+=("0;");

         numberOfConditions_.at(condChip-1).push_back(initstr);

         */

        //std::cout<< std::hex << (*myObjectParameter).at(0).etThreshold << std::endl;
        unsigned int counter=0;

        for (ConditionMap::const_iterator iterCond = MuonConditions1s.begin(); iterCond
                != MuonConditions1s.end(); iterCond++)
        {

            // add this condition to name -> integer conversion map
            conditionToIntegerMap_[iterCond->first]=counter;

            L1GtMuonTemplate* m_gtMuonTemplate =
                    static_cast<L1GtMuonTemplate*>(iterCond->second);
            const std::vector<L1GtMuonTemplate::ObjectParameter>* op =
                    m_gtMuonTemplate->objectParameter();

            if (muonConditionTypes.at(i)==Type1s)
            {

                // build eta
                muonParameters["eta_1_s"] += (bm_.buildEtaMuon(op, 1, counter));

                // add the parameters to parameter map
                muonParameters["phi_h_1_s"]+= bm_.buildPhiMuon(op, 1, counter,
                        true);
                muonParameters["phi_l_1_s"]+=bm_.buildPhiMuon(op, 1, counter,
                        false);

                if (debugMode_)
                {
                    muonParameters["phi_l_1_s"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_h_1_s"]+=("--"+iterCond->first+"\n");
                    muonParameters["eta_1_s"] +=("--"+iterCond->first+"\n");
                }

            } else

            if (muonConditionTypes.at(i)==Type2s)
            {

                // build eta
                muonParameters["eta_2_s"] += (bm_.buildEtaMuon(op, 2, counter));

                // add the parameters to parameter map
                muonParameters["phi_h_2_s"]+= bm_.buildPhiMuon(op, 2, counter,
                        true);
                muonParameters["phi_l_2_s"]+=bm_.buildPhiMuon(op, 2, counter,
                        false);

                if (debugMode_)
                {
                    muonParameters["phi_l_2_s"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_h_2_s"]+=("--"+iterCond->first+"\n");
                    muonParameters["eta_2_s"] +=("--"+iterCond->first+"\n");
                }

            } else
            //m_gtMuonTemplate->print(std::cout);

            if (muonConditionTypes.at(i)==Type3s)
            {

                // build eta
                muonParameters["eta_3"] += (bm_.buildEtaMuon(op, 3, counter));

                // add the parameters to parameter map
                muonParameters["phi_h_3"]+= bm_.buildPhiMuon(op, 3, counter,
                        true);
                muonParameters["phi_l_3"]+=bm_.buildPhiMuon(op, 3, counter,
                        false);

                if (debugMode_)
                {
                    muonParameters["phi_l_3"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_h_3"]+=("--"+iterCond->first+"\n");
                    muonParameters["eta_3"] +=("--"+iterCond->first+"\n");
                }

            }

            if (muonConditionTypes.at(i)==Type4s)
            {

                // build eta
                muonParameters["eta_4"] += (bm_.buildEtaMuon(op, 4, counter));

                // add the parameters to parameter map
                muonParameters["phi_h_4"]+= bm_.buildPhiMuon(op, 4, counter,
                        true);
                muonParameters["phi_l_4"]+=bm_.buildPhiMuon(op, 4, counter,
                        false);

                if (debugMode_)
                {
                    muonParameters["phi_l_4"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_h_4"]+=("--"+iterCond->first+"\n");
                    muonParameters["eta_4"] +=("--"+iterCond->first+"\n");
                }

            }

            if (muonConditionTypes.at(i)==Type2wsc)
            {
                const L1GtMuonTemplate::CorrelationParameter* cp =
                        m_gtMuonTemplate->correlationParameter();

                // build eta
                muonParameters["eta_2_wsc"]
                        += (bm_.buildEtaMuon(op, 2, counter));

                // build phi
                muonParameters["phi_h_2_wsc"]+= bm_.buildPhiMuon(op, 2,
                        counter, true);
                muonParameters["phi_l_2_wsc"]+=bm_.buildPhiMuon(op, 2, counter,
                        false);

                // build delta_eta
                std::ostringstream dEta;
                muonParameters["delta_eta"] += bm_.buildDeltaEtaMuon(cp,
                        counter);

                // build delta_phi
                muonParameters["delta_phi"] += bm_.buildDeltaPhiMuon(cp,
                        counter);

                if (debugMode_)
                {
                    muonParameters["eta_2_wsc"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_h_2_wsc"]+=("--"+iterCond->first+"\n");
                    muonParameters["phi_l_2_wsc"] +=("--"+iterCond->first+"\n");
                    muonParameters["delta_eta"]+=("--"+iterCond->first+"\n");
                    muonParameters["delta_phi"] +=("--"+iterCond->first+"\n");
                }

            }
            counter++;
        }
    }

}
bool L1GtVhdlWriterCore::getSubstParamCommonFromTriggerMenu ( const unsigned short int &  condChip,
L1GtVhdlTemplateFile particle,
const L1GtObject object,
const L1GtConditionCategory category,
std::string &  parameterStr 
)

builds the parameters particle_common for the cond_chip.vhd's

Definition at line 484 of file L1GtVhdlWriterCore.cc.

References condType2Str_, L1GtVhdlTemplateFile::findAndReplaceString(), JetCounts, objType2Str_, returnConditionsOfOneClass(), L1GtVhdlTemplateFile::returnParameterMap(), sp(), L1GtVhdlDefinitions::stringConstantCommon_, L1GtVhdlDefinitions::substParamParticle_, and L1GtVhdlDefinitions::substParamType_.

Referenced by getCondChipVhdContentFromTriggerMenu().

{

    std::map<L1GtConditionType,std::string> condType2Strcopy = condType2Str_;

    // make a copy since types will deleted later after they are processed
    std::map<L1GtConditionType,std::string>::iterator typeIterator =
            condType2Strcopy.begin();

    while (typeIterator != condType2Strcopy.end())
    {

        ConditionMap outputMap;
        
        if (returnConditionsOfOneClass((*typeIterator).first, category, object, (*conditionMap_).at(condChip-1), outputMap))
        {

            // special treatment for jet counts in buildCodChipParameters
            if (object !=JetCounts)
            {
                std::string tempStr2 = particle.returnParameterMap()[stringConstantCommon_];
                while (particle.findAndReplaceString(tempStr2,
                        sp(substParamParticle_), objType2Str_[object]))
                    ;
                while (particle.findAndReplaceString(tempStr2,
                        sp(substParamType_), condType2Str_[(*typeIterator).first]))
                    ;
                parameterStr+=(tempStr2+"\n\n");

                //parameterStr+=(tempStr2+"<= '0';\n");

                // remove this type since it was already processed
                condType2Strcopy.erase(typeIterator);
            }

        }

        typeIterator++;

    }

    return true;
}
std::string L1GtVhdlWriterCore::gtTemplatesPath ( )

returns the templates path

Definition at line 1032 of file L1GtVhdlWriterCore.cc.

References vhdlDir_.

{
    return vhdlDir_;
}
std::string L1GtVhdlWriterCore::index4CondChipVhd ( int  intval)

builds the index for the cond_chip vhds. (They have to start at 1 so one has to be added to the value in conversion map)

Definition at line 1377 of file L1GtVhdlWriterCore.cc.

References int2str().

Referenced by getCondChipVhdContentFromTriggerMenu().

{
    intval++;
    return int2str(intval);
}
void L1GtVhdlWriterCore::initializeDeltaConditions ( )

Definition at line 1794 of file L1GtVhdlWriterCore.cc.

References caloObjects_, ETM, i, gen::k, Mu, numberOfConditions_, objType2Str_, and retNumberOfConditionsString().

Referenced by makeFirmware().

{

    for (unsigned int k=0; k<=1; k++)
    {

        // combine muon with calo particles
        for (unsigned int i=0; i<caloObjects_.size(); i++)
        {
            numberOfConditions_.at(k).push_back(retNumberOfConditionsString(objType2Str_[Mu]
                    +"_"+objType2Str_[caloObjects_.at(i)], 0));
        }

        // combine etm with muon
        numberOfConditions_.at(k).push_back(retNumberOfConditionsString(objType2Str_[ETM]+"_"
                +objType2Str_[Mu], 0));

        // combine etm with calo particles
        for (unsigned int i=0; i<caloObjects_.size(); i++)
        {
            numberOfConditions_.at(k).push_back(retNumberOfConditionsString(objType2Str_[ETM]
                    +"_"+objType2Str_[caloObjects_.at(i)], 0));
        }

        std::vector<L1GtObject> caloObjectsCp = caloObjects_;

        while (caloObjectsCp.size()>0)
        {
            std::vector<L1GtObject>::iterator iter=caloObjectsCp.begin();
            L1GtObject firstPartner = (*iter);
            caloObjectsCp.erase(iter);

            iter=caloObjectsCp.begin();
            while (iter!=caloObjectsCp.end())
            {
                numberOfConditions_.at(k).push_back(retNumberOfConditionsString(
                        objType2Str_[firstPartner]+"_"+objType2Str_[(*iter)], 0));
                iter++;
            }

        }

    }
}
std::string L1GtVhdlWriterCore::int2str ( const int &  integerValue) [static]
bool L1GtVhdlWriterCore::makeFirmware ( const std::vector< ConditionMap > &  conditionMap,
const AlgorithmMap algorithmMap 
)

produces the firmware code

Definition at line 917 of file L1GtVhdlWriterCore.cc.

References addJetCountsToCond2IntMap(), algorithmMap_, caloObjects_, conditionMap_, conditionToIntegerMap_, debugMode_, esumObjects_, getCaloSetupContentFromTriggerMenu(), getCondChipVhdContentFromTriggerMenu(), getEsumsSetupContentFromTriggerMenu(), getMuonSetupContentFromTriggerMenu(), i, initializeDeltaConditions(), objType2Str_, outputDir_, L1GtVhdlDefinitions::outputSubDir1_, L1GtVhdlDefinitions::outputSubDir2_, processAlgorithmMap(), PixelCPETemplateReco_cfi::templates, version_, writeAlgoSetup(), writeCond2intMap2File(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), writeMuonSetupVhdl(), and writeQsfSetupFiles().

Referenced by L1GtVhdlWriter::analyze().

{
    conditionMap_ = &conditionMap;

    algorithmMap_ = &algorithmMap;
    
    std::string subDir1 = outputDir_+outputSubDir1_;
    std::string subDir2  = outputDir_+outputSubDir2_;
    
    if (!mkdir(subDir1.c_str(), 666));
    if (!mkdir(subDir2.c_str(), 666));
    
    chmod(subDir1.c_str(), 0777);
    chmod(subDir2.c_str(), 0777);
    
    /*
    subDirs_.push_back(subDir1);
    subDirs_.push_back(subDir2);
    */
    
    writeQsfSetupFiles(version_);
    
    
    //--------------------------------------build setups-------------------------------------------------------

    // loop over the two condition chips
    for (unsigned short int i =1; i<=2; i++)
    {
        // ----------------------- muon setup -------------------------------------------------------

        std::map<std::string,std::string> muonParameters;
        getMuonSetupContentFromTriggerMenu(i, muonParameters);
        writeMuonSetupVhdl(muonParameters, "muon", i);

        // ----------------------- calo setup -------------------------------------------------------

        // map containing all calo object types correlated with the strings
        // under which they appear in the firmware
        std::vector<L1GtObject>::iterator caloObjIter = caloObjects_.begin();

        // loop over all calo objectsbuildMuonSetupVhdl
        while (caloObjIter != caloObjects_.end())
        {
            std::map<std::string,std::string> caloParameters;
            getCaloSetupContentFromTriggerMenu(i, caloParameters,
                    (*caloObjIter));
            writeMuonSetupVhdl(caloParameters, objType2Str_[(*caloObjIter)], i);

            caloObjIter++;
        }

        // ----------------------- etm setup ---------------------------------------------------------

        // map containing all calo object types correlated with the strings
        // under which they appear in the firmware
        std::vector<L1GtObject>::iterator esumObjIter = esumObjects_.begin();

        while (esumObjIter != esumObjects_.end())
        {
            std::string etmParameter;

            getEsumsSetupContentFromTriggerMenu(i, (*esumObjIter),
                    etmParameter);
            writeEtmSetup(etmParameter, i);

            esumObjIter++;

        }

        // add jet counts to condition 2 integer map
        addJetCountsToCond2IntMap(i, (*conditionMap_), conditionToIntegerMap_);

        // --------------------cond chip setup---------------------------------------------------------
        // Important: all other setups have to be build BEFORE this one because it needs a
        // complete condition2integer map !!!

        std::map<std::string, L1GtVhdlTemplateFile> templates;
        std::map<std::string, std::string> common;
        getCondChipVhdContentFromTriggerMenu(i, templates, common);
        writeConditionChipSetup(templates, common, i);

        // despite yet not existing they have to appear in cond_chip_pkg vhds
        initializeDeltaConditions();

        // --------------------cond chip pkg------------------------------------------------------------

        writeCondChipPkg(i);

        // -----------------------def val pkg -------------------------------------------------

        writeDefValPkg((*conditionMap_), i);

        // debug
        if (debugMode_)
        {
            //printConditionsOfCategory(CondEnergySum, (*conditionMap_).at(i-1));
        }

    }

    if (debugMode_)
        writeCond2intMap2File();

    //-------------------------------process algorithms----------------------------------------------------------

    std::vector< std::map<int, std::string> > algoStrings;

    processAlgorithmMap(algoStrings);
    
    writeAlgoSetup(algoStrings);

    return true;
}
void L1GtVhdlWriterCore::msg ( const std::string &  message)

adds a string to intern message buffer

Definition at line 1357 of file L1GtVhdlWriterCore.cc.

References internMessageBuf_.

Referenced by buildCommonHeader(), getCondChipVhdContentFromTriggerMenu(), printConditionsOfCategory(), and processAlgorithmMap().

{
    internMessageBuf_.push_back(message);
}
L1GtVhdlTemplateFile L1GtVhdlWriterCore::openVhdlFileWithCommonHeader ( const std::string &  filename,
const std::string &  outputFilename 
)

opens a new template file and inserts the common header

Definition at line 1074 of file L1GtVhdlWriterCore.cc.

References commonHeader_, L1GtVhdlTemplateFile::insert(), L1GtVhdlTemplateFile::substitute(), and vhdlDir_.

Referenced by writeAlgoSetup(), writeCondChipPkg(), writeConditionChipSetup(), writeDefValPkg(), writeEtmSetup(), and writeMuonSetupVhdl().

{
    L1GtVhdlTemplateFile commonHeaderCp;
    commonHeaderCp = commonHeader_;

    commonHeaderCp.substitute("vhdl_file_name", outputFilename);

    L1GtVhdlTemplateFile myTemplate(vhdlDir_+"Templates/"+filename);
    myTemplate.insert("$(header)", commonHeaderCp);

    return myTemplate;
}
void L1GtVhdlWriterCore::printCommonHeader ( )

prints the common header

Definition at line 1320 of file L1GtVhdlWriterCore.cc.

References commonHeader_, and L1GtVhdlTemplateFile::print().

void L1GtVhdlWriterCore::printConditionsOfCategory ( const L1GtConditionCategory category,
const ConditionMap map 
)

for debuggin

Definition at line 1864 of file L1GtVhdlWriterCore.cc.

References int2str(), and msg().

{
    int counter =0;
    for (ConditionMap::const_iterator iterCond = map.begin(); iterCond
            != map.end(); iterCond++)
    {
        msg(iterCond->first);
        counter++;
    }

    msg("Total Occurances: "+int2str(counter));

}
bool L1GtVhdlWriterCore::processAlgorithmMap ( std::vector< std::map< int, std::string > > &  algoStrings)

processes algorithm map delivered by parser, replaces condition names by types and serial numbers, splits the map in a vector two seperate ones for the two condition chips

Definition at line 824 of file L1GtVhdlWriterCore.cc.

References asciidump::at, conditionMap_, conditionToIntegerMap_, condType2Str_, debugMode_, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getConditionsFromAlgo(), i, msg(), NULL, and objType2Str_.

Referenced by makeFirmware().

{
    std::map<int, std::string> algorithmsChip1;
    std::map<int, std::string> algorithmsChip2;
    
    AlgorithmMap::const_iterator algoIter=(*algorithmMap_).begin();

    // loop over algorithm map
    while (algoIter!=(*algorithmMap_).end())
    {
        // msg(algoIter->first);

        L1GtVhdlTemplateFile dummy;

        // get the logical expression
        std::string logicalExpr = (algoIter->second).algoLogicalExpression();
        std::vector<std::string> conditions;

        dummy.getConditionsFromAlgo(logicalExpr, conditions);

        std::string logicalExprCopy= logicalExpr;

        // loop over all condition names appearing in algorithm and replace them by type and integer value
        for (unsigned int i=0; i<conditions.size(); i++)
        {
            std::ostringstream newExpr;
            
            // look for the condition on correct chip
           
            std::vector<ConditionMap> * conditionMapCp = const_cast< std::vector<ConditionMap>* >(conditionMap_);
            
            L1GtCondition* cond = (*conditionMapCp).at((algoIter->second).algoChipNumber())[conditions.at(i)];

            // check weather condition exists
            if (cond!=NULL)
            {
                newExpr<<objType2Str_[(cond->objectType()).at(0)];

                newExpr <<"_" << condType2Str_[cond->condType()] << "(";

                newExpr << conditionToIntegerMap_[conditions.at(i)] << ")";
                dummy.findAndReplaceString(logicalExpr, conditions.at(i),
                        newExpr.str());
            } else
                msg("Panik! Didn't find Condition "+conditions.at(i));
        }

        // has to be checked!
        std::vector<int> orderConditionChip;
        orderConditionChip.push_back(2);
        orderConditionChip.push_back(1);

        int pin = (algoIter->second).algoOutputPin(2, 96, orderConditionChip);

        //msg(int2str(pin));

        if (pin<0)
            pin*=-1;

        if ((algoIter->second).algoChipNumber()==0)
        {
            algorithmsChip1[pin]=logicalExpr;
            if (debugMode_)
                algorithmsChip1[pin]+=("-- "+logicalExprCopy);
        } else if ((algoIter->second).algoChipNumber()==1)
        {
            algorithmsChip2[pin]=logicalExpr;
            if (debugMode_)
                algorithmsChip2[pin]+=("-- "+logicalExprCopy);
        } else
            ;

        algoIter++;
    }

    algoStrings.push_back(algorithmsChip1);
    algoStrings.push_back(algorithmsChip2);
    
    return true;

}
std::string L1GtVhdlWriterCore::retNumberOfConditionsString ( const std::string &  typeStr,
const int &  number 
)

Definition at line 1906 of file L1GtVhdlWriterCore.cc.

References int2str(), and L1GtVhdlDefinitions::stringConstantConstantNr_.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), and initializeDeltaConditions().

{
    std::string initstr=stringConstantConstantNr_+typeStr+" : integer := "+int2str(number)
            +";";

    return initstr;
}
L1GtVhdlTemplateFile L1GtVhdlWriterCore::retrunCommonHeader ( )

returns the common header

Definition at line 1325 of file L1GtVhdlWriterCore.cc.

References commonHeader_.

Referenced by L1GtVhdlWriter::analyze().

{
    return commonHeader_;
}
bool L1GtVhdlWriterCore::returnConditionsOfOneClass ( const L1GtConditionType type,
const L1GtConditionCategory category,
const L1GtObject object,
const ConditionMap map,
ConditionMap outputMap 
)

returns all condition of the same class. Conditions belong to one class if they are matching in type (Type1s, Type2s..) category (CondMuon, CondCalo,)and are defined for the same object (Mu, fwdJet..)

Parameters:
mapis the ConditionMap that shall be filtered
conditionToIntegerMapis the condition is added to this conversion map
outputMaphere the conditions matching the requirements are stored

Definition at line 95 of file L1GtVhdlWriterCore.cc.

References ntuplemaker::status.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), getDefValsFromTriggerMenu(), and getSubstParamCommonFromTriggerMenu().

{
    bool status = false;

    ConditionMap::const_iterator condIter = map.begin();
    while (condIter!=map.end())
    {
        if (condIter->second->condCategory()==category
                && condIter->second->condType()==type && (condIter->second->objectType())[0]==object)
        {
            outputMap[condIter->first]=condIter->second;
            status = true;
        }
        condIter++;
    }

    return status;
}
std::string L1GtVhdlWriterCore::sp ( const std::string &  name)

converts string name to substiution parameter synthax; name -->

Definition at line 1920 of file L1GtVhdlWriterCore.cc.

Referenced by buildDefValuesBuffer(), getCondChipVhdContentFromTriggerMenu(), getSubstParamCommonFromTriggerMenu(), and writeDefValPkg().

{
    return "$("+name+")";
}
void L1GtVhdlWriterCore::writeAlgoSetup ( std::vector< std::map< int, std::string > > &  algoStrings)

builds the prealgo_and_or setup

Definition at line 1253 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), lut2db_cfg::filename, L1GtVhdlTemplateFile::findAndReplaceString(), i, int2str(), gen::k, openVhdlFileWithCommonHeader(), dumpDBToFile_GT_ttrig_cfg::outputFileName, L1GtVhdlTemplateFile::save(), L1GtVhdlDefinitions::stringConstantAlgo_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::substParamAlgos_, indexGen::templateFile, and L1GtVhdlDefinitions::vhdlTemplateAlgoAndOr_.

Referenced by makeFirmware().

{
    // loop over the two condition chips
    for (unsigned int i=1; i<=2; i++)
    {
        std::string filename=vhdlTemplateAlgoAndOr_;

        // output file name
        std::string outputFileName = filename;
        L1GtVhdlTemplateFile::findAndReplaceString(outputFileName, ".",
                int2str(i)+".");

        L1GtVhdlTemplateFile templateFile = openVhdlFileWithCommonHeader(
                filename, outputFileName);

        std::ostringstream buffer;
        
        unsigned int algoPinsPerChip = 96;

        for (unsigned int k=1; k<=algoPinsPerChip; k++)
        {

            buffer<< stringConstantAlgo_<<"("<<k<<")";
            if (algoStrings.at(i-1)[k]!="")
                buffer<<" <= "<<algoStrings.at(i-1)[k]<<";"<<std::endl;
            else
                buffer<<" <= '0';"<<std::endl;
        }

        templateFile.substitute(substParamAlgos_, buffer.str());
        templateFile.save(chip2OutputSubDir(i)+filename);
        chmod((chip2OutputSubDir(i)+filename).c_str(), 0666);
    }

}
void L1GtVhdlWriterCore::writeCond2intMap2File ( )

produces a control output file for condition to integer conversion

Definition at line 1433 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), conditionMap_, conditionToIntegerMap_, lut2db_cfg::filename, i, and download_sqlite_cfg::outputFile.

Referenced by makeFirmware().

{
   
    
    for (unsigned int i=0; i<=1;i++)
    {
        ConditionMap::const_iterator iterCond =
            conditionMap_->at(i).begin();
       
        std::string filename=chip2OutputSubDir(i+1)+"cond_names_integer.txt";
        
        std::ofstream outputFile(filename.c_str());
        
        while (iterCond!=conditionMap_->at(i).end())
        {
            conditionToIntegerMap_[(*iterCond).first];
            
            outputFile<<(iterCond->first)<<": "<<conditionToIntegerMap_[(*iterCond).first]<<std::endl;
            iterCond++;
        }
        
        outputFile.close();
        
        chmod(filename.c_str(), 0666);
          
        
    }
   
    /*
    
    
    const std::vector<ConditionMap> * conditionMap_;
    
    std::string filename=outputDir_+"cond_names_integer.txt";
    std::ofstream outputFile(filename.c_str());

    for (std::map<std::string,int>::const_iterator iterCond =
            conditionToIntegerMap_.begin(); iterCond
            != conditionToIntegerMap_.end(); iterCond++)
    {
        outputFile<<(iterCond->first)<<": "<<(iterCond->second)<<std::endl;
    }
    
    */

}
void L1GtVhdlWriterCore::writeCondChipPkg ( const int &  chip)
void L1GtVhdlWriterCore::writeConditionChipSetup ( std::map< std::string, L1GtVhdlTemplateFile templates,
const std::map< std::string, std::string > &  common,
const unsigned short int &  chip 
)

builds cond_chip.vhds

Definition at line 1208 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), lut2db_cfg::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::insert(), int2str(), openVhdlFileWithCommonHeader(), dumpDBToFile_GT_ttrig_cfg::outputFileName, L1GtVhdlTemplateFile::save(), L1GtVhdlTemplateFile::substitute(), and L1GtVhdlDefinitions::vhdlTemplateCondChip_.

Referenced by makeFirmware().

{

    // get filename 
    std::string filename = vhdlTemplateCondChip_;

    // build output filename
    std::string outputFileName = filename;
    L1GtVhdlTemplateFile::findAndReplaceString(outputFileName, ".",
            int2str(chip)+".");

    L1GtVhdlTemplateFile myTemplate = openVhdlFileWithCommonHeader(filename,
            outputFileName);

    // map containing the subsitution parameters with their content (as L1GtVhdlTemplateFile file object)
    std::map<std::string, L1GtVhdlTemplateFile>::iterator iter=
            templates.begin();

    while (iter != templates.end())
    {

        myTemplate.insert("$("+(iter->first)+")", iter->second);

        iter++;
    }

    // subsitutes common parameters
    std::map<std::string, std::string>::const_iterator iter2= common.begin();

    while (iter2 != common.end())
    {

        myTemplate.substitute((iter2->first), iter2->second);

        iter2++;
    }

    myTemplate.save(chip2OutputSubDir(chip)+filename);
    chmod((chip2OutputSubDir(chip)+filename).c_str(), 0666);

}
void L1GtVhdlWriterCore::writeDefValPkg ( const std::vector< ConditionMap > &  conditionMap,
const int &  chip 
)

writes def_val_pkg.vhd

Definition at line 1536 of file L1GtVhdlWriterCore.cc.

References buildDefValuesBuffer(), caloObjects_, chip2OutputSubDir(), condType2Str_, esumObjects_, lut2db_cfg::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getInternalParameter(), i, L1GtVhdlTemplateFile::insert(), int2str(), JetCounts, Mu, L1GtVhdlTemplateFile::open(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::save(), sp(), L1GtVhdlDefinitions::stringConstantEsumsHigh_, L1GtVhdlDefinitions::stringConstantEsumsLow_, L1GtVhdlDefinitions::stringConstantPth_, L1GtVhdlDefinitions::stringConstantPtl_, L1GtVhdlDefinitions::stringConstantQuality_, L1GtVhdlDefinitions::substParamCaloDefVals_, L1GtVhdlDefinitions::substParamCharge_, L1GtVhdlDefinitions::substParamEsumsDefVals_, L1GtVhdlDefinitions::substParamJetsDefVals_, L1GtVhdlDefinitions::substParamMuonDefVals_, Type2cor, Type3s, TypeETM, TypeETT, TypeHTT, TypeJetCounts, vhdlDir_, and L1GtVhdlDefinitions::vhdlTemplateDefValPkg_.

Referenced by makeFirmware().

{
    // open internal template file
    L1GtVhdlTemplateFile internalTemplate;
    internalTemplate.open(vhdlDir_+"InternalTemplates/defvalpkg", true);

    // to write the def_value_pkg file it has to be looped over all POSSIBLE types of conditions
    // POSSIBLE: calo_3 eg. does not exist and therefore makes no sense..

    // Process muon conditions first

    // temporary buffers for the default value blocks (see internal templates) of the different types.
    // in the end those buffers are simply appended to the actual template!
    L1GtVhdlTemplateFile muonDefValuesBuffer, caloDefValuesBuffer,
            jetCountsDefValuesBuffer, esumsDefValBuffer;

    // Get the default value type strings from internal template
    std::vector<std::string> muonDefValTypes;
    muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPtl_));
    muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantPth_));
    muonDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantQuality_));
    muonDefValTypes.push_back(internalTemplate.getInternalParameter(substParamCharge_));

    int jetCountsMaxIndex = 11;

    // fill jet counts vector (from 1 to 11)
    std::vector<std::string> jetCountsDefValTypes;
    for (int i = 0; i<=jetCountsMaxIndex; i++)
    {
        jetCountsDefValTypes.push_back(int2str(i));
    }

    // only one default value for calo objects therefore only a empty string
    std::vector<std::string> caloDefValTypes;
    caloDefValTypes.push_back("");

    // get types of esums defvalues (as firmware strings) from the internal templates
    std::vector<std::string> esumsDefValTypes;
    esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsLow_));
    esumsDefValTypes.push_back(internalTemplate.getInternalParameter(stringConstantEsumsHigh_));

    std::map<L1GtConditionType,std::string>::iterator typeIter;

    // prepare a map with all muon relevant types by removing 
    // obsolete types from a copy of condType2Str_ map
    // should be improved
    std::map<L1GtConditionType,std::string> muonTypes = condType2Str_;

    typeIter=muonTypes.find(Type2cor);
    muonTypes.erase(typeIter);
    typeIter=muonTypes.find(TypeETM);
    muonTypes.erase(typeIter);
    typeIter=muonTypes.find(TypeETT);
    muonTypes.erase(typeIter);
    typeIter=muonTypes.find(TypeHTT);
    muonTypes.erase(typeIter);
    typeIter=muonTypes.find(TypeJetCounts);
    muonTypes.erase(typeIter);

    std::map<L1GtConditionType,std::string> caloTypes = muonTypes;
    typeIter=caloTypes.find(Type3s);
    caloTypes.erase(typeIter);

    // dummy type in order to be able to use the same code as for calo and muon
    // this map is also used for esums since there is no difference in treatment 
    std::map<L1GtConditionType,std::string> jetCountsTypes;
    jetCountsTypes[TypeJetCounts] = "";

    // here the DefValuesBuffer are build (=objects of the class L1GtVhdlTemplateFile
    // that are containing all default values and finally can be inserted into the
    // def_val_pkg.vhd template

    buildDefValuesBuffer(muonDefValuesBuffer, muonTypes, muonDefValTypes, Mu);

    // loop over all possible calo objects here
    for (unsigned int i=0; i<caloObjects_.size(); i++)
    {
        buildDefValuesBuffer(caloDefValuesBuffer, caloTypes, caloDefValTypes,
                caloObjects_.at(i));
    }

    // loop over all possible esums objects here
    for (unsigned int i=0; i<esumObjects_.size(); i++)
    {
        buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes,
                esumsDefValTypes, esumObjects_.at(i));
    }

    // same procedure for jet counts
    buildDefValuesBuffer(esumsDefValBuffer, jetCountsTypes,
            jetCountsDefValTypes, JetCounts);

    //----------------------In this section the actual output file is written----------------

    // now open the actual template file:

    std::string filename = vhdlTemplateDefValPkg_;

    std::string outputFile = filename;

    // modify output filename
    L1GtVhdlTemplateFile::findAndReplaceString(outputFile, ".", int2str(chip)
            +".");
    L1GtVhdlTemplateFile defValTemplate = openVhdlFileWithCommonHeader(
            filename, outputFile);

    // insert the temporary buffers to the template

    // muon default values
    defValTemplate.insert(sp(substParamMuonDefVals_), muonDefValuesBuffer);

    // calo default values
    defValTemplate.insert(sp(substParamCaloDefVals_), caloDefValuesBuffer);

    // esums default values
    defValTemplate.insert(sp(substParamEsumsDefVals_), esumsDefValBuffer);

    // jet counts default values
    defValTemplate.insert(sp(substParamJetsDefVals_), jetCountsDefValuesBuffer);

    // close and save the file
    
    L1GtVhdlTemplateFile::findAndReplaceString(outputFile, "1","");
    L1GtVhdlTemplateFile::findAndReplaceString(outputFile, "2","");
    
    defValTemplate.save(chip2OutputSubDir(chip)+outputFile);
    chmod((chip2OutputSubDir(chip)+outputFile).c_str(), 0666);

}
void L1GtVhdlWriterCore::writeEtmSetup ( std::string &  etmString,
const int &  condChip 
)

builds etm setup files

Definition at line 1289 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), lut2db_cfg::filename, L1GtVhdlTemplateFile::findAndReplaceString(), int2str(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::save(), L1GtVhdlTemplateFile::substitute(), and L1GtVhdlDefinitions::vhdlTemplateEtmSetup_.

Referenced by makeFirmware().

{

    // get filename
    std::string filename= vhdlTemplateEtmSetup_;
    std::string outputFile = filename;

    L1GtVhdlTemplateFile myTemplate;

    // modify output filename
    myTemplate.findAndReplaceString(outputFile, ".", int2str(condChip)+".");

    myTemplate = openVhdlFileWithCommonHeader(filename, filename);

    // replace all occurances of $(particle)
    while (myTemplate.substitute("particle", "etm"))
        while (myTemplate.substitute("particle", "etm"))
            ;

    // delete last char if it is \n
    if (etmString[etmString.length()-1] == '\n')
        etmString = etmString.substr(0, etmString.length()-1);

    myTemplate.substitute("phi", etmString);

    myTemplate.save(chip2OutputSubDir(condChip)+filename);
    chmod((chip2OutputSubDir(condChip)+filename).c_str(), 0666);

}
void L1GtVhdlWriterCore::writeMuonSetupVhdl ( std::map< std::string, std::string > &  muonParameters,
const std::string &  particle,
unsigned short int &  condChip 
)

builds muon setup files

Definition at line 1088 of file L1GtVhdlWriterCore.cc.

References L1GtVhdlTemplateFile::append(), chip2OutputSubDir(), lut2db_cfg::filename, L1GtVhdlTemplateFile::findAndReplaceString(), L1GtVhdlTemplateFile::getSubstitutionParametersFromTemplate(), i, L1GtVhdlTemplateFile::insert(), L1GtVhdlTemplateFile::open(), openVhdlFileWithCommonHeader(), download_sqlite_cfg::outputFile, L1GtVhdlTemplateFile::removeLineWithContent(), L1GtVhdlTemplateFile::returnParameterMap(), L1GtVhdlTemplateFile::save(), L1GtVhdlTemplateFile::substitute(), vhdlDir_, L1GtVhdlDefinitions::vhdlTemplateCaloSetup_, and L1GtVhdlDefinitions::vhdlTemplateMuonSetup_.

Referenced by makeFirmware().

{
    std::string filename;

    L1GtVhdlTemplateFile muonTemplate, internalTemplate, internalTemplateCopy;

    // choose the correct template file name
    if (particle=="muon")
    {
        filename = vhdlTemplateMuonSetup_;
        internalTemplate.open(vhdlDir_+"InternalTemplates/muonsetup", true);
    } else
    {
        filename = vhdlTemplateCaloSetup_;
        internalTemplate.open(vhdlDir_+"InternalTemplates/calosetup", true);
    }

    std::string outputFile;
    outputFile = filename;

    // modify filename
    if (particle!="muon")
        muonTemplate.findAndReplaceString(outputFile, "calo", particle);

    // add condition chip index to output filename
    //muonTemplate.findAndReplaceString(outputFile, ".", int2str(condChip)+".");

    // open the template file and insert header
    muonTemplate = openVhdlFileWithCommonHeader(filename, outputFile);

    std::map<std::string,std::string> parameterMap =
            internalTemplate.returnParameterMap();

    std::vector<std::string> substitutionParameters;

    // fills the map with all substitution parameters of the template file
    substitutionParameters=muonTemplate.getSubstitutionParametersFromTemplate();

    // insert a emty line at the end of each block
    internalTemplate.append("");

    std::map<std::string, std::string>::iterator iter;

    // loop over all substitution parameters that have been extracted from the template file
    for (unsigned int i=0; i<substitutionParameters.size(); i++)
    {
        // make a working copy of the template file
        internalTemplateCopy = internalTemplate;

        // choose which of the three constant template strings to take - only for calo!
        if (particle!="muon")
        {

            if (substitutionParameters.at(i).substr(0, 3) == "eta")
                internalTemplateCopy.substitute("constant", parameterMap["eta"]);
            else if (substitutionParameters.at(i).substr(0, 3) == "phi")
                internalTemplateCopy.substitute("constant", parameterMap["phi"]);
            else if (substitutionParameters.at(i).substr(0, 3) == "del"/*ta*/)
            {
                internalTemplateCopy.substitute("constant",
                        parameterMap["delta"]);
                while (internalTemplateCopy.substitute("delta",
                        substitutionParameters[i]))
                    internalTemplateCopy.substitute("delta",
                            substitutionParameters[i]);

            }
        }

        if (particle=="muon")
        {
        // final preparation of the internal template before it is inserted in the actual template file
        internalTemplateCopy.substitute("type", substitutionParameters[i]);
        } else
            
        {
            internalTemplateCopy.substitute("type", substitutionParameters[i].substr(4)); 
        }

        // subsitute the second occurance of type without "_l" and "_h"

        std::string paramCopy = substitutionParameters[i];

        internalTemplateCopy.findAndReplaceString(paramCopy, "_l", "");
        internalTemplateCopy.findAndReplaceString(paramCopy, "_h", "");

        internalTemplateCopy.substitute("type2", paramCopy);

        internalTemplateCopy.substitute("others",
                parameterMap[substitutionParameters[i]]);

        // replace all the occurances of "particle"
        while (muonTemplate.substitute("particle", particle))
            muonTemplate.substitute("particle", particle);

        // remove the the parameter $(content) if its empty
        iter=muonParameters.find(substitutionParameters[i]);

        // check weather this parameter exists
        if (iter!=muonParameters.end())
        {
            if ((*iter).second[(*iter).second.length()-1]=='\n')
                (*iter).second[(*iter).second.length()-1]=' ';
            internalTemplateCopy.substitute("content", (*iter).second);
        } else
            internalTemplateCopy.removeLineWithContent("$(content)");

        // insert the processed internal template in the muon template file
        muonTemplate.insert("$("+substitutionParameters[i]+")",
                internalTemplateCopy);
    }

    // save the muon template file
    muonTemplate.save(chip2OutputSubDir(condChip)+outputFile);
    chmod((chip2OutputSubDir(condChip)+outputFile).c_str(), 0666);

}
void L1GtVhdlWriterCore::writeQsfSetupFiles ( const std::string &  version)

builds the two quartus setup files. This routine is called in buildCommonHeader!

Definition at line 1330 of file L1GtVhdlWriterCore.cc.

References chip2OutputSubDir(), cmsPerfCommons::filenames, L1GtVhdlTemplateFile::findAndReplaceString(), i, L1GtVhdlTemplateFile::open(), L1GtVhdlDefinitions::quartusSetupFileChip1_, L1GtVhdlDefinitions::quartusSetupFileChip2_, L1GtVhdlTemplateFile::save(), L1GtVhdlTemplateFile::substitute(), and vhdlDir_.

Referenced by makeFirmware().

{

    std::vector<std::string> filenames;
    filenames.push_back(quartusSetupFileChip1_);
    filenames.push_back(quartusSetupFileChip2_);

    for (unsigned int i=0; i<filenames.size(); i++)
    {
        L1GtVhdlTemplateFile myTemplate;

        myTemplate.open(vhdlDir_+"Templates/"+filenames.at(i));
        myTemplate.substitute("version", version);

        std::string tempStr = filenames.at(i);
        
        if (i==0)
            L1GtVhdlTemplateFile::findAndReplaceString(tempStr , "cond1","cond");
        if (i==1)
            L1GtVhdlTemplateFile::findAndReplaceString(tempStr , "cond2","cond");
        
        myTemplate.save(chip2OutputSubDir(i+1)+tempStr);
        chmod((chip2OutputSubDir(i+1)+tempStr).c_str(), 0666);
    }

}

Member Data Documentation

algorithm map

Definition at line 199 of file L1GtVhdlWriterCore.h.

Referenced by makeFirmware().

list of all possible calo objects

Definition at line 214 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), initializeDeltaConditions(), L1GtVhdlWriterCore(), makeFirmware(), and writeDefValPkg().

std::map<L1GtObject,std::string> L1GtVhdlWriterCore::caloType2Int_ [private]

converts L1GtObject to calo_nr

Reimplemented from L1GtVhdlDefinitions.

Definition at line 208 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), and L1GtVhdlWriterCore().

common header for all files

Definition at line 231 of file L1GtVhdlWriterCore.h.

Referenced by buildCommonHeader(), openVhdlFileWithCommonHeader(), printCommonHeader(), and retrunCommonHeader().

const std::vector<ConditionMap>* L1GtVhdlWriterCore::conditionMap_ [private]

condition map

Definition at line 196 of file L1GtVhdlWriterCore.h.

Referenced by makeFirmware(), processAlgorithmMap(), and writeCond2intMap2File().

std::map<std::string,int> L1GtVhdlWriterCore::conditionToIntegerMap_ [private]
std::map<L1GtConditionType,std::string> L1GtVhdlWriterCore::condType2Str_ [private]

list of all possible esums objects

Definition at line 217 of file L1GtVhdlWriterCore.h.

Referenced by getCondChipVhdContentFromTriggerMenu(), L1GtVhdlWriterCore(), makeFirmware(), and writeDefValPkg().

std::vector<std::string> L1GtVhdlWriterCore::internMessageBuf_ [private]

Definition at line 233 of file L1GtVhdlWriterCore.h.

Referenced by getMsgBuf(), and msg().

std::vector<std::vector<std::string> > L1GtVhdlWriterCore::numberOfConditions_ [private]

vector containing the initialization of all conditions

Definition at line 236 of file L1GtVhdlWriterCore.h.

Referenced by addJetCountsToCond2IntMap(), countCondsAndAdd2NumberVec(), initializeDeltaConditions(), L1GtVhdlWriterCore(), and writeCondChipPkg().

std::map<L1GtObject,std::string> L1GtVhdlWriterCore::objType2Str_ [private]
std::string L1GtVhdlWriterCore::outputDir_ [private]

output directory

Definition at line 223 of file L1GtVhdlWriterCore.h.

Referenced by chip2OutputSubDir(), L1GtVhdlWriterCore(), and makeFirmware().

std::string L1GtVhdlWriterCore::version_ [private]

Definition at line 228 of file L1GtVhdlWriterCore.h.

Referenced by buildCommonHeader(), makeFirmware(), and writeCondChipPkg().

std::string L1GtVhdlWriterCore::vhdlDir_ [private]