The macros was working only in SSD mode. Now it works il All mode
[u/mrichter/AliRoot.git] / ITS / SSDrecpointTest.C
index 2cc5e2146fbf142171b6b7a6c08a0452cfd64743..1306102be209769d83581975efdf85dff7d4920e 100644 (file)
@@ -21,6 +21,9 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
    if (gClassTable->GetID("AliRun") < 0) {
       gROOT->LoadMacro("loadlibs.C");
       loadlibs();
+   } else {
+      delete gAlice;
+      gAlice=0;
    }
 
 // Connect the Root Galice file containing Geometry, Kine and Hits
@@ -47,6 +50,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
             Int_t nxN;
             Int_t hitprim;
             Int_t partcode;
+            Int_t ntrover;
             Float_t x;
             Float_t z;
             Float_t dx;
@@ -62,6 +66,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
             Int_t nxN;
             Int_t noverlaps;
             Int_t noverprim;
+            Int_t ntrover;
             Float_t qclP;
             Float_t qclN;
             Float_t qrec;
@@ -82,6 +87,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
           ntuple->Branch("nxN",&ntuple_st.nxN,"nxN/I");
           ntuple->Branch("hitprim",&ntuple_st.hitprim,"hitprim/I");
           ntuple->Branch("partcode",&ntuple_st.partcode,"partcode/I");
+          ntuple->Branch("ntrover",&ntuple_st.ntrover,"ntrover/I");
           ntuple->Branch("x",&ntuple_st.x,"x/F");
           ntuple->Branch("z",&ntuple_st.z,"z/F");
           ntuple->Branch("dx",&ntuple_st.dx,"dx/F");
@@ -101,6 +107,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
           ntuple1->Branch("dz",&ntuple1_st.dz,"dz/F");
          ntuple1->Branch("noverlaps",&ntuple1_st.noverlaps,"noverlaps/I");
           ntuple1->Branch("noverprim",&ntuple1_st.noverprim,"noverprim/I");
+          ntuple1->Branch("ntrover",&ntuple1_st.ntrover,"ntrover/I");
 
           ntuple2 = new TTree("ntuple2","Demo ntuple2");
           ntuple2->Branch("nxP",&ntuple2_st.nxP,"nxP/I");
@@ -132,7 +139,8 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
    AliITS *ITS  = (AliITS*) gAlice->GetModule("ITS");
    if (!ITS) { cout << "no ITS" << endl; return; }
    
-   AliITSgeom *aliitsgeo = ITS->GetITSgeom();
+   //AliITSgeom *aliitsgeo = ITS->GetITSgeom();
+   AliITSgeom *geom = ITS->GetITSgeom();
 
    //Int_t cp[8]={0,0,0,0,0,0,0,0};
 
@@ -205,31 +213,33 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
      // check hits
      
      Int_t nmodules=0;
+     Int_t mod;
      
      ITS->InitModules(-1,nmodules); 
      ITS->FillModules(nev,0,nmodules,"","");
      
      TObjArray *fITSmodules = ITS->GetModules();
      
