Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:50

0001 //-------------------------------------------------

0002 //

0003 //   Class: L1MuDTTSTheta.cpp

0004 //

0005 //   Description: Implementation of TS Theta trigger algorithm

0006 //

0007 //

0008 //   Author List:

0009 //   C. Grandi

0010 //   Modifications:

0011 //   III/2005 : Sara Vanini NEWGEO update

0012 //   I/2007 : Carlo Battilana Config class update

0013 //   mar07 - S. Vanini : parameters from DTConfigManager

0014 //

0015 //--------------------------------------------------

0016 
0017 //-----------------------

0018 // This Class's Header --

0019 //-----------------------

0020 #include "L1Trigger/DTTriggerServerTheta/interface/DTTSTheta.h"
0021 
0022 //-------------------------------

0023 // Collaborating Class Headers --

0024 //-------------------------------

0025 #include "L1Trigger/DTTriggerServerTheta/interface/DTChambThSegm.h"
0026 #include "L1Trigger/DTBti/interface/DTBtiCard.h"
0027 #include "L1Trigger/DTBti/interface/DTBtiTrigData.h"
0028 
0029 //---------------

0030 // C++ Headers --

0031 //---------------

0032 #include <iostream>
0033 
0034 //----------------

0035 // Constructors --

0036 //----------------

0037 DTTSTheta::DTTSTheta(DTTrigGeom* geom, DTBtiCard* bticard) : DTGeomSupplier(geom), _bticard(bticard) {
0038   for (int i = 0; i < DTConfigTSTheta::NSTEPL - DTConfigTSTheta::NSTEPF + 1; i++) {
0039     _trig[i].zero();
0040     _Htrig[i].zero();
0041     _ntrig[i] = 0;
0042     _nHtrig[i] = 0;
0043   }
0044 }
0045 
0046 //--------------

0047 // Destructor --

0048 //--------------

0049 DTTSTheta::~DTTSTheta() {
0050   //delete _config;

0051 }
0052 
0053 //--------------

0054 // Operations --

0055 //--------------

