35 std::cout <<
"ProtonTaggerFilter: Initializing ..." << std::endl;
46 case 0:
std::cout <<
"Option chosen for beam 1: ingnore" << std::endl;
break;
47 case 1:
std::cout <<
"Option chosen for beam 1: 420" << std::endl;
break;
48 case 2:
std::cout <<
"Option chosen for beam 1: 220" << std::endl;
break;
49 case 3:
std::cout <<
"Option chosen for beam 1: 420 and 220" << std::endl;
break;
50 case 4:
std::cout <<
"Option chosen for beam 1: 420 or 220" << std::endl;
break;
52 <<
"Error: beam1mode cannot be " <<
beam1mode;
57 case 0:
std::cout <<
"Option chosen for beam 2: ingnore" << std::endl;
break;
58 case 1:
std::cout <<
"Option chosen for beam 2: 420" << std::endl;
break;
59 case 2:
std::cout <<
"Option chosen for beam 2: 220" << std::endl;
break;
60 case 3:
std::cout <<
"Option chosen for beam 2: 420 and 220" << std::endl;
break;
61 case 4:
std::cout <<
"Option chosen for beam 2: 420 or 220" << std::endl;
break;
63 <<
"Error: beam2mode cannot be " <<
beam2mode;
66 switch (beamCombiningMode)
68 case 1:
std::cout <<
"Option chosen: one proton is sufficient" << std::endl;
break;
69 case 2:
std::cout <<
"Option chosen: two protons should be tagged" << std::endl;
break;
70 case 3:
std::cout <<
"Option chosen: two protons should be tagged as 220+220 or 420+420" << std::endl;
break;
71 case 4:
std::cout <<
"Option chosen: two protons should be tagged as 220+420 or 420+220" << std::endl;
break;
76 if (((
beam1mode != 4) || (beam2mode != 4)) && (beamCombiningMode > 2)) {
77 std::cerr <<
"Warning: beamCombiningMode = " << beamCombiningMode
78 <<
" only makes sence with beam1mode = beam2mode = 4" << std::endl;
81 if (((
beam1mode == 0) || (beam2mode == 0)) && (beamCombiningMode > 1)) {
82 std::cerr <<
"Warning: You ask for 2 protons while one of the beams is set to ignore" << std::endl;
85 if ((
beam1mode == 0) && (beam2mode == 0)) {
86 std::cerr <<
"Warning: Both beams are set to ignore." << std::endl;
89 std::cout <<
"ProtonTaggerFilter: Initialized" << std::endl;
102 std::cout <<
"ProtonTaggerFilter: Getting ready ..." << std::endl;
104 edm::FileInPath myDataFile(
"FastSimulation/ForwardDetectors/data/acceptance_420_220.root");
107 std::cout <<
"Opening " << fullPath << std::endl;
108 TFile
f(fullPath.c_str());
110 if (
f.Get(
"description") !=
nullptr)
111 std::cout <<
"Description found: " <<
f.Get(
"description")->GetTitle() << std::endl;
113 std::cout <<
"Reading acceptance tables @#@#%@$%@$#%@%" << std::endl;
126 std::cout <<
"ProtonTaggerFilter: Ready" << std::endl;
142 iEvent.
getByLabel(
"generatorSmeared",evtSource);
146 if (genEvent->particles_empty()) {
147 std::cout <<
"empty source event" << std::endl;
155 bool isPileUp =
true;
157 bool isProduct = iEvent.
getByLabel(
"famosPileUp",
"PileUpEvents", pileUpSource);
160 pileUpEvent = pileUpSource->
GetEvent();
171 const double mp = 0.938272029;
172 const double Ebeam = 7000.0;
173 const float pzCut = 2500;
174 const float acceptThreshold = 0.5;
178 std::list<HepMC::GenParticle*> veryForwardParicles;
180 for ( HepMC::GenEvent::particle_const_iterator piter = genEvent->particles_begin();
181 piter != genEvent->particles_end();
187 float pz = p->momentum().pz();
188 if (((pz > pzCut) || (pz < -pzCut)) && ((p->status() == 0) || (p->status() == 1))) {
189 veryForwardParicles.push_back(p);
200 for ( HepMC::GenEvent::particle_const_iterator piter = pileUpEvent->particles_begin();
201 piter != pileUpEvent->particles_end();
207 float pz = p->momentum().pz();
208 if (((pz > pzCut) || (pz < -pzCut)) && ((p->status() == 0) || (p->status() == 1))) {
209 veryForwardParicles.push_back(p);
220 if (veryForwardParicles.empty())
return false;
225 float acc420b1, acc220b1, acc420and220b1, acc420or220b1;
226 float acc420b2, acc220b2, acc420and220b2, acc420or220b2;
228 acc420b1 = acc220b1 = acc420and220b1 = acc420or220b1 = 0;
229 acc420b2 = acc220b2 = acc420and220b2 = acc420or220b2 = 0;
239 for (std::list<HepMC::GenParticle*>::const_iterator
part = veryForwardParicles.begin();
240 part != veryForwardParicles.end();
246 float pz = p->momentum().pz();
247 float pt = p->momentum().perp();
248 float phi = p->momentum().phi();;
250 if ((pz > Ebeam) || (pz < -Ebeam))
continue;
255 if (pz>0) xi -= pz/Ebeam;
258 double t = (-pt*pt - mp*mp*xi*
xi) / (1-xi);
265 if (xi<0.0) xi=-10.0;
279 acc420or220b1 = acc420b1 + acc220b1 - acc420and220b1;
283 bool res420and220 = (acc420and220b1 > acceptThreshold);
284 bool res420 = (acc420b1 > acceptThreshold);
285 bool res220 = (acc220b1 > acceptThreshold);
287 if (res420and220) {nP1at220m++; nP1at420m++;}
288 else if (res420) nP1at420m++;
289 else if (res220) nP1at220m++;
291 if ((p->pdg_id() != 2212) && (res220 || res420 || res420and220)) {
292 std::cout <<
" !!! P got proton 1 at 420 m: pz = " << pz << std::endl;
293 if (res220)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 220 m along beam 1, pz = " << pz << std::endl;
294 if (res420)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 420 m along beam 1, pz = " << pz << std::endl;
295 if (res420and220)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 220 m & 420 m along beam 1, pz = " << pz << std::endl;
307 acc420or220b2 = acc420b2 + acc220b2 - acc420and220b2;
311 bool res420and220 = (acc420and220b2 > acceptThreshold);
312 bool res420 = (acc420b2 > acceptThreshold);
313 bool res220 = (acc220b2 > acceptThreshold);
315 if (res420and220) {nP2at220m++; nP2at420m++;}
316 else if (res420) nP2at420m++;
317 else if (res220) nP2at220m++;
319 if ((p->pdg_id() != 2212) && (res220 || res420 || res420and220)) {
320 std::cout <<
" !!! P got proton 1 at 420 m: pz = " << pz << std::endl;
321 if (res220)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 220 m along beam 2, pz = " << pz << std::endl;
322 if (res420)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 420 m along beam 2, pz = " << pz << std::endl;
323 if (res420and220)
std::cout <<
"got a particle with pid" << p->pdg_id() <<
" at 220 m & 420 m along beam 2, pz = " << pz << std::endl;
330 bool p1at220m = (nP1at220m>0) ?
true :
false;
331 bool p1at420m = (nP1at420m>0) ?
true :
false;
332 bool p2at220m = (nP2at220m>0) ?
true :
false;
333 bool p2at420m = (nP2at420m>0) ?
true :
false;
335 if ((nP1at220m > 1) && (
beam1mode!=1))
std::cout <<
" !!! " << nP1at220m <<
" proton(s) from beam 1 at 220 m" << std::endl;
336 if ((nP1at420m > 1) && (
beam1mode!=2))
std::cout <<
" !!! " << nP1at420m <<
" proton(s) from beam 1 at 420 m" << std::endl;
337 if ((nP2at220m > 1) && (
beam2mode!=1))
std::cout <<
" !!! " << nP2at220m <<
" proton(s) from beam 2 at 220 m" << std::endl;
338 if ((nP2at420m > 1) && (
beam2mode!=2))
std::cout <<
" !!! " << nP2at420m <<
" proton(s) from beam 2 at 420 m" << std::endl;
343 bool p1accepted =
false;
344 bool p2accepted =
false;
346 if ((
beam1mode==1) && p1at420m ) p1accepted =
true;
347 if ((
beam1mode==2) && p1at220m ) p1accepted =
true;
348 if ((
beam1mode==3) && p1at220m && p1at420m) p1accepted =
true;
349 if ((
beam1mode==4) && (p1at220m || p1at420m)) p1accepted =
true;
351 if ((
beam2mode==1) && p2at420m ) p2accepted =
true;
352 if ((
beam2mode==2) && p2at220m ) p2accepted =
true;
353 if ((
beam2mode==3) && p2at220m && p2at420m ) p2accepted =
true;
354 if ((
beam2mode==4) && (p2at220m || p2at420m)) p2accepted =
true;
362 if (p1accepted || p2accepted)
return true;
else return false;
365 if (p1accepted && p2accepted)
return true;
else return false;
368 if ((p1at220m && p2at220m) || (p1at420m && p2at420m))
return true;
else return false;
371 if ((p1at220m && p2at420m) || (p1at420m && p2at220m))
return true;
else return false;
T getParameter(std::string const &) const
void Init(TFile &, const std::string)
Get acceptance tables from root file.
AcceptanceTableHelper helper420beam1
Objects which actually compute the acceptance (one per detector or combination of detectors) ...
virtual void endJob()
endjob function of the EDFilter
AcceptanceTableHelper helper420a220beam1
AcceptanceTableHelper helper420a220beam2
#define DEFINE_FWK_MODULE(type)
unsigned int beamCombiningMode
choose how to combine data from the two beams (ask for 1/2 proton)
AcceptanceTableHelper helper220beam2
ProtonTaggerFilter(edm::ParameterSet const &p)
default constructor
unsigned int beam1mode
choose which of the detectors (FP420/TOTEM/both) will be used for beam 1
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
AcceptanceTableHelper helper220beam1
const HepMC::GenEvent * GetEvent() const
unsigned int beam2mode
choose which of the detectors (FP420/TOTEM/both) will be used for beam 2
~ProtonTaggerFilter() override
empty destructor
AcceptanceTableHelper helper420beam2
virtual void beginJob()
startup function of the EDFilter
std::string fullPath() const
bool filter(edm::Event &e, const edm::EventSetup &c) override
decide if the event is accepted by the proton taggers
float GetAcceptance(float, float, float)
Acceptance as a function of t, xi and phi.
Fast simulation of near-beam detector acceptance.