CMS 3D CMS Logo

L1GtVmeWriterCore Class Reference

Description: core class to write the VME xml file. More...

#include <L1TriggerConfig/L1GtConfigProducers/interface/L1GtVmeWriterCore.h>

Inheritance diagram for L1GtVmeWriterCore:

L1GtXmlParserTags

List of all members.

Public Member Functions

std::string calculateAddress (const L1GtObject &obj, const L1GtConditionType &type, const std::string &reg, const int &index)
 calculates address
std::string calculateJetsAddress (const int &countIndex, const int &obj, const int &index)
 calculates addresses for jets counts
std::string closeTag (const std::string &tag)
 closes xml tag
int condIndex2reg (const unsigned int &index)
 conversion algorithm for condition index to hex value used to calculate address values
 L1GtVmeWriterCore (const std::string &outputDir, const std::string &vmeXmlFile)
 constructor
std::string openTag (const std::string &tag)
 opens a new xml tag
std::string spaces (const unsigned int &level)
 returns a string containing spaces dependant on level
std::string vmeAddrValueBlock (const std::string &addr, const int &val, const int &spaceLevel, const bool setMsb=false)
 builds a address value block
void writeVME (const std::vector< ConditionMap > &conditionMap, std::map< std::string, int > cond2intMap, L1GtVhdlTemplateFile header, const int spacesPerLevel=2)
virtual ~L1GtVmeWriterCore ()
 destructor

Private Attributes

std::map< int, intjetObj2reg_
std::map< int, intjetType2reg_
std::string m_outputDir
 output directory
std::string m_vmeXmlFile
 output file
std::map< L1GtObject, intobject2reg_
std::map< std::string, intreg2hex_
int spacesPerLevel_
std::map< L1GtConditionType, inttype2reg_


Detailed Description

Description: core class to write the VME xml file.

Implementation: Core class to write the VME xml file: L1GtVmeWriter is an EDM wrapper for this class. L1GtVmeWriterCore can also be used in L1 Trigger Supervisor framework, with another wrapper - it must be therefore EDM-framework free.

Author:
: Vasile Mihai Ghete - HEPHY Vienna
Date
2008/02/27 21:18:53
Revision
1.3

Implementation: Core class to write the VME xml file: L1GtVmeWriter is an EDM wrapper for this class. L1GtVmeWriterCore can also be used in L1 Trigger Supervisor framework, with another wrapper - it must be therefore EDM-framework free.

Author:
: Vasile Mihai Ghete - HEPHY Vienna
Date
2008/02/27 21:18:29
Revision
1.3

Definition at line 36 of file L1GtVmeWriterCore.h.


Constructor & Destructor Documentation

L1GtVmeWriterCore::L1GtVmeWriterCore ( const std::string &  outputDir,
const std::string &  vmeXmlFile 
)

constructor

Definition at line 41 of file L1GtVmeWriterCore.cc.

References CenJet, ETM, ETT, ForJet, HTT, IsoEG, jetObj2reg_, jetType2reg_, L1GtXmlParserTags::m_xmlTagChargeCorrelation, L1GtXmlParserTags::m_xmlTagEtThreshold, L1GtXmlParserTags::m_xmlTagPtHighThreshold, L1GtXmlParserTags::m_xmlTagPtLowThreshold, L1GtXmlParserTags::m_xmlTagQuality, Mu, NoIsoEG, object2reg_, reg2hex_, spacesPerLevel_, TauJet, Type1s, type2reg_, Type2s, Type2wsc, Type3s, Type4s, TypeETM, TypeETT, and TypeHTT.

