<h1align="left">How to Display a Basic Event comming from <u><strong>Your</strong></u> Experimental Data ? </h1>
<p> This project contains 3 functions + the main :<br/>
Build_Geometry() method will create the geom file associated to our detector.<br/>
In this example, we'll build a more realistic appartus.<br/>
Our experiment will be composed of 10 tracking planes. </p>
<p> The Build_1Event() method will fill the myEvents objects with all data related to 1 Event.<br/>
In our cases, random variables will be used inside this function to simulate a particle gun.</p>
<p>The myEvents will be created by the third function Build_Events(). This method will also call Build_1Event() N Times.<br/>
Where N is the number of events we want to store/display.</p>
<p> Finally the main() function will first call the GeometryBuilder, then initialise the MyEvents objects <br/>
After that, it will enter in the events loop. And call the Build_1_Events function at each loop.<br/>
Finally, we'll store events data in a .vis file which can be read by FROG.</p>
<h2>1. The Includes</h2>
<p>Includes are basically the same than in the previous tutorial. Except that FROG_Events.h and FROG_Element_Event_Track.h have been added. The first one, will do exactly same thing that FROG_Element_Geometry. It contains the Load/Save functions. The second one will store our event data. Which will be a track in this example. </p>
<p>This I will note comment because it is the topic of the previous tutorial. We use exactly the same Idea. The Geometry is composed of 10 tracking layer. Orthogonal to the Z axis. Each layer are square plane with a dimention of 100 x 100 (cm). The layers are positioned on (0,0,50*i) where i = 0, 1, 2, ..., 10 (so actually we have 11 layers ;) ) <br/>
We create also 2 others geometry objects : the particle gun (at 0,0,-300) and what I call a mirror wall (at 0,0,600). This object is just a cube. That will reflect our beam, exactly as a mirror does with the light. Add the end of the fucntion I save the geometry into the file "MyCustomTracker.geom".</p>
<preclass="codebox">void Build_Geometry()
{
<spanclass="Style2"> // This element is the root of the "file" tree. (don't change this line)</span>
ROG_Element_Base* prim = new FROG_Element_Base(C_PRIMARY);
<spanclass="Style2"> // This element is the geometry branch of the tree. (don't change this line)
// When the element have been created, we have to attach it to the root (or more generally to the mother branch).</span>
FROG_Element_Base* mygeom = new FROG_Element_Base(C_GEOMETRY);
prim->addDaughter(mygeom);
<spanclass="Style2"> // This a particular geometry branch : this allow us to group all the detectors attached to this branch.
// Moreover, this group of detector as a detId, which allow us to easily "call" this group (e.g. for the display).
// Warning : be sure that the detId is not already use by an other detecor. (detId should be bigger than 1000000).
// Warning : an empty group (containing 0 elements) can not be save.</span>
FROG_Element_Base_With_DetId* tracker = new FROG_Element_Base_With_DetId_And_Name(9000000,"Tracker");
mygeom->addDaughter(tracker);
<spanclass="Style2">
// This variable will allow us to do not use twice the same detId.</span>
unsigned int DetIdCount = 1;<br/><spanclass="Style2"><br/> // We'll fill the tracker group with 10 primitive objects. A lots of primitive objects can be use in FROG.
// You can find all the primitive header files in <FROGDIR>/soft/Includes/FROG/FROG_Element_Primitive_*.h
// There is also some CMS oriented dataformat : <FROGDIR>/soft/Includes/FROG/FROG_Element_Geom_*.h
// Do not hesitate to add your own primitive objects. There are really easy to do (takes an existing primitive as example
// and copy/paste to build your own).</span>
for(int i=0;i<=10;i++){
FROG_Element_Primitive_Rectangle* layer = new FROG_Element_Primitive_Rectangle(400000000+DetIdCount,
0 ,0 ,50*i, //Position
50 ,0 ,0 , //Width
0 ,50 ,0 ); //Length
tracker->addDaughter(layer);
DetIdCount++;
}
<spanclass="Style2"> // This group will contains all no realistic objects. For Instance, a cube will symbolised the Particle Gun.
// And an other cube will symbolise the mirror wall.</span>
FROG_Element_Base_With_DetId* others = new FROG_Element_Base_With_DetId_And_Name(8000000,"Others");
mygeom->addDaughter(others);
FROG_Element_Primitive_Cube* End = new FROG_Element_Primitive_Cube(400000000+DetIdCount,
0 ,0 ,600, //Position
50 ,0 ,0 , //Width
0 ,50 ,0 , //Length
0 ,0 ,50 ); //Thickness
others->addDaughter(End); DetIdCount++;
FROG_Element_Primitive_Cube* PG = new FROG_Element_Primitive_Cube(400000000+DetIdCount,
0 ,0 ,-300, //Position
5 ,0 ,0 , //Width
0 ,5 ,0 , //Length
0 ,0 ,50 ); //Thickness
others->addDaughter(PG); DetIdCount++;
<spanclass="Style2"> // Now that the geometry tree is build. We can create the geometry objects with this tree. The geometry Object
// will handle the writting/reading of geometry files. It has also a very useful function to get a branch or a leaf of the tree
// from his detId (Geometry::FindByDetId).</span>
FROG_Geometry* CustomGeom = new FROG_Geometry(prim);
<p>Now, we can create the Event Tree. As it is done for the geometry, first we need a root of type FROG_Element_Base with a chunkId of type C_PRIMARY.<br/>
Then we can add event branch on this root. Each branch should be of type FROG_Element_Event. The constructor of this method can take the EventNumber and the RunNumber as parameter. Default values are 0. Then we shoudl fill the Event branch with the data of the particular event. This is the job of the Build_1Event function. This function take a pointer of the event branch in argument. These operation are repeated N(=10) times. In order to simulate/store 10 events. Of course you can increase this Number in order to display more events (there is no limitation on the number of events). Finally, When the tree is complete, we can create a FROG_Events object, which will allow us to save the tree on the disk. Thanks to the function save. Let's call the events file : "SimulatedEvents.vis"</p>
<preclass="codebox">void Build_Events()
{
<spanclass="Style2"> // This element is the root of the "file" tree. (don't change this line)</span>
FROG_Element_Base* prim = new FROG_Element_Base(C_PRIMARY);
<spanclass="Style2"> // Prepare to simulate 10 events.</span>
for(unsigned int i=0;i<10;i++){
<spanclass="Style2"> // Create a new event</span>
FROG_Element_Event* event = new FROG_Element_Event(1,i);
<spanclass="Style2"> // Fill the event with monte carlo</span>
Build_1Event(event);
<spanclass="Style2"> // Store the event</span>
prim->addDaughter(event);
}
<spanclass="Style2"> // Save the event tree on disk</span>
FROG_Events* events = new FROG_Events(prim);
events->Save("SimulatedEvents.vis");
<spanclass="Style2"> // print the tree of all elements
// FROG_ELEMENT::PrintTree(prim); </span>
}</pre>
<h2>5. Build One Event</h2>
<p>This is the most important function. (and basically the only one you have to change). In this particular example, we need to simulate the event and to store it at the same time. So first, I define a large number of variables that are used to define the particle gun direction and position, particle direction and Pt. </p>
<p>Then I create 2 FORG_Objects. The first one is a FROG_Element_Base_With_DetId it will contains all the reco tracks in the event. (we will have only one track... but we want to put this track in a "group" in order to give it a name). The "name" of this group is no more a DetId, but and EvtId which is actually the same that the DetId but for event.<br/>
The second object is the track itself. This object is of the type FROG_Element_Event_Track. There is a lot of predefine Event_Object that you can use to store and display your events. Some of them are listed bellow (and an other tutorial will explains you how to create your own Objects) : </p>
<ul>
<li>Frog_Element_Event_CaloHit</li>
<li>Frog_Element_Event_Hit</li>
<li>Frog_Element_Event_Segment</li>
<li>Frog_Element_Event_Sim_Hit</li>
<li>Frog_Element_Event_Sim_Track</li>
<li>Frog_Element_Event_Sim_Vertex</li>
<li>Frog_Element_Event_Track</li>
</ul>
<p>The constructor of the FROG_Element_Event_Track takes the P, Pt and Chi2 as input. The first parameter should be 0 (this argument will be remove soon... it is there only for back-portability). This object will take the Hits on the tracker layer as daughters/leaves. </p>
<p>So we have to create the hits on all the layers... So the following is basically the particle propagation in the detector (this step can be done with Geant4). When the particle cross a layer, I just create a new hit. Which is define by the DetId of the layer that produce the Hit, a X,Y,Z position (in the global frame) and an energyLoss (always equal to 0 in this tutorial). Also, if the particle reach the "mirrow wall" I just flip the Z component of the particle momentum. <br>
</p>
<p>Finally, I just plug the track branch on the trackCollection branch. And the trackCollection branch on the Event branch. </p>
<p>Now, as usual, we have to setup the FROG config file in order to display what we want.We can specify the geometry file, the events file.<br/>
But also the Geometry we want to display (9000000=Tracker & 8000000=MirrorWall+ParticleGun) and Event data we want to display (23100000) = RecoTracks.</p>
<p>Then we can set up views. It can be nice to have 3 views for this experiment : The standard 3D view, a longitudinal 2D view and a transversal 2D view (not so usefull!).<br/>
Finally we can set the style (color, thicknes, marker ans so on) of the recoTracks. The full config file can be found <ahref="config.txt">here</a>. </p>
<preclass="codebox2"><spanclass="Style2">//It is possible to load other config file from this one.</span>