]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MakeSDigits.C
Make the logger compatible with AliMergeableCollection
[u/mrichter/AliRoot.git] / MUON / MakeSDigits.C
CommitLineData
377cd3df 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/// \ingroup macros
19/// \file MakeSDigits.C
20/// \brief Macro for generation SDigits from raw data for merging
21/// \author Indranil Das, HEP Division, SINP (indra.das@saha.ac.in, indra.ehep@gmail.com)
22///
23/// Usage : To run this code one should have $ALICE_ROOT/MUON/rootlogon.C
24/// in the current working directory. Then run it from command line as,
25/// <pre>aliroot MakeSDigits.C\(\""reconstructed galicefile"\",\""rawdatafile"\",\""OCDB path"\",run-numer\)
26///
27/// where inputs are : 1. galice file of local reconstruction directory
28/// 2. rootified rawdata file of local reconstruction directory.
29/// In case the raw data are ddl files, specify the path which has "raw0", "raw1".... events
30/// 3. OCDB path
31/// 4. run number
388897f8 32/// 5. switch to merge(true) or not merge(false) trigger digits
377cd3df 33/// and the output is : "MUON.SDigits.root" file with the same tree and event structure as produced in simulation directory
34/// </pre>
35/// Note:
36/// galice.root and raw.root cannot be a directory read from alien
37/// beacuse "muonLoader->WriteSDigits("OVERWRITE")" tries to write in reconstruction directory,
38/// which will fail. For files in alien, make a local copy of the galice and raw.root file, and run the code
39/// in that directory.
40///
41/// Merging Hints :
42/// Follow the merging procedure as specified in the \ref README_sim page, with
43/// <pre>MuonSim.MergeWith("recodir_that_has_MUON.SDigits.root_from_rawdata/galice.root",nofBackground)
44/// </pre>
45/// in the $ALICE_ROOT/MUON/runSimulation.C
46
47/**********************************************************************
48 Created on : 11/01/2010
49 Purpose : To create SDigits from RawData
50 Author : Indranil Das, HEP Division, SINP
51 Email : indra.das@saha.ac.in | indra.ehep@gmail.com
52**********************************************************************/
53
54
55int MakeSDigits(const char* galiceFile="galice.root", const char* rawRootFile="./raw.root",
388897f8 56 const char* ocdb = "local://$ALICE_ROOT/OCDB", int run=0, bool isMergeTrigger=true)
377cd3df 57{
58 //TGrid connect for alien ocdb
59 TGrid::Connect("alien://");
60
61 AliCDBManager *man = AliCDBManager::Instance();
62 man->SetDefaultStorage(ocdb);
63 man->SetRun(run);
64
65 AliMpCDB::LoadDDLStore(true);
66
67 AliRawReader *rawReader = AliRawReader::Create(rawRootFile);
68
69 AliRunLoader* runLoader = AliRunLoader::Open(galiceFile);
70 AliLoader* muonLoader = runLoader->GetDetectorLoader("MUON");
71
72 for(Int_t iEvent=0;iEvent<runLoader->GetNumberOfEvents();iEvent++){
73
74 cout<<"Running for Event : "<<iEvent<<endl;
75
76 rawReader->NextEvent();
77 runLoader->GetEvent(iEvent);
78
79 muonLoader->LoadSDigits("update");
80 muonLoader->CleanSDigits();
81 if (!muonLoader->TreeS()) muonLoader->MakeSDigitsContainer();
82
83 TTree* treeS = muonLoader->TreeS();
84
85 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
86 sDigitStore->Connect(*treeS,true);
377cd3df 87 AliMUONDigitMaker *digitMaker = new AliMUONDigitMaker(false);
388897f8 88
89 if(isMergeTrigger){
90 AliMUONVTriggerStore* triggerStore = new AliMUONTriggerStoreV1;
91 triggerStore->Connect(*treeS,true);
92 digitMaker->SetMakeTriggerDigits(true);
93 digitMaker->Raw2Digits(rawReader,sDigitStore,triggerStore);
94 }else{
95 digitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
96 }
377cd3df 97
98 TIter next(sDigitStore->CreateIterator());
99 AliMUONVDigit *mdigit;
100
101 while ( (mdigit = reinterpret_cast<AliMUONVDigit *>(next())) ) {
388897f8 102 if(mdigit->DetElemId()<1100){
103 mdigit->SetCharge(Float_t(mdigit->ADC()));
104 mdigit->SetADC(0);
105 }else{
106 mdigit->SetCharge(1.0);
107 }
377cd3df 108 //mdigit->Print();
109 }
110 treeS->Fill();
111
112 muonLoader->WriteSDigits("OVERWRITE");
113
114 muonLoader->UnloadSDigits();
115
388897f8 116 if(isMergeTrigger)
117 triggerStore->Delete();
377cd3df 118 sDigitStore->Delete();
119 digitMaker->Delete();
120
121 }
122 delete runLoader;
123
124 return 0;
388897f8 125}