CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/L1Trigger/DTTrigger/src/DTTrigProd.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00013 //
00014 //--------------------------------------------------
00015 
00016 // This class's header
00017 #include "L1Trigger/DTTrigger/interface/DTTrigProd.h"
00018 
00019 // Framework related classes
00020 #include "FWCore/Framework/interface/EventSetup.h"
00021 #include "FWCore/Framework/interface/ESHandle.h"
00022 #include "FWCore/Framework/interface/Run.h"
00023 
00024 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManager.h"
00025 #include "L1TriggerConfig/DTTPGConfig/interface/DTConfigManagerRcd.h"
00026 
00027 // Data Formats classes
00028 #include "L1Trigger/DTSectorCollector/interface/DTSectCollPhSegm.h"
00029 #include "L1Trigger/DTSectorCollector/interface/DTSectCollThSegm.h"
00030 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
00031 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
00032 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
00033 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThDigi.h"
00034 
00035 // Collaborating classes
00036 #include <iostream>
00037 
00038 using namespace edm;
00039 using namespace std;
00040 
00041 // DataFormats interface
00042 typedef vector<DTSectCollPhSegm>  SectCollPhiColl;
00043 typedef SectCollPhiColl::const_iterator SectCollPhiColl_iterator;
00044 typedef vector<DTSectCollThSegm>  SectCollThetaColl;
00045 typedef SectCollThetaColl::const_iterator SectCollThetaColl_iterator;
00046 
00047 DTTrigProd::DTTrigProd(const ParameterSet& pset) : my_trig(0) {
00048   
00049   produces<L1MuDTChambPhContainer>();
00050   produces<L1MuDTChambThContainer>();
00051 
00052   my_debug = pset.getUntrackedParameter<bool>("debug");
00053   my_DTTFnum = pset.getParameter<bool>("DTTFSectorNumbering");
00054   my_params = pset;
00055 
00056   my_lut_dump_flag = pset.getUntrackedParameter<bool>("lutDumpFlag");
00057   my_lut_btic = pset.getUntrackedParameter<int>("lutBtic");
00058 
00059 }
00060 
00061 DTTrigProd::~DTTrigProd(){
00062 
00063   if (my_trig) delete my_trig;
00064 
00065 }
00066 
00067 void DTTrigProd::beginRun(edm::Run& iRun, const edm::EventSetup& iEventSetup) {
00068 
00069   if(my_debug)
00070     cout << "DTTrigProd::beginRun  " << iRun.id().run() << endl;
00071   
00072   ESHandle< DTConfigManager > dtConfig ;
00073   iEventSetup.get< DTConfigManagerRcd >().get( dtConfig ) ;
00074 
00075   my_CCBValid = dtConfig->CCBConfigValidity();
00076 
00077   if (!my_trig) {
00078     my_trig = new DTTrig(my_params);
00079     my_trig->createTUs(iEventSetup);
00080     if (my_debug)
00081       cout << "[DTTrigProd] TU's Created" << endl;
00082     
00083     if(my_lut_dump_flag) {
00084       cout << "Dumping luts...." << endl;
00085       my_trig->dumpLuts(my_lut_btic, dtConfig.product());
00086     }   
00087   }
00088 
00089 
00090   
00091 }
00092 
00093 
00094 void DTTrigProd::produce(Event & iEvent, const EventSetup& iEventSetup){
00095 
00096   vector<L1MuDTChambPhDigi> outPhi;
00097   vector<L1MuDTChambThDigi> outTheta;
00098 
00099   // SV check if CCB configuration is valid, otherwise just produce empty collections
00100   if(!my_CCBValid)  {
00101     if (my_debug)
00102       cout << "[DTTrigProd] CCB configuration is not valid for this run, empty collection will be produced " << endl;
00103   }  else  {
00104     my_trig->triggerReco(iEvent,iEventSetup);
00105     my_BXoffset = my_trig->getBXOffset();
00106   
00107     if (my_debug)
00108       cout << "[DTTrigProd] Trigger algorithm run for " <<iEvent.id() << endl;
00109   
00110     // Convert Phi Segments
00111     SectCollPhiColl myPhiSegments;
00112     myPhiSegments = my_trig->SCPhTrigs();
00113 
00114     SectCollPhiColl_iterator SCPCend = myPhiSegments.end();
00115     for (SectCollPhiColl_iterator it=myPhiSegments.begin();it!=SCPCend;++it){
00116       int step = (*it).step() - my_BXoffset; // Shift correct BX to 0 (needed for DTTF data processing)
00117       int sc_sector = (*it).SCId().sector();
00118       if (my_DTTFnum == true) sc_sector--; // Modified for DTTF numbering [0-11]
00119         outPhi.push_back(L1MuDTChambPhDigi(step,
00120                                        (*it).ChamberId().wheel(),
00121                                        sc_sector,
00122                                        (*it).ChamberId().station(),
00123                                        (*it).phi(),
00124                                        (*it).phiB(),
00125                                        (*it).code(),
00126                                        !(*it).isFirst(),
00127                                        0
00128                                        ));
00129     }
00130 
00131     // Convert Theta Segments
00132     SectCollThetaColl myThetaSegments;
00133     myThetaSegments = my_trig->SCThTrigs();
00134   
00135     SectCollThetaColl_iterator SCTCend = myThetaSegments.end();
00136     for (SectCollThetaColl_iterator it=myThetaSegments.begin();it!=SCTCend;++it){
00137       int pos[7], qual[7];
00138       for (int i=0; i<7; i++){
00139         pos[i] =(*it).position(i);
00140         qual[i]=(*it).quality(i);
00141       }
00142       int step =(*it).step() - my_BXoffset; // Shift correct BX to 0 (needed for DTTF data processing)
00143       int sc_sector =  (*it).SCId().sector();
00144       if (my_DTTFnum == true) sc_sector--; // Modified for DTTF numbering [0-11]
00145       outTheta.push_back(L1MuDTChambThDigi( step,
00146                                          (*it).ChamberId().wheel(),
00147                                          sc_sector,
00148                                          (*it).ChamberId().station(),
00149                                          pos,
00150                                          qual
00151                                          ));
00152     }
00153   }
00154 
00155   // Write everything into the event (CB write empty collection as default actions if emulator does not run)
00156   std::auto_ptr<L1MuDTChambPhContainer> resultPhi (new L1MuDTChambPhContainer);
00157   resultPhi->setContainer(outPhi);
00158   iEvent.put(resultPhi);
00159   std::auto_ptr<L1MuDTChambThContainer> resultTheta (new L1MuDTChambThContainer);
00160   resultTheta->setContainer(outTheta);
00161   iEvent.put(resultTheta);
00162 
00163 }
00164