Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 #include "AtlfastAlgs/MuonMatrixManager.h"
002 #include "PathResolver/PathResolver.h"
003 #include <iostream>
004 
005 namespace Atlfast
006 {
007   using std::abs;
008   using std::ifstream;
009 
010 /** @brief Provides smear matrices corresponding to given track trajectories.
011    *
012    * Used by Atlfast::Tracksmearer. It reads a flat file containing smear matrix
013    * data and creates a BinData object for every eta/rT bin.
014    */
015 
016   //-----------------------------------------------------------
017   // PUBLIC: Constructor
018   //-----------------------------------------------------------
019   MuonMatrixManager::MuonMatrixManager( string paramFile, int randSeed, MsgStream log ) : 
020        m_file( paramFile ), 
021        m_randSeed( randSeed )
022   {
023     m_log = &log;
024     *m_log << MSG::INFO 
025            << "Constructing MuonMatrixManager with parameter file " 
026            << paramFile 
027            << endreq;
028     m_file = PathResolver::find_file( m_file, "DATAPATH" );
029     m_correlatedData = new CorrelatedData(randSeed);
030     this->initialise();
031     *m_log << MSG::INFO << "Constructed MuonMatrixManager" << endreq;
032   }
033   
034   
035   //-----------------------------------------------------------
036   // PUBLIC: Destructor
037   //-----------------------------------------------------------
038   MuonMatrixManager::~MuonMatrixManager()
039   {
040     delete m_correlatedData;
041 
042     map< BinID, IBinData* >::iterator iter = m_binData.begin();
043     map< BinID, IBinData* >::iterator end  = m_binData.end();
044     for ( ; iter != end; ++iter )  delete ( iter->second ); 
045   }
046   
047   //------------------------------------------------------------
048   // PRIVATE: initialise : read file and construct data bins
049   //------------------------------------------------------------
050   void MuonMatrixManager::initialise()
051   {
052     // open file
053     ifstream input;
054     input.open( m_file.c_str() );
055     
056     if (input) 
057     {
058       *m_log << MSG::INFO << "MuonMatrixManager: File " << m_file << " open." << endreq;
059       
060       double pTMin, etaMin, etaMax, rTBoundary;
061       
062       // read some parameters
063       input >> pTMin;
064       input >> etaMin;
065       input >> etaMax;
066       input >> m_nEtaBins;
067       input >> m_nRTBins;
068       
069       // construct vector<binboundaries>
070       double etaStep = ( etaMax - etaMin )/ double( m_nEtaBins );
071       for ( int i = 0; i < m_nEtaBins; i++ )
072       { 
073         m_etaBoundaries.push_back( etaMin + etaStep/2. + double(i)*etaStep );
074       }
075       for ( int i = 0; i < m_nRTBins + 1; i++ )
076       {
077         input >> rTBoundary;
078         m_rTBoundaries.push_back( rTBoundary );
079       }
080       
081       // parameters are stored in rT bin blocks----
082       // with parameters in format:
083       // Gaussian sigmas: 
084       //              C0(d0, z0, phi0, cot(theta0), q/pT), 
085       //              C1(d0, z0, phi0, cot(theta0), q/pT), etc.
086       // correlation coefficients rho: 
087       //              C0(rho(d0,phi0), rho(d0,q/pT), rho(phi0,q/pT), rho(z0,cot(theta0))), 
088       //              C1(rho(d0,phi0), rho(d0,q/pT), rho(phi0,q/pT), rho(z0,cot(theta0))), etc.
089       //
090       // coefficients C0,C1,C2,C3,C4 define pT-dependence of the respective quantities
091       // according to f(pT) = C0 + C1/sqrt(pT) + C2/pT + C3/pT/sqrt(pT) + C4/pT^2
092 
093       // start bin id ints at zero
094       int iBin = 0; 
095       
096       for ( int rt = 0; rt < m_nRTBins; rt++ )
097       {
098         // make vectors to hold all resolution parameters for this rt bin
099         vector<double> empty;
100         vector< vector<double> >  sigmaC0( m_nEtaBins, empty ); 
101         vector< vector<double> >  sigmaC1( m_nEtaBins, empty );
102         vector< vector<double> >  sigmaC2( m_nEtaBins, empty );
103         vector< vector<double> >  sigmaC3( m_nEtaBins, empty );
104         vector< vector<double> >  sigmaC4( m_nEtaBins, empty );
105         vector< vector<double> >  correlationsC0( m_nEtaBins, empty );
106         vector< vector<double> >  correlationsC1( m_nEtaBins, empty );
107         vector< vector<double> >  correlationsC2( m_nEtaBins, empty );
108         vector< vector<double> >  correlationsC3( m_nEtaBins, empty );
109         vector< vector<double> >  correlationsC4( m_nEtaBins, empty );
110         
111         // read eta bin number of values for each C and parameter
112         // read Gaussian sigmas
113         fillVector( input, sigmaC0, 5 );
114         fillVector( input, sigmaC1, 5 );
115         fillVector( input, sigmaC2, 5 );
116         fillVector( input, sigmaC3, 5 );
117         fillVector( input, sigmaC4, 5 );
118         // read correlations data
119         fillVector( input, correlationsC0, 4 );
120         fillVector( input, correlationsC1, 4 );
121         fillVector( input, correlationsC2, 4 );
122         fillVector( input, correlationsC3, 4 );
123         fillVector( input, correlationsC4, 4 );
124         
125         // DATA READING FINISHED FOR THIS RT BIN
126         // got all values, now make rT/eta bins and resolution objects
127         for ( int i = 0; i < m_nEtaBins - 1; ++i ) 
128         {         
129           double etaLow  = m_etaBoundaries[i];
130           double etaHigh = m_etaBoundaries[i+1];
131           
132           // make bin id with rT and eta boundaries
133           BinID rTEtaBin( iBin, m_rTBoundaries[rt], m_rTBoundaries[rt+1], etaLow, etaHigh );
134           
135           //make parameter resolutions for each parameter
136           vector<ParameterResolutions*> sigmas;
137           vector<ParameterResolutions*> correlations;
138           for ( int param = 0; param < 5; param++ ) 
139           {
140              vector<BinID> sigmaCoeffBins;
141              sigmaCoeffBins.push_back( BinID( 0, sigmaC0[i][param], sigmaC0[i+1][param] ) );
142              sigmaCoeffBins.push_back( BinID( 0, sigmaC1[i][param], sigmaC1[i+1][param] ) );
143              sigmaCoeffBins.push_back( BinID( 0, sigmaC2[i][param], sigmaC2[i+1][param] ) );
144              sigmaCoeffBins.push_back( BinID( 0, sigmaC3[i][param], sigmaC3[i+1][param] ) );
145              sigmaCoeffBins.push_back( BinID( 0, sigmaC4[i][param], sigmaC4[i+1][param] ) );
146              sigmas.push_back( new ParameterResolutions( sigmaCoeffBins, etaLow, etaHigh ) );
147           }
148           for ( int param = 0; param < 4; param++ ) 
149           {
150             vector<BinID> correlationsCoeffBins;
151             correlationsCoeffBins.push_back( BinID( 0, correlationsC0[i][param], correlationsC0[i+1][param]) );
152             correlationsCoeffBins.push_back( BinID( 0, correlationsC1[i][param], correlationsC1[i+1][param]) );
153             correlationsCoeffBins.push_back( BinID( 0, correlationsC2[i][param], correlationsC2[i+1][param]) );
154             correlationsCoeffBins.push_back( BinID( 0, correlationsC3[i][param], correlationsC3[i+1][param]) );
155             correlationsCoeffBins.push_back( BinID( 0, correlationsC4[i][param], correlationsC4[i+1][param]) );
156             correlations.push_back( new ParameterResolutions( correlationsCoeffBins, etaLow, etaHigh ) );
157           }
158           
159           // Now make a bin data with edges rT and eta, containing the 
160           // correlation data
161           MuonBinData* binData = new MuonBinData( rTEtaBin, sigmas, correlations );
162           
163           // enter bin data into map
164           m_binData[rTEtaBin] = binData;
165           
166           // increment bin ID
167           iBin++;
168           
169         } // end of eta bin loop
170       } // end of rT bin loop
171 
172       // close file
173       input.close();
174       
175     }
176     else  // no input file 
177     { 
178       *m_log << MSG::INFO 
179              << "MuonMatrixManager: no data file ( " << m_file << " )!!!!" 
180              << endreq;
181     }
182     
183     makeHeader();
184     
185   }
186   
187   void MuonMatrixManager::makeHeader()
188   {
189     HeaderPrinter hp( "Atlfast MuonTrack Smearer:", *m_log );
190     hp.add( "Total number of Bins     ", m_nRTBins * m_nEtaBins );
191     hp.add( "rT Bin Min               ", m_rTBoundaries.front() );        
192     hp.add( "rT Bin Max               ", m_rTBoundaries.back() );
193     hp.add( "Number of rT Bins        ", m_nRTBins );
194     hp.add( "Eta Bin Min              ", m_etaBoundaries.front() );        
195     hp.add( "Eta Bin Max              ", m_etaBoundaries.back() );
196     hp.add( "Number of Eta Bins       ", m_nEtaBins );
197     hp.print();
198   }
199   
200   //-----------------------------------------------------------
201   // PRIVATE: fillVector
202   //             reads n x M parameters into member variable
203   //-----------------------------------------------------------
204   void MuonMatrixManager::fillVector( ifstream& input, 
205                                         vector< vector<double> >& myVector, 
206                                         int M=5 )
207   {
208     double res;
209     for ( int param = 0; param < M; param++ ) 
210     { 
211       vector< vector<double> >::iterator binIter = myVector.begin();
212       for ( ; binIter != myVector.end(); binIter++ )
213       {
214         input >> res;
215         binIter->push_back(res);
216       } 
217     }
218   }
219   
220  
221   //-----------------------------------------------------------
222   // PUBLIC: getMatrix : returns the Sigma (=covariance) matrix 
223   //                  corresponding to a given track trajectory
224   //-----------------------------------------------------------
225   vector<double> MuonMatrixManager::getVariables( const TrackTrajectory& track,
226                                                     HepSymMatrix& returnSigma ) const
227   {
228     HepSymMatrix Sigma;
229     vector<double> variables;
230 
231     IBinData* binData = getBinData(track);
232     Sigma = binData->getMatrix(track);
233     
234     // do Dcorset and Dcorgen to get smear parameters
235     variables = m_correlatedData->generate( m_correlatedData->root(Sigma) );
236     
237     returnSigma = Sigma;
238     return variables;
239   }
240   
241   
242   //-----------------------------------------------------------
243   // Private: getBinData : returns the IBinData of bin 
244   //                 corresponding to a given track trajectory
245   //-----------------------------------------------------------
246   IBinData* MuonMatrixManager::getBinData( const TrackTrajectory& traj ) const
247   {
248     TrackParameters track = traj.parameters();
249 
250     vector<double> rTEta;
251     double rT  = abs( traj.radius() );
252     double eta = abs( track.eta() );
253 
254     // validity check
255     double rTLow   = ( (m_binData.begin())->first ).low(0);
256     double rTHigh  = ( (m_binData.rbegin())->first ).high(0);
257     double etaLow  = ( (m_binData.begin())->first ).low(1);
258     double etaHigh = ( (m_binData.rbegin())->first ).high(1);
259 
260     if ( rT < rTLow ) rT = rTLow;
261     if ( rT > rTHigh) rT = rTHigh;  
262     if ( eta < etaLow ) eta = etaLow;
263     if ( eta > etaHigh) eta = etaHigh;  
264 
265     // find BinID
266     rTEta.push_back(rT);
267     rTEta.push_back(eta);
268 
269     map<BinID, IBinData*>::const_iterator binIter = m_binData.begin();
270     map<BinID, IBinData*>::const_iterator binEnd  = m_binData.end();
271 
272     for ( ; binIter != binEnd; ++binIter )
273     {
274       if ( binIter->first.isInBin(rTEta) ) 
275       {
276         return binIter->second;
277       }
278     }
279     
280     // OOPS! couldn't fin bin
281     *m_log << MSG::WARNING 
282            << "WARNING: MuonMatrixManager - No bin; rT " << rT << ", eta " << eta 
283            << endreq;
284 
285     return ( m_binData.begin() )->second;
286   }
287   
288 }// namespace
289 

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!