1 //____________________________________________________________________
5 // Script that extracts the medium numbers corresponding to each
6 // registered detector.
8 // Use the script `Compile.C' to compile this class using ACLic.
10 /** @file MediaTable.C
11 @author Christian Holm Christensen <cholm@nbi.dk>
12 @date Wed Dec 27 14:25:11 2006
13 @brief Script to make a file with a list of medium numbers for
16 /** Script to make a file with a list of medium numbers for all active
17 detectors. This should be executed in the same process as the one
18 that makes the @c galice.root file. For example
24 AliLog::SetModuleDebugLevel("FMD", 1);
25 sim.SetConfigFile("$(ALICE_ROOT)/FMD/Config.C");
26 // sim.SetMakeSDigits("FMD");
27 sim.SetMakeDigits("FMD ITS VZERO T0");
28 sim.SetWriteRawData("FMD");
29 gROOT->Macro("$(ALICE_ROOT)/FMD/scripts/MediaTable.C");
37 It can also be executed after the fact, if one make sure to use
38 the same configuration file as the one used for the simulation.
41 Root> gAlice->Init("$(ALICE_ROOT)/FMD/Config.C");
42 Root> .x $ALICE_ROOT/FMD/scripts/MediaTable.C
45 The idea is to use the generated file to track where particles are
46 produced in the simulation. This is needed to do background
47 studies in the FMD. The file written contains a @c TObjArray of
48 @c TObjString objects. The @c TObjString objects has the name of
49 the detector corresponding to the medium Id that the object is at
50 in the array. To read the file, do for example:
52 TFile* file = TFile::Open("mediatable.root", "READ");
53 TObjArray* array = (TObjArray*)(file->Get("mediatable"));
54 Int_t n = array->GetEntries();
58 for (j = 0; j < n; j++) {
59 TObjString* s = static_cast<TObjString*>(array->At(j));
60 if (!l || s->Compare(l) != 0) {
62 std::cout << l->GetName() << "\t" << min
63 << "\t" << j - 1 << std::endl;
68 std::cout << l->GetName() << "\t" << min << "\t" << j << std::endl;
71 See also the script @c BackgroundStudy.C for more on how this is
72 used in the FMD collaboration.
74 //____________________________________________________________________
79 TFile* file = TFile::Open("mediatable.root", "RECREATE");
80 TObjArray* media = gAlice->Modules();
81 AliModule* module = 0;
83 TObjArray* array = new TObjArray(media->GetEntries());
84 while ((module = static_cast<AliModule*>(next()))) {
85 Int_t low = module->LoMedium();
86 Int_t high = module->HiMedium();
87 for (Int_t j = low; j <=high; j++) {
88 TObjString* o = new TObjString(module->GetName());
89 std::cout << "Adding " << j << ":\t" << o->GetName() << std::endl;
90 array->AddAtAndExpand(o, j);
93 array->Write("mediatable", TObject::kSingleKey);