CMS 3D CMS Logo

BSCTrigger.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: BSCTrigger
4 // Class: BSCTrigger
5 //
13 //
14 // Original Author: Muriel VANDER DONCKT *:0
15 // Created: Wed Jul 16 16:11:05 CEST 2008
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
37 
40 
41 
42 //
43 // class declaration
44 //
45 
47 public:
48  explicit BSCTrigger(const edm::ParameterSet&);
49  ~BSCTrigger() override;
50 
51 private:
52  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
53  int getBSCNum(int id, float z) const;
54  bool isInner(int id) const;
55  bool isZplus(int id) const;
56  // ----------member data ---------------------------
57  const std::vector<unsigned> ttBits_;
58  const std::vector<std::string> names_;
59  const double theCoincidence_;
60  const double theResolution_;
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78  ttBits_{iConfig.getParameter< std::vector<unsigned> >("bitNumbers")},
79  names_{iConfig.getParameter< std::vector<std::string> >("bitNames")},
80  theCoincidence_{iConfig.getParameter<double>("coincidence")},
81  theResolution_{iConfig.getParameter<double>("resolution")},
82  theHitsToken_{consumes<CrossingFrame<PSimHit>>(iConfig.getParameter<edm::InputTag>("theHits")) },
83  thePutToken_{produces<L1GtTechnicalTriggerRecord>()}
84 {
85 }
86 
87 
89 {
90 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 
94 }
95 
96 
97 //
98 // member functions
99 //
100 
101 // ------------ method called to produce the data ------------
103 {
104  std::vector<L1GtTechnicalTrigger> ttVec(ttBits_.size());
105 
107  iEvent.getByToken(theHitsToken_, cf);
108 
109  if (!cf.failedToGet()) {
110  std::vector<float> EnergyBX(32);
111  std::vector<float> EnergyBXMinusDt(32);
112 
113  for ( int c=0;c<32;++c){
114  EnergyBX[c]=0;
115  EnergyBXMinusDt[c]=0;
116  }
117  MixCollection<PSimHit> theBSCHitContainer(cf.product());
118  const float dt1=theCoincidence_/2 + theResolution_;
119  const float dt2=theCoincidence_/2 - theResolution_;
120  if ( edm::isDebugEnabled() ) LogDebug("BSCTrig")<<" ----------------new event ---with "<<theBSCHitContainer.size()<<" hits in the BSC";
121 
122  // collect total deposited energy in BSC segments -> EnergyBX[segment id], in GeV units ---------------------------------------------------------------
123  for (auto itHit = theBSCHitContainer.begin(); itHit != theBSCHitContainer.end(); ++itHit) {
124  float zh=itHit->entryPoint().z()/10;
125  int id=getBSCNum(itHit->detUnitId(),zh);
126  if ( id > 31 ) continue; // the small 2 paddles further from the IP
127  float t=itHit->timeOfFlight();
128 
129  if ( edm::isDebugEnabled() ) {
130  float rh=sqrt(itHit->entryPoint().x()*itHit->entryPoint().x()+itHit->entryPoint().y()*itHit->entryPoint().y())/10;
131  LogTrace("BSCTrig")<<" BSC Num "<<id<<" z="<<zh<<" isZplus="<<isZplus(id)<<" Hit DetId="<<getBSCNum(id,zh)<<" r="<<rh<<" isInner="<<isInner(id);
132  LogTrace("BSCTrig")<<" Hit time="<<t<<" accepted range=["<<dt2<<","<<dt1<<"] from a "<<abs(itHit->particleType())<<" with energy " <<itHit->energyLoss();
133  }
134  if (fabs(t)> dt1 || fabs(t) <dt2 ) continue;
135  if (t>0) EnergyBX[id]+=itHit->energyLoss();
136  else EnergyBXMinusDt[id]+=itHit->energyLoss();
137  }
138 
139  // count number of segments hit in inner/outer and +z, -z ---------------------------------------------------------------------------------------------
140  int ZMinnerBX=0, ZMouterBX=0;
141  int ZPinnerBX=0, ZPouterBX=0;
142  int ZMinnerBXMinusDt=0, ZMouterBXMinusDt=0;
143  int ZPinnerBXMinusDt=0, ZPouterBXMinusDt=0;
144 
145  constexpr float MipFraction=0.5;
146  constexpr float MipEnergy=0.0027;
147  constexpr float theThreshold=MipFraction*MipEnergy;
148  for ( unsigned int ipad = 0 ; ipad<32; ipad++) {
149  if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" EnergyBX["<<ipad<<"]="<<EnergyBX[ipad];
150  // hits after the bunch crossing
151  if ( EnergyBX[ipad] > theThreshold ) {
152  if ( isZplus(ipad)) {
153  if ( isInner(ipad) ) ZPinnerBX++;
154  else ZPouterBX++;
155  } else {
156  if ( isInner(ipad) ) ZMinnerBX++;
157  else ZMouterBX++;
158  }
159  }
160  // hits before the bunch crossing
161  if ( EnergyBXMinusDt[ipad] > theThreshold ) {
162  if ( isZplus(ipad)) {
163  if ( isInner(ipad) ) ZPinnerBXMinusDt++;
164  else ZPouterBXMinusDt++;
165  } else {
166  if ( isInner(ipad) ) ZMinnerBXMinusDt++;
167  else ZMouterBXMinusDt++;
168  }
169  }
170  }
171 
172  if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" Zplus I="<<ZPinnerBX<<" Zminus I="<<ZMinnerBX<<" Zplus O="<<ZPouterBX<<" Zminus O="<<ZMouterBX;
173 
174  // minimum bias technical triggers that are also connected to 'external condition' triggers -----------------
175  bool bit32=false; // min bias inner >=1
176  if(ZPinnerBX >= 1 && ZMinnerBX >= 1) bit32 = true;
177 
178  bool bit33=false; // min bias inner >=2
179  if(ZPinnerBX >= 2 && ZMinnerBX >= 2) bit33 = true;
180 
181  bool bit34=false; // min bias OR
182  if(ZPinnerBX + ZMinnerBX + ZPouterBX + ZMouterBX >= 1) bit34 = true;
183 
184  bool bit35=false; // high multiplicity
185  if(ZPinnerBX == 8 && ZMinnerBX == 8) bit35 = true;
186 
187  // beam halo technical triggers ----------------------------------------------------------------
188  bool bit36=false; // beam 2 halo inner
189  if(ZPinnerBX >= 1 && ZMinnerBXMinusDt >= 1) bit36 = true;
190 
191  bool bit37=false; // beam 2 halo outer
192  if(ZPouterBX >= 1 && ZMouterBXMinusDt >= 1) bit37 = true;
193 
194  bool bit38=false; // beam 1 halo inner
195  if(ZMinnerBX >= 1 && ZPinnerBXMinusDt >= 1) bit38 = true;
196 
197  bool bit39=false; // beam 1 halo outer
198  if(ZMouterBX >= 1 && ZPouterBXMinusDt >= 1) bit39 = true;
199 
200  // minimum bias technical triggers ---------------------------------------------------------
201  bool bit40=false; // min bias all >=1
202  if(ZPinnerBX + ZPouterBX >= 1 && ZMinnerBX + ZMouterBX >= 1) bit40 = true;
203 
204  bool bit41=false; // min bias all >=2
205  if(ZPinnerBX + ZPouterBX >= 2 && ZMinnerBX + ZMouterBX >= 2) bit41 = true;
206 
207  bool bit42=false; // beam 1 splash (-z)
208  if(ZMinnerBX >= 2) bit42 = true;
209 
210  bool bit43=false; // beam 2 splash (+z)
211  if(ZPinnerBX >= 2) bit43 = true;
212 
213  for ( unsigned i=0; i< ttBits_.size();++i ){
214  bool bit = false;
215  if ( names_.at(i) == names_[0] ) bit = bit32;
216  if ( names_.at(i) == names_[1] ) bit = bit33;
217  if ( names_.at(i) == names_[2] ) bit = bit34;
218  if ( names_.at(i) == names_[3] ) bit = bit35;
219  if ( names_.at(i) == names_[4] ) bit = bit36;
220  if ( names_.at(i) == names_[5] ) bit = bit37;
221  if ( names_.at(i) == names_[6] ) bit = bit38;
222  if ( names_.at(i) == names_[7] ) bit = bit39;
223  if ( names_.at(i) == names_[8] ) bit = bit40;
224  if ( names_.at(i) == names_[9] ) bit = bit41;
225  if ( names_.at(i) == names_[10]) bit = bit42;
226  if ( names_.at(i) == names_[11]) bit = bit43;
227  ttVec.at(i)=L1GtTechnicalTrigger(names_.at(i), ttBits_.at(i), 0, bit) ;
228  if ( edm::isDebugEnabled() ) LogTrace("AnaBsc") << "bit: "<<ttBits_[i] << " VALUE:"<<bit ;
229  }
230  } else ttVec.clear();
232  output.setGtTechnicalTrigger(ttVec);
233  iEvent.emplace(thePutToken_,std::move(output));
234 }
235 int BSCTrigger::getBSCNum( int id, float z ) const {
236  int zside = 0;
237  if ( z > 0 ) zside = 1;
238  if ( edm::isDebugEnabled() ) {
239  int det = (id&24)>>3;
240  int station = id&7;
241  LogTrace("BSCTrig")<<"id="<<id<<" zside="<<zside<<" det="<<det<<" station="<<station;
242  }
243  int BSCNum;
244  if (id&16) BSCNum=32+(id&1)+(zside<<1) ; // small paddles further from IP
245  else BSCNum= (id&15)+(zside<<4); // the BSC on the HF
246  return BSCNum;
247 }
248 
249 bool BSCTrigger::isInner( int id ) const {
250  return ( (id&8)>>3 ) ;
251 }
252 
253 bool BSCTrigger::isZplus( int id ) const {
254  return ( (id&16)>>4 ) ;
255 }
256 
257 //define this as a plug-in
#define LogDebug(id)
BSCTrigger(const edm::ParameterSet &)
Definition: BSCTrigger.cc:77
T getParameter(std::string const &) const
bool isDebugEnabled()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
const edm::EDPutTokenT< L1GtTechnicalTriggerRecord > thePutToken_
Definition: BSCTrigger.cc:62
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const edm::EDGetTokenT< CrossingFrame< PSimHit > > theHitsToken_
Definition: BSCTrigger.cc:61
int zside(DetId const &)
const double theCoincidence_
Definition: BSCTrigger.cc:59
const double theResolution_
Definition: BSCTrigger.cc:60
const std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:57
#define constexpr
int getBSCNum(int id, float z) const
Definition: BSCTrigger.cc:235
int iEvent
Definition: GenABIO.cc:230
bool isZplus(int id) const
Definition: BSCTrigger.cc:253
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isInner(int id) const
Definition: BSCTrigger.cc:249
#define LogTrace(id)
const std::vector< std::string > names_
Definition: BSCTrigger.cc:58
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:453
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: BSCTrigger.cc:102
~BSCTrigger() override
Definition: BSCTrigger.cc:88
def move(src, dest)
Definition: eostools.py:511
void setGtTechnicalTrigger(const std::vector< L1GtTechnicalTrigger > &gtTechnicalTriggerValue)