00042                                      :
00043     m_outputDir(outputDir), m_vmeXmlFile(vmeXmlFile)
00044 {
00045 
00046     object2reg_[Mu]=0x00A0000;
00047     object2reg_[NoIsoEG]=0x0020000;
00048     object2reg_[IsoEG]=0x0000000;
00049     object2reg_[ForJet]=0x0080000;
00050     object2reg_[TauJet]=0x0060000;
00051     object2reg_[CenJet]=0x0040000;
00052     object2reg_[HTT]=0x0100000;
00053     object2reg_[ETT]=0x0100000;
00054     object2reg_[ETM]=0x0100000;
00055 
00056     type2reg_[Type1s]=0x000C000;
00057     type2reg_[Type2s]=0x0004000;
00058     type2reg_[Type2wsc]=0x0008000;
00059     type2reg_[Type3s]=0x0010000;
00060     type2reg_[Type4s]=0x0000000;
00061     type2reg_[TypeETM]=0x0004000;
00062     type2reg_[TypeETT]=0x0000000;
00063     type2reg_[TypeHTT]=0x0008000;
00064 
00065     reg2hex_[m_xmlTagEtThreshold+"_1"]=0x0000000;
00066     reg2hex_[m_xmlTagEtThreshold+"_2"]=0x0000002;
00067     reg2hex_[m_xmlTagEtThreshold+"_3"]=0x0000004;
00068     reg2hex_[m_xmlTagEtThreshold+"_4"]=0x0000006;
00069     reg2hex_[m_xmlTagPtHighThreshold+"_1"]=0x0000000;
00070     reg2hex_[m_xmlTagPtHighThreshold+"_2"]=0x0000002;
00071     reg2hex_[m_xmlTagPtHighThreshold+"_3"]=0x0000004;
00072     reg2hex_[m_xmlTagPtHighThreshold+"_4"]=0x0000006;
00073     reg2hex_[m_xmlTagQuality+"_1"]=0x0000050;
00074     reg2hex_[m_xmlTagQuality+"_2"]=0x0000052;
00075     reg2hex_[m_xmlTagQuality+"_3"]=0x0000054;
00076     reg2hex_[m_xmlTagQuality+"_4"]=0x0000056;
00077     reg2hex_[m_xmlTagPtLowThreshold+"_1"]=0x0000058;
00078     reg2hex_[m_xmlTagPtLowThreshold+"_2"]=0x000005A;
00079     reg2hex_[m_xmlTagPtLowThreshold+"_3"]=0x000005C;
00080     reg2hex_[m_xmlTagPtLowThreshold+"_4"]=0x000005E;
00081     reg2hex_[m_xmlTagChargeCorrelation]=0x000008A;
00082     reg2hex_["jet_cnt_threshold"]=0x0000000;
00083     reg2hex_["threshold_lsb"]=0x0000000;
00084     reg2hex_["threshold_msb"]=0x0000002;
00085 
00086     // sepcial maps for jet counts
00087     jetType2reg_[0]=0x0000000;
00088     jetType2reg_[1]=0x0004000;
00089     jetType2reg_[2]=0x0008000;
00090     jetType2reg_[3]=0x000C000;
00091     jetType2reg_[4]=0x0010000;
00092     jetType2reg_[5]=0x0014000;
00093 
00094     jetObj2reg_[0]=0x00C0000;
00095     jetObj2reg_[1]=0x00E0000;
00096     
00097     spacesPerLevel_ = 2;
00098 
00099 }

L1GtVmeWriterCore::~L1GtVmeWriterCore (  )  [virtual]

destructor

Definition at line 102 of file L1GtVmeWriterCore.cc.

00103 {
00104 
00105     // empty now
00106 
00107 }


Member Function Documentation

std::string L1GtVmeWriterCore::calculateAddress ( const L1GtObject obj,
const L1GtConditionType type,
const std::string &  reg,
const int index 
)

calculates address

Definition at line 131 of file L1GtVmeWriterCore.cc.

References condIndex2reg(), object2reg_, reg2hex_, HLT_VtxMuL3::result, and type2reg_.

Referenced by writeVME().

00133 {
00134 
00135     int result = object2reg_[obj]+ type2reg_[type]+ reg2hex_[reg]
00136             +condIndex2reg(index);
00137 
00138     std::bitset<25> bs(result);
00139 
00140     std::ostringstream buffer;
00141     buffer<<bs;
00142     return buffer.str();
00143 
00144 }

std::string L1GtVmeWriterCore::calculateJetsAddress ( const int countIndex,
const int obj,
const int index 
)

calculates addresses for jets counts

