-void AliITS::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
- Option_t *opt0,Option_t *opt1,Text_t *flnm){
- // keep galice.root for signal and name differently the file for
- // background when add! otherwise the track info for signal will be lost !
- // the condition below will disappear when the geom class will be
- // initialized for all versions - for the moment it is only for v5 !
- // Inputs:
- // Int_t evnt Event to be processed.
- // Int_t bgrev Background Hit tree number.
- // Int_t size Size used by InitModules. See InitModules.
- // Option_t *opt0 Option passed to FillModules. See FillModules.
- // Option_t *opt1 String indicating if merging hits or not. To
- // merge hits set equal to "Add". Otherwise no
- // background hits are considered.
- // Test_t *flnm File name containing the background hits..
- // Outputs:
- // none.
- // Return:
- // none.
-
- if(!GetITSgeom()) return;
- AliITSgeom *geom = GetITSgeom();
-
- const char *all = strstr(opt1,"All");
- const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
- strstr(opt1,"SSD")};
- Int_t nmodules;
- InitModules(size,nmodules);
- FillModules(evNumber,bgrev,nmodules,opt0,flnm);
-
- AliITSsimulation *sim = 0;
- AliITSDetType *iDetType = 0;
- AliITSmodule *mod = 0;
- Int_t id,module;
-
- //m.b. : this change is nothing but a nice way to make sure
- //the CPU goes up !
- for(module=0;module<geom->GetIndexMax();module++){
- id = geom->GetModuleType(module);
- if (!all && !det[id]) continue;
- iDetType = DetType(id);
- sim = (AliITSsimulation*)iDetType->GetSimulationModel();
- if (!sim) {
- Error("HitsToFastPoints",
- "The simulation class was not instanciated!");
- exit(1);
- } // end if !sim
- mod = (AliITSmodule *)fITSmodules->At(module);
- sim->CreateFastRecPoints(mod,module,gRandom);
- gAlice->TreeR()->Fill();
- ResetRecPoints();
- } // end for module
-
- ClearModules();
-
- char hname[30];
- sprintf(hname,"TreeR%d",evNumber);
- gAlice->TreeR()->Write(hname,TObject::kOverwrite);
- // reset tree
- gAlice->TreeR()->Reset();
+Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
+{
+ //
+ // Converts RAW data to SDigits
+ //
+ // Get TreeS
+ //
+ Int_t last = -1;
+ Int_t size = AliITSgeomTGeo::GetNModules();
+ if(!fModA) {
+ fModA = new TClonesArray*[size];
+ for (Int_t mod = 0; mod < size; mod++) fModA[mod] = new TClonesArray("AliITSpListItem", 10000);
+ }
+ AliLoader* loader = (AliRunLoader::Instance())->GetLoader("ITSLoader");
+ if (!loader){
+ Error("Open","Can not get ITS loader from Run Loader");
+ return kFALSE;
+ }
+
+ TTree* tree = 0;
+ tree = loader->TreeS();
+ if (!tree){
+ loader->MakeTree("S");
+ tree = loader->TreeS();
+ }
+ //
+ // Array for SDigits
+ //
+ if(!fpSDigits){
+ fpSDigits = new TClonesArray("AliITSpListItem",10000);
+ }
+ TClonesArray& aSDigits = *fpSDigits;
+ Int_t bufsize = 32000;
+ tree->Branch("ITS", &fpSDigits, bufsize);
+ Int_t npx = 0;
+ //
+ // SPD
+ //
+ AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
+ if(!segSPD){
+ AliWarning("Set AliITS defaults");
+ SetDefaults();
+ segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
+ }
+ npx = segSPD->Npx();
+ Double_t thr, sigma;
+
+ AliITSRawStreamSPD inputSPD(rawReader);
+ while(1){
+ Bool_t next = inputSPD.Next();
+ if (!next) break;
+
+ Int_t module = inputSPD.GetModuleID();
+ Int_t column = inputSPD.GetColumn();
+ Int_t row = inputSPD.GetRow();
+ Int_t index = npx * column + row;
+
+ if (module >= size) continue;
+
+ last = (fModA[module])->GetEntries();
+ TClonesArray& dum = *fModA[module];
+ fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
+ thr += 1.;
+ new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
+ }
+ rawReader->Reset();
+
+ //
+ // SDD
+ //
+ AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
+ npx = segSDD->Npx();
+ Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD);
+ Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1);
+ Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1);
+
+ AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
+ for(Int_t iMod=firstSDD; iMod<firstSSD; iMod++){
+ AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(iMod);
+ Bool_t isZeroSupp=cal->GetZeroSupp();
+ if(isZeroSupp){
+ for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,cal->GetZSLowThreshold(iSid));
+ }else{
+ for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,0);
+ }
+ }
+
+ AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
+ inputSDD->SetDDLModuleMap(ddlmap);
+ while(inputSDD->Next()){
+ if(inputSDD->IsCompletedModule()==kFALSE &&
+ inputSDD->IsCompletedDDL()==kFALSE){
+
+ Int_t module = inputSDD->GetModuleID();
+ Int_t anode = inputSDD->GetCoord1()+segSDD->NpzHalf()*inputSDD->GetChannel();
+ Int_t time = inputSDD->GetCoord2();
+ Int_t signal10 = inputSDD->GetSignal();
+ Int_t index = AliITSpList::GetIndex(anode,time,scalef*npx);
+
+ if (module >= size) continue;
+ last = fModA[module]->GetEntries();
+ TClonesArray& dum = *fModA[module];
+ new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
+ ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
+ }
+ }
+ delete inputSDD;
+ rawReader->Reset();
+
+ //
+ // SSD
+ //
+ AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
+ npx = segSSD->Npx();
+ AliITSRawStreamSSD inputSSD(rawReader);
+ while(1){
+ Bool_t next = inputSSD.Next();
+ if (!next) break;
+
+ Int_t module = inputSSD.GetModuleID();
+ if(module<0)AliError(Form("Invalid SSD module %d \n",module));
+ if(module<0)continue;
+ Int_t side = inputSSD.GetSideFlag();
+ Int_t strip = inputSSD.GetStrip();
+ Int_t signal = inputSSD.GetSignal();
+ Int_t index = npx * side + strip;
+
+ if (module >= size) continue;
+
+ last = fModA[module]->GetEntries();
+ TClonesArray& dum = *fModA[module];
+ new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
+ }
+ rawReader->Reset();
+ AliITSpListItem* sdig = 0;
+
+ Int_t firstssd = GetITSgeom()->GetStartDet(kSSD);
+ Double_t adcToEv = 1.;
+ for (Int_t mod = 0; mod < size; mod++)
+ {
+ if(mod>=firstssd) {
+ AliITSCalibrationSSD* calssd = (AliITSCalibrationSSD*)fDetTypeSim->GetCalibrationModel(mod);
+ adcToEv = 1./calssd->GetSSDDEvToADC(1.);
+ }
+ Int_t nsdig = fModA[mod]->GetEntries();
+ for (Int_t ie = 0; ie < nsdig; ie++) {
+ sdig = (AliITSpListItem*) (fModA[mod]->At(ie));
+ Double_t digsig = sdig->GetSignal();
+ if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron
+ new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig);
+ Float_t sig = sdig->GetSignalAfterElect();
+ if(mod>=firstssd) sig*=adcToEv;
+ if (sig > 0.) {
+ sdig = (AliITSpListItem*)aSDigits[ie];
+ sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
+ }
+ }
+
+ tree->Fill();
+ aSDigits.Clear();
+ fModA[mod]->Clear();
+ }
+ loader->WriteSDigits("OVERWRITE");
+ return kTRUE;