CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/L1Trigger/GlobalCaloTrigger/src/L1GctJetLeafCard.cc

Go to the documentation of this file.
00001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetLeafCard.h"
00002 
00003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00004 
00005 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetFinderBase.h"
00006 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctTdrJetFinder.h"
00007 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctHardwareJetFinder.h"
00008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctNullJetFinder.h"
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 
00012 //DEFINE STATICS
00013 const int L1GctJetLeafCard::MAX_JET_FINDERS = 3;  
00014 
00015 L1GctJetLeafCard::L1GctJetLeafCard(int id, int iphi, jetFinderType jfType):
00016   L1GctProcessor(),
00017   m_id(id),
00018   m_whichJetFinder(jfType),
00019   phiPosition(iphi),
00020   m_exSum(0), m_eySum(0),
00021   m_hxSum(0), m_hySum(0),
00022   m_etSum(0), m_htSum(0),
00023   m_hfSums(),
00024   m_exSumPipe(), m_eySumPipe(),
00025   m_hxSumPipe(), m_hySumPipe(),
00026   m_etSumPipe(), m_htSumPipe(),
00027   m_hfSumsPipe(),
00028   m_ctorInputOk(true)
00029 {
00030   //Check jetLeafCard setup
00031   if(m_id < 0 || m_id > 5)
00032     {
00033       m_ctorInputOk = false;
00034       if (m_verbose) {
00035         edm::LogWarning("L1GctSetupError")
00036           << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id << " has been incorrectly constructed!\n"
00037           << "ID number should be between the range of 0 to 5\n";
00038       } 
00039     }
00040   
00041   //iphi is redundant
00042   if(phiPosition != m_id%3)
00043     {
00044       m_ctorInputOk = false;
00045       if (m_verbose) {
00046         edm::LogWarning("L1GctSetupError")
00047           << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id << " has been incorrectly constructed!\n"
00048           << "Argument iphi is " << phiPosition << ", should be " << (m_id%3) << " for this ID value \n";
00049       } 
00050     }
00051   
00052   switch (m_whichJetFinder) {
00053   case tdrJetFinder :
00054     m_jetFinderA = new L1GctTdrJetFinder( 3*id );
00055     m_jetFinderB = new L1GctTdrJetFinder(3*id+1);
00056     m_jetFinderC = new L1GctTdrJetFinder(3*id+2);
00057     break;
00058 
00059   case hardwareJetFinder :
00060     m_jetFinderA = new L1GctHardwareJetFinder( 3*id );
00061     m_jetFinderB = new L1GctHardwareJetFinder(3*id+1);
00062     m_jetFinderC = new L1GctHardwareJetFinder(3*id+2);
00063     break;
00064 
00065   case nullJetFinder :
00066     m_jetFinderA = new L1GctNullJetFinder( 3*id );
00067     m_jetFinderB = new L1GctNullJetFinder(3*id+1);
00068     m_jetFinderC = new L1GctNullJetFinder(3*id+2);
00069     break;
00070 
00071   default :
00072 
00073     m_ctorInputOk = false;
00074     if (m_verbose) {
00075       edm::LogWarning("L1GctSetupError")
00076         << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id << " has been incorrectly constructed!\n"
00077         << "Unrecognised jetFinder type " << m_whichJetFinder << ", cannot setup jetFinders\n";
00078     }
00079 
00080   }
00081 
00082   if (!m_ctorInputOk && m_verbose) {
00083     edm::LogError("L1GctSetupError") << "Jet Leaf Card ID " << m_id << " has been incorrectly constructed";
00084   }
00085 }
00086 
00087 L1GctJetLeafCard::~L1GctJetLeafCard()
00088 {
00089   delete m_jetFinderA;
00090   delete m_jetFinderB;
00091   delete m_jetFinderC;
00092 }
00093 
00095 void L1GctJetLeafCard::setNeighbourLeafCards(std::vector<L1GctJetLeafCard*> neighbours)
00096 {
00097   std::vector<L1GctJetFinderBase*> jfNeighbours(2);
00098 
00099   if (neighbours.size()==2) {
00100 
00101     jfNeighbours.at(0) = neighbours.at(0)->getJetFinderC();
00102     jfNeighbours.at(1) = m_jetFinderB;
00103     m_jetFinderA->setNeighbourJetFinders(jfNeighbours);
00104 
00105     jfNeighbours.at(0) = m_jetFinderA;
00106     jfNeighbours.at(1) = m_jetFinderC;
00107     m_jetFinderB->setNeighbourJetFinders(jfNeighbours);
00108 
00109     jfNeighbours.at(0) = m_jetFinderB;
00110     jfNeighbours.at(1) = neighbours.at(1)->getJetFinderA();
00111     m_jetFinderC->setNeighbourJetFinders(jfNeighbours);
00112 
00113   } else {
00114     m_ctorInputOk = false;
00115     if (m_verbose) {
00116       edm::LogWarning("L1GctSetupError")
00117         << "L1GctJetLeafCard::setNeighbourLeafCards() : In Jet Leaf Card ID " << m_id 
00118         << " size of input vector should be 2, but is in fact " << neighbours.size() << "\n";
00119     }
00120   }
00121 }
00122 
00123 std::ostream& operator << (std::ostream& s, const L1GctJetLeafCard& card)
00124 {
00125   using std::endl;
00126 
00127   s << "===L1GctJetLeafCard===" << endl;
00128   s << "ID = " << card.m_id << endl;
00129   s << "i_phi = " << card.phiPosition << endl;;
00130   s << "Ex " << card.m_exSum << endl;
00131   s << "Ey " << card.m_eySum << endl;
00132   s << "Hx " << card.m_hxSum << endl;
00133   s << "Hy " << card.m_hySum << endl;
00134   s << "Et " << card.m_etSum << endl;
00135   s << "Ht " << card.m_htSum << endl;
00136   s << "JetFinder A : " << endl << (*card.m_jetFinderA);
00137   s << "JetFinder B : " << endl << (*card.m_jetFinderB); 
00138   s << "JetFinder C : " << endl << (*card.m_jetFinderC);
00139   s << endl;
00140 
00141   return s;
00142 }
00143 
00145 void L1GctJetLeafCard::reset() {
00146   L1GctProcessor::reset();
00147   m_jetFinderA->reset();
00148   m_jetFinderB->reset();
00149   m_jetFinderC->reset();
00150 }
00151 
00153 void L1GctJetLeafCard::setBxRange(const int firstBx, const int numberOfBx) {
00154   L1GctProcessor::setBxRange(firstBx, numberOfBx);
00155   m_jetFinderA->setBxRange(firstBx, numberOfBx);
00156   m_jetFinderB->setBxRange(firstBx, numberOfBx);
00157   m_jetFinderC->setBxRange(firstBx, numberOfBx);
00158 }
00159 
00160 void L1GctJetLeafCard::setNextBx(const int bx) {
00161   L1GctProcessor::setNextBx(bx);
00162   m_jetFinderA->setNextBx(bx);
00163   m_jetFinderB->setNextBx(bx);
00164   m_jetFinderC->setNextBx(bx);
00165 }
00166 
00167 void L1GctJetLeafCard::resetProcessor()
00168 {
00169   m_exSum.reset();
00170   m_eySum.reset();
00171   m_hxSum.reset();
00172   m_hySum.reset();
00173   m_etSum.reset();
00174   m_htSum.reset();
00175   m_hfSums.reset();
00176 }
00177 
00178 void L1GctJetLeafCard::resetPipelines()
00179 {
00180   m_exSumPipe.reset(numOfBx());
00181   m_eySumPipe.reset(numOfBx());
00182   m_hxSumPipe.reset(numOfBx());
00183   m_hySumPipe.reset(numOfBx());
00184   m_etSumPipe.reset(numOfBx());
00185   m_htSumPipe.reset(numOfBx());
00186   m_hfSumsPipe.reset(numOfBx());
00187 }
00188 
00189 void L1GctJetLeafCard::fetchInput() {
00190   m_jetFinderA->fetchInput();
00191   m_jetFinderB->fetchInput();
00192   m_jetFinderC->fetchInput();
00193 }
00194 
00195 void L1GctJetLeafCard::process() {
00196 
00197   // Check the setup
00198   if (setupOk()) {
00199 
00200     // Perform the jet finding
00201     m_jetFinderA->process();
00202     m_jetFinderB->process();
00203     m_jetFinderC->process();
00204 
00205     // Finish Et and Ht sums for the Leaf Card
00206     // First Et and missing Et
00207     m_etSum =
00208       m_jetFinderA->getEtSum() +
00209       m_jetFinderB->getEtSum() +
00210       m_jetFinderC->getEtSum();
00211     if (m_etSum.overFlow()) m_etSum.setValue(etTotalMaxValue);
00212     m_exSum =
00213       ((etComponentType) m_jetFinderA->getExSum()) +
00214       ((etComponentType) m_jetFinderB->getExSum()) +
00215       ((etComponentType) m_jetFinderC->getExSum());
00216     m_eySum =
00217       ((etComponentType) m_jetFinderA->getEySum()) +
00218       ((etComponentType) m_jetFinderB->getEySum()) +
00219       ((etComponentType) m_jetFinderC->getEySum());
00220 
00221     // Exactly the same procedure for Ht and missing Ht
00222     m_htSum =
00223       m_jetFinderA->getHtSum() +
00224       m_jetFinderB->getHtSum() +
00225       m_jetFinderC->getHtSum();
00226     if (m_htSum.overFlow()) m_htSum.setValue(htTotalMaxValue);
00227     m_hxSum =
00228       ((htComponentType) m_jetFinderA->getHxSum()) +
00229       ((htComponentType) m_jetFinderB->getHxSum()) +
00230       ((htComponentType) m_jetFinderC->getHxSum());
00231     m_hySum =
00232       ((htComponentType) m_jetFinderA->getHySum()) +
00233       ((htComponentType) m_jetFinderB->getHySum()) +
00234       ((htComponentType) m_jetFinderC->getHySum());
00235 
00236     // And the same again for Hf Sums
00237     m_hfSums = 
00238       m_jetFinderA->getHfSums() +
00239       m_jetFinderB->getHfSums() +
00240       m_jetFinderC->getHfSums();
00241 
00242     // Store the outputs in pipelines
00243     m_exSumPipe.store  (m_exSum,  bxRel());
00244     m_eySumPipe.store  (m_eySum,  bxRel());
00245     m_hxSumPipe.store  (m_hxSum,  bxRel());
00246     m_hySumPipe.store  (m_hySum,  bxRel());
00247     m_etSumPipe.store  (m_etSum,  bxRel());
00248     m_htSumPipe.store  (m_htSum,  bxRel());
00249     m_hfSumsPipe.store (m_hfSums, bxRel());
00250   }
00251 }
00252 
00253 bool L1GctJetLeafCard::setupOk() const {
00254   return (m_ctorInputOk &&
00255           m_jetFinderA->setupOk() &&
00256           m_jetFinderB->setupOk() &&
00257           m_jetFinderC->setupOk()); }
00258 
00259 // get the jet output
00260 L1GctJetFinderBase::JetVector
00261 L1GctJetLeafCard::getOutputJetsA() const { return m_jetFinderA->getJets(); }  
00262 L1GctJetFinderBase::JetVector
00263 L1GctJetLeafCard::getOutputJetsB() const { return m_jetFinderB->getJets(); }  
00264 L1GctJetFinderBase::JetVector
00265 L1GctJetLeafCard::getOutputJetsC() const { return m_jetFinderC->getJets(); }  
00266 
00268 std::vector< L1GctInternEtSum  > L1GctJetLeafCard::getInternalEtSums() const
00269 {
00270 
00271   std::vector< L1GctInternEtSum > result;
00272   for (int bx=0; bx<numOfBx(); bx++) {
00273     result.push_back( L1GctInternEtSum::fromEmulatorJetTotEt ( m_etSumPipe.contents.at(bx).value(),
00274                                                                m_etSumPipe.contents.at(bx).overFlow(),
00275                                                                static_cast<int16_t> (bx-bxMin()) ) );
00276     result.push_back( L1GctInternEtSum::fromEmulatorJetMissEt( m_exSumPipe.contents.at(bx).value(),
00277                                                                m_exSumPipe.contents.at(bx).overFlow(),
00278                                                                static_cast<int16_t> (bx-bxMin()) ) );
00279     result.push_back( L1GctInternEtSum::fromEmulatorJetMissEt( m_eySumPipe.contents.at(bx).value(),
00280                                                                m_eySumPipe.contents.at(bx).overFlow(),
00281                                                                static_cast<int16_t> (bx-bxMin()) ) );
00282     result.push_back( L1GctInternEtSum::fromEmulatorJetTotHt ( m_htSumPipe.contents.at(bx).value(),
00283                                                                m_htSumPipe.contents.at(bx).overFlow(),
00284                                                                static_cast<int16_t> (bx-bxMin()) ) );
00285   }
00286   return result;
00287 }
00288 
00289 std::vector< L1GctInternHtMiss > L1GctJetLeafCard::getInternalHtMiss() const
00290 {
00291 
00292   std::vector< L1GctInternHtMiss > result;
00293   for (int bx=0; bx<numOfBx(); bx++) {
00294     result.push_back( L1GctInternHtMiss::emulatorMissHtxHty( m_hxSumPipe.contents.at(bx).value(),
00295                                                              m_hySumPipe.contents.at(bx).value(),
00296                                                              m_hxSumPipe.contents.at(bx).overFlow(),
00297                                                              static_cast<int16_t> (bx-bxMin()) ) );
00298   }
00299   return result;
00300 
00301 }