1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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)
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\)
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
32 /// and the output is : "MUON.SDigits.root" file with the same tree and event structure as produced in simulation directory
35 /// galice.root and raw.root cannot be a directory read from alien
36 /// beacuse "muonLoader->WriteSDigits("OVERWRITE")" tries to write in reconstruction directory,
37 /// which will fail. For files in alien, make a local copy of the galice and raw.root file, and run the code
38 /// in that directory.
41 /// Follow the merging procedure as specified in the \ref README_sim page, with
42 /// <pre>MuonSim.MergeWith("recodir_that_has_MUON.SDigits.root_from_rawdata/galice.root",nofBackground)
44 /// in the $ALICE_ROOT/MUON/runSimulation.C
46 /**********************************************************************
47 Created on : 11/01/2010
48 Purpose : To create SDigits from RawData
49 Author : Indranil Das, HEP Division, SINP
50 Email : indra.das@saha.ac.in | indra.ehep@gmail.com
51 **********************************************************************/
54 int MakeSDigits(const char* galiceFile="galice.root", const char* rawRootFile="./raw.root",
55 const char* ocdb = "local://$ALICE_ROOT/OCDB", int run=0)
57 //TGrid connect for alien ocdb
58 TGrid::Connect("alien://");
60 AliCDBManager *man = AliCDBManager::Instance();
61 man->SetDefaultStorage(ocdb);
64 AliMpCDB::LoadDDLStore(true);
66 AliRawReader *rawReader = AliRawReader::Create(rawRootFile);
68 AliRunLoader* runLoader = AliRunLoader::Open(galiceFile);
69 AliLoader* muonLoader = runLoader->GetDetectorLoader("MUON");
71 for(Int_t iEvent=0;iEvent<runLoader->GetNumberOfEvents();iEvent++){
73 cout<<"Running for Event : "<<iEvent<<endl;
75 rawReader->NextEvent();
76 runLoader->GetEvent(iEvent);
78 muonLoader->LoadSDigits("update");
79 muonLoader->CleanSDigits();
80 if (!muonLoader->TreeS()) muonLoader->MakeSDigitsContainer();
82 TTree* treeS = muonLoader->TreeS();
84 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
85 sDigitStore->Connect(*treeS,true);
87 AliMUONDigitMaker *digitMaker = new AliMUONDigitMaker(false);
88 digitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
90 TIter next(sDigitStore->CreateIterator());
91 AliMUONVDigit *mdigit;
93 while ( (mdigit = reinterpret_cast<AliMUONVDigit *>(next())) ) {
94 mdigit->SetCharge(Float_t(mdigit->ADC()));
100 muonLoader->WriteSDigits("OVERWRITE");
102 muonLoader->UnloadSDigits();
104 sDigitStore->Delete();
105 digitMaker->Delete();