/[PAMELA software]/calo/flight/CaloPreSampler/src/CaloPreSampler.cpp
ViewVC logotype

Diff of /calo/flight/CaloPreSampler/src/CaloPreSampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mocchiut, Fri Jul 20 09:13:38 2007 UTC revision 1.13 by mocchiut, Mon Jul 27 13:58:58 2009 UTC
# Line 12  Line 12 
12   */   */
13  CaloPreSampler::CaloPreSampler(){  CaloPreSampler::CaloPreSampler(){
14    Clear();    Clear();
15  };  }
16    
17  CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){    CaloPreSampler::CaloPreSampler(PamLevel2 *l2p){  
18    //    //
# Line 30  CaloPreSampler::CaloPreSampler(PamLevel2 Line 30  CaloPreSampler::CaloPreSampler(PamLevel2
30    cstrip = new CaloStrip(false);    cstrip = new CaloStrip(false);
31    //  c1 = new CaloLevel1();    //  c1 = new CaloLevel1();
32    pcalo = new CaloLevel2();    pcalo = new CaloLevel2();
33    N = 3;    N = 4;
34      NC = 22-N;
35    debug = false;    debug = false;
36    sel = true;    sel = true;
37    cont = false;    cont = false;
38    emulate18 = true;    emulate18 = true;
39    simulation = false;    simulation = false;
40      withtrk = true;
41      rigdefault = 50.;
42      nox = false;
43      noy = false;
44      forcecalo = false;
45      forcefitmode = -1;
46      memset(mask,0,2*22*sizeof(Int_t));
47    //    //
48    Clear();    Clear();
49    //    //
# Line 62  CaloPreSampler::CaloPreSampler(PamLevel2 Line 70  CaloPreSampler::CaloPreSampler(PamLevel2
70    printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data());    printf(" Reading magnetic field maps at %s\n",(q4->PATH+q4->NAME).Data());
71    trk->LoadField(q4->PATH+q4->NAME);    trk->LoadField(q4->PATH+q4->NAME);
72    //    //
73  };  }
74    
75    void CaloPreSampler::SetNoWpreSampler(Int_t n){
76      if ( NC+n < 23 ){
77        N = n;
78      } else {
79        printf(" ERROR! Calorimeter is made of 22 W planes\n");
80        printf(" you are giving N presampler = %i and N calo = %i \n",n,NC);
81        printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n");
82        NC = 18;
83        N = 4;
84      };
85    }
86    
87    void CaloPreSampler::SetNoWcalo(Int_t n){
88      if ( N+n < 23 ){
89        NC = n;
90      } else {
91        printf(" ERROR! Calorimeter is made of 22 W planes\n");
92        printf(" you are giving N W presampler = %i and N W calo = %i \n",N,n);
93        printf(" WARNING: using default values NWpre = 4, NWcalo = 18\n");
94        NC = 18;
95        N = 4;
96      };
97    }
98    
99    void CaloPreSampler::SplitInto(Int_t NoWpreSampler, Int_t NoWcalo){
100      this->SetNoWcalo(0);
101      this->SetNoWpreSampler(0);
102      if ( NoWpreSampler < NoWcalo ){
103            this->SetNoWpreSampler(NoWpreSampler);
104            this->SetNoWcalo(NoWcalo);
105      } else {
106            this->SetNoWcalo(NoWcalo);
107            this->SetNoWpreSampler(NoWpreSampler);
108      };
109    }
110    
111  void CaloPreSampler::Clear(){  void CaloPreSampler::Clear(){
112    //    //
113    pcalo->Clear();    pcalo->Clear();
114    //    //
115  };  }
116    
117  void CaloPreSampler::Print(){  void CaloPreSampler::Print(){
118    //    //
# Line 90  void CaloPreSampler::Print(){ Line 134  void CaloPreSampler::Print(){
134    };    };
135    printf("========================================================================\n");    printf("========================================================================\n");
136    //    //
137  };  }
138    
139  void CaloPreSampler::Delete(){  void CaloPreSampler::Delete(){
140    Clear();    Clear();
141    delete pcalo;    delete pcalo;
142    //delete this;    //delete this;
143  };  }
144    
145    
146  void CaloPreSampler::Process(){  void CaloPreSampler::Process(){
# Line 107  void CaloPreSampler::Process(){ Line 151  void CaloPreSampler::Process(){
151      return;      return;
152    };    };
153    //    //
154      // Clear structures used to communicate with fortran
155      //
156      event->ClearStructs();//ELENA
157      if ( forcefitmode > 0 ){
158        if ( forcefitmode != 1000 && forcefitmode != 1001 && forcefitmode != 1002 ){
159          printf(" ERROR! forcefitmode=%i \n Use forcefitmode = 1000 for fit mode 0, 1001 fit mode 1, 1002 fit mode 3\n",forcefitmode);
160          forcefitmode = -1;
161        } else {
162          event->clevel2->fmode[0] = forcefitmode;
163          event->clevel2->fmode[1] = forcefitmode;
164        };
165      };
166      //
167    Bool_t newentry = false;    Bool_t newentry = false;
168    //    //
169    if ( L2->IsORB() ){    if ( L2->IsORB() ){
# Line 131  void CaloPreSampler::Process(){ Line 188  void CaloPreSampler::Process(){
188    Int_t S11 = 0;    Int_t S11 = 0;
189    Float_t tmptrigty = -1.;    Float_t tmptrigty = -1.;
190    Bool_t trackanyway = true;    Bool_t trackanyway = true;
191    Float_t rigdefault = 50.;    //  Float_t rigdefault = 50.;
192    Bool_t hZn = true;    Bool_t hZn = true;
193    Bool_t withtrk = true;    //  Bool_t withtrk = true;
194    Bool_t st = true;    Bool_t st = true;
195    Int_t ntrkentry = 0;    Int_t ntrkentry = 0;
196    TrkLevel2 *trk = L2->GetTrkLevel2();    TrkLevel2 *trk = L2->GetTrkLevel2();
# Line 153  void CaloPreSampler::Process(){ Line 210  void CaloPreSampler::Process(){
210      if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true;      if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -2 ) m2 = true;
211      if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true;      if ( L2->GetCaloLevel2()->GetCaloTrkVar(mm)->trkseqno == -3 ) m3 = true;
212    };    };
213      if ( !withtrk ) m3 = true;
214    //    //
215    if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n");    if ( debug ) printf(" Fill estrip matrix needed to calculate variables \n");
216    //    //
# Line 167  void CaloPreSampler::Process(){ Line 225  void CaloPreSampler::Process(){
225      //      //
226      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
227      //      //
228        // Mask x or y view if nox and/or noy are true (default false)
229        //
230        if ( mask[view][plane] ) mip = 0.;
231        if ( nox && view == 0 ) mip = 0.;
232        if ( noy && view == 1 ) mip = 0.;
233        //
234        if ( emulate18 && view == 0 && plane == 18 ) mip = 0.;
235        //
236      // Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19      // Selection mode: fill the matrix only for plane < (22 - N) REMEMBER N = number of W planes to be used as presampler, ie if N = 2 then we want to use planes from 0 to 19
237      //                 included so plane < (22 - 2)      //                 included so plane < (22 - 2)
238      //      //
239      if ( sel ){      if ( sel ){
240        if ( plane < (22 - N) ){        if ( plane < (22 - N) ){
241          //          //
242          if ( emulate18 && plane == (18 - N) ) mip = 0.;          if ( emulate18 && plane == (18 - N) && view == 0 ) mip = 0.;
243            if ( plane >= NC ) mip = 0.;
244          event->clevel1->estrip[strip][plane][view] = mip;          event->clevel1->estrip[strip][plane][view] = mip;
245          //          //
246        };        };
# Line 184  void CaloPreSampler::Process(){ Line 251  void CaloPreSampler::Process(){
251      if ( cont ){      if ( cont ){
252        if ( plane >= N ){        if ( plane >= N ){
253          //          //
254          if ( emulate18 && plane == (18 + N) ) mip = 0.;          if ( emulate18 && plane == (18 + N) && view == 0 ) mip = 0.;
255            if ( (plane-N) >= NC ) mip = 0.;
256          event->clevel1->estrip[strip][(plane-N)][view] = mip;          event->clevel1->estrip[strip][(plane-N)][view] = mip;
257          //          //
258        };        };
# Line 228  void CaloPreSampler::Process(){ Line 296  void CaloPreSampler::Process(){
296    //    //
297    // use only N W planes    // use only N W planes
298    //    //
299    event->clevel1->npla = 22-N;    //  event->clevel1->npla = 22-N;
300      event->clevel1->npla = NC;
301    //    //
302    S3 = 0;    S3 = 0;
303    S2 = 0;    S2 = 0;
# Line 248  void CaloPreSampler::Process(){ Line 317  void CaloPreSampler::Process(){
317    //    //
318    event->clevel1->good2 = 1;    event->clevel1->good2 = 1;
319    //    //
320      // copy variables calculated during calibration process which is skipped here...
321      //
322      event->clevel2->good = L2->GetCaloLevel2()->good;
323      memcpy(event->clevel2->perr,L2->GetCaloLevel2()->perr,sizeof(L2->GetCaloLevel2()->perr));
324      memcpy(event->clevel2->swerr,L2->GetCaloLevel2()->swerr,sizeof(L2->GetCaloLevel2()->swerr));
325      memcpy(event->clevel2->crc,L2->GetCaloLevel2()->crc,sizeof(L2->GetCaloLevel2()->crc));
326      event->clevel2->selftrigger = L2->GetCaloLevel2()->selftrigger;
327      //
328    // Calculate variables common to all tracks (qtot, nstrip, etc.)    // Calculate variables common to all tracks (qtot, nstrip, etc.)
329    //    //
330    if ( debug ) printf("1 Call GetCommonVar() \n");    if ( debug ) printf("1 Call GetCommonVar() \n");
# Line 311  void CaloPreSampler::Process(){ Line 388  void CaloPreSampler::Process(){
388    // conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event    // conditions are: 0) no track from the tracker 1) we have a track fit both in x and y 2) no problems with calo for this event 3) no selftrigger event
389    //    //
390    //  if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){    //  if ( trackanyway && !filled && event->clevel2->npcfit[0] >= 2 && event->clevel2->npcfit[1] >= 2 && event->clevel2->good != 0 && event->clevel2->trigty < 2. ){
391    if ( trackanyway && m3 ){    if ( (trackanyway && m3) || forcecalo ){
392      if ( debug ) printf(" Event with a track not fitted by the tracker \n");      if ( debug ) printf(" Event with a track not fitted by the tracker \n");
393      //      //
394      // Disable "track mode" in the fortran routine      // Disable "track mode" in the fortran routine
# Line 443  void CaloPreSampler::Process(){ Line 520  void CaloPreSampler::Process(){
520        if ( debug ) printf(" Selftrigger: problems with event \n");        if ( debug ) printf(" Selftrigger: problems with event \n");
521      };      };
522    };    };
523    //  //   //
524    // Clear structures used to communicate with fortran  //   // Clear structures used to communicate with fortran
525    //  //   //
526    event->ClearStructs();  //   event->ClearStructs();
527    // ELENA: moved @ beginning
528    //    //
529    //    //
530    //    //
531    if ( debug ) this->Print();    if ( debug ) this->Print();
532    if ( debug ) printf(" exit \n");    if ( debug ) printf(" exit \n");
533    //    //
534  };  }
535    
536    //
537    // Method to add a calorimeter track, evaluated around a tracker track defined by a status vector.
538    // (can be used to evaluate the calorimeter track around an arbitrary axis, by setting the status vector with zero deflection )
539    //
540    //
541    CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag){
542    
543        int ntrkentry = pcalo->ntrk();
544        //
545        for (Int_t nt=0; nt < ntrkentry; nt++){  
546            if( pcalo->GetCaloTrkVar(nt)->trkseqno == trktag){
547                cout << " CaloTrkVar* CaloPreSampler::AddCaloTrkVar(float *al,int trktag)"<<endl;
548                cout << " --> trktag = "<<trktag<<" already defined "<<endl;
549                return NULL;
550            }
551        }
552        //
553        event->clevel1->good2 = 1; //is a trk track
554        event->clevel1->trkchi2 = 0;
555        event->clevel1->hzn = 0;
556        //
557        // Copy the alpha vector in the input structure
558        //
559        for (Int_t e = 0; e < 5 ; e++){
560            event->clevel1->al_p[e][0] = al[e];
561        };    
562        //
563        // Get tracker related variables for this track
564        //
565        if ( debug ) printf("track %i Call GetTrkVar() \n",trktag);
566        event->GetTrkVar();
567        if ( debug ) printf(" event->clevel2->dX0l %f \n",event->clevel2->dX0l);
568        //
569        // Save tracker track sequence number
570        //  
571        event->trkseqno = trktag;
572        //
573        // Copy values in the class ca from the structure clevel2
574        //
575        if ( debug ) printf("track %i Call FillTrkVar() \n",trktag);
576        event->FillTrkVar(pcalo,ntrkentry);
577    
578        return pcalo->GetCaloTrkVar(ntrkentry);
579        
580    
581    };//ELENA

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23