Definition at line 117 of file L1GtVmeWriterCore.cc.

References condIndex2reg(), jetObj2reg_, jetType2reg_, reg2hex_, and HLT_VtxMuL3::result.

Referenced by writeVME().

00119 {
00120     int result = jetType2reg_[countIndex] + jetObj2reg_[obj]
00121             + reg2hex_["jet_cnt_threshold"] +condIndex2reg(index);
00122 
00123     std::bitset<24> bs(result);
00124 
00125     std::ostringstream buffer;
00126     buffer<<bs;
00127 
00128     return buffer.str();
00129 }

std::string L1GtVmeWriterCore::closeTag ( const std::string &  tag  ) 

closes xml tag

Definition at line 152 of file L1GtVmeWriterCore.cc.

Referenced by vmeAddrValueBlock(), and writeVME().

00153 {
00154     return "</"+tag+">\n";
00155 }

int L1GtVmeWriterCore::condIndex2reg ( const unsigned int index  ) 

conversion algorithm for condition index to hex value used to calculate address values

Definition at line 109 of file L1GtVmeWriterCore.cc.

Referenced by calculateAddress(), and calculateJetsAddress().

00110 {
00111     int indexcp = index;
00112 
00113     return (indexcp << 8);
00114 
00115 }

std::string L1GtVmeWriterCore::openTag ( const std::string &  tag  ) 

opens a new xml tag

Definition at line 147 of file L1GtVmeWriterCore.cc.

Referenced by vmeAddrValueBlock(), and writeVME().

00148 {
00149     return "<"+tag+">\n";
00150 }

std::string L1GtVmeWriterCore::spaces ( const unsigned int level  ) 

returns a string containing spaces dependant on level

Definition at line 178 of file L1GtVmeWriterCore.cc.

References i, and spacesPerLevel_.

Referenced by vmeAddrValueBlock(), and writeVME().

00179 {
00180     std::ostringstream buffer;
00181 
00182     for (unsigned int i=0; i<(level*spacesPerLevel_); i++)
00183     {
00184         buffer<<" ";
00185     }
00186 
00187     return buffer.str();
00188 
00189 }

std::string L1GtVmeWriterCore::vmeAddrValueBlock ( const std::string &  addr,
const int val,
const int spaceLevel,
const bool  setMsb = false 
)

builds a address value block

Definition at line 157 of file L1GtVmeWriterCore.cc.

References closeTag(), lat::endl(), L1GtXmlParserTags::m_xmlTagValue, L1GtXmlParserTags::m_xmlTagVmeAddress, openTag(), and spaces().

Referenced by writeVME().

00159 {
00160     std::ostringstream buffer;
00161 
00162     std::bitset<8> bsVal(val);
00163 
00164     if (setMsb)
00165         bsVal.set(7);
00166 
00167     buffer << spaces(spaceLevel) << openTag(m_xmlTagVmeAddress)
00168             << spaces(spaceLevel+1) << addr << std::endl
00169             << spaces(spaceLevel+1) << openTag(m_xmlTagValue)
00170             << spaces(spaceLevel+1) << bsVal <<std::endl
00171             << spaces(spaceLevel+1) << closeTag(m_xmlTagValue)
00172             << spaces(spaceLevel) << closeTag(m_xmlTagVmeAddress);
00173 
00174     return buffer.str();
00175 
00176 }

void L1GtVmeWriterCore::writeVME ( const std::vector< ConditionMap > &  conditionMap,
std::map< std::string, int cond2intMap,
L1GtVhdlTemplateFile  header,
const int  spacesPerLevel = 2 
)

Definition at line 191 of file L1GtVmeWriterCore.cc.

