Retete CMSSW

Etapele de producere ale evenimentelor:

1) Event generation (IOMC/CosmicMuonGenerator)
- input events for the simulation are to be produced by a specified event generator source. There are called generically particle guns, and are 
particularly useful during testing. There are several types of particle guns, e.g., flat energy, flat Pt (transverse momentum), beam profile, 
cosmic muon generator.
- The generator creates a data event in memory of class edm::Event for each iteration of the event loop in the configuration file, and puts into the 
event the particles (or particle characteristics) it generates, in the form of HepMCProduct. The HepMCProduct is a wrapper around generator 
information recorded in the HepMC format (HepMC::GenEvent).


2) Simulation
- produces the simulated hits in the detector given the output of the generator. In order to simulate hits, you need to factor in the detector geometry, 
the magnetic field, and the detector simulation parameters. After the OscarProducer execution, calling Geant 4!!! and producing the simulated hits in 
the detectors
- producerea de digi-ti folosind modulul OscarProducer (Det.Simulation module) = simulated hits
- Geant4-based simulation of the physics processes that accompany passage of particles through hierarchy of volumes and materials that compose the 
CMS detector, and of the subdetector responsces (simulated hits).


3) Digitization of the simulated hits
- simulation of the electronics response to the hits in the detector; se foloseste: DigisToRecHit.cfg (process Clusterizer).

- In the old code, the first two steps were done by OSCAR , while the third one was done by ORCA. 


************************************************************************************
Comenzi utile:
- scp a1.root danteb1178@cms-p6-3.pg.infn.it:/home/danteb1178/mtcc/fisiereMTCC/
- scp b3.root tonoiu@lxplus.cern.ch:~/CMSSW_0_6_0_pre3/src/
- eval `scramv1 runtime -csh`
- cvs co -r V00-02-04 RecoTracker/TkHitPairs = instaleaza o anumita versiune a pachetului TkHitPairs
- cmscvsroot CMSSW = set the CVSROOT environment variable; 
- scramv1 list | grep CMSSW_0_7_0  = imi spune daca este CMSSW070 este instalat in sistem.
- 
************************************************************************************************************************************

Instalare CMG (cosmic muon generator)

   	cd mtcc/
scramv1 project CMSSW CMSSW_0_5_0 ...= Setup a new project development area. The new area will appear in the current working directory. 
				CMSSW_0_5_0 = versiunea de cmssw.
      cd CMSSW_0_5_0/src/
cmscvsroot CMSSW ...=??? ...cvs is a version control system.  Using it, you can record the history of your source files.
cvs co IOMC/CosmicMuonGenerator ...= face check up si  update al unor fisiere din IOMC/Co...
        cvs login ...= in caz de eroare este necasar un login
        cvs co IOMC/CosmicMuonGenerator
pico CosmicMuonsSurface.cfg
        cd ../../
scramv1 b ...=compilare Package IOMC/CosmicMuonGenerator
        cd CosmicMuonGenerator/test/
eval `scramv1 runtime -csh` ...eval = evaluate a tcl script; tcp is a scripting language for controlling and applications...= 
			Makes all the libraries known to SCRAMv1 accessible
cmsRun CosmicMuonsSurface.cfg ...=executie simulare
        pico CosmicMuonsSurface.cfg
        cmsRun CosmicMuonsSurface.cfg
        ls
        pico simcosmic.cfg
        pico CosmicMuonsSurface.cfg
cmsRun simcosmic.cfg
root simevents_flatptgun.root
        TBrowser kk
        .q
        cd ../test/
        pico CosmicMuonsSurface.cfg
