#include "Stntuple/loop/TStnAna.hh" #include "TSiExample.hh" #include "TObjArray.h" #include "Stntuple/obj/TStnTrack.hh" TSiExample::TSiExample(const char* name, const char* title) : TStnModule(name,title), NTrk(NULL), Pt(NULL), NPhi(NULL), NSas(NULL), NZ(NULL), Stat(NULL), fT(NULL), fH(NULL), fS(NULL) {} TSiExample::~TSiExample() {} int TSiExample::BeginJob() { fT=(TStnTrackBlock *)fAna->RegisterDataBlock("TrackBlock","TStnTrackBlock"); if (!fT) { printf(" >>> branch *** %s *** doesn't exist \n","TrackBlock"); fEnabled = 0; } fL=(TStnTrackLinkBlock *)fAna->RegisterDataBlock("TrackLinkBlock","TStnTrackLinkBlock"); if (!fL) { printf(" >>> branch *** %s *** doesn't exist \n","TrackLinkBlock"); fEnabled = 0; } fH=(TSvxDataBlock *)fAna->RegisterDataBlock("SvxDataBlock","TSvxDataBlock"); if (!fH) { printf(" >>> branch *** %s *** doesn't exist \n","SvxDataBlock"); fEnabled = 0; } fS=(TSiStripBlock *)fAna->RegisterDataBlock("SiStripsBlock","TSiStripBlock"); if (!fS) { printf(" >>> branch *** %s *** doesn't exist \n","SiStripsBlock"); fEnabled = 0; } NTrk = new TH1F("NTrk","NTrack passing cuts",5,0.0,5.0); Pt = new TH1F("Pt","Pt",50,0.0,100.0); NPhi = new TH1F("NPhi","NPhi",10,0.0,10.0); NSas = new TH1F("NSas","NSas",10,0.0,10.0); NZ = new TH1F("NZ","NZ",10,0.0,10.0); Stat = new TH1F("Stat","Status code of strips in hits on tracks",3,0.0,3.0); for (int b=0; b<6; b++) { char tit[100]; char name[4]; sprintf(tit,"%s%d","Global XY of axial hits in barrel ",b); sprintf(name,"%s%d","XY",b); XY[b] = new TH2F(tit,name,100,-35.0,35.0,100,-35.0,35.0); } return 0; } int TSiExample::BeginRun() { return 0; } int TSiExample::Event(int ientry) { fT->Clear(); fT->GetEntry(ientry); // Loop over all the tracks passing some cuts int ntrk=0; for (int itrk=0; itrkNTracks(); itrk++) { TStnTrack *t=fT->Track(itrk); if (t->Pt()>10.0 && t->Pt()<500.0 && t->NSvxHits()>0) { // If event has a good track, then on first track that passes, // load the other branches. This speeds up reading of ntuples. if (ntrk==0) { fL->Clear(); fL->GetEntry(ientry); fH->Clear(); fH->GetEntry(ientry); // fH->InitEvent(); // Call this if you want to use the lookup tables using digicodes fS->Clear(); fS->GetEntry(ientry); } ntrk++; Pt->Fill(t->Pt()); NPhi->Fill(1.0*t->NSvxRPhiHits()); NSas->Fill(1.0*t->NSvxSASHits()); NZ->Fill(1.0*t->NSvxZHits()); // Now loop over hits attached to this track int nhit=fL->SiHitLinkTrk()->NLinks(itrk); for (int ih=0; ihSiHitLinkTrk()->Index(itrk,ih); // Check that this index is valid, if not something bad is happening if (ihit > fH->NSiHits() || ihit < 0) return -1; // Now you can use this index to get the TStnSiHit, or the links to the TStnSiStrips TStnSiHit *hit = fH->SiHit(ihit); if (hit->DigiCode()->Side()==0) { XY[hit->DigiCode()->Barrel()*2+hit->DigiCode()->LadderSeg()]->Fill(hit->Global()->x(), hit->Global()->y()); } int nstp = fH->SiStripLinkHit()->NLinks(ihit); for (int is=0; isSiStripLinkHit()->Index(ihit,is); TStnSiStrip *stp = fS->SiStrip(istp); Stat->Fill(stp->fStatus); } } // Loop over hits on track } // Track cuts } // Loop over tracks if (ntrk>0) NTrk->Fill(1.0*ntrk); return 0; } int TSiExample::EndJob() { return 0; }