+
+//_____________________________________________________________________
+Bool_t AliMUON::Raw2SDigits(AliRawReader* rawReader)
+{
+ /// Convert raw data to SDigit
+
+ if (!fLoader->TreeS()) fLoader->MakeSDigitsContainer();
+
+ TTree* treeS = fLoader->TreeS();
+
+ AliMUONVDigitStore* sDigitStore = AliMUONVDigitStore::Create(DigitStoreClassName());
+ AliMUONVTriggerStore* triggerStore = 0x0;
+
+ sDigitStore->Connect(*treeS);
+
+ if (!fDigitMaker) fDigitMaker = new AliMUONDigitMaker;
+
+ if (fConvertTrigger) {
+ triggerStore = new AliMUONTriggerStoreV1;
+ triggerStore->Connect(*treeS,true);
+ fDigitMaker->SetMakeTriggerDigits(true);
+ }
+
+ if (!fDigitCalibrator)
+ {
+ AliMUONRecoParam* recoParam = GetRecoParam();
+
+ if (!recoParam)
+ {
+ AliFatal("Cannot work without recoparams !");
+ }
+
+ fDigitCalibrator = new AliMUONDigitCalibrator(*fCalibrationData,recoParam);
+ }
+
+ fDigitMaker->Raw2Digits(rawReader,sDigitStore,triggerStore);
+
+ fDigitCalibrator->Calibrate(*sDigitStore);
+
+ TIter next(sDigitStore->CreateIterator());
+ AliMUONDigit* sdigit;
+
+ // now tweak the digits to make them "as fresh as possible", i.e.
+ // reset their calibrated status, as they'll be calibrated again
+ // once embedded.
+ while ( ( sdigit = static_cast<AliMUONDigit*>(next()) ) )
+ {
+ sdigit->Calibrated(kFALSE);
+ }
+
+ treeS->Fill();
+
+ fLoader->WriteSDigits("OVERWRITE");
+
+ fLoader->UnloadSDigits();
+
+ delete sDigitStore;
+
+ delete triggerStore;
+
+ return kTRUE;
+}
+