Atlfast::EPileupMap Class Reference

Simple std::vector containing EPileupDeposit. More...

#include <EPileupMap.h>

Collaboration diagram for Atlfast::EPileupMap:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EPileupMap (int)
 ~EPileupMap ()
void fillMap ()
std::vector< EPileupDeposit * > * getEMMap () const
std::vector< EPileupDeposit * > * getHadMap () const

Private Member Functions

void makeCellMap ()
void setInputFile ()
void emptyMap ()

Private Attributes

std::vector< EPileupDeposit * > * m_hadPileupMap
std::vector< EPileupDeposit * > * m_emPileupMap
std::map< int, double > * m_phiMap
std::map< int, double > * m_etaMap
std::string m_pileupFile
std::string m_fileDir
int m_nFiles

Detailed Description

Simple std::vector containing EPileupDeposit.

Can randomly select a file to read in and fill vector with EPileupDeposits calculating its eta and phi from the code given.

Author:
Jon Couchman

Definition at line 40 of file EPileupMap.h.


Constructor & Destructor Documentation

Atlfast::EPileupMap::EPileupMap ( int   ) 

Constructor

Set input epileup file directory and number of files in directory depending on the luminosity

Construnt maps relating the cell ids to etas and phis

Definition at line 13 of file EPileupMap.cxx.

00013                                       {
00014     m_emPileupMap = new std::vector<EPileupDeposit*>;
00015     m_hadPileupMap = new std::vector<EPileupDeposit*>;
00016     
00019     if (luminosity == 1){
00020       m_nFiles = 10401;
00021       m_fileDir = "allfiles_ll/";
00022     }else if (luminosity == 2){
00023       m_nFiles = 10830;
00024       m_fileDir = "allfiles_hl/";
00025     }
00027     this->makeCellMap();
00028   }

Atlfast::EPileupMap::~EPileupMap (  ) 

Destructor

Definition at line 30 of file EPileupMap.cxx.

00030                          {
00031     this->emptyMap();
00032     delete m_emPileupMap;
00033     delete m_hadPileupMap;
00034     delete m_phiMap;
00035     delete m_etaMap;
00036   }


Member Function Documentation

void Atlfast::EPileupMap::fillMap (  ) 

Fills vector m_map with new EPileupDeposits from a text file. Deletes any deposits in vector before it fills it with the new ones

Clear map and delete all the EpileupDeposits in it

Set m_pileupFile using random nember generator

Open input file

find whether EM or HAD deposit

Set eta and phi codes from single code read in

Convert eT from MeV to GeV

Put new EPileupDeposit in EM vector

Put new EPileupDeposit in HAD vector

Definition at line 39 of file EPileupMap.cxx.

00039                           {
00041     this->emptyMap();
00043     this->setInputFile();
00044 
00045     std::ifstream input;
00047     input.open( m_pileupFile.c_str());
00048     if (input) {
00049       int code;
00050       double energy;
00051       while (input >> code && input >> energy){
00052         if (code > 0){ 
00053           std::string type;
00055           int intType = code/100000;
00057           int eta = (code - intType*100000)/100;
00058           int phi =  code - intType*100000 - eta*100;
00060           double et = energy*GeV;
00061 
00062           if(intType == 1){
00064             m_emPileupMap->
00065               push_back(
00066                         new EPileupDeposit(
00067                                            (m_etaMap->find(eta))->second,
00068                                            (m_phiMap->find(phi))->second,
00069                                            et)
00070                         );
00071           }//if(intType == 1)
00072           
00073           if(intType == 2){
00075             m_hadPileupMap->
00076               push_back(
00077                         new EPileupDeposit(
00078                                            (m_etaMap->find(eta))->second,
00079                                            (m_phiMap->find(phi))->second,
00080                                            et
00081                                            )
00082                         );
00083           }//if(intType == 2)
00084           
00085         }
00086         
00087       }
00088     }else{
00089       std::cout << "ERROR! COULD NOT OPEN EPILEUP FILE " 
00090                 << m_pileupFile << std::endl;
00091     } 
00092     return;
00093   }

std::vector<EPileupDeposit*>* Atlfast::EPileupMap::getEMMap (  )  const [inline]

Returns std::vector of EPileupDeposits

Definition at line 50 of file EPileupMap.h.

00050 {return m_emPileupMap;}

std::vector<EPileupDeposit*>* Atlfast::EPileupMap::getHadMap (  )  const [inline]

Returns std::vector of EPileupDeposits

