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 /// 5. switch to merge(true) or not merge(false) trigger digits
33 /// and the output is : "MUON.SDigits.root" file with the same tree and event structure as produced in simulation directory
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.
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)
45 /// in the $ALICE_ROOT/MUON/runSimulation.C
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 **********************************************************************/
55 int MakeSDigits(const char* galiceFile="galice.root", const char* rawRootFile="./raw.root",
56 const char* ocdb = "local://$ALICE_ROOT/OCDB", int run=0, bool isMergeTrigger=true)
58 //TGrid connect for alien ocdb
59 TGrid::Connect("alien://");
61 AliCDBManager *man = AliCDBManager::Instance();
62 man->SetDefaultStorage(ocdb);
65 AliMpCDB::LoadDDLStore(true);
67 AliRawReader *rawReader = AliRawReader::Create(rawRootFile);
69 AliRunLoader* runLoader = AliRunLoader::Open(galiceFile);
70 AliLoader* muonLoader = runLoader->GetDetectorLoader("MUON");
72 for(Int_t iEvent=0;iEvent<runLoader->GetNumberOfEvents();iEvent++){
74 cout<<"Running for Event : "<<iEvent<<endl;
76 rawReader->NextEvent();
77 runLoader->GetEvent(iEvent);
79 muonLoader->LoadSDigits("update");
80 muonLoader->CleanSDigits();
81 if (!muonLoader->TreeS()) muonLoader->MakeSDigitsContainer();
83 TTree* treeS = muonLoader->TreeS();
85 AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV2S");
86 sDigitStore->Connect(*treeS,true);
87 AliMUONDigitMaker *digitMaker = new AliMUONDigitMaker(false);
90 AliMUONVTriggerStore* triggerStore = new AliMUONTriggerStoreV1;
91 triggerStore->Connect(*treeS,true);
92 digitMaker->SetMakeTriggerDigits(true);
93 digitMaker->Raw2Digits(rawReader,sDigitStore,triggerStore);
95 digitMaker->Raw2Digits(rawReader,sDigitStore,0x0);
98 TIter next(sDigitStore->CreateIterator());
99 AliMUONVDigit *mdigit;
101 while ( (mdigit = reinterpret_cast<AliMUONVDigit *>(next())) ) {
102 if(mdigit->DetElemId()<1100){
103 mdigit->SetCharge(Float_t(mdigit->ADC()));
106 mdigit->SetCharge(1.0);
112 muonLoader->WriteSDigits("OVERWRITE");
114 muonLoader->UnloadSDigits();
117 triggerStore->Delete();
118 sDigitStore->Delete();
119 digitMaker->Delete();