0056 
0057 void DTTSTheta::localClear() {
0058   for (int is = 0; is < DTConfigTSTheta::NSTEPL - DTConfigTSTheta::NSTEPF + 1; is++) {
0059     // clear input bit masks

0060     _trig[is].zero();
0061     _Htrig[is].zero();
0062     _ntrig[is] = 0;
0063     _nHtrig[is] = 0;
0064   }
0065 }
0066 
0067 void DTTSTheta::setConfig(const DTConfigManager* conf) {
0068   DTChamberId sid = ChamberId();
0069   _config = conf->getDTConfigTSTheta(sid);
0070 }
0071 
0072 void DTTSTheta::loadDTTSTheta() {
0073   localClear();
0074   if (station() == 4)
0075     return;
0076 
0077   if (config()->debug()) {
0078     std::cout << "DTTSTheta::loadDTTSTheta called for wheel=" << wheel();
0079     std::cout << ", station=" << station();
0080     std::cout << ", sector=" << sector() << std::endl;
0081   }
0082 
0083   // loop on all BTI triggers

0084   std::vector<DTBtiTrigData>::const_iterator p;
0085   std::vector<DTBtiTrigData>::const_iterator pend = _bticard->end();
0086   for (p = _bticard->begin(); p != pend; p++) {
0087     // Look only to BTIs in SL 2

0088     if (p->btiSL() == 2) {
0089       // BTI number

0090       int step = p->step();
0091       add_btiT(step, &(*p));
0092     }
0093   }
0094 }
0095 
0096 void DTTSTheta::add_btiT(int step, const DTBtiTrigData* btitrig) {
0097   int n = btitrig->btiNumber();
0098 
0099   /*

0100 OBSOLETE! in NEWGEO the bti number order is the correct one!

0101   // check where the BTI is, and reverse the order in stat 1 and 2 and 3 (only for some sectors)

0102 

0103   if( (wheel()==0 && (sector()==1 ||  sector()==4 || sector()==5 ||

0104               sector()==8 || sector()==9 || sector()==12))

0105       || wheel()==-1 

0106       || wheel()==-2)

0107     {n=DTConfigTSTheta::NCELLTH + 1 - n; }

0108 

0109 */
0110 
0111   if (n < 1 || n > geom()->nCell(2)) {
0112     std::cout << "DTTSTheta::add_btiT: BTI out of range: " << n;
0113     std::cout << " trigger not added!" << std::endl;
0114     return;
0115   }
0116   if (step < DTConfigTSTheta::NSTEPF || step > DTConfigTSTheta::NSTEPL) {
0117     std::cout << "DTTSTheta::add_btiT: step out of range: " << step;
0118     std::cout << " trigger not added!" << std::endl;
0119     return;
0120   }
0121   _trig[step - DTConfigTSTheta::NSTEPF].set(n - 1);
0122   _ntrig[step - DTConfigTSTheta::NSTEPF]++;
0123 
0124   if (btitrig->code() == 8) {
0125     _Htrig[step - DTConfigTSTheta::NSTEPF].set(n - 1);
0126     _nHtrig[step - DTConfigTSTheta::NSTEPF]++;
0127   }
0128 
0129   if (config()->debug()) {
0130     std::cout << "BTI Trigger added at step " << step;
0131     std::cout << " to DTTSTheta at position " << n << std::endl;
0132   }
0133   return;
0134 }
0135 
0136 void DTTSTheta::runDTTSTheta() {
0137   // Just make a DTChambThSegm for each step and store it

0138   for (int is = DTConfigTSTheta::NSTEPF; is < DTConfigTSTheta::NSTEPL + 1; is++) {
0139     if (_ntrig[is - DTConfigTSTheta::NSTEPF] > 0) {
0140       int i = 0;
0141       int code[8];
0142       int pos[8];
0143       int qual[8];
0144       for (i = 0; i < 8; i++) {
0145         //@@ MULT not implemented:

0146         pos[i] = btiMask(is)->byte(i).any();
0147         qual[i] = btiQual(is)->byte(i).any();
0148         code[i] = pos[i] + qual[i];
0149       }
0150 
0151       // SM .OR. response of BTI number 57 in previous group of 8 BTIs

0152 
0153       if (pos[7] > pos[6])
0154         pos[6] = pos[7];
0155       if (qual[7] > qual[6])
0156         qual[6] = qual[7];
0157       if (code[7] > code[6])
0158         code[6] = code[7];
0159 
0160       if (config()->debug()) {
0161         std::cout << " wheel = " << wheel() << " station = " << station() << " sector = " << sector() << std::endl;
0162         std::cout << " pos :  ";
0163         for (i = 0; i < 8; i++) {
0164           std::cout << pos[i] << " ";
0165         }
0166         std::cout << std::endl;
0167         std::cout << " qual :  ";
0168         for (i = 0; i < 8; i++) {
0169           std::cout << qual[i] << " ";
0170         }
0171         std::cout << std::endl;
0172         std::cout << " code :  ";
0173         for (i = 0; i < 8; i++) {
0174           std::cout << code[i] << " ";
0175         }
0176         std::cout << std::endl;
0177         std::cout << std::endl;
0178       }
0179 
0180       _cache.push_back(DTChambThSegm(ChamberId(), is, pos, qual));
0181     }
0182   }
0183 
0184   // debugging...

0185   if (config()->debug()) {
0186     if (!_cache.empty()) {
0187       std::cout << "====================================================" << std::endl;
0188       std::cout << "                 Theta segments                     " << std::endl;
0189       std::vector<DTChambThSegm>::const_iterator p;
0190       for (p = _cache.begin(); p < _cache.end(); p++) {
0191         p->print();
0192       }
0193       std::cout << "====================================================" << std::endl;
0194     }
0195   }
0196   // end debugging

0197 }
0198 
0199 int DTTSTheta::nSegm(int step) {
0200   int n = 0;
0201   std::vector<DTChambThSegm>::const_iterator p;
0202   for (p = begin(); p < end(); p++) {
0203     if (p->step() == step)
0204       n++;
0205   }
0206   return n;
0207 }
0208 
0209 const DTChambThSegm* DTTSTheta::segment(int step, unsigned n) {
0210   std::vector<DTChambThSegm>::const_iterator p;
0211   for (p = begin(); p < end(); p++) {
0212     if (p->step() == step && n == 1)
0213       return &(*p);
0214   }
0215   return nullptr;
0216 }
0217 
0218 int DTTSTheta::nTrig(int step) {
0219   if (step < DTConfigTSTheta::NSTEPF || step > DTConfigTSTheta::NSTEPL) {
0220     std::cout << "DTTSTheta::nTrig: step out of range " << step;
0221     std::cout << " 0 returned" << std::endl;
0222     return 0;
0223   }
0224   if (size() > 0)
0225     return _ntrig[step - DTConfigTSTheta::NSTEPF];
0226   return 0;
0227 }
0228 
0229 int DTTSTheta::nHTrig(int step) {
0230   if (step < DTConfigTSTheta::NSTEPF || step > DTConfigTSTheta::NSTEPL) {
0231     std::cout << "DTTSTheta::nHTrig: step out of range " << step;
0232     std::cout << " 0 returned" << std::endl;
0233     return 0;
0234   }
0235   if (size() > 0)
0236     return _nHtrig[step - DTConfigTSTheta::NSTEPF];
0237   return 0;
0238 }
0239 
0240 BitArray<DTConfigTSTheta::NCELLTH>* DTTSTheta::btiMask(int step) const {
0241   if (step < DTConfigTSTheta::NSTEPF || step > DTConfigTSTheta::NSTEPL) {
0242     std::cout << "DTTSTheta::btiMask: step out of range " << step;
0243     std::cout << " empty pointer returned" << std::endl;
0244     return nullptr;
0245   }
0246   return (BitArray<DTConfigTSTheta::NCELLTH>*)&_trig[step - DTConfigTSTheta::NSTEPF];
0247 }
0248 
0249 BitArray<DTConfigTSTheta::NCELLTH>* DTTSTheta::btiQual(int step) const {
0250   if (step < DTConfigTSTheta::NSTEPF || step > DTConfigTSTheta::NSTEPL) {
0251     std::cout << "DTTSTheta::btiQual: step out of range " << step;
0252     std::cout << " empty pointer returned" << std::endl;
0253     return nullptr;
0254   }
0255   return (BitArray<DTConfigTSTheta::NCELLTH>*)&_Htrig[step - DTConfigTSTheta::NSTEPF];
0256 }
0257 
0258 LocalPoint DTTSTheta::localPosition(const DTTrigData* tr) const {
0259   //const DTChambThSegm* trig = dynamic_cast<const DTChambThSegm*>(tr);

0260   //@@ Not implemented yet

0261   return LocalPoint(0, 0, 0);
0262 }
0263 
0264 LocalVector DTTSTheta::localDirection(const DTTrigData* tr) const {
0265   //const DTChambThSegm* trig = dynamic_cast<const DTChambThSegm*>(tr);

0266   //@@ Not implemented yet

0267   return LocalVector(0, 0, 0);
0268 }
0269 
0270 void DTTSTheta::print(const DTTrigData* trig) const {
0271   trig->print();
0272   //@@ coordinate printing not implemented yet

0273   //@@ rermove this method as soon as the local coordinates are meaningful

0274 }