+ fPMDLoader->WriteDigits("OVERWRITE");
+
+}
+//____________________________________________________________________________
+void AliPMDDigitizer::Exec(Option_t *option)
+{
+ // Does the event merging and digitization
+ const char *cdeb = strstr(option,"deb");
+ if(cdeb)
+ {
+ AliDebug(100," *** PMD Exec is called ***");
+ }
+
+ Int_t ninputs = fManager->GetNinputs();
+ AliDebug(1,Form("Number of files to be processed = %d",ninputs));
+ ResetCellADC();
+
+ for (Int_t i = 0; i < ninputs; i++)
+ {
+ Int_t troffset = fManager->GetMask(i);
+ MergeSDigits(i, troffset);
+ }
+
+ fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+ fPMD = (AliPMD*)gAlice->GetDetector("PMD");
+ fPMDLoader = fRunLoader->GetLoader("PMDLoader");
+ if (fPMDLoader == 0x0)
+ {
+ AliError("Can not find PMD or PMDLoader");
+ }
+ fPMDLoader->LoadDigits("update");
+ TTree* treeD = fPMDLoader->TreeD();
+ if (treeD == 0x0)
+ {
+ fPMDLoader->MakeTree("D");
+ treeD = fPMDLoader->TreeD();
+ }
+ Int_t bufsize = 16000;
+ if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000);
+ treeD->Branch("PMDDigit", &fDigits, bufsize);
+
+ Float_t adc;
+ Float_t deltaE = 0.;
+ Int_t detno = 0;
+ Int_t trno = 1;
+
+ for (Int_t idet = 0; idet < 2; idet++)
+ {
+ for (Int_t ism = 0; ism < fgkTotUM; ism++)
+ {
+ for (Int_t jrow = 0; jrow < fgkRow; jrow++)
+ {
+ for (Int_t kcol = 0; kcol < fgkCol; kcol++)
+ {
+ if (idet == 0)
+ {
+ deltaE = fPRE[ism][jrow][kcol];
+ trno = fPRETrackNo[ism][jrow][kcol];
+ detno = 0;
+ }
+ else if (idet == 1)
+ {
+ deltaE = fCPV[ism][jrow][kcol];
+ trno = fCPVTrackNo[ism][jrow][kcol];
+ detno = 1;
+ }
+ if (deltaE > 0.)
+ {
+ MeV2ADC(deltaE,adc);
+ AddDigit(trno,detno,ism,jrow,kcol,adc);
+ }
+ } // column loop
+ } // row loop
+ treeD->Fill();
+ ResetDigit();
+ } // supermodule loop
+ } // detector loop
+ fPMDLoader->WriteDigits("OVERWRITE");
+ fPMDLoader->UnloadDigits();
+ ResetCellADC();