************************************************************************************************************************************
 
 Setting up your Computing Environment:	(https://uimon.cern.ch/twiki/bin/view/CMS/WorkBookSetComputerNode)

- First verify that CMSSW release 0_7_0 is installed on your system:
scramv1 list | grep CMSSW_0_7_0  If installed, it will return a pointer of the form /afs/.../Releases/CMSSW/CMSSW_0_7_0 .
- To build the work area, run the scramv1 project command as follows: scramv1 project CMSSW CMSSW_0_7_0 
- You must setup your runtime environment every time you start work in your project area. 
cd CMSSW_0_7_0/src ; eval `scramv1 runtime -csh`; 

Access Modules from CVS Repository: Once your environment is set up, you're ready to put code in it and try things out. You'll need to use CVS to 
move code and configuration files to your area. To ensure that you get all the pieces of code that you need, access the code using the CVS checkout 
command "cvs co". 
- Set the CVS root to CMSSW: cmscvsroot CMSSW  
- Check the environment variable: echo $CVSROOT :pserver:anonymous@cmscvs.cern.ch:/cvs_server/repositories/CMSSW
- The first time you use this CVS repository, you'll need to log in to it: cvs login Enter password: 98passwd
- To find out what's in the repository, do: scramv1 list CMSSW .You'll see a list with names like CMSSW_x_y_z, some with other suffixes. The names 
point to directories, e.g., CMSSW CMSSW_0_7_0 --> /uscmst1/prod/sw/local/Releases/CMSSW_0_7_0 . For each listed directory, modules are under its src 
directory. To list the modules under this directory, use "ls".
- to run lots of different generation tests, you could check out the entire IOMC module: cvs co -r CMSSW_0_7_0 IOMC 

Set up ROOT:
- 
***********************************************************************************************************************************
How to Produce gene+simu+digi Data in CMSSW (https://uimon.cern.ch/twiki/bin/view/CMS/WorkBookGeneSimDigi#Generate_particles)

Generate particles:
- Monte Carlo Event Generators are used to generate high-energy-physics events, i.e. sets of outgoing particles produced in the interactions between 
two incoming particles. CMSSW provides different ways of producing and feeding generated events to the simulation.
- Pythia is the event generator typically used in CMS. The objective of Pythia is to provide as accurate as possible a representation of event properties
in a wide range of reactions.
- There are simpler generators that produce individual particles. These are called generically particle guns , and are particularly useful during testing.
There are several types of particle guns, e.g., flat energy, flat Pt (transverse momentum), beam profile, cosmic muon generator.
- The generator creates in memory an edm::Event , and for each iteration of the event loop, adds to the event the particles (or particle characteristics)
it generates, in the form of HepMCProduct. The HepMCProduct is a wrapper around generator information recorded in the HepMC format( HepMC::GenEvent ).
Job Splitting:
- You can define and split jobs in a variety of different ways. You can run a generator module together with an output module to dump information into 
an output ROOT file (in addition to putting it into the event in memory). Then a subsequent job could read in the file and do more processing on the data.
You can also run event generation in the same job with detector simulation and further processing, and send it to a ROOT file, or not.
Reading POOL ROOT files:
- You can read an output ROOT file by placing the following statement into your run configuration:
source = PoolSource { untracked string fileName = 'file:pythiaHZZ4mu.root' untracked int32 maxEvents = -1
# this mean unlimitted number of events, # i.e. through the end of the file }
Detector Simulation:
- Full-scale simulation of the CMS detector is based on the Geant4 toolkit. It relies on a fairly detailed description of the hierarchy of volumes and 
materials, and knowing which parts are "sensitive detector" (i.e., furnished with a readout) as opposed to "dead materials".
Through that hierarchy of volumes and materials the generated particles are traced (or a subset of the particles that fit into a cetain, user-specified,
kinematic region), and the physics processes that accompany particle passage through matter are modeled. Results of each particle's interactions with
matter are recorded in the form of simulated hits. An example of a simulated hit can be energy loss by a given particle within a "sensitive volume" of 
one of the subdetectors, stored along with several other characteristics of the interaction. Particles can be either "primary" (generated particle) or 
"secondary" (a result of Geant4-modeled interactions of a primary particle with matter).
- The CMSSW detector simulation software is organized as a single module OscarProducer which plugs directly into the cmsRun framework executable.
As any module, OscarProducer comes with a set of configuration parameters. For user's convenience, we distribute with the release a standard set of 
OscarProducer parameters, in a single file that can be included, literaly with the "include" statement, into user's run configuration file. 
Geometry and Magnetic Field:
- The standard CMS detector geometry configuration used by the detector simulation is loaded via a set of two instructions: an "include" statement to 
read in the Geometry/CMSCommonData/data/cmsSimIdealGeometryXML.cfi file, and an EventSetup module (es_module) with the geometry in it.
A private configuration can replace the official cfi file for specific studies. 
- If for a specific study you want to switch off the magnetic field, use the bool UseMagneticField flag in the OscarProducer module
Detector Simulation Module : OscarProducer:
- The simulation of the detector response is invoked in the configuration file by including the following in the run configuration of the
SimG4Core/Application/data/SimG4Object.cfi file (inside of which OscarProducer is called): 
 "include "SimG4Core/Application/data/SimG4Object.cfi" . This provides default configuration of the ParameterSet for the OscarProducer module













************************************************************************************************************************************
Legenda:

- RecHit = Reconstructed Hits. RecHits have a meaning only in the context of the track they belong to, since a cluster is fitted to a rechit taking into 
	account the information of the track. Such RecHits make little sense outside this context.
- scram = Software Configuration, Release And Management - a build and configuration management system
- scramv1 b = pentru a compila un pachet CMSSW; Optiuni = -v, -k ; The -v options asks for verbosity, the -k tells scram not to stop at the first error.
- es_module = EventSetup module