test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
35 
38 
39 
40 //
41 // class declaration
42 //
43 
44 class BSCTrigger : public edm::EDProducer {
45 public:
46  explicit BSCTrigger(const edm::ParameterSet&);
47  ~BSCTrigger();
48 
49 private:
50  virtual void beginJob() override ;
51  virtual void produce(edm::Event&, const edm::EventSetup&) override;
52  virtual void endJob() override ;
53  int getBSCNum(int id, float z);
54  bool isInner(int id);
55  bool isZplus(int id);
56  // ----------member data ---------------------------
57  std::vector<unsigned> ttBits_;
58  std::vector<std::string> names_;
59  unsigned nEvt_;
63  int theNouter_;
64  int nevt_;
66 };
67 
68 //
69 // constants, enums and typedefs
70 //
71 
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81 {
82  ttBits_=iConfig.getParameter< std::vector<unsigned> >("bitNumbers");
83  names_= iConfig.getParameter< std::vector<std::string> >("bitNames");
84  theCoincidence_= iConfig.getParameter<double>("coincidence");
85  theResolution_= iConfig.getParameter<double>("resolution");
86  TheHits_tag_= iConfig.getParameter<edm::InputTag>("theHits");
87  produces<L1GtTechnicalTriggerRecord>();
88  nevt_=0;
89 }
90 
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called to produce the data ------------
107 {
108  std::vector<L1GtTechnicalTrigger> ttVec(ttBits_.size());
109  std::vector<float>EnergyBX(32);
110  std::vector<float>EnergyBXMinusDt(32);
111  int ZMinnerBX=0, ZMouterBX=0;
112  int ZPinnerBX=0, ZPouterBX=0;
113  int ZMinnerBXMinusDt=0, ZMouterBXMinusDt=0;
114  int ZPinnerBXMinusDt=0, ZPouterBXMinusDt=0;
115  ++nevt_;
116  std::auto_ptr<L1GtTechnicalTriggerRecord> BscRecord;
117  float MipFraction=0.5;
118  float MipEnergy=0.0027;
119  float theThreshold=MipFraction*MipEnergy;
120 
122  iEvent.getByLabel(TheHits_tag_, cf);
123 
124  if (!cf.failedToGet()) {
125  for ( int c=0;c<32;++c){
126  EnergyBX[c]=0;
127  EnergyBXMinusDt[c]=0;
128  }
129  std::auto_ptr<MixCollection<PSimHit> > theBSCHitContainer( new MixCollection <PSimHit>(cf.product()));
131  float dt1,dt2;
134  if ( edm::isDebugEnabled() ) LogDebug("BSCTrig")<<" ----------------new event ---with "<<theBSCHitContainer->size()<<" hits in the BSC";
135 
136  // collect total deposited energy in BSC segments -> EnergyBX[segment id], in GeV units ---------------------------------------------------------------
137  for (itHit = theBSCHitContainer->begin(); itHit != theBSCHitContainer->end(); ++itHit) {
138  float zh=itHit->entryPoint().z()/10;
139  int id=getBSCNum(itHit->detUnitId(),zh);
140  if ( id > 31 ) continue; // the small 2 paddles further from the IP
141  float t=itHit->timeOfFlight();
142 
143  if ( edm::isDebugEnabled() ) {
144  float rh=sqrt(itHit->entryPoint().x()*itHit->entryPoint().x()+itHit->entryPoint().y()*itHit->entryPoint().y())/10;
145  LogTrace("BSCTrig")<<" BSC Num "<<id<<" z="<<zh<<" isZplus="<<isZplus(id)<<" Hit DetId="<<getBSCNum(id,zh)<<" r="<<rh<<" isInner="<<isInner(id);
146  LogTrace("BSCTrig")<<" Hit time="<<t<<" accepted range=["<<dt2<<","<<dt1<<"] from a "<<abs(itHit->particleType())<<" with energy " <<itHit->energyLoss();
147  }
148  if (fabs(t)> dt1 || fabs(t) <dt2 ) continue;
149  if (t>0) EnergyBX[id]+=itHit->energyLoss();
150  else EnergyBXMinusDt[id]+=itHit->energyLoss();
151  }
152 
153  // count number of segments hit in inner/outer and +z, -z ---------------------------------------------------------------------------------------------
154  for ( unsigned int ipad = 0 ; ipad<32; ipad++) {
155  if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" EnergyBX["<<ipad<<"]="<<EnergyBX[ipad];
156  // hits after the bunch crossing
157  if ( EnergyBX[ipad] > theThreshold ) {
158  if ( isZplus(ipad)) {
159  if ( isInner(ipad) ) ZPinnerBX++;
160  else ZPouterBX++;
161  } else {
162  if ( isInner(ipad) ) ZMinnerBX++;
163  else ZMouterBX++;
164  }
165  }
166  // hits before the bunch crossing
167  if ( EnergyBXMinusDt[ipad] > theThreshold ) {
168  if ( isZplus(ipad)) {
169  if ( isInner(ipad) ) ZPinnerBXMinusDt++;
170  else ZPouterBXMinusDt++;
171  } else {
172  if ( isInner(ipad) ) ZMinnerBXMinusDt++;
173  else ZMouterBXMinusDt++;
174  }
175  }
176  }
177 
178  if ( edm::isDebugEnabled() ) LogTrace("BSCTrig")<<" Zplus I="<<ZPinnerBX<<" Zminus I="<<ZMinnerBX<<" Zplus O="<<ZPouterBX<<" Zminus O="<<ZMouterBX;
179 
180  // minimum bias technical triggers that are also connected to 'external condition' triggers -----------------
181  bool bit32=false; // min bias inner >=1
182  if(ZPinnerBX >= 1 && ZMinnerBX >= 1) bit32 = true;
183 
184  bool bit33=false; // min bias inner >=2
185  if(ZPinnerBX >= 2 && ZMinnerBX >= 2) bit33 = true;
186 
187  bool bit34=false; // min bias OR
188  if(ZPinnerBX + ZMinnerBX + ZPouterBX + ZMouterBX >= 1) bit34 = true;
189 
190  bool bit35=false; // high multiplicity
191  if(ZPinnerBX == 8 && ZMinnerBX == 8) bit35 = true;
192 
193  // beam halo technical triggers ----------------------------------------------------------------
194  bool bit36=false; // beam 2 halo inner
195  if(ZPinnerBX >= 1 && ZMinnerBXMinusDt >= 1) bit36 = true;
196 
197  bool bit37=false; // beam 2 halo outer
198  if(ZPouterBX >= 1 && ZMouterBXMinusDt >= 1) bit37 = true;
199 
200  bool bit38=false; // beam 1 halo inner
201  if(ZMinnerBX >= 1 && ZPinnerBXMinusDt >= 1) bit38 = true;
202 
203  bool bit39=false; // beam 1 halo outer
204  if(ZMouterBX >= 1 && ZPouterBXMinusDt >= 1) bit39 = true;
205 
206  // minimum bias technical triggers ---------------------------------------------------------
207  bool bit40=false; // min bias all >=1
208  if(ZPinnerBX + ZPouterBX >= 1 && ZMinnerBX + ZMouterBX >= 1) bit40 = true;
209 
210  bool bit41=false; // min bias all >=2
211  if(ZPinnerBX + ZPouterBX >= 2 && ZMinnerBX + ZMouterBX >= 2) bit41 = true;
212 
213  bool bit42=false; // beam 1 splash (-z)
214  if(ZMinnerBX >= 2) bit42 = true;
215 
216  bool bit43=false; // beam 2 splash (+z)
217  if(ZPinnerBX >= 2) bit43 = true;
218 
219  for ( unsigned i=0; i< ttBits_.size();++i ){
220  bool bit = false;
221  if ( names_.at(i) == names_[0] ) bit = bit32;
222  if ( names_.at(i) == names_[1] ) bit = bit33;
223  if ( names_.at(i) == names_[2] ) bit = bit34;
224  if ( names_.at(i) == names_[3] ) bit = bit35;
225  if ( names_.at(i) == names_[4] ) bit = bit36;
226  if ( names_.at(i) == names_[5] ) bit = bit37;
227  if ( names_.at(i) == names_[6] ) bit = bit38;
228  if ( names_.at(i) == names_[7] ) bit = bit39;
229  if ( names_.at(i) == names_[8] ) bit = bit40;
230  if ( names_.at(i) == names_[9] ) bit = bit41;
231  if ( names_.at(i) == names_[10]) bit = bit42;
232  if ( names_.at(i) == names_[11]) bit = bit43;
233  ttVec.at(i)=L1GtTechnicalTrigger(names_.at(i), ttBits_.at(i), 0, bit) ;
234  if ( edm::isDebugEnabled() ) LogTrace("AnaBsc") << "bit: "<<ttBits_[i] << " VALUE:"<<bit ;
235  }
236  } else ttVec.clear();
237  std::auto_ptr<L1GtTechnicalTriggerRecord> output(new L1GtTechnicalTriggerRecord());
238  output->setGtTechnicalTrigger(ttVec);
239  iEvent.put(output);
240 }
241 // ------------ method called once each job just before starting event loop ------------
243 {
244 }
245 
246 // ------------ method called once each job just after ending the event loop ------------
248 }
249 
250 int BSCTrigger::getBSCNum( int id, float z ) {
251  int zside = 0;
252  if ( z > 0 ) zside = 1;
253  if ( edm::isDebugEnabled() ) {
254  int det = (id&24)>>3;
255  int station = id&7;
256  LogTrace("BSCTrig")<<"id="<<id<<" zside="<<zside<<" det="<<det<<" station="<<station;
257  }
258  int BSCNum;
259  if (id&16) BSCNum=32+(id&1)+(zside<<1) ; // small paddles further from IP
260  else BSCNum= (id&15)+(zside<<4); // the BSC on the HF
261  return BSCNum;
262 }
263 
264 bool BSCTrigger::isInner( int id ){
265  return ( (id&8)>>3 ) ;
266 }
267 
268 bool BSCTrigger::isZplus( int id ){
269  return ( (id&16)>>4 ) ;
270 }
271 
272 //define this as a plug-in
#define LogDebug(id)
BSCTrigger(const edm::ParameterSet &)
Definition: BSCTrigger.cc:80
virtual void beginJob() override
Definition: BSCTrigger.cc:242
T getParameter(std::string const &) const
bool isDebugEnabled()
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isZplus(int id)
Definition: BSCTrigger.cc:268
int zside(DetId const &)
float float float z
float theResolution_
Definition: BSCTrigger.cc:61
unsigned nEvt_
Definition: BSCTrigger.cc:59
std::vector< unsigned > ttBits_
Definition: BSCTrigger.cc:57
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > names_
Definition: BSCTrigger.cc:58
bool isInner(int id)
Definition: BSCTrigger.cc:264
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
virtual void endJob() override
Definition: BSCTrigger.cc:247
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::InputTag TheHits_tag_
Definition: BSCTrigger.cc:65
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
#define LogTrace(id)
int theNouter_
Definition: BSCTrigger.cc:63
bool failedToGet() const
Definition: HandleBase.h:79
T const * product() const
Definition: Handle.h:81
int getBSCNum(int id, float z)
Definition: BSCTrigger.cc:250
float theCoincidence_
Definition: BSCTrigger.cc:60
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: BSCTrigger.cc:106
int theNinner_
Definition: BSCTrigger.cc:62