References asciidump::at, calculateAddress(), calculateJetsAddress(), closeTag(), CondCalo, CondCorrelation, CondEnergySum, CondJetCounts, CondMuon, CondNull, L1GtMuonTemplate::correlationParameter(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), aod_PYTHIA_cfg::fileName, i, index, L1GtVhdlWriterCore::int2str(), m_outputDir, m_vmeXmlFile, L1GtXmlParserTags::m_xmlConditionAttrObject, L1GtXmlParserTags::m_xmlConditionAttrType, L1GtXmlParserTags::m_xmlTagChargeCorrelation, L1GtXmlParserTags::m_xmlTagChip, L1GtXmlParserTags::m_xmlTagHeader, L1GtXmlParserTags::m_xmlTagPtHighThreshold, L1GtXmlParserTags::m_xmlTagPtLowThreshold, L1GtXmlParserTags::m_xmlTagQuality, L1GtXmlParserTags::m_xmlTagVme, maps, Mu, VarParsing::obj, L1GtVhdlDefinitions::obj2str(), L1GtJetCountsTemplate::objectParameter(), L1GtCaloTemplate::objectParameter(), L1GtMuonTemplate::objectParameter(), L1GtEnergySumTemplate::objectParameter(), openTag(), L1GtVhdlTemplateFile::removeEmptyLines(), L1GtVhdlTemplateFile::returnLines(), spaces(), spacesPerLevel_, L1GtVhdlTemplateFile::substitute(), L1GtVhdlDefinitions::type2str(), and vmeAddrValueBlock().

Referenced by L1GtVhdlWriter::analyze().