Definition at line 52 of file EPileupMap.h.

00052 {return m_hadPileupMap;}

void Atlfast::EPileupMap::makeCellMap (  )  [private]

Makes two maps relating cell ids to eta and phi positions

Maybe these should be setable member variables. As we only have one set of maps at the moment, it would be dangerous for user to fiddle with these

Definition at line 113 of file EPileupMap.cxx.

00113                               {
00114     m_phiMap = new std::map<int,double> ;
00115     m_etaMap = new std::map<int,double> ;
00119     int EtaCells = 100;
00120     double EtaRange = 10;
00121     int PhiCells = 64;
00122     double PhiRange = 2*3.1415;
00123     for (int i = 1 ; i <= EtaCells; ++i){
00124       m_etaMap->
00125         insert(std::pair<int,double>(i,
00126                                      (i-(EtaCells/2))/(EtaCells/EtaRange)-
00127                                       EtaRange/(EtaCells*2.0) 
00128                                      )
00129                );
00130     }
00131     for (int i = 1 ; i <= PhiCells; ++i){
00132       m_phiMap->
00133         insert(std::pair<int,double>(i,
00134                                      (i-(PhiCells/2))/(PhiCells/PhiRange)-
00135                                      PhiRange/(PhiCells*2.0)
00136                                      )
00137                ) ;
00138     }
00139     return;
00140   }

void Atlfast::EPileupMap::setInputFile (  )  [private]

Uses a random number to set the value of m_pileupFile

Definition at line 144 of file EPileupMap.cxx.

00144                                {
00145     double max = RAND_MAX; 
00146     int i = (int)(rand()/max*m_nFiles);
00147     if(i < 10){
00148       m_pileupFile = m_fileDir + "part0000" + numberToString(i);
00149      } else if(i < 100){
00150        m_pileupFile = m_fileDir + "part000" + numberToString(i);
00151      } else if(i < 1000){
00152        m_pileupFile = m_fileDir + "part00" + numberToString(i);
00153      } else if(i < 10000){
00154        m_pileupFile = m_fileDir + "part0" + numberToString(i);
00155      } else {
00156        m_pileupFile = m_fileDir + "part" + numberToString(i);
00157      }
00158 
00159     m_pileupFile = PathResolver::find_file(m_pileupFile, "DATAPATH");
00160 
00161     return;
00162   }

void Atlfast::EPileupMap::emptyMap (  )  [private]

Tidies up m_map

Definition at line 95 of file EPileupMap.cxx.

00095                            {
00096     if (m_emPileupMap->size()){
00097       std::vector<EPileupDeposit*>::iterator itr=m_emPileupMap->begin();
00098       for (; itr != m_emPileupMap->end();++itr){
00099         delete (*itr);
00100       }
00101     m_emPileupMap->clear();
00102     }
00103     if (m_hadPileupMap->size()){
00104       std::vector<EPileupDeposit*>::iterator itr=m_hadPileupMap->begin();
00105       for (; itr != m_hadPileupMap->end();++itr){
00106         delete (*itr);
00107       }
00108     m_hadPileupMap->clear();
00109     }
00110     return;
00111   }


Member Data Documentation

std::vector<EPileupDeposit*>* Atlfast::EPileupMap::m_hadPileupMap [private]

std::vector containg the EPileupDeposits

Definition at line 62 of file EPileupMap.h.

std::vector<EPileupDeposit*>* Atlfast::EPileupMap::m_emPileupMap [private]

std::vector containg the EPileupDeposits

Definition at line 64 of file EPileupMap.h.

std::map<int,double>* Atlfast::EPileupMap::m_phiMap [private]

std::map relating cell id to phi position

Definition at line 66 of file EPileupMap.h.

std::map<int,double>* Atlfast::EPileupMap::m_etaMap [private]

std::map relating cell id to eta position

Definition at line 68 of file EPileupMap.h.

std::string Atlfast::EPileupMap::m_pileupFile [private]

Name of input text file containg the EPileup values

Definition at line 70 of file EPileupMap.h.

std::string Atlfast::EPileupMap::m_fileDir [private]

Name of directory containg input files

Definition at line 72 of file EPileupMap.h.

int Atlfast::EPileupMap::m_nFiles [private]

Number of files in m_fileDir

Definition at line 74 of file EPileupMap.h.


The documentation for this class was generated from the following files:
Generated on Mon Sep 24 14:19:37 2007 for AtlfastAlgs by  doxygen 1.5.1