Subversion Repositories f9daq

Rev

Rev 266 | Rev 268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 266 Rev 267
Line 21... Line 21...
21
 
21
 
22
class Blab2 {
22
class Blab2 {
23
public:
23
public:
24
UInt_t fNeve;
24
UInt_t fNeve;
25
UInt_t fNfirst;
25
UInt_t fNfirst;
-
 
26
UInt_t fPrint;
26
int fData;
27
int fData;
27
TH1F *fH[100];
28
TH1F *fH[100];
28
UInt_t fHtype[100];
29
UInt_t fHtype[100];
29
TClonesArray *fList[100];
30
TClonesArray *fList[100];
30
 
31
 
Line 33... Line 34...
33
void Init();
34
void Init();
34
void event();
35
void event();
35
void Process();
36
void Process();
36
void h1d(const char *varname, const char *name, int nbins, double min, double max, int id );
37
void h1d(const char *varname, const char *name, int nbins, double min, double max, int id );
37
int  selector(int pin, int charge, SIMPLEPID particlename,  int hid, int pout );
38
int  selector(int pin, int charge, SIMPLEPID particlename,  int hid, int pout );
38
int  combiner(int id0 ,int id1 , SIMPLEPID particlename, double min, double max, int hid, int id );
39
int  combiner(int id0 ,int id1 , int same, SIMPLEPID particlename, double min, double max, int hid, int id );
39
int  fix_mass(int id);
40
int  fix_mass(int id);
40
int  Fill(int hid, BParticle *p);
41
int  Fill(int hid, BParticle *p);
41
void plist(int i);
42
void plist(int i);
42
 
43
 
43
 
44
 
44
ClassDef ( Blab2, 1 )
45
ClassDef ( Blab2, 1 )
45
};
46
};
46
 
47
 
47
ClassImp(Blab2)
48
ClassImp(Blab2)
48
 
49
 
49
Blab2::Blab2():fNfirst(0), fNeve(0), fData(0){
50
Blab2::Blab2():fNfirst(0), fNeve(0), fData(0), fPrint(0) {
50
 
51
 
51
 Process();
52
 Process();
52
};
53
};
53
 
54
 
54
 
55
 
Line 76... Line 77...
76
}  
77
}  
77
 
78
 
78
return 0;
79
return 0;
79
}
80
}
80
 
81
 
