Page MenuHomeHEPForge

04_Simple_Cylindrical_Detector.cpp
No OneTemporary

04_Simple_Cylindrical_Detector.cpp

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
#include <stdio.h>
#include <iostream>
#include <math.h>
#ifdef windows
#include <windows.h>
#endif
#include "../../Includes/FROG/FROG_DetId.h"
#include "../../Includes/FROG/FROG_Geometry.h"
#include "../../Includes/FROG/FROG_Geometry.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_Events.h"
#include "../../Includes/FROG/FROG_Events.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_Element_Tools.h"
#include "../../Includes/FROG/FROG_Element_Tools.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_Net_Tools.h"
#include "../../Includes/FROG/FROG_Net_Tools.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_ReadCards.h"
#include "../../Includes/FROG/FROG_ReadCards.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_Coord.h"
#include "../../Includes/FROG/FROG_Coord.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_Path.h"
#include "../../Includes/FROG/FROG_Path.cpp" //Needed for reference
#include "../../Includes/FROG/FROG_ZLib.h"
#include "../../Includes/FROG/FROG_ZLib.cpp" //Needed for reference
void Build_Geometry();
void Build_Events();
void Build_1Event(FROG_Element_Event* event, unsigned int i);
void Build_Geometry()
{
// This element is the root of the "file" tree. (don't change this line)
FROG_Element_Base* prim = new FROG_Element_Base(C_PRIMARY);
// FROG_Element_Base* mygeom = new FROG_Element_Base(C_GEOMETRY);
// prim->addDaughter(mygeom);
FROG_Element_Base* mygeom = prim;
FROG_Element_Base_With_DetId_And_Name* tracker = new FROG_Element_Base_With_DetId_And_Name(9000000,"TRACKER");
mygeom->addDaughter(tracker);
unsigned int DetIdCount = 1;
for(int i=0;i<1;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
FROG_Element_Primitive_Cylinder* layer = new FROG_Element_Primitive_Cylinder(
400000000+DetIdCount, // DetId
50+i*10, // Radius
0, 0, 0, // Position
0, 0, 200+i*20, // Length
10, 2);
tracker->addDaughter(layer);
DetIdCount++;
}
FROG_Geometry* CustomGeom = new FROG_Geometry(prim);
CustomGeom->Save("Detector.geom");
FROG_ELEMENT::PrintTree(CustomGeom->prim);
return;
}
void Build_Events() {
// This element is the root of the "file" tree.
FROG_Events* events = new FROG_Events();
// Prepare to simulate 100 events.
for(unsigned int i=0;i<100;i++){
// Create a new event
FROG_Element_Event* event = new FROG_Element_Event(1,i);
// Fill the event with monte carlo
Build_1Event(event, i);
// Store the event
events->AddEvent(event);
if(!events->SaveInLive("SimulatedEvents.vis",false,false,2000000)){
printf("File Size Exeeded 2.000.000 bytes\n");
printf("Stop here\n");
exit(0);
}
}
events->SaveInLive("SimulatedEvents.vis",true,false,2000000);
// The following lines are used to check if the output .vis file can be read correctly:
std::cout << "--------- check output file ---------" << std::endl;
FROG_Events* evt = new FROG_Events();
evt->Load("SimulatedEvents.vis");
FROG_ELEMENT::PrintTree(evt->prim);
}
void Build_1Event(FROG_Element_Event* event, unsigned int i)
{
double theta = asin(50.0 /sqrt(50.0*50+100*100));
double Eta = -log(tan(theta/2.0));
printf("theta = %f --> eta = %f\n",theta,Eta);
FROG_Element_Base_With_DetId_And_Name* TestCollection = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK, "Test Candidates");
event->addDaughter(TestCollection);
FROG_Element_Base_With_DetId_And_Name* CandCollection1 = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+1, "Candidates:1*Eta");
FROG_Element_Event_Candidate* cand1 = new FROG_Element_Event_Candidate(100, 50000, Eta, 0.0628*i);
CandCollection1->addDaughter(cand1);
TestCollection->addDaughter(CandCollection1);
FROG_Element_Base_With_DetId_And_Name* CandCollection2 = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+2, "Candidates:2*Eta");
FROG_Element_Event_Candidate* cand2 = new FROG_Element_Event_Candidate(100, 50000, 2*Eta, 0.0628*i);
CandCollection2->addDaughter(cand2);
TestCollection->addDaughter(CandCollection2);
FROG_Element_Base_With_DetId_And_Name* CandCollection3 = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+3, "Candidates:3*Eta");
FROG_Element_Event_Candidate* cand3 = new FROG_Element_Event_Candidate(100, 50000, 3*Eta, 0.0628*i);
CandCollection3->addDaughter(cand3);
TestCollection->addDaughter(CandCollection3);
FROG_Element_Base_With_DetId_And_Name* CandCollectionI = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+4, "Candidates:-1*Eta");
FROG_Element_Event_Candidate* candI = new FROG_Element_Event_Candidate(100, 50000, -1*Eta, 0.0628*i);
CandCollectionI->addDaughter(candI);
TestCollection->addDaughter(CandCollectionI);
FROG_Element_Base_With_DetId_And_Name* CandCollectionZ = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+5, "Candidates: 0*Eta");
FROG_Element_Event_Candidate* candZ = new FROG_Element_Event_Candidate(100, 50000, 0*Eta, 0.0628*i);
CandCollectionZ->addDaughter(candZ);
TestCollection->addDaughter(CandCollectionZ);
FROG_Element_Base_With_DetId_And_Name* JetCollection = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+6, "Jet: Eta->-Eta & Phi->180ー+Phi");
FROG_Element_Event_Jet* Jet = new FROG_Element_Event_Jet(50000, -1*Eta, 3.1415+0.0628*i);
JetCollection->addDaughter(Jet);
TestCollection->addDaughter(JetCollection);
FROG_Element_Base_With_DetId_And_Name* MetCollection = new FROG_Element_Base_With_DetId_And_Name(EVTID_TRK+7, "Met: Eta->-Eta & Phi->180ー+Phi");
FROG_Element_Event_MET* Met = new FROG_Element_Event_MET(100,50000, -1*Eta, 3.1415+0.0628*i,0);
MetCollection->addDaughter(Met);
TestCollection->addDaughter(MetCollection);
}
int main()
{
#ifdef windows
SetDllDirectory("../../Lib");
#endif
// Build and Save the geometry
Build_Geometry();
// Build and Save the event collection
Build_Events();
}
// If everything is fine, You just have to update the FROG's config.txt to load your events file.
// You can for instance replace
// InputVisFile = ../test/SinglePion.vis;
// by
// InputVisFile = Examples/02_Display_Basics_Events/SimulatedEvents.vis;
// In case of questions, remarks or any other comments please contact us :
// Loic.Quertenmont@cern.ch, Vincent.Roberfroid@cern.ch

File Metadata

Mime Type
text/x-c
Expires
Sat, Dec 21, 3:51 PM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3950167
Default Alt Text
04_Simple_Cylindrical_Detector.cpp (6 KB)

Event Timeline