00193 {
00194 
00195     L1GtVhdlDefinitions maps;
00196     
00197     // define appearance
00198     spacesPerLevel_ = spacesPerLevel;
00199 
00200     std::string fileName = m_outputDir+m_vmeXmlFile;
00201 
00202     // open output file
00203     std::ofstream outputFile(fileName.c_str());
00204 
00205     // begin of VME XML
00206     outputFile << "<" << m_xmlTagVme << ">" << std::endl;
00207 
00208     // insert header
00209     outputFile << spaces(1) << openTag(m_xmlTagHeader);
00210     header.substitute("vhdl_file_name", m_vmeXmlFile);
00211     header.removeEmptyLines();
00212 
00213     std::vector<std::string> lines = header.returnLines();
00214 
00215     for (unsigned int i = 0; i< lines.size(); i++)
00216     {
00217         outputFile << spaces(2)<<lines.at(i);
00218         //if (i!=lines.size()-1)
00219         outputFile<<std::endl;
00220     }
00221 
00222     outputFile << spaces(1) << closeTag(m_xmlTagHeader);
00223 
00224     // loop over chips
00225     for (unsigned int index=1; index<=2; index++)
00226     {
00227         outputFile << spaces(1) <<"<" << m_xmlTagChip << index <<">"
00228                 << std::endl;
00229 
00230         // loop over condition map
00231         for (ConditionMap::const_iterator iterCond = conditionMap.at(index-1).begin(); iterCond != conditionMap.at(index-1).end(); iterCond++)
00232         {
00233 
00234             // open a condition
00235             outputFile << spaces(2) << "<" << iterCond->first << " "
00236                     << m_xmlConditionAttrObject <<"=\"" << maps.obj2str((iterCond->second->objectType())[0])<<"\" " <<m_xmlConditionAttrType <<"=\""
00237                     << maps.type2str(iterCond->second->condType())<< "\">"
00238                     <<std::endl;
00239 
00240             switch ((iterCond->second)->condCategory())
00241             {
00242 
00243             case CondMuon:
00244             {
00245 
00246                 L1GtMuonTemplate* muonTemplate =
00247                         static_cast<L1GtMuonTemplate*>(iterCond->second);
00248                 const std::vector<L1GtMuonTemplate::ObjectParameter>* op =
00249                         muonTemplate->objectParameter();
00250 
00251                 // get the number of objects
00252                 unsigned int nObjects = iterCond->second->nrObjects();
00253 
00254                 for (unsigned int i =0; i<nObjects; i++)
00255                 {
00256 
00257                     std::string opi = L1GtVhdlWriterCore::int2str(i);
00258 
00259                     // ptHighTreshold
00260                     std::string address = calculateAddress(Mu, (iterCond->second)->condType(),
00261                             (m_xmlTagPtHighThreshold+"_"+opi),
00262                             cond2intMap[iterCond->first]);
00263 
00264                     outputFile << spaces(3) << openTag(m_xmlTagPtHighThreshold)
00265                             <<vmeAddrValueBlock(address, (*op).at(i).ptHighThreshold, 4,iterCond->second->condGEq()) << spaces(3)
00266                             << closeTag(m_xmlTagPtHighThreshold);
00267 
00268                     // ptLow Threshold
00269                     address = calculateAddress(Mu, (iterCond->second)->condType(),
00270                             (m_xmlTagPtLowThreshold+"_"+opi),
00271                             cond2intMap[iterCond->first]);
00272 
00273                     outputFile << spaces(3) << openTag(m_xmlTagPtLowThreshold)
00274                             <<vmeAddrValueBlock(address, (*op).at(i).ptLowThreshold, 4, iterCond->second->condGEq()) << spaces(3)
00275                             <<closeTag(m_xmlTagPtLowThreshold);
00276 
00277                     // Quality
00278                     address = calculateAddress(Mu, (iterCond->second)->condType(), (m_xmlTagQuality+"_"
00279                             +opi), cond2intMap[iterCond->first]);
00280 
00281                     outputFile << spaces(3) << openTag(m_xmlTagQuality)
00282                             << vmeAddrValueBlock(address, (*op).at(i).qualityRange, 4) << spaces(3)
00283                             << closeTag(m_xmlTagQuality);
00284 
00285                 }
00286 
00287                 const L1GtMuonTemplate::CorrelationParameter *cp =
00288                         muonTemplate->correlationParameter();
00289 
00290                 // Charage correlation -  occurs only one time
00291                 outputFile << spaces(3)<< openTag(m_xmlTagChargeCorrelation);
00292 
00293                 std::string address = calculateAddress(Mu, (iterCond->second)->condType(),
00294                         (m_xmlTagChargeCorrelation),
00295                         cond2intMap[iterCond->first]);
00296 
00297                 outputFile << vmeAddrValueBlock(address, (*cp).chargeCorrelation, 4) << spaces(3)
00298                         << closeTag(m_xmlTagChargeCorrelation);
00299 
00300             }
00301                 break;
00302 
00303             case CondCalo:
00304             {
00305 
00306                 L1GtCaloTemplate* m_gtCaloTemplate =
00307                         static_cast<L1GtCaloTemplate*>(iterCond->second);
00308                 const std::vector<L1GtCaloTemplate::ObjectParameter>* op =
00309                         m_gtCaloTemplate->objectParameter();
00310 
00311                 // get the number of objects
00312                 unsigned int nObjects = iterCond->second->nrObjects();
00313 
00314                 for (unsigned int i =0; i<nObjects; i++)
00315                 {
00316 
00317                     std::string opi = L1GtVhdlWriterCore::int2str(i);
00318                     std::string address = calculateAddress((iterCond->second->objectType()).at(0), (iterCond->second)->condType(),
00319                             (m_xmlTagPtHighThreshold+"_"+opi),
00320                             cond2intMap[iterCond->first]);
00321 
00322                     // insert Address/Value Tag
00323                     outputFile<<vmeAddrValueBlock(address, (*op).at(i).etThreshold, 3, iterCond->second->condGEq());
00324 
00325                 }
00326 
00327             }
00328                 break;
00329 
00330             case CondEnergySum:
00331             {
00332 
00333                 L1GtEnergySumTemplate* energySumTempl =
00334                         static_cast<L1GtEnergySumTemplate*>(iterCond->second);
00335 
00336                 const std::vector<L1GtEnergySumTemplate::ObjectParameter>* op =
00337                         energySumTempl->objectParameter();
00338 
00339                 // get the number of objects
00340                 unsigned int nObjects = iterCond->second->nrObjects();
00341 
00342                 for (unsigned int i =0; i<nObjects; i++)
00343                 {
00344 
00345                     std::string opi = L1GtVhdlWriterCore::int2str(i);
00346 
00347                     std::string address = calculateAddress((iterCond->second->objectType()).at(0), (iterCond->second)->condType(),
00348                             (m_xmlTagPtHighThreshold+"_"+opi),
00349                             cond2intMap[iterCond->first]);
00350 
00351                     // insert Address/Value Tag
00352                     outputFile<<vmeAddrValueBlock(address, (*op).at(i).etThreshold, 3,iterCond->second->condGEq());
00353 
00354                 }
00355 
00356             }
00357 
00358                 break;
00359 
00360             case CondJetCounts:
00361             {
00362 
00363                 L1GtJetCountsTemplate* jetsTemplate =
00364                         static_cast<L1GtJetCountsTemplate*>(iterCond->second);
00365                 const std::vector<L1GtJetCountsTemplate::ObjectParameter>* op =
00366                         jetsTemplate->objectParameter();
00367 
00368                 // get the number of objects
00369                 // unsigned int nObjects = iterCond->second->nrObjects();
00370 
00371                 // count index
00372                 int ci = (*op)[0].countIndex;
00373 
00374                 // 0 for count index 0-5 and 1 for count index 6 - 11
00375                 int obj;
00376 
00377                 if (ci<=5)
00378                     obj=0;
00379                 else
00380                     obj=1;
00381 
00382                 std::string address = calculateJetsAddress(ci, obj,
00383                         cond2intMap[iterCond->first]);
00384 
00385                 outputFile<<vmeAddrValueBlock(address, (*op).at(0).countThreshold, 3, iterCond->second->condGEq());
00386 
00387             }
00388                 break;
00389             case CondCorrelation:
00390             {
00391                 // empty
00392             }
00393                 break;
00394 
00395             case CondNull:
00396             {
00397                 // empty
00398             }
00399                 break;
00400 
00401             default:
00402             {
00403                 // empty
00404             }
00405                 break;
00406 
00407             }
00408 
00409             // close the condition
00410             outputFile << spaces(2)<< closeTag(iterCond->first);
00411 
00412         }
00413 
00414         outputFile << spaces(1) << "</" << m_xmlTagChip << index<<">"
00415                 <<std::endl;
00416 
00417     }
00418 
00419     // end of vme XML
00420     outputFile <<closeTag(m_xmlTagVme);
00421 
00422     // close output file
00423     outputFile.close();
00424 
00425     std::cout << std::endl <<"*******   VME XML File: "<< m_outputDir
00426             << m_vmeXmlFile << " written sucessfully!  *******"<<std::endl;
00427 
00428 }


