]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/README
Build TGeo geometry also when running with Geant4
[u/mrichter/AliRoot.git] / MUON / README
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ==========================================================
19 Please add  to this README file all information concerning 
20 config files, simulation, digitalization, clusterization, 
21 reconstruction and macro analysis
22
23 ==========================================================
24  How to check that your aliroot is working well
25 ==========================================================
26 There is a script file AlirootRun_MUONtest.sh which 
27 allows for simulating, reconstructing and making the
28 invariant analysis of the generated Upsilon (1S).
29 The used configuration file is Config.C in MUON 
30 directory.
31 You have to type :
32 source $ALICE_ROOT/MUON/AlirootRun_MUONtest.sh 
33 The results of this test are saved in test_out/ directory.
34 Please note that the CDB (Condition DataBase) is now always *required* 
35 to perform either simulation or reconstruction. For the moment, a version
36  of that CDB is stored in CVS, so you should have one already in MUON/Calib
37 subdirectories.
38
39 ==========================================================
40  How to check that your aliroot is working VERY well
41 ==========================================================
42 There is a script file AlirootRun_MUONlongtest.sh which
43 allows for simulating, reconstructing and making the
44 -+invariant analysis of the generated Upsilon (1S).
45 This script generates a large number of Upsilon (20k) 
46 in order to access differential quantities. 
47 The used configuration file is Config.C in MUON
48 directory.
49 One should really run this script to check if the MUON 
50 code can process a large number of events WITHOUT errors,
51 in particular before making important commits !!
52
53 You have to type :
54 $ALICE_ROOT/MUON/AlirootRun_MUONtestlong.sh
55 The results of this test are saved in testlong_out/ directory
56 and will be kept in CVS
57
58 (NOTE: the macros performing the calculations/plots MUONefficiency.C 
59 and MUONplotEfficiency.C are also able to handle J/Psi if 
60 Config.C is modified accordingly )
61
62 ==========================================================
63  How to run a MUON generation
64 ==========================================================
65 aliroot
66 root [0] gAlice->Run(10,"$ALICE_ROOT/MUON/Config.C");
67
68 1 single muon of 7 GeV/c in the MUON spectrometer 
69 acceptance will be simulated using geant3. 
70 Hit information will be store in the root file in the
71 execution directory.
72 If you want to change the option or to define a new directory
73 for hits, you have to do the following before:
74 root [0] gAlice->SetConfigFunction("Config( \"/home/martinez/aliroot/work_NewIO/test/\" , \"box\" );"); 
75
76 ============================================================
77  How to dump the content of Root data files 
78 ============================================================
79 To check the content of Root data files, the AliMUONData class
80 provides the functions to produce an ASCII output on the screen
81 which can be redirected on the file:
82
83 aliroot
84 root [0] AliMUONData data("galice.root");
85 root [1] data.DumpKine(5);       > dump.kine
86 root [2] data.DumpHits(5);       > dump.hits
87 root [3] data.DumpDigits(5);     > dump.digits
88 root [4] data.DumpSDigits(5);    > dump.sdigits
89 root [5] data.DumpRecPoints(5);  > dump.recpoints
90 root [6] data.DumpRecTrigger(5); > dump.rectrigger
91
92 If the event number in the function argument is not specified,
93 data are dumped for all events.
94
95
96 ============================================================
97  How to check the Geometry with the new Geometrical modeler
98  ftp://root.cern.ch/root/doc/chapter16.pdf
99  http://agenda.cern.ch/fullAgenda.php?ida=a05212
100 ============================================================
101 gAlice->Init("$ALICE_ROOT/MUON/Config.C");
102 gGeoManager->GetMasterVolume()->Draw();
103
104
105 ============================================================
106  How to check the overlap with the new Geometrical modeler
107  ftp://root.cern.ch/root/doc/chapter16.pdf
108  http://agenda.cern.ch/fullAgenda.php?ida=a05212
109 ============================================================
110 gAlice->Init("$ALICE_ROOT/MUON/Config.C");
111 gGeoManager->CheckOverlaps();
112 gGeoManager->PrintOverlaps();
113
114 ============================================================
115  How to run MUONdisplay
116 ============================================================
117 First you need to perform a full simulation: 
118 generation, digitalisation and clusterisation
119 To run MUONdisplay with Root 5.04/00 you need to get a fix in
120 the gpad/src/TPad.cxx from Root CVS:
121  cvs update -r 1.200 gpad/src/TPad.cxx
122 and recompile root. 
123
124 .L $ALICE_ROOT/MUON/MUONdisplay.C
125 MUONdisplay(0,"galice.root")
126
127 ============================================================
128  Tracking parameters, cuts, energy loss and physics processes
129 ============================================================
130 Tracking parameters in MUON are automatically defined by GEANT
131 MUON takes the default values of CUTs  and physics processes
132 defined by the Config files, except for the gas mixture medium 
133 of the tracking chambers. The CUT's and physics processes of
134 the gas mixture medium  is then defined in the galice.cuts file
135 in the data directory. In particular ILOSS parameter MUST be
136 equal unity (1) in order simulate a realistic energy loss
137 distribution (mean value and fluctuations) in the active gas.
138
139 ============================================================
140  Tracking of particle in the magnetic field
141 ============================================================
142 GEANT has two ways for tracking charged particles in the 
143 magnetic field: HELIX et RKUTA.
144 HELIX is faster and works well if the gradient of magnetic 
145 field is small. 
146 For MUON, HELIX is a not a good approximation and we must 
147 use RKUTA to get the optimal mass resolution of the 
148 spectrometer. The choice of HELIX or RKUTA is done in the
149 config file when the magnetic field is defined:
150   AliMagFMaps* field = new AliMagFMaps("Maps","Maps", TRACKING, FACTOR, MAXB, AliMagFMaps::k5kG);
151   gAlice->SetField(field);
152 TRACKING must be 1 for RKUTA and 2 for HELIX (the default value for aliroot is 2 (HELIX))
153 FACTOR allows you to set the magnetic field to 0, just putting FACTOR=0. Default value is 1.
154 MAXB is the maximum magnetic field which is 10.T
155
156 ===========================================================
157  MUON cocktail for physics ..............
158 ===========================================================
159 There is a MUON cocktail generator of the muon sources in the
160 EVGEN directory. This class derives from AliGenCocktail.
161 In the init of this class I have filled the cocktail with 
162 the muon sources: J/Psi, Upsilon, Open Charm, Open Beauty, 
163 Pion, Kaons. The code needs only the production cross section 
164 at 4pi (for the moment this values are in the code since I 
165 prefere them do not be modified), and the code calculates the  
166 rate of particles in the acceptance, making the scaling based 
167 on the number of collisions for the hard probes and on the  
168 number of participants for soft sources: Pions and Kaons.
169
170 In the Genereate of this class all entries in the cocktail 
171 are called and we define a "primordial trigger" with requires 
172 a minimum number of muons above a Pt cut in the required acceptance.
173 In order to normalized to the real number of simulated events, 
174 there are 2 data members in the class fNsuceeded adn fNGenerate 
175 which tell us what is the biais source.
176
177 Enclose an example to use this generator:   
178 AliGenMUONCocktail * gener = new AliGenMUONCocktail();
179 gener->SetPtRange(1.,100.);       // Transverse momentum range  
180 gener->SetPhiRange(0.,360.);    // Azimuthal angle range 
181 gener->SetYRange(-4.0,-2.4);
182 gener->SetMuonPtCut(1.);
183 gener->SetMuonThetaCut(171.,178.);
184 gener->SetMuonMultiplicity(2);
185 gener->SetImpactParameterRange(0.,5.); // 10% most centra PbPb collisions
186 gener->SetVertexSmear(kPerTrack);  
187 gener->SetOrigin(0,0,0);        // Vertex position
188 gener->SetSigma(0,0,0.0);       // Sigma in (X,Y,Z) (cm) on IP position
189 gener->Init();
190  
191 ================================================================
192  csh Script for the full reconstruction with raw data generator
193 ================================================================
194 The rawdata generation and analysis is working with the new segmentation.
195 So the config file must use the version "AliMUONFactoryV3"
196
197 Generation
198 The method AliSimulation::SetWriteRawData("MUON") enables on 
199 the muon rawdata generation
200 aliroot -b << EOF  
201 AliSimulation MuonSim("$ALICE_ROOT/MUON/Config.C")
202 MuonSim.SetMakeTrigger("MUON");
203 MuonSim.SetWriteRawData("MUON")
204 MuonSim.Run(10)
205 .q
206 EOF
207
208 Reconstruction
209 aliroot -b << EOF 
210 AliReconstruction MuonRec("galice.root");
211 MuonRec.SetInput("$YOUR_WORKING_DIRECTORY/");  Do not forget the slash at the end!
212 MuonRec.SetRunVertexFinder(kFALSE);
213 MuonRec.SetRunLocalReconstruction("MUON");
214 MuonRec.SetRunTracking("");
215 MuonRec.SetFillESD("MUON");
216 MuonRec.SetOption("MUON", "VS"); // to use VS cluster finder
217 // MuonRec.SetOption("MUON", "VS Original"); // to run VS and original track finder
218 // MuonRec.SetOption("MUON", "Combi"); // to run combined cluster / track finder
219 MMuonRec.Run();
220 .q
221 EOF
222
223 ============================================================
224  How to read & decode raw data 
225 ============================================================
226 These macros can read & decode DDL files, root and DATE files.
227 Nevertheless for the two latter, aliroot has to be compiled with DATE.
228
229 For tracker raw data
230 .includepath $ALICE_ROOT/STEER
231 .includepath $ALICE_ROOT/MUON
232 .includepath $ALICE_ROOT/RAW
233 .L $ALICE_ROOT/MUON/MUONRawStreamTracker.C+
234 MUONRawStreamTracker(maxEvent, firstDDL, lastDDL, rawFileName)
235
236 For trigger raw data
237 .includepath $ALICE_ROOT/STEER
238 .includepath $ALICE_ROOT/MUON
239 .includepath $ALICE_ROOT/RAW
240 .L $ALICE_ROOT/MUON/MUONRawStreamTrigger.C+ 
241 MUONRawStreamTrigger(maxEvent, firstDDL, lastDDL, rawFileName)
242
243 Default wise the macro read all DDL files from the current directory for 1000 events.
244 For root file rawFileName must end with .root, for date file rawFileName 
245 must be no extention. For DDL files you have to specified the directory 
246 where the raw0...n subdirectories are located:
247 MUONRawStreamTracker(maxEvent, "$YOUR_WORKING_DIRECTORY/"); //Do not forget the slash at the end!
248
249
250 ============================================================
251  How to run MUONRecoCheck macro
252 ============================================================
253 To check the muon reconstruction by comparing the reconstructed tracks
254 with the reference tracks made of "AliTrackReference" for the hits and
255 kinematic informations (TParticle) for the vertex.
256 This macro can be used to check the track reconstruction e.g. efficiency,
257 momentum resolution ... but also to make physics analysis whenever
258 track identification is needed.   
259
260 To compile MUONRecoCheck.C
261 .includepath $ALICE_ROOT/STEER
262 .includepath $ALICE_ROOT/MUON
263 .L $ALICE_ROOT/MUON/MUONRecoCheck.C+
264
265 // To run MUONRecoCheck
266 MUONRecoCheck(nEvent,"galice.root"); // nEvent = nb of events
267
268
269 ============================================================
270  How to run MUONTracker macro
271 ============================================================
272 To make the track reconstruction directly from AliTrackReference hits 
273 which are recorded in TrackRefs.root during the simulation.
274 It can be used to check the reconstruction without clusterization.      
275
276 To compile MUONTracker.C
277 .includepath $ALICE_ROOT/STEER
278 .includepath $ALICE_ROOT/MUON
279 .L $ALICE_ROOT/MUON/MUONTracker.C+
280
281 // To run MUONTracker
282 MUONTracker(iEventMin,iEventMax,"galice.root"); // iEventMin: first event
283
284 ===========================================================
285  Macro  MUONGenerateGeometryData.C
286 ===========================================================
287                                                 
288 Macro for generating the geometry data files
289 and mis-alignment data.
290
291 Geometry data files:
292 - MUON/data/volpath.dat file contains the volume paths 
293 for all alignable objects (modules & detection 
294 elements).
295 - MUON/data/transform.dat file contains the transformations
296 data (translation and rotation) for all alignable objects
297 (modules & detection elements)
298 - MUON/data/svmap.dat file contains all the information to link 
299 each geant volume (it can be extended to other virtual MC) with
300 a detection element. The point here is that a given detection
301 element, i.e. a slat chamber can consist of more geant volumes.
302 the correspondence is then defined in an input file.
303 Each time there is a change in the definition of MC geometry, these
304 input files must be re-generated via the macro  
305 MUONGenerateGeometryData.C
306
307 To be run from aliroot:
308 .x MUONGenerateGeometryData.C
309
310 The generated files do not replace the existing ones
311 but have different names (with extension ".out").
312 Replacement with new files has to be done manually.
313
314 If the appropiate flags are set (zeroAlign, resMisAlign and/or fullMisAlign)
315 zero, residual and/or full misalignment data are generated in a
316 local CDB folder (defaults are ResMisAlignCDB and FullMisAlignCDB
317 in the working directory). Inside the local CDB the path for the
318 alignment data is (and must be) "MUON/Align/Data/".
319 Residual misalignment: Default is our current estimate of
320 misalignment after all our alignment procedure has been applied.
321 Full misalignment: Default is our current estimate of initial
322 misalignment.
323
324 ==========================================================
325 How to simulate events with misaligned geometry in local CDB
326 ==========================================================
327
328 If you want to use a misaligned geometry to simulate some
329 events you can use a local CDB. For this need to follow
330 the next steps:
331
332 - Generate misaligned data in local CDB.
333 You can use MUONGenerateGeometryData.C as described above in
334 the corresponding section. Let's assume you used the default
335 residual misalignment settings, then you have a local CDB in
336 your working directory called ResMisAlignCDB containing
337 misalignement data (ResMisAlignCDB/MUON/Align).
338
339 - Copy the calibration data in your local CDB.
340 cp -r $ALICE_ROOT/MUON/Calib ResMisAlignCDB/MUON
341
342 - Tell AliSimulation you want to use your local CDB for MUON
343 To do this you need to instantiate the AliCDBManager, set the
344 default storage and set the specific storage for MUON, before
345 instantiating AliSimulation (see for example the commented
346 lines AlirootRun_MUONtest.sh).
347
348 aliroot -b  >& testSim.out << EOF
349 AliCDBManager* man = AliCDBManager::Instance();
350 man->SetDefaultStorage("local://$ALICE_ROOT");
351 man->SetSpecificStorage("MUON","local://ResMisAlignCDB");
352 AliSimulation MuonSim("$ALICE_ROOT/MUON/Config.C");
353 MuonSim.SetWriteRawData("MUON");
354 MuonSim.Run(10);
355 .q
356 EOF
357
358 ==========================================================
359 How to check the alignment software
360 ==========================================================
361
362 The script AlirootRun_MUONtestAlign.sh  allows you to check the software for
363 the alignment with physics tracks. The script will:
364 - Generate a misaligned geometry in a local CDB (default FullMisAlignCDB)
365 - Simulate 1000 events using previously misaligned geometry
366 - Reconstruct the events using perfect geometry
367 - Run the alignment code over the above events using MUONAlignment.C
368
369 To run you need to type:
370 $ALICE_ROOT/MUON/AlirootRun_MUONtestAlign.sh
371
372 The results of the test are saved in test_align/ directory. The file measShifts.root
373 contains useful graphs for studying the alignment performances. A local CDB
374 containing the realigned geometry is also created (default is ReAlignCDB). The
375 file $ALICE_ROOT/MUON/data/transform2ReAlign.dat contains the
376 transformations describing the realigned geometry to be compared with the
377 used misaligned geometry $ALICE_ROOT/MUON/data/transform2.dat.
378
379 IMPORTANT NOTE: For a useful test of the alignment performances, the
380 order of 100 000 tracks is needed, it is then advisable to generate and
381 reconstruct enough events separately and run MUONAlignment.C providing a file list
382 afterwards.
383
384 ==========================================================
385  How to Merge events
386 ==========================================================
387
388 You can merge 2 types of simulated events. For example, 
389 you can simulate Hijing events, and then simulate muons
390 merging both.
391
392 Merging is done at the sdigits level, so Kinematics files 
393 of the merged events will just correspond to the 
394 Config.C simulated file (not to Config_HIJING.C).
395
396 You must, first, do the Hijing simulation and store it 
397 in directory $HIJING_SIM. Note that for merging you 
398 won't need Kinematics files of the Hijing simulation...
399
400 Hijing simulation
401
402 aliroot -b << EOF
403 AliSimulation HijingSim("$HIJING_SIM/Config_HIJING.C")
404 HijingSim.Run(5)
405 .q
406 EOF
407
408
409 Then you can do muon simulation and reconstruction
410 merging both simulated events. In next example, we are
411 merging 20 times each Hijing event in order to simulate 
412 100 muons merged with 5 Hijing events.
413
414
415 aliroot -b << EOF
416 AliSimulation MuonSim("$ALICE_ROOT/MUON/Config.C")
417 MuonSim.MergeWith("$HIJING_SIM/galice.root",20) //parameters are the Hijing simulation file and the number of times we use each Hijing event
418 MuonSim.Run(100) // number of muon (Config.C) events
419 .q
420 EOF
421
422
423 aliroot -b << EOF
424 TPluginManager * pluginmanager = gROOT->GetPluginManager()
425 pluginmanager->AddHandler("AliReconstructor","MUON","AliMUONReconstructor","MUON","AliMUONReconstructor()")
426 AliReconstruction  MuonRec("galice.root")
427 MuonRec.SetRunTracking("")
428 MuonRec.SetRunVertexFinder(kFALSE)
429 MuonRec.SetRunLocalReconstruction("MUON")
430 MuonRec.SetFillESD("MUON")
431 MuonRec.Run()
432 .q
433 EOF
434
435 ==========================================================
436  How to play with the CDB
437 ==========================================================
438
439 If you'd like to see how the CDB is created, please have a look at the 
440 MUONCDB.C (work in progress, though).
441
442 ==========================================================
443 ...on track numbering 
444 ==========================================================
445
446 All generated particles, including primary and secondary
447 particles are put on the stack. The secondary particles are kept
448 in the stack only if they gave a hit in *any* of the ALICE detectors
449 The number of all particles placed on the stack for a given event 
450 can be obtained with
451 Int_t nPart = AliStack::GetNtrack();
452 Looping from 0 to nPart via AliStack::Particle(ipart)
453 gives the particle listing as obtained from the particle generator (primaries) 
454 and Monte Carlo (secondaries).
455
456 The particle response in the detector, a hit, is registered
457 in the hits tree and the hits are filled with each primary track.
458 The total number of "tracks" (fills of the tree) can be obtained
459 with ntracks = AliMUONData::GetNtracks() and is usually smaller than "nPart".
460 Since particles can also deposit hits in other detectors than 
461 the MUON spectrometer, there will be many "tracks" (fills) in the hit-tree
462 without a hit in MUON.
463
464 The correspondence between "track ID" in the hits-tree ("itr") and the
465 particle ID for particles on the stack (i.e. generated particles) can be
466 obtained via:
467 for (Int_t itr = 0; itr < ntracks; itr++) {
468     MUONData->GetTrack(itr); //track "itr" of the hits-tree
469     Int_t nhitstot = MUONData->Hits()->GetEntriesFast();
470     AliMUONHit* mHit;    
471     for (Int_t ihit=0; ihit<nhitstot; ihit++) {
472        mHit = static_cast<AliMUONHit*>(MUONData->Hits()->At(ihit));
473        Int_t id = muonHit->Track(); //gives particle ID on stack
474        TParticle* particle = gAlice->Stack()->Particle(id);
475     }  
476 }
477
478 During the procedure to go from hits to digits, the hits 
479 are summed up such that more than one track can contribute
480 to a given digit. As a consequence the method
481 Int_t AliMUONDigit::Track(Int_t trackID)
482 takes an argument, where "trackID" runs from 0 to 
483 AliMUONDigit::Ntracks() to provide the reference to *all*
484 tracks that contributed to it. The returned track ID is the one 
485 referred to in the hit-tree. To know which is the generated particle
486 that deposited a given digit one has to follow the sequence of the kind:
487
488
489 mDigit = static_cast<AliMUONDigit*>(digits->At(idigit));
490 for (int tr = 0; tr < mDigit->Ntracks(); tr++){
491    Int_t hitTrackID = mDigit->Track(tr);
492    MUONData->GetTrack(hitTrackID);
493    mHit = static_cast<AliMUONHit*>(MUONData->Hits()->At(0));
494                                   //just take first hit of given track
495    Int_t numPart = mHit->Track(); //gives ID of particle on the stack
496    Int_t idTrack  = mHit->Particle(); //gives flavour code of the particle
497 }
498 In this example, for simplicity, only the first hit of a 
499 hit-track is used to check the particle ID.
500
501 ==========================================================
502 Macro to process PDC06 preproduction 
503 ==========================================================
504
505 To read a generation/reconstrution from PDC06 preproduction, and write a file 
506 with a tree of AliMUONTrackLight / AliMUONPairLight :
507 go to the directory containing the generation/reconstruction. From there run
508 aliroot
509 .x DecodeRecoCocktail.C+
510 .q
511
512 To read the file previously generated:
513 aliroot
514 .x ReadRecoCocktail.C+
515 .q
516
517 ===========================================================
518  Still working ..............
519 ===========================================================