void TestEMCALSDigit() { // Getting EMCAL Detector and Geometry. AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read"); if (rl == 0x0) cout<<"Can not instatiate the Run Loader"<<endl; rl->LoadgAlice();//Needed to get geometry AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*> (rl->GetDetectorLoader("EMCAL")); TGeoManager::Import("geometry.root"); AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry AliEMCALGeometry * geom ; if(alirun){ AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL"); geom = emcal->GetGeometry(); } if (geom == 0) cout<<"Did not get geometry from EMCALLoader"<<endl; else geom->PrintGeometry(); //Load Digits rl->LoadSDigits("EMCAL"); //Get maximum number of events Int_t maxevent = rl->GetNumberOfEvents(); cout<<"Number of events "<<maxevent<<endl; //maxevent = 10 ; Int_t iEvent = -1 ; Float_t amp = -1 ; Float_t time = -1 ; Int_t id = -1 ; Int_t iSupMod = 0 ; Int_t iTower = 0 ; Int_t iIphi = 0 ; Int_t iIeta = 0 ; Int_t iphi = 0 ; Int_t ieta = 0 ; AliEMCALDigit * dig; for ( iEvent=0; iEvent<maxevent; iEvent++) { cout << " ======> Event " << iEvent << endl ; //Load Event rl->GetEvent(iEvent); //Fill array of digits TClonesArray *digits = emcalLoader->SDigits(); //Get digits from the list for(Int_t idig = 0; idig< digits->GetEntries();idig++){ //cout<<">> idig "<<idig<<endl; dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ; if(dig != 0){ id = dig->GetId() ; //cell (digit) label amp = dig->GetAmplitude(); //amplitude in cell (digit) time = dig->GetTime();//time of creation of digit after collision cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl; //Geometry methods if(geom){ geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta); //Gives SuperModule and Tower numbers geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower, iIphi, iIeta,iphi,ieta); //Gives label of cell in eta-phi position per each supermodule cout<< "SModule "<<iSupMod<<"; Tower "<<iTower <<"; Eta "<<iIeta <<"; Phi "<<iIphi<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl; } } else cout<<"Digit pointer 0x0"<<endl; } } }
void compClusHitsMod2(int nev=-1) { const int kSplit=0x1<<22; const int kSplCheck=0x1<<23; // gSystem->Load("libITSUpgradeBase"); gSystem->Load("libITSUpgradeSim"); gSystem->Load("libITSUpgradeRec"); gROOT->SetStyle("Plain"); AliCDBManager* man = AliCDBManager::Instance(); man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); man->SetSpecificStorage("GRP/GRP/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Align/Data", Form("local://%s",gSystem->pwd())); man->SetSpecificStorage("ITS/Calib/RecoParam", Form("local://%s",gSystem->pwd())); man->SetRun(0); TH1F* hL0A = new TH1F("hL0A", "Layer 0, polar angle", 20, 0, TMath::PiOver2()); hL0A->SetDirectory(0); hL0A->GetXaxis()->SetTitle("#alpha"); TH1F* hL0B = new TH1F("hL0B", "Layer 0, azimuthal angle", 20, 0, TMath::PiOver2()); hL0B->SetDirectory(0); hL0B->GetXaxis()->SetTitle("#beta"); TH1F* hL1A = new TH1F("hL1A", "Layer 1, polar angle", 20, 0, TMath::PiOver2()); hL1A->SetDirectory(0); hL1A->GetXaxis()->SetTitle("#alpha"); TH1F* hL1B = new TH1F("hL1B", "Layer 1, azimuthal angle", 20, 0, TMath::PiOver2()); hL1B->SetDirectory(0); hL1B->GetXaxis()->SetTitle("#beta"); TH1F* hL2A = new TH1F("hL2A", "Layer 2, polar angle", 20, 0, TMath::PiOver2()); hL2A->SetDirectory(0); hL2A->GetXaxis()->SetTitle("#alpha"); TH1F* hL2B = new TH1F("hL2B", "Layer 2, azimuthal angle", 20, 0, TMath::PiOver2()); hL2B->SetDirectory(0); hL2B->GetXaxis()->SetTitle("#beta"); TH1F* hL3A = new TH1F("hL3A", "Layer 3, polar angle", 20, 0, TMath::PiOver2()); hL3A->SetDirectory(0); hL3A->GetXaxis()->SetTitle("#alpha"); TH1F* hL3B = new TH1F("hL3B", "Layer 3, azimuthal angle", 20, 0, TMath::PiOver2()); hL3B->SetDirectory(0); hL3B->GetXaxis()->SetTitle("#beta"); TH1F* hL4A = new TH1F("hL4A", "Layer 4, polar angle", 20, 0, TMath::PiOver2()); hL4A->SetDirectory(0); hL4A->GetXaxis()->SetTitle("#alpha"); TH1F* hL4B = new TH1F("hL4B", "Layer 4, azimuthal angle", 20, 0, TMath::PiOver2()); hL4B->SetDirectory(0); hL4B->GetXaxis()->SetTitle("#beta"); TH1F* hL5A = new TH1F("hL5A", "Layer 5, polar angle", 20, 0, TMath::PiOver2()); hL5A->SetDirectory(0); hL5A->GetXaxis()->SetTitle("#alpha"); TH1F* hL5B = new TH1F("hL5B", "Layer 5, azimuthal angle", 20, 0, TMath::PiOver2()); hL5B->SetDirectory(0); hL5B->GetXaxis()->SetTitle("#beta"); TH1F* hL6A = new TH1F("hL6A", "Layer 6, polar angle", 20, 0, TMath::PiOver2()); hL6A->SetDirectory(0); hL6A->GetXaxis()->SetTitle("#alpha"); TH1F* hL6B = new TH1F("hL6B", "Layer 6, azimuthal angle", 20, 0, TMath::PiOver2()); hL6B->SetDirectory(0); hL6B->GetXaxis()->SetTitle("#beta"); gAlice=NULL; AliRunLoader* runLoader = AliRunLoader::Open("galice.root"); runLoader->LoadgAlice(); gAlice = runLoader->GetAliRun(); runLoader->LoadHeader(); runLoader->LoadKinematics(); runLoader->LoadRecPoints(); runLoader->LoadSDigits(); runLoader->LoadHits(); AliLoader *dl = runLoader->GetDetectorLoader("ITS"); AliGeomManager::LoadGeometry("geometry.root"); TObjArray algITS; AliGeomManager::LoadAlignObjsFromCDBSingleDet("ITS",algITS); AliGeomManager::ApplyAlignObjsToGeom(algITS); // AliITSUGeomTGeo* gm = new AliITSUGeomTGeo(kTRUE); AliITSMFTClusterPix::SetGeom(gm); // AliITSURecoDet *its = new AliITSURecoDet(gm, "ITSinterface"); its->CreateClusterArrays(); // Double_t xg1,yg1,zg1=0.,xg0,yg0,zg0=0.,tg0; Double_t xExit,yExit,zExit,xEnt,yEnt,zEnt,tof1; // TTree *cluTree = 0x0; TTree *hitTree = 0x0; TClonesArray *hitList=new TClonesArray("AliITSMFTHit"); // Float_t xyzClGloF[3]; Double_t xyzClGlo[3],xyzClTr[3]; Int_t labels[3]; int nLab = 0; int nlr=its->GetNLayersActive(); int ntotev = (Int_t)runLoader->GetNumberOfEvents(); printf("N Events : %i \n",ntotev); if (nev>0) ntotev = TMath::Min(nev,ntotev); // // output tree TFile* flOut = TFile::Open("clInfo.root","recreate"); TTree* trOut = new TTree("clitsu","clitsu"); clSumm cSum; trOut->Branch("evID", &cSum.evID ,"evID/I"); trOut->Branch("volID",&cSum.volID,"volID/I"); trOut->Branch("lrID", &cSum.lrID ,"lrID/I"); trOut->Branch("clID", &cSum.clID ,"clID/I"); trOut->Branch("nPix", &cSum.nPix ,"nPix/I"); trOut->Branch("nX" , &cSum.nX ,"nX/I"); trOut->Branch("nZ" , &cSum.nZ ,"nZ/I"); trOut->Branch("q" , &cSum.q ,"q/I"); trOut->Branch("pt" , &cSum.pt ,"pt/F"); trOut->Branch("eta" ,&cSum.eta ,"eta/F"); trOut->Branch("phi" , &cSum.phi ,"phi/F"); trOut->Branch("xyz", cSum.xyz, "xyz[3]/F"); trOut->Branch("dX" , &cSum.dX ,"dX/F"); trOut->Branch("dY" , &cSum.dY ,"dY/F"); trOut->Branch("dZ" , &cSum.dZ ,"dZ/F"); trOut->Branch("split",&cSum.split,"split/O"); trOut->Branch("prim", &cSum.prim, "prim/O"); trOut->Branch("pdg", &cSum.pdg, "pdg/I"); trOut->Branch("ntr", &cSum.ntr, "ntr/I"); trOut->Branch("alpha", &cSum.alpha, "alpha/F"); trOut->Branch("beta", &cSum.beta, "beta/F"); trOut->Branch("nRowPatt", &cSum.nRowPatt, "nRowPatt/I"); trOut->Branch("nColPatt", &cSum.nColPatt, "nColPatt/I"); TopDatabase DB; for (Int_t iEvent = 0; iEvent < ntotev; iEvent++) { printf("\n Event %i \n",iEvent); runLoader->GetEvent(iEvent); AliStack *stack = runLoader->Stack(); cluTree=dl->TreeR(); hitTree=dl->TreeH(); hitTree->SetBranchAddress("ITS",&hitList); // // read clusters for (int ilr=nlr;ilr--;) { TBranch* br = cluTree->GetBranch(Form("ITSRecPoints%d",ilr)); if (!br) {printf("Did not find cluster branch for lr %d\n",ilr); exit(1);} br->SetAddress(its->GetLayerActive(ilr)->GetClustersAddress()); } cluTree->GetEntry(0); its->ProcessClusters(); // // read hits for(Int_t iEnt=0;iEnt<hitTree->GetEntries();iEnt++){//entries loop of the hits hitTree->GetEntry(iEnt); int nh = hitList->GetEntries(); for(Int_t iHit=0; iHit<nh;iHit++){ AliITSMFTHit *pHit = (AliITSMFTHit*)hitList->At(iHit); int mcID = pHit->GetTrack(); //printf("MCid: %d %d %d Ch %d\n",iEnt,iHit, mcID, pHit->GetChip()); TClonesArray* harr = arrMCTracks.GetEntriesFast()>mcID ? (TClonesArray*)arrMCTracks.At(mcID) : 0; if (!harr) { harr = new TClonesArray("AliITSMFTHit"); // 1st encounter of the MC track arrMCTracks.AddAtAndExpand(harr,mcID); } // new ( (*harr)[harr->GetEntriesFast()] ) AliITSMFTHit(*pHit); } } // return; // // compare clusters and hits // printf(" tree entries: %lld\n",cluTree->GetEntries()); // for (int ilr=0;ilr<nlr;ilr++) { AliITSURecoLayer* lr = its->GetLayerActive(ilr); TClonesArray* clr = lr->GetClusters(); int nClu = clr->GetEntries(); //printf("Layer %d : %d clusters\n",ilr,nClu); // for (int icl=0;icl<nClu;icl++) { AliITSMFTClusterPix *cl = (AliITSMFTClusterPix*)clr->At(icl); int modID = cl->GetVolumeId(); //------------ check if this is a split cluster int sInL = modID - gm->GetFirstChipIndex(ilr); if (!cl->TestBit(kSplCheck)) { cl->SetBit(kSplCheck); // check if there is no other cluster with same label on this module AliITSURecoSens* sens = lr->GetSensor(sInL); int nclSn = sens->GetNClusters(); int offs = sens->GetFirstClusterId(); // printf("To check for %d (mod:%d) N=%d from %d\n",icl,modID,nclSn,offs); for (int ics=0;ics<nclSn;ics++) { AliITSMFTClusterPix* clusT = (AliITSMFTClusterPix*)lr->GetCluster(offs+ics); // access to clusters if (clusT==cl) continue; for (int ilb0=0;ilb0<3;ilb0++) { int lb0 = cl->GetLabel(ilb0); if (lb0<=-1) break; for (int ilb1=0;ilb1<3;ilb1++) { int lb1 = clusT->GetLabel(ilb1); if (lb1<=-1) break; if (lb1==lb0) { cl->SetBit(kSplit); clusT->SetBit(kSplit); /* printf("Discard clusters of module %d:\n",modID); cl->Print(); clusT->Print(); */ break; } } } } } //------------ const AliITSMFTSegmentationPix* segm = gm->GetSegmentation(ilr); // cl->GetGlobalXYZ(xyzClGloF); int clsize = cl->GetNPix(); for (int i=3;i--;) xyzClGlo[i] = xyzClGloF[i]; const TGeoHMatrix* mat = gm->GetMatrixSens(modID); if (!mat) {printf("failed to get matrix for module %d\n",cl->GetVolumeId());} mat->MasterToLocal(xyzClGlo,xyzClTr); // int col,row; segm->LocalToDet(xyzClTr[0],xyzClTr[2],row,col); // effective col/row nLab = 0; for (int il=0;il<3;il++) { if (cl->GetLabel(il)>=0) labels[nLab++] = cl->GetLabel(il); else break; } // find hit info for (int il=0;il<nLab;il++) { TClonesArray* htArr = (TClonesArray*)arrMCTracks.At(labels[il]); //printf("check %d/%d LB %d %p\n",il,nLab,labels[il],htArr); if (!htArr) {printf("did not find MChits for label %d ",labels[il]); cl->Print(); continue;} // int nh = htArr->GetEntriesFast(); AliITSMFTHit *pHit=0; for (int ih=nh;ih--;) { AliITSMFTHit* tHit = (AliITSMFTHit*)htArr->At(ih); if (tHit->GetChip()!=modID) continue; pHit = tHit; break; } if (!pHit) { printf("did not find MChit for label %d on module %d ",il,modID); cl->Print(); htArr->Print(); continue; } // pHit->GetPositionG(xg1,yg1,zg1); pHit->GetPositionG0(xg0,yg0,zg0,tg0); // double txyzH[3],gxyzH[3] = { (xg1+xg0)/2, (yg1+yg0)/2, (zg1+zg0)/2 }; mat->MasterToLocal(gxyzH,txyzH); double rcl = TMath::Sqrt(xyzClTr[0]*xyzClTr[0]+xyzClTr[1]*xyzClTr[1]); double rht = TMath::Sqrt(txyzH[0]*txyzH[0]+txyzH[1]*txyzH[1]); // //Angles determination pHit->GetPositionL(xExit,yExit,zExit,gm); pHit->GetPositionL0(xEnt,yEnt,zEnt,tof1,gm); Double_t dirHit[3]={(xExit-xEnt),(yExit-yEnt),(zExit-zEnt)}; /*double PG[3] = {(double)pHit->GetPXG(), (double)pHit->GetPYG(), (double)pHit->GetPZG()}; //Momentum at hit-point in Global Frame double PL[3]; if (TMath::Abs(PG[0])<10e-7 && TMath::Abs(PG[1])<10e-7) { pHit->Dump(); int lb = pHit->GetTrack(); stack->Particle(lb)->Print(); continue; } mat->MasterToLocalVect(PG,PL); //Momentum in local Frame //printf(">> %e %e %e %e %e %e\n",PG[0],PL[0],PG[1],PL[1],PG[2],PL[2]);*/ Double_t alpha1 = TMath::ACos(TMath::Abs(dirHit[1])/TMath::Sqrt(dirHit[0]*dirHit[0]+dirHit[1]*dirHit[1]+dirHit[2]*dirHit[2])); //Polar Angle Float_t alpha2 = (Float_t) alpha1; //convert to float cSum.alpha = alpha2; Double_t beta1; beta1 = TMath::ATan2(dirHit[0],dirHit[2]); //Azimuthal angle, values from -Pi to Pi Float_t beta2 = (Float_t) beta1; cSum.beta = beta2; if(ilr==0){ hL0A->Fill(alpha2); hL0B->Fill(beta2); } if(ilr==1){ hL1A->Fill(alpha2); hL1B->Fill(beta2); } if(ilr==2){ hL2A->Fill(alpha2); hL2B->Fill(beta2); } if(ilr==3){ hL3A->Fill(alpha2); hL3B->Fill(beta2); } if(ilr==4){ hL4A->Fill(alpha2); hL4B->Fill(beta2); } if(ilr==5){ hL5A->Fill(alpha2); hL5B->Fill(beta2); } if(ilr==6){ hL6A->Fill(alpha2); hL6B->Fill(beta2); } GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); DB.AccountTopology(*cl, cSum.dX, cSum.dZ, cSum.alpha, cSum.beta); GetHistoClSize(clsize,kDR,&histoArr)->Fill((rht-rcl)*1e4); if (cl->TestBit(kSplit)) { if (col%2) GetHistoClSize(clsize,kDTXoddSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXevenSPL,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZSPL,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixSPL,&histoArr)->Fill(clsize); } if (col%2) GetHistoClSize(clsize,kDTXodd,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); else GetHistoClSize(clsize,kDTXeven,&histoArr)->Fill((txyzH[0]-xyzClTr[0])*1e4); GetHistoClSize(clsize,kDTZ,&histoArr)->Fill((txyzH[2]-xyzClTr[2])*1e4); GetHistoClSize(0,kNPixAll,&histoArr)->Fill(clsize); // cSum.evID = iEvent; cSum.volID = cl->GetVolumeId(); cSum.lrID = ilr; cSum.clID = icl; cSum.nPix = cl->GetNPix(); cSum.nX = cl->GetNx(); cSum.nZ = cl->GetNz(); cSum.q = cl->GetQ(); cSum.split = cl->TestBit(kSplit); cSum.dX = (txyzH[0]-xyzClTr[0])*1e4; cSum.dY = (txyzH[1]-xyzClTr[1])*1e4; cSum.dZ = (txyzH[2]-xyzClTr[2])*1e4; cSum.nRowPatt = cl-> GetPatternRowSpan(); cSum.nColPatt = cl-> GetPatternColSpan(); int label = cl->GetLabel(0); TParticle* part = 0; if (label>=0 && (part=stack->Particle(label)) ) { cSum.pdg = part->GetPdgCode(); cSum.eta = part->Eta(); cSum.pt = part->Pt(); cSum.phi = part->Phi(); cSum.prim = stack->IsPhysicalPrimary(label); } cSum.ntr = 0; for (int ilb=0;ilb<3;ilb++) if (cl->GetLabel(ilb)>=0) cSum.ntr++; for (int i=0;i<3;i++) cSum.xyz[i] = xyzClGloF[i]; // trOut->Fill(); /* if (clsize==5) { printf("\nL%d(%c) Mod%d, Cl:%d | %+5.1f %+5.1f (%d/%d)|H:%e %e %e | C:%e %e %e\n",ilr,cl->TestBit(kSplit) ? 'S':'N', modID,icl,(txyzH[0]-xyzClTr[0])*1e4,(txyzH[2]-xyzClTr[2])*1e4, row,col, gxyzH[0],gxyzH[1],gxyzH[2],xyzClGlo[0],xyzClGlo[1],xyzClGlo[2]); cl->Print(); pHit->Print(); // double a0,b0,c0,a1,b1,c1,e0; pHit->GetPositionL0(a0,b0,c0,e0); pHit->GetPositionL(a1,b1,c1); float cloc[3]; cl->GetLocalXYZ(cloc); printf("LocH: %e %e %e | %e %e %e\n",a0,b0,c0,a1,b1,c1); printf("LocC: %e %e %e | %e %e %e\n",cloc[0],cloc[1],cloc[2],xyzClTr[0],xyzClTr[1],xyzClTr[2]); } */ // } } } // layerClus.Clear(); // arrMCTracks.Delete(); }//event loop // DB.EndAndSort(); DB.SetThresholdCumulative(0.95); cout << "Over threshold: : "<< DB.GetOverThr()<<endl; DB.Grouping(10,10); DB.PrintDB("Database1.txt"); flOut->cd(); trOut->Write(); delete trOut; flOut->Close(); flOut->Delete(); DrawReport("clinfo.ps",&histoArr); TFile* flDB = TFile::Open("TopologyDatabase.root", "recreate"); flDB->WriteObject(&DB,"DB","kSingleKey"); flDB->Close(); delete flDB; TCanvas* cnv123 = new TCanvas("cnv123","cnv123"); cnv123->Divide(1,2); cnv123->Print("anglesdistr.pdf["); cnv123->cd(1); hL0A->Draw(); cnv123->cd(2); hL0B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL1A->Draw(); cnv123->cd(2); hL1B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL2A->Draw(); cnv123->cd(2); hL2B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL3A->Draw(); cnv123->cd(2); hL3B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL4A->Draw(); cnv123->cd(2); hL4B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL5A->Draw(); cnv123->cd(2); hL5B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->cd(1); hL6A->Draw(); cnv123->cd(2); hL6B->Draw(); cnv123->Print("anglesdistr.pdf"); cnv123->Print("anglesdistr.pdf]"); // }