Member Data Documentation

std::map<int,int> L1GtVmeWriterCore::jetObj2reg_ [private]

Definition at line 93 of file L1GtVmeWriterCore.h.

Referenced by calculateJetsAddress(), and L1GtVmeWriterCore().

std::map<int,int> L1GtVmeWriterCore::jetType2reg_ [private]

Definition at line 91 of file L1GtVmeWriterCore.h.

Referenced by calculateJetsAddress(), and L1GtVmeWriterCore().

std::string L1GtVmeWriterCore::m_outputDir [private]

output directory

Definition at line 80 of file L1GtVmeWriterCore.h.

Referenced by writeVME().

std::string L1GtVmeWriterCore::m_vmeXmlFile [private]

output file

Definition at line 83 of file L1GtVmeWriterCore.h.

Referenced by writeVME().

std::map<L1GtObject,int> L1GtVmeWriterCore::object2reg_ [private]

Definition at line 85 of file L1GtVmeWriterCore.h.

Referenced by calculateAddress(), and L1GtVmeWriterCore().

std::map<std::string,int> L1GtVmeWriterCore::reg2hex_ [private]

Definition at line 89 of file L1GtVmeWriterCore.h.

Referenced by calculateAddress(), calculateJetsAddress(), and L1GtVmeWriterCore().

int L1GtVmeWriterCore::spacesPerLevel_ [private]

Definition at line 95 of file L1GtVmeWriterCore.h.

Referenced by L1GtVmeWriterCore(), spaces(), and writeVME().

std::map<L1GtConditionType,int> L1GtVmeWriterCore::type2reg_ [private]

Definition at line 87 of file L1GtVmeWriterCore.h.

Referenced by calculateAddress(), and L1GtVmeWriterCore().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:26:47 2009 for CMSSW by  doxygen 1.5.4