Int_t ITSgeoplot (char *opt="All+Rec", char *filename="galice.root") { /******************************************************************* * This macro displays geometrical information related to the * hits, digits and rec points in ITS. * There are histograms that are not displayed (i.e. energy * deposition) but that are saved onto a file (see below) * * Options: Any combination of: * 1) subdetector name: "SPD", "SDD", "SSD", "All" (default) * 2) Printouts: "Verbose" Almost everything is printed out: * it is wise to redirect the output onto a file * e.g.: .x ITSgeoplot.C("All+Verbose") > out.log * 3) Rec Points option: "Rec" ---> Uses Rec. Points (default) * otherwise ---> uses hits and digits only * Examples: * .x ITSgeoplot(); (All subdetectors; no-verbose; no-recpoints) * .x ITSgeoplot("SPD+SSD+Verbose+Rec"); * * OUTPUT: It produces a root file with a list of histograms * The list can be accessed either with the Root TBrowser * or with the simple macro ITSgeoplotread.C * WARNING: spatial information for SSD/DIGITS is obtained by pairing * digits on p and n side originating from the same track, when * possible. This (mis)use of DIGITS is tolerated for debugging * purposes only !!!! The pairing in real life should be done * starting from info really available... * * M.Masera 19/3/2001 18:45 ********************************************************************/ extern void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb); extern Int_t GetRecCoor(TObject *ge, TClonesArray *ITSrec, Int_t mod, TH2F *h2, TH1F *h1, Bool_t verb); extern void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, Int_t mod, Bool_t verbose, TObjArray & histos); //Options TString choice(opt); Bool_t All = choice.Contains("All"); Bool_t verbose=choice.Contains("Verbose"); Bool_t userec=choice.Contains("Rec"); Int_t retcode=1; //return code if (gClassTable->GetID("AliRun") < 0) { gROOT->LoadMacro("loadlibs.C"); loadlibs(); } else { if(gAlice){ delete gAlice; gAlice=0; } } // Connect the Root input file containing Geometry, Kine and Hits // galice.root file by default TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); if (!file) file = new TFile(filename); file->ls(); // Get AliRun object from file if (!gAlice) { gAlice = (AliRun*)file->Get("gAlice"); if (gAlice && verbose)cout<<"AliRun object found on file "<GetEvent(0); if(verbose) { cout<<" "<InitModules(-1,nmodules); cout<<"Number of ITS modules= "<FillModules(0,0,nmodules," "," "); cout<<"ITS modules .... DONE!"<TreeD(); //RECPOINTS TTree *TR = gAlice->TreeR(); TClonesArray *ITSrec = ITS->RecPoints(); if(userec && (!TR || !ITSrec)){ userec = kFALSE; cout<<" "<GetITSgeom(); for(Int_t subd=0;subd<3;subd++){ if(All || (choice.Contains("SPD") && subd==0) || (choice.Contains("SDD") && subd==1) || (choice.Contains("SSD") && subd==2)){ // Prepare array for the digits TClonesArray *ITSdigits = ITS->DigitsAddress(subd); Bool_t usedigits = kTRUE; if(!ITSdigits){ usedigits = kFALSE; cout<<" "<DetType(subd); TString detna; // subdetector name if(subd==0)detna="SPD"; if(subd==1)detna="SDD"; if(subd==2)detna="SSD"; AliITSsegmentation *seg=(AliITSsegmentation*)iDetType->GetSegmentationModel(); // Loop on modules first = geom->GetStartDet(subd); last = geom->GetLastDet(subd); if(verbose){ cout<<" "<GetTrans(mod,pos); // position of the module in the MRS ragdet=sqrt(pos[0]*pos[0]+pos[1]*pos[1]); // The following 2 histos are a check of the geometry TH2F *bidi = (TH2F*)histos.At(2+subd*9); TH1F *uni = (TH1F*)histos.At(5+subd*9); bidi->Fill(pos[0],pos[1]); uni->Fill(pos[2]); if(verbose){ cout<<"==========================================================="<ResetRecPoints(); TR->GetEvent(mod); TH2F *bidi=(TH2F*)histos.At(6+subd*9); TH1F *uni=(TH1F*)histos.At(7+subd*9); nrecp=GetRecCoor(geom,ITSrec,mod,bidi,uni,verbose); } // Digits if(usedigits){ ITS->ResetDigits(); nbytes += TD->GetEvent(mod); GetDigits(seg,geom,ITSdigits,subd,mod,verbose,histos); } } // End of loop on the modules TH1F *h1tmp; TH2F *h2tmp; // Plot the histograms TCanvas *current=0; // current Canvas (1--> SPD, 2---> SDD, 3---> SSD) if(subd==0){ // Prepare canvas 1 TCanvas *c1 = new TCanvas("c1","SPD",10,10,600,900); c1->Divide(2,3); current=c1; } if(subd==1){ // Prepare canvas 2 TCanvas *c2 = new TCanvas("c2","SDD",40,40,600,900); c2->Divide(2,3); current=c2; } if(subd==2){ // Prepare canvas 3 TCanvas *c3 = new TCanvas("c3","SSD",70,70,600,900); c3->Divide(2,3); current=c3; } current->cd(1); h2tmp = (TH2F*)histos.At(9*subd); h2tmp->Draw(); current->cd(2); h1tmp=(TH1F*)histos.At(3+subd*9); h1tmp->Draw(); current->cd(3); h2tmp=(TH2F*)histos.At(1+9*subd); h2tmp->Draw(); current->cd(4); h1tmp=(TH1F*)histos.At(4+subd*9); h1tmp->Draw(); if(userec){ current->cd(5); h2tmp=(TH2F*)histos.At(6+9*subd); h2tmp->Draw(); current->cd(6); h1tmp=(TH1F*)histos.At(7+subd*9); h1tmp->Draw(); } else { current->cd(5); h2tmp=(TH2F*)histos.At(2+9*subd); h2tmp->Draw(); current->cd(6); h2tmp=(TH2F*)histos.At(5+9*subd); h2tmp->Draw(); } } // if(All..... } // end of loop on subdetectors // Save the histograms TFile *fh = new TFile("ITSgeoplot.root","recreate"); // The list is written to file as a single entry TList *lihi = new TList(); // copy the pointers to the histograms to a TList object. // The histograms concerning recpoints are not copied if // 'userec' is false. for(Int_t i=0;i7 && i<16) || (choice.Contains("SSD") && i>15)){ if(!(!userec && ((i+2)%9==0 || (i+1)%9==0)))lihi->Add(histos.At(i)); } } lihi->Write("Histograms ITS hits+digits+recpoints",TObject::kSingleKey); fh->Close(); return retcode; } void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb){ TH2F *h2=(TH2F*)histos.At(1+subd*9); TH1F *h1=(TH1F*)histos.At(4+subd*9); TH1F *ener=(TH1F*)histos.At(8+subd*9); AliITS *ITS= (AliITS*)its; AliITSmodule *modu = ITS->GetModule(mod); TObjArray *fHits = modu->GetHits(); Int_t nhits = fHits->GetEntriesFast(); if(nhits>0){ if(verb){ cout<<"-------------------------------------------------------"<At(hit); if(!iHit->StatusEntering()){ Float_t x=iHit->GetXG(); Float_t y=iHit->GetYG(); Float_t z=iHit->GetZG(); Float_t edep=iHit->GetIonization()*1000000; h2->Fill(x,y); h1->Fill(z); ener->Fill(edep); if(verb){ cout<<"hit # "<GetTrack()<<" energy deposition (KeV)= "<GetEntries(); if(nrecp>0){ Float_t lc[3]; for(Int_t i=0; i<3; i++) lc[i]=0.; Float_t gc[3]; for(Int_t i=0; i<3; i++) gc[i]=0.; if(verb){ cout<<"-------------------------------------------------------"<At(irec); lc[0]=recp->GetX(); lc[2]=recp->GetZ(); geom->LtoG(mod,lc,gc); if(verb){ cout<<"recp # "<Fill(gc[0],gc[1]); h1->Fill(gc[2]); } } return nrecp; } void GetDigits(TObject *tmps,TObject *ge,TClonesArray *ITSdigits, Int_t subd, Int_t mod, Bool_t verbose, TObjArray & histos){ AliITSsegmentation *seg = (AliITSsegmentation*)tmps; AliITSgeom *geom = (AliITSgeom*)ge; Float_t lcoor[3]; for(Int_t j=0; j<3; j++) lcoor[j]=0.; //local coord dig. Float_t gcoor[3]; for(Int_t j=0; j<3; j++) gcoor[j]=0.; // global coo. dig. Float_t ragdig; // Radius digit TArrayI ssdone(5000); // used to match p and n side digits of strips TArrayI pair(5000); // as above Int_t ndigits = ITSdigits->GetEntries(); AliITSdigit *digs; if(ndigits){ if(verbose){ cout<<"-------------------------------------------------------"<UncheckedAt(digit); Int_t iz=digs->fCoord1; // cell number z Int_t ix=digs->fCoord2; // cell number x // Get local coordinates of the element (microns) if(subd<2){ seg->GetPadCxz(ix,iz,lcoor[0],lcoor[2]); } else{ // SSD: if iz==0 ---> N side; if iz==1 P side if(ssdone[digit]==0){ ssdone[digit]=1; pair[digit]=-1; Bool_t pside=(iz==1); Bool_t impaired=kTRUE; Int_t pstrip=0; Int_t nstrip=0; if(pside)pstrip=ix; if(!pside)nstrip=ix; for(Int_t digi2=0;digi2UncheckedAt(digi2); if(dig2->fCoord1 != iz && dig2->GetTracks()[0]==digs->GetTracks()[0]){ ssdone[digi2]=2; pair[digit]=digi2; if(pside)nstrip=dig2->fCoord2; if(!pside)pstrip=dig2->fCoord2; impaired=kFALSE; } } } if(!impaired)seg->GetPadCxz(pstrip,nstrip,lcoor[0],lcoor[2]); } } if(subd==0){ // !!!THIS CONVERSION TO HIT LRS SHOULD BE REMOVED AS SOON AS THE CODE IS FIXED lcoor[0]=lcoor[0]-seg->Dx()/2; lcoor[2]=lcoor[2]-seg->Dz()/2; } if(subd<2 || (subd==2 && ssdone[digit]==1)){ Int_t coor1=digs->fCoord1; Int_t coor2=digs->fCoord2; Int_t tra0=digs->GetTracks()[0]; if(verbose){ cout<<"digit # "<LtoG(mod,lcoor,gcoor); // global coord. in cm ragdig=sqrt(gcoor[0]*gcoor[0]+gcoor[1]*gcoor[1]); if(verbose)cout<<"global coordinates "<Fill(gcoor[0],gcoor[1]); uni->Fill(gcoor[2]); } } } // loop on digits for this module } // if(ndigits>0.... }