-     Int_t first1 = aliitsgeo->GetStartDet(2); // SSD
-     Int_t last1 = aliitsgeo->GetLastDet(2);   // SSD
-     Int_t first = aliitsgeo->GetStartDet(1);  // SDD
-     Int_t last = aliitsgeo->GetLastDet(1);    // SDD
-     Int_t first0 = aliitsgeo->GetStartDet(0);  // SPD
-     Int_t last0 = aliitsgeo->GetLastDet(0);    // SPD
-
-     //  For the SPD: first0 = 0, last0 = 239, 240 modules;  
-     //  for the SDD: first1 = 240, last1 = 499, 260 modules;  
-     //  for the SPD: first2 = 500, last2 = 2269, 1770 modules;
-       
-     printf("det type %d first, last %d %d \n",0,first0,last0);
-     printf("det type %d first, last %d %d \n",1,first,last);
-     printf("det type %d first1, last1 %d %d \n",2,first1,last1);
-
-     // module loop
-     for (Int_t mod=first1; mod<last1; mod++) {
-
-              TTree *TR = gAlice->TreeR();
+     Int_t first0 = geom->GetStartDet(0);  // SPD
+     Int_t last0 = geom->GetLastDet(0);    // SPD
+     Int_t first1 = geom->GetStartDet(1);  // SDD
+     Int_t last1 = geom->GetLastDet(1);    // SDD
+     Int_t first2 = geom->GetStartDet(2);  // SSD
+     Int_t last2 = geom->GetLastDet(2);    // SSD
+
+     //  For the SPD: first0 = 0, last0 = 239     (240 modules);  
+     //  for the SDD: first1 = 240, last1 = 499   (260 modules);  
+     //  for the SSD: first2 = 500, last2 = 2269  (1770 modules).  
+
+     printf("det type %d first0, last0 %d %d \n",0,first0,last0);
+     printf("det type %d first1, last1 %d %d \n",1,first1,last1);
+     printf("det type %d first2, last2 %d %d \n",2,first2,last2);
+
+     // module loop for the SSD
+     //for (mod=first2; mod<last2+1; mod++) {  // for the "ALL" option
+     for (mod=0; mod<last2-first2+1; mod++) { //for the "SSD" option
+
+       TTree *TR = gAlice->TreeR();
        Int_t nentrec=TR->GetEntries();
        //printf("Found %d entries in the RecPoints tree\n",nentrec);
       
@@ -240,23 +250,27 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
        //cout << "RECPOINTS: reset" << endl;
        ITS->ResetRecPoints();
        //cout << "RECPOINTS: get" << endl;
-       //TR->GetEvent(mod+1);
-       TR->GetEvent(mod);
+       //TR->GetEvent(mod+1);   // for the V3.04 AliRoot
+       TR->GetEvent(mod);       // for the V3.05 AliRoot
 
        Int_t nrecp = ITSrec->GetEntries();
        totpoints += nrecp;
        if (nrecp) printf("Found %d rec points for module %d\n",nrecp,mod);
-       if (!nrecp) continue;
+       //if (!nrecp) continue;
        Int_t nclusters = ITSclu->GetEntries();
        totclust += nclusters;
-       if (nclusters) cout<<"ncluster ="<<nclusters<<endl;
        //if (nclusters) printf("Found %d clusters for module %d\n",nrecc,mod);
        
+       //AliITSmodule *Mod = (AliITSmodule *)fITSmodules->At(mod+first2);
+       // for the "SSD" option
+
        AliITSmodule *Mod = (AliITSmodule *)fITSmodules->At(mod);
+       // for the "ALL" option
+
        //       printf("Mod: %X\n",Mod);
        Int_t nhits = Mod->GetNhits();
        Float_t epart = 0;
-       cout <<" module,nrecp,nclusters,nhits ="<<mod<<","<<nrecp<<","<<nclusters<<","<<nhits<< endl;
+       //cout <<" module,nrecp,nclusters,nhits ="<<mod<<","<<nrecp<<","<<nclusters<<","<<nhits<< endl;
 
        // ---------------- cluster/hit analysis ---------------------
 
@@ -272,6 +286,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
 
         Int_t nxP = itsClu->fMultiplicity;
         Int_t nxN = itsClu->fMultiplicityN;
+        Int_t ntrover = itsClu->fNtracks;
         Float_t qclP = itsClu->fSignalP;     // in ADC
         Float_t qclN = itsClu->fSignalN;     // in ADC
         //Float_t dq = qclP - qclN;
@@ -289,7 +304,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
         Int_t tr2 = itsPnt->GetLabel(ii);
          Int_t ii = 2;
         Int_t tr3 = itsPnt->GetLabel(ii);
-
+        //cout<<"pnt,ntrover,tr1,tr2,tr3 ="<<pnt<<","<<ntrover<<","<<tr1<<","<<tr2<<","<<tr3<<endl;
         // fill ntuple2
             ntuple2_st.nxP = nxP;
              ntuple2_st.nxN = nxN;
@@ -331,6 +346,7 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
    //  partcode (pdgCode): 11 - e-, 13 - mu-, 22 - gamma, 111 - pi0, 211 - i+
    //  310 - K0s, 321 - K+, 2112 - n, 2212 - p, 3122 - lambda
 
+          //cout<<"hit,hitstat,track,partcode,parent ="<<hit<<","<<hitstat<<","<<track<<","<<partcode<<","<<parent<<endl;
            Float_t pmod = itsHit->GetParticle()->P(); // the momentum at the
                                                      // vertex
           pmod *= 1.0e+3;
@@ -352,7 +368,8 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
 
          // Consider the hits only with the track number equaled to one
          // of the recpoint
-         if(track == tr1) flagtrack = 1;
+         if((track == tr1) || (track == tr2) || (track == tr3)) flagtrack = 1;
+         //cout<<"!!Ok: track,tr1,tr2,tr3 ="<<track<<","<<tr1<<","<<tr2<<","<<tr3<<endl;
 
          if(flagtrack == 1) {     // the hit corresponds to the recpoint
 
@@ -376,39 +393,45 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
 
 
          // x,z resolution colculation
-          if((hitstat == 68 || hitsat == 33) && parent < 0)  {
+          if((hitstat == 68 || hitsat == 33) && dray == 0) {
             Float_t xmed = (xhit + xhit0)/2;
             Float_t zmed = (zhit + zhit0)/2;
             Float_t xdif = xmed - xrec;
             Float_t zdif = zmed - zrec;
 
-            hitprim = 1; // hitprim=1 for the primery particles
-
-            noverprim += 1;
-
+            if(parent < 0)  {
+             hitprim = 1; // hitprim=1 for the primery particles
+             noverprim += 1;
+           }
             pathInSSD = TMath::Sqrt((xhit0-xhit)*(xhit0-xhit)+(yhit0-yhit)*(yhit0-yhit)+(zhit0-zhit)*(zhit0-zhit));
 
+            //cout<<"lay,pnt,hit,xmed,xrec,xdif,zmed,zrec,zdif ="<<hitlayer<<","<<pnt<<","<<hit<<","<<xmed<<","<<xrec<<","<<xdif<<","<<zmed<<","<<zrec<<","<<zdif<<endl;
 
-        // fill ntuple
+            // fill ntuple
              ntuple_st.lay = hitlayer;
             ntuple_st.nxP = nxP;
              ntuple_st.nxN = nxN;
             ntuple_st.hitprim = hitprim;
              ntuple_st.partcode = partcode;
+             ntuple_st.ntrover = ntrover;
             ntuple_st.x = xrec/1000;
              ntuple_st.z = zrec/1000;
             ntuple_st.dx = xdif;
              ntuple_st.dz = zdif;
              ntuple_st.pmod = pmod;
 
-             if(qcut < 0.18) ntuple->Fill();
+             //if(qcut < 0.18) ntuple->Fill();
+             ntuple->Fill();
 
-           if(hitlayer == 5 && qcut < 0.18) {
+            //if(hitlayer == 5 && qcut < 0.18) {
+             
+           if(hitlayer == 5 ) {
              Xres5->Fill(xdif);
              Zres5->Fill(zdif);
              Path5->Fill(pathInSSD);
-            }
-            if(hitlayer == 6 && qcut < 0.18) {
+           }
+            //if(hitlayer == 6 && qcut < 0.18) {
+            if(hitlayer == 6) {
              Xres6->Fill(xdif);
              Zres6->Fill(zdif);
              Path6->Fill(pathInSSD);
@@ -421,7 +444,6 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
        } // hit loop       
 
        if(flaghit == 1) {
-         cout<<" flaghit Ok"<<endl;
 
          if(noverlaps == 0) noverlaps = 1; // cluster contains one or more
          // delta rays only
@@ -441,8 +463,10 @@ void SSDrecpointTest (Int_t evNumber1=0,Int_t evNumber2=0)
          noverprim -= 1;
          ntuple1_st.noverlaps = noverlaps;
          ntuple1_st.noverprim = noverprim;
+          ntuple1_st.ntrover = ntrover;
 
-         if(qcut < 0.18) ntuple1->Fill();
+         //if(qcut < 0.18) ntuple1->Fill();
+         ntuple1->Fill();
 
           Float_t de = dedx*300./pathInSSD;
           dEdX->Fill(de);