81
int Blab2::combiner(int _p0, int _p1,SIMPLEPID pid, double min, double max, int hid, int _p2 ){
82
int Blab2::combiner(int _p0, int _p1,int same, SIMPLEPID pid, double min, double max, int hid, int _p2 ){
82
   // Loop over all the particles in both lists.
83
   // Loop over all the particles in both lists.
83
 if (_p0 < 0 ) _p0 =0;
84
 if (_p0 < 0 ) _p0 =0;
84
 if (_p1 < 0 ) _p1 =0;
85
 if (_p1 < 0 ) _p1 =0;
85
 
86
 
86
 
87
 
87
 fList[_p2]->Clear();
88
 fList[_p2]->Clear();
88
 int nprt=0;
89
 int nprt=0;
89
 
90
 
90
 for(TIter next1(fList[_p0]);BParticle * p1 =(BParticle *) next1();) {
91
 for(TIter next1(fList[_p0]);BParticle * p1 =(BParticle *) next1();) {
91
    // the second loop
92
    // the second loop
92
   
93
   // in the case the second parti 
93
   for(TIter next2 = (_p0!=_p1) ?  TIter(fList[_p1]): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) {  
94
   for(TIter next2 = (_p0!=_p1 && same==0) ?  TIter(fList[_p1]): TIter(next1) ; BParticle * p2 =(BParticle *) next2();) {  
94
      if (p1==p2) continue;
95
      if (p1==p2) continue;     // do not use the same particle in the combinations
95
      BParticle  p = *p1 + *p2; // Combine two particles into a new particle   
96
      BParticle  p = *p1 + *p2; // Combine two particles into a new particle   
96
      if (p.InMassRange(min, max)){
97
      if (p.InMassRange(min, max)){
97
            //SIMPLEPID pid = PION; // should be set to particlename
98
            p.SetPid(pid); // set PID to particlename to fix the particle mass
98
            p.SetPid(pid);
-
 
99
            TClonesArray& list = *fList[_p2];
99
            TClonesArray& list = *fList[_p2];
100
            new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles
100
            new (list[nprt++]) BParticle ( p ); // create a new entry in kslist list of particles
101
            Fill(hid, &p);
101
            Fill(hid, &p);
102
      }
102
      }
103
       
103
       
Line 150... Line 150...
150
}
150
}
151
 
151
 
152
 
152
 
153
void Blab2::Process(){
153
void Blab2::Process(){
154
 
154
 
-
 
155
char sList[0xFFFF];
155
for (int i=0;i<100;i++) fH[i]=NULL;
156
for (int i=0;i<100;i++) fH[i]=NULL;
156
for (int i=0;i<100;i++) fHtype[i]=0;
157
for (int i=0;i<100;i++) fHtype[i]=0;
157
for (int i=0;i<100;i++) fList[i]=NULL;
158
for (int i=0;i<100;i++) fList[i]=NULL;
158
 
159
 
159
Init();
160
Init();
Line 163... Line 164...
163
TTree * t =(TTree *) f-> Get( "T"); // Obtain a pointer to a tree of "event" data in the file
164
TTree * t =(TTree *) f-> Get( "T"); // Obtain a pointer to a tree of "event" data in the file
164
BEvent * mevent = new BEvent(); // Create a  "BEvent" object where data from the file will be loaded
165
BEvent * mevent = new BEvent(); // Create a  "BEvent" object where data from the file will be loaded
165
TBranch * branch = t-> GetBranch( "BEvent"); // Obtain a branch for "BEvent" in the tree
166
TBranch * branch = t-> GetBranch( "BEvent"); // Obtain a branch for "BEvent" in the tree
166
branch-> SetAddress(&mevent); // Register created "BEvent" object to the branch
167
branch-> SetAddress(&mevent); // Register created "BEvent" object to the branch
167
TH1F *fHnprt= new TH1F("h100", "Number of particles in the event;N particles;N events", 50, -0.5, 49.5);
168
TH1F *fHnprt= new TH1F("h100", "Number of particles in the event;N particles;N events", 50, -0.5, 49.5);
168
TH1F *fHid= new TH1F("h101", "Particle type;ID;N particles", 6, -0, 6);
169
TH1F *fHid= new TH1F("h101", "Particle types;ID;N particles", 6, -0, 6);
169
 
-
 
170
const char *names[6]={"PHOTON", "ELECTRON", "PION", "MUON", "KAON", "PROTON"};
170
const char *names[12]={"PHOTON", "ELECTRON", "PION", "MUON", "KAON", "PROTON", "JPSI", "D", "DSTAR", "B","KS", "ALL" };
171
for (int i=1;i<=6;i++) fHid->GetXaxis()->SetBinLabel(i,names[i-1]);
171
for (int i=1;i<=6;i++) fHid->GetXaxis()->SetBinLabel(i,names[i-1]);
172
 
172
 
173
send_message(0, TString::Format("Number of Entries in the file %lld\n", t->GetEntries() ),0);
173
send_message(0, TString::Format("<br>Number of Events in the file %lld<br>\n", t->GetEntries() ),0);
174
TStopwatch timer;
174
TStopwatch timer;
175
timer.Start();
175
timer.Start();
-
 
176
int nev  = 0;
176
int i    =TMath::Min(fNfirst, (UInt_t) t-> GetEntries());
177
int i    =TMath::Min(fNfirst, (UInt_t) t-> GetEntries());
177
int cNeve=TMath::Min(fNfirst+fNeve, (UInt_t) t-> GetEntries());
178
int cNeve=TMath::Min(fNfirst+fNeve, (UInt_t) t-> GetEntries());
178
while (i<cNeve){
179
while (i<cNeve){
179
 t-> GetEntry(i); // Read the content of the event from the file
180
 t-> GetEntry(i); // Read the content of the event from the file
180
 fList[0]= mevent->GetParticleList();
181
 fList[0]= mevent->GetParticleList();
181
 
182
 
182
 event();
183
 event();
183
 
184
 
-
 
185
 int progress = (100*i)/cNeve;
184
 if (i%10000==0) send_message(2, TString::Format("Event %d\n",i), (100*i)/cNeve);
186
 if (i%10000==0) send_message(2, TString::Format("Event %d\n",i), progress);
185
 
187
 
186
 int nprt=0;
188
 int nprt=0;
-
 
189
 if (nev>100) fPrint = 0; // disable particle prints for huge numer of events
-
 
190
 if (fPrint) sprintf(sList,"Primary particle list for Event %d<br/><table class='plist' ><tr><th>N<th>px(GeV/c)<th>py(GeV/c)<th>pz(GeV/c)<th>p(GeV/c)<th>Energy(GeV)<th>Charge<th>ID<th></tr>", i);
187
 for(TIter next(fList[0]); BParticle * p =(BParticle *) next();) {
191
 for(TIter next(fList[0]); BParticle * p =(BParticle *) next();) {
188
   nprt++;
192
   nprt++;
189
   fHid->Fill(p->pid());
193
   fHid->Fill(p->pid());
-
 
194
   if (fPrint) sprintf(sList,"%s<tr><td>%d<td>%g<td>%g<td>%g<td>%g<td>%g<td>%1.0f<td>%s</tr>",sList,nprt, p->px(),p->py(),p->pz(),p->GetMomentum(),p->e(), p->charge(),names[p->pid()] );
190
 }
195
 }
191
 fHnprt->Fill(nprt);
196
 fHnprt->Fill(nprt);
-
 
197
 if (fPrint) {
-
 
198
   sprintf(sList,"%s</table>",sList);
-
 
199
   send_message(0, TString(sList),progress);
-
 
200
   nev++;
192
 
201
 }
193
 mevent-> Clear();  // Clear the memory.
202
 mevent-> Clear();  // Clear the memory.
194
 for (int k=0;k<100;k++) if (fList[k]!=0) fList[k]->Clear();
203
 for (int k=0;k<100;k++) if (fList[k]!=0) fList[k]->Clear();
195
 i++;
204
 i++;
196
}
205
}
197
 
206