CMS 3D CMS Logo

L1GlobalCaloTrigger.cc

Go to the documentation of this file.
00001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GlobalCaloTrigger.h"
00002 
00003 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
00004 #include "CondFormats/L1TObjects/interface/L1GctJetCounterSetup.h"
00005 #include "CondFormats/L1TObjects/interface/L1GctChannelMask.h"
00006 
00007 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetEtCalibrationLut.h"
00008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctEmLeafCard.h"
00009 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctWheelJetFpga.h"
00010 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctWheelEnergyFpga.h"
00011 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetFinalStage.h"
00012 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctGlobalEnergyAlgos.h"
00013 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctGlobalHfSumAlgos.h"
00014 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctElectronFinalSort.h"
00015 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetCounter.h"
00016 
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 
00019 using std::vector;
00020 
00021 //DEFINE STATICS
00022 const int L1GlobalCaloTrigger::N_JET_LEAF_CARDS = 6;
00023 const int L1GlobalCaloTrigger::N_EM_LEAF_CARDS = 2;
00024 const int L1GlobalCaloTrigger::N_WHEEL_CARDS = 2;
00025 
00026 // constructor
00027 L1GlobalCaloTrigger::L1GlobalCaloTrigger(const L1GctJetLeafCard::jetFinderType jfType) :
00028   theJetLeafCards(N_JET_LEAF_CARDS),
00029   theJetFinders(N_JET_LEAF_CARDS*3),
00030   theEmLeafCards(N_EM_LEAF_CARDS),
00031   theIsoElectronSorters(N_EM_LEAF_CARDS*2),
00032   theNonIsoElectronSorters(N_EM_LEAF_CARDS*2),
00033   theWheelJetFpgas(N_WHEEL_CARDS),
00034   theWheelEnergyFpgas(N_WHEEL_CARDS),
00035   m_jetFinderParams(0),
00036   m_jetEtCalLuts(),
00037   m_inputChannelMask(0),
00038   m_bxRangeAuto(true),
00039   m_bxStart(0), m_numOfBx(1),
00040   m_allInputEmCands(), m_allInputRegions()  
00041 {
00042 
00043   // construct hardware
00044   build(jfType);
00045 }
00046 
00048 L1GlobalCaloTrigger::~L1GlobalCaloTrigger()
00049 {
00050   // Delete the components of the GCT that we made in build()
00051   // (But not the LUTs, since these don't belong to us)
00052 
00053   if (theNonIsoEmFinalStage != 0) delete theNonIsoEmFinalStage;
00054   
00055   if (theIsoEmFinalStage != 0) delete theIsoEmFinalStage;
00056   
00057   if (theEnergyFinalStage != 0) delete theEnergyFinalStage;     
00058   
00059   if (theJetFinalStage != 0) delete theJetFinalStage;                   
00060   
00061   for (unsigned i=0; i<theWheelEnergyFpgas.size(); ++i) { 
00062     if (theWheelEnergyFpgas.at(i) != 0) delete theWheelEnergyFpgas.at(i); }
00063   theWheelEnergyFpgas.clear();
00064   
00065   for (unsigned i=0; i<theWheelJetFpgas.size(); ++i) { 
00066     if (theWheelJetFpgas.at(i) != 0) delete theWheelJetFpgas.at(i); }
00067   theWheelJetFpgas.clear();             
00068 
00069   for (unsigned i=0; i<theEmLeafCards.size(); ++i) { 
00070     if (theEmLeafCards.at(i) != 0) delete theEmLeafCards.at(i); }
00071   theEmLeafCards.clear();
00072 
00073   for (unsigned i=0; i<theJetLeafCards.size(); ++i) { 
00074     if (theJetLeafCards.at(i) != 0) delete theJetLeafCards.at(i); }
00075   theJetLeafCards.clear();
00076   
00077 }
00078 
00083 void L1GlobalCaloTrigger::reset() {
00084 
00085   // Input data
00086   m_allInputEmCands.clear();
00087   m_allInputRegions.clear();
00088 
00089   if (m_bxRangeAuto) {
00090     m_bxStart = 0;
00091     m_numOfBx = 1;
00092   }
00093 
00094   // EM Leaf Card
00095   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00096     theEmLeafCards.at(i)->reset();
00097   }
00098 
00099   // Jet Leaf cards
00100   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00101     theJetLeafCards.at(i)->reset();
00102   }
00103 
00104   // Jet Finders
00105   for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
00106     theJetFinders.at(i)->reset();
00107   }
00108 
00109   // Wheel Cards
00110   for (int i=0; i<N_WHEEL_CARDS; i++) {
00111     theWheelJetFpgas.at(i)->reset();
00112   }
00113 
00114   for (int i=0; i<N_WHEEL_CARDS; i++) {
00115     theWheelEnergyFpgas.at(i)->reset();
00116   }
00117 
00118   // Electron Final Stage
00119   theIsoEmFinalStage->reset();
00120   theNonIsoEmFinalStage->reset();
00121 
00122   // Jet Final Stage
00123   theJetFinalStage->reset();
00124 
00125   // Energy Final Stage
00126   theEnergyFinalStage->reset();
00127 
00128 }
00129 
00130 void L1GlobalCaloTrigger::process() {
00131 
00132   // Shouldn't get here unless the setup has been completed
00133   if (setupOk()) {
00134 
00136     sortInputData();
00137     // Extract the earliest and latest bunch crossing
00138     // in the input if required, and forward to the processors
00139     // to determine the size of the output vectors
00140     bxSetup();
00141 
00142     vector<L1CaloEmCand>::iterator emc=m_allInputEmCands.begin();
00143     vector<L1CaloRegion>::iterator rgn=m_allInputRegions.begin();
00144     int bx = m_bxStart;
00145 
00146     // Loop over bunch crossings
00147     for (int i=0; i<m_numOfBx; i++) {
00148       // Perform partial reset (reset processing logic but preserve pipeline contents)
00149       bxReset(bx);
00150       // Fill input data into processors for this bunch crossing
00151       fillEmCands(emc, bx);
00152       fillRegions(rgn, bx);
00153       // Process this bunch crossing
00154       bxProcess(bx);
00155       bx++;
00156     }
00157   }
00158 }
00159 
00161 void L1GlobalCaloTrigger::sortInputData() {
00162   std::sort(m_allInputEmCands.begin(), m_allInputEmCands.end(), emcBxComparator);
00163   std::sort(m_allInputRegions.begin(), m_allInputRegions.end(), rgnBxComparator);
00164 }
00165 
00167 void L1GlobalCaloTrigger::bxSetup() {
00168   // Assume input data have been sorted by bunch crossing number
00169   if (m_bxRangeAuto) {
00170     // Find parameters defining the range of bunch crossings to be processed
00171     int16_t firstBxEmCand = (m_allInputEmCands.size()==0 ? 0 : m_allInputEmCands.front().bx() );
00172     int16_t firstBxRegion = (m_allInputRegions.size()==0 ? 0 : m_allInputRegions.front().bx() );
00173     int16_t  lastBxEmCand = (m_allInputEmCands.size()==0 ? 0 : m_allInputEmCands.back().bx() );
00174     int16_t  lastBxRegion = (m_allInputRegions.size()==0 ? 0 : m_allInputRegions.back().bx() );
00175     m_bxStart = std::min(firstBxEmCand, firstBxRegion);
00176     m_numOfBx = std::max( lastBxEmCand,  lastBxRegion) - m_bxStart + 1;
00177   } else {
00178     // Remove any input from before the start of the requested range
00179     for (vector<L1CaloEmCand>::iterator emc=m_allInputEmCands.begin(); emc != m_allInputEmCands.end(); emc++) {
00180       if (emc->bx() >= m_bxStart) break;
00181       m_allInputEmCands.erase(emc);
00182     }
00183 
00184     for (vector<L1CaloRegion>::iterator rgn=m_allInputRegions.begin(); rgn != m_allInputRegions.end(); rgn++) {
00185       if (rgn->bx() >= m_bxStart) break;
00186       m_allInputRegions.erase(rgn);
00187     }
00188   }
00189 
00190   // Setup pipeline lengths
00191   // EM Leaf Card
00192   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00193     theEmLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
00194   }
00195 
00196   // Jet Leaf cards
00197   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00198     theJetLeafCards.at(i)->setBxRange(m_bxStart, m_numOfBx);
00199   }
00200 
00201   // Wheel Cards
00202   for (int i=0; i<N_WHEEL_CARDS; i++) {
00203     theWheelJetFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
00204   }
00205 
00206   for (int i=0; i<N_WHEEL_CARDS; i++) {
00207     theWheelEnergyFpgas.at(i)->setBxRange(m_bxStart, m_numOfBx);
00208   }
00209 
00210   // Electron Final Stage
00211   theIsoEmFinalStage->setBxRange(m_bxStart, m_numOfBx);
00212   theNonIsoEmFinalStage->setBxRange(m_bxStart, m_numOfBx);
00213 
00214   // Jet Final Stage
00215   theJetFinalStage->setBxRange(m_bxStart, m_numOfBx);
00216 
00217   // Energy Final Stage
00218   theEnergyFinalStage->setBxRange(m_bxStart, m_numOfBx);
00219 }
00220 
00222 void L1GlobalCaloTrigger::bxReset(const int bx) {
00223   // EM Leaf Card
00224   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00225     theEmLeafCards.at(i)->setNextBx(bx);
00226   }
00227 
00228   // Jet Leaf cards
00229   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00230     theJetLeafCards.at(i)->setNextBx(bx);
00231   }
00232 
00233   // Wheel Cards
00234   for (int i=0; i<N_WHEEL_CARDS; i++) {
00235     theWheelJetFpgas.at(i)->setNextBx(bx);
00236   }
00237 
00238   for (int i=0; i<N_WHEEL_CARDS; i++) {
00239     theWheelEnergyFpgas.at(i)->setNextBx(bx);
00240   }
00241 
00242   // Electron Final Stage
00243   theIsoEmFinalStage->setNextBx(bx);
00244   theNonIsoEmFinalStage->setNextBx(bx);
00245 
00246   // Jet Final Stage
00247   theJetFinalStage->setNextBx(bx);
00248 
00249   // Energy Final Stage
00250   theEnergyFinalStage->setNextBx(bx);
00251 
00252 }
00253 
00255 void L1GlobalCaloTrigger::bxProcess(const int bx) {
00256 
00257   // EM Leaf Card
00258   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00259     theEmLeafCards.at(i)->fetchInput();
00260     theEmLeafCards.at(i)->process();
00261   }
00262 
00263   // Jet Leaf cards - first stage processing
00264   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00265     theJetLeafCards.at(i)->fetchInput();
00266   }
00267 
00268   // Jet Leaf cards - second stage processing
00269   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00270     theJetLeafCards.at(i)->process();
00271   }
00272 
00273   // Wheel Cards
00274   for (int i=0; i<N_WHEEL_CARDS; i++) {
00275     theWheelJetFpgas.at(i)->fetchInput();
00276     theWheelJetFpgas.at(i)->process();
00277   }
00278 
00279   for (int i=0; i<N_WHEEL_CARDS; i++) {
00280     theWheelEnergyFpgas.at(i)->fetchInput();
00281     theWheelEnergyFpgas.at(i)->process();
00282   }
00283 
00284   // Electron Final Stage
00285   theIsoEmFinalStage->fetchInput();
00286   theIsoEmFinalStage->process();
00287 
00288   theNonIsoEmFinalStage->fetchInput();
00289   theNonIsoEmFinalStage->process();
00290 
00291 
00292   // Jet Final Stage
00293   theJetFinalStage->fetchInput();
00294   theJetFinalStage->process();
00295 
00296   // Energy Final Stage
00297   theEnergyFinalStage->fetchInput();
00298   theEnergyFinalStage->process();
00299 
00300 }
00301 
00306 void L1GlobalCaloTrigger::setJetFinderParams(const L1GctJetFinderParams* jfpars) {
00307 
00308   // Some parameters not (yet?) implemented
00309   if ((jfpars->CENTRAL_FORWARD_ETA_BOUNDARY==7) &&
00310       (jfpars->CENTRAL_JET_SEED==jfpars->TAU_JET_SEED)) { 
00311 
00312     m_jetFinderParams = jfpars;
00313     // Need to propagate the new parameters to all the JetFinders
00314     for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00315       theJetLeafCards.at(i)->getJetFinderA()->setJetFinderParams(jfpars);
00316       theJetLeafCards.at(i)->getJetFinderB()->setJetFinderParams(jfpars);
00317       theJetLeafCards.at(i)->getJetFinderC()->setJetFinderParams(jfpars);
00318     }
00319   }
00320 }
00321 
00323 void L1GlobalCaloTrigger::setJetEtCalibrationLuts(const L1GlobalCaloTrigger::lutPtrVector& jfluts) {
00324 
00325   m_jetEtCalLuts = jfluts;
00326   // Need to propagate the new lut to all the JetFinders
00327   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00328     theJetLeafCards.at(i)->getJetFinderA()->setJetEtCalibrationLuts(jfluts);
00329     theJetLeafCards.at(i)->getJetFinderB()->setJetEtCalibrationLuts(jfluts);
00330     theJetLeafCards.at(i)->getJetFinderC()->setJetEtCalibrationLuts(jfluts);
00331   }
00332 }
00333 
00335 void L1GlobalCaloTrigger::setupJetCounterLuts(const L1GctJetCounterSetup* jcPosPars,
00336                                               const L1GctJetCounterSetup* jcNegPars) {
00337 
00338   // Initialise look-up tables for Plus and Minus wheels
00339   for (unsigned j=0; j<jcPosPars->numberOfJetCounters(); ++j) {
00340     theWheelJetFpgas.at(0)->getJetCounter(j)->setLut(
00341                  jcPosPars->getCutsForJetCounter(j) );
00342   }
00343   for (unsigned j=0; j<jcNegPars->numberOfJetCounters(); ++j) {
00344     theWheelJetFpgas.at(1)->getJetCounter(j)->setLut(
00345                  jcNegPars->getCutsForJetCounter(j) );
00346   }
00347 }
00348 
00350 void L1GlobalCaloTrigger::setupHfSumLuts(const L1GctHfLutSetup* iSetup) {
00351   if (getHfSumProcessor() != 0) {
00352     getHfSumProcessor()->setupLuts(iSetup);
00353   }
00354 }
00355 
00357 void L1GlobalCaloTrigger::setChannelMask(const L1GctChannelMask* mask) {
00358   m_inputChannelMask = mask;
00359 }
00360 
00362 bool L1GlobalCaloTrigger::setupOk() const { 
00363   bool result = true;
00364   result &= (m_inputChannelMask != 0);
00365   // EM Leaf Card
00366   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00367     result &= theEmLeafCards.at(i)->setupOk();
00368   }
00369 
00370   // Jet Leaf cards
00371   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00372     result &= theJetLeafCards.at(i)->setupOk();
00373   }
00374 
00375   // Jet Finders
00376   for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
00377     result &= theJetFinders.at(i)->setupOk();
00378   }
00379 
00380   // Wheel Cards
00381   for (int i=0; i<N_WHEEL_CARDS; i++) {
00382     result &= theWheelJetFpgas.at(i)->setupOk();
00383   }
00384 
00385   for (int i=0; i<N_WHEEL_CARDS; i++) {
00386     result &= theWheelEnergyFpgas.at(i)->setupOk();
00387   }
00388 
00389   // Electron Final Stage
00390   result &= theIsoEmFinalStage->setupOk();
00391   result &= theNonIsoEmFinalStage->setupOk();
00392 
00393   // Jet Final Stage
00394   result &= theJetFinalStage->setupOk();
00395 
00396   // Energy Final Stage
00397   result &= theEnergyFinalStage->setupOk();
00398 
00399   // All done.
00400   return result;
00401 }
00402 
00404 L1GctGlobalHfSumAlgos* L1GlobalCaloTrigger::getHfSumProcessor() const
00405 {
00406   L1GctGlobalHfSumAlgos* result = 0;
00407   if (theEnergyFinalStage !=0) {
00408     result = theEnergyFinalStage->getHfSumProcessor();
00409   }
00410   return result;
00411 }
00412 
00415 void L1GlobalCaloTrigger::setBxRange(const int firstBx, const int lastBx) { m_bxStart = firstBx; m_numOfBx = lastBx - firstBx + 1; m_bxRangeAuto = false; }
00417 void L1GlobalCaloTrigger::setBxRangeSymmetric(const int numOfBx) { m_bxStart = -numOfBx; m_numOfBx = 2*numOfBx + 1; m_bxRangeAuto = false; }
00419 void L1GlobalCaloTrigger::setBxRangeAutomatic()  { m_bxStart = 0; m_numOfBx = 1; m_bxRangeAuto = true; }
00420 
00426 void L1GlobalCaloTrigger::fillRegions(const vector<L1CaloRegion>& rgn)
00427 {
00428   // To enable multiple bunch crossing operation, we copy the input regions into a vector,
00429   // from which they will be extracted one bunch crossing at a time and sent to the processors
00430   vector<L1CaloRegion>::iterator itr=m_allInputRegions.end();
00431   m_allInputRegions.insert(itr, rgn.begin(), rgn.end());
00432 }
00433 
00435 void L1GlobalCaloTrigger::fillEmCands(const vector<L1CaloEmCand>& em)
00436 {
00437   // To enable multiple bunch crossing operation, we copy the input electrons into a vector,
00438   // from which they will be extracted one bunch crossing at a time and sent to the processors
00439   vector<L1CaloEmCand>::iterator itr=m_allInputEmCands.end();
00440   m_allInputEmCands.insert(itr, em.begin(), em.end());
00441 }
00442 
00444 void L1GlobalCaloTrigger::fillRegions(vector<L1CaloRegion>::iterator& rgn, const int bx) {
00445   while (rgn != m_allInputRegions.end() && rgn->bx() == bx) {
00446     setRegion(*rgn++);
00447   }
00448 }
00449 
00451 void L1GlobalCaloTrigger::fillEmCands(vector<L1CaloEmCand>::iterator& emc, const int bx){
00452   while (emc != m_allInputEmCands.end() && emc->bx() == bx) {
00453     if (emc->isolated()) {
00454       setIsoEm(*emc);
00455     } else {
00456       setNonIsoEm(*emc);
00457     } 
00458     emc++;
00459   }
00460 }
00461 
00465 void L1GlobalCaloTrigger::setRegion(const L1CaloRegion& region) 
00466 {
00467   if ( !m_inputChannelMask->regionMask( region.gctEta(), region.gctPhi() ) ) {
00468     unsigned crate = region.rctCrate();
00469     // Find the relevant jetFinders
00470     static const unsigned NPHI = L1CaloRegionDetId::N_PHI/2;
00471     unsigned prevphi = crate % NPHI;
00472     unsigned thisphi = (crate+1) % NPHI;
00473     unsigned nextphi = (crate+2) % NPHI;
00474 
00475     // Send the region to six jetFinders.
00476     theJetFinders.at(thisphi)->setInputRegion(region);
00477     theJetFinders.at(nextphi)->setInputRegion(region);
00478     theJetFinders.at(prevphi)->setInputRegion(region);
00479     theJetFinders.at(thisphi+NPHI)->setInputRegion(region);
00480     theJetFinders.at(nextphi+NPHI)->setInputRegion(region);
00481     theJetFinders.at(prevphi+NPHI)->setInputRegion(region);
00482   }
00483 }
00484 
00487 void L1GlobalCaloTrigger::setRegion(const unsigned et, const unsigned ieta, const unsigned iphi,
00488                                     const bool overFlow, const bool fineGrain)
00489 {
00490   //  L1CaloRegion temp = L1CaloRegion::makeRegionFromGctIndices(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
00491   L1CaloRegion temp(et, overFlow, fineGrain, false, false, ieta, iphi, 0);
00492   setRegion(temp);
00493 }
00494 
00498 void L1GlobalCaloTrigger::setIsoEm(const L1CaloEmCand& em) 
00499 {
00500   if ( !m_inputChannelMask->emCrateMask( em.rctCrate() ) )
00501     theIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
00502 }
00503 
00507 void L1GlobalCaloTrigger::setNonIsoEm(const L1CaloEmCand& em) 
00508 {
00509   if ( !m_inputChannelMask->emCrateMask( em.rctCrate() ) )
00510     theNonIsoElectronSorters.at(sorterNo(em))->setInputEmCand(em);
00511 }
00512 
00516 void L1GlobalCaloTrigger::print() {
00517 
00518   using edm::LogInfo;
00519   using std::endl;
00520 
00521   LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
00522   LogInfo("L1GlobalCaloTrigger") << "=== START DEBUG OUTPUT  ===" << endl;
00523 
00524   LogInfo("L1GlobalCaloTrigger") << endl;
00525   LogInfo("L1GlobalCaloTrigger") << "N Jet Leaf Cards " << theJetLeafCards.size() << endl;
00526   LogInfo("L1GlobalCaloTrigger") << "N Wheel Jet Fpgas " << theWheelJetFpgas.size() << endl;
00527   LogInfo("L1GlobalCaloTrigger") << "N Wheel Energy Fpgas " << theWheelEnergyFpgas.size() << endl;
00528   LogInfo("L1GlobalCaloTrigger") << "N Em Leaf Cards " << theEmLeafCards.size() << endl;
00529   LogInfo("L1GlobalCaloTrigger") << endl;
00530 
00531   for (unsigned i=0; i<theJetLeafCards.size(); i++) {
00532     LogInfo("L1GlobalCaloTrigger") << "Jet Leaf Card " << i << " : " << theJetLeafCards.at(i) << endl;
00533     LogInfo("L1GlobalCaloTrigger") << (*theJetLeafCards.at(i));
00534   }
00535   LogInfo("L1GlobalCaloTrigger") << endl;
00536 
00537   for (unsigned i=0; i<theWheelJetFpgas.size(); i++) {
00538     LogInfo("L1GlobalCaloTrigger") << "Wheel Jet FPGA " << i << " : " << theWheelJetFpgas.at(i) << endl; 
00539     LogInfo("L1GlobalCaloTrigger") << (*theWheelJetFpgas.at(i));
00540   }
00541   LogInfo("L1GlobalCaloTrigger") << endl;
00542 
00543   for (unsigned i=0; i<theWheelEnergyFpgas.size(); i++) {
00544     LogInfo("L1GlobalCaloTrigger") << "Wheel Energy FPGA " << i <<" : " << theWheelEnergyFpgas.at(i) << endl; 
00545     LogInfo("L1GlobalCaloTrigger") << (*theWheelEnergyFpgas.at(i));
00546   }
00547   LogInfo("L1GlobalCaloTrigger") << endl;
00548 
00549   LogInfo("L1GlobalCaloTrigger") << (*theJetFinalStage);
00550   LogInfo("L1GlobalCaloTrigger") << endl;
00551 
00552   LogInfo("L1GlobalCaloTrigger") << (*theEnergyFinalStage);
00553   LogInfo("L1GlobalCaloTrigger") << endl;
00554 
00555   for (unsigned i=0; i<theEmLeafCards.size(); i++) {
00556     LogInfo("L1GlobalCaloTrigger") << ( (i==0) ? "Positive eta " : "Negative eta " ); 
00557     LogInfo("L1GlobalCaloTrigger") << "EM Leaf Card " << i << " : " << theEmLeafCards.at(i) << endl;
00558     LogInfo("L1GlobalCaloTrigger") << (*theEmLeafCards.at(i));
00559   }
00560   LogInfo("L1GlobalCaloTrigger") << endl;
00561 
00562   LogInfo("L1GlobalCaloTrigger") << (*theIsoEmFinalStage);
00563   LogInfo("L1GlobalCaloTrigger") << endl;
00564 
00565   LogInfo("L1GlobalCaloTrigger") << (*theNonIsoEmFinalStage);
00566 
00567   LogInfo("L1GlobalCaloTrigger") << "=== Global Calo Trigger ===" << endl;
00568   LogInfo("L1GlobalCaloTrigger") << "===  END DEBUG OUTPUT   ===" << endl;
00569  
00570 }
00571 
00575 // isolated EM outputs
00576 L1GctEmCandCollection L1GlobalCaloTrigger::getIsoElectrons() const { 
00577   return theIsoEmFinalStage->getOutputCands();
00578 }       
00579 
00580 // non isolated EM outputs
00581 L1GctEmCandCollection L1GlobalCaloTrigger::getNonIsoElectrons() const {
00582   return theNonIsoEmFinalStage->getOutputCands(); 
00583 }
00584 
00585 // central jet outputs to GT
00586 L1GctJetCandCollection L1GlobalCaloTrigger::getCentralJets() const {
00587   return theJetFinalStage->getCentralJets();
00588 }
00589 
00590 // forward jet outputs to GT
00591 L1GctJetCandCollection L1GlobalCaloTrigger::getForwardJets() const { 
00592   return theJetFinalStage->getForwardJets(); 
00593 }
00594 
00595 // tau jet outputs to GT
00596 L1GctJetCandCollection L1GlobalCaloTrigger::getTauJets() const { 
00597   return theJetFinalStage->getTauJets(); 
00598 }
00599 
00600 // total Et output
00601 L1GctEtTotalCollection L1GlobalCaloTrigger::getEtSumCollection() const {
00602   L1GctEtTotalCollection result(m_numOfBx);
00603   int bx = m_bxStart;
00604   for (int i=0; i<m_numOfBx; i++) {
00605     L1GctEtTotal temp(theEnergyFinalStage->getEtSumColl().at(i).value(),
00606                       theEnergyFinalStage->getEtSumColl().at(i).overFlow(),
00607                       bx++ );
00608     result.at(i) = temp;
00609   }
00610   return result;
00611 }
00612 
00613 L1GctEtHadCollection   L1GlobalCaloTrigger::getEtHadCollection() const {
00614   L1GctEtHadCollection result(m_numOfBx);
00615   int bx = m_bxStart;
00616   for (int i=0; i<m_numOfBx; i++) {
00617     L1GctEtHad temp(theEnergyFinalStage->getEtHadColl().at(i).value(),
00618                     theEnergyFinalStage->getEtHadColl().at(i).overFlow(),
00619                     bx++ );
00620     result.at(i) = temp;
00621   }
00622   return result;
00623 }
00624 
00625 L1GctEtMissCollection  L1GlobalCaloTrigger::getEtMissCollection() const {
00626   L1GctEtMissCollection result(m_numOfBx);
00627   int bx = m_bxStart;
00628   for (int i=0; i<m_numOfBx; i++) {
00629     L1GctEtMiss temp(theEnergyFinalStage->getEtMissColl().at(i).value(),
00630                      theEnergyFinalStage->getEtMissPhiColl().at(i).value(),
00631                      theEnergyFinalStage->getEtMissColl().at(i).overFlow(),
00632                      bx++ );
00633     result.at(i) = temp;
00634   }
00635   return result;
00636 }
00637 
00638 L1GctEtMissCollection  L1GlobalCaloTrigger::getHtMissCollection() const {
00639   L1GctEtMissCollection result(m_numOfBx);
00640   int bx = m_bxStart;
00641   for (int i=0; i<m_numOfBx; i++) {
00642     L1GctEtMiss temp(theEnergyFinalStage->getHtMissColl().at(i).value(),
00643                      theEnergyFinalStage->getHtMissPhiColl().at(i).value(),
00644                      false,
00645                      bx++ );
00646     result.at(i) = temp;
00647   }
00648   return result;
00649 }
00650 
00651 L1GctJetCountsCollection L1GlobalCaloTrigger::getJetCountsCollection() const {
00652   L1GctJetCountsCollection result(m_numOfBx);
00653   int bx = m_bxStart;
00654   for (int i=0; i<m_numOfBx; i++) {
00655     L1GctJetCounts temp(theEnergyFinalStage->getJetCountValuesColl().at(i), bx++);
00656     result.at(i) = temp;
00657   }
00658   return result;
00659 }
00660 
00661 L1GctHFBitCountsCollection L1GlobalCaloTrigger::getHFBitCountsCollection() const {
00662   L1GctHFBitCountsCollection result(m_numOfBx);
00663   if (getHfSumProcessor() != 0) {
00664     int bx = m_bxStart;
00665     for (int i=0; i<m_numOfBx; i++) {
00666       L1GctHFBitCounts temp =
00667         L1GctHFBitCounts::fromGctEmulator(static_cast<int16_t>(bx),
00668                                           getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::bitCountPosEtaRing1).at(i),
00669                                           getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::bitCountPosEtaRing2).at(i),
00670                                           getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::bitCountNegEtaRing1).at(i),
00671                                           getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::bitCountNegEtaRing2).at(i));
00672       result.at(i) = temp;
00673       bx++;
00674     }
00675   }
00676   return result;
00677 }
00678 
00679 L1GctHFRingEtSumsCollection L1GlobalCaloTrigger::getHFRingEtSumsCollection() const {
00680   L1GctHFRingEtSumsCollection result(m_numOfBx);
00681   if (getHfSumProcessor() != 0) {
00682     int bx = m_bxStart;
00683     for (int i=0; i<m_numOfBx; i++) {
00684       L1GctHFRingEtSums temp =
00685         L1GctHFRingEtSums::fromGctEmulator(static_cast<int16_t>(bx),
00686                                            getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::etSumPosEtaRing1).at(i),
00687                                            getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::etSumPosEtaRing2).at(i),
00688                                            getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::etSumNegEtaRing1).at(i),
00689                                            getHfSumProcessor()->hfSumsOutput(L1GctHfLutSetup::etSumNegEtaRing2).at(i));
00690       result.at(i) = temp;
00691       bx++;
00692     }
00693   }
00694   return result;
00695 }
00696 
00697 
00699 void L1GlobalCaloTrigger::setVerbose() {
00700   // EM Leaf Card
00701   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00702     theEmLeafCards.at(i)->setVerbose();
00703   }
00704 
00705   // Jet Leaf cards
00706   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00707     theJetLeafCards.at(i)->setVerbose();
00708   }
00709 
00710   // Jet Finders
00711   for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
00712     theJetFinders.at(i)->setVerbose();
00713   }
00714 
00715   // Wheel Cards
00716   for (int i=0; i<N_WHEEL_CARDS; i++) {
00717     theWheelJetFpgas.at(i)->setVerbose();
00718   }
00719 
00720   for (int i=0; i<N_WHEEL_CARDS; i++) {
00721     theWheelEnergyFpgas.at(i)->setVerbose();
00722   }
00723 
00724   // Electron Final Stage
00725   theIsoEmFinalStage->setVerbose();
00726   theNonIsoEmFinalStage->setVerbose();
00727 
00728   // Jet Final Stage
00729   theJetFinalStage->setVerbose();
00730 
00731   // Energy Final Stage
00732   theEnergyFinalStage->setVerbose();
00733 }
00734 
00735 void L1GlobalCaloTrigger::setTerse() {
00736   // EM Leaf Card
00737   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00738     theEmLeafCards.at(i)->setTerse();
00739   }
00740 
00741   // Jet Leaf cards
00742   for (int i=0; i<N_JET_LEAF_CARDS; i++) {
00743     theJetLeafCards.at(i)->setTerse();
00744   }
00745 
00746   // Jet Finders
00747   for (int i=0; i<N_JET_LEAF_CARDS*3; i++) {
00748     theJetFinders.at(i)->setTerse();
00749   }
00750 
00751   // Wheel Cards
00752   for (int i=0; i<N_WHEEL_CARDS; i++) {
00753     theWheelJetFpgas.at(i)->setTerse();
00754   }
00755 
00756   for (int i=0; i<N_WHEEL_CARDS; i++) {
00757     theWheelEnergyFpgas.at(i)->setTerse();
00758   }
00759 
00760   // Electron Final Stage
00761   theIsoEmFinalStage->setTerse();
00762   theNonIsoEmFinalStage->setTerse();
00763 
00764   // Jet Final Stage
00765   theJetFinalStage->setTerse();
00766 
00767   // Energy Final Stage
00768   theEnergyFinalStage->setTerse();
00769 }
00770 
00771 /* PRIVATE METHODS */
00772 
00773 // instantiate hardware/algorithms
00774 void L1GlobalCaloTrigger::build(L1GctJetLeafCard::jetFinderType jfType) {
00775 
00776   // The first half of the jet leaf cards are at negative eta,
00777   // followed by positive eta
00778   // Jet Leaf cards
00779   for (int jlc=0; jlc<N_JET_LEAF_CARDS; jlc++) {
00780     theJetLeafCards.at(jlc) = new L1GctJetLeafCard(jlc,jlc % 3, jfType);
00781     theJetFinders.at( 3*jlc ) = theJetLeafCards.at(jlc)->getJetFinderA();
00782     theJetFinders.at(3*jlc+1) = theJetLeafCards.at(jlc)->getJetFinderB();
00783     theJetFinders.at(3*jlc+2) = theJetLeafCards.at(jlc)->getJetFinderC();
00784   }
00785 
00786   //Link jet leaf cards together
00787   vector<L1GctJetLeafCard*> neighbours(2);
00788   for (int jlc=0 ; jlc<N_JET_LEAF_CARDS/2; jlc++) {
00789     // Define local constant for ease of typing
00790     static const int NL = N_JET_LEAF_CARDS/2;
00791     int nlc = (jlc+1)%NL;
00792     int mlc = (jlc+(NL-1))%NL;
00793     neighbours.at(0) = theJetLeafCards.at(mlc);
00794     neighbours.at(1) = theJetLeafCards.at(nlc);
00795     theJetLeafCards.at(jlc)->setNeighbourLeafCards(neighbours);
00796     neighbours.at(0) = theJetLeafCards.at(NL+mlc);
00797     neighbours.at(1) = theJetLeafCards.at(NL+nlc);
00798     theJetLeafCards.at(NL+jlc)->setNeighbourLeafCards(neighbours);
00799   }
00800 
00801   // EM leaf cards  
00802   // Card 0 is positive eta, card 1 is negative eta
00803   for (int i=0; i<N_EM_LEAF_CARDS; i++) {
00804     theEmLeafCards.at(i) = new L1GctEmLeafCard(i);
00805     theIsoElectronSorters.at( 2*i ) = theEmLeafCards.at(i)->getIsoElectronSorterU1();
00806     theIsoElectronSorters.at(2*i+1) = theEmLeafCards.at(i)->getIsoElectronSorterU2();
00807     theNonIsoElectronSorters.at( 2*i ) = theEmLeafCards.at(i)->getNonIsoElectronSorterU1();
00808     theNonIsoElectronSorters.at(2*i+1) = theEmLeafCards.at(i)->getNonIsoElectronSorterU2();
00809   }
00810 
00811    // Wheel Fpgas
00812    vector<L1GctJetLeafCard*> wheelJetLeafCards(3);
00813    vector<L1GctJetLeafCard*> wheelEnergyLeafCards(3);
00814 
00815    // The first wheel card is at negative eta,
00816    // the second one is at positive eta
00817    for (int i=0; i<N_WHEEL_CARDS; i++) {
00818      for (int j=0; j<3; j++) {
00819        wheelJetLeafCards.at(j)=theJetLeafCards.at(i*3+j);
00820        wheelEnergyLeafCards.at(j)=theJetLeafCards.at(i*3+j);
00821      }
00822      theWheelJetFpgas.at(i)    = new L1GctWheelJetFpga   (i,wheelJetLeafCards);
00823      theWheelEnergyFpgas.at(i) = new L1GctWheelEnergyFpga(i,wheelEnergyLeafCards);
00824    }
00825 
00826    // Jet Final Stage  
00827    theJetFinalStage = new L1GctJetFinalStage(theWheelJetFpgas);
00828 
00829   // Electron Final Sort
00830    theIsoEmFinalStage = new L1GctElectronFinalSort(true,theEmLeafCards.at(0), theEmLeafCards.at(1));
00831    theNonIsoEmFinalStage = new L1GctElectronFinalSort(false,theEmLeafCards.at(0), theEmLeafCards.at(1));  
00832 
00833   // Global Energy Algos
00834   theEnergyFinalStage = new L1GctGlobalEnergyAlgos(theWheelEnergyFpgas, theWheelJetFpgas);
00835 
00836 }
00837 
00845 unsigned L1GlobalCaloTrigger::sorterNo(const L1CaloEmCand& em) const {
00846   unsigned crate = em.rctCrate();
00847   unsigned result = ( ((crate%9) < 4) ? 1 : 0 );
00848   if (crate>=9) result += 2;
00849   if (crate>=18) result = 0;
00850   return result; 
00851 }
00852 

Generated on Tue Jun 9 17:40:11 2009 for CMSSW by  doxygen 1.5.4