Go to the documentation of this file.00001
00002 #include "SLHCUpgradeSimulations/L1CaloTrigger/interface/L1CaloAlgoBase.h"
00003
00004 #include "SimDataFormats/SLHC/interface/L1TowerJet.h"
00005 #include "SimDataFormats/SLHC/interface/L1TowerJetFwd.h"
00006 #include "SimDataFormats/SLHC/interface/L1CaloTower.h"
00007 #include "SimDataFormats/SLHC/interface/L1CaloTowerFwd.h"
00008
00009 #include <algorithm>
00010 #include <string>
00011 #include <vector>
00012
00013
00014 class L1TowerJetProducer:
00015 public L1CaloAlgoBase < l1slhc::L1CaloTowerCollection, l1slhc::L1TowerJetCollection >
00016 {
00017 public:
00018 L1TowerJetProducer( const edm::ParameterSet & );
00019 ~L1TowerJetProducer( );
00020
00021
00022
00023 void algorithm( const int &, const int & );
00024
00025 private:
00026 void calculateJetPosition( l1slhc::L1TowerJet & lJet );
00027
00028 int mJetDiameter;
00029 l1slhc::L1TowerJet::tJetShape mJetShape;
00030
00031 std::vector< std::pair< int , int > > mJetShapeMap;
00032
00033 };
00034
00035 L1TowerJetProducer::L1TowerJetProducer( const edm::ParameterSet & aConfig ):L1CaloAlgoBase < l1slhc::L1CaloTowerCollection, l1slhc::L1TowerJetCollection > ( aConfig )
00036 {
00037 mJetDiameter = aConfig.getParameter<unsigned>("JetDiameter");
00038 mPhiOffset = 0;
00039
00040
00041
00042
00043
00044
00045 mEtaOffset = -(mJetDiameter);
00046
00047
00048
00049
00050
00051 mJetShapeMap.reserve(256);
00052
00053 std::string lJetShape = aConfig.getParameter< std::string >("JetShape");
00054 std::transform( lJetShape.begin() , lJetShape.end() , lJetShape.begin() , ::toupper );
00055
00056 std::cout << "Creating JetShapeMap:" << std::endl;
00057
00058 if ( lJetShape == "CIRCLE" ){
00059 mJetShape = l1slhc::L1TowerJet::circle;
00060
00061
00062 double lCentre( (mJetDiameter-1) / 2.0 );
00063 double lDelta;
00064
00065 std::vector<double> lDeltaSquare;
00066 for( int i = 0 ; i != mJetDiameter ; ++i ){
00067 lDelta = double(i) - lCentre;
00068 lDeltaSquare.push_back( lDelta*lDelta );
00069 }
00070
00071 double lDeltaRSquare;
00072 double lDeltaRSquareMax( (mJetDiameter*mJetDiameter) / 4.0 );
00073
00074 for( int x = 0 ; x != mJetDiameter ; ++x ){
00075 for( int y = 0 ; y != mJetDiameter ; ++y ){
00076 lDeltaRSquare = lDeltaSquare[x] + lDeltaSquare[y];
00077 if( lDeltaRSquare <= lDeltaRSquareMax ){
00078 mJetShapeMap.push_back( std::make_pair( x , y ) );
00079
00080 }else{
00081
00082 }
00083 }
00084
00085 }
00086
00087 }else{
00088
00089 mJetShape = l1slhc::L1TowerJet::square;
00090
00091 for( int x = 0 ; x != mJetDiameter ; ++x ){
00092 for( int y = 0 ; y != mJetDiameter ; ++y ){
00093 mJetShapeMap.push_back( std::make_pair( x , y ) );
00094 }
00095 }
00096 }
00097
00098 std::cout << "JetShapeMap includes " << mJetShapeMap.size() << " towers." << std::endl;
00099 std::cout<<" Eta offset is "<< mEtaOffset << std::endl;
00100 }
00101
00102 L1TowerJetProducer::~L1TowerJetProducer( )
00103 {
00104 }
00105
00106
00107
00108
00109
00110 void L1TowerJetProducer::algorithm( const int &aEta, const int &aPhi )
00111 {
00112
00113
00114 int lTowerIndex = mCaloTriggerSetup->getBin( aEta, aPhi );
00115 std::pair < int, int > lTowerEtaPhi = mCaloTriggerSetup->getTowerEtaPhi( lTowerIndex );
00116
00117 l1slhc::L1TowerJet lJet( mJetDiameter, mJetShape , mJetShapeMap.size() , lTowerEtaPhi.first , lTowerEtaPhi.second );
00118
00119
00120 for ( std::vector< std::pair< int , int > >::const_iterator lJetShapeMapIt = mJetShapeMap.begin() ; lJetShapeMapIt != mJetShapeMap.end() ; ++lJetShapeMapIt )
00121 {
00122 int lPhi = aPhi+(lJetShapeMapIt->second);
00123 if ( lPhi > mCaloTriggerSetup->phiMax( ) ) lPhi -= 72;
00124
00125 l1slhc::L1CaloTowerCollection::const_iterator lTowerItr = fetch( aEta+(lJetShapeMapIt->first) , lPhi );
00126
00127 if ( lTowerItr != mInputCollection->end( ) )
00128 {
00129 l1slhc::L1CaloTowerRef lRef( mInputCollection, lTowerItr - mInputCollection->begin( ) );
00130 lJet.addConstituent( lRef );
00131
00132 lJet.CalcWeightediEta();
00133 lJet.CalcWeightediPhi();
00134 }
00135 }
00136
00137 if ( lJet.E( ) > 0 )
00138 {
00139 calculateJetPosition( lJet );
00140
00141 lJet.calculateWeightedEta();lJet.calculateWeightedPhi();
00142 mOutputCollection->insert( lTowerEtaPhi.first, lTowerEtaPhi.second, lJet );
00143
00144 }
00145
00146 }
00147
00148
00149
00150 void L1TowerJetProducer::calculateJetPosition( l1slhc::L1TowerJet & lJet )
00151 {
00152
00153 double tmpeta(9999);
00154 double halfTowerOffset = 0.0435;
00155 const double endcapEta[8] = { 0.09, 0.1, 0.113, 0.129, 0.15, 0.178, 0.15, 0.35 };
00156
00157 double JetSize = double(lJet.JetSize()) / 2.0;
00158
00159 int abs_eta = lJet.iEta( ) + int(JetSize) ;
00160
00161
00162 if( abs_eta>=0 && lJet.iEta( )<0 ) abs_eta += 1;
00163
00164
00165 abs_eta = fabs( abs_eta);
00166
00167
00168 if ( abs_eta < 21 )
00169 {
00170 tmpeta = ( abs_eta * 0.0870 - halfTowerOffset);
00171
00172 if( lJet.JetSize() % 2 == 1 ) tmpeta += halfTowerOffset;
00173
00174 }
00175 else
00176 {
00177 abs_eta -= 21;
00178
00179 tmpeta = 1.74;
00180
00181 for ( int i = 0; i != int(abs_eta); ++i )
00182 {
00183 tmpeta += endcapEta[i];
00184 }
00185
00186
00187 if( lJet.JetSize() % 2 == 0 ) tmpeta += endcapEta[abs_eta] / 2.;
00188 else tmpeta += endcapEta[abs_eta];
00189
00190 }
00191
00192 if(( lJet.iEta( ) + int(JetSize) )<0) tmpeta = (-1)*tmpeta;
00193
00194
00195
00196
00197 double phi = ( ( lJet.iPhi( ) + JetSize ) * 0.087 );
00198
00199 phi -= 0.087;
00200 double pi=(72*0.087)/2;
00201 if(phi>pi) phi-=2*pi;
00202
00203 double Et = double( lJet.E( ) ) / 2.;
00204
00205 lJet.setP4( math::PtEtaPhiMLorentzVector( Et, tmpeta, phi, 0. ) );
00206
00207 }
00208
00209
00210
00211 DEFINE_EDM_PLUGIN( edm::MakerPluginFactory, edm::WorkerMaker < L1TowerJetProducer >, "L1TowerJetProducer" );
00212 DEFINE_FWK_PSET_DESC_FILLER( L1TowerJetProducer );