[CLOSED] Specific event selection in Dpm generator [message #13048] |
Thu, 09 February 2012 10:25 |
donghee
Messages: 385 Registered: January 2009 Location: Germnay
|
first-grade participant |
From: *dip.t-dialin.net
|
|
Hello everyone,
I'm trying to select and save a specific event type from DPM generator.
For instance, I would like to select and save only pi+pi- event from DPM generation.
In PndDpmDirect I can simply select those event after pid checking for generated event type.
Then I do not add any tracks into output file, if this condition is not satisfied. That mean only pi+pi- event have track information, and other event types are set to zero tracks.
After this modification in FairPrimaryGenerator, PndDpmDirect file, I want to save only pi+pi- event without any zero track event, which is marked by my decision, into my final output file. Now, I have a trouble to discarding zero track from my output file.
I'm wondering, are there some possible and simple way to select and save specific event.
One general way is of course handling of source code dpm_gen_.f.
I am not prefer this way.
Second convenient way for me is control setting or option at FairPrimaryGenerator, PndDpmDirect, and FairMCEventHeader after MC generation from DPM.
Thank you for your reading!
Donghee
[Updated on: Sun, 09 March 2014 13:32] by Moderator Report message to a moderator
|
|
|
Re: Specific event selection in Dpm generator [message #13049 is a reply to message #13048] |
Thu, 09 February 2012 11:27 |
donghee
Messages: 385 Registered: January 2009 Location: Germnay
|
first-grade participant |
From: *dip.t-dialin.net
|
|
Hello everyone,
I solve this problem with quite simple trick using while loop only in PndDpmDirect code.(posted below)
It might be useful that someone prepare a selector function inside PndDpmDirect in the future, if it is not exsiting.
Anyhow, thank you again for your reading...
Quote: |
// ----- Public method ReadEvent --------------------------------------
Bool_t PndDpmDirect::ReadEvent(FairPrimaryGenerator* primGen) {
int npart, i;
Double_t fX, fY, fZ, radius;
double Px[1000],Py[1000],Pz[1000],E[1000],Pm[1000],Wh[1000];
int Id[1000];
float Generator=0.; // Format in which events are produced (0=pythia, 1=pluto)
Double_t weight = 1.0;
Int_t activeCnt=0;
Int_t NIDs=0;
Int_t event_type = 844;
Int_t particle_number = 4;
double PID_type_1 = 211;
double PID_type_2 = -211;
//4pi = 844
//2pi = 422
//////////////////////////////////////////////////////////////////////// ///////////////////////Donghee Kang
//Selector!!!
while(1){
bool selector = false;
// run generator
dpm_gen__(&Generator, &fSeed);
// Loop over all produced particles
npart = lujets_.n;
if(npart == particle_number){//////////////////////////////////////////Donghee Kang
NIDs = 0;
for (i= 0; i< npart; ++i) {
Id[i]=lujets_.k[i+1000];
if( (Id[i] == PID_type_1) || (Id[i] == PID_type_2) ){
NIDs += TMath::Abs(Id[i]);
} //Id[i] check!!!
}//loop
if(NIDs == event_type){
for (i= 0; i< npart; ++i) {
Id[i]=lujets_.k[i+1000];
Px[i]=lujets_.p[i];
Py[i]=lujets_.p[i+1000];
Pz[i]=lujets_.p[i+2000];
Pm[i]=lujets_.p[i+4000];
E[i]=lujets_.p[i+3000];
Wh[i]=1.0;
/* Check if fGasmode is set */
fX = 0.;
fY = 0.;
fZ = 0.;
if (fGasmode == 1) {
// define position of track start
// Random 2D point in a circle of radius r (simple beamprofile)
radius = gRandom->Gaus(0,fRsigma);
gRandom->Circle(fX, fY, radius);
// calculate fZ according to some (probability) density function of the gas
fZ=fDensityFunction->GetRandom();
}
// add track
//printf("- I -: new particle at: %f, %f, %f ...\n", fX, fY, fZ);
primGen->AddTrack(Id[i], Px[i], Py[i], Pz[i], fX, fY, fZ);
}//loop
selector= true;
}// //////////////////////////////////////////
else{
selector = false;
}
}//npart == 4
if(selector){
//cout<<"Yes I have 4 pi+"<<endl;
break;
}
}//End of while
return kTRUE; //////////////////////////////////////////
}
|
|
|
|
Re: Specific event selection in Dpm generator [message #15371 is a reply to message #13049] |
Wed, 28 August 2013 18:28 |
MartinJGaluska
Messages: 203 Registered: March 2010 Location: Germany
|
first-grade participant |
From: *physik.uni-giessen.de
|
|
Hello all,
we ran now into the same problem as Donghee did more than a year ago (in the sense that we also wanted to filter the events which are produced by the dpm generator) while performing a background study. A solution was found pretty fast for our specific problem, but I believe that it would make sense to have a more general solution. Therefore, I implemented a filter for PndDpmDirect which can handle pretty general requests from the simulation macro in the form:
Dpm->AddFilterMinMax( 1, 5, 11, -211 ); // request at least 1 and at most 5 e- OR pi-
Dpm->AddFilterMinMax( 1, 5, -11, 211 ); // AND request at least 1 and at most 5 e+ OR pi+
Dpm->AddFilterMinMax( 3, 9999, 22 ); // AND request at least 3 and at most 9999 gamma
The standard behaviour is the same as before (i.e. no event filtering).
You can tell PndDpmDirect how often it should try to find a suitable event before giving up:
Dpm->SetFilterMaxTries(99999);
and it can tell you at the end of the simulation macro how many events dpm simulated in total to get the number of filtered events that you wanted as well as how many events reached the limit of tries without success:
if( UseDpm ){
cout << Dpm->GetNumberOfSimulatedEvents() << " events were simulated in dpm\n";
cout << Dpm->GetNumberOfFilterFailedEvents() << " unsuccessful attempts to find an event that suits your filters\n\n";
}
The code is currently still in testing and if you agree I would like to upload it to the trunk once it was tested to be reliable.
------------
EDIT:
Here was a paragraph about a restriction of the code which is obsolete now.
The restriction that you can add a filter for a specific pdg code ONLY ONCE has been removed in versions later than 2013-10-21:
------------
I am looking forward to reading your feedback.
Kind regards,
Martin
[Updated on: Wed, 09 April 2014 11:12] Report message to a moderator
|
|
|
|
Re: Specific event selection in Dpm generator [message #15373 is a reply to message #15372] |
Thu, 29 August 2013 11:10 |
MartinJGaluska
Messages: 203 Registered: March 2010 Location: Germany
|
first-grade participant |
From: *physik.uni-giessen.de
|
|
Hello Stefano,
sure, it would certainly be possible to integrate it in FairPrimaryGenerator if the experts agree.
I can either provide the code that I wrote for PndDpmDirect as an inspiration for the experts or I would need the advice of at least one of them to help me integrate it in FairPrimaryGenerator without breaking any functionality of PandaRoot or possibly other frameworks. Ideally, one could implement it so that no changes to all derived classes would be necessary.
-------
EDIT:
After talking to Klaus Götzen and Andreas Pitka I implemented the possibility for an arbitrary number of conditions per pdg code and also a maximum number of particles per event.
Also a filter just on particles' charges would be desirable.
In addition, a minimum and maximum (total/transversal/z) momentum should be implemented (both in the laboratory system as well as in arbitrary center of mass systems).
-------
Let's see what Mohammad and Florian think about it.
Kind regards,
Martin
[Updated on: Mon, 21 October 